customer.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. <template>
  2. <div>
  3. <div class="search-term">
  4. <el-form :inline="true" :model="searchInfo" class="demo-form-inline">
  5. <el-form-item>
  6. <el-button @click="openDialog" type="primary">新增客户</el-button>
  7. </el-form-item>
  8. </el-form>
  9. </div>
  10. <el-table
  11. :data="tableData"
  12. border
  13. ref="multipleTable"
  14. stripe
  15. style="width: 100%"
  16. tooltip-effect="dark"
  17. >
  18. <el-table-column type="selection" width="55"></el-table-column>
  19. <el-table-column label="接入日期" width="180">
  20. <template slot-scope="scope">{{ scope.row.CreatedAt|formatDate }}</template>
  21. </el-table-column>
  22. <el-table-column label="姓名" prop="customerName" width="120"></el-table-column>
  23. <el-table-column label="电话" prop="customerPhoneData" width="120"></el-table-column>
  24. <el-table-column label="接入人ID" prop="sysUserId" width="120"></el-table-column>
  25. <el-table-column label="按钮组">
  26. <template slot-scope="scope">
  27. <el-button @click="updateCustomer(scope.row)" size="small" type="text">变更</el-button>
  28. <el-popover placement="top" width="160" v-model="scope.row.visible">
  29. <p>确定要删除吗?</p>
  30. <div style="text-align: right; margin: 0">
  31. <el-button size="mini" type="text" @click="scope.row.visible = false">取消</el-button>
  32. <el-button type="primary" size="mini" @click="deleteCustomer(scope.row)">确定</el-button>
  33. </div>
  34. <el-button type="text" size="mini" slot="reference">删除</el-button>
  35. </el-popover>
  36. </template>
  37. </el-table-column>
  38. </el-table>
  39. <el-pagination
  40. :current-page="page"
  41. :page-size="pageSize"
  42. :page-sizes="[10, 30, 50, 100]"
  43. :style="{float:'right',padding:'20px'}"
  44. :total="total"
  45. @current-change="handleCurrentChange"
  46. @size-change="handleSizeChange"
  47. layout="total, sizes, prev, pager, next, jumper"
  48. ></el-pagination>
  49. <el-dialog :before-close="closeDialog" :visible.sync="dialogFormVisible" title="新增Api">
  50. <el-form :inline="true" :model="form" label-width="80px">
  51. <el-form-item label="客户名">
  52. <el-input autocomplete="off" v-model="form.customerName"></el-input>
  53. </el-form-item>
  54. <el-form-item label="客户电话">
  55. <el-input autocomplete="off" v-model="form.customerPhoneData"></el-input>
  56. </el-form-item>
  57. </el-form>
  58. <div class="dialog-footer" slot="footer">
  59. <el-button @click="closeDialog">取 消</el-button>
  60. <el-button @click="enterDialog" type="primary">确 定</el-button>
  61. </div>
  62. </el-dialog>在资源权限中将此角色的资源权限清空 或者不包含创建者的角色 即可屏蔽此客户资源的显示
  63. </div>
  64. </template>
  65. <script>
  66. import {
  67. createExaCustomer,
  68. updateExaCustomer,
  69. deleteExaCustomer,
  70. getExaCustomer,
  71. getExaCustomerList
  72. } from "@/api/customer";
  73. import { formatTimeToStr } from "@/utils/data";
  74. import infoList from "@/components/mixins/infoList";
  75. export default {
  76. name: "Customer",
  77. mixins: [infoList],
  78. data() {
  79. return {
  80. listApi: getExaCustomerList,
  81. dialogFormVisible: false,
  82. visible: false,
  83. type: "",
  84. form: {
  85. customerName: "",
  86. customerPhoneData: ""
  87. }
  88. };
  89. },
  90. filters: {
  91. formatDate: function(time) {
  92. if (time != null && time != "") {
  93. var date = new Date(time);
  94. return formatTimeToStr(date, "yyyy-MM-dd hh:mm:ss");
  95. } else {
  96. return "";
  97. }
  98. }
  99. },
  100. methods: {
  101. async updateCustomer(row) {
  102. const res = await getExaCustomer({ ID: row.ID });
  103. this.type = "update";
  104. if (res.code == 0) {
  105. this.form = res.data.customer;
  106. this.dialogFormVisible = true;
  107. }
  108. },
  109. closeDialog() {
  110. this.dialogFormVisible = false;
  111. this.form = {
  112. customerName: "",
  113. customerPhoneData: ""
  114. };
  115. },
  116. async deleteCustomer(row) {
  117. this.visible = false;
  118. const res = await deleteExaCustomer({ ID: row.ID });
  119. if (res.code == 0) {
  120. this.$message({
  121. type: "success",
  122. message: "删除成功"
  123. });
  124. this.getTableData();
  125. }
  126. },
  127. async enterDialog() {
  128. let res;
  129. switch (this.type) {
  130. case "create":
  131. res = await createExaCustomer(this.form);
  132. break;
  133. case "update":
  134. res = await updateExaCustomer(this.form);
  135. break;
  136. default:
  137. res = await createExaCustomer(this.form);
  138. break;
  139. }
  140. if (res.code == 0) {
  141. this.closeDialog();
  142. this.getTableData();
  143. }
  144. },
  145. openDialog() {
  146. this.type = "create";
  147. this.dialogFormVisible = true;
  148. }
  149. },
  150. created() {
  151. this.getTableData();
  152. }
  153. };
  154. </script>
  155. <style>
  156. </style>