2025-03-03 16:50:51 +08:00
|
|
|
<template>
|
2025-03-04 16:24:17 +08:00
|
|
|
<CustomCard>
|
|
|
|
<div>
|
|
|
|
<el-row :gutter="20">
|
2025-03-14 17:33:44 +08:00
|
|
|
<el-col :span="4">
|
2025-03-20 09:16:17 +01:00
|
|
|
<!-- <el-tree
|
2025-03-11 15:58:05 +08:00
|
|
|
style="max-width: 600px"
|
|
|
|
:data="typeTree"
|
|
|
|
node-key="areaCode"
|
|
|
|
:props="{ children: 'areaChildVOS', label: 'areaName' }"
|
|
|
|
@node-click="handleNodeClick"
|
2025-03-20 09:16:17 +01:00
|
|
|
/> -->
|
|
|
|
<custom-table-tree title="行政区域" :data="typeTree" :option="treeOption" @node-click="handleNodeClick" />
|
2025-03-04 16:24:17 +08:00
|
|
|
</el-col>
|
2025-03-14 17:33:44 +08:00
|
|
|
<el-col :span="20">
|
2025-03-04 16:24:17 +08:00
|
|
|
<avue-crud
|
|
|
|
ref="crudRef"
|
|
|
|
v-model="state.form"
|
|
|
|
v-model:search="state.query"
|
|
|
|
v-model:page="state.pageData"
|
|
|
|
:table-loading="state.loading"
|
|
|
|
:data="state.data"
|
|
|
|
:option="state.options"
|
|
|
|
@refresh-change="refreshChange"
|
|
|
|
@search-reset="searchChange"
|
|
|
|
@search-change="searchChange"
|
|
|
|
@selection-change="selectionChange"
|
|
|
|
@current-change="currentChange"
|
|
|
|
@size-change="sizeChange"
|
|
|
|
@row-del="rowDel"
|
|
|
|
>
|
|
|
|
<template #menu-left>
|
|
|
|
<el-button type="primary" icon="Plus" @click="onAdd">新增</el-button>
|
|
|
|
<el-button type="success" icon="download" @click="onExport">导出</el-button>
|
|
|
|
</template>
|
|
|
|
|
|
|
|
<template #menu="scope">
|
|
|
|
<custom-table-operate :actions="state.options.actions" :data="scope" />
|
|
|
|
</template>
|
|
|
|
</avue-crud>
|
|
|
|
</el-col>
|
|
|
|
</el-row>
|
|
|
|
</div>
|
|
|
|
</CustomCard>
|
2025-03-03 16:50:51 +08:00
|
|
|
</template>
|
2025-03-04 16:24:17 +08:00
|
|
|
<script setup>
|
|
|
|
import { ref, reactive, onMounted } from 'vue';
|
|
|
|
import { useApp } from '@/hooks';
|
|
|
|
import { CRUD_OPTIONS } from '@/config';
|
|
|
|
import CustomCard from '@/components/CustomCard.vue';
|
2025-03-06 16:20:26 +08:00
|
|
|
import { useUserStore } from '@/store/modules/user';
|
2025-03-11 15:58:05 +08:00
|
|
|
import { getRegion } from '@/apis/index';
|
2025-03-04 16:24:17 +08:00
|
|
|
|
|
|
|
const { VITE_APP_BASE_API } = import.meta.env;
|
|
|
|
const app = useApp();
|
2025-03-06 16:20:26 +08:00
|
|
|
const UserStore = useUserStore();
|
2025-03-04 16:24:17 +08:00
|
|
|
|
|
|
|
/* --------------- data --------------- */
|
|
|
|
// #region
|
2025-03-06 16:20:26 +08:00
|
|
|
|
|
|
|
const crudRef = ref(null);
|
2025-03-04 16:24:17 +08:00
|
|
|
const state = reactive({
|
|
|
|
loading: false,
|
|
|
|
query: {
|
|
|
|
current: 1,
|
|
|
|
size: 10,
|
|
|
|
},
|
|
|
|
form: {},
|
|
|
|
selection: [],
|
|
|
|
options: {
|
|
|
|
...CRUD_OPTIONS,
|
|
|
|
addBtnText: '',
|
|
|
|
addBtn: false,
|
|
|
|
column: [
|
2025-03-06 16:20:26 +08:00
|
|
|
{ label: '编号', prop: 'gridManager', addDisplay: false, editDisplay: false },
|
|
|
|
{
|
|
|
|
label: '所属上级',
|
|
|
|
prop: 'villageCode',
|
|
|
|
type: 'cascader',
|
|
|
|
checkStrictly: true,
|
|
|
|
props: {
|
|
|
|
label: 'areaName',
|
|
|
|
value: 'areaCode',
|
|
|
|
children: 'areaChildVOS',
|
|
|
|
},
|
|
|
|
dicUrl: `${VITE_APP_BASE_API}/system/area/region?areaCode=530000`,
|
|
|
|
dicHeaders: {
|
|
|
|
authorization: UserStore.token,
|
|
|
|
},
|
|
|
|
dicFormatter: (res) => res.data ?? [],
|
|
|
|
rules: [
|
|
|
|
{
|
|
|
|
required: true,
|
|
|
|
message: '请选择',
|
|
|
|
trigger: 'blur',
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{ label: '名称', prop: 'gridManager' },
|
|
|
|
{ label: '状态', prop: 'gridManager', addDisplay: false, editDisplay: false },
|
2025-03-04 16:24:17 +08:00
|
|
|
],
|
|
|
|
actions: [
|
|
|
|
{
|
|
|
|
name: (row) => getStatusButtonText(row.status),
|
|
|
|
icon: 'edit',
|
|
|
|
event: ({ row }) => rowStatus(row),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
name: '编辑',
|
|
|
|
icon: 'edit',
|
|
|
|
event: ({ row }) => rowEdit(row),
|
|
|
|
},
|
|
|
|
{
|
|
|
|
type: 'danger',
|
|
|
|
name: '删除',
|
|
|
|
icon: 'delete',
|
|
|
|
event: ({ row }) => rowDel(row),
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
pageData: {
|
|
|
|
total: 0,
|
|
|
|
currentPage: 1,
|
|
|
|
pageSize: 10,
|
|
|
|
},
|
|
|
|
data: [],
|
|
|
|
currentRow: {},
|
|
|
|
});
|
|
|
|
|
2025-03-20 09:16:17 +01:00
|
|
|
const typeTree = ref([]);
|
|
|
|
const treeOption = ref({
|
|
|
|
nodeKey: 'areaCode',
|
|
|
|
props: { children: 'areaChildVOS', label: 'areaName' },
|
|
|
|
});
|
|
|
|
const townOptions = reactive([]);
|
|
|
|
const infoData = reactive({
|
2025-03-04 16:24:17 +08:00
|
|
|
countyId: '',
|
|
|
|
townId: '',
|
|
|
|
name: '',
|
|
|
|
});
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
|
|
|
|
/* --------------- methods --------------- */
|
|
|
|
const loadData = () => {
|
|
|
|
//state.loading = true;
|
|
|
|
// getAnnualList(state.query)
|
|
|
|
// .then((res) => {
|
|
|
|
// if (res.code === 200) {
|
|
|
|
// const { current, size, total, records } = res.data;
|
|
|
|
// state.data = records;
|
|
|
|
// state.pageData = {
|
|
|
|
// currentPage: current || 1,
|
|
|
|
// pageSize: size || 10,
|
|
|
|
// total: total,
|
|
|
|
// };
|
|
|
|
// }
|
|
|
|
// })
|
|
|
|
// .catch((err) => {
|
|
|
|
// app.$message.error(err.msg);
|
|
|
|
// state.data = [];
|
|
|
|
// })
|
|
|
|
// .finally(() => {
|
|
|
|
// state.loading = false;
|
|
|
|
// });
|
|
|
|
};
|
|
|
|
|
2025-03-11 15:58:05 +08:00
|
|
|
const getTree = () => {
|
|
|
|
getRegion().then((res) => {
|
|
|
|
if (res.code === 200) {
|
|
|
|
const { code, data } = res;
|
|
|
|
typeTree.value = data;
|
|
|
|
console.info('区域信息', typeTree.value);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2025-03-04 16:24:17 +08:00
|
|
|
onMounted(() => {
|
2025-03-11 15:58:05 +08:00
|
|
|
getTree();
|
2025-03-04 16:24:17 +08:00
|
|
|
loadData();
|
|
|
|
});
|
|
|
|
|
|
|
|
// 页数
|
|
|
|
const currentChange = (current) => {
|
|
|
|
state.query.current = current;
|
|
|
|
loadData();
|
|
|
|
};
|
|
|
|
|
|
|
|
// 条数
|
|
|
|
const sizeChange = (size) => {
|
|
|
|
state.query.size = size;
|
|
|
|
loadData();
|
|
|
|
};
|
|
|
|
|
|
|
|
// 搜索
|
|
|
|
const searchChange = (params, done) => {
|
|
|
|
if (done) done();
|
|
|
|
state.query = params;
|
|
|
|
state.query.current = 1;
|
|
|
|
loadData();
|
|
|
|
};
|
|
|
|
|
|
|
|
// 刷新
|
|
|
|
const refreshChange = () => {
|
|
|
|
loadData();
|
|
|
|
app.$message.success('刷新成功');
|
|
|
|
};
|
|
|
|
|
|
|
|
// 选择
|
|
|
|
const selectionChange = (rows) => {
|
|
|
|
state.selection = rows;
|
|
|
|
};
|
|
|
|
|
|
|
|
const handleNodeClick = (data) => {
|
2025-03-11 15:58:05 +08:00
|
|
|
// if (data.level == '2') {
|
|
|
|
// return;
|
|
|
|
// }
|
|
|
|
// if (data.level == '0') {
|
|
|
|
// infoData.countyId = data.id;
|
|
|
|
// infoData.townId = '';
|
|
|
|
// }
|
|
|
|
// if (data.level == '1') {
|
|
|
|
// let countys =
|
|
|
|
// typeTree.filter((m) => {
|
|
|
|
// return m.id == data.pId;
|
|
|
|
// }) || [];
|
|
|
|
// let town = countys[0] && countys[0].children ? countys[0].children : [];
|
|
|
|
// townOptions = town;
|
|
|
|
// infoData.townId = data.id;
|
|
|
|
// infoData.countyId = data.pId;
|
|
|
|
// }
|
2025-03-04 16:24:17 +08:00
|
|
|
// console.info('infoData', infoData);
|
|
|
|
};
|
|
|
|
// 编辑
|
|
|
|
const rowStatus = (row) => {
|
|
|
|
console.info('操作状态');
|
|
|
|
};
|
|
|
|
|
|
|
|
const rowDel = (row) => {};
|
|
|
|
|
|
|
|
const getStatusButtonText = (status) => {
|
|
|
|
switch (status) {
|
|
|
|
case 'active':
|
|
|
|
return '启用';
|
|
|
|
case 'inactive':
|
|
|
|
return '禁用';
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2025-03-06 16:20:26 +08:00
|
|
|
const rowEdit = (row) => {
|
|
|
|
crudRef.value && crudRef.value.rowEdit(row);
|
|
|
|
};
|
2025-03-04 16:24:17 +08:00
|
|
|
|
|
|
|
const onAdd = () => {
|
2025-03-06 16:20:26 +08:00
|
|
|
// infoVisible.value = true;
|
|
|
|
crudRef.value && crudRef.value.rowAdd();
|
2025-03-04 16:24:17 +08:00
|
|
|
};
|
|
|
|
const onExport = () => {};
|
|
|
|
// #region
|
|
|
|
|
|
|
|
// #endregion
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<style lang="scss" scoped></style>
|