This commit is contained in:
wangzenghua 2025-04-02 07:42:19 +01:00
parent f637bec8f5
commit edf016b1c7
4 changed files with 37 additions and 14 deletions

View File

@ -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-28 14:18:58 * @LastEditTime: 2025-04-02 14:21:56
*/ */
import lodash from 'lodash'; import lodash from 'lodash';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
@ -138,12 +138,12 @@ export const setPropDisplay = (column, fields) => {
* @param {*} tree * @param {*} tree
* @returns * @returns
*/ */
export const flattenTree = (tree) => { export const flattenTree = (tree, children = 'children') => {
const result = []; const result = [];
function traverse(node) { function traverse(node) {
result.push(node); result.push(node);
if (node.children && node.children.length > 0) { if (node[children] && node[children].length > 0) {
node.children.forEach((child) => traverse(child)); node[children].forEach((child) => traverse(child));
} }
} }
if (Array.isArray(tree)) { if (Array.isArray(tree)) {
@ -276,6 +276,7 @@ export const getTree = (data, id = 'id', parentId = 'parentId', children = 'chil
const map = {}; const map = {};
data.forEach((item) => { data.forEach((item) => {
item.level = 0;
map[item[id]] = item; map[item[id]] = item;
}); });
@ -283,9 +284,11 @@ export const getTree = (data, id = 'id', parentId = 'parentId', children = 'chil
data.forEach((item) => { data.forEach((item) => {
const parent = map[item[parentId]]; const parent = map[item[parentId]];
if (parent) { if (parent) {
item.level = parent.level + 1;
parent[children] = parent[children] || []; parent[children] = parent[children] || [];
parent[children].push(item); parent[children].push(item);
} else { } else {
item.level = 0;
tree.push(item); tree.push(item);
} }
}); });

View File

@ -142,9 +142,14 @@ const state = reactive({
{ {
label: '区域面积', label: '区域面积',
prop: 'area', prop: 'area',
width: 100, width: 150,
overHidden: true,
disabled: true, disabled: true,
labelTip: '请先选择地块!', labelTip: '请先选择地块!',
formatter: (row) => {
const item = state.unitList.find((v) => v.dictValue == row.unit);
return row.area + (!isEmpty(item) ? item.dictLabel : '平方米');
},
}, },
{ {
label: '状态', label: '状态',
@ -412,7 +417,7 @@ const remoteLandList = async (val) => {
// //
const selectedChange = ({ item, value, dic }) => { const selectedChange = ({ item, value, dic }) => {
// console.log(390, value, item); // console.log(390, value, item);
crudRef.value.tableForm.landId = item?.id; crudRef.value.tableForm.landId = value;
crudRef.value.tableForm.landName = item?.landName; crudRef.value.tableForm.landName = item?.landName;
crudRef.value.tableForm.address = item?.address; crudRef.value.tableForm.address = item?.address;
crudRef.value.tableForm.area = item?.area; crudRef.value.tableForm.area = item?.area;

View File

@ -51,13 +51,16 @@ const state = reactive({
selection: [], selection: [],
options: { options: {
...CRUD_OPTIONS, ...CRUD_OPTIONS,
addBtnText: '添加网格', // addBtnText: '',
column: [ column: [
{ {
label: '网格区', label: '网格区',
prop: 'gridArea', prop: 'gridArea',
search: true, search: true,
width: 200, width: 200,
addDisplay: false,
editDisplay: false,
viewDisplay: true,
rules: { rules: {
required: true, required: true,
message: '请输入', message: '请输入',
@ -93,6 +96,11 @@ const state = reactive({
addDisplay: true, addDisplay: true,
editDisplay: true, editDisplay: true,
viewDisplay: false, viewDisplay: false,
// multiple: true,
// checkStrictly: true,
// collapseTags: true,
// emitPath: false,
// checkDescendants: false,
props: { props: {
label: 'areaName', label: 'areaName',
value: 'areaCode', value: 'areaCode',
@ -261,7 +269,6 @@ const selectionChange = (rows) => {
// //
const rowView = (row) => { const rowView = (row) => {
// state.currentRow = row;
crudRef.value.rowView(row); crudRef.value.rowView(row);
}; };
@ -271,7 +278,8 @@ const setCity = (row) => {
row.cityCode = row?.cities[1] ?? null; row.cityCode = row?.cities[1] ?? null;
row.gridAreaCode = row?.cities[2] ?? null; row.gridAreaCode = row?.cities[2] ?? null;
row.townCode = row?.cities[3] ?? null; row.townCode = row?.cities[3] ?? null;
row.village = row?.cities[3] ?? null; row.village = row?.cities[4] ?? null;
// row.village = row?.cities.join(',');
} }
}; };
@ -296,7 +304,8 @@ const rowSave = (row, done, loading) => {
// //
const rowEdit = (row) => { const rowEdit = (row) => {
row.cities = compact([row.provinceCode, row.cityCode, row.gridAreaCode ?? '', row.townCode ?? '', row.village ?? '']); const village = !isEmpty(row.village) ? row.village : [];
row.cities = compact([row.provinceCode, row.cityCode, row.gridAreaCode ?? '', row.townCode ?? '', ...village]);
crudRef.value.rowEdit(row); crudRef.value.rowEdit(row);
}; };
const rowUpdate = (row, index, done, loading) => { const rowUpdate = (row, index, done, loading) => {
@ -331,7 +340,6 @@ const rowDel = (row, index, done) => {
.then((res) => { .then((res) => {
if (res.code === 200) { if (res.code === 200) {
app.$message.success('删除成功!'); app.$message.success('删除成功!');
done();
loadData(); loadData();
} }
}) })

View File

@ -84,7 +84,7 @@ const state = reactive({
selection: [], selection: [],
options: { options: {
...CRUD_OPTIONS, ...CRUD_OPTIONS,
addBtnText: '添加信息', // addBtnText: '',
column: [ column: [
{ {
label: '溯源码', label: '溯源码',
@ -236,6 +236,12 @@ const state = reactive({
}, },
{ {
label: '乡镇', label: '乡镇',
prop: 'town',
hide: true,
display: false,
},
{
label: '村',
prop: 'village', prop: 'village',
hide: true, hide: true,
display: false, display: false,
@ -455,7 +461,8 @@ const setCity = (row) => {
row.province = row?.cities[0] ?? null; row.province = row?.cities[0] ?? null;
row.city = row?.cities[1] ?? null; row.city = row?.cities[1] ?? null;
row.county = row?.cities[2] ?? null; row.county = row?.cities[2] ?? null;
row.village = row?.cities[3] ?? null; row.town = row?.cities[3] ?? null;
row.village = row?.cities[4] ?? null;
} }
}; };
@ -509,7 +516,7 @@ const rowSave = (row, done, loading) => {
// //
const rowEdit = (row) => { const rowEdit = (row) => {
row.base64 = row.productUrl; row.base64 = row.productUrl;
row.cities = compact([row.province, row.city, row.county ?? '', row.village ?? '']); row.cities = compact([row.province, row.city, row.county ?? '', row.town ?? '', row.village ?? '']);
crudRef.value.rowEdit(row); crudRef.value.rowEdit(row);
}; };
const rowUpdate = (row, index, done, loading) => { const rowUpdate = (row, index, done, loading) => {