This commit is contained in:
辉 2024-05-24 11:03:42 +08:00
parent ce89cd4052
commit 65b7669bf5
3 changed files with 39 additions and 16 deletions

View File

@ -89,6 +89,7 @@ export default ({
addnode: { addnode: {
fileName: '', fileName: '',
fileSpan: '', fileSpan: '',
fieldMark: "",
}, },
modify: false, modify: false,
} }
@ -107,6 +108,7 @@ export default ({
if (el.labelFieldId == item[1]) { if (el.labelFieldId == item[1]) {
this.addnode.fileSpan = el.fieldName this.addnode.fileSpan = el.fieldName
this.addnode.fileName = e.fieldName this.addnode.fileName = e.fieldName
this.addnode.fieldMark = el.fieldMark
} }
}) })
}) })
@ -116,6 +118,7 @@ export default ({
if (el.labelFieldId == item[1]) { if (el.labelFieldId == item[1]) {
this.addnode.fileSpan = el.fieldName this.addnode.fileSpan = el.fieldName
this.addnode.fileName = e.fieldName this.addnode.fileName = e.fieldName
this.addnode.fieldMark = el.fieldMark
} }
}) })
}) })
@ -135,6 +138,7 @@ export default ({
type: 'attachment', type: 'attachment',
link: '', link: '',
fileName: this.addnode.fileName, fileName: this.addnode.fileName,
fieldMark: this.addnode.fieldMark,
fileSpan: this.addnode.fileSpan, fileSpan: this.addnode.fileSpan,
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!! children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
} }
@ -142,6 +146,7 @@ export default ({
this.addnode = { this.addnode = {
fileName: '', fileName: '',
fileSpan: '', fileSpan: '',
fieldMark: "",
} }
this.editor.focus() this.editor.focus()
}, 100); }, 100);
@ -160,6 +165,7 @@ export default ({
type: 'attachmenttwo', type: 'attachmenttwo',
link: '', link: '',
fileName: this.addnode.fileName, fileName: this.addnode.fileName,
fieldMark: this.addnode.fieldMark,
fileSpan: this.addnode.fileSpan, fileSpan: this.addnode.fileSpan,
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!! children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
} }
@ -167,6 +173,7 @@ export default ({
this.addnode = { this.addnode = {
fileName: '', fileName: '',
fileSpan: '', fileSpan: '',
fieldMark: "",
} }
this.editor.focus() this.editor.focus()
}, 100); }, 100);
@ -206,9 +213,7 @@ export default ({
}, },
watch: { watch: {
nodeContent(newValue, oldValue) { nodeContent(newValue, oldValue) {
if (newValue) { this.html = newValue;
this.html = newValue;
}
} }
}, },
mounted() { mounted() {
@ -311,7 +316,7 @@ function withAttachment(editor) { // JS 语法
Boot.registerPlugin(withAttachment) Boot.registerPlugin(withAttachment)
function renderAttachment(elem, children, editor) { // JS 语法 function renderAttachment(elem, children, editor) { // JS 语法
// 获取“附件”的数据,参考上文 myResume 数据结构 // 获取“附件”的数据,参考上文 myResume 数据结构
const { fileName = '', link = '', fileSpan = '' } = elem const { fileName = '', link = '', fileSpan = '', fieldMark = '' } = elem
// 附件 icon 图标 vnode // 附件 icon 图标 vnode
const iconVnode = h( const iconVnode = h(
// HTML tag // HTML tag
@ -387,7 +392,7 @@ function renderAttachment(elem, children, editor) {
} }
function renderAttachmenttwo(elem, children, editor) { // JS 语法 function renderAttachmenttwo(elem, children, editor) { // JS 语法
// 获取“附件”的数据,参考上文 myResume 数据结构 // 获取“附件”的数据,参考上文 myResume 数据结构
const { fileName = '', link = '', fileSpan = '' } = elem const { fileName = '', link = '', fileSpan = '', fieldMark = '' } = elem
// 附件 icon 图标 vnode // 附件 icon 图标 vnode
const iconVnode = h( const iconVnode = h(
// HTML tag // HTML tag
@ -480,13 +485,14 @@ const rendermodule = { // JS 语法
Boot.registerModule(rendermodule) Boot.registerModule(rendermodule)
function attachmentToHtml(elem, childrenHtml) { // JS 语法 function attachmentToHtml(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据 // 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem const { link = '', fileName = '', fileSpan = '', fieldMark = '' } = elem
// 生成 HTML 代码 // 生成 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-void
data-w-e-is-inline data-w-e-is-inline
data-link="${link}" data-link="${link}"
data-fileSpan="${fileSpan}" data-fileSpan="${fileSpan}"
data-fieldMark="${fieldMark}"
data-fileName="${fileName}"> data-fileName="${fileName}">
<span class="path-tag-wrap"> <span class="path-tag-wrap">
<span>${fileName}</span> <span>${fileName}</span>
@ -497,13 +503,14 @@ function attachmentToHtml(elem, childrenHtml) { // JS 语法
} }
function attachmentToHtmltwo(elem, childrenHtml) { // JS 语法 function attachmentToHtmltwo(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据 // 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem const { link = '', fileName = '', fileSpan = '', fieldMark = '' } = elem
// 生成 HTML 代码 // 生成 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-void
data-w-e-is-inline data-w-e-is-inline
data-link="${link}" data-link="${link}"
data-fileSpan="${fileSpan}" data-fileSpan="${fileSpan}"
data-fieldMark="${fieldMark}"
data-fileName="${fileName}"> data-fileName="${fileName}">
<span class="path-tag-wrap"> <span class="path-tag-wrap">
<span>${fileName}</span> <span>${fileName}</span>
@ -529,12 +536,14 @@ function parseAttachmentHtml(domElem, children, editor) {
const link = domElem.getAttribute('data-link') || '' const link = domElem.getAttribute('data-link') || ''
const fileName = domElem.getAttribute('data-fileName') || '' const fileName = domElem.getAttribute('data-fileName') || ''
const fileSpan = domElem.getAttribute('data-fileSpan') || '' const fileSpan = domElem.getAttribute('data-fileSpan') || ''
const fieldMark = domElem.getAttribute('data-fieldMark') || ''
// 生成“附件”元素(按照此前约定的数据结构) // 生成“附件”元素(按照此前约定的数据结构)
const myResume = { const myResume = {
type: 'attachment', type: 'attachment',
link, link,
fileName, fileName,
fileSpan, fileSpan,
fieldMark,
children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!! children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!!
} }
return myResume return myResume
@ -544,11 +553,13 @@ function parseAttachmentHtmltwo(domElem, children, editor) {
const link = domElem.getAttribute('data-link') || '' const link = domElem.getAttribute('data-link') || ''
const fileName = domElem.getAttribute('data-fileName') || '' const fileName = domElem.getAttribute('data-fileName') || ''
const fileSpan = domElem.getAttribute('data-fileSpan') || '' const fileSpan = domElem.getAttribute('data-fileSpan') || ''
const fieldMark = domElem.getAttribute('data-fieldMark') || ''
// 生成“附件”元素(按照此前约定的数据结构) // 生成“附件”元素(按照此前约定的数据结构)
const myResume = { const myResume = {
type: 'attachmenttwo', type: 'attachmenttwo',
link, link,
fileName, fileName,
fieldMark,
fileSpan, fileSpan,
children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!! children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!!
} }

View File

@ -442,7 +442,7 @@ export default {
required: true, required: true,
trigger: "blur", trigger: "blur",
validator: validateInput // validator: validateInput
}, },
// { pattern:/^$W*$/, message: '以$开头且不能输入汉字和数字的字符串', trigger: 'blur' } // { pattern:/^$W*$/, message: '以$开头且不能输入汉字和数字的字符串', trigger: 'blur' }
], ],
@ -479,7 +479,7 @@ export default {
required: true, required: true,
// message: "请输入画像字段表示", // message: "请输入画像字段表示",
trigger: "blur", trigger: "blur",
validator: validateInput // validator: validateInput
}, },
], ],

View File

@ -89,6 +89,7 @@ export default ({
addnode: { addnode: {
fileName: '', fileName: '',
fileSpan: '', fileSpan: '',
fieldMark: "",
}, },
modify: false, modify: false,
} }
@ -104,6 +105,7 @@ export default ({
if (el.labelFieldId == item[1]) { if (el.labelFieldId == item[1]) {
this.addnode.fileSpan = el.fieldName this.addnode.fileSpan = el.fieldName
this.addnode.fileName = e.fieldName this.addnode.fileName = e.fieldName
this.addnode.fieldMark = el.fieldMark
} }
}) })
}) })
@ -113,6 +115,7 @@ export default ({
if (el.labelFieldId == item[1]) { if (el.labelFieldId == item[1]) {
this.addnode.fileSpan = el.fieldName this.addnode.fileSpan = el.fieldName
this.addnode.fileName = e.fieldName this.addnode.fileName = e.fieldName
this.addnode.fieldMark = el.fieldMark
} }
}) })
}) })
@ -133,12 +136,14 @@ export default ({
link: '', link: '',
fileName: this.addnode.fileName, fileName: this.addnode.fileName,
fileSpan: this.addnode.fileSpan, fileSpan: this.addnode.fileSpan,
fieldMark: this.addnode.fieldMark,
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!! children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
} }
this.editor.insertNode(resume) this.editor.insertNode(resume)
this.addnode = { this.addnode = {
fileName: '', fileName: '',
fileSpan: '', fileSpan: '',
fieldMark: '',
} }
this.editor.focus() this.editor.focus()
}, 100); }, 100);
@ -158,11 +163,13 @@ export default ({
link: '', link: '',
fileName: this.addnode.fileName, fileName: this.addnode.fileName,
fileSpan: this.addnode.fileSpan, fileSpan: this.addnode.fileSpan,
fieldMark: this.addnode.fieldMark,
children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!! children: [{ text: '' }], // void 元素必须有一个 children ,其中只有一个空字符串,重要!!!
} }
this.editor.insertNode(resume) this.editor.insertNode(resume)
this.addnode = { this.addnode = {
fileName: '', fileName: '',
fieldMark: '',
fileSpan: '', fileSpan: '',
} }
this.editor.focus() this.editor.focus()
@ -205,9 +212,8 @@ export default ({
}, },
watch: { watch: {
nodeContent(newValue, oldValue) { nodeContent(newValue, oldValue) {
if (newValue) { console.log(newValue, oldValue)
this.html = newValue; this.html = newValue;
}
} }
}, },
mounted() { mounted() {
@ -310,7 +316,7 @@ function withAttachment(editor) { // JS 语法
Boot.registerPlugin(withAttachment) Boot.registerPlugin(withAttachment)
function renderAttachment(elem, children, editor) { // JS 语法 function renderAttachment(elem, children, editor) { // JS 语法
// 获取“附件”的数据,参考上文 myResume 数据结构 // 获取“附件”的数据,参考上文 myResume 数据结构
const { fileName = '', link = '', fileSpan = '' } = elem const { fileName = '', link = '', fileSpan = '', fieldMark } = elem
// 附件 icon 图标 vnode // 附件 icon 图标 vnode
const iconVnode = h( const iconVnode = h(
// HTML tag // HTML tag
@ -386,7 +392,7 @@ function renderAttachment(elem, children, editor) {
} }
function renderAttachmenttwo(elem, children, editor) { // JS 语法 function renderAttachmenttwo(elem, children, editor) { // JS 语法
// 获取“附件”的数据,参考上文 myResume 数据结构 // 获取“附件”的数据,参考上文 myResume 数据结构
const { fileName = '', link = '', fileSpan = '' } = elem const { fileName = '', link = '', fileSpan = '', fieldMark = '' } = elem
// 附件 icon 图标 vnode // 附件 icon 图标 vnode
const iconVnode = h( const iconVnode = h(
// HTML tag // HTML tag
@ -479,13 +485,14 @@ const rendermodule = { // JS 语法
Boot.registerModule(rendermodule) Boot.registerModule(rendermodule)
function attachmentToHtml(elem, childrenHtml) { // JS 语法 function attachmentToHtml(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据 // 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem const { link = '', fileName = '', fileSpan = '', fieldMark = '' } = elem
// 生成 HTML 代码 // 生成 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-void
data-w-e-is-inline data-w-e-is-inline
data-link="${link}" data-link="${link}"
data-fileSpan="${fileSpan}" data-fileSpan="${fileSpan}"
data-fieldMark="${fieldMark}"
data-fileName="${fileName}"> data-fileName="${fileName}">
<span class="path-tag-wrap"> <span class="path-tag-wrap">
<span>${fileName}</span> <span>${fileName}</span>
@ -496,13 +503,14 @@ function attachmentToHtml(elem, childrenHtml) { // JS 语法
} }
function attachmentToHtmltwo(elem, childrenHtml) { // JS 语法 function attachmentToHtmltwo(elem, childrenHtml) { // JS 语法
// 获取附件元素的数据 // 获取附件元素的数据
const { link = '', fileName = '', fileSpan = '' } = elem const { link = '', fileName = '', fileSpan = '', fieldMark = '' } = elem
// 生成 HTML 代码 // 生成 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-void
data-w-e-is-inline data-w-e-is-inline
data-link="${link}" data-link="${link}"
data-fileSpan="${fileSpan}" data-fileSpan="${fileSpan}"
data-fieldMark="${fieldMark}"
data-fileName="${fileName}"> data-fileName="${fileName}">
<span class="path-tag-wrap"> <span class="path-tag-wrap">
<span>${fileName}</span> <span>${fileName}</span>
@ -528,12 +536,14 @@ function parseAttachmentHtml(domElem, children, editor) {
const link = domElem.getAttribute('data-link') || '' const link = domElem.getAttribute('data-link') || ''
const fileName = domElem.getAttribute('data-fileName') || '' const fileName = domElem.getAttribute('data-fileName') || ''
const fileSpan = domElem.getAttribute('data-fileSpan') || '' const fileSpan = domElem.getAttribute('data-fileSpan') || ''
const fieldMark = domElem.getAttribute('data-fieldMark') || ''
// 生成“附件”元素(按照此前约定的数据结构) // 生成“附件”元素(按照此前约定的数据结构)
const myResume = { const myResume = {
type: 'attachment', type: 'attachment',
link, link,
fileName, fileName,
fileSpan, fileSpan,
fieldMark,
children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!! children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!!
} }
return myResume return myResume
@ -543,12 +553,14 @@ function parseAttachmentHtmltwo(domElem, children, editor) {
const link = domElem.getAttribute('data-link') || '' const link = domElem.getAttribute('data-link') || ''
const fileName = domElem.getAttribute('data-fileName') || '' const fileName = domElem.getAttribute('data-fileName') || ''
const fileSpan = domElem.getAttribute('data-fileSpan') || '' const fileSpan = domElem.getAttribute('data-fileSpan') || ''
const fieldMark = domElem.getAttribute('data-fieldMark') || ''
// 生成“附件”元素(按照此前约定的数据结构) // 生成“附件”元素(按照此前约定的数据结构)
const myResume = { const myResume = {
type: 'attachmenttwo', type: 'attachmenttwo',
link, link,
fileName, fileName,
fileSpan, fileSpan,
fieldMark,
children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!! children: [{ text: '' }], // void node 必须有 children ,其中有一个空字符串,重要!!!
} }
return myResume return myResume