diff --git a/src/views/backOfficeSystem/JudgmentHome/strategicResearch/addReport.vue b/src/views/backOfficeSystem/JudgmentHome/strategicResearch/addReport.vue index c69443f..b1e88f6 100644 --- a/src/views/backOfficeSystem/JudgmentHome/strategicResearch/addReport.vue +++ b/src/views/backOfficeSystem/JudgmentHome/strategicResearch/addReport.vue @@ -9,24 +9,26 @@
-
- - +
-
+
下载
@@ -52,11 +54,7 @@ import { gsxtYpbgAddEntity, gsxtYpbgEditEntity, gsxtYpbgId } from "@/api/huiShan const emit = defineEmits(["updateDate", 'ok']); const { proxy } = getCurrentInstance(); const { D_BZ_YPLX } = proxy.$dict("D_BZ_YPLX") -const props = defineProps({ - dic: Object, -}); - - +const props = defineProps({}); const ConsultationShow = ref(false) const showText = ref(false); const textContent = ref() @@ -112,74 +110,63 @@ const formData = ref([ { label: "报告类型", prop: "bglx", type: "select", width: "100%", options: D_BZ_YPLX }, - { label: "报告内容", prop: "bgnr", type: "slot", width: "100%", blur: setEditorTextContent }, ]); - -const listQuery = ref({ - bgmc: "", - bgnr: "", - fj: "" -}); //表单 +const listQuery = ref({}); //表单 const loading = ref(false); const elform = ref(); const title = ref(""); -/** 外面行数据 */ -const outRow = ref({}) - // 初始化数据 const init = (type, row) => { - if(row){ - listQuery.value = { - bgmc: row.bgmc, - bgnr: row.bgnr, - id: row.id, - bglx: row.bglx, - } - outRow.value = { ...row } - } + if(row) listQuery.value = JSON.parse(JSON.stringify(row)); dialogForm.value = true; title.value = type == "add" ? "新增" :type == "edit"? "编辑" : "详情"; setEditorTextContent() }; -const getText = (val, row = {}) => { +const getText = (val) => { listQuery.value.fj = val.text; setEditorTextContent() } +function stripReportHeader(html) { + const source = typeof html === "string" ? html : ""; + if (!source) return ""; + const hrMatch = source.match(/]*\/?>/i); + if (hrMatch && typeof hrMatch.index === "number") { + return source.slice(hrMatch.index + hrMatch[0].length).trim(); + } + if (typeof dataBt.value === "string" && source.startsWith(dataBt.value)) { + return source.slice(dataBt.value.length).trim(); + } + return source.trim(); +} + function setEditorTextContent() { let html = dataBt.value; html += `

${listQuery.value.bgnr || ''}

` html += `

${listQuery.value.fj || ''}

` - textContent.value = html + textContent.value = html; } -// watch(() => listQuery.value, (val) => { - -// }, -// { -// deep: true, immediate: true -// }) // 提交 const submit = () => { - elform.value.submit((data) => { - // let url = title.value == "新增" ? "/mosty-gsxt/gsxt/jyfx/add" : "/mosty-gsxt/gsxt/jyfx/edit"; - - let params = { + elform.value.submit( async (data) => { + loading.value = true; + const params = { ...data, - ypid: outRow.value.id, - ypmc: outRow.value.ypyt + bgnr: stripReportHeader(textContent.value) }; - const apiFun = !listQuery.value.id ? gsxtYpbgAddEntity : gsxtYpbgEditEntity - if (!listQuery.value.id) delete params.id - apiFun(params).then(() => { + const apiFun = !listQuery.value.id ? gsxtYpbgAddEntity : gsxtYpbgEditEntity; + if (!listQuery.value.id) delete params.id; + try { + await apiFun(params); loading.value = false; proxy.$message({ type: "success", message: title.value + "成功" }); emit("ok"); close(); - }).catch(() => { + } catch (e) { loading.value = false; - }) + } }); }; //编辑器创建成功 @@ -188,9 +175,8 @@ const handleCreated = (editor) => { }; //内容发生变化 const handChange = (editor) => { + // 判断是否是一个空段落,是空就传空文本 - - }; onBeforeUnmount(() => { const editor = editorRef.value; @@ -200,7 +186,6 @@ onBeforeUnmount(() => { // 关闭 const close = () => { - listQuery.value = {}; loading.value = false; dialogForm.value = false; listQuery.value = {} diff --git a/src/views/backOfficeSystem/JudgmentHome/strategicResearch/index.vue b/src/views/backOfficeSystem/JudgmentHome/strategicResearch/index.vue index e64c015..2409ccc 100644 --- a/src/views/backOfficeSystem/JudgmentHome/strategicResearch/index.vue +++ b/src/views/backOfficeSystem/JudgmentHome/strategicResearch/index.vue @@ -149,7 +149,6 @@ const getList = () => { let data = { ...pageData.pageConfiger, ...queryFrom.value}; gsxtYpbgGetPageList(data).then(res => { console.log(res); - pageData.tableData = res.records || []; pageData.total = res.total; pageData.tableConfiger.loading = false;