@@ -496,7 +497,8 @@
}],
logList: [],
// 任务人查看
- my_mission_distribute: [],
+ my_mission_distribute: [],
+ showform_mission_distribute:[],
distributeTable: [{
label: '执行人',
prop: 'accept_admin_name',
@@ -658,8 +660,9 @@
// }
}
})
- this.my_mission_distribute = md
- console.log(this.my_mission_distribute)
+ this.my_mission_distribute = this.convertToTree(md)
+ console.log(this.my_mission_distribute)
+
this.pictureList = []
for (var f of res.files) {
this.pictureList.push({
@@ -668,11 +671,57 @@
name: f.original_name
})
}
- this.showform = res
+ this.showform = res
+ this.showform_mission_distribute = this.convertToTree(res.mission_distribute)
+ console.log("this.showform.mission_distribute",this.showform_mission_distribute)
this.is_what_unitType = res.unit_type_detail ? res.unit_type_detail.value : ''
},
-
+ // 更改为树形结构
+ convertToTree(arr) {
+ const map = {};
+ const carryType2Map = {};
+ const roots = [];
+ const used = new Set();
+
+ // 首次遍历,将每个对象存入 map 中,并记录 carry_type === 2 的对象
+ arr.forEach(item => {
+ if (!map[item.accept_admin_id]) {
+ map[item.accept_admin_id] = [];
+ }
+ const newItem = { ...item, children: [] };
+ map[item.accept_admin_id].push(newItem);
+ if (item.carry_type === 2) {
+ carryType2Map[item.accept_admin_id] = newItem;
+ }
+ });
+
+ // 第二次遍历,构建父子关系
+ arr.forEach(item => {
+ const current = map[item.accept_admin_id].find(i => i.id === item.id);
+ if (item.from_user_id!== null) {
+ const parentList = map[item.from_user_id];
+ if (parentList) {
+ const parent = carryType2Map[item.from_user_id];
+ if (parent) {
+ parent.children.push(current);
+ used.add(current.id);
+ }
+ }
+ }
+ });
+
+ // 将未作为子元素的项添加到 roots 中
+ Object.values(map).forEach(items => {
+ items.forEach(item => {
+ if (!used.has(item.id)) {
+ roots.push(item);
+ }
+ });
+ });
+
+ return roots;
+ },
async getUnitTypeList() {
const res = await getparameteritem('unitTypeList')
this.unitTypeList = res.detail
@@ -699,7 +748,8 @@
this.showform = {}
this.isEditor = false
- this.my_mission_distribute = []
+ this.my_mission_distribute = []
+ this.showform_mission_distribute = []
this.pictureList = []
this.is_what_unitType = ''
this.url_type = ''
diff --git a/vue.config.js b/vue.config.js
index c1b0b04..8b49cd5 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -25,7 +25,7 @@ module.exports = {
* Detail: https://cli.vuejs.org/config/#publicpath
*/
publicPath: process.env.ENV === 'staging' ? '/admin_test' : '/admin',
- outputDir: '/Users/mac/Documents/朗业/2024/h-河道处项目/a-安全生产/safety-manage-service/public/admin',
+ outputDir: '/Users/mac/Documents/朗业/2024/h-河道处项目/a-安全生产/safety-manage-service/public/admin_test',
assetsDir: 'static',
lintOnSave: process.env.NODE_ENV === 'development',
productionSourceMap: false,