|  | @ -1,6 +1,15 @@ | 
		
	
		
			
				|  |  | <template> |  |  | <template> | 
		
	
		
			
				|  |  |   <div class="flex formManage"> |  |  |   <div class="flex formManage"> | 
		
	
		
			
				|  |  |     <div class="leftContent">新增表单</div> |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     <div class="leftContent">新增表单 | 
		
	
		
			
				|  |  |  |  |  |       <img | 
		
	
		
			
				|  |  |  |  |  |         v-for="(item,index) in imgList" | 
		
	
		
			
				|  |  |  |  |  |         :key="index" | 
		
	
		
			
				|  |  |  |  |  |         :ref="`imgs${index}`" | 
		
	
		
			
				|  |  |  |  |  |         width="80%" | 
		
	
		
			
				|  |  |  |  |  |         :src="item.src" | 
		
	
		
			
				|  |  |  |  |  |         @click="insertImg(`imgs${index}`)" | 
		
	
		
			
				|  |  |  |  |  |       > | 
		
	
		
			
				|  |  |  |  |  |     </div> | 
		
	
		
			
				|  |  |     <div class="flex1" style="background: #FFFFFF;padding:0 10px"> |  |  |     <div class="flex1" style="background: #FFFFFF;padding:0 10px"> | 
		
	
		
			
				|  |  |       <div style="padding: 10px 0"> |  |  |       <div style="padding: 10px 0"> | 
		
	
		
			
				|  |  |         <el-button type="primary" size="mini" @click="saveForm">保存</el-button> |  |  |         <el-button type="primary" size="mini" @click="saveForm">保存</el-button> | 
		
	
	
		
			
				|  | @ -23,17 +32,30 @@ | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | import Editor from '@/components/formEditor/Editor.vue' |  |  | import Editor from '@/components/formEditor/Editor.vue' | 
		
	
		
			
				|  |  | import ImgEditor from '@/components/360View/img-editor.vue' |  |  | import ImgEditor from '@/components/360View/img-editor.vue' | 
		
	
		
			
				|  |  |  |  |  | import styeFormSign from '@/mixins/styeFormSign' | 
		
	
		
			
				|  |  |  |  |  | import eventBus from '@/page-subspecialty/utils/eventBus' | 
		
	
		
			
				|  |  | 
 |  |  | 
 | 
		
	
		
			
				|  |  | export default { |  |  | export default { | 
		
	
		
			
				|  |  |   name: 'Index', |  |  |   name: 'Index', | 
		
	
		
			
				|  |  |   components: { ImgEditor, Editor }, |  |  |   components: { ImgEditor, Editor }, | 
		
	
		
			
				|  |  |  |  |  |   mixins: [styeFormSign], | 
		
	
		
			
				|  |  |   data() { |  |  |   data() { | 
		
	
		
			
				|  |  |     return { |  |  |     return { | 
		
	
		
			
				|  |  |  |  |  |       imgList: [{ | 
		
	
		
			
				|  |  |  |  |  |         src: require('@/assets/img/xianganLogo3.png') | 
		
	
		
			
				|  |  |  |  |  |       }, { | 
		
	
		
			
				|  |  |  |  |  |         src: require('@/assets/img/od.png') | 
		
	
		
			
				|  |  |  |  |  |       }], | 
		
	
		
			
				|  |  |       editor: null, |  |  |       editor: null, | 
		
	
		
			
				|  |  |       formList: [], |  |  |       formList: [], | 
		
	
		
			
				|  |  |       editorShow: false, |  |  |       editorShow: false, | 
		
	
		
			
				|  |  |       curImgSrc: '', |  |  |  | 
		
	
		
			
				|  |  |       curKey: '' |  |  |  | 
		
	
		
			
				|  |  |  |  |  |       curImgSrc: '', // 当前图片的路径 | 
		
	
		
			
				|  |  |  |  |  |       curKey: '', // 当前图片的ID | 
		
	
		
			
				|  |  |  |  |  |       curInsertId: '', // 插入盒子的id | 
		
	
		
			
				|  |  |  |  |  |       mode: '', // 当前编辑器的模式 | 
		
	
		
			
				|  |  |  |  |  |       formListValue: {}, // 签名需要的对象 | 
		
	
		
			
				|  |  |  |  |  |       formData: {}, // 表单数据 | 
		
	
		
			
				|  |  |  |  |  |       dataKeys: [] // 表单数据全部键名 | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |   }, |  |  |   }, | 
		
	
		
			
				|  |  |   methods: { |  |  |   methods: { | 
		
	
	
		
			
				|  | @ -42,39 +64,84 @@ export default { | 
		
	
		
			
				|  |  |       this.editor.execCommand('new') |  |  |       this.editor.execCommand('new') | 
		
	
		
			
				|  |  |       this.setForm() |  |  |       this.setForm() | 
		
	
		
			
				|  |  |       if (this.editor) { |  |  |       if (this.editor) { | 
		
	
		
			
				|  |  |  |  |  |         this.formData = { | 
		
	
		
			
				|  |  |  |  |  |           ...this.editor.getBindObject().BODY, | 
		
	
		
			
				|  |  |  |  |  |           ...this.editor.getBindObject().HEADER | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |         this.dataKeys = Object.keys(this.formData) | 
		
	
		
			
				|  |  |  |  |  | 
 | 
		
	
		
			
				|  |  |         this.imageChange() |  |  |         this.imageChange() | 
		
	
		
			
				|  |  |         // this.editor.$('#patientId').change(() => { |  |  |  | 
		
	
		
			
				|  |  |         //   console.log('asdfas') |  |  |  | 
		
	
		
			
				|  |  |         // }) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |         this.initSignHtml() | 
		
	
		
			
				|  |  |  |  |  |         this.getSignResult() | 
		
	
		
			
				|  |  |  |  |  |         this.insertImgBoxClick() | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     // 签名成功后 | 
		
	
		
			
				|  |  |  |  |  |     getSignResult() { | 
		
	
		
			
				|  |  |  |  |  |       eventBus.$off('saveSignRes') | 
		
	
		
			
				|  |  |  |  |  |       eventBus.$on('saveSignRes', data => { | 
		
	
		
			
				|  |  |  |  |  |         this.editor.$('#' + data.idName)[0].src = data.src | 
		
	
		
			
				|  |  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     // 签字板签名 | 
		
	
		
			
				|  |  |  |  |  |     initSignHtml() { | 
		
	
		
			
				|  |  |  |  |  |       const signList = this.dataKeys.filter(item => item.split('_')[0] === 'SIGN') | 
		
	
		
			
				|  |  |  |  |  |       signList.forEach(item => { | 
		
	
		
			
				|  |  |  |  |  |         // 点击打开编辑器 | 
		
	
		
			
				|  |  |  |  |  |         this.editor.$('#' + item).click(() => { | 
		
	
		
			
				|  |  |  |  |  |           if (this.mode !== 'form') return | 
		
	
		
			
				|  |  |  |  |  |           this.initPlugin(item) | 
		
	
		
			
				|  |  |  |  |  |         }) | 
		
	
		
			
				|  |  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |  |     }, | 
		
	
		
			
				|  |  |     closeDialog() { |  |  |     closeDialog() { | 
		
	
		
			
				|  |  |       this.editorShow = false |  |  |       this.editorShow = false | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |     fullImgBack(value) { |  |  |     fullImgBack(value) { | 
		
	
		
			
				|  |  |       if (this.curKey) { |  |  |       if (this.curKey) { | 
		
	
		
			
				|  |  |         this.editor.$(`#${this.curKey}`)[0].src = value |  |  |         this.editor.$(`#${this.curKey}`)[0].src = value | 
		
	
		
			
				|  |  |  |  |  |         this.editor.$(`#${this.curKey}`)[0].width = this.curKey.split('_')[1] | 
		
	
		
			
				|  |  |       } |  |  |       } | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     // 图片编辑 | 
		
	
		
			
				|  |  |     imageChange() { |  |  |     imageChange() { | 
		
	
		
			
				|  |  |       const data = this.editor.getBindObject().BODY |  |  |  | 
		
	
		
			
				|  |  |       const keys = Object.keys(data) |  |  |  | 
		
	
		
			
				|  |  |       // 筛选出图片编辑的字段 |  |  |       // 筛选出图片编辑的字段 | 
		
	
		
			
				|  |  |       const imgEditorList = keys.filter(item => item.includes('imgEditor')) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |       const imgEditorList = this.dataKeys.filter(item => item.split('_')[0] === 'EIMG') | 
		
	
		
			
				|  |  |       // 遍历图片编辑 |  |  |       // 遍历图片编辑 | 
		
	
		
			
				|  |  |       imgEditorList.forEach(item => { |  |  |       imgEditorList.forEach(item => { | 
		
	
		
			
				|  |  |         // 点击打开编辑器 |  |  |         // 点击打开编辑器 | 
		
	
		
			
				|  |  |         this.editor.$('#' + item).click(() => { |  |  |         this.editor.$('#' + item).click(() => { | 
		
	
		
			
				|  |  |  |  |  |           if (this.mode !== 'form') return | 
		
	
		
			
				|  |  |           this.curKey = item |  |  |           this.curKey = item | 
		
	
		
			
				|  |  |           this.curImgSrc = data[item] // 编辑器默认背景图带入 |  |  |  | 
		
	
		
			
				|  |  |  |  |  |           this.curImgSrc = this.formData[item] // 编辑器默认背景图带入 | 
		
	
		
			
				|  |  |           this.editorShow = true |  |  |           this.editorShow = true | 
		
	
		
			
				|  |  |           this.$nextTick(() => { |  |  |           this.$nextTick(() => { | 
		
	
		
			
				|  |  |             this.$refs.imgEditorRef.init() |  |  |             this.$refs.imgEditorRef.init() | 
		
	
		
			
				|  |  |           }) |  |  |           }) | 
		
	
		
			
				|  |  |           // this.editor.$('#img_editor')[0].src = require('@/assets/img/od.png') |  |  |  | 
		
	
		
			
				|  |  |         }) |  |  |         }) | 
		
	
		
			
				|  |  |       }) |  |  |       }) | 
		
	
		
			
				|  |  |       // console.log(keys) |  |  |  | 
		
	
		
			
				|  |  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     // 空白区域图片插入 | 
		
	
		
			
				|  |  |  |  |  |     insertImgBoxClick() { | 
		
	
		
			
				|  |  |  |  |  |       const insertList = [] | 
		
	
		
			
				|  |  |  |  |  |       for (let i = 1; i < 6; i++) { | 
		
	
		
			
				|  |  |  |  |  |         if (this.editor.$('#INSERT' + i)[0]) { | 
		
	
		
			
				|  |  |  |  |  |           insertList.push('INSERT' + i) | 
		
	
		
			
				|  |  |  |  |  |         } else { | 
		
	
		
			
				|  |  |  |  |  |           continue | 
		
	
		
			
				|  |  |  |  |  |         } | 
		
	
		
			
				|  |  |  |  |  |       } | 
		
	
		
			
				|  |  |  |  |  |       insertList.forEach(item => { | 
		
	
		
			
				|  |  |  |  |  |         this.editor.$('#' + item).click(() => { | 
		
	
		
			
				|  |  |  |  |  |           if (this.mode !== 'form') return | 
		
	
		
			
				|  |  |  |  |  |           this.curInsertId = item | 
		
	
		
			
				|  |  |  |  |  |         }) | 
		
	
		
			
				|  |  |  |  |  |       }) | 
		
	
		
			
				|  |  |  |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     insertImg(refName) { | 
		
	
		
			
				|  |  |  |  |  |       if (!this.curInsertId) return | 
		
	
		
			
				|  |  |  |  |  |       const img = this.$refs[refName][0].cloneNode() | 
		
	
		
			
				|  |  |  |  |  |       this.editor.$('#' + this.curInsertId).append(img) | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |     saveForm() { |  |  |     saveForm() { | 
		
	
		
			
				|  |  |       const html = this.editor.getHtml() |  |  |       const html = this.editor.getHtml() | 
		
	
	
		
			
				|  | @ -84,8 +151,11 @@ export default { | 
		
	
		
			
				|  |  |       const html = decodeURIComponent(window.sessionStorage.getItem('form')) |  |  |       const html = decodeURIComponent(window.sessionStorage.getItem('form')) | 
		
	
		
			
				|  |  |       this.editor.loadHtml(html) |  |  |       this.editor.loadHtml(html) | 
		
	
		
			
				|  |  |       this.editor.execCommand('form') |  |  |       this.editor.execCommand('form') | 
		
	
		
			
				|  |  |  |  |  |       this.mode = 'form' | 
		
	
		
			
				|  |  |     }, |  |  |     }, | 
		
	
		
			
				|  |  |  |  |  |     // 表单编辑模式的修改 | 
		
	
		
			
				|  |  |     setFormMode(mode) { |  |  |     setFormMode(mode) { | 
		
	
		
			
				|  |  |  |  |  |       this.mode = mode | 
		
	
		
			
				|  |  |       this.editor.execCommand(mode) |  |  |       this.editor.execCommand(mode) | 
		
	
		
			
				|  |  |     } |  |  |     } | 
		
	
		
			
				|  |  |   } |  |  |   } | 
		
	
	
		
			
				|  | @ -100,5 +170,6 @@ export default { | 
		
	
		
			
				|  |  |   width: 240px; |  |  |   width: 240px; | 
		
	
		
			
				|  |  |   background: #fff; |  |  |   background: #fff; | 
		
	
		
			
				|  |  |   margin-right: 10px; |  |  |   margin-right: 10px; | 
		
	
		
			
				|  |  |  |  |  |   text-align: center; | 
		
	
		
			
				|  |  | } |  |  | } | 
		
	
		
			
				|  |  | </style> |  |  | </style> | 
		
	
	
		
			
				|  | 
 |