accountIndex.vue 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <a-drawer title="客户账号管理" :width="650" :open="visible" :destroy-on-close="true" @close="onClose">
  3. <s-table
  4. ref="tableRef"
  5. :columns="columns"
  6. :data="loadData"
  7. :alert="false"
  8. :row-key="(record) => record.id"
  9. :tool-config="toolConfig"
  10. >
  11. <template #operator class="table-operator">
  12. <a-button type="primary" v-if="hasPerm('customerAccountAdd')" @click="accountAddForm.onOpen(recordData)">
  13. <template #icon>
  14. <plus-outlined />
  15. </template>
  16. <span>新增账号</span>
  17. </a-button>
  18. </template>
  19. <template #bodyCell="{ column, record, index }">
  20. <template v-if="column.dataIndex === 'serial'">
  21. {{ index + 1 }}
  22. </template>
  23. <template v-if="column.dataIndex === 'action'">
  24. <a-space>
  25. <a-button type="link" danger size="small" v-if="hasPerm('customerAccountDelete')" @click="deleteConfig(record)">删除</a-button>
  26. </a-space>
  27. </template>
  28. </template>
  29. </s-table>
  30. </a-drawer>
  31. <AccountAddForm ref="accountAddForm" @successful="tableRef.refresh(true)" />
  32. </template>
  33. <script setup name="accountForm">
  34. import customerAccountApi from '@/api/biz/customerAccountApi'
  35. import AccountAddForm from './accountAdd.vue'
  36. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  37. import {Modal} from 'ant-design-vue';
  38. import {createVNode} from 'vue';
  39. const columns = [
  40. {
  41. title: '序号',
  42. width: 50,
  43. dataIndex: 'serial',
  44. align:'center'
  45. },
  46. {
  47. title: '账号',
  48. align:'center',
  49. dataIndex: 'loginAccount'
  50. },
  51. ]
  52. const submitLoading = ref(false)
  53. const toolConfig = { refresh: true, height: false, columnSetting: false, striped: false }
  54. // 默认是关闭状态
  55. const visible = ref(false)
  56. const searchFormState = ref()
  57. const accountAddForm = ref()
  58. const recordData = ref()
  59. const tableRef = ref()
  60. // 操作栏通过权限判断是否显示
  61. if (hasPerm(['customerAccountDelete'])) {
  62. columns.push({
  63. title: '操作',
  64. dataIndex: 'action',
  65. align: 'center',
  66. width: 150
  67. })
  68. }
  69. // 打开抽屉
  70. const onOpen = (record) => {
  71. recordData.value = record
  72. searchFormState.value = {
  73. customerId: record.id
  74. }
  75. visible.value = true
  76. }
  77. // 加载字段数据
  78. const loadData = (parameter) => {
  79. return customerAccountApi.customerAccountPage(Object.assign(parameter, searchFormState.value)).then((res) => {
  80. return res
  81. })
  82. }
  83. // 关闭抽屉
  84. const onClose = () => {
  85. visible.value = false
  86. }
  87. // 删除
  88. const deleteConfig = (record) => {
  89. Modal.confirm({
  90. title: '确定删除该数据吗?',
  91. icon: createVNode(ExclamationCircleOutlined),
  92. content: '',
  93. onOk() {
  94. submitLoading.value = true
  95. let params = [
  96. {
  97. id: record.id
  98. }
  99. ]
  100. customerAccountApi
  101. .customerAccountDelete(params)
  102. .then(() => {
  103. tableRef.value.refresh(true)
  104. })
  105. .finally(() => {
  106. submitLoading.value = false
  107. })
  108. },
  109. onCancel() {}
  110. })
  111. }
  112. // 调用这个函数将子组件的一些数据和方法暴露出去
  113. defineExpose({
  114. onOpen
  115. })
  116. </script>
  117. <style scoped>
  118. </style>