transportIndex.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <template>
  2. <a-drawer :title="title" :width="850" :open="visible" :destroy-on-close="true" @close="onClose">
  3. <a-card :bordered="false" class="mb-2">
  4. <s-table
  5. ref="tableRef"
  6. :columns="columns"
  7. :data="loadData"
  8. bordered
  9. :row-key="(record) => record.id"
  10. >
  11. <template #operator class="table-operator">
  12. <a-space>
  13. <a-button type="primary" @click="formRef.onOpen(null, supplierId)" v-if="hasPerm('bizSupplierTransportAdd')">
  14. <template #icon><plus-outlined /></template>
  15. 新增
  16. </a-button>
  17. </a-space>
  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 === 'transportType'">
  24. {{ $TOOL.dictTypeData('transport_type', record.transportType) }}
  25. </template>
  26. <template v-if="column.dataIndex === 'action'">
  27. <a-space>
  28. <a @click="formRef.onOpen(record, supplierId)" v-if="hasPerm('bizSupplierTransportEdit')">编辑</a>
  29. <a-divider type="vertical" v-if="hasPerm(['bizSupplierTransportEdit', 'bizSupplierTransportDelete'], 'and')" />
  30. <a-button type="link" danger size="small" v-if="hasPerm('bizSupplierTransportDelete')" @click="deleteConfig(record)">删除</a-button>
  31. </a-space>
  32. </template>
  33. </template>
  34. </s-table>
  35. </a-card>
  36. </a-drawer>
  37. <Form ref="formRef" @successful="tableRef.refresh()" />
  38. </template>
  39. <script setup name="bizsuppliertransport">
  40. import { cloneDeep } from 'lodash-es'
  41. import Form from './transportForm.vue'
  42. import bizSupplierTransportApi from '@/api/biz/bizSupplierTransportApi'
  43. import {ExclamationCircleOutlined} from '@ant-design/icons-vue';
  44. import {Modal} from 'ant-design-vue';
  45. import {createVNode} from 'vue';
  46. const submitLoading = ref(false)
  47. const toolConfig = { refresh: true, height: false, columnSetting: false, striped: false }
  48. // 默认是关闭状态
  49. const visible = ref(false)
  50. const searchFormState = ref({})
  51. const tableRef = ref()
  52. const formRef = ref()
  53. const recordData = ref()
  54. const title = ref()
  55. const supplierId = ref()
  56. const columns = [
  57. {
  58. title: '序号',
  59. width: 50,
  60. dataIndex: 'serial',
  61. align:'center'
  62. },
  63. {
  64. title: '运输类型',
  65. dataIndex: 'transportType',
  66. align: 'center',
  67. },
  68. {
  69. title: '运输号',
  70. dataIndex: 'transportNo',
  71. align: 'center',
  72. },
  73. {
  74. title: '创建时间',
  75. dataIndex: 'createTime',
  76. align: 'center'
  77. },
  78. ]
  79. // 操作栏通过权限判断是否显示
  80. if (hasPerm(['bizSupplierTransportEdit', 'bizSupplierTransportDelete'])) {
  81. columns.push({
  82. title: '操作',
  83. dataIndex: 'action',
  84. align: 'center',
  85. width: 150
  86. })
  87. }
  88. // 打开抽屉
  89. const onOpen = (record) => {
  90. recordData.value = record
  91. title.value = "【" + record.supplierName + "】-运输车辆/船舶管理"
  92. searchFormState.value = {
  93. supplierId: record.id
  94. }
  95. supplierId.value = record.id
  96. visible.value = true
  97. }
  98. const loadData = (parameter) => {
  99. return bizSupplierTransportApi.bizSupplierTransportPage(Object.assign(parameter, searchFormState.value)).then((data) => {
  100. return data
  101. })
  102. }
  103. // 关闭抽屉
  104. const onClose = () => {
  105. visible.value = false
  106. }
  107. // 删除
  108. const deleteConfig = (record) => {
  109. Modal.confirm({
  110. title: '确定删除该数据吗?',
  111. icon: createVNode(ExclamationCircleOutlined),
  112. content: '',
  113. onOk() {
  114. submitLoading.value = true
  115. let params = [
  116. {
  117. id: record.id
  118. }
  119. ]
  120. bizLoadTimeApi
  121. .bizLoadTimeDelete(params)
  122. .then(() => {
  123. tableRef.value.refresh(true)
  124. })
  125. .finally(() => {
  126. submitLoading.value = false
  127. })
  128. },
  129. onCancel() {}
  130. })
  131. }
  132. // 调用这个函数将子组件的一些数据和方法暴露出去
  133. defineExpose({
  134. onOpen
  135. })
  136. </script>