|
|
|
@ -1,13 +1,16 @@ |
|
|
|
<template> |
|
|
|
<div> |
|
|
|
<div style="margin:2px 2px 2px 2px;display: flex;"> |
|
|
|
<!-- |
|
|
|
<el-checkbox style="margin-top: 6px;" v-model="isOnlyCus" true-label="Y" false-label="N" size="small"> |
|
|
|
仅单位 |
|
|
|
</el-checkbox> |
|
|
|
--> |
|
|
|
<el-input placeholder="输入关键字进行过滤" v-model="filterText" size="small" /> |
|
|
|
</div> |
|
|
|
<div> |
|
|
|
<el-tree :data="customerOrg.customerOrgTree" :props="treeprops" node-key="id" :filter-node-method="filterNode" |
|
|
|
<!-- :filter-node-method="filterNode" --> |
|
|
|
<el-tree :data="customerOrgTreeSeo" :props="treeprops" node-key="id" |
|
|
|
:style="'overflow: scroll;width:200px;height:' + (window.pageHeight < 600 ? 465 : window.pageHeight - 135) + 'px;'" |
|
|
|
:default-expanded-keys="customerOrg.defaultExpandedKeys" @node-click="treeclick" highlight-current draggable |
|
|
|
:allow-drag="allowDrag" :allow-drop="allowDrop" @node-drop="nodeDrop" ref="customerOrgTree"> |
|
|
|
@ -30,6 +33,8 @@ import { mapState, mapMutations } from "vuex"; |
|
|
|
import { getapi, postapi, putapi, deletapi } from "@/api/api"; |
|
|
|
import { tcdate, deepCopy, reMadeOrgTree } from "../../utlis/proFunc"; |
|
|
|
import { getTreePids, getTreeNode } from "../../utlis/tree"; |
|
|
|
import { setDBCom, getDBCom } from "../../utlis/indexedDB"; |
|
|
|
|
|
|
|
|
|
|
|
export default { |
|
|
|
components: {}, |
|
|
|
@ -37,6 +42,8 @@ export default { |
|
|
|
return { |
|
|
|
isOnlyCus: 'N', |
|
|
|
filterText: '', |
|
|
|
customerOrgTreeSeo: [], |
|
|
|
customerOrgTreeAll: [], |
|
|
|
treeprops: { |
|
|
|
label: "displayName", // label/displayName |
|
|
|
value: "id", |
|
|
|
@ -45,7 +52,7 @@ export default { |
|
|
|
}, //树形组件的数据结构 |
|
|
|
}; |
|
|
|
}, |
|
|
|
//<el-tree :data="$store.state.customerOrg.customerOrgTree" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree> |
|
|
|
//<el-tree :data="$store.state.customerOrgTreeSeo" :props="$store.state.customerOrg.treeprops" @node-click="treeclick"></el-tree> |
|
|
|
computed: { |
|
|
|
...mapState(["customerOrg", "window", "dataTransOpts"]), |
|
|
|
}, |
|
|
|
@ -63,23 +70,40 @@ export default { |
|
|
|
methods: { |
|
|
|
...mapMutations(["setData"]), |
|
|
|
|
|
|
|
//获取体检单位列表树信息 避免重复切换页面,多次调用接口/下载 内存溢出 |
|
|
|
//获取体检单位列表树信息 |
|
|
|
getCustomerOrgTree() { |
|
|
|
if (this.dataTransOpts.orgDataSet.length > 0) { |
|
|
|
this.customerOrg.customerOrgTreeBak = reMadeOrgTree(deepCopy(this.dataTransOpts.orgDataSet)) |
|
|
|
this.customerOrg.customerOrgTree = deepCopy(this.customerOrg.customerOrgTreeBak) |
|
|
|
} else { |
|
|
|
getapi("/api/app/customerorg/getbycodeall?IsHidePerson=1").then((res) => { |
|
|
|
//customerOrgTree = res.data; |
|
|
|
if (res.code > -1) { |
|
|
|
this.dataTransOpts.orgDataSet = res.data |
|
|
|
this.customerOrg.customerOrgTreeBak = reMadeOrgTree(deepCopy(this.dataTransOpts.orgDataSet)) |
|
|
|
this.customerOrg.customerOrgTree = deepCopy(this.customerOrg.customerOrgTreeBak) |
|
|
|
// tcdate(this.customerOrg.customerOrgTree); |
|
|
|
getDBCom('orgDatasEdit') |
|
|
|
.then(localData => { |
|
|
|
let now = Date.now() |
|
|
|
// 24小时 = 86400000 毫秒 |
|
|
|
if (localData?.createdat && now - 43200000 < localData.createdat) { |
|
|
|
// console.log('this.orgDatas.length',this.orgDatas.length) |
|
|
|
if (localData.data.length > 0) { |
|
|
|
let treeData = reMadeOrgTree(deepCopy(localData.data)); |
|
|
|
this.customerOrgTreeAll = treeData; |
|
|
|
this.customerOrgTreeSeo = treeData.slice(0, 100) |
|
|
|
}else{ |
|
|
|
this.getOrgTreeApi() |
|
|
|
} |
|
|
|
} else { |
|
|
|
this.getOrgTreeApi() |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}) |
|
|
|
.catch(err => { |
|
|
|
console.error(err) |
|
|
|
this.getOrgTreeApi() |
|
|
|
}) |
|
|
|
}, |
|
|
|
|
|
|
|
getOrgTreeApi() { |
|
|
|
getapi("/api/app/customerorg/getbycodeall?IsHidePerson=1").then((res) => { |
|
|
|
if (res.code > -1) { |
|
|
|
let treeData = reMadeOrgTree(deepCopy(res.data)); |
|
|
|
this.customerOrgTreeAll = treeData; |
|
|
|
this.customerOrgTreeSeo = treeData.slice(0, 100) |
|
|
|
setDBCom('orgDatasEdit', res.data) |
|
|
|
} |
|
|
|
}); |
|
|
|
}, |
|
|
|
|
|
|
|
// 判断选中接点是否可以拖拽 |
|
|
|
@ -104,19 +128,17 @@ export default { |
|
|
|
let body = { itemList: [] } |
|
|
|
|
|
|
|
if (draggingNode.data.parentId) { |
|
|
|
let parentNode = getTreeNode(this.customerOrg.customerOrgTree, 'treeChildren', 'id', draggingNode.data.parentId) |
|
|
|
let parentNode = getTreeNode(this.customerOrgTreeSeo, 'treeChildren', 'id', draggingNode.data.parentId) |
|
|
|
parentNode.treeChildren.forEach((e, i) => { |
|
|
|
body.itemList.push({ id: e.id, displayOrder: i }) |
|
|
|
}); |
|
|
|
} else { |
|
|
|
this.customerOrg.customerOrgTree.forEach((e, i) => { |
|
|
|
this.customerOrgTreeSeo.forEach((e, i) => { |
|
|
|
body.itemList.push({ id: e.id, displayOrder: i }) |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// console.log('body',body) |
|
|
|
|
|
|
|
|
|
|
|
putapi('/api/app/customerorg/updatesortmany', body) |
|
|
|
|
|
|
|
|
|
|
|
@ -144,7 +166,7 @@ export default { |
|
|
|
this.dataTransOpts.tableS.customer_org.id = data.id //单位ID |
|
|
|
this.dataTransOpts.tableS.customer_org.parent_id = data.id //一级单位ID |
|
|
|
if (data.parentId) { |
|
|
|
let pids = getTreePids(this.customerOrg.customerOrgTree, "treeChildren", 'parentId', 'id', data.id) |
|
|
|
let pids = getTreePids(this.customerOrgTreeSeo, "treeChildren", 'parentId', 'id', data.id) |
|
|
|
this.dataTransOpts.tableS.customer_org.parent_id = pids[pids.length - 2] |
|
|
|
} |
|
|
|
this.dataTransOpts.refresh.customer_org.S++ |
|
|
|
@ -154,20 +176,23 @@ export default { |
|
|
|
}, |
|
|
|
|
|
|
|
//全树过滤 |
|
|
|
filterNode(value, data) { |
|
|
|
//console.log(value,data) |
|
|
|
if (!value) return true; |
|
|
|
return data['displayName'].indexOf(value) !== -1 || data['simpleCode'].indexOf(value.toUpperCase()) !== -1; |
|
|
|
}, |
|
|
|
// filterNode(value, data) { |
|
|
|
// //console.log(value,data) |
|
|
|
// if (!value) return true; |
|
|
|
// return data['displayName'].indexOf(value) !== -1 || data['simpleCode'].indexOf(value.toUpperCase()) !== -1; |
|
|
|
// }, |
|
|
|
|
|
|
|
//顶级树过滤 |
|
|
|
filterParentNode(value) { |
|
|
|
// console.log(value, data) |
|
|
|
// if (!value) return true; |
|
|
|
// return data['displayName'].indexOf(value) > -1 || data['simpleCode'].indexOf(value.toUpperCase()) > -1 || data['shortName'].indexOf(value) > -1 || data['customerOrgCode'].indexOf(value) > -1; |
|
|
|
this.customerOrg.customerOrgTree = this.customerOrg.customerOrgTreeBak.filter(e => { |
|
|
|
return e.label.indexOf(value) > -1 || e.simpleCode.indexOf(value.toUpperCase()) > -1 || e.shortName.indexOf(value) > -1 |
|
|
|
}) |
|
|
|
if (value){ |
|
|
|
let org = this.customerOrgTreeAll.filter(e => { |
|
|
|
return e.label.indexOf(value) > -1 || e.simpleCode.indexOf(value.toUpperCase()) > -1 |
|
|
|
}) |
|
|
|
this.customerOrgTreeSeo = org.slice(0,100) |
|
|
|
}else{ |
|
|
|
this.customerOrgTreeSeo = this.customerOrgTreeAll.slice(0,100) |
|
|
|
} |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
@ -184,20 +209,20 @@ export default { |
|
|
|
}, |
|
|
|
"filterText"(newVal, oldVal) { |
|
|
|
if (newVal != oldVal) { |
|
|
|
if (this.isOnlyCus == 'N') { |
|
|
|
this.$refs['customerOrgTree'].filter(newVal); |
|
|
|
} else { |
|
|
|
// if (this.isOnlyCus == 'N') { |
|
|
|
// this.$refs['customerOrgTree'].filter(newVal); |
|
|
|
// } else { |
|
|
|
this.filterParentNode(newVal) |
|
|
|
} |
|
|
|
// } |
|
|
|
} |
|
|
|
}, |
|
|
|
"isOnlyCus"(newVal, oldVal) { |
|
|
|
if (newVal == 'N') { |
|
|
|
this.$refs['customerOrgTree'].filter(this.filterText); |
|
|
|
} else { |
|
|
|
this.filterParentNode(this.filterText) |
|
|
|
} |
|
|
|
} |
|
|
|
// "isOnlyCus"(newVal, oldVal) { |
|
|
|
// if (newVal == 'N') { |
|
|
|
// this.$refs['customerOrgTree'].filter(this.filterText); |
|
|
|
// } else { |
|
|
|
// this.filterParentNode(this.filterText) |
|
|
|
// } |
|
|
|
// } |
|
|
|
}, |
|
|
|
|
|
|
|
}; |
|
|
|
|