ChronicDiseaseAdd.vue 13 KB

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