Browse Source

修改codeMirror的updateValue事件

main
likunming 6 months ago
parent
commit
35c5815d9e
  1. 8
      io.sc.platform.core.frontend/src/platform/components/code-mirror/WCodeMirror.vue
  2. 12
      io.sc.platform.core.frontend/src/platform/components/form/WForm.vue

8
io.sc.platform.core.frontend/src/platform/components/code-mirror/WCodeMirror.vue

@ -254,6 +254,9 @@ onMounted(() => {
if (!props.lineBreak) {
content = content?.replace(/[\r\n]/g, '');
}
if (content !== modelValue.value) {
fieldMethodsClass.updateValue(content);
}
//updateModelValue(content);
}),
],
@ -270,7 +273,6 @@ onMounted(() => {
content = content.replace(/[\r\n]/g, '');
}
editorView.dispatch({ changes: { from: 0, to: editorView.state.doc.length, insert: content } });
fieldMethodsClass.updateValue(content);
}
},
);
@ -288,8 +290,8 @@ const focus = () => {
const blur = () => {
isFocus = false;
let content = editorView.state.doc.toString();
if (Tools.isUndefinedOrNull(content)) {
modelValue.value = '';
if (Tools.isUndefinedOrNull(content) || content === modelValue.value) {
return;
}
const reg = /\$\{(.+?)\}\.\$\{(.+?)\}/g;
while (reg.test(content)) {

12
io.sc.platform.core.frontend/src/platform/components/form/WForm.vue

@ -73,6 +73,10 @@ const props = defineProps({
},
});
const emit = defineEmits<{
(e: 'updateValue', args: object): void;
}>();
const localFlag = ref(false);
const formRef = ref();
const formStatus = ref(PageStatusEnum.新增);
@ -100,6 +104,8 @@ const defaultValueHandler = (field) => {
field.multiple
) {
return [];
} else if (field.type === 'w-code-mirror') {
return '';
}
return undefined;
};
@ -177,6 +183,12 @@ const updateModelValue = (name, value) => {
formFields[name].error = false;
formFields[name].errorMessage = undefined;
}
emit('updateValue', {
form: instance,
value: toRaw(formData),
fieldName: name,
fieldValue: value,
});
};
const setComponentRef = (el, fieldName) => {

Loading…
Cancel
Save