customer.vue 4.9 KB

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