AddCommonSymptom.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431
  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="type">
  10. <el-select :disabled="isEdit || isDetail" v-model="form.type" placeholder="请选择类型" @change="changeType" class="selectDepart">
  11. <el-option v-for="item in typeList" :key="item.key" :label="item.name" :value="item.key"></el-option>
  12. </el-select>
  13. </el-form-item>
  14. <el-form-item label="选择科室" prop="department">
  15. <el-select :disabled="isEdit || isDetail || !form.type" v-model="form.department" placeholder="请添加科室" @change="changeDept" class="selectDepart">
  16. <el-option v-for="item in departList" :key="item.id" :label="item.name" :value="item.id"></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. this.getIcssEnumsData()
  124. }
  125. },
  126. watch: {
  127. searchVal(newVal, preVal) {
  128. if(newVal.trim() == ''){
  129. this.getSymptomList()
  130. }else if(newVal.trim() != preVal.trim()){
  131. this.getSymptomList()
  132. }
  133. }
  134. },
  135. methods: {
  136. back(){
  137. this.$router.go(-1);
  138. },
  139. getIcssEnumsData() {
  140. api.getIcssEnumsData().then((res) => {
  141. if(res.data.code === '0') {
  142. console.log(res.data.data.questionTypeEnum)
  143. this.typeList = res.data.data.questionUsualTypeEnum
  144. }
  145. })
  146. },
  147. getDepartmentList() {
  148. const param = {
  149. "type": this.form.type
  150. }
  151. api.getDepartmentList(param).then((res)=>{
  152. if(res.data.code === '0') {
  153. this.departList = res.data.data
  154. }
  155. })
  156. },
  157. getSymptomList() {
  158. let noIds = []
  159. for (let i =0; i < this.rightTagsList.length; i++) {
  160. noIds.push(this.rightTagsList[i].id)
  161. }
  162. const param = {
  163. "deptId": this.form.department,
  164. "tagName": this.searchVal,
  165. "noIds": noIds,
  166. "type": this.form.type,
  167. "notTagType": [8],
  168. }
  169. api.getSymptomList(param).then((res)=>{
  170. if(res.data.code === '0') {
  171. this.leftTagsList = res.data.data
  172. }
  173. })
  174. },
  175. changeDept() {
  176. this.clearData()
  177. this.getSymptomList()
  178. },
  179. changeType() {
  180. this.form.department = ''
  181. this.getDepartmentList()
  182. this.clearData()
  183. },
  184. clearData() {
  185. this.leftTagsList = [];
  186. this.rightTagsList = [];
  187. this.selectLeftTagsList = [];
  188. this.selectRightTagIndex = -1;
  189. },
  190. selectLeftTag(tag, index, e) {
  191. const hasTag = this.isHasTag(tag, this.selectLeftTagsList)
  192. if (hasTag) {
  193. this.selectLeftTagsList = this.selectLeftTagsList.filter(item => item.id !== tag.id)
  194. } else {
  195. this.selectLeftTagsList.push(tag);
  196. }
  197. },
  198. selectRightTag(index) {
  199. this.selectRightTagIndex = this.selectRightTagIndex === index ? -1 : index
  200. },
  201. toRightList(){
  202. this.rightTagsList.push(...this.selectLeftTagsList);
  203. this.selectLeftTagsList = [];
  204. this.selectRightTagIndex = -1;
  205. this.getSymptomList()
  206. },
  207. toLeftList(){
  208. if(this.selectRightTagIndex == -1) {
  209. return
  210. }
  211. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  212. this.selectLeftTagsList = [];
  213. this.selectRightTagIndex -= 1;
  214. this.getSymptomList()
  215. },
  216. toUp(){
  217. if(this.selectRightTagIndex === 0 || this.selectRightTagIndex === -1) {
  218. return
  219. }
  220. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  221. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  222. this.rightTagsList.splice(this.selectRightTagIndex-1, 0,tempItem)
  223. this.selectRightTagIndex -= 1
  224. },
  225. toDown(){
  226. if(this.selectRightTagIndex === this.rightTagsList.length-1 || this.selectRightTagIndex === -1) {
  227. return
  228. }
  229. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  230. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  231. this.rightTagsList.splice(this.selectRightTagIndex+1, 0,tempItem)
  232. this.selectRightTagIndex += 1
  233. },
  234. isHasTag(item, arr) {
  235. for ( let i = 0; i <arr.length; i++) {
  236. if(arr[i].id === item.id) {
  237. return true;
  238. }
  239. }
  240. return false;
  241. },
  242. getStyle(item){ //左侧选中状态
  243. return this.isHasTag(item, this.selectLeftTagsList)
  244. },
  245. getStyle2(item) {
  246. return this.isHasTag(item, this.selectRightTagsList)
  247. },
  248. submitForm(formName) {
  249. if(this.isDetail) {
  250. this.$router.push({
  251. path:'/admin/LT-YXSJWH-CJZZWH'
  252. })
  253. return;
  254. }
  255. const valided = this.$refs[formName].validate((valid, callback) => {
  256. if (valid) {
  257. return
  258. } else {
  259. console.log('error submit!!');
  260. return false;
  261. }
  262. });
  263. if(!this.form.department || !this.form.type) {
  264. return
  265. }
  266. if(this.rightTagsList.length === 0) {
  267. this.warning('请选择常见选项标签')
  268. return
  269. }
  270. this.showDelDialog()
  271. },
  272. showDelDialog() {
  273. let questionId = []
  274. for (let i =0; i < this.rightTagsList.length; i++) {
  275. questionId.push(this.rightTagsList[i].id)
  276. }
  277. const param ={
  278. "deptId": this.form.department,
  279. "questionId": questionId,
  280. "type": this.form.type,
  281. }
  282. this.showConfirmDialog('是否保存常见选项内容?', () => {
  283. api.addCommonSymptom(param).then((res) => {
  284. if (res.data.code === '0') {
  285. this.warning(res.data.msg || '保存成功', 'success','1000')
  286. setTimeout(() => {
  287. this.$router.push({
  288. path:'/admin/LT-YXSJWH-CJZZWH'
  289. })
  290. }, 1000);
  291. } else {
  292. this.warning(res.data.msg)
  293. }
  294. }).catch((err) => {
  295. this.warning(err);
  296. })
  297. });
  298. },
  299. showConfirmDialog(msg, resolve) {
  300. this.$alert(msg, '提示', {
  301. confirmButtonText: '确定',
  302. type: 'warning'
  303. }).then(() => {
  304. resolve();
  305. }).catch(() => {});
  306. },
  307. warning(msg, type,time) {
  308. this.$message({
  309. showClose: true,
  310. message: msg,
  311. type: type || 'warning',
  312. duration:time || '3000'
  313. })
  314. },
  315. }
  316. }
  317. </script>
  318. <style lang="less">
  319. @import '../../less/common.less';
  320. .addCommonSymptomWrapper {
  321. .groupTitle {
  322. background-color: #fff;
  323. height: 40px;
  324. line-height: 40px;
  325. padding-left: 20px;
  326. }
  327. .addDepartForm {
  328. background-color: #fff;
  329. padding: 20px;
  330. margin: 20px 20px 0px 20px;
  331. }
  332. .symptomList {
  333. background-color: #fff;
  334. padding: 20px;
  335. margin: 20px 20px 0px 20px;
  336. height: 500px;
  337. }
  338. .bottomPartLeft {
  339. width: 32%;
  340. }
  341. .symptomPoolTitle {
  342. height: 40px;
  343. line-height: 40px;
  344. }
  345. .symptomPool {
  346. width: 100%;
  347. }
  348. .tagList {
  349. width: 100%;
  350. height: 300px;
  351. border: 1px solid @icssBorder;
  352. box-sizing: border-box;
  353. }
  354. .tagList {
  355. border: 1px solid @icssBorder;
  356. }
  357. .tagPool {
  358. height: 300px;
  359. overflow-y: auto;
  360. }
  361. .tagItem {
  362. position: relative;
  363. line-height: 30px;
  364. cursor: pointer;
  365. padding: 0 10px;
  366. }
  367. .tagName:before {
  368. content: '['
  369. }
  370. .tagName::after {
  371. content: ']'
  372. }
  373. .bottomPartMid {
  374. width: 8%;
  375. margin-top: 60px;
  376. p {
  377. width: 100%;
  378. text-align: center;
  379. span {
  380. cursor: pointer;
  381. display: inline-block;
  382. width: 30px;
  383. height: 40px;
  384. line-height: 40px;
  385. margin: 0 auto;
  386. border: 1px solid @icssBorder;
  387. margin-bottom: 15px;
  388. font-size: 18px;
  389. }
  390. }
  391. }
  392. .bottomPartRight {
  393. width: 32%;
  394. }
  395. .operationPool {
  396. position: relative;
  397. width: 100%;
  398. height: 340px;
  399. padding: 10px 0;
  400. overflow-y: auto;
  401. }
  402. .btn {
  403. position: relative;
  404. background-color: #fff;
  405. margin: 0px 20px;
  406. padding: 20px;
  407. .el-button {
  408. position: absolute;
  409. right: 20px;
  410. top: -20px;
  411. }
  412. }
  413. .selectDepart {
  414. }
  415. }
  416. </style>