AddConceptRelation.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531
  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:null,
  122. typeList:[],
  123. nodeList:[],
  124. saveDisable: false, //保存按钮禁止点击
  125. conceptType:'',
  126. searchType:''
  127. }
  128. },
  129. created(){
  130. const { isEdit, data , filter} = this.$route.params;
  131. const typeL = filter.type.toString().split('101');
  132. this.conceptType = typeL[0];
  133. this.searchType = typeL[1];
  134. if(isEdit) {
  135. this.titleText = '修改';
  136. this.isEdit = isEdit;
  137. this.rightTagsList = data.nodeList;
  138. this.form.conceptId =data.conceptId;
  139. this.form.conceptName =data.conceptName;
  140. this.form.conceptNameType =data.conceptNameType;
  141. }
  142. let typeList = JSON.parse(localStorage.getItem("knowledgeEnumsData"));
  143. // this.typeList = typeList.lexiconTypeEnum;
  144. this.typeList = typeList.concatLexiconTypeEnum; //7-8 RGB
  145. this.getTagList();//获取标签池内容
  146. },
  147. watch: {
  148. searchTagVal(newVal, preVal) {
  149. if(newVal.trim() != preVal.trim()){
  150. this.getTagList(false)
  151. }
  152. },
  153. type(newVal,preVal){
  154. if(newVal != preVal){
  155. this.getTagList(true)
  156. }
  157. }
  158. },
  159. methods: {
  160. close() {
  161. this.conceptList =[];
  162. },
  163. back(){
  164. this.$router.go(-1);
  165. },
  166. searchDiag() {
  167. const param = {
  168. "name": this.searchDiagVal,
  169. "relationId": 17,
  170. "relationPosition": 1,
  171. "typeId":this.conceptType,
  172. "relationTypeId":this.searchType //9-19新增
  173. }
  174. api.getConceptInfoAssay(param).then((res)=>{
  175. if(res.data.code === '0') {
  176. this.conceptList = res.data.data
  177. }
  178. })
  179. },
  180. selectDiag(item) {
  181. this.form.conceptId = item.conceptId;
  182. this.form.conceptName = item.conceptName;
  183. this.form.conceptNameType = item.conceptNameType;
  184. this.searchDiagVal = '';
  185. this.conceptList=[];
  186. },
  187. focuInput() {
  188. },
  189. getTagList(flag) {
  190. const notIds = this.selectedTags();
  191. //2019-8-15 需求修改:搜索结果与类型关联bug2045
  192. let param = {
  193. "name": this.searchTagVal,
  194. "relationId": 17,
  195. "relationPosition": 2,
  196. // "typeId": this.type, //选中类型的id
  197. "typeId": this.searchType, //选中类型的id
  198. "relationConceptId":this.form.conceptId,
  199. "excludedConceptIds":notIds
  200. }
  201. // let param;
  202. /*if(flag){
  203. param = {
  204. "name": this.searchTagVal,
  205. "relationId": 17,
  206. "relationPosition": 2,
  207. "typeId": this.type, //选中类型的id
  208. "relationConceptId":this.form.conceptId,
  209. "excludedConceptIds":notIds
  210. }
  211. }else{// 单独搜索时不带类型限制
  212. param = {
  213. "name": this.searchTagVal,
  214. "relationId": 17,
  215. "relationPosition": 2,
  216. "relationConceptId":this.form.conceptId,
  217. "excludedConceptIds":notIds
  218. }
  219. }*/
  220. api.getConceptInfoAssay(param).then((res)=>{
  221. if(res.data.code === '0') {
  222. this.leftTagsList = res.data.data
  223. }
  224. })
  225. },
  226. selectedTags() {//右侧选项ids
  227. let selectedTags = []
  228. for (let i =0; i < this.rightTagsList.length; i++) {
  229. selectedTags.push(this.rightTagsList[i].conceptId)
  230. }
  231. return selectedTags
  232. },
  233. selectLeftTag(tag, index, e) {
  234. const hasTag = this.isHasTag(tag, this.selectLeftTagsList)
  235. if (hasTag) {
  236. this.selectLeftTagsList = this.selectLeftTagsList.filter(item => item.conceptId !== tag.conceptId)
  237. } else {
  238. this.selectLeftTagsList.push(tag);
  239. }
  240. },
  241. selectRightTag(index) {
  242. this.selectRightTagIndex = this.selectRightTagIndex === index ? -1 : index
  243. },
  244. toRightList(){
  245. if(this.selectLeftTagsList.length==0){
  246. return
  247. }
  248. this.rightTagsList.push(...this.selectLeftTagsList);
  249. this.selectLeftTagsList = [];
  250. this.selectRightTagIndex = -1;
  251. if(this.searchTagVal.trim()){
  252. this.getTagList(false);
  253. }else{
  254. this.getTagList(true)
  255. }
  256. },
  257. toLeftList(){
  258. if(this.selectRightTagIndex == -1) {
  259. return
  260. }
  261. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  262. this.selectLeftTagsList = [];
  263. this.selectRightTagIndex -= 1;
  264. if(this.searchTagVal.trim()){
  265. this.getTagList(false);
  266. }else{
  267. this.getTagList(true)
  268. }
  269. },
  270. toUp(){
  271. if(this.selectRightTagIndex === 0 || this.selectRightTagIndex === -1) {
  272. return
  273. }
  274. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  275. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  276. this.rightTagsList.splice(this.selectRightTagIndex-1, 0,tempItem)
  277. this.selectRightTagIndex -= 1
  278. },
  279. toDown(){
  280. if(this.selectRightTagIndex === this.rightTagsList.length-1 || this.selectRightTagIndex === -1) {
  281. return
  282. }
  283. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  284. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  285. this.rightTagsList.splice(this.selectRightTagIndex+1, 0,tempItem)
  286. this.selectRightTagIndex += 1
  287. },
  288. isHasTag(item, arr) {
  289. for ( let i = 0; i <arr.length; i++) {
  290. if(arr[i].conceptId === item.conceptId) {
  291. return true;
  292. }
  293. }
  294. return false;
  295. },
  296. getStyle(item){ //左侧选中状态
  297. return this.isHasTag(item, this.selectLeftTagsList)
  298. },
  299. getStyle2(item) {
  300. return this.isHasTag(item, this.selectRightTagsList)
  301. },
  302. submitForm(formName) {
  303. if(!this.form.conceptId) {
  304. this.warning('请选择术语')
  305. return
  306. }
  307. if(this.rightTagsList.length === 0) {
  308. this.warning('请添加关联术语')
  309. return
  310. }
  311. this.showDelDialog()
  312. },
  313. showDelDialog() {
  314. const rightTagsList = this.rightTagsList;
  315. for (let i = 0; i < rightTagsList.length; i++) {
  316. let item = {};
  317. item.conceptId = rightTagsList[i].conceptId;
  318. item.relationId = 17;
  319. this.nodeList.push(item);
  320. }
  321. const param ={
  322. "conceptId": this.form.conceptId,
  323. "nodeList": this.nodeList,
  324. "sonRelationId": 17,
  325. "sonTypeId":this.searchType //9-20新增
  326. }
  327. this.showConfirmDialog('是否建立该关联?', () => {
  328. this.saveDisable = true; //提交保存按钮不可点击,返回结果时才可点击,防止频繁发送请求
  329. api.addConceptRelation(param).then((res) => {
  330. if (res.data.code === '0') {
  331. this.warning(res.data.msg || '关联成功', 'success','1000')
  332. setTimeout(() => {
  333. //返回带搜索条件的首页
  334. this.$router.push({
  335. name:'ConceptRelation',
  336. params: Object.assign({}, this.$route.params, {currentPage: 1})
  337. })
  338. }, 1000);
  339. } else {
  340. this.warning(res.data.msg)
  341. }
  342. this.saveDisable = false
  343. }).catch((err) => {
  344. this.warning(err);
  345. })
  346. });
  347. },
  348. showConfirmDialog(msg, resolve) {
  349. this.$alert(msg, '提示', {
  350. confirmButtonText: '确定',
  351. type: 'warning'
  352. }).then(() => {
  353. resolve();
  354. }).catch(() => {});
  355. },
  356. warning(msg, type,time) {
  357. this.$message({
  358. showClose: true,
  359. message: msg,
  360. type: type || 'warning',
  361. duration:time || '3000'
  362. })
  363. },
  364. }
  365. }
  366. </script>
  367. <style lang="less">
  368. @import '../../less/common.less';
  369. .addConceptRelationBox {
  370. color: #606266;
  371. font-size: 14px;
  372. .topBack {
  373. top: 0;
  374. }
  375. .groupTitle {
  376. background-color: #fff;
  377. height: 40px;
  378. line-height: 40px;
  379. padding-left: 20px;
  380. }
  381. .searchInput, .searchName {
  382. display: inline-block;
  383. height: 32px;
  384. line-height: 32px;
  385. border: 1px solid #a9a9a9;
  386. margin: 0px 0 0 0;
  387. padding: 0 5px;
  388. float: left;
  389. }
  390. .isRequired .el-form-item__label::before {
  391. content: '*';
  392. color: red;
  393. }
  394. .searchName {
  395. border-left: none;
  396. cursor: pointer;
  397. padding: 0 12px;
  398. font-size: 16px;
  399. }
  400. .itemList {
  401. position: absolute;
  402. background: #fff;
  403. width: 162px;
  404. max-height: 150px;
  405. border: 1px solid #a9a9a9;
  406. left: 82px;
  407. top: 33px;
  408. z-index: 2;
  409. overflow-y: auto;
  410. }
  411. .diagItem {
  412. padding: 0 5px;
  413. height: 30px;
  414. line-height: 30px;
  415. font-size: 14px;
  416. cursor: pointer;
  417. }
  418. .diagItem:hover {
  419. background: #f5f7fa;
  420. }
  421. .addDepartForm {
  422. background-color: #fff;
  423. // padding: 20px;
  424. padding: 20px 20px 0 20px;
  425. margin: 70px 20px 0px 20px;
  426. border-bottom: 1px solid #a9a9a9;
  427. }
  428. .symptomList {
  429. background-color: #fff;
  430. padding: 20px;
  431. margin: 0px 20px 0px 20px;
  432. height: 500px;
  433. }
  434. .bottomPartLeft {
  435. width: 32%;
  436. }
  437. .symptomPoolTitle {
  438. height: 40px;
  439. line-height: 40px;
  440. }
  441. .symptomPool {
  442. width: 100%;
  443. .el-input__inner {
  444. border-radius: 0;
  445. }
  446. }
  447. .tagList {
  448. width: 100%;
  449. height: 300px;
  450. border: 1px solid @icssBorder;
  451. box-sizing: border-box;
  452. // border-top: none;
  453. }
  454. /* .tagList {
  455. border: 1px solid @icssBorder;
  456. } */
  457. .tagPool {
  458. height: 300px;
  459. overflow-y: auto;
  460. border-top: none;
  461. }
  462. .tagItem {
  463. position: relative;
  464. line-height: 30px;
  465. cursor: pointer;
  466. padding: 0 10px;
  467. }
  468. .tagName:before {
  469. content: '['
  470. }
  471. .tagName::after {
  472. content: ']'
  473. }
  474. .bottomPartMid {
  475. width: 8%;
  476. margin-top: 220px;
  477. p {
  478. width: 100%;
  479. text-align: center;
  480. span {
  481. cursor: pointer;
  482. display: inline-block;
  483. width: 30px;
  484. height: 40px;
  485. line-height: 40px;
  486. margin: 0 auto;
  487. border: 1px solid @icssBorder;
  488. margin-bottom: 15px;
  489. font-size: 18px;
  490. }
  491. }
  492. }
  493. .bottomPartRight {
  494. width: 32%;
  495. margin-top: 101px;
  496. }
  497. .operationPool {
  498. position: relative;
  499. width: 100%;
  500. height: 340px;
  501. padding: 10px 0;
  502. overflow-y: auto;
  503. }
  504. .btn {
  505. position: relative;
  506. background-color: #fff;
  507. margin: 0px 20px;
  508. padding: 20px;
  509. .el-button {
  510. position: absolute;
  511. right: 20px;
  512. top: -20px;
  513. }
  514. }
  515. .assayTitle{
  516. font-weight: bold;
  517. margin-bottom: 20px;
  518. }
  519. }
  520. </style>