| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- <!-- eslint-disable vue/multi-word-component-names -->
- <template>
- <BasicTable @register="registerMapTable" :rowSelection="rowSelection">
- <template #resetBefore>
- <!-- <a-button type="default" class="ml-8px" preIcon="mdi:download" @click="onExportXls"> 下载 </a-button> -->
- <a-button type="default" class="ml-8px" preIcon="mdi:plus" @click="handleOpenModal({})"> 新增 </a-button>
- </template>
- <template #action="{ record }">
- <button @click="handleGoToPageQuery(record, `/manage/mapView`)" class="action-btn" title=""> 布点 </button>
- <button @click="handleOpenModal(record)" class="action-btn" title="修改">
- <SvgIcon name="edit" />
- </button>
- <!-- 删除按钮 -->
- <Popconfirm
- title="删除确认"
- description="是否确认删除?"
- okText="确认"
- cancelText="取消"
- @confirm="handleDeleteRecord(record)"
- @cancel="handleCancel"
- placement="top"
- >
- <button class="action-btn" title="删除">
- <SvgIcon name="delete" />
- </button>
- </Popconfirm>
- </template>
- </BasicTable>
- <!-- 注册编辑弹框组件 -->
- <MapEditModal @register="registerModal" @success="handleModalSuccess" />
- </template>
- <script setup lang="ts">
- import { computed, onMounted } from 'vue';
- import { useRouter } from 'vue-router';
- import { BasicTable } from '/@/components/Table';
- import { SvgIcon } from '/@/components/Icon';
- import { Popconfirm } from 'ant-design-vue';
- // 引入动态列/表单配置函数 + 类型
- import { getColumns, getSearchFormSchema } from './cad.data';
- import { getMineFileList, deleteMineFile } from './cad.api';
- import { useListPage } from '/@/hooks/system/useListPage';
- // import { useIntervalFn } from '@vueuse/core';
- import { useModal } from '/@/components/Modal';
- import MapEditModal from './components/MapEditModal.vue';
- // 路由实例
- const router = useRouter();
- // 弹框注册
- const [registerModal, { openModal }] = useModal();
- // 生成动态列和搜索表单(computed响应式更新)
- const columns = computed(() => getColumns());
- const searchFormSchema = computed(() => getSearchFormSchema());
- // ========== 表格注册 ==========
- const { tableContext: mapManageTable } = useListPage({
- tableProps: {
- api: getMineFileList, // 数据统计接口
- // dataSource: mockData,
- columns, // 绑定动态列
- rowKey: 'mineCode',
- rowSelection: {
- type: 'checkbox',
- onChange: (selectedRowKeys, selectedRows) => {
- console.log('选中了:', selectedRowKeys, selectedRows);
- },
- },
- formConfig: {
- labelWidth: 120,
- schemas: searchFormSchema.value, // 绑定动态搜索表单
- showAdvancedButton: false,
- schemaGroupNames: ['常规查询'],
- },
- showIndexColumn: false,
- scroll: { x: 'max-content' },
- },
- exportConfig: {
- url: '/ventanaly-province/province/mineData/exportMineData', //后端接口未知
- name: '矿山信息',
- params: {},
- },
- });
- const [registerMapTable, mapTable, { rowSelection }] = mapManageTable;
- // const { pause, resume } = useIntervalFn(() => mapTable.reload({ silence: true }), 60000);
- /**
- * 打开弹框函数
- * @param result 弹框数据
- */
- function handleOpenModal(record: any) {
- openModal(true, { ...record });
- }
- /**
- * 弹框结果处理函数
- * @param result 弹框数据
- */
- async function handleModalSuccess() {
- await mapTable.reload();
- }
- /**
- * 删除记录方法
- * @param record 当前行数据
- */
- async function handleDeleteRecord(record: any) {
- try {
- await deleteMineFile({ id: record.id });
- await mapTable.reload();
- } catch (error) {
- console.error('删除失败:', error);
- }
- }
- function handleGoToPageQuery(record: any, path: string) {
- const mineCode = record.mineCode;
- router.push({
- path,
- state: { mineCode },
- });
- }
- /**
- * 气泡取消按钮通用回调
- */
- function handleCancel() {
- // 取消操作,无逻辑(仅关闭气泡)
- }
- // ========== 初始化 ==========
- onMounted(async () => {});
- </script>
- <style lang="less" scoped>
- .action-btn {
- height: 30px;
- cursor: pointer;
- margin-right: 10px;
- background: none;
- &:last-child {
- margin-right: 0;
- }
- }
- </style>
|