This commit is contained in:
辉 2024-04-08 10:58:02 +08:00
parent b2cb39bd84
commit 9e142de3de
2 changed files with 43 additions and 15 deletions

View File

@ -41,6 +41,7 @@ import { getToken } from "@/utils/auth";
var that
export default ({
props: ['nodeContent'],
components: { Editor, Toolbar },
name: 'wangEditor',
data() {
@ -86,6 +87,7 @@ export default ({
},
methods: {
emit() {
console.log()
this.$emit("on-nodeContent", { nodeContent: this.html });
},
panelchange(item) {
@ -124,7 +126,7 @@ export default ({
link: '',
fileName: this.addnode.fileName,
fileSpan: this.addnode.fileSpan,
children: [{ text: ' ' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
}
this.editor.insertNode(resume)
this.addnode = {
@ -149,7 +151,7 @@ export default ({
link: '',
fileName: this.addnode.fileName,
fileSpan: this.addnode.fileSpan,
children: [{ text: ' ' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
}
this.editor.insertNode(resume)
this.addnode = {
@ -192,7 +194,15 @@ export default ({
this.labelshow = false
},
},
watch: {
nodeContent(newValue, oldValue) {
if (newValue) {
this.html = newValue;
}
}
},
mounted() {
this.html = this.nodeContent
},
beforeDestroy() {
const editor = this.editor
@ -279,7 +289,6 @@ function withAttachment(editor) { // JS 语法
const type = DomEditor.getNodeType(elem)
if (type === 'attachment') return true // 针对 type: attachment ,设置为 inline
if (type === 'attachmenttwo') return true // 针对 type: attachment ,设置为 inline
if (type === 'text') return true // 针对 type: attachment ,设置为 inline
return isInline(elem)
}
newEditor.isVoid = elem => {
@ -464,8 +473,7 @@ function attachmentToHtml(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem
// 生成 HTML 代码
const html = `
<span data-w-e-type="attachment"
const html = `<span data-w-e-type="attachment"
data-w-e-is-void
data-w-e-is-inline
data-link="${link}"
@ -482,8 +490,7 @@ function attachmentToHtmltwo(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem
// 生成 HTML 代码
const html = `
<span data-w-e-type="attachmenttwo"
const html = `<span data-w-e-type="attachmenttwo"
data-w-e-is-void
data-w-e-is-inline
data-link="${link}"
@ -523,11 +530,33 @@ function parseAttachmentHtml(domElem, children, editor) {
}
return myResume
}
function parseAttachmentHtmltwo(domElem, children, editor) { // JS 语法
// 从 DOM element 中获取“附件”的信息
const link = domElem.getAttribute('data-link') || ''
const fileName = domElem.getAttribute('data-fileName') || ''
const fileSpan = domElem.getAttribute('data-fileSpan') || ''
// 生成“附件”元素(按照此前约定的数据结构)
const myResume = {
type: 'attachmenttwo',
link,
fileName,
fileSpan,
children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!!
}
return myResume
}
const parseHtmlConf = {
selector: 'span[data-w-e-type="attachment"]', // CSS 选择器,匹配特定的 HTML 标签
parseElemHtml: parseAttachmentHtml,
}
Boot.registerParseElemHtml(parseHtmlConf)
const parseHtmlConftwo = {
selector: 'span[data-w-e-type="attachmenttwo"]', // CSS 选择器,匹配特定的 HTML 标签
parseElemHtml: parseAttachmentHtmltwo,
}
const parseHtmlConfmodule = {
parseElemsHtml: [parseHtmlConf, parseHtmlConftwo] // parseElemHtml
}
Boot.registerModule(parseHtmlConfmodule)
</script>
<style lang="scss" scoped>
::v-deep .el-textarea__inner {

View File

@ -96,7 +96,8 @@
</el-form>
</div>
<div class="bottomform">
<wangeditor style="width:100%;" @on-nodeContent="onNodeContent" ref="wangeditor" />
<wangeditor style="width:100%;" :nodeContent="form.nodeContent" @on-nodeContent="onNodeContent"
ref="wangeditor" />
<div class="card">
<div class="flex">
<div class="pushMethod">
@ -319,12 +320,10 @@ export default {
this.updata.specialDiseaseRouteId = this.$route.query.id
selectSpecialDisease(this.$route.query.id).then(res => {
res.data.specialDiseaseNodeList.forEach(e => {
if (e.taskType) {
e.taskType = Number(e.taskType)
this.changeTaskType(e.taskType, e.taskSubdivision)
}
e.taskSubdivision = Number(e.taskSubdivision)
e.taskStatus = Number(e.taskStatus)
this.changeTaskType(e.taskType, e.taskSubdivision)
let item = {
routeNodeName: e.routeNodeName,
routeNodeDay: e.routeNodeDay,
@ -402,8 +401,7 @@ export default {
this.updata.specialDiseaseNodeList.push(el)
}) : ""
})
specialDiseaseNode(this.updata).then(res => {
})
specialDiseaseNode(this.updata).then(res => { })
},
//问卷传值
questionontemplate(item) {
@ -454,6 +452,7 @@ export default {
})
},
changetaskSubdivision(e) {
this.form.taskSubdivision = e
this.taskPartitionList.forEach(el => {
if (e == el.id) {
this.form.executionTime = el.executionTime