AddDisAndScaleRelation.vue 15 KB

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