DiseaseTree.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. <template>
  2. <div class="addMedicalMultRelationWrapper">
  3. <crumbs :title="minTitle" fix="fixed" linkTo="AboutDisease"></crumbs>
  4. <div class="contents">
  5. <div class="content">
  6. <div class="addBtn" v-if="list.length == 0">
  7. <el-button
  8. @click="addConcept"
  9. >+ 新 增</el-button>
  10. </div>
  11. <div class="tree">
  12. <el-tree
  13. :data="list"
  14. :props="defaultProps"
  15. node-key="conceptId"
  16. draggable
  17. :allow-drag="allowDrag"
  18. :allow-drop="allowDrop"
  19. :expand-on-click-node="true"
  20. :render-after-expand="true"
  21. :highlight-current="true"
  22. :default-expanded-keys="defaultExpandedArr"
  23. @node-click = "handleNodeClick"
  24. >
  25. <span class="custom-tree-node" slot-scope="{ node, data }" >
  26. <span class="custom-tree-node-name ellipsis" :class="{colorGray: data.isDeletedConcept == 'Y'}" :title="node.label">{{ node.label }}</span>
  27. <span class="btn-box">
  28. <el-button
  29. class="btn-add fl"
  30. v-if="data.level < 2 &&data.level>0"
  31. type="text"
  32. size="mini"
  33. @click="(e) => append(data, e)">
  34. + 增加
  35. </el-button>
  36. <el-button
  37. class="btn-del fr"
  38. v-if="data.level != 0"
  39. type="text"
  40. size="mini"
  41. @click="() => remove(node, data)">
  42. 删除
  43. </el-button>
  44. </span>
  45. </span>
  46. </el-tree>
  47. </div>
  48. <div class="btn">
  49. <el-button
  50. type="primary"
  51. :disabled = 'saveDisable'
  52. @click="confirm"
  53. >确 定</el-button>
  54. </div>
  55. </div>
  56. </div>
  57. <div class="btmFix"></div>
  58. <SearchList
  59. v-if="showSearch"
  60. :conceptList="conceptList||[]"
  61. :addLevel="addLevel"
  62. top="120px"
  63. @closeSearch="closeSearch"
  64. @selectConcept="selectConcept"
  65. @searchConcept="searchConcept" />
  66. </div>
  67. </template>
  68. <script type="text/javascript">
  69. import api from '@api/knowledgeTree.js';
  70. import SearchList from '../basicKnow/SearchList.vue';
  71. export default {
  72. name:'DiseaseTree',
  73. components:{
  74. SearchList
  75. },
  76. data(){
  77. return{
  78. minTitle:'疾病相关维护-添加',
  79. tab:[
  80. {name:'ICD10疾病类别',id:'1'},
  81. {name:'科室疾病类别',id:'2'},
  82. {name:'药物类别',id:'3'},
  83. {name:'症状类别',id:'4'},
  84. {name:'手术和操作类别',id:'5'},
  85. {name:'实验室检查类别',id:'6'},
  86. {name:'辅助检查类别',id:'7'},
  87. ],
  88. template:{
  89. "conceptId": null,
  90. "conceptName": "",
  91. "nodeList": [{
  92. "conceptId": 501,
  93. "conceptName": "疾病相关主症状",
  94. "nodeList": [],
  95. "libType": [103],
  96. "level": 1,
  97. "sonRelationId": 17,
  98. "isExpanded": false
  99. }, {
  100. "conceptId": 502,
  101. "conceptName": "疾病相关次症状",
  102. "nodeList": [],
  103. "libType": [103],
  104. "level": 1,
  105. "sonRelationId": 17,
  106. "isExpanded": false
  107. }, {
  108. "conceptId": 503,
  109. "conceptName": "疾病相关体格检查结果",
  110. "nodeList": [],
  111. "libType": [104],
  112. "level": 1,
  113. "sonRelationId": 17,
  114. "isExpanded": false
  115. }, {
  116. "conceptId": 504,
  117. "conceptName": "疾病相关实验室检查套餐",
  118. "nodeList": [],
  119. "libType": [107],
  120. "level": 1,
  121. "sonRelationId": 17,
  122. "isExpanded": false
  123. }, {
  124. "conceptId": 505,
  125. "conceptName": "疾病相关辅助检查项目",
  126. "nodeList": [],
  127. "libType": [109, 110],
  128. "level": 1,
  129. "sonRelationId": 17,
  130. "isExpanded": false
  131. }, {
  132. "conceptId": 506,
  133. "conceptName": "疾病相关药物治疗",
  134. "nodeList": [],
  135. "libType": [101],
  136. "level": 1,
  137. "sonRelationId": 17,
  138. "isExpanded": false
  139. }, {
  140. "conceptId": 507,
  141. "conceptName": "疾病相关手术治疗",
  142. "nodeList": [],
  143. "libType": [106],
  144. "level": 1,
  145. "sonRelationId": 17,
  146. "isExpanded": false
  147. }, {
  148. "conceptId": 508,
  149. "conceptName": "疾病相关鉴别诊断",
  150. "nodeList": [],
  151. "libType": [100],
  152. "level": 1,
  153. "sonRelationId": 17,
  154. "isExpanded": false
  155. }],
  156. "level": 0,
  157. "isExpanded": false
  158. },
  159. curId:'1',
  160. list: [],
  161. defaultProps: {
  162. children: 'nodeList',
  163. label: 'conceptName'
  164. },
  165. conceptList: [], //概念列表
  166. showSearch: false,
  167. addLevel: 0, //添加级别
  168. excludedConceptIds:[],
  169. operaList: [],
  170. relationConceptId: '', //关联父类ID
  171. level: 0, //层级(修改时只能显示三级)
  172. saveDisable: false, //保存按钮禁止点击
  173. defaultExpandedArr: [],
  174. relationTypes:[]
  175. }
  176. },
  177. created(){
  178. this.getTreeList(1)
  179. },
  180. methods:{
  181. addConcept(e) {
  182. this.addLevel = 0;
  183. this.openSearch(e);
  184. },
  185. getTreeList(id){
  186. const { isEdit, data } = this.$route.params
  187. if(isEdit) {
  188. this.isEdit = isEdit
  189. this.minTitle = '疾病相关维护-修改'
  190. const paramData = JSON.parse(JSON.stringify(data))
  191. let result = paramData.diseaseDetailDTO||{}
  192. // this.relationTypes = paramData.types[0]||[]
  193. const itemStr = JSON.stringify(result)
  194. let tmp = itemStr.replace(/disName/g,'conceptName').replace(/rname/g,'conceptName').replace(/datas/g,'nodeList').replace(/details/g,'nodeList').replace(/id/g,'conceptId').replace(/sconceptId/g,'conceptId').replace(/rconceptId/g,'conceptId').replace(/libName/g,'conceptName')
  195. let item = JSON.parse(tmp)
  196. item.level = 0
  197. item.isExpanded = false
  198. item.nodeList = this.IteraNodeList(item.nodeList, [], 1)
  199. let arr = []
  200. arr[0] = item
  201. this.list = [...arr]
  202. }
  203. },
  204. allowDrop(draggingNode, dropNode, type) {
  205. if(draggingNode.parent.data.conceptName !== dropNode.parent.data.conceptName){
  206. return false
  207. }else{
  208. return type !== 'inner'
  209. }
  210. },
  211. allowDrag(draggingNode) {
  212. return draggingNode.data.level != 0;//一级不可拖动
  213. },
  214. handleNodeClick(data) {
  215. if(data.nodeList.length > 0) {
  216. if(!data.isExpanded) {
  217. this.defaultExpandedArr.push(data.conceptId)
  218. } else {
  219. this.defaultExpandedArr = this.defaultExpandedArr.filter(item => item !== data.conceptId)
  220. }
  221. this.$set(data, 'isExpanded', !data.isExpanded);
  222. }
  223. },
  224. confirm() {
  225. if(!this.list[0] || this.list[0].nodeList.length == 0) {
  226. this.message('请输入数据信息');
  227. return
  228. }
  229. const param = {
  230. conceptId: this.list[0].conceptId,
  231. sonRelationId: 17,
  232. isOrderBy: 1
  233. }
  234. const nodeListResult = []
  235. this.IteraNodeList(this.list[0].nodeList, nodeListResult, 0)
  236. param.nodeList = nodeListResult
  237. this.saveDisable = true //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  238. api.diseaseBaseSave(this.reparams(param)).then((res) => {
  239. const { data } = res
  240. if(data.code == '0') {
  241. this.message(res.data.msg||'保存成功','success');
  242. this.$router.push({
  243. name: 'AboutDisease',
  244. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  245. });
  246. } else {
  247. this.message(data.msg);
  248. }
  249. this.saveDisable = false;
  250. })
  251. },
  252. IteraNodeList(nodeList, nodeListResult, type, level = 1) {
  253. this.level= level + 1
  254. for(let i = 0; i <nodeList.length; i++) {
  255. let newChild;
  256. if(type == '0') { //添加的时候保存所有的id列表
  257. newChild = {conceptId: nodeList[i].conceptId,libType:nodeList[i].libType, relationId: 17,nodeList:[],sonRelationId: 17, isExpanded:false}
  258. } else if(type == '1') { //修改的时候添加层级
  259. const item = JSON.parse(JSON.stringify(nodeList[i]))
  260. newChild = Object.assign(item, {level: level, nodeList: [],sonRelationId: 17, isExpanded:false})
  261. } else if(type == '2') { //移除节点的时候同时移除节点(搜索时排除的id列表)
  262. newChild = nodeList[i].conceptId
  263. }
  264. if(nodeList[i].nodeList &&nodeList[i].nodeList.length > 0&&level < 3) {
  265. if(type == '0' || type =='1') {
  266. this.IteraNodeList(nodeList[i].nodeList, newChild.nodeList, type, level+1)
  267. } else if(type == '2') {
  268. this.IteraNodeList(nodeList[i].nodeList, nodeListResult, type, level+1)
  269. }
  270. }
  271. newChild&&nodeListResult.push(newChild)
  272. }
  273. return nodeListResult
  274. },
  275. searchConcept(txt) {
  276. let excludedConceptIds = [];
  277. if(!txt){
  278. this.conceptList = []
  279. return
  280. }
  281. if(this.list.length>0) {
  282. this.excludedConceptIds = this.IteraNodeList(this.list[0].nodeList,excludedConceptIds, 2)
  283. }
  284. const {libType} = this.operaList
  285. this.list.length>0&&this.excludedConceptIds.push(this.list[0].conceptId)
  286. const params = {
  287. "name": txt,
  288. "excludedConceptIds": this.excludedConceptIds||[],
  289. "libType": this.addLevel == 0?100:libType&&libType[0]||''
  290. }
  291. api.searchConcept(params).then((res) => {
  292. const { data } = res
  293. if(data.code == '0') {
  294. this.conceptList = data.data
  295. }
  296. })
  297. },
  298. selectConcept(data) {
  299. const {item,txt} = data
  300. if(this.addLevel == 0) {
  301. let temp = JSON.parse(JSON.stringify(this.template))
  302. temp.conceptId = item.conceptId
  303. temp.conceptName = item.conceptName
  304. this.list = [temp]
  305. }else {
  306. const data = this.operaList
  307. const newChild = Object.assign({}, item, {nodeList: [],libType:data.libType, level: data.level+1, conceptId: item.conceptId, relationId: 17,sonRelationId: 17});
  308. // const newChild = { id: id++, label: 'nodeList', level: data.level+1, children: [] };
  309. if (!data.nodeList) {
  310. this.$set(data, 'nodeList', []);
  311. }
  312. data.nodeList.push(newChild);
  313. }
  314. this.conceptList = [];
  315. this.searchConcept(txt)
  316. // this.closeSearch();
  317. },
  318. openSearch(e) {
  319. this.showSearch = true
  320. },
  321. closeSearch() {
  322. this.conceptText = ''
  323. this.conceptList = []
  324. this.showSearch = false
  325. },
  326. append(data, e) {
  327. this.addLevel = data.level+1;
  328. this.relationConceptId = data.conceptId
  329. this.operaList = data;
  330. this.openSearch(data);
  331. // const newChild = { id: id++, label: 'testtest', level: data.level+1, nodeList: [] };
  332. // if (!data.nodeList) {
  333. // this.$set(data, 'nodeList', []);
  334. // }
  335. // data.nodeList.push(newChild);
  336. },
  337. remove(node, data) {
  338. const parent = node.parent;
  339. const nodeList = parent.data.nodeList || parent.data;
  340. const index = nodeList.findIndex(d => d.conceptId === data.conceptId);
  341. nodeList.splice(index, 1);
  342. },
  343. reparams(param){
  344. let params = []
  345. const tmplis = param.nodeList||[];
  346. for(let i = 0;i < tmplis.length;i++){
  347. let item = tmplis[i],sonIds=[]
  348. if(item.nodeList&&item.nodeList.length>0){
  349. for(let j = 0;j < item.nodeList.length;j++){
  350. sonIds.push(item.nodeList[j].conceptId)
  351. }
  352. }
  353. let obj = {
  354. "sid": param.conceptId,
  355. "rid": item.conceptId,
  356. "eids": sonIds,
  357. // "eid": item.libType[0],
  358. // "srid": 0
  359. }
  360. params.push(obj)
  361. }
  362. return params
  363. },
  364. message(msg,type){
  365. this.$message({
  366. showClose: true,
  367. message:msg,
  368. type:type||'warning'
  369. })
  370. },
  371. }
  372. }
  373. </script>
  374. <style lang="less" scoped>
  375. @import "../../less/admin.less";
  376. .content {
  377. min-width: auto;
  378. box-sizing: border-box;
  379. }
  380. .contents {
  381. box-sizing: border-box;
  382. box-sizing: border-box;
  383. }
  384. .addMedicalMultRelationWrapper {
  385. height: calc(100% - 70px);
  386. }
  387. .tree {
  388. margin-bottom: 230px;
  389. }
  390. .contents {
  391. height: 100%;
  392. padding-top: 60px;
  393. }
  394. .btn-box {
  395. position: absolute;
  396. left: 350px;
  397. }
  398. .btn-del {
  399. color: #8F8F8F;
  400. padding-left: 28px;
  401. }
  402. .addBtn {
  403. width: 66px;
  404. order: 1px solid #21CBC7;
  405. border-radius: 2px;
  406. }
  407. .conceptSearch {
  408. position: fixed;
  409. right: 20px;
  410. top: 180px;
  411. bottom: 10px;
  412. width: 300px;
  413. background: #fff;
  414. border: 1px solid #C9C9C9;
  415. text-align: center;
  416. z-index: 2;
  417. padding: 30px;
  418. box-sizing: border-box;
  419. .conceptTitle {
  420. width: 100%;
  421. text-align: center;
  422. padding: 20px 0;
  423. }
  424. .searchText {
  425. padding: 0 35px 0 15px;
  426. width: 100%;
  427. height: 34px;
  428. border: 1px solid #C9C9C9;
  429. box-sizing: border-box;
  430. }
  431. .conceptList {
  432. min-height: 200px;
  433. max-height:300px;
  434. margin: -2px auto 0;
  435. border: 1px solid #E1DFDF;
  436. overflow: hidden;
  437. overflow-y: auto;
  438. }
  439. .conceptItem {
  440. height: 34px;
  441. line-height: 34px;
  442. text-align: left;
  443. padding: 0 15px;
  444. cursor: pointer;
  445. }
  446. .conceptItem:hover {
  447. background: #f5f7fa;
  448. }
  449. .closeSearch {
  450. position: absolute;
  451. width: 30px;
  452. right: 0;
  453. top: 0;
  454. }
  455. .searchWrap {
  456. position: relative;
  457. .search {
  458. position: absolute;
  459. right: 7px;
  460. top:8px;
  461. }
  462. }
  463. }
  464. .delete {
  465. cursor: pointer;
  466. }
  467. .content{
  468. background: #fff;
  469. padding: 20px 20px 30px;
  470. color: #545455;
  471. }
  472. .btn {
  473. text-align: center;
  474. margin-top: 20px;
  475. }
  476. .custom-tree-node-name {
  477. display: inline-block;
  478. width: 270px;
  479. }
  480. .colorGray {
  481. color: #c1c1c1;
  482. }
  483. </style>