index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <MapView v-if="showCAD" class="w-full h-full" v-bind="selected" @close="showCAD = false"></MapView>
  4. <BasicTable v-else @register="registerMapTable">
  5. <template #resetBefore>
  6. <!-- <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 下载 </a-button> -->
  7. <a-button type="default" class="ml-8px" preIcon="mdi:plus" @click="handleOpenModal({})"> 新增 </a-button>
  8. </template>
  9. <template #action="{ record }">
  10. <button @click="handleGoToPageQuery(record)" class="action-btn" title=""> 布点 </button>
  11. <button @click="handleOpenModal(record)" class="action-btn" title="修改">
  12. <SvgIcon name="edit" />
  13. </button>
  14. <!-- 删除按钮 -->
  15. <Popconfirm
  16. title="删除确认"
  17. description="是否确认删除?"
  18. okText="确认"
  19. cancelText="取消"
  20. @confirm="handleDeleteRecord(record)"
  21. @cancel="handleCancel"
  22. placement="top"
  23. >
  24. <button class="action-btn" title="删除">
  25. <SvgIcon name="delete" />
  26. </button>
  27. </Popconfirm>
  28. </template>
  29. </BasicTable>
  30. <!-- 注册编辑弹框组件 -->
  31. <MapEditModal @register="registerModal" @success="handleModalSuccess" />
  32. </template>
  33. <script setup lang="ts">
  34. import { computed, ref } from 'vue';
  35. // import { useRouter } from 'vue-router';
  36. import { BasicTable } from '/@/components/Table';
  37. import { SvgIcon } from '/@/components/Icon';
  38. import { message, Popconfirm } from 'ant-design-vue';
  39. // 引入动态列/表单配置函数 + 类型
  40. import { getColumns, getSearchFormSchema } from './cad.data';
  41. import { getMineFileList, deleteMineFile } from './cad.api';
  42. import { useListPage } from '/@/hooks/system/useListPage';
  43. // import { useIntervalFn } from '@vueuse/core';
  44. import { useModal } from '/@/components/Modal';
  45. import MapEditModal from './components/MapEditModal.vue';
  46. import MapView from './components/MapView.vue';
  47. // 弹框注册
  48. const [registerModal, { openModal }] = useModal();
  49. // 生成动态列和搜索表单(computed响应式更新)
  50. const columns = computed(() => getColumns());
  51. const searchFormSchema = computed(() => getSearchFormSchema());
  52. // ========== 表格注册 ==========
  53. const { tableContext: mapManageTable } = useListPage({
  54. tableProps: {
  55. api: getMineFileList, // 数据统计接口
  56. // dataSource: mockData,
  57. columns, // 绑定动态列
  58. rowKey: 'mineCode',
  59. formConfig: {
  60. labelWidth: 120,
  61. schemas: searchFormSchema.value, // 绑定动态搜索表单
  62. showAdvancedButton: false,
  63. schemaGroupNames: ['常规查询'],
  64. },
  65. showIndexColumn: false,
  66. scroll: { x: 'max-content' },
  67. },
  68. exportConfig: {
  69. url: '/ventanaly-province/province/mineData/exportMineData', //后端接口未知
  70. name: '矿山信息',
  71. params: {},
  72. },
  73. });
  74. const [registerMapTable, mapTable] = mapManageTable;
  75. // const { pause, resume } = useIntervalFn(() => mapTable.reload({ silence: true }), 60000);
  76. /**
  77. * 打开弹框函数
  78. * @param result 弹框数据
  79. */
  80. function handleOpenModal(record: any) {
  81. openModal(true, { ...record });
  82. }
  83. /**
  84. * 弹框结果处理函数
  85. * @param result 弹框数据
  86. */
  87. async function handleModalSuccess() {
  88. await mapTable.reload();
  89. }
  90. /**
  91. * 删除记录方法
  92. * @param record 当前行数据
  93. */
  94. async function handleDeleteRecord(record: any) {
  95. await deleteMineFile({ id: record.id });
  96. message.success('删除成功');
  97. await mapTable.reload();
  98. }
  99. function handleGoToPageQuery(record: any) {
  100. selected.value = record;
  101. showCAD.value = true;
  102. // router.push({
  103. // path,
  104. // query: {
  105. // mineCode: record.mineCode,
  106. // wjId: record.wjId,
  107. // },
  108. // });
  109. }
  110. /**
  111. * 气泡取消按钮通用回调
  112. */
  113. function handleCancel() {
  114. // 取消操作,无逻辑(仅关闭气泡)
  115. }
  116. const showCAD = ref(false);
  117. const selected = ref();
  118. </script>
  119. <style lang="less" scoped>
  120. .action-btn {
  121. height: 30px;
  122. cursor: pointer;
  123. margin-right: 10px;
  124. background: none;
  125. &:last-child {
  126. margin-right: 0;
  127. }
  128. }
  129. </style>