customer.vue 4.7 KB

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