Merge branch 'dev' of http://192.168.18.88:8077/sznyb/daimp-front into dev
This commit is contained in:
commit
8fc195de39
@ -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);
|
||||
}
|
||||
});
|
||||
|
@ -34,20 +34,18 @@
|
||||
</div>
|
||||
</template>
|
||||
<script setup>
|
||||
import { ref, reactive, onMounted } from 'vue';
|
||||
import { useRouter } from 'vue-router';
|
||||
import { ref, reactive } from 'vue';
|
||||
import { useApp } from '@/hooks';
|
||||
import { useUserStore } from '@/store/modules/user';
|
||||
import { CRUD_OPTIONS } from '@/config';
|
||||
import { isEmpty, setDicData, debounce } from '@/utils';
|
||||
import { CommonDicData } from '@/apis';
|
||||
// import { CommonDicData } from '@/apis';
|
||||
import { getLandsList } from '@/apis/land';
|
||||
import { GetEntityList, AddEntity, UpdateEntity, DeleteEntity, UpdateStatus } from '@/apis/plantingAndBreeding/base';
|
||||
|
||||
const { VITE_APP_BASE_API } = import.meta.env;
|
||||
const app = useApp();
|
||||
const UserStore = useUserStore();
|
||||
const router = useRouter();
|
||||
const crudRef = ref(null);
|
||||
const state = reactive({
|
||||
loading: false,
|
||||
@ -142,9 +140,15 @@ 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 : '平方米');
|
||||
return row.area + (!isEmpty(row.unit) ? row.unit : '平方米');
|
||||
},
|
||||
},
|
||||
{
|
||||
label: '状态',
|
||||
@ -238,18 +242,18 @@ const state = reactive({
|
||||
});
|
||||
|
||||
// 加载
|
||||
const getUnit = async () => {
|
||||
CommonDicData('sys_unit_type')
|
||||
.then((res) => {
|
||||
console.log(250, res);
|
||||
if (res.code === 200) {
|
||||
state.unitList = res.data;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
app.$message.error(err.msg);
|
||||
});
|
||||
};
|
||||
// const getUnit = async () => {
|
||||
// CommonDicData('sys_unit_type')
|
||||
// .then((res) => {
|
||||
// console.log(250, res);
|
||||
// if (res.code === 200) {
|
||||
// state.unitList = res.data;
|
||||
// }
|
||||
// })
|
||||
// .catch((err) => {
|
||||
// app.$message.error(err.msg);
|
||||
// });
|
||||
// };
|
||||
|
||||
const loadData = async () => {
|
||||
state.loading = true;
|
||||
@ -276,9 +280,9 @@ const loadData = async () => {
|
||||
|
||||
loadData();
|
||||
|
||||
onMounted(() => {
|
||||
getUnit();
|
||||
});
|
||||
// onMounted(() => {
|
||||
// getUnit();
|
||||
// });
|
||||
|
||||
// 页数
|
||||
const currentChange = (current) => {
|
||||
@ -412,7 +416,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;
|
||||
|
@ -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();
|
||||
}
|
||||
})
|
||||
|
@ -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) => {
|
||||
|
Loading…
x
Reference in New Issue
Block a user