index.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  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="loadPoint">
  7. <a-input v-model:value="searchFormState.loadPoint" 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('bizLoadPointAdd')">
  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('bizLoadPointEdit')">编辑</a>
  36. <a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete'], 'and')" />
  37. <a-button type="link" danger size="small" v-if="hasPerm('bizLoadPointDelete')" @click="deleteConfig(record)">删除</a-button>
  38. <a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete'], 'or') && hasPerm('bizLoadUser')" />
  39. <a @click="userIndexRef.onOpen(record)" v-if="hasPerm('bizLoadUser')">装货员</a>
  40. <a-divider type="vertical" v-if="hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete', 'bizLoadUser'], 'or') && hasPerm('bizLoadTime')" />
  41. <a @click="timeIndexRef.onOpen(record)" v-if="hasPerm('bizLoadTime')">装货时间</a>
  42. </a-space>
  43. </template>
  44. </template>
  45. </s-table>
  46. </a-card>
  47. <Form ref="formRef" @successful="tableRef.refresh()" />
  48. <UserIndex ref="userIndexRef" @successful="tableRef.refresh()" />
  49. <TimeIndex ref="timeIndexRef" @successful="tableRef.refresh()" />
  50. </template>
  51. <script setup name="bizloadpoint">
  52. import { cloneDeep } from 'lodash-es'
  53. import Form from './form.vue'
  54. import UserIndex from './userIndex.vue'
  55. import TimeIndex from './timeIndex.vue'
  56. import bizLoadPointApi from '@/api/biz/bizLoadPointApi'
  57. const searchFormState = ref({})
  58. const searchFormRef = ref()
  59. const tableRef = ref()
  60. const formRef = ref()
  61. const userIndexRef = ref()
  62. const timeIndexRef = ref()
  63. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  64. const columns = [
  65. {
  66. title: '序号',
  67. width: 50,
  68. dataIndex: 'serial',
  69. align:'center'
  70. },
  71. {
  72. title: '装货点位',
  73. dataIndex: 'loadPoint',
  74. align: 'center'
  75. },
  76. {
  77. title: '创建时间',
  78. dataIndex: 'createTime',
  79. align: 'center'
  80. },
  81. ]
  82. // 操作栏通过权限判断是否显示
  83. if (hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete', 'bizLoadUser', 'bizLoadTime'], 'or')) {
  84. columns.push({
  85. title: '操作',
  86. dataIndex: 'action',
  87. align: 'center',
  88. width: 320
  89. })
  90. }
  91. const selectedRowKeys = ref([])
  92. // 列表选择配置
  93. const options = {
  94. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  95. alert: {
  96. show: true,
  97. clear: () => {
  98. selectedRowKeys.value = ref([])
  99. }
  100. },
  101. rowSelection: {
  102. onChange: (selectedRowKey, selectedRows) => {
  103. selectedRowKeys.value = selectedRowKey
  104. }
  105. }
  106. }
  107. const loadData = (parameter) => {
  108. const searchFormParam = cloneDeep(searchFormState.value)
  109. return bizLoadPointApi.bizLoadPointPage(Object.assign(parameter, searchFormParam)).then((data) => {
  110. return data
  111. })
  112. }
  113. // 重置
  114. const reset = () => {
  115. searchFormRef.value.resetFields()
  116. tableRef.value.refresh(true)
  117. }
  118. // 删除
  119. const deleteConfig = (record) => {
  120. Modal.confirm({
  121. title: '确定删除该数据吗?',
  122. icon: createVNode(ExclamationCircleOutlined),
  123. content: '',
  124. onOk() {
  125. submitLoading.value = true
  126. let params = [
  127. {
  128. id: record.id
  129. }
  130. ]
  131. customerApi
  132. .customerDelete(params)
  133. .then(() => {
  134. tableRef.value.refresh(true)
  135. })
  136. .finally(() => {
  137. submitLoading.value = false
  138. })
  139. },
  140. onCancel() {}
  141. })
  142. }
  143. </script>