feat: 富文本和项目报监bug
This commit is contained in:
parent
19fd88b4ab
commit
36744c2071
@ -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>
|
||||||
|
|||||||
@ -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 }
|
||||||
|
|||||||
@ -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;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user