AddConceptRelation.vue 15 KB

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