|
@@ -208,7 +208,7 @@
|
|
<div class="move_top">
|
|
<div class="move_top">
|
|
<div
|
|
<div
|
|
class="img_box ispointer"
|
|
class="img_box ispointer"
|
|
- v-if="index !== 0 && ismix(item.name)"
|
|
|
|
|
|
+ v-if="(index !== 0 && ismix(item.name))&&isCode(item)&&hvaeCode(item)"
|
|
@mouseover="upActive = index"
|
|
@mouseover="upActive = index"
|
|
@mouseout="upActive = null"
|
|
@mouseout="upActive = null"
|
|
@click="
|
|
@click="
|
|
@@ -234,8 +234,8 @@
|
|
<div
|
|
<div
|
|
class="img_box ispointer"
|
|
class="img_box ispointer"
|
|
v-if="
|
|
v-if="
|
|
- index !== group.planDetails.length - 1 &&
|
|
|
|
- ismix(item.name)
|
|
|
|
|
|
+ (index !== group.planDetails.length - 1 &&
|
|
|
|
+ ismix(item.name))&&isCode(item)&&hvaeCode(item)
|
|
"
|
|
"
|
|
@mouseover="downActive = index"
|
|
@mouseover="downActive = index"
|
|
@mouseout="downActive = null"
|
|
@mouseout="downActive = null"
|
|
@@ -378,6 +378,9 @@ export default {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
return {
|
|
return {
|
|
|
|
+ hvaeId:'',
|
|
|
|
+ codeId:'',
|
|
|
|
+ objOne:{},
|
|
upActive: null,
|
|
upActive: null,
|
|
downActive: null,
|
|
downActive: null,
|
|
isEdit: false,
|
|
isEdit: false,
|
|
@@ -436,7 +439,6 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
params.planDetailParent[0].planDetails.splice(index, 1, ...arr);
|
|
params.planDetailParent[0].planDetails.splice(index, 1, ...arr);
|
|
-
|
|
|
|
params.planDetailParent = params.planDetailParent.map((item) => {
|
|
params.planDetailParent = params.planDetailParent.map((item) => {
|
|
let newArr = [];
|
|
let newArr = [];
|
|
if (item.planDetails) {
|
|
if (item.planDetails) {
|
|
@@ -450,7 +452,9 @@ export default {
|
|
planId: child.planId,
|
|
planId: child.planId,
|
|
remark: child.remark,
|
|
remark: child.remark,
|
|
status: child.status,
|
|
status: child.status,
|
|
- value: child.value
|
|
|
|
|
|
+ value: child.value,
|
|
|
|
+ id:child.id,
|
|
|
|
+ parentId:child.parentId
|
|
};
|
|
};
|
|
});
|
|
});
|
|
}
|
|
}
|
|
@@ -464,6 +468,12 @@ export default {
|
|
status: item.status
|
|
status: item.status
|
|
};
|
|
};
|
|
});
|
|
});
|
|
|
|
+ //将可能诊断和已有诊断的子集放回树里面
|
|
|
|
+ if(this.isEdit){
|
|
|
|
+ params.planDetailParent[0].planDetailSub=this.buildTree(params.planDetailParent[0].planDetailSub,'id','parentId','9715')
|
|
|
|
+ }else{
|
|
|
|
+ params.planDetailParent[0].planDetailSub=this.buildTree(params.planDetailParent[0].planDetailSub,'id','parentId','1')
|
|
|
|
+ }
|
|
api.savePlanInfoDatas(params).then((res) => {
|
|
api.savePlanInfoDatas(params).then((res) => {
|
|
if (res.data.code === "0") {
|
|
if (res.data.code === "0") {
|
|
this.$message({
|
|
this.$message({
|
|
@@ -570,6 +580,10 @@ export default {
|
|
if (res.data.code === "0") {
|
|
if (res.data.code === "0") {
|
|
this.form.planDetailSub = res.data.data.planDetailDefault;
|
|
this.form.planDetailSub = res.data.data.planDetailDefault;
|
|
this.fomatArr(res.data.data.planDetailDefault);
|
|
this.fomatArr(res.data.data.planDetailDefault);
|
|
|
|
+
|
|
|
|
+ // 将获取的数据改成改数组
|
|
|
|
+ this.form.planDetailSub[0].planDetails=this.tree2Array(this.form.planDetailSub[0],this.form.planDetailSub[0].parentId)
|
|
|
|
+ this.form.planDetailSub[0].planDetails.shift()
|
|
}
|
|
}
|
|
});
|
|
});
|
|
},
|
|
},
|
|
@@ -592,6 +606,7 @@ export default {
|
|
const res = await api.getPlanInfoIds(params);
|
|
const res = await api.getPlanInfoIds(params);
|
|
if (res.data.code === "0") {
|
|
if (res.data.code === "0") {
|
|
const obj = res.data.data[0];
|
|
const obj = res.data.data[0];
|
|
|
|
+ // // 合并默认数据
|
|
const { data } = this.$route.params;
|
|
const { data } = this.$route.params;
|
|
this.form = {
|
|
this.form = {
|
|
hospitalId: obj.hospitalId,
|
|
hospitalId: obj.hospitalId,
|
|
@@ -603,8 +618,13 @@ export default {
|
|
};
|
|
};
|
|
const defaultRes = await api.getDefaultPlans();
|
|
const defaultRes = await api.getDefaultPlans();
|
|
if (defaultRes.data.code === "0") {
|
|
if (defaultRes.data.code === "0") {
|
|
- // 合并默认数据
|
|
|
|
this.mergeDefaultPlans(defaultRes.data.data.planDetailDefault);
|
|
this.mergeDefaultPlans(defaultRes.data.data.planDetailDefault);
|
|
|
|
+
|
|
|
|
+ this.$nextTick(()=>{
|
|
|
|
+ // 改数组里面的可能诊断和已有诊断
|
|
|
|
+ this.form.planDetailSub[0].planDetails=this.tree2Array(this.form.planDetailSub[0],this.form.planDetailSub[0].parentId)
|
|
|
|
+ this.form.planDetailSub[0].planDetails.shift()
|
|
|
|
+ })
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (err) {
|
|
} catch (err) {
|
|
@@ -640,6 +660,7 @@ export default {
|
|
this.form.planDetailSub[oneIndex].planDetails.push(child);
|
|
this.form.planDetailSub[oneIndex].planDetails.push(child);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
+
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// 排序
|
|
// 排序
|
|
@@ -650,7 +671,163 @@ export default {
|
|
}
|
|
}
|
|
});
|
|
});
|
|
this.fomatArr(newData);
|
|
this.fomatArr(newData);
|
|
- }
|
|
|
|
|
|
+ },
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ // 将treeObj中的所有对象,放入一个数组中,要求某个对象在另一个对象的children时,其parent_id是对应的另一个对象的id
|
|
|
|
+ // 其原理实际上是数据结构中的广度优先遍历
|
|
|
|
+ tree2Array(treeObj, rootid) {
|
|
|
|
+ const temp = []; // 设置临时数组,用来存放队列
|
|
|
|
+ const out = []; // 设置输出数组,用来存放要输出的一维数组
|
|
|
|
+ temp.push(treeObj);
|
|
|
|
+ // 首先把根元素存放入out中
|
|
|
|
+ let parentId = rootid;
|
|
|
|
+ const obj = this.deepCopy(treeObj);
|
|
|
|
+ obj.parentId = parentId;
|
|
|
|
+ delete obj['planDetails'];
|
|
|
|
+ out.push(obj)
|
|
|
|
+ // 对树对象进行广度优先的遍历
|
|
|
|
+ while(temp.length > 0) {
|
|
|
|
+ const first = temp.shift();
|
|
|
|
+ const planDetails = first.planDetails;
|
|
|
|
+ if(planDetails && planDetails.length > 0) {
|
|
|
|
+ parentId = first.id;
|
|
|
|
+ const len = first.planDetails.length;
|
|
|
|
+ for(let i=0;i<len;i++) {
|
|
|
|
+ temp.push(planDetails[i]);
|
|
|
|
+ const obj = this.deepCopy(planDetails[i]);
|
|
|
|
+ obj.parentId = parentId;
|
|
|
|
+ delete obj['planDetails'];
|
|
|
|
+ out.push(obj)
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let arr=[];
|
|
|
|
+ let arrs=[];
|
|
|
|
+ let flag;
|
|
|
|
+ let haveFlag;
|
|
|
|
+ //修改
|
|
|
|
+ if(this.isEdit){
|
|
|
|
+ // //可能诊断
|
|
|
|
+ flag=null;
|
|
|
|
+ //可能诊断
|
|
|
|
+ arr = this.someFor(arr,out,'maydiagnose',flag);
|
|
|
|
+ //已诊断
|
|
|
|
+ arrs = this.someFor(arrs,arr,'hasdiagnose',haveFlag);
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ //新增
|
|
|
|
+ //可能诊断
|
|
|
|
+ arr = this.someFor(arr,out,'maydiagnose',flag);
|
|
|
|
+ //已诊断
|
|
|
|
+ arrs = this.someFor(arrs,arr,'hasdiagnose',haveFlag);
|
|
|
|
+ }
|
|
|
|
+ return arrs
|
|
|
|
+ },
|
|
|
|
+ // 将可能诊断和已诊断的子集放在各自的下面
|
|
|
|
+ someFor(arr,oldArr,num,flag){
|
|
|
|
+ // 保存父级id
|
|
|
|
+ let numName;
|
|
|
|
+ oldArr.forEach((item,index)=>{
|
|
|
|
+ //判断父级的code,记住父级在数组的下标和id
|
|
|
|
+ if(item.code==num){
|
|
|
|
+ flag=index
|
|
|
|
+ numName=item.id
|
|
|
|
+ }
|
|
|
|
+ //子级下的父级id与父级的id对比
|
|
|
|
+ if(item.parentId==numName){
|
|
|
|
+ flag=flag+1
|
|
|
|
+ arr.splice(flag,0,item)
|
|
|
|
+ oldArr.splice(index,item)
|
|
|
|
+ }else{
|
|
|
|
+ arr.push(item)
|
|
|
|
+ }
|
|
|
|
+ })
|
|
|
|
+ return arr
|
|
|
|
+ },
|
|
|
|
+ // 深拷贝
|
|
|
|
+ deepCopy(obj){
|
|
|
|
+ // 深度复制数组
|
|
|
|
+ if(Object.prototype.toString.call(obj) === "[object Array]"){
|
|
|
|
+ const object=[];
|
|
|
|
+ for(let i=0;i<obj.length;i++){
|
|
|
|
+ object.push(deepCopy(obj[i]))
|
|
|
|
+ }
|
|
|
|
+ return object
|
|
|
|
+ }
|
|
|
|
+ // 深度复制对象
|
|
|
|
+ if(Object.prototype.toString.call(obj) === "[object Object]"){
|
|
|
|
+ const object={};
|
|
|
|
+ for(let p in obj){
|
|
|
|
+ object[p]=obj[p]
|
|
|
|
+ }
|
|
|
|
+ return object
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ // 将一个数组,变成能够以树形展示的对象
|
|
|
|
+ buildTree(array,id,parent_id,num) {
|
|
|
|
+ // 创建临时对象
|
|
|
|
+ let temp = {};
|
|
|
|
+ // 创建需要返回的树形对象
|
|
|
|
+ let tree = {};
|
|
|
|
+ // 先遍历数组,将数组的每一项添加到temp对象中
|
|
|
|
+ for(let i in array) {
|
|
|
|
+ temp[array[i][id]] = array[i];
|
|
|
|
+ }
|
|
|
|
+ // 遍历temp对象,将当前子节点与父节点建立连接
|
|
|
|
+ for(let i in temp) {
|
|
|
|
+ // 判断是否是根节点下的项
|
|
|
|
+ if(temp[i][parent_id] !=num) {
|
|
|
|
+ if(num==1){
|
|
|
|
+ if(!temp[temp[i][parent_id]].planDetails) {
|
|
|
|
+ temp[temp[i][parent_id]].planDetails = new Array();
|
|
|
|
+ temp[temp[i][parent_id]].planDetailSub = new Array();
|
|
|
|
+ }
|
|
|
|
+ }else{
|
|
|
|
+ if(!temp[temp[i][parent_id]].planDetailSub) {
|
|
|
|
+ temp[temp[i][parent_id]].planDetails = new Array();
|
|
|
|
+ temp[temp[i][parent_id]].planDetailSub = new Array();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ // temp[temp[i][parent_id]].planDetails.push(temp[i]);
|
|
|
|
+ temp[temp[i][parent_id]].planDetailSub.push(temp[i])
|
|
|
|
+
|
|
|
|
+ } else {
|
|
|
|
+ tree[temp[i][id]] = temp[i];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ let arr=[];
|
|
|
|
+ Object.keys(tree).forEach((key)=>{
|
|
|
|
+ arr.push(tree[key])
|
|
|
|
+ })
|
|
|
|
+ return arr;
|
|
|
|
+ },
|
|
|
|
+ //判断可能诊断下面的文字没有图片
|
|
|
|
+ isCode(item){
|
|
|
|
+ if(item.code=='maydiagnose'){
|
|
|
|
+ this.codeId=item.id
|
|
|
|
+ }
|
|
|
|
+ if(item.parentId==this.codeId){
|
|
|
|
+ return false
|
|
|
|
+ }else{
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ //判断已诊断下面的文字没有图片
|
|
|
|
+ hvaeCode(item){
|
|
|
|
+ if(item.code=='hasdiagnose'){
|
|
|
|
+ this.hvaeId=item.id
|
|
|
|
+ }
|
|
|
|
+ if(item.parentId==this.hvaeId){
|
|
|
|
+ return false
|
|
|
|
+ }else{
|
|
|
|
+ return true
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
},
|
|
},
|
|
|
|
|
|
created() {
|
|
created() {
|