This commit is contained in:
2026-01-25 21:29:59 +08:00
parent 8b3494c95b
commit 1a3c4f0ea9
2 changed files with 42 additions and 58 deletions

View File

@ -9,24 +9,26 @@
</div> </div>
<div class="form_cnt"> <div class="form_cnt">
<FormMessage :formList="formData" v-model="listQuery" ref="elform" :rules="rules"> <FormMessage :formList="formData" v-model="listQuery" ref="elform" :rules="rules">
<template #bgnr>
<el-input v-model="listQuery.bgnr" style="width: 100%" placeholder="请输入关键字" class="input-with-select">
<template #append>
<el-button :icon="Search" type="primary">搜索</el-button>
</template>
</el-input>
</template>
<template #fj><el-button type="primary" @click="showText = true">附件上传</el-button></template> <template #fj><el-button type="primary" @click="showText = true">附件上传</el-button></template>
</FormMessage> </FormMessage>
<div class="cntBox"> <div class="cntBox">
<!-- 工具栏 --> <!-- 工具栏 -->
<Toolbar style="border-bottom: 1px solid #ccc" :editor="editorRef" :defaultConfig="toolbarConfig" <Toolbar
style="border-bottom: 1px solid #ccc"
:editor="editorRef"
:defaultConfig="toolbarConfig"
:mode="mode" /> :mode="mode" />
<!-- 编辑器 --> <!-- 编辑器 -->
<Editor :style="`height: 480px; overflow-y: hidden`" :model-value="textContent" :defaultConfig="editorConfig" <Editor
:mode="mode" @onCreated="handleCreated" @onChange="handChange" /> :style="`height: 480px; overflow-y: hidden`"
v-model="textContent"
:defaultConfig="editorConfig"
:mode="mode"
@onCreated="handleCreated"
@onChange="handChange"
/>
</div> </div>
<div v-if="outRow.id" style="display: flex; justify-content: center;"> <div v-if="listQuery.id" style="display: flex; justify-content: center;">
<!-- <el-button style="display: block;" type="primary" @click="ConsultationShow = true">网上会商</el-button> --> <!-- <el-button style="display: block;" type="primary" @click="ConsultationShow = true">网上会商</el-button> -->
<el-button style="display: block;" type="primary" @click="downloadWithStyles(textContent)">下载</el-button> <el-button style="display: block;" type="primary" @click="downloadWithStyles(textContent)">下载</el-button>
</div> </div>
@ -52,11 +54,7 @@ import { gsxtYpbgAddEntity, gsxtYpbgEditEntity, gsxtYpbgId } from "@/api/huiShan
const emit = defineEmits(["updateDate", 'ok']); const emit = defineEmits(["updateDate", 'ok']);
const { proxy } = getCurrentInstance(); const { proxy } = getCurrentInstance();
const { D_BZ_YPLX } = proxy.$dict("D_BZ_YPLX") const { D_BZ_YPLX } = proxy.$dict("D_BZ_YPLX")
const props = defineProps({ const props = defineProps({});
dic: Object,
});
const ConsultationShow = ref(false) const ConsultationShow = ref(false)
const showText = ref(false); const showText = ref(false);
const textContent = ref() const textContent = ref()
@ -112,74 +110,63 @@ const formData = ref([
{ {
label: "报告类型", prop: "bglx", type: "select", width: "100%", options: D_BZ_YPLX label: "报告类型", prop: "bglx", type: "select", width: "100%", options: D_BZ_YPLX
}, },
{ label: "报告内容", prop: "bgnr", type: "slot", width: "100%", blur: setEditorTextContent },
]); ]);
const listQuery = ref({}); //表单
const listQuery = ref({
bgmc: "",
bgnr: "",
fj: ""
}); //表单
const loading = ref(false); const loading = ref(false);
const elform = ref(); const elform = ref();
const title = ref(""); const title = ref("");
/** 外面行数据 */
const outRow = ref({})
// 初始化数据 // 初始化数据
const init = (type, row) => { const init = (type, row) => {
if(row){ if(row) listQuery.value = JSON.parse(JSON.stringify(row));
listQuery.value = {
bgmc: row.bgmc,
bgnr: row.bgnr,
id: row.id,
bglx: row.bglx,
}
outRow.value = { ...row }
}
dialogForm.value = true; dialogForm.value = true;
title.value = type == "add" ? "新增" :type == "edit"? "编辑" : "详情"; title.value = type == "add" ? "新增" :type == "edit"? "编辑" : "详情";
setEditorTextContent() setEditorTextContent()
}; };
const getText = (val, row = {}) => { const getText = (val) => {
listQuery.value.fj = val.text; listQuery.value.fj = val.text;
setEditorTextContent() setEditorTextContent()
} }
function stripReportHeader(html) {
const source = typeof html === "string" ? html : "";
if (!source) return "";
const hrMatch = source.match(/<hr\b[^>]*\/?>/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() { function setEditorTextContent() {
let html = dataBt.value; let html = dataBt.value;
html += `<p style="text-align: center;"><span style="font-size: 22px;">${listQuery.value.bgnr || ''}</span></p>` html += `<p style="text-align: center;"><span style="font-size: 22px;">${listQuery.value.bgnr || ''}</span></p>`
html += `<p>${listQuery.value.fj || ''}</p>` html += `<p>${listQuery.value.fj || ''}</p>`
textContent.value = html textContent.value = html;
} }
// watch(() => listQuery.value, (val) => {
// },
// {
// deep: true, immediate: true
// })
// 提交 // 提交
const submit = () => { const submit = () => {
elform.value.submit((data) => { elform.value.submit( async (data) => {
// let url = title.value == "新增" ? "/mosty-gsxt/gsxt/jyfx/add" : "/mosty-gsxt/gsxt/jyfx/edit"; loading.value = true;
const params = {
let params = {
...data, ...data,
ypid: outRow.value.id, bgnr: stripReportHeader(textContent.value)
ypmc: outRow.value.ypyt
}; };
const apiFun = !listQuery.value.id ? gsxtYpbgAddEntity : gsxtYpbgEditEntity const apiFun = !listQuery.value.id ? gsxtYpbgAddEntity : gsxtYpbgEditEntity;
if (!listQuery.value.id) delete params.id if (!listQuery.value.id) delete params.id;
apiFun(params).then(() => { try {
await apiFun(params);
loading.value = false; loading.value = false;
proxy.$message({ type: "success", message: title.value + "成功" }); proxy.$message({ type: "success", message: title.value + "成功" });
emit("ok"); emit("ok");
close(); close();
}).catch(() => { } catch (e) {
loading.value = false; loading.value = false;
}) }
}); });
}; };
//编辑器创建成功 //编辑器创建成功
@ -188,9 +175,8 @@ const handleCreated = (editor) => {
}; };
//内容发生变化 //内容发生变化
const handChange = (editor) => { const handChange = (editor) => {
// 判断是否是一个空段落,是空就传空文本 // 判断是否是一个空段落,是空就传空文本
}; };
onBeforeUnmount(() => { onBeforeUnmount(() => {
const editor = editorRef.value; const editor = editorRef.value;
@ -200,7 +186,6 @@ onBeforeUnmount(() => {
// 关闭 // 关闭
const close = () => { const close = () => {
listQuery.value = {};
loading.value = false; loading.value = false;
dialogForm.value = false; dialogForm.value = false;
listQuery.value = {} listQuery.value = {}

View File

@ -149,7 +149,6 @@ const getList = () => {
let data = { ...pageData.pageConfiger, ...queryFrom.value}; let data = { ...pageData.pageConfiger, ...queryFrom.value};
gsxtYpbgGetPageList(data).then(res => { gsxtYpbgGetPageList(data).then(res => {
console.log(res); console.log(res);
pageData.tableData = res.records || []; pageData.tableData = res.records || [];
pageData.total = res.total; pageData.total = res.total;
pageData.tableConfiger.loading = false; pageData.tableConfiger.loading = false;