DiseaseTree.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492
  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. const params = {
  286. "name": txt,
  287. "excludedConceptIds": this.excludedConceptIds||[],
  288. "libType": this.addLevel == 0?100:libType&&libType[0]||''
  289. }
  290. api.searchConcept(params).then((res) => {
  291. const { data } = res
  292. if(data.code == '0') {
  293. this.conceptList = data.data
  294. }
  295. })
  296. },
  297. selectConcept(data) {
  298. const {item,txt} = data
  299. if(this.addLevel == 0) {
  300. let temp = JSON.parse(JSON.stringify(this.template))
  301. temp.conceptId = item.conceptId
  302. temp.conceptName = item.conceptName
  303. this.list = [temp]
  304. }else {
  305. const data = this.operaList
  306. const newChild = Object.assign({}, item, {nodeList: [],libType:data.libType, level: data.level+1, conceptId: item.conceptId, relationId: 17,sonRelationId: 17});
  307. // const newChild = { id: id++, label: 'nodeList', level: data.level+1, children: [] };
  308. if (!data.nodeList) {
  309. this.$set(data, 'nodeList', []);
  310. }
  311. data.nodeList.push(newChild);
  312. }
  313. this.conceptList = [];
  314. this.searchConcept(txt)
  315. // this.closeSearch();
  316. },
  317. openSearch(e) {
  318. this.showSearch = true
  319. },
  320. closeSearch() {
  321. this.conceptText = ''
  322. this.conceptList = []
  323. this.showSearch = false
  324. },
  325. append(data, e) {
  326. this.addLevel = data.level+1;
  327. this.relationConceptId = data.conceptId
  328. this.operaList = data;
  329. this.openSearch(data);
  330. // const newChild = { id: id++, label: 'testtest', level: data.level+1, nodeList: [] };
  331. // if (!data.nodeList) {
  332. // this.$set(data, 'nodeList', []);
  333. // }
  334. // data.nodeList.push(newChild);
  335. },
  336. remove(node, data) {
  337. const parent = node.parent;
  338. const nodeList = parent.data.nodeList || parent.data;
  339. const index = nodeList.findIndex(d => d.conceptId === data.conceptId);
  340. nodeList.splice(index, 1);
  341. },
  342. reparams(param){
  343. let params = []
  344. const tmplis = param.nodeList||[];
  345. for(let i = 0;i < tmplis.length;i++){
  346. let item = tmplis[i],sonIds=[]
  347. if(item.nodeList&&item.nodeList.length>0){
  348. for(let j = 0;j < item.nodeList.length;j++){
  349. sonIds.push(item.nodeList[j].conceptId)
  350. }
  351. }
  352. let obj = {
  353. "sid": param.conceptId,
  354. "rid": item.conceptId,
  355. "eids": sonIds,
  356. // "eid": item.libType[0],
  357. // "srid": 0
  358. }
  359. params.push(obj)
  360. }
  361. return params
  362. },
  363. message(msg,type){
  364. this.$message({
  365. showClose: true,
  366. message:msg,
  367. type:type||'warning'
  368. })
  369. },
  370. }
  371. }
  372. </script>
  373. <style lang="less" scoped>
  374. @import "../../less/admin.less";
  375. .content {
  376. min-width: auto;
  377. box-sizing: border-box;
  378. }
  379. .contents {
  380. box-sizing: border-box;
  381. box-sizing: border-box;
  382. }
  383. .addMedicalMultRelationWrapper {
  384. height: calc(100% - 70px);
  385. }
  386. .tree {
  387. margin-bottom: 230px;
  388. }
  389. .contents {
  390. height: 100%;
  391. padding-top: 60px;
  392. }
  393. .btn-box {
  394. position: absolute;
  395. left: 350px;
  396. }
  397. .btn-del {
  398. color: #8F8F8F;
  399. padding-left: 28px;
  400. }
  401. .addBtn {
  402. width: 66px;
  403. order: 1px solid #21CBC7;
  404. border-radius: 2px;
  405. }
  406. .conceptSearch {
  407. position: fixed;
  408. right: 20px;
  409. top: 180px;
  410. bottom: 10px;
  411. width: 300px;
  412. background: #fff;
  413. border: 1px solid #C9C9C9;
  414. text-align: center;
  415. z-index: 2;
  416. padding: 30px;
  417. box-sizing: border-box;
  418. .conceptTitle {
  419. width: 100%;
  420. text-align: center;
  421. padding: 20px 0;
  422. }
  423. .searchText {
  424. padding: 0 35px 0 15px;
  425. width: 100%;
  426. height: 34px;
  427. border: 1px solid #C9C9C9;
  428. box-sizing: border-box;
  429. }
  430. .conceptList {
  431. min-height: 200px;
  432. max-height:300px;
  433. margin: -2px auto 0;
  434. border: 1px solid #E1DFDF;
  435. overflow: hidden;
  436. overflow-y: auto;
  437. }
  438. .conceptItem {
  439. height: 34px;
  440. line-height: 34px;
  441. text-align: left;
  442. padding: 0 15px;
  443. cursor: pointer;
  444. }
  445. .conceptItem:hover {
  446. background: #f5f7fa;
  447. }
  448. .closeSearch {
  449. position: absolute;
  450. width: 30px;
  451. right: 0;
  452. top: 0;
  453. }
  454. .searchWrap {
  455. position: relative;
  456. .search {
  457. position: absolute;
  458. right: 7px;
  459. top:8px;
  460. }
  461. }
  462. }
  463. .delete {
  464. cursor: pointer;
  465. }
  466. .content{
  467. background: #fff;
  468. padding: 20px 20px 30px;
  469. color: #545455;
  470. }
  471. .btn {
  472. text-align: center;
  473. margin-top: 20px;
  474. }
  475. .custom-tree-node-name {
  476. display: inline-block;
  477. width: 270px;
  478. }
  479. .colorGray {
  480. color: #c1c1c1;
  481. }
  482. </style>