DiseaseTree.vue 14 KB

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