AddCommonSymptom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419
  1. <!-- 添加常见科室症状 -->
  2. <template>
  3. <div class="addCommonSymptomWrapper">
  4. <div class="groupTitle"><i
  5. class="el-icon-back"
  6. @click="back"
  7. ></i> 常见症状维护系统--{{titleText}}</div>
  8. <el-form :model="form" ref="ruleForm" :rules="rules" class="addDepartForm">
  9. <el-form-item label="选择科室" prop="department">
  10. <el-select :disabled="isEdit || isDetail" v-model="form.department" placeholder="请添加科室" @change="changeDept" class="selectDepart">
  11. <el-option v-for="item in departList" :key="item.id" :label="item.name" :value="item.id"></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="选择类型" prop="type">
  15. <el-select :disabled="isEdit || isDetail" v-model="form.type" placeholder="请选择类型" @change="changeType" class="selectDepart">
  16. <el-option v-for="item in typeList" :key="item.type" :label="item.typeName" :value="item.type"></el-option>
  17. </el-select>
  18. </el-form-item>
  19. </el-form>
  20. <div class="symptomList">
  21. <div class="bottomPartLeft fl" v-if="!isDetail">
  22. <p class="symptomPoolTitle">症状池</p>
  23. <div class="symptomPool">
  24. <el-input
  25. placeholder="请输入搜索内容"
  26. v-model="searchVal"
  27. >
  28. <i
  29. slot="prefix"
  30. class="el-input__icon el-icon-search"
  31. ></i>
  32. </el-input>
  33. <ul class="tagList tagPool">
  34. <li v-for="(item, index) in leftTagsList"
  35. class = "tagItem"
  36. :key='item.id'
  37. :title="'[ '+item.tagName+' ]'"
  38. :style="getStyle(item)?styles:null"
  39. @click='selectLeftTag(item, index)'
  40. >
  41. <p class="tagName ellipsis" >{{item.tagName}} </p>
  42. </li>
  43. </ul>
  44. </div>
  45. </div>
  46. <div class="bottomPartMid fl" v-if="!isDetail">
  47. <p><span class="el-icon-arrow-right" @click="toRightList"></span></p>
  48. <p><span class="el-icon-arrow-left" @click="toLeftList"></span></p>
  49. </div>
  50. <div class="bottomPartRight fl">
  51. <p class="symptomPoolTitle">常见症状:</p>
  52. <ul class="tagList operationPool">
  53. <li class = "tagItem"
  54. v-for="(item,index) in rightTagsList"
  55. :key='item.id'
  56. :style="index === selectRightTagIndex?styles:null"
  57. @click='isDetail ? "":selectRightTag(index)'
  58. >
  59. <p v-if="item.tagName" class="tagName ellipsis" :title="'[ '+item.tagName+' ]'">{{item.tagName}} </p>
  60. </li>
  61. </ul>
  62. </div>
  63. <div class="bottomPartMid fl" v-if="!isDetail">
  64. <p><span class="el-icon-arrow-up" @click="toUp"></span></p>
  65. <p><span class="el-icon-arrow-down" @click="toDown"></span></p>
  66. </div>
  67. </div>
  68. <div class="btn">
  69. <el-button
  70. type="primary"
  71. @click="submitForm('ruleForm')"
  72. >确 定</el-button>
  73. </div>
  74. </div>
  75. </template>
  76. <script>
  77. import api from '@api/icss.js';
  78. export default {
  79. name: 'AddCommonSymptom',
  80. data() {
  81. return{
  82. rules: {
  83. department:[{required: true, message: '请选择科室', trigger: ['blur']}],
  84. type:[{required: true, message: '请选择类型', trigger: ['blur']}]
  85. },
  86. form: {
  87. department: '',
  88. type:''
  89. },
  90. titleText: '添加科室常见症状',
  91. departList: [],
  92. typeList:[],
  93. searchVal: '',
  94. isEdit: false,
  95. isDetail: false,
  96. leftTagsList:[],
  97. rightTagsList:[],
  98. selectLeftTagsList: [],
  99. selectRightTagIndex: -1,
  100. styles:{
  101. background:'#eae7e7'
  102. },
  103. }
  104. },
  105. created(){
  106. const { isEdit, isDetail, data } = this.$route.params;
  107. if(isEdit || isDetail) {
  108. if(isEdit) {
  109. this.titleText = '修改科室常见症状'
  110. } else {
  111. this.titleText = '科室常见症状详情'
  112. }
  113. this.isEdit = isEdit
  114. this.isDetail = isDetail
  115. this.rightTagsList = data.data
  116. this.departList.push({name: data.name, id: data.id})
  117. this.typeList.push({typeName: data.typeName, type: data.type})
  118. this.form.department =data.id
  119. this.form.type =data.type
  120. this.getSymptomList()
  121. } else {
  122. this.getDepartmentList()
  123. }
  124. },
  125. watch: {
  126. searchVal(newVal, preVal) {
  127. if(newVal.trim() == ''){
  128. this.getSymptomList()
  129. }else if(newVal.trim() != preVal.trim()){
  130. this.getSymptomList()
  131. }
  132. }
  133. },
  134. methods: {
  135. back(){
  136. this.$router.go(-1);
  137. },
  138. getDepartmentList() {
  139. api.getDepartmentList().then((res)=>{
  140. if(res.data.code === '0') {
  141. this.departList = res.data.data
  142. }
  143. })
  144. },
  145. getSymptomList() {
  146. let noIds = []
  147. for (let i =0; i < this.rightTagsList.length; i++) {
  148. noIds.push(this.rightTagsList[i].id)
  149. }
  150. const param = {
  151. "deptId": this.form.department,
  152. "tagName": this.searchVal,
  153. "noIds": noIds,
  154. "type": this.form.type,
  155. "notTagType": [8],
  156. }
  157. api.getSymptomList(param).then((res)=>{
  158. if(res.data.code === '0') {
  159. this.leftTagsList = res.data.data
  160. }
  161. })
  162. },
  163. changeDept() {
  164. this.form.type = ''
  165. this.typeList = this.departList.filter(item => this.form.department == item.id)[0].typeDTOList
  166. this.clearData()
  167. },
  168. changeType() {
  169. this.clearData()
  170. this.getSymptomList()
  171. },
  172. clearData() {
  173. this.leftTagsList = [];
  174. this.rightTagsList = [];
  175. this.selectLeftTagsList = [];
  176. this.selectRightTagIndex = -1;
  177. },
  178. selectLeftTag(tag, index, e) {
  179. const hasTag = this.isHasTag(tag, this.selectLeftTagsList)
  180. if (hasTag) {
  181. this.selectLeftTagsList = this.selectLeftTagsList.filter(item => item.id !== tag.id)
  182. } else {
  183. this.selectLeftTagsList.push(tag);
  184. }
  185. },
  186. selectRightTag(index) {
  187. this.selectRightTagIndex = this.selectRightTagIndex === index ? -1 : index
  188. },
  189. toRightList(){
  190. this.rightTagsList.push(...this.selectLeftTagsList);
  191. this.selectLeftTagsList = [];
  192. this.selectRightTagIndex = -1;
  193. this.getSymptomList()
  194. },
  195. toLeftList(){
  196. if(this.selectRightTagIndex == -1) {
  197. return
  198. }
  199. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  200. this.selectLeftTagsList = [];
  201. this.selectRightTagIndex -= 1;
  202. this.getSymptomList()
  203. },
  204. toUp(){
  205. if(this.selectRightTagIndex === 0 || this.selectRightTagIndex === -1) {
  206. return
  207. }
  208. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  209. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  210. this.rightTagsList.splice(this.selectRightTagIndex-1, 0,tempItem)
  211. this.selectRightTagIndex -= 1
  212. },
  213. toDown(){
  214. if(this.selectRightTagIndex === this.rightTagsList.length-1 || this.selectRightTagIndex === -1) {
  215. return
  216. }
  217. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  218. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  219. this.rightTagsList.splice(this.selectRightTagIndex+1, 0,tempItem)
  220. this.selectRightTagIndex += 1
  221. },
  222. isHasTag(item, arr) {
  223. for ( let i = 0; i <arr.length; i++) {
  224. if(arr[i].id === item.id) {
  225. return true;
  226. }
  227. }
  228. return false;
  229. },
  230. getStyle(item){ //左侧选中状态
  231. return this.isHasTag(item, this.selectLeftTagsList)
  232. },
  233. getStyle2(item) {
  234. return this.isHasTag(item, this.selectRightTagsList)
  235. },
  236. submitForm(formName) {
  237. if(this.isDetail) {
  238. this.$router.push({
  239. path:'/admin/LT-YXSJWH-CJZZWH'
  240. })
  241. return;
  242. }
  243. const valided = this.$refs[formName].validate((valid, callback) => {
  244. if (valid) {
  245. return
  246. } else {
  247. console.log('error submit!!');
  248. return false;
  249. }
  250. });
  251. if(!this.form.department || !this.form.type) {
  252. return
  253. }
  254. if(this.rightTagsList.length === 0) {
  255. this.warning('请选择症状标签')
  256. return
  257. }
  258. this.showDelDialog()
  259. },
  260. showDelDialog() {
  261. let questionId = []
  262. for (let i =0; i < this.rightTagsList.length; i++) {
  263. questionId.push(this.rightTagsList[i].id)
  264. }
  265. const param ={
  266. "deptId": this.form.department,
  267. "questionId": questionId,
  268. "type": this.form.type,
  269. }
  270. this.showConfirmDialog('是否保存常见选项内容?', () => {
  271. api.addCommonSymptom(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-CJZZWH'
  277. })
  278. }, 1000);
  279. } else {
  280. this.warning(res.data.msg)
  281. }
  282. }).catch((err) => {
  283. this.warning(err);
  284. })
  285. });
  286. },
  287. showConfirmDialog(msg, resolve) {
  288. this.$alert(msg, '提示', {
  289. confirmButtonText: '确定',
  290. type: 'warning'
  291. }).then(() => {
  292. resolve();
  293. }).catch(() => {});
  294. },
  295. warning(msg, type,time) {
  296. this.$message({
  297. showClose: true,
  298. message: msg,
  299. type: type || 'warning',
  300. duration:time || '3000'
  301. })
  302. },
  303. }
  304. }
  305. </script>
  306. <style lang="less">
  307. @import '../../less/common.less';
  308. .addCommonSymptomWrapper {
  309. .groupTitle {
  310. background-color: #fff;
  311. height: 40px;
  312. line-height: 40px;
  313. padding-left: 20px;
  314. }
  315. .addDepartForm {
  316. background-color: #fff;
  317. padding: 20px;
  318. margin: 20px 20px 0px 20px;
  319. }
  320. .symptomList {
  321. background-color: #fff;
  322. padding: 20px;
  323. margin: 20px 20px 0px 20px;
  324. height: 500px;
  325. }
  326. .bottomPartLeft {
  327. width: 32%;
  328. }
  329. .symptomPoolTitle {
  330. height: 40px;
  331. line-height: 40px;
  332. }
  333. .symptomPool {
  334. width: 100%;
  335. }
  336. .tagList {
  337. width: 100%;
  338. height: 300px;
  339. border: 1px solid @icssBorder;
  340. box-sizing: border-box;
  341. }
  342. .tagList {
  343. border: 1px solid @icssBorder;
  344. }
  345. .tagPool {
  346. height: 300px;
  347. overflow-y: auto;
  348. }
  349. .tagItem {
  350. position: relative;
  351. line-height: 30px;
  352. cursor: pointer;
  353. padding: 0 10px;
  354. }
  355. .tagName:before {
  356. content: '['
  357. }
  358. .tagName::after {
  359. content: ']'
  360. }
  361. .bottomPartMid {
  362. width: 8%;
  363. margin-top: 60px;
  364. p {
  365. width: 100%;
  366. text-align: center;
  367. span {
  368. cursor: pointer;
  369. display: inline-block;
  370. width: 30px;
  371. height: 40px;
  372. line-height: 40px;
  373. margin: 0 auto;
  374. border: 1px solid @icssBorder;
  375. margin-bottom: 15px;
  376. font-size: 18px;
  377. }
  378. }
  379. }
  380. .bottomPartRight {
  381. width: 32%;
  382. }
  383. .operationPool {
  384. position: relative;
  385. width: 100%;
  386. height: 340px;
  387. padding: 10px 0;
  388. overflow-y: auto;
  389. }
  390. .btn {
  391. position: relative;
  392. background-color: #fff;
  393. margin: 0px 20px;
  394. padding: 20px;
  395. .el-button {
  396. position: absolute;
  397. right: 20px;
  398. top: -20px;
  399. }
  400. }
  401. .selectDepart {
  402. }
  403. }
  404. </style>