Commit f4c2ae81 authored by 黄奎's avatar 黄奎

页面修改

parent 60b16810
<template> <template>
<div> <div>
<script type="text/plain" id="editor"></script> <script type="text/plain" :id="id"></script>
<!-- 选择图片 --> <!-- 选择图片 -->
<el-dialog title="选择文件" :visible.sync="changeState" width="1240px"> <el-dialog title="选择文件" :visible.sync="changeState" width="1240px">
<ChooseImg @SelectId="SelectId"></ChooseImg> <ChooseImg @SelectId="SelectId"></ChooseImg>
...@@ -14,10 +14,13 @@ ...@@ -14,10 +14,13 @@
ChooseImg ChooseImg
}, },
name: 'UE', name: 'UE',
data () { data() {
return { return {
id: 'editor' + (Math.floor((Math.random() * 10000) + 1)),
editor: null, editor: null,
changeState:false, changeState:false,
isInputChange: false,
tempContent: this.defaultMsg
} }
}, },
props: { props: {
...@@ -29,45 +32,61 @@ ...@@ -29,45 +32,61 @@
}, },
}, },
mounted() { mounted() {
this.loadUe();
},
watch: {
defaultMsg(newVal, oldVal) {
if (!this.isInputChange && newVal) {
if (this.editor && this.editor.isReady === 1) {
this.editor.setContent(newVal);
} else {
this.tempContent = newVal;
}
}
if (this.isInputChange) {
this.isInputChange = false;
}
},
}, },
methods: { methods: {
InitData(){ InitData() {
const _this = this;
this.editor = UE.getEditor('editor', this.config); // 初始化UE
this.editor.addListener("ready", function () {
_this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
});
this.loadUe();
}, },
SelectId(e) { SelectId(e) {
if (e) { if (e) {
let html = ''; let html = '';
this.ue = UE.getEditor('editor'); this.ue = UE.getEditor(this.id);
html= '<img src="' + this.domainManager().ImageUrl+e.url + '" style="max-width: 100%;">'; html = '<img src="' + this.domainManager().ImageUrl + e.url + '" style="max-width: 100%;">';
this.ue.execCommand('inserthtml', html); this.ue.execCommand('inserthtml', html);
} }
this.changeState=false; this.isInputChange = false;
}, },
getUEContent() { // 获取内容方法 getUEContent() { // 获取内容方法
return this.editor.getContent() return this.editor.getContent()
}, },
loadUe() { loadUe() {
const vm = this; const _this = this;
this.ue = UE.getEditor('editor'); this.editor = UE.getEditor(this.id, this.config); // 初始化UE
// this.ue.addListener('ready', editor => { this.editor.addListener("ready", function () {
// if (this.tempContent) { _this.editor.setContent(_this.defaultMsg); // 确保UE加载完成后,放入内容。
// this.ue.setContent(this.tempContent); });
// }
// }); this.editor.addListener('ready', editor => {
// this.ue.addListener('keyup', editor => { if (_this.tempContent) {
// this.isInputChange = true; _this.editor.setContent(_this.tempContent);
// this.$emit('input', this.ue.getContent()); }
// }); });
// this.ue.addListener('contentChange', editor => { this.editor.addListener('keyup', editor => {
// this.isInputChange = true; this.isInputChange = false;
// this.$emit('input', this.ue.getContent()); var str = _this.editor.getContent();
// }); _this.$emit('input', _this.editor.getContent());
});
this.editor.addListener('contentChange', editor => {
this.isInputChange = false;
var str = _this.editor.getContent();
_this.$emit('input', _this.editor.getContent());
});
let self = this; let self = this;
UE.registerUI('appinsertimage', (editor, uiName) => { UE.registerUI('appinsertimage', (editor, uiName) => {
return new UE.ui.Button({ return new UE.ui.Button({
...@@ -77,7 +96,7 @@ ...@@ -77,7 +96,7 @@
cssRules: 'background-position: -381px 0px;', cssRules: 'background-position: -381px 0px;',
onclick() { onclick() {
self.ue = editor self.ue = editor
vm.changeState = true; _this.isInputChange = true;
}, },
}); });
}); });
...@@ -88,4 +107,5 @@ ...@@ -88,4 +107,5 @@
}, },
} }
</script> </script>
...@@ -2,15 +2,18 @@ ...@@ -2,15 +2,18 @@
.diy-image-text { .diy-image-text {
width: 100%; width: 100%;
height: 500px; height: 500px;
overflow:hidden; overflow: hidden;
overflow-y: auto; overflow-y: auto;
} }
.bb{
.bb {
visibility: hidden; visibility: hidden;
} }
.classA{
.classA {
visibility: visible; visibility: visible;
} }
</style> </style>
<template> <template>
<div :class="{'active':imageData.isCked}"> <div :class="{'active':imageData.isCked}">
...@@ -25,12 +28,12 @@ ...@@ -25,12 +28,12 @@
<div class="diy-modal"> <div class="diy-modal">
<div class="diy-component-preview"> <div class="diy-component-preview">
<div class="diy-image-text"> <div class="diy-image-text">
<div v-if="data.content" v-html="jiance"></div> <div v-if="data.content" v-html="data.content"></div>
<div v-else flex="main:center" style="line-height: 500px;color: rgb(173, 177, 184);">图文详情</div> <div v-else flex="main:center" style="line-height: 500px;color: rgb(173, 177, 184);">图文详情</div>
</div> </div>
</div> </div>
<div class="diy-component-edit bb" :class="{'classA':imageData.isCked}"> <div class="diy-component-edit bb" :class="{'classA':imageData.isCked}">
<UE :defaultMsg=defaultMsg :config=config ref="ue"></UE> <UE :defaultMsg="defaultMsg" :config="config" ref="ue" @input="input"></UE>
</div> </div>
</div> </div>
</div> </div>
...@@ -50,11 +53,10 @@ ...@@ -50,11 +53,10 @@
initialFrameWidth: null, initialFrameWidth: null,
initialFrameHeight: 350, initialFrameHeight: 350,
}, },
content:'' content: ''
}; };
}, },
created() { created() {},
},
methods: { methods: {
//向父组件传值 并调用排序 //向父组件传值 并调用排序
resetSord(IsUp) { resetSord(IsUp) {
...@@ -64,14 +66,21 @@ ...@@ -64,14 +66,21 @@
delPlugin() { delPlugin() {
this.$emit('comDelPlugin', this.index); this.$emit('comDelPlugin', this.index);
}, },
input(obj) {
this.data.content = obj
}, },
computed: {
}, },
computed: {},
mounted() { mounted() {
this.$refs.ue.InitData(); this.$refs.ue.InitData();
}, },
watch:{ watch: {
defaultMsg: {
handler(newVal, oldVal) {
console.log(newVal);
},
deep: true
}
} }
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment