更新
This commit is contained in:
@ -9,24 +9,26 @@
|
||||
</div>
|
||||
<div class="form_cnt">
|
||||
<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>
|
||||
</FormMessage>
|
||||
<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" />
|
||||
<!-- 编辑器 -->
|
||||
<Editor :style="`height: 480px; overflow-y: hidden`" :model-value="textContent" :defaultConfig="editorConfig"
|
||||
:mode="mode" @onCreated="handleCreated" @onChange="handChange" />
|
||||
<Editor
|
||||
:style="`height: 480px; overflow-y: hidden`"
|
||||
v-model="textContent"
|
||||
:defaultConfig="editorConfig"
|
||||
:mode="mode"
|
||||
@onCreated="handleCreated"
|
||||
@onChange="handChange"
|
||||
/>
|
||||
</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="downloadWithStyles(textContent)">下载</el-button>
|
||||
</div>
|
||||
@ -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(/<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() {
|
||||
let html = dataBt.value;
|
||||
html += `<p style="text-align: center;"><span style="font-size: 22px;">${listQuery.value.bgnr || ''}</span></p>`
|
||||
html += `<p>${listQuery.value.fj || ''}</p>`
|
||||
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 = {}
|
||||
|
||||
@ -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;
|
||||
|
||||
Reference in New Issue
Block a user