ChronicDiseaseAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474
  1. <template>
  2. <div>
  3. <crumbs
  4. :title="minTitle"
  5. class="topBack"
  6. linkTo="/admin/LT-YXSJWH-LBJGWH"
  7. ></crumbs>
  8. <div class="ChronicDiseaseAddWrap" @click="close">
  9. <div class="ChronicDisease">
  10. <p class="ChronicDiseaseTop" v-if="!editData.isEdit">
  11. <span>选择量表标签:</span>
  12. <input
  13. type="text"
  14. v-model="region"
  15. @click.stop
  16. >
  17. <i @click.stop="searchTagList">搜索</i>
  18. <ul v-if="showLis">
  19. <li v-for="item in AdscriptionsType" :key="item.id" @click="selectLis(item.id,item.tagName)">{{item.tagName}}</li>
  20. </ul>
  21. </p>
  22. <p class="ChronicDiseaseBtm">
  23. <span>已选择量表:</span>
  24. <i>{{selectName}}</i>
  25. </p>
  26. </div>
  27. <div class="ChronicDiseaseDetail">
  28. <div class="ChronicDiseaseLeft">
  29. <h4>操作栏:</h4>
  30. <div class="parts" v-for="(item,idx) in parts" :class="selectLeftPart.id == item.id?'selectDom':null" :key="item.id" @click="selectPart(item,1)">
  31. {{item.name}}
  32. </div>
  33. </div>
  34. <div class="bottomPartMid fl">
  35. <p><span
  36. class="el-icon-arrow-right"
  37. @click="toRightPool"
  38. ></span></p>
  39. <p><span
  40. class="el-icon-arrow-left"
  41. @click="toLeftPool"
  42. ></span></p>
  43. </div>
  44. <div class="ChronicDiseaseRight">
  45. <h4>内容池:</h4>
  46. <div class="contentWrap">
  47. <div class="contentDetail clearfix" v-for="(item,idx) in contentPool" :class="selectRightPart.order == item.order?'selectDom':null" :key="item.order" @click="selectPart(item,2)">
  48. <span>{{item.name}}:</span>
  49. <div class="contentDetails">
  50. <quillEditor v-model="item.content" :options="editorOption" v-if="item.val == 0"></quillEditor>
  51. </div>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="bottomPartMid upAndDown">
  56. <p><span
  57. class="el-icon-arrow-up"
  58. @click="movePool(1)"
  59. ></span></p>
  60. <p><span
  61. class="el-icon-arrow-down"
  62. @click="movePool(2)"
  63. ></span></p>
  64. </div>
  65. <div class="btn">
  66. <el-button
  67. type="primary"
  68. @click="submitForm"
  69. >确 定</el-button>
  70. </div>
  71. </div>
  72. </div>
  73. </div>
  74. </template>
  75. <script>
  76. import api from '@api/icss.js';
  77. import utils from '@api/utils.js';
  78. import 'quill/dist/quill.core.css'
  79. import 'quill/dist/quill.snow.css'
  80. import 'quill/dist/quill.bubble.css'
  81. import {quillEditor, Quill} from 'vue-quill-editor'
  82. import config from '@api/config';
  83. import {container, ImageExtend, QuillWatch} from 'quill-image-extend-module';
  84. Quill.register('modules/ImageExtend', ImageExtend);
  85. /**
  86. * 归属type
  87. * 1:主诉模板 2:现病史模板 3:现病史空模板 4 : 其他史模板 5:嵌套模板 6:慢病模板
  88. */
  89. export default {
  90. data() {
  91. return {
  92. editorOption: {
  93. modules: {
  94. toolbar: {
  95. container: container
  96. }
  97. }
  98. },
  99. region: '', //量表标签
  100. selectName:'',
  101. selectId:'',
  102. AdscriptionsType: [],
  103. editData: {},
  104. minTitle:'量表维护-添加量表',
  105. showLis:false,
  106. parts:[],
  107. selectLeftPart:{},//左侧选中
  108. selectRightPart:{},//右侧选中
  109. contentPool:[], //内容池
  110. }
  111. },
  112. beforeMount:function(){
  113. let tmpPart = localStorage.getItem('DiseaseManage')
  114. this.parts = JSON.parse(tmpPart)
  115. },
  116. mounted() {
  117. let tmpEditData = this.$route.params
  118. if (tmpEditData.isEdit) { //修改
  119. this.editData = tmpEditData
  120. this.minTitle='量表维护-修改量表'
  121. this.selectName = tmpEditData.data.name
  122. this.selectId = tmpEditData.data.id
  123. let tmpScale = tmpEditData.data.scale
  124. for(let i = 0;i < tmpScale.length;i++){
  125. tmpScale[i].val = tmpScale[i].type
  126. tmpScale[i].order = tmpScale[i].orderNo
  127. tmpScale[i].name = tmpScale[i].type == 0?'文本模块':'推送模块'
  128. }
  129. this.contentPool = tmpScale
  130. }
  131. this.$emit('changeVal', this.form, false)
  132. },
  133. methods: {
  134. toRightPool() {
  135. let tmpLeft = JSON.parse(JSON.stringify(this.selectLeftPart))
  136. let tmpPool = JSON.parse(JSON.stringify(this.contentPool))
  137. if(JSON.stringify(tmpLeft) == '{}'){
  138. return
  139. }
  140. if(tmpLeft.val == 1){
  141. for(let i = 0;i < tmpPool.length;i++){
  142. if(tmpPool[i].val == 1){
  143. // this.$message({
  144. // message: '推送模块只能添加一次',
  145. // type: 'warning'
  146. // });
  147. return
  148. }
  149. }
  150. }
  151. tmpPool.push(tmpLeft)
  152. this.selectLeftPart = {}
  153. for(let i = 0;i < tmpPool.length;i++){
  154. tmpPool[i].order = i+1
  155. }
  156. this.contentPool = tmpPool
  157. },
  158. toLeftPool() {
  159. let tmpRight = JSON.parse(JSON.stringify(this.selectRightPart))
  160. let tmpPool = JSON.parse(JSON.stringify(this.contentPool))
  161. if(JSON.stringify(tmpRight) == '{}'){
  162. return
  163. }
  164. tmpPool = tmpPool.filter((item)=>item.order != tmpRight.order)
  165. for(let i = 0;i < tmpPool.length;i++){
  166. tmpPool[i].order = i+1
  167. }
  168. this.contentPool = tmpPool
  169. this.selectRightPart = {}
  170. },
  171. movePool(dir) {
  172. let tmpRight = JSON.parse(JSON.stringify(this.selectRightPart))
  173. let tmpPool = JSON.parse(JSON.stringify(this.contentPool))
  174. if((dir == 1 && tmpRight.order == 1) || (dir == 2 && tmpRight.order == tmpPool.length)){
  175. return
  176. }
  177. if(JSON.stringify(tmpRight) == '{}'){
  178. return
  179. }
  180. tmpPool = tmpPool.filter((item)=>item.order != tmpRight.order)
  181. if(dir == 1){
  182. tmpPool.splice(tmpRight.order-2,0,tmpRight)
  183. for(let i = 0;i < tmpPool.length;i++){
  184. tmpPool[i].order = i+1
  185. }
  186. }else if(dir == 2){
  187. tmpPool.splice(tmpRight.order,0,tmpRight)
  188. for(let i = 0;i < tmpPool.length;i++){
  189. tmpPool[i].order = i+1
  190. }
  191. }
  192. this.selectRightPart = tmpRight
  193. this.contentPool = tmpPool
  194. },
  195. selectPart(part,dir){
  196. if(dir == 1){
  197. if(this.selectLeftPart.val == part.val){
  198. this.selectLeftPart = {}
  199. }else{
  200. this.selectLeftPart = part
  201. }
  202. }else if(dir == 2){
  203. if(this.selectRightPart.order == part.order){
  204. this.selectRightPart = {}
  205. }else{
  206. this.selectRightPart = part
  207. }
  208. }
  209. },
  210. close(){
  211. this.showLis = false
  212. },
  213. selectLis(id,name){
  214. this.selectName = name
  215. this.selectId = id
  216. },
  217. searchTagList() {
  218. let param = {
  219. "tagName": this.region,
  220. "type": "21",
  221. "filterList":[
  222. "scale"
  223. ]
  224. }
  225. api.searchTagList(param).then((res) => {
  226. if (res.data.code === '0') {
  227. this.AdscriptionsType = res.data.data
  228. this.showLis = this.AdscriptionsType.length > 0
  229. }
  230. })
  231. },
  232. getParams(){
  233. let tmpParams = []
  234. let tmpPool = JSON.parse(JSON.stringify(this.contentPool))
  235. for(let i = 0;i < tmpPool.length;i++){
  236. if(tmpPool[i].val == 0 && !tmpPool[i].content){
  237. }else{
  238. let tmpObj = {
  239. "content": "",
  240. "orderNo": '',
  241. "type": ''
  242. }
  243. tmpObj.content = tmpPool[i].content || ''
  244. tmpObj.orderNo = tmpPool[i].order
  245. tmpObj.type = tmpPool[i].val
  246. tmpParams.push(tmpObj)
  247. }
  248. }
  249. return {
  250. "content": tmpParams,
  251. "scaleId": this.selectId
  252. }
  253. },
  254. submitForm() {
  255. if(this.selectName == ''){
  256. this.$message({
  257. message: '请选择量表标签',
  258. type: 'warning'
  259. });
  260. return
  261. }
  262. let param = this.getParams();
  263. if(param.content.length == 0){
  264. this.$message({
  265. message: '请添加内容池内容',
  266. type: 'warning'
  267. });
  268. return
  269. }
  270. this.showConfirmDialog('是否保存该标签组?', () => {
  271. api.insertOrUpdate(param).then((res) => {
  272. if (res.data.code === '0') {
  273. this.warning(res.data.msg || '保存成功', 'success');
  274. setTimeout(() => {
  275. this.$router.push({
  276. path:'/admin/LT-YXSJWH-LBJGWH'
  277. })
  278. }, 1000);
  279. }
  280. })
  281. })
  282. },
  283. showConfirmDialog(msg, resolve) {
  284. this.$alert(msg, '提示', {
  285. confirmButtonText: '确定',
  286. type: 'warning'
  287. }).then(() => {
  288. resolve();
  289. }).catch(() => {});
  290. },
  291. warning(msg, type,time) {
  292. this.$message({
  293. showClose: true,
  294. message: msg,
  295. type: type || 'warning',
  296. duration:time || '3000'
  297. })
  298. },
  299. },
  300. components:{
  301. quillEditor
  302. }
  303. }
  304. </script>
  305. <style lang="less">
  306. .contentDetails{
  307. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-image,
  308. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-video,
  309. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-link{
  310. display: none;
  311. }
  312. }
  313. </style>
  314. <style lang="less" scoped>
  315. @import "../../less/common.less";
  316. .topBack {
  317. top: 0;
  318. }
  319. .btn {
  320. text-align: right;
  321. margin-top: 20px;
  322. }
  323. .ChronicDiseaseAddWrap {
  324. margin: 20px;
  325. box-sizing: border-box;
  326. background-color: #fff;
  327. color: #606266;
  328. .ChronicDisease {
  329. border-bottom: 1px solid #c0c4cc;
  330. padding: 20px;
  331. margin-top: 60px;
  332. span {
  333. width: 160px;
  334. display: inline-block;
  335. }
  336. .ChronicDiseaseTop {
  337. input {
  338. width: 221px;
  339. height: 34px;
  340. line-height: 34px;
  341. padding-left: 7px;
  342. padding-right: 56px;
  343. box-sizing: border-box;
  344. }
  345. i {
  346. display: inline-block;
  347. width: 56px;
  348. height: 34px;
  349. line-height: 32px;
  350. border-left: 1px solid @icssBorder;
  351. position: relative;
  352. left: -57px;
  353. vertical-align: middle;
  354. text-align: center;
  355. cursor: pointer;
  356. }
  357. ul {
  358. width: 219px;
  359. margin-left: 160px;
  360. border: 1px solid @icssBorder;
  361. background: #fff;
  362. max-height: 200px;
  363. overflow-y: auto;
  364. height: auto;
  365. position: absolute;
  366. z-index: 9999;
  367. li {
  368. border: 1px solid #fff;
  369. padding-left: 7px;
  370. height: 27px;
  371. line-height: 27px;
  372. overflow: hidden;
  373. white-space: nowrap;
  374. text-overflow: ellipsis;
  375. }
  376. li:hover {
  377. background: #f5f7fa;
  378. }
  379. }
  380. }
  381. .ChronicDiseaseBtm {
  382. margin: 25px 0 10px 0;
  383. }
  384. }
  385. .ChronicDiseaseDetail {
  386. padding: 20px;
  387. overflow: hidden;
  388. position: relative;
  389. h4 {
  390. margin-bottom: 10px;
  391. }
  392. .bottomPartMid {
  393. width: 80px;
  394. margin-top: 60px;
  395. p {
  396. width: 100%;
  397. text-align: center;
  398. span {
  399. cursor: pointer;
  400. display: inline-block;
  401. width: 30px;
  402. height: 40px;
  403. line-height: 40px;
  404. margin: 0 auto;
  405. border: 1px solid @icssBorder;
  406. margin-bottom: 15px;
  407. font-size: 18px;
  408. }
  409. }
  410. }
  411. .upAndDown {
  412. position: absolute;
  413. right: 0;
  414. top: 0;
  415. }
  416. .ChronicDiseaseLeft {
  417. float: left;
  418. .parts {
  419. height: 40px;
  420. line-height: 40px;
  421. width: 160px;
  422. text-align: center;
  423. font-size: 14px;
  424. margin: 20px 0;
  425. background-color: #EFEFEF;
  426. border: 1px solid @icssBorder;
  427. color: #333;
  428. cursor: pointer;
  429. }
  430. }
  431. }
  432. .ChronicDiseaseRight {
  433. padding-right: 50px;
  434. .contentWrap {
  435. color: #333;
  436. min-width: 400px;
  437. min-height: 500px;
  438. max-height: 600px;
  439. border: 1px solid @icssBorder;
  440. background: #fff;
  441. overflow-y: auto;
  442. .contentDetail {
  443. border: 1px solid #fff;
  444. padding: 5px;
  445. padding-left: 80px;
  446. box-sizing: border-box;
  447. margin: 5px;
  448. position: relative;
  449. span {
  450. width: 80px;
  451. display: inline-block;
  452. position: absolute;
  453. top: 12px;
  454. left: 0px;
  455. text-align: right;
  456. }
  457. .contentDetails {
  458. float: left;
  459. min-height: 40px;
  460. width: 100%;
  461. box-sizing: border-box;
  462. background-color: #EFEFEF;
  463. }
  464. }
  465. }
  466. }
  467. .selectDom {
  468. border: 1px solid @adminBase !important;
  469. }
  470. }
  471. </style>