ChronicDiseaseAdd.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471
  1. <template>
  2. <div>
  3. <crumbs
  4. :title="minTitle"
  5. class="topBack"
  6. linkTo="/admin/LT-YXSYKWH-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.conceptId" @click="selectLis(item.conceptId,item.name)">{{item.name}}</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" class="ql-editor"></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.row.name
  122. this.selectId = tmpEditData.row.conceptId
  123. let tmpScale = tmpEditData.data
  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 == 1?'文本模块':'推送模块'
  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 == 2){
  141. for(let i = 0;i < tmpPool.length;i++){
  142. if(tmpPool[i].val == 2){
  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. if(this.region.trim() == ''){
  219. return
  220. }
  221. api.searchKnowledgeLis({name: this.region}).then((res) => {
  222. if (res.data.code === '0') {
  223. console.log(res)
  224. this.AdscriptionsType = res.data.data
  225. this.showLis = this.AdscriptionsType.length > 0
  226. }
  227. })
  228. },
  229. getParams(){
  230. let tmpParams = []
  231. let tmpPool = JSON.parse(JSON.stringify(this.contentPool))
  232. for(let i = 0;i < tmpPool.length;i++){
  233. if(tmpPool[i].val == 0 && !tmpPool[i].content){
  234. }else{
  235. let tmpObj = {
  236. "content": "",
  237. "orderNo": '',
  238. "type": ''
  239. }
  240. tmpObj.content = tmpPool[i].content || ''
  241. tmpObj.orderNo = tmpPool[i].order
  242. tmpObj.type = tmpPool[i].val
  243. tmpParams.push(tmpObj)
  244. }
  245. }
  246. return {
  247. "content": tmpParams,
  248. "conceptId": this.selectId
  249. }
  250. },
  251. submitForm() {
  252. if(this.selectName == ''){
  253. this.$message({
  254. message: '请选择量表标签',
  255. type: 'warning'
  256. });
  257. return
  258. }
  259. let param = this.getParams();
  260. if(param.content.length == 0){
  261. this.$message({
  262. message: '请添加内容池内容',
  263. type: 'warning'
  264. });
  265. return
  266. }
  267. this.showConfirmDialog('是否保存该量表结构?', () => {
  268. api.insertOrUpdate(param).then((res) => {
  269. if (res.data.code === '0') {
  270. this.warning(res.data.msg || '保存成功', 'success');
  271. setTimeout(() => {
  272. this.$router.push({
  273. path:'/admin/LT-YXSYKWH-LBJGWH'
  274. })
  275. }, 1000);
  276. }
  277. })
  278. })
  279. },
  280. showConfirmDialog(msg, resolve) {
  281. this.$alert(msg, '提示', {
  282. confirmButtonText: '确定',
  283. type: 'warning'
  284. }).then(() => {
  285. resolve();
  286. }).catch(() => {});
  287. },
  288. warning(msg, type,time) {
  289. this.$message({
  290. showClose: true,
  291. message: msg,
  292. type: type || 'warning',
  293. duration:time || '3000'
  294. })
  295. },
  296. },
  297. components:{
  298. quillEditor
  299. }
  300. }
  301. </script>
  302. <style lang="less">
  303. .contentDetails{
  304. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-image,
  305. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-video,
  306. .quill-editor .ql-toolbar.ql-snow .ql-formats .ql-link{
  307. display: none;
  308. }
  309. }
  310. </style>
  311. <style lang="less" scoped>
  312. @import "../../less/common.less";
  313. .topBack {
  314. top: 0;
  315. }
  316. .btn {
  317. text-align: right;
  318. margin-top: 20px;
  319. }
  320. .ChronicDiseaseAddWrap {
  321. margin: 20px;
  322. box-sizing: border-box;
  323. background-color: #fff;
  324. color: #606266;
  325. .ChronicDisease {
  326. border-bottom: 1px solid #c0c4cc;
  327. padding: 20px;
  328. margin-top: 60px;
  329. span {
  330. width: 160px;
  331. display: inline-block;
  332. }
  333. .ChronicDiseaseTop {
  334. input {
  335. width: 221px;
  336. height: 34px;
  337. line-height: 34px;
  338. padding-left: 7px;
  339. padding-right: 56px;
  340. box-sizing: border-box;
  341. }
  342. i {
  343. display: inline-block;
  344. width: 56px;
  345. height: 34px;
  346. line-height: 32px;
  347. border-left: 1px solid @icssBorder;
  348. position: relative;
  349. left: -57px;
  350. vertical-align: middle;
  351. text-align: center;
  352. cursor: pointer;
  353. }
  354. ul {
  355. width: 219px;
  356. margin-left: 160px;
  357. border: 1px solid @icssBorder;
  358. background: #fff;
  359. max-height: 200px;
  360. overflow-y: auto;
  361. height: auto;
  362. position: absolute;
  363. z-index: 9999;
  364. li {
  365. border: 1px solid #fff;
  366. padding-left: 7px;
  367. height: 27px;
  368. line-height: 27px;
  369. overflow: hidden;
  370. white-space: nowrap;
  371. text-overflow: ellipsis;
  372. }
  373. li:hover {
  374. background: #f5f7fa;
  375. }
  376. }
  377. }
  378. .ChronicDiseaseBtm {
  379. margin: 25px 0 10px 0;
  380. }
  381. }
  382. .ChronicDiseaseDetail {
  383. padding: 20px;
  384. overflow: hidden;
  385. position: relative;
  386. h4 {
  387. margin-bottom: 10px;
  388. }
  389. .bottomPartMid {
  390. width: 80px;
  391. margin-top: 60px;
  392. p {
  393. width: 100%;
  394. text-align: center;
  395. span {
  396. cursor: pointer;
  397. display: inline-block;
  398. width: 30px;
  399. height: 40px;
  400. line-height: 40px;
  401. margin: 0 auto;
  402. border: 1px solid @icssBorder;
  403. margin-bottom: 15px;
  404. font-size: 18px;
  405. }
  406. }
  407. }
  408. .upAndDown {
  409. position: absolute;
  410. right: 0;
  411. top: 0;
  412. }
  413. .ChronicDiseaseLeft {
  414. float: left;
  415. .parts {
  416. height: 40px;
  417. line-height: 40px;
  418. width: 160px;
  419. text-align: center;
  420. font-size: 14px;
  421. margin: 20px 0;
  422. background-color: #EFEFEF;
  423. border: 1px solid @icssBorder;
  424. color: #333;
  425. cursor: pointer;
  426. }
  427. }
  428. }
  429. .ChronicDiseaseRight {
  430. padding-right: 50px;
  431. .contentWrap {
  432. color: #333;
  433. min-width: 400px;
  434. min-height: 500px;
  435. max-height: 600px;
  436. border: 1px solid @icssBorder;
  437. background: #fff;
  438. overflow-y: auto;
  439. .contentDetail {
  440. border: 1px solid #fff;
  441. padding: 5px;
  442. padding-left: 80px;
  443. box-sizing: border-box;
  444. margin: 5px;
  445. position: relative;
  446. span {
  447. width: 80px;
  448. display: inline-block;
  449. position: absolute;
  450. top: 12px;
  451. left: 0px;
  452. text-align: right;
  453. }
  454. .contentDetails {
  455. float: left;
  456. min-height: 40px;
  457. width: 100%;
  458. box-sizing: border-box;
  459. background-color: #EFEFEF;
  460. }
  461. }
  462. }
  463. }
  464. .selectDom {
  465. border: 1px solid @adminBase !important;
  466. }
  467. }
  468. </style>