index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. <template>
  2. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  3. <a-form ref="searchFormRef" name="advanced_search" :model="searchFormState" class="ant-advanced-search-form">
  4. <a-row :gutter="24">
  5. <a-col :span="6">
  6. <a-form-item label="客户" name="customerName">
  7. <a-input v-model:value="searchFormState.customerName" placeholder="查询客户名称" allow-clear />
  8. </a-form-item>
  9. </a-col>
  10. <a-col :span="6">
  11. <a-button type="primary" @click="tableRef.refresh()">查询</a-button>
  12. <a-button style="margin: 0 8px" @click="reset">重置</a-button>
  13. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizServiceCustomerAdd')">
  14. <template #icon><plus-outlined /></template>
  15. 新增
  16. </a-button>
  17. </a-col>
  18. </a-row>
  19. </a-form>
  20. </a-card>
  21. <a-card :bordered="false" style="margin-bottom: 10px" class="mb-2">
  22. <s-table
  23. ref="tableRef"
  24. :columns="columns"
  25. :data="loadData"
  26. bordered
  27. :row-key="(record) => record.id"
  28. >
  29. <template #bodyCell="{ column, record, index }">
  30. <template v-if="column.dataIndex === 'serial'">
  31. {{ index + 1 }}
  32. </template>
  33. <template v-if="column.dataIndex === 'action'">
  34. <a-space>
  35. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizServiceCustomerEdit')">编辑</a>
  36. <a-divider type="vertical" v-if="hasPerm(['bizServiceCustomerEdit', 'bizServiceCustomerDelete'], 'and')" />
  37. <a-button type="link" danger size="small" v-if="hasPerm('bizServiceCustomerDelete')" @click="deleteConfig(record)">删除</a-button>
  38. <a-divider type="vertical" v-if="hasPerm(['bizServiceCustomerEdit', 'bizServiceCustomerDelete'], 'or') && hasPerm('bizServiceCustomerAccount')" />
  39. <a @click="accountIndexRef.onOpen(record)" v-if="hasPerm('bizServiceCustomerAccount')">账户管理</a>
  40. </a-space>
  41. </template>
  42. </template>
  43. </s-table>
  44. </a-card>
  45. <Form ref="formRef" @successful="tableRef.refresh()" />
  46. <AccountIndex ref="accountIndexRef" @successful="tableRef.refresh()" />
  47. </template>
  48. <script setup name="bizservicecustomer">
  49. import { cloneDeep } from 'lodash-es'
  50. import Form from './form.vue'
  51. import AccountIndex from './accountIndex.vue'
  52. import bizServiceCustomerApi from '@/api/biz/bizServiceCustomerApi'
  53. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  54. import {Modal} from 'ant-design-vue';
  55. import {createVNode} from 'vue';
  56. const searchFormState = ref({})
  57. const searchFormRef = ref()
  58. const tableRef = ref()
  59. const formRef = ref()
  60. const accountIndexRef = ref()
  61. const submitLoading = ref(false)
  62. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  63. const columns = [
  64. {
  65. title: '序号',
  66. width: 50,
  67. dataIndex: 'serial',
  68. align:'center'
  69. },
  70. {
  71. title: '客户名称',
  72. width: 180,
  73. dataIndex: 'name',
  74. align: 'center'
  75. },
  76. {
  77. title: '联系人',
  78. width: 180,
  79. dataIndex: 'contact',
  80. align: 'center'
  81. },
  82. {
  83. title: '手机号',
  84. width: 180,
  85. dataIndex: 'phone',
  86. align: 'center'
  87. },
  88. {
  89. title: '客户地址',
  90. dataIndex: 'address',
  91. align: 'center'
  92. },
  93. {
  94. title: '创建时间',
  95. width: 180,
  96. dataIndex: 'createTime',
  97. align: 'center'
  98. },
  99. ]
  100. // 操作栏通过权限判断是否显示
  101. if (hasPerm(['bizServiceCustomerEdit', 'bizServiceCustomerDelete', 'bizServiceCustomerAccount'], 'or')) {
  102. columns.push({
  103. title: '操作',
  104. dataIndex: 'action',
  105. align: 'center',
  106. width: 260
  107. })
  108. }
  109. const loadData = (parameter) => {
  110. const searchFormParam = cloneDeep(searchFormState.value)
  111. return bizServiceCustomerApi.bizServiceCustomerPage(Object.assign(parameter, searchFormParam)).then((data) => {
  112. return data
  113. })
  114. }
  115. // 重置
  116. const reset = () => {
  117. searchFormRef.value.resetFields()
  118. tableRef.value.refresh(true)
  119. }
  120. // 删除
  121. const deleteConfig = (record) => {
  122. Modal.confirm({
  123. title: '确定删除该数据吗?',
  124. icon: createVNode(ExclamationCircleOutlined),
  125. content: '',
  126. onOk() {
  127. submitLoading.value = true
  128. let params = [
  129. {
  130. id: record.id
  131. }
  132. ]
  133. bizServiceCustomerApi
  134. .bizServiceCustomerDelete(params)
  135. .then(() => {
  136. tableRef.value.refresh(true)
  137. })
  138. .finally(() => {
  139. submitLoading.value = false
  140. })
  141. },
  142. onCancel() {}
  143. })
  144. }
  145. </script>