AddDisAndScaleRelation.vue 14 KB

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