AddConceptRelation.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  1. <template>
  2. <div class="addConceptRelationBox" @click="close">
  3. <crumbs
  4. :title="'医学术语关联维护-'+titleText"
  5. class="topBack"
  6. :param="$route.params"
  7. linkTo="ConceptRelation"
  8. ></crumbs>
  9. <el-form :model="form" ref="ruleForm" class="addDepartForm">
  10. <p class="assayTitle">选择医学标准术语</p>
  11. <el-form-item v-if="!isEdit" label="术语搜索:" prop="department">
  12. <input class="searchInput" @focus="focuInput" type="text" v-model = "searchDiagVal">
  13. <span class="searchName" @click="searchDiag">搜索</span>
  14. <!-- <ul class="itemList conceptList" ref="conceptList"> -->
  15. <ul class="itemList" v-show="conceptList.length>0">
  16. <li
  17. v-for="item in conceptList"
  18. class="diagItem ellipsis"
  19. :title="item.conceptNameType"
  20. @click="selectDiag(item)"
  21. :key="item.conceptId">
  22. {{item.conceptNameType||item.conceptName}}
  23. </li>
  24. </ul>
  25. </el-form-item>
  26. <el-form-item class="isRequired" label="已选择术语:" prop="type">
  27. {{form.conceptNameType}}
  28. </el-form-item>
  29. </el-form>
  30. <div class="symptomList">
  31. <div class="bottomPartLeft fl">
  32. <p class="assayTitle">关联标准术语</p>
  33. <p class="symptomPoolTitle">术语搜索</p>
  34. <el-form>
  35. <el-form-item label="类型:">
  36. <el-select v-model="type" placeholder="请选择" size="small">
  37. <el-option
  38. v-for="item in typeList"
  39. :key="item.key"
  40. :label="item.name"
  41. :value="item.key">
  42. </el-option>
  43. </el-select>
  44. </el-form-item>
  45. </el-form>
  46. <div class="symptomPool">
  47. <el-input
  48. placeholder="请输入搜索内容"
  49. v-model="searchTagVal">
  50. <i slot="prefix" class="el-input__icon el-icon-search"></i>
  51. </el-input>
  52. <ul class="tagList tagPool">
  53. <li v-for="(item, index) in leftTagsList"
  54. class = "tagItem"
  55. :key='item.conceptId'
  56. :title="item.conceptNameType"
  57. :style="getStyle(item)?styles:null"
  58. @click='selectLeftTag(item, index)'
  59. >
  60. <!-- <p class="tagName ellipsis" >{{item.conceptName}} </p> -->
  61. <p class="ellipsis" >{{item.conceptNameType}} </p>
  62. </li>
  63. </ul>
  64. </div>
  65. </div>
  66. <div class="bottomPartMid fl">
  67. <p><span class="el-icon-arrow-right" @click="toRightList"></span></p>
  68. <p><span class="el-icon-arrow-left" @click="toLeftList"></span></p>
  69. </div>
  70. <div class="bottomPartRight fl">
  71. <p class="symptomPoolTitle">已选内容:</p>
  72. <ul class="tagList operationPool">
  73. <li class = "tagItem"
  74. v-for="(item,index) in rightTagsList"
  75. :key='item.conceptId'
  76. :style="index === selectRightTagIndex?styles:null"
  77. @click='selectRightTag(index)'
  78. >
  79. <!-- <p v-if="item.conceptName" class="tagName ellipsis" :title="'[ '+item.conceptName+' ]'">{{item.conceptName}} </p> -->
  80. <p v-if="item.conceptName" class="ellipsis" :title="item.conceptNameType">{{item.conceptNameType}} </p>
  81. </li>
  82. </ul>
  83. </div>
  84. <div class="bottomPartMid fl" >
  85. <p><span class="el-icon-arrow-up" @click="toUp"></span></p>
  86. <p><span class="el-icon-arrow-down" @click="toDown"></span></p>
  87. </div>
  88. </div>
  89. <div class="btn">
  90. <el-button
  91. type="primary"
  92. :disabled = 'saveDisable'
  93. @click="submitForm('ruleForm')"
  94. >确 定</el-button>
  95. </div>
  96. </div>
  97. </template>
  98. <script>
  99. import api from '@api/icss.js';
  100. export default {
  101. name: 'AddConceptRelation',
  102. data() {
  103. return{
  104. form: {
  105. conceptId: '',
  106. conceptName:'',
  107. conceptNameType:''
  108. },
  109. titleText: '添加',
  110. conceptList: [],
  111. searchDiagVal: '',
  112. searchTagVal: '',
  113. isEdit: false,
  114. leftTagsList:[],
  115. rightTagsList:[], //右侧已选的左侧不能再搜出--去重处理
  116. selectLeftTagsList: [],
  117. selectRightTagIndex: -1,
  118. styles:{
  119. background:'#eae7e7'
  120. },
  121. type:'',
  122. typeList:[],
  123. nodeList:[],
  124. saveDisable: false //保存按钮禁止点击
  125. }
  126. },
  127. created(){
  128. const { isEdit, data } = this.$route.params;
  129. if(isEdit) {
  130. this.titleText = '修改';
  131. this.isEdit = isEdit;
  132. this.rightTagsList = data.nodeList;
  133. this.form.conceptId =data.conceptId;
  134. this.form.conceptName =data.conceptName;
  135. this.form.conceptNameType =data.conceptNameType;
  136. }
  137. let typeList = JSON.parse(localStorage.getItem("knowledgeEnumsData"));
  138. // this.typeList = typeList.lexiconTypeEnum;
  139. this.typeList = typeList.concatLexiconTypeEnum; //7-8 RGB
  140. },
  141. watch: {
  142. searchTagVal(newVal, preVal) {
  143. if(newVal.trim() != preVal.trim()){
  144. this.getTagList(false)
  145. }
  146. },
  147. type(newVal,preVal){
  148. if(newVal != preVal){
  149. this.getTagList(true)
  150. }
  151. }
  152. },
  153. methods: {
  154. close() {
  155. this.conceptList =[];
  156. },
  157. back(){
  158. this.$router.go(-1);
  159. },
  160. searchDiag() {
  161. const param = {
  162. "name": this.searchDiagVal,
  163. "relationId": 17,
  164. "relationPosition": 1
  165. }
  166. api.getConceptInfoAssay(param).then((res)=>{
  167. if(res.data.code === '0') {
  168. this.conceptList = res.data.data
  169. }
  170. })
  171. },
  172. selectDiag(item) {
  173. this.form.conceptId = item.conceptId;
  174. this.form.conceptName = item.conceptName;
  175. this.form.conceptNameType = item.conceptNameType;
  176. this.searchDiagVal = '';
  177. this.conceptList=[];
  178. },
  179. focuInput() {
  180. },
  181. getTagList(flag) {
  182. const notIds = this.selectedTags();
  183. let param;
  184. if(flag){
  185. param = {
  186. "name": this.searchTagVal,
  187. "relationId": 17,
  188. "relationPosition": 2,
  189. "typeId": this.type, //选中类型的id
  190. "relationConceptId":this.form.conceptId,
  191. "excludedConceptIds":notIds
  192. }
  193. }else{// 单独搜索时不带类型限制
  194. param = {
  195. "name": this.searchTagVal,
  196. "relationId": 17,
  197. "relationPosition": 2,
  198. "relationConceptId":this.form.conceptId,
  199. "excludedConceptIds":notIds
  200. }
  201. }
  202. api.getConceptInfoAssay(param).then((res)=>{
  203. if(res.data.code === '0') {
  204. this.leftTagsList = res.data.data
  205. }
  206. })
  207. },
  208. selectedTags() {//右侧选项ids
  209. let selectedTags = []
  210. for (let i =0; i < this.rightTagsList.length; i++) {
  211. selectedTags.push(this.rightTagsList[i].conceptId)
  212. }
  213. return selectedTags
  214. },
  215. selectLeftTag(tag, index, e) {
  216. const hasTag = this.isHasTag(tag, this.selectLeftTagsList)
  217. if (hasTag) {
  218. this.selectLeftTagsList = this.selectLeftTagsList.filter(item => item.conceptId !== tag.conceptId)
  219. } else {
  220. this.selectLeftTagsList.push(tag);
  221. }
  222. },
  223. selectRightTag(index) {
  224. this.selectRightTagIndex = this.selectRightTagIndex === index ? -1 : index
  225. },
  226. toRightList(){
  227. if(this.selectLeftTagsList.length==0){
  228. return
  229. }
  230. this.rightTagsList.push(...this.selectLeftTagsList);
  231. this.selectLeftTagsList = [];
  232. this.selectRightTagIndex = -1;
  233. if(this.searchTagVal.trim()){
  234. this.getTagList(false);
  235. }else{
  236. this.getTagList(true)
  237. }
  238. },
  239. toLeftList(){
  240. if(this.selectRightTagIndex == -1) {
  241. return
  242. }
  243. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  244. this.selectLeftTagsList = [];
  245. this.selectRightTagIndex -= 1;
  246. if(this.searchTagVal.trim()){
  247. this.getTagList(false);
  248. }else{
  249. this.getTagList(true)
  250. }
  251. },
  252. toUp(){
  253. if(this.selectRightTagIndex === 0 || this.selectRightTagIndex === -1) {
  254. return
  255. }
  256. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  257. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  258. this.rightTagsList.splice(this.selectRightTagIndex-1, 0,tempItem)
  259. this.selectRightTagIndex -= 1
  260. },
  261. toDown(){
  262. if(this.selectRightTagIndex === this.rightTagsList.length-1 || this.selectRightTagIndex === -1) {
  263. return
  264. }
  265. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  266. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  267. this.rightTagsList.splice(this.selectRightTagIndex+1, 0,tempItem)
  268. this.selectRightTagIndex += 1
  269. },
  270. isHasTag(item, arr) {
  271. for ( let i = 0; i <arr.length; i++) {
  272. if(arr[i].conceptId === item.conceptId) {
  273. return true;
  274. }
  275. }
  276. return false;
  277. },
  278. getStyle(item){ //左侧选中状态
  279. return this.isHasTag(item, this.selectLeftTagsList)
  280. },
  281. getStyle2(item) {
  282. return this.isHasTag(item, this.selectRightTagsList)
  283. },
  284. submitForm(formName) {
  285. if(!this.form.conceptId) {
  286. this.warning('请选择术语')
  287. return
  288. }
  289. if(this.rightTagsList.length === 0) {
  290. this.warning('请添加关联术语')
  291. return
  292. }
  293. this.showDelDialog()
  294. },
  295. showDelDialog() {
  296. const rightTagsList = this.rightTagsList;
  297. for (let i = 0; i < rightTagsList.length; i++) {
  298. let item = {};
  299. item.conceptId = rightTagsList[i].conceptId;
  300. item.relationId = 17;
  301. this.nodeList.push(item);
  302. }
  303. const param ={
  304. "conceptId": this.form.conceptId,
  305. "nodeList": this.nodeList,
  306. "sonRelationId": 17
  307. }
  308. this.showConfirmDialog('是否建立该关联?', () => {
  309. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  310. api.addConceptRelation(param).then((res) => {
  311. if (res.data.code === '0') {
  312. this.warning(res.data.msg || '关联成功', 'success','1000')
  313. setTimeout(() => {
  314. //返回带搜索条件的首页
  315. this.$router.push({
  316. name:'ConceptRelation',
  317. params: Object.assign({}, this.$route.params, {currentPage: 1})
  318. })
  319. }, 1000);
  320. } else {
  321. this.warning(res.data.msg)
  322. }
  323. this.saveDisable = false
  324. }).catch((err) => {
  325. this.warning(err);
  326. })
  327. });
  328. },
  329. showConfirmDialog(msg, resolve) {
  330. this.$alert(msg, '提示', {
  331. confirmButtonText: '确定',
  332. type: 'warning'
  333. }).then(() => {
  334. resolve();
  335. }).catch(() => {});
  336. },
  337. warning(msg, type,time) {
  338. this.$message({
  339. showClose: true,
  340. message: msg,
  341. type: type || 'warning',
  342. duration:time || '3000'
  343. })
  344. },
  345. }
  346. }
  347. </script>
  348. <style lang="less">
  349. @import '../../less/common.less';
  350. .addConceptRelationBox {
  351. color: #606266;
  352. font-size: 14px;
  353. .topBack {
  354. top: 0;
  355. }
  356. .groupTitle {
  357. background-color: #fff;
  358. height: 40px;
  359. line-height: 40px;
  360. padding-left: 20px;
  361. }
  362. .searchInput, .searchName {
  363. display: inline-block;
  364. height: 32px;
  365. line-height: 32px;
  366. border: 1px solid #a9a9a9;
  367. margin: 0px 0 0 0;
  368. padding: 0 5px;
  369. float: left;
  370. }
  371. .isRequired .el-form-item__label::before {
  372. content: '*';
  373. color: red;
  374. }
  375. .searchName {
  376. border-left: none;
  377. cursor: pointer;
  378. padding: 0 12px;
  379. font-size: 16px;
  380. }
  381. .itemList {
  382. position: absolute;
  383. background: #fff;
  384. width: 162px;
  385. max-height: 150px;
  386. border: 1px solid #a9a9a9;
  387. left: 82px;
  388. top: 33px;
  389. z-index: 2;
  390. overflow-y: auto;
  391. }
  392. .diagItem {
  393. padding: 0 5px;
  394. height: 30px;
  395. line-height: 30px;
  396. font-size: 14px;
  397. cursor: pointer;
  398. }
  399. .diagItem:hover {
  400. background: #f5f7fa;
  401. }
  402. .addDepartForm {
  403. background-color: #fff;
  404. // padding: 20px;
  405. padding: 20px 20px 0 20px;
  406. margin: 70px 20px 0px 20px;
  407. border-bottom: 1px solid #a9a9a9;
  408. }
  409. .symptomList {
  410. background-color: #fff;
  411. padding: 20px;
  412. margin: 0px 20px 0px 20px;
  413. height: 500px;
  414. }
  415. .bottomPartLeft {
  416. width: 32%;
  417. }
  418. .symptomPoolTitle {
  419. height: 40px;
  420. line-height: 40px;
  421. }
  422. .symptomPool {
  423. width: 100%;
  424. .el-input__inner {
  425. border-radius: 0;
  426. }
  427. }
  428. .tagList {
  429. width: 100%;
  430. height: 300px;
  431. border: 1px solid @icssBorder;
  432. box-sizing: border-box;
  433. // border-top: none;
  434. }
  435. /* .tagList {
  436. border: 1px solid @icssBorder;
  437. } */
  438. .tagPool {
  439. height: 300px;
  440. overflow-y: auto;
  441. border-top: none;
  442. }
  443. .tagItem {
  444. position: relative;
  445. line-height: 30px;
  446. cursor: pointer;
  447. padding: 0 10px;
  448. }
  449. .tagName:before {
  450. content: '['
  451. }
  452. .tagName::after {
  453. content: ']'
  454. }
  455. .bottomPartMid {
  456. width: 8%;
  457. margin-top: 220px;
  458. p {
  459. width: 100%;
  460. text-align: center;
  461. span {
  462. cursor: pointer;
  463. display: inline-block;
  464. width: 30px;
  465. height: 40px;
  466. line-height: 40px;
  467. margin: 0 auto;
  468. border: 1px solid @icssBorder;
  469. margin-bottom: 15px;
  470. font-size: 18px;
  471. }
  472. }
  473. }
  474. .bottomPartRight {
  475. width: 32%;
  476. margin-top: 101px;
  477. }
  478. .operationPool {
  479. position: relative;
  480. width: 100%;
  481. height: 340px;
  482. padding: 10px 0;
  483. overflow-y: auto;
  484. }
  485. .btn {
  486. position: relative;
  487. background-color: #fff;
  488. margin: 0px 20px;
  489. padding: 20px;
  490. .el-button {
  491. position: absolute;
  492. right: 20px;
  493. top: -20px;
  494. }
  495. }
  496. .assayTitle{
  497. font-weight: bold;
  498. margin-bottom: 20px;
  499. }
  500. }
  501. </style>