customer.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  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="按钮组" min-width="160">
  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="danger" icon="el-icon-delete" 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="客户">
  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 class="tips">在资源权限中将此角色的资源权限清空 或者不包含创建者的角色 即可屏蔽此客户资源的显示</div>
  64. </div>
  65. </template>
  66. <script>
  67. import {
  68. createExaCustomer,
  69. updateExaCustomer,
  70. deleteExaCustomer,
  71. getExaCustomer,
  72. getExaCustomerList
  73. } from "@/api/customer";
  74. import { formatTimeToStr } from "@/utils/date";
  75. import infoList from "@/mixins/infoList";
  76. export default {
  77. name: "Customer",
  78. mixins: [infoList],
  79. data() {
  80. return {
  81. listApi: getExaCustomerList,
  82. dialogFormVisible: 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. row.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. if (this.tableData.length == 1) {
  125. this.page--;
  126. }
  127. this.getTableData();
  128. }
  129. },
  130. async enterDialog() {
  131. let res;
  132. switch (this.type) {
  133. case "create":
  134. res = await createExaCustomer(this.form);
  135. break;
  136. case "update":
  137. res = await updateExaCustomer(this.form);
  138. break;
  139. default:
  140. res = await createExaCustomer(this.form);
  141. break;
  142. }
  143. if (res.code == 0) {
  144. this.closeDialog();
  145. this.getTableData();
  146. }
  147. },
  148. openDialog() {
  149. this.type = "create";
  150. this.dialogFormVisible = true;
  151. }
  152. },
  153. created() {
  154. this.getTableData();
  155. }
  156. };
  157. </script>
  158. <style>
  159. </style>