From edf016b1c7b5f6da5eac649d3cbcc4a2a0cad8e9 Mon Sep 17 00:00:00 2001 From: wangzenghua <1048523306@qq.com> Date: Wed, 2 Apr 2025 07:42:19 +0100 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/utils/index.js | 11 +++++++---- .../views/plantingAndBreeding/base/index.vue | 9 +++++++-- .../src/views/resource/grid/index.vue | 18 +++++++++++++----- .../views/trace/agricultural/coding/index.vue | 13 ++++++++++--- 4 files changed, 37 insertions(+), 14 deletions(-) diff --git a/sub-government-affairs-service/src/utils/index.js b/sub-government-affairs-service/src/utils/index.js index b9b0504..6f004ad 100644 --- a/sub-government-affairs-service/src/utils/index.js +++ b/sub-government-affairs-service/src/utils/index.js @@ -3,7 +3,7 @@ * @Author: zenghua.wang * @Date: 2022-02-23 21:12:37 * @LastEditors: zenghua.wang - * @LastEditTime: 2025-03-28 14:18:58 + * @LastEditTime: 2025-04-02 14:21:56 */ import lodash from 'lodash'; import dayjs from 'dayjs'; @@ -138,12 +138,12 @@ export const setPropDisplay = (column, fields) => { * @param {*} tree * @returns */ -export const flattenTree = (tree) => { +export const flattenTree = (tree, children = 'children') => { const result = []; function traverse(node) { result.push(node); - if (node.children && node.children.length > 0) { - node.children.forEach((child) => traverse(child)); + if (node[children] && node[children].length > 0) { + node[children].forEach((child) => traverse(child)); } } if (Array.isArray(tree)) { @@ -276,6 +276,7 @@ export const getTree = (data, id = 'id', parentId = 'parentId', children = 'chil const map = {}; data.forEach((item) => { + item.level = 0; map[item[id]] = item; }); @@ -283,9 +284,11 @@ export const getTree = (data, id = 'id', parentId = 'parentId', children = 'chil data.forEach((item) => { const parent = map[item[parentId]]; if (parent) { + item.level = parent.level + 1; parent[children] = parent[children] || []; parent[children].push(item); } else { + item.level = 0; tree.push(item); } }); diff --git a/sub-government-affairs-service/src/views/plantingAndBreeding/base/index.vue b/sub-government-affairs-service/src/views/plantingAndBreeding/base/index.vue index 4e86fd2..ca32cb6 100644 --- a/sub-government-affairs-service/src/views/plantingAndBreeding/base/index.vue +++ b/sub-government-affairs-service/src/views/plantingAndBreeding/base/index.vue @@ -142,9 +142,14 @@ const state = reactive({ { label: '区域面积', prop: 'area', - width: 100, + width: 150, + overHidden: true, disabled: true, labelTip: '请先选择地块!', + formatter: (row) => { + const item = state.unitList.find((v) => v.dictValue == row.unit); + return row.area + (!isEmpty(item) ? item.dictLabel : '平方米'); + }, }, { label: '状态', @@ -412,7 +417,7 @@ const remoteLandList = async (val) => { // 选择赋值 const selectedChange = ({ item, value, dic }) => { // 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.address = item?.address; crudRef.value.tableForm.area = item?.area; diff --git a/sub-government-affairs-service/src/views/resource/grid/index.vue b/sub-government-affairs-service/src/views/resource/grid/index.vue index be2d871..2a4c7c4 100644 --- a/sub-government-affairs-service/src/views/resource/grid/index.vue +++ b/sub-government-affairs-service/src/views/resource/grid/index.vue @@ -51,13 +51,16 @@ const state = reactive({ selection: [], options: { ...CRUD_OPTIONS, - addBtnText: '添加网格', + // addBtnText: '添加网格', column: [ { label: '网格区', prop: 'gridArea', search: true, width: 200, + addDisplay: false, + editDisplay: false, + viewDisplay: true, rules: { required: true, message: '请输入', @@ -93,6 +96,11 @@ const state = reactive({ addDisplay: true, editDisplay: true, viewDisplay: false, + // multiple: true, + // checkStrictly: true, + // collapseTags: true, + // emitPath: false, + // checkDescendants: false, props: { label: 'areaName', value: 'areaCode', @@ -261,7 +269,6 @@ const selectionChange = (rows) => { // 查看 const rowView = (row) => { - // state.currentRow = row; crudRef.value.rowView(row); }; @@ -271,7 +278,8 @@ const setCity = (row) => { row.cityCode = row?.cities[1] ?? null; row.gridAreaCode = row?.cities[2] ?? 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) => { - 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); }; const rowUpdate = (row, index, done, loading) => { @@ -331,7 +340,6 @@ const rowDel = (row, index, done) => { .then((res) => { if (res.code === 200) { app.$message.success('删除成功!'); - done(); loadData(); } }) diff --git a/sub-government-affairs-service/src/views/trace/agricultural/coding/index.vue b/sub-government-affairs-service/src/views/trace/agricultural/coding/index.vue index 9d5f806..b508c6e 100644 --- a/sub-government-affairs-service/src/views/trace/agricultural/coding/index.vue +++ b/sub-government-affairs-service/src/views/trace/agricultural/coding/index.vue @@ -84,7 +84,7 @@ const state = reactive({ selection: [], options: { ...CRUD_OPTIONS, - addBtnText: '添加信息', + // addBtnText: '添加信息', column: [ { label: '溯源码', @@ -236,6 +236,12 @@ const state = reactive({ }, { label: '乡镇', + prop: 'town', + hide: true, + display: false, + }, + { + label: '村', prop: 'village', hide: true, display: false, @@ -455,7 +461,8 @@ const setCity = (row) => { row.province = row?.cities[0] ?? null; row.city = row?.cities[1] ?? 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) => { 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); }; const rowUpdate = (row, index, done, loading) => {