AddCommonSymptom.vue 12 KB

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