|
|
|
@ -5,35 +5,25 @@
@@ -5,35 +5,25 @@
|
|
|
|
|
@expand="onExpandClick" |
|
|
|
|
> |
|
|
|
|
<template #toolbar> |
|
|
|
|
<a-button |
|
|
|
|
type="primary" |
|
|
|
|
<a-button type="primary" |
|
|
|
|
@click="handleAdd()" |
|
|
|
|
>新增地址</a-button> |
|
|
|
|
<a-button type="default" |
|
|
|
|
@click="expandAll" |
|
|
|
|
>展开全部</a-button> |
|
|
|
|
<a-button type="default" |
|
|
|
|
@click="collapseAll" |
|
|
|
|
>折叠全部</a-button> |
|
|
|
|
>新增区域</a-button> |
|
|
|
|
</template> |
|
|
|
|
<template #action="{ record }"> |
|
|
|
|
<TableAction :actions="[ |
|
|
|
|
{ |
|
|
|
|
label: '编辑', |
|
|
|
|
icon: 'fa6-regular:pen-to-square', |
|
|
|
|
|
|
|
|
|
onClick: handleEdit.bind(null, record) |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: '新增', |
|
|
|
|
icon: 'ant-design:plus-circle-outlined', |
|
|
|
|
|
|
|
|
|
onClick: handleAdd.bind(null, record) |
|
|
|
|
}, |
|
|
|
|
{ |
|
|
|
|
label: '删除', |
|
|
|
|
icon: 'ant-design:delete-outlined', |
|
|
|
|
|
|
|
|
|
color: 'error', |
|
|
|
|
popConfirm: { |
|
|
|
|
title: '是否确认删除', |
|
|
|
@ -43,7 +33,7 @@
@@ -43,7 +33,7 @@
|
|
|
|
|
/> |
|
|
|
|
</template> |
|
|
|
|
</BasicTable> |
|
|
|
|
<DeptModal @register="registerModal" @success="handleRefreshTable"/> |
|
|
|
|
<RegionModal @register="registerModal" @success="handleRefreshTable"/> |
|
|
|
|
</div> |
|
|
|
|
</template> |
|
|
|
|
<script lang="ts" setup> |
|
|
|
@ -55,18 +45,17 @@
@@ -55,18 +45,17 @@
|
|
|
|
|
*/ |
|
|
|
|
import { BasicTable, useTable, TableAction } from '/@/components/Table'; |
|
|
|
|
import { useModal } from '/@/components/Modal'; |
|
|
|
|
import DeptModal from './RegionModal.vue'; |
|
|
|
|
import RegionModal from './RegionModal.vue'; |
|
|
|
|
import { columns, searchFormSchema } from './region.data'; |
|
|
|
|
import {delAddr, getAddr, listAddr} from '/@/api/platform/system/controller/region'; |
|
|
|
|
import { delRegion, listRegion } from '/@/api/platform/system/controller/region'; |
|
|
|
|
import { useMessage } from '/@/hooks/web/useMessage'; |
|
|
|
|
import { listToTree } from '/@/utils/helper/treeHelper'; |
|
|
|
|
|
|
|
|
|
/** 通用变量统一声明区域 */ |
|
|
|
|
const { createMessage } = useMessage(); |
|
|
|
|
const [registerModal, { openModal }] = useModal(); |
|
|
|
|
const [registerTable, { reload, expandAll, collapseAll,getDataSource }] = useTable({ |
|
|
|
|
title: '地址列表', |
|
|
|
|
api: listAddr, |
|
|
|
|
const [registerTable, { reload, getDataSource }] = useTable({ |
|
|
|
|
title: '区域列表', |
|
|
|
|
api: listRegion, |
|
|
|
|
rowKey: 'id', |
|
|
|
|
columns, |
|
|
|
|
formConfig: { |
|
|
|
@ -90,25 +79,13 @@ const [registerTable, { reload, expandAll, collapseAll,getDataSource }] = useTab
@@ -90,25 +79,13 @@ const [registerTable, { reload, expandAll, collapseAll,getDataSource }] = useTab
|
|
|
|
|
slots: { customRender: 'action' }, |
|
|
|
|
fixed: false |
|
|
|
|
}, |
|
|
|
|
// afterFetch: (result) => listToTree(result, { id: 'id' }), |
|
|
|
|
searchInfo: { parentId: '0' } |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function onExpandClick(e, info) { |
|
|
|
|
let reqObj = { |
|
|
|
|
parentId: info.id, // 点击的ID |
|
|
|
|
}; |
|
|
|
|
listAddr(reqObj).then((res) => { |
|
|
|
|
getDataSource().forEach((item) =>{ //重点,根据点击的ID相等,将children 赋值给对应的一级菜单 |
|
|
|
|
if(info.id == item.id){ |
|
|
|
|
item.children = res; |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
listRegion({ parentId: info.id }).then((res) => info.children = res); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** 新增按钮操作,行内新增与工具栏局域新增通用 */ |
|
|
|
|
function handleAdd(record?: Recordable) { |
|
|
|
|
openModal(true,{ _tag: 'add', record }); |
|
|
|
@ -121,7 +98,7 @@ function handleEdit(record: Recordable) {
@@ -121,7 +98,7 @@ function handleEdit(record: Recordable) {
|
|
|
|
|
|
|
|
|
|
/** 删除按钮操作,行内删除 */ |
|
|
|
|
async function handleDel(record: Recordable) { |
|
|
|
|
await delAddr(record.id); |
|
|
|
|
await delRegion(record.id); |
|
|
|
|
createMessage.success('删除成功!'); |
|
|
|
|
handleRefreshTable(); |
|
|
|
|
} |
|
|
|
@ -130,5 +107,4 @@ async function handleDel(record: Recordable) {
@@ -130,5 +107,4 @@ async function handleDel(record: Recordable) {
|
|
|
|
|
function handleRefreshTable() { |
|
|
|
|
reload(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
</script> |
|
|
|
|