loadUserIndex.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <template>
  2. <a-card :bordered="false">
  3. <s-table
  4. ref="tableRef"
  5. :columns="columns"
  6. :data="loadData"
  7. :alert="options.alert.show"
  8. bordered
  9. :row-key="(record) => record.id"
  10. :tool-config="toolConfig"
  11. :row-selection="options.rowSelection"
  12. >
  13. <template #operator class="table-operator">
  14. <a-space>
  15. <a-button type="primary" @click="formRef.onOpen()" v-if="hasPerm('bizLoadUserAdd')">
  16. <template #icon><plus-outlined /></template>
  17. 新增
  18. </a-button>
  19. <xn-batch-button
  20. v-if="hasPerm('bizLoadUserBatchDelete')"
  21. buttonName="批量删除"
  22. icon="DeleteOutlined"
  23. :selectedRowKeys="selectedRowKeys"
  24. @batchCallBack="deleteBatchBizLoadUser"
  25. />
  26. </a-space>
  27. </template>
  28. <template #bodyCell="{ column, record }">
  29. <template v-if="column.dataIndex === 'action'">
  30. <a-space>
  31. <a @click="formRef.onOpen(record)" v-if="hasPerm('bizLoadUserEdit')">编辑</a>
  32. <a-divider type="vertical" v-if="hasPerm(['bizLoadUserEdit', 'bizLoadUserDelete'], 'and')" />
  33. <a-button type="link" danger size="small" v-if="hasPerm('bizLoadUserDelete')" @click="deleteConfig(record)">删除</a-button>
  34. </a-space>
  35. </template>
  36. </template>
  37. </s-table>
  38. </a-card>
  39. <Form ref="formRef" @successful="tableRef.refresh()" />
  40. </template>
  41. <script setup name="bizloaduser">
  42. import { cloneDeep } from 'lodash-es'
  43. import Form from './loadUserForm.vue'
  44. import bizLoadUserApi from '@/api/biz/bizLoadUserApi'
  45. const searchFormState = ref({})
  46. const searchFormRef = ref()
  47. const tableRef = ref()
  48. const formRef = ref()
  49. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  50. const columns = [
  51. {
  52. title: '装货点位id',
  53. dataIndex: 'loadId'
  54. },
  55. {
  56. title: '点位人员信息',
  57. dataIndex: 'userId'
  58. },
  59. ]
  60. // 操作栏通过权限判断是否显示
  61. if (hasPerm(['bizLoadUserEdit', 'bizLoadUserDelete'])) {
  62. columns.push({
  63. title: '操作',
  64. dataIndex: 'action',
  65. align: 'center',
  66. width: 150
  67. })
  68. }
  69. const selectedRowKeys = ref([])
  70. // 列表选择配置
  71. const options = {
  72. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  73. alert: {
  74. show: true,
  75. clear: () => {
  76. selectedRowKeys.value = ref([])
  77. }
  78. },
  79. rowSelection: {
  80. onChange: (selectedRowKey, selectedRows) => {
  81. selectedRowKeys.value = selectedRowKey
  82. }
  83. }
  84. }
  85. const loadData = (parameter) => {
  86. const searchFormParam = cloneDeep(searchFormState.value)
  87. return bizLoadUserApi.bizLoadUserPage(Object.assign(parameter, searchFormParam)).then((data) => {
  88. return data
  89. })
  90. }
  91. // 重置
  92. const reset = () => {
  93. searchFormRef.value.resetFields()
  94. tableRef.value.refresh(true)
  95. }
  96. // 删除
  97. const deleteConfig = (record) => {
  98. Modal.confirm({
  99. title: '确定删除该数据吗?',
  100. icon: createVNode(ExclamationCircleOutlined),
  101. content: '',
  102. onOk() {
  103. submitLoading.value = true
  104. let params = [
  105. {
  106. id: record.id
  107. }
  108. ]
  109. customerApi
  110. .customerDelete(params)
  111. .then(() => {
  112. tableRef.value.refresh(true)
  113. })
  114. .finally(() => {
  115. submitLoading.value = false
  116. })
  117. },
  118. onCancel() {}
  119. })
  120. }
  121. </script>