DiseaseTree.vue 16 KB

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