Merge branch 'dev' of http://192.168.18.88:8077/sznyb/daimp-front into dev
This commit is contained in:
commit
4c6569db65
@ -10,15 +10,6 @@ export function GetEntityList(params = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Title: 根据字典类型查询字典数据信息
|
|
||||||
*/
|
|
||||||
export function GetDict(dictType) {
|
|
||||||
return request(`/system/dict/data/list/${dictType}`, {
|
|
||||||
method: 'GET',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Title: 新增
|
* @Title: 新增
|
||||||
*/
|
*/
|
||||||
@ -47,3 +38,12 @@ export function DeleteEntity(params = {}) {
|
|||||||
method: 'DELETE',
|
method: 'DELETE',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: 根据字典类型查询字典数据信息
|
||||||
|
*/
|
||||||
|
export function GetDict(dictType) {
|
||||||
|
return request(`/system/dict/data/list/${dictType}`, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -10,15 +10,6 @@ export function GetEntityList(params = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @Title: 信息
|
|
||||||
*/
|
|
||||||
export function GetEntity(dictId) {
|
|
||||||
return request(`/system/dict/type/list/${dictId}`, {
|
|
||||||
method: 'GET',
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Title: 新增
|
* @Title: 新增
|
||||||
*/
|
*/
|
||||||
@ -56,3 +47,12 @@ export function GetEntityOption() {
|
|||||||
method: 'GET',
|
method: 'GET',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title: 信息
|
||||||
|
*/
|
||||||
|
export function GetDictType(dictId) {
|
||||||
|
return request(`/system/dict/type/list/${dictId}`, {
|
||||||
|
method: 'GET',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
* @Author: zenghua.wang
|
* @Author: zenghua.wang
|
||||||
* @Date: 2022-02-23 21:12:37
|
* @Date: 2022-02-23 21:12:37
|
||||||
* @LastEditors: zenghua.wang
|
* @LastEditors: zenghua.wang
|
||||||
* @LastEditTime: 2025-03-27 15:43:36
|
* @LastEditTime: 2025-03-28 14:18:58
|
||||||
*/
|
*/
|
||||||
import lodash from 'lodash';
|
import lodash from 'lodash';
|
||||||
import dayjs from 'dayjs';
|
import dayjs from 'dayjs';
|
||||||
@ -123,6 +123,16 @@ export const setDicLabel = (dicData, value) => {
|
|||||||
}
|
}
|
||||||
return label;
|
return label;
|
||||||
};
|
};
|
||||||
|
/**
|
||||||
|
* @Title 设置字段显隐
|
||||||
|
* @param {*} column
|
||||||
|
* @param {*} fields
|
||||||
|
*/
|
||||||
|
export const setPropDisplay = (column, fields) => {
|
||||||
|
column.forEach((item) => {
|
||||||
|
item.display = fields.includes(item.prop) ? false : true;
|
||||||
|
});
|
||||||
|
};
|
||||||
/**
|
/**
|
||||||
* @Title 将tree数据结构打平
|
* @Title 将tree数据结构打平
|
||||||
* @param {*} tree
|
* @param {*} tree
|
||||||
@ -283,6 +293,38 @@ export const getTree = (data, id = 'id', parentId = 'parentId', children = 'chil
|
|||||||
return tree;
|
return tree;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title 根据节点 id 查找其父级、祖父级等所有上级节点 id
|
||||||
|
* @param {*} treeData
|
||||||
|
* @param {*} targetId
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export const getParentIds = (treeData, targetId, id = 'id', children = 'children') => {
|
||||||
|
const parentMap = {};
|
||||||
|
function buildParentMap(node, parentId = null) {
|
||||||
|
if (node[id]) {
|
||||||
|
parentMap[node[id]] = parentId;
|
||||||
|
}
|
||||||
|
if (node[children]) {
|
||||||
|
for (const child of node[children]) {
|
||||||
|
buildParentMap(child, node[id]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const rootNode of treeData) {
|
||||||
|
buildParentMap(rootNode);
|
||||||
|
}
|
||||||
|
|
||||||
|
const parentIds = [];
|
||||||
|
let currentId = targetId;
|
||||||
|
while (parentMap[currentId] !== null) {
|
||||||
|
parentIds.push(parentMap[currentId]);
|
||||||
|
currentId = parentMap[currentId];
|
||||||
|
}
|
||||||
|
return parentIds.reverse();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @Title 获取路由中的参数
|
* @Title 获取路由中的参数
|
||||||
* @param name
|
* @param name
|
||||||
|
@ -58,7 +58,7 @@ import { useApp } from '@/hooks';
|
|||||||
import { CRUD_OPTIONS } from '@/config';
|
import { CRUD_OPTIONS } from '@/config';
|
||||||
import { getLandTypeTree, landTypeSave, getLandType, exportLandType, delLandType, editLandType } from '@/apis/baseInfo';
|
import { getLandTypeTree, landTypeSave, getLandType, exportLandType, delLandType, editLandType } from '@/apis/baseInfo';
|
||||||
import { useUserStore } from '@/store/modules/user';
|
import { useUserStore } from '@/store/modules/user';
|
||||||
import { isEmpty, flattenTree, setDicLabel, downloadFile } from '@/utils';
|
import { isEmpty, getParentIds, flattenTree, setDicLabel, downloadFile } from '@/utils';
|
||||||
|
|
||||||
const { VITE_APP_BASE_API } = import.meta.env;
|
const { VITE_APP_BASE_API } = import.meta.env;
|
||||||
const app = useApp();
|
const app = useApp();
|
||||||
@ -125,7 +125,7 @@ const state = reactive({
|
|||||||
dicHeaders: {
|
dicHeaders: {
|
||||||
authorization: UserStore.token,
|
authorization: UserStore.token,
|
||||||
},
|
},
|
||||||
dicFormatter: (res) => [{ id: null, landType: '土地分类', children: res.data }],
|
dicFormatter: (res) => [{ id: '0', landType: '土地分类', children: res.data }],
|
||||||
span: 24,
|
span: 24,
|
||||||
rules: [
|
rules: [
|
||||||
{
|
{
|
||||||
@ -188,7 +188,7 @@ watch(
|
|||||||
if (!isEmpty(val)) {
|
if (!isEmpty(val)) {
|
||||||
const list = flattenTree(val);
|
const list = flattenTree(val);
|
||||||
treeDicData.value = list.map((item) => {
|
treeDicData.value = list.map((item) => {
|
||||||
return { label: item.landType, value: item.id };
|
return { label: item.landType, value: item.id, id: item.id, parentId: item.pid };
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -198,7 +198,7 @@ const getLandTree = async () => {
|
|||||||
try {
|
try {
|
||||||
const res = await getLandTypeTree();
|
const res = await getLandTypeTree();
|
||||||
if (res.code == 200) {
|
if (res.code == 200) {
|
||||||
treeData.value = [{ id: null, landType: '土地分类', children: res.data }];
|
treeData.value = [{ id: '0', landType: '土地分类', children: res.data }];
|
||||||
}
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
app.$message.error(err.msg);
|
app.$message.error(err.msg);
|
||||||
@ -210,7 +210,7 @@ getLandTree();
|
|||||||
const loadData = () => {
|
const loadData = () => {
|
||||||
state.loading = true;
|
state.loading = true;
|
||||||
getLandType({
|
getLandType({
|
||||||
pid: treeSelected.value?.id ?? null,
|
pid: treeSelected.value?.id ?? '0',
|
||||||
...state.query,
|
...state.query,
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
@ -307,7 +307,7 @@ async function rowDel(row, done, loading) {
|
|||||||
const setPid = (row) => {
|
const setPid = (row) => {
|
||||||
if (!isEmpty(row.pids)) {
|
if (!isEmpty(row.pids)) {
|
||||||
const len = row.pids.length;
|
const len = row.pids.length;
|
||||||
row.pid = row?.pids[len - 1] ?? null;
|
row.pid = row?.pids[len - 1] ?? '0';
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -333,6 +333,8 @@ const rowSave = async (row, done, loading) => {
|
|||||||
|
|
||||||
// 编辑
|
// 编辑
|
||||||
const rowEdit = (row) => {
|
const rowEdit = (row) => {
|
||||||
|
row.pids = getParentIds(treeData.value, row.id);
|
||||||
|
console.log('pids=', row.pids);
|
||||||
crudRef.value && crudRef.value.rowEdit(row);
|
crudRef.value && crudRef.value.rowEdit(row);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -112,7 +112,7 @@ const state = reactive({
|
|||||||
value: '0',
|
value: '0',
|
||||||
rules: {
|
rules: {
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入',
|
message: '请选择',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -83,7 +83,7 @@ const state = reactive({
|
|||||||
value: '0',
|
value: '0',
|
||||||
rules: {
|
rules: {
|
||||||
required: true,
|
required: true,
|
||||||
message: '请输入',
|
message: '请选择',
|
||||||
trigger: 'blur',
|
trigger: 'blur',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
Loading…
x
Reference in New Issue
Block a user