transportIndex.vue 3.4 KB

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