AddDisAndScaleRelation.vue 14 KB

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