index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  58. import {Modal} from 'ant-design-vue';
  59. import {createVNode} from 'vue';
  60. const searchFormState = ref({})
  61. const searchFormRef = ref()
  62. const tableRef = ref()
  63. const formRef = ref()
  64. const userIndexRef = ref()
  65. const timeIndexRef = ref()
  66. const toolConfig = { refresh: true, height: true, columnSetting: true, striped: false }
  67. const columns = [
  68. {
  69. title: '序号',
  70. width: 50,
  71. dataIndex: 'serial',
  72. align:'center'
  73. },
  74. {
  75. title: '装货点位',
  76. dataIndex: 'loadPoint',
  77. align: 'center'
  78. },
  79. {
  80. title: '创建时间',
  81. dataIndex: 'createTime',
  82. align: 'center'
  83. },
  84. ]
  85. // 操作栏通过权限判断是否显示
  86. if (hasPerm(['bizLoadPointEdit', 'bizLoadPointDelete', 'bizLoadUser', 'bizLoadTime'], 'or')) {
  87. columns.push({
  88. title: '操作',
  89. dataIndex: 'action',
  90. align: 'center',
  91. width: 320
  92. })
  93. }
  94. const selectedRowKeys = ref([])
  95. // 列表选择配置
  96. const options = {
  97. // columns数字类型字段加入 needTotal: true 可以勾选自动算账
  98. alert: {
  99. show: true,
  100. clear: () => {
  101. selectedRowKeys.value = ref([])
  102. }
  103. },
  104. rowSelection: {
  105. onChange: (selectedRowKey, selectedRows) => {
  106. selectedRowKeys.value = selectedRowKey
  107. }
  108. }
  109. }
  110. const loadData = (parameter) => {
  111. const searchFormParam = cloneDeep(searchFormState.value)
  112. return bizLoadPointApi.bizLoadPointPage(Object.assign(parameter, searchFormParam)).then((data) => {
  113. return data
  114. })
  115. }
  116. // 重置
  117. const reset = () => {
  118. searchFormRef.value.resetFields()
  119. tableRef.value.refresh(true)
  120. }
  121. // 删除
  122. const deleteConfig = (record) => {
  123. Modal.confirm({
  124. title: '确定删除该数据吗?',
  125. icon: createVNode(ExclamationCircleOutlined),
  126. content: '',
  127. onOk() {
  128. submitLoading.value = true
  129. let params = [
  130. {
  131. id: record.id
  132. }
  133. ]
  134. bizLoadPointApi
  135. .bizLoadPointDelete(params)
  136. .then(() => {
  137. tableRef.value.refresh(true)
  138. })
  139. .finally(() => {
  140. submitLoading.value = false
  141. })
  142. },
  143. onCancel() {}
  144. })
  145. }
  146. </script>