DiseaseTree.vue 16 KB

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