AddCommonSymptom.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  1. <!-- 添加常见科室症状 -->
  2. <template>
  3. <div class="addCommonSymptomWrapper">
  4. <div class="groupTitle"><i
  5. class="el-icon-back"
  6. @click="back"
  7. ></i> 常见症状维护系统--添加科室常见症状</div>
  8. <el-form :model="form" ref="ruleForm" :rules="rules" class="addDepartForm">
  9. <el-form-item label="选择科室" prop="department">
  10. <el-select 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 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">
  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">
  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='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">
  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. departList: [],
  91. typeList:[],
  92. searchVal: '',
  93. leftTagsList:[],
  94. rightTagsList:[],
  95. selectLeftTagsList: [],
  96. selectRightTagIndex: -1,
  97. styles:{
  98. background:'#eae7e7'
  99. },
  100. }
  101. },
  102. created(){
  103. const { isEdit, isDetail, data } = this.$route.params;
  104. if(isEdit || isDetail) {
  105. this.isEdit = isEdit
  106. } else {
  107. this.getDepartmentList()
  108. }
  109. },
  110. watch: {
  111. searchVal(newVal, preVal) {
  112. if(newVal.trim() == ''){
  113. this.getSymptomList()
  114. }else if(newVal.trim() != preVal.trim()){
  115. this.getSymptomList()
  116. }
  117. }
  118. },
  119. methods: {
  120. back(){
  121. this.$router.go(-1);
  122. },
  123. getDepartmentList() {
  124. api.getDepartmentList().then((res)=>{
  125. if(res.data.code === '0') {
  126. this.departList = res.data.data
  127. }
  128. })
  129. },
  130. getSymptomList() {
  131. let noIds = []
  132. for (let i =0; i < this.rightTagsList.length; i++) {
  133. noIds.push(this.rightTagsList[i].id)
  134. }
  135. const param = {
  136. "deptId": this.form.department,
  137. "tagName": this.searchVal,
  138. "noIds": noIds,
  139. "type": this.form.type
  140. }
  141. api.getSymptomList(param).then((res)=>{
  142. if(res.data.code === '0') {
  143. this.leftTagsList = res.data.data
  144. }
  145. })
  146. },
  147. changeDept() {
  148. console.log('asdasfdgag',this.departList)
  149. this.form.type = ''
  150. this.typeList = this.departList.filter(item => this.form.department == item.id)[0].typeDTOList
  151. this.clearData()
  152. },
  153. changeType() {
  154. this.clearData()
  155. this.getSymptomList()
  156. },
  157. clearData() {
  158. this.leftTagsList = [];
  159. this.rightTagsList = [];
  160. this.selectLeftTagsList = [];
  161. this.selectRightTagIndex = -1;
  162. },
  163. selectLeftTag(tag, index, e) {
  164. const hasTag = this.isHasTag(tag, this.selectLeftTagsList)
  165. if (hasTag) {
  166. this.selectLeftTagsList = this.selectLeftTagsList.filter(item => item.id !== tag.id)
  167. } else {
  168. this.selectLeftTagsList.push(tag);
  169. }
  170. },
  171. selectRightTag(index) {
  172. this.selectRightTagIndex = this.selectRightTagIndex === index ? -1 : index
  173. },
  174. toRightList(){
  175. this.rightTagsList.push(...this.selectLeftTagsList);
  176. this.selectLeftTagsList = [];
  177. this.selectRightTagsList = [];
  178. this.getSymptomList()
  179. },
  180. toLeftList(){
  181. for(let i = 0; i < this.selectRightTagsList.length; i++) {
  182. this.rightTagsList = this.rightTagsList.filter(item => item.id !== this.selectRightTagsList[i].id)
  183. }
  184. this.selectLeftTagsList = [];
  185. this.selectRightTagsList = [];
  186. this.getSymptomList()
  187. },
  188. toUp(){
  189. if(this.selectRightTagIndex === 0 || this.selectRightTagIndex === -1) {
  190. return
  191. }
  192. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  193. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  194. this.rightTagsList.splice(this.selectRightTagIndex-1, 0,tempItem)
  195. this.selectRightTagIndex = -1
  196. },
  197. toDown(){
  198. if(this.selectRightTagIndex === this.rightTagsList.length-1 || this.selectRightTagIndex === -1) {
  199. return
  200. }
  201. const tempItem = this.rightTagsList[this.selectRightTagIndex]
  202. this.rightTagsList.splice(this.selectRightTagIndex, 1)
  203. this.rightTagsList.splice(this.selectRightTagIndex+1, 0,tempItem)
  204. this.selectRightTagIndex = -1
  205. },
  206. isHasTag(item, arr) {
  207. for ( let i = 0; i <arr.length; i++) {
  208. if(arr[i].id === item.id) {
  209. return true;
  210. }
  211. }
  212. return false;
  213. },
  214. getStyle(item){ //左侧选中状态
  215. return this.isHasTag(item, this.selectLeftTagsList)
  216. },
  217. getStyle2(item) {
  218. return this.isHasTag(item, this.selectRightTagsList)
  219. },
  220. submitForm(formName) {
  221. this.$refs[formName].validate((valid) => {
  222. if (valid) {
  223. return
  224. } else {
  225. console.log('error submit!!');
  226. return false;
  227. }
  228. });
  229. if(!this.form.department) {
  230. return
  231. }
  232. this.showDelDialog()
  233. },
  234. showDelDialog() {
  235. let questionId = []
  236. for (let i =0; i < this.rightTagsList.length; i++) {
  237. questionId.push(this.rightTagsList[i].id)
  238. }
  239. const param ={
  240. "deptId": this.form.department,
  241. "questionId": questionId
  242. }
  243. this.showConfirmDialog('是否保存该标签组?', () => {
  244. api.addCommonSymptom(param).then((res) => {
  245. if (res.data.code === '0') {
  246. this.warning(res.data.msg || '保存成功', 'success','1000')
  247. setTimeout(() => {
  248. this.$router.push({
  249. path:'/admin/LT-YXSJWH-CJZZWH'
  250. })
  251. }, 1000);
  252. } else {
  253. this.warning(res.data.msg)
  254. }
  255. }).catch((err) => {
  256. this.warning(err);
  257. })
  258. });
  259. },
  260. showConfirmDialog(msg, resolve) {
  261. this.$alert(msg, '提示', {
  262. confirmButtonText: '确定',
  263. type: 'warning'
  264. }).then(() => {
  265. resolve();
  266. }).catch(() => {});
  267. },
  268. warning(msg, type,time) {
  269. this.$message({
  270. showClose: true,
  271. message: msg,
  272. type: type || 'warning',
  273. duration:time || '3000'
  274. })
  275. },
  276. }
  277. }
  278. </script>
  279. <style lang="less">
  280. @import '../../less/common.less';
  281. .addCommonSymptomWrapper {
  282. .groupTitle {
  283. background-color: #fff;
  284. height: 40px;
  285. line-height: 40px;
  286. padding-left: 20px;
  287. }
  288. .addDepartForm {
  289. background-color: #fff;
  290. padding: 20px;
  291. margin: 20px 20px 0px 20px;
  292. }
  293. .symptomList {
  294. background-color: #fff;
  295. padding: 20px;
  296. margin: 20px 20px 0px 20px;
  297. height: 500px;
  298. }
  299. .bottomPartLeft {
  300. width: 32%;
  301. }
  302. .symptomPoolTitle {
  303. height: 40px;
  304. line-height: 40px;
  305. }
  306. .symptomPool {
  307. width: 100%;
  308. }
  309. .tagList {
  310. width: 100%;
  311. height: 300px;
  312. border: 1px solid @icssBorder;
  313. box-sizing: border-box;
  314. }
  315. .tagList {
  316. border: 1px solid @icssBorder;
  317. }
  318. .tagPool {
  319. height: 300px;
  320. overflow-y: auto;
  321. }
  322. .tagItem {
  323. position: relative;
  324. line-height: 30px;
  325. cursor: pointer;
  326. padding: 0 10px;
  327. }
  328. .tagName:before {
  329. content: '['
  330. }
  331. .tagName::after {
  332. content: ']'
  333. }
  334. .bottomPartMid {
  335. width: 8%;
  336. margin-top: 60px;
  337. p {
  338. width: 100%;
  339. text-align: center;
  340. span {
  341. cursor: pointer;
  342. display: inline-block;
  343. width: 30px;
  344. height: 40px;
  345. line-height: 40px;
  346. margin: 0 auto;
  347. border: 1px solid @icssBorder;
  348. margin-bottom: 15px;
  349. font-size: 18px;
  350. }
  351. }
  352. }
  353. .bottomPartRight {
  354. width: 32%;
  355. }
  356. .operationPool {
  357. position: relative;
  358. width: 100%;
  359. height: 340px;
  360. padding: 10px 0;
  361. }
  362. .btn {
  363. position: relative;
  364. background-color: #fff;
  365. margin: 0px 20px;
  366. padding: 20px;
  367. .el-button {
  368. position: absolute;
  369. right: 20px;
  370. top: -20px;
  371. }
  372. }
  373. .selectDepart {
  374. }
  375. }
  376. </style>