DiseaseTree.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  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="() => 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. "level": 0,
  160. "isExpanded": false
  161. },
  162. curId:'1',
  163. list: [],
  164. defaultProps: {
  165. children: 'nodeList',
  166. label: 'conceptName'
  167. },
  168. conceptList: [], //概念列表
  169. showSearch: false,
  170. addLevel: 0, //添加级别
  171. excludedConceptIds:[],
  172. operaList: [],
  173. relationConceptId: '', //关联父类ID
  174. level: 0, //层级(修改时只能显示三级)
  175. saveDisable: false, //保存按钮禁止点击
  176. defaultExpandedArr: [],
  177. relationTypes:[]
  178. }
  179. },
  180. created(){
  181. this.getTreeList(1)
  182. },
  183. methods:{
  184. addConcept(e) {
  185. this.addLevel = 0;
  186. this.openSearch(e);
  187. },
  188. getTreeList(id){
  189. const { isEdit, data } = this.$route.params
  190. if(isEdit) {
  191. this.isEdit = isEdit
  192. this.minTitle = '疾病相关维护-修改'
  193. const paramData = JSON.parse(JSON.stringify(data))
  194. let result = paramData.diseaseDetailDTO||{}
  195. // this.relationTypes = paramData.types[0]||[]
  196. const itemStr = JSON.stringify(result)
  197. 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')
  198. let item = JSON.parse(tmp)
  199. item.level = 0
  200. item.isExpanded = false
  201. item.nodeList = this.IteraNodeList(item.nodeList, [], 1)
  202. let arr = []
  203. arr[0] = item
  204. this.list = [...arr]
  205. }
  206. },
  207. allowDrop(draggingNode, dropNode, type) {
  208. if(draggingNode.parent.data.conceptName !== dropNode.parent.data.conceptName){
  209. return false
  210. }else{
  211. return type !== 'inner'
  212. }
  213. },
  214. allowDrag(draggingNode) {
  215. return draggingNode.data.level > 1;//一级不可拖动
  216. },
  217. handleNodeClick(data) {
  218. if(data.nodeList.length > 0) {
  219. if(!data.isExpanded) {
  220. this.defaultExpandedArr.push(data.conceptId)
  221. } else {
  222. this.defaultExpandedArr = this.defaultExpandedArr.filter(item => item !== data.conceptId)
  223. }
  224. this.$set(data, 'isExpanded', !data.isExpanded);
  225. }
  226. },
  227. confirm() {
  228. if(!this.list[0] || this.list[0].nodeList.length == 0) {
  229. this.message('请输入数据信息');
  230. return
  231. }
  232. const param = {
  233. conceptId: this.list[0].conceptId,
  234. sonRelationId: 17,
  235. isOrderBy: 1
  236. }
  237. const nodeListResult = []
  238. this.IteraNodeList(this.list[0].nodeList, nodeListResult, 0)
  239. param.nodeList = nodeListResult
  240. const {params,grandson} = this.reparams(param)
  241. if(grandson == 0){
  242. this.message('增加子项数据后才能保存~');
  243. return
  244. }
  245. this.saveDisable = true //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  246. api.diseaseBaseSave(params).then((res) => {
  247. const { data } = res
  248. if(data.code == '0') {
  249. this.message(res.data.msg||'保存成功','success');
  250. this.$router.push({
  251. name: 'AboutDisease',
  252. params: Object.assign({}, this.$route.params, { currentPage: 1 })
  253. });
  254. } else {
  255. this.message(data.msg);
  256. }
  257. this.saveDisable = false;
  258. })
  259. },
  260. IteraNodeList(nodeList, nodeListResult, type, level = 1) {
  261. this.level= level + 1
  262. for(let i = 0; i <nodeList.length; i++) {
  263. let newChild;
  264. if(type == '0') { //添加的时候保存所有的id列表
  265. newChild = {conceptId: nodeList[i].conceptId,libType:nodeList[i].libType, relationId: 17,nodeList:[],sonRelationId: 17, isExpanded:false}
  266. } else if(type == '1') { //修改的时候添加层级
  267. const item = JSON.parse(JSON.stringify(nodeList[i]))
  268. newChild = Object.assign(item, {level: level, nodeList: [],sonRelationId: 17, isExpanded:false})
  269. } else if(type == '2') { //移除节点的时候同时移除节点(搜索时排除的id列表)
  270. newChild = nodeList[i].conceptId
  271. }
  272. if(nodeList[i].nodeList &&nodeList[i].nodeList.length > 0&&level < 3) {
  273. if(type == '0' || type =='1') {
  274. this.IteraNodeList(nodeList[i].nodeList, newChild.nodeList, type, level+1)
  275. } else if(type == '2') {
  276. this.IteraNodeList(nodeList[i].nodeList, nodeListResult, type, level+1)
  277. }
  278. }
  279. newChild&&nodeListResult.push(newChild)
  280. }
  281. return nodeListResult
  282. },
  283. searchConcept(txt) {
  284. let excludedConceptIds = [];
  285. if(!txt){
  286. this.conceptList = []
  287. return
  288. }
  289. if(this.list.length>0) {
  290. this.excludedConceptIds = this.IteraNodeList(this.list[0].nodeList,excludedConceptIds, 2)
  291. }
  292. const {libType} = this.operaList
  293. this.list.length>0&&this.excludedConceptIds.push(this.list[0].conceptId)
  294. const params = {
  295. "name": txt,
  296. "diseaseName":txt,
  297. "excludedConceptIds": this.excludedConceptIds||[],
  298. "libType": this.addLevel == 0?100:libType&&libType[0]||''
  299. }
  300. let searchUrl = this.addLevel == 0?'findDisName':'searchConcept'
  301. api[searchUrl](params).then((res) => {
  302. const { data } = res
  303. if(data.code == '0') {
  304. this.conceptList = data.data
  305. }
  306. })
  307. },
  308. selectConcept(data) {
  309. const {item,txt} = data
  310. if(this.addLevel == 0) {
  311. let temp = JSON.parse(JSON.stringify(this.template))
  312. temp.conceptId = item.conceptId
  313. temp.conceptName = item.conceptName
  314. this.list = [temp]
  315. }else {
  316. const data = this.operaList
  317. const newChild = Object.assign({}, item, {nodeList: [],libType:data.libType, level: data.level+1, conceptId: item.conceptId, relationId: 17,sonRelationId: 17});
  318. // const newChild = { id: id++, label: 'nodeList', level: data.level+1, children: [] };
  319. if (!data.nodeList) {
  320. this.$set(data, 'nodeList', []);
  321. }
  322. data.nodeList.push(newChild);
  323. }
  324. this.conceptList = [];
  325. if(this.addLevel == 0){
  326. this.closeSearch();
  327. }else{
  328. this.searchConcept(txt)
  329. }
  330. },
  331. openSearch(e) {
  332. this.showSearch = true
  333. },
  334. closeSearch() {
  335. this.conceptList = []
  336. this.showSearch = false
  337. },
  338. append(data, e) {
  339. if(this.$refs.searchDom){console.log(this.$refs.searchDom.$refs.conceptInput)
  340. this.conceptList = [];
  341. setTimeout(()=>{
  342. this.$refs.searchDom.$refs.conceptInput.value="";
  343. })
  344. }
  345. this.addLevel = data.level+1;
  346. this.relationConceptId = data.conceptId
  347. this.operaList = data;
  348. this.openSearch(data);
  349. // const newChild = { id: id++, label: 'testtest', level: data.level+1, nodeList: [] };
  350. // if (!data.nodeList) {
  351. // this.$set(data, 'nodeList', []);
  352. // }
  353. // data.nodeList.push(newChild);
  354. },
  355. remove(node, data) {
  356. const parent = node.parent;
  357. const nodeList = parent.data.nodeList || parent.data;
  358. const index = nodeList.findIndex(d => d.conceptId === data.conceptId);
  359. nodeList.splice(index, 1);
  360. },
  361. reparams(param){
  362. let params = [],grandson = 0;
  363. const tmplis = param.nodeList||[];
  364. for(let i = 0;i < tmplis.length;i++){
  365. let item = tmplis[i],sonIds=[];
  366. if(item.nodeList&&item.nodeList.length>0){
  367. for(let j = 0;j < item.nodeList.length;j++){
  368. sonIds.push(item.nodeList[j].conceptId)
  369. }
  370. }
  371. if(sonIds.length > 0){
  372. ++grandson
  373. }
  374. let obj = {
  375. "sid": param.conceptId,
  376. "rid": item.conceptId,
  377. "eids": sonIds,
  378. // "eid": item.libType[0],
  379. // "srid": 0
  380. }
  381. params.push(obj)
  382. }
  383. return {params,grandson}
  384. },
  385. message(msg,type){
  386. this.$message({
  387. showClose: true,
  388. message:msg,
  389. type:type||'warning'
  390. })
  391. },
  392. }
  393. }
  394. </script>
  395. <style lang="less" scoped>
  396. @import "../../less/admin.less";
  397. .content {
  398. min-width: auto;
  399. box-sizing: border-box;
  400. }
  401. .contents {
  402. box-sizing: border-box;
  403. box-sizing: border-box;
  404. }
  405. .addMedicalMultRelationWrapper {
  406. height: calc(100% - 70px);
  407. }
  408. .tree {
  409. margin-bottom: 230px;
  410. }
  411. .contents {
  412. height: 100%;
  413. padding-top: 60px;
  414. }
  415. .btn-box {
  416. position: absolute;
  417. left: 350px;
  418. }
  419. .btn-del {
  420. color: #8F8F8F;
  421. padding-left: 28px;
  422. }
  423. .addBtn {
  424. width: 66px;
  425. order: 1px solid #21CBC7;
  426. border-radius: 2px;
  427. }
  428. .conceptSearch {
  429. position: fixed;
  430. right: 20px;
  431. top: 180px;
  432. bottom: 10px;
  433. width: 300px;
  434. background: #fff;
  435. border: 1px solid #C9C9C9;
  436. text-align: center;
  437. z-index: 2;
  438. padding: 30px;
  439. box-sizing: border-box;
  440. .conceptTitle {
  441. width: 100%;
  442. text-align: center;
  443. padding: 20px 0;
  444. }
  445. .searchText {
  446. padding: 0 35px 0 15px;
  447. width: 100%;
  448. height: 34px;
  449. border: 1px solid #C9C9C9;
  450. box-sizing: border-box;
  451. }
  452. .conceptList {
  453. min-height: 200px;
  454. max-height:300px;
  455. margin: -2px auto 0;
  456. border: 1px solid #E1DFDF;
  457. overflow: hidden;
  458. overflow-y: auto;
  459. }
  460. .conceptItem {
  461. height: 34px;
  462. line-height: 34px;
  463. text-align: left;
  464. padding: 0 15px;
  465. cursor: pointer;
  466. }
  467. .conceptItem:hover {
  468. background: #f5f7fa;
  469. }
  470. .closeSearch {
  471. position: absolute;
  472. width: 30px;
  473. right: 0;
  474. top: 0;
  475. }
  476. .searchWrap {
  477. position: relative;
  478. .search {
  479. position: absolute;
  480. right: 7px;
  481. top:8px;
  482. }
  483. }
  484. }
  485. .delete {
  486. cursor: pointer;
  487. }
  488. .content{
  489. background: #fff;
  490. padding: 20px 20px 30px;
  491. color: #545455;
  492. }
  493. .btn {
  494. text-align: center;
  495. margin-top: 20px;
  496. }
  497. .custom-tree-node-name {
  498. display: inline-block;
  499. width: 270px;
  500. }
  501. .colorGray {
  502. color: #c1c1c1;
  503. }
  504. </style>