feat: 富文本和项目报监bug

This commit is contained in:
于晏彭 2023-05-26 11:22:38 +08:00
parent 19fd88b4ab
commit 36744c2071
3 changed files with 26 additions and 12 deletions

View File

@ -18,7 +18,6 @@
import { QuillEditor } from "@vueup/vue-quill"; import { QuillEditor } from "@vueup/vue-quill";
import "@vueup/vue-quill/dist/vue-quill.snow.css"; import "@vueup/vue-quill/dist/vue-quill.snow.css";
import { reactive, onMounted, ref, toRaw, watch } from "vue"; import { reactive, onMounted, ref, toRaw, watch } from "vue";
// import { backsite } from '@/api'
import { upload } from "@/api/modules/upload"; import { upload } from "@/api/modules/upload";
const props = defineProps(["value"]); const props = defineProps(["value"]);
@ -30,17 +29,22 @@ const clearText = () => {
toRaw(myQuillEditor.value).setHTML(""); toRaw(myQuillEditor.value).setHTML("");
}; };
defineExpose<{ clearText: typeof clearText }>({ clearText }); const setText = val => {
toRaw(myQuillEditor.value).setHTML(val);
};
defineExpose<{ clearText: typeof clearText; setText: typeof setText }>({ clearText, setText });
const myQuillEditor = ref(); const myQuillEditor = ref();
watch(
() => props.value, // watch(
val => { // () => props.value,
// console.log(toRaw(myQuillEditor.value)); // val => {
toRaw(myQuillEditor.value).getHTML(val); // console.log(toRaw(myQuillEditor.value));
}, // toRaw(myQuillEditor.value).setHTML(val);
{ deep: true } // }
); // );
const fileBtn = ref(); const fileBtn = ref();
const data = reactive({ const data = reactive({
content: "", content: "",
@ -98,6 +102,7 @@ onMounted(() => {
if (myQuillEditor.value) { if (myQuillEditor.value) {
quill.getModule("toolbar").addHandler("image", imgHandler); quill.getModule("toolbar").addHandler("image", imgHandler);
} }
toRaw(myQuillEditor.value).setHTML(props.value); toRaw(myQuillEditor.value).setHTML(props.value);
}); });
</script> </script>

View File

@ -115,11 +115,13 @@ const confirm = async (formEl: FormInstance | undefined, params: any) => {
if (store.Message != undefined) { if (store.Message != undefined) {
await editmyPost(formData.value); await editmyPost(formData.value);
ElMessage.success("编辑成功"); ElMessage.success("编辑成功");
editorRef.value?.clearText();
delete store.Message; delete store.Message;
} else { } else {
try { try {
const res = await addLows(formData.value); const res = await addLows(formData.value);
ElMessage.success("发布成功"); ElMessage.success("发布成功");
editorRef.value?.clearText();
} catch (err) {} } catch (err) {}
// //
editorRef.value?.clearText(); editorRef.value?.clearText();
@ -156,6 +158,7 @@ onMounted(async () => {
annexFileList.value = []; annexFileList.value = [];
if (store.Message) { if (store.Message) {
formData.value = store.Message as formDataType; formData.value = store.Message as formDataType;
editorRef.value.setText(formData.value.content);
// //
annexFileList.value = [ annexFileList.value = [
{ name: store.Message.annexFileList[0].fileName || null, url: store.Message.annexFileList[0].fileUrl || null } { name: store.Message.annexFileList[0].fileName || null, url: store.Message.annexFileList[0].fileUrl || null }

View File

@ -83,9 +83,15 @@ onMounted(async () => {
if (store.Message && store.Message.engineeringMains.length) { if (store.Message && store.Message.engineeringMains.length) {
formData.value = formData.value.map(item => { formData.value = formData.value.map(item => {
// console.log("main", store.Message.engineeringMains); // console.log("main", store.Message.engineeringMains);
const curr = store.Message.engineeringMains.find(main => item.type == main.type); let curr = store.Message.engineeringMains.find(main => item.type == main.type);
if ("contractType" in item) { if ("contractType" in item) {
return curr; return (curr = {
enterpriseSn: curr.enterpriseName,
creditCode: curr.creditCode,
legalPerson: curr.legalPerson,
legalPersonTel: curr.legalPersonTel,
contractType: curr.contractType
});
} else { } else {
delete curr["contractType"]; delete curr["contractType"];
return curr; return curr;