提交代码
This commit is contained in:
parent
4a452976ee
commit
679e5f4287
|
@ -96,7 +96,7 @@ const props = defineProps({
|
|||
});
|
||||
const loading = ref(false);
|
||||
const tinymceId = ref(
|
||||
"vue-tinymce-" + +new Date() + ((Math.random() * 1000).toFixed(0) + "")
|
||||
"vue-tinymce-" + +new Date() + ((Math.random() * 1000).toFixed(0) + "")
|
||||
);
|
||||
|
||||
const baseUrl = import.meta.env.VITE_APP_BASE_API
|
||||
|
@ -217,8 +217,10 @@ const init = reactive({
|
|||
// 设置初始化内容(初始化结束后执行)
|
||||
init_instance_callback: function (editor) {
|
||||
console.log('初始化内容', props.value)
|
||||
editor.setContent(props.value); // 设置默认文本内容
|
||||
emits('update:modelValue', editor.getContent()) //更新
|
||||
if (props.value) {
|
||||
editor.setContent(props.value); // 设置默认文本内容
|
||||
emits('update:modelValue', editor.getContent()) //更新
|
||||
}
|
||||
// 设置高度
|
||||
editor.getContainer().setAttribute("style", `height: ${props.height}px;`);
|
||||
},
|
||||
|
@ -234,19 +236,19 @@ const myValue = computed({
|
|||
},
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// 监听富文本中的数据变化
|
||||
watch(
|
||||
() => myValue.value,
|
||||
() => {
|
||||
emits(
|
||||
"setHtml",
|
||||
tinymce.activeEditor.getContent({ format: "text" }),
|
||||
myValue.value
|
||||
);
|
||||
}
|
||||
);
|
||||
// watch(
|
||||
// () => myValue.value,
|
||||
// () => {
|
||||
// emits(
|
||||
// "setHtml",
|
||||
// tinymce.activeEditor.getContent({ format: "text" }),
|
||||
// myValue.value
|
||||
// );
|
||||
// }
|
||||
// );
|
||||
|
||||
// 设置编辑器只读模式
|
||||
watch(
|
||||
|
@ -277,13 +279,13 @@ window.onresize = function temp() {
|
|||
};
|
||||
|
||||
// 设置值
|
||||
const handleSetContent = (content) => {
|
||||
const handleSetContent = (content) => {
|
||||
tinymce.activeEditor.setContent(content);
|
||||
};
|
||||
|
||||
// 获取值
|
||||
const handleGetContent = () => {
|
||||
return tinymce.activeEditor.getContent();
|
||||
return tinymce.activeEditor.getContent();
|
||||
};
|
||||
|
||||
const updateModelValue = (val) => {
|
||||
|
@ -305,14 +307,14 @@ const updateModelValue = (val) => {
|
|||
})
|
||||
}
|
||||
const checkEmptyContent = (editor) => {
|
||||
const plainText = editor.getContent({ format: 'text' }).trim()
|
||||
const htmlContent = editor.getContent()
|
||||
|
||||
// 检测常见空内容情况
|
||||
return plainText === '' ||
|
||||
htmlContent === '' ||
|
||||
htmlContent === '<p><br data-mce-bogus="1"></p>' ||
|
||||
htmlContent === '<p> </p>'
|
||||
const plainText = editor.getContent({ format: 'text' }).trim()
|
||||
const htmlContent = editor.getContent()
|
||||
|
||||
// 检测常见空内容情况
|
||||
return plainText === '' ||
|
||||
htmlContent === '' ||
|
||||
htmlContent === '<p><br data-mce-bogus="1"></p>' ||
|
||||
htmlContent === '<p> </p>'
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -12,7 +12,7 @@
|
|||
<div class="organization-list" v-loading="loading">
|
||||
<div class="organization-item" v-for="item in tableData">
|
||||
<div class="fileContainer">
|
||||
<img :src="item.organPic" />
|
||||
<img :src="baseUrl + item.organPic" />
|
||||
<div class="optionBtns">
|
||||
<el-button type="primary" class="editIconBtn" v-hasPermi="['databaseLibary:edit']"
|
||||
@click="handleEdit(item.id)">
|
||||
|
@ -46,6 +46,7 @@ import deleteIcon from '@/assets/images/deleteIcon.png'
|
|||
import { getBusEncyclopediaDatabasePage } from "@/api/databaseLibary"
|
||||
|
||||
const router = useRouter()
|
||||
const baseUrl = import.meta.env.VITE_APP_BASE_API
|
||||
const queryParams = ref({
|
||||
pageIndex: 1,
|
||||
pageSize: 10,
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
:label="item.label" :value="item.value" @change="handleChangeTwoType(item.value)" />
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<el-form-item label="组织架构图" prop="organPic" v-if="ruleForm.category == '组织架构'">
|
||||
<el-form-item label="组织架构图" prop="organPic" v-show="ruleForm.category == '组织架构'">
|
||||
<myFileUpload ref="organPicRef" @set-form-file="handleSetorganPic" />
|
||||
</el-form-item>
|
||||
<el-form-item label="正文内容" prop="mainText">
|
||||
|
@ -152,6 +152,7 @@ const levelList = ref([
|
|||
{ title: '新建', path: '/databaseLibaryForm' },
|
||||
])
|
||||
const baseUrl = import.meta.env.VITE_APP_BASE_API
|
||||
const organPicRef = ref(null)
|
||||
const formTitle = ref('新建')
|
||||
// 显示相关链接数据
|
||||
const showTableData = ref([])
|
||||
|
@ -178,25 +179,28 @@ const { ruleForm, rules } = toRefs(data)
|
|||
|
||||
// 初始化
|
||||
onMounted(() => {
|
||||
getLast10Years();
|
||||
getBusDependencyData();
|
||||
const id = route.params && route.params.Id
|
||||
if (id) {
|
||||
ruleForm.value.id = id
|
||||
formTitle.value = '编辑'
|
||||
getDetailInfo(id)
|
||||
levelList.value = [
|
||||
{ title: '百科数据库', path: '/databaseLibary' },
|
||||
{ title: '编辑', path: '/databaseLibaryForm' },
|
||||
]
|
||||
} else {
|
||||
ruleForm.value.id = null
|
||||
formTitle.value = '新建'
|
||||
levelList.value = [
|
||||
{ title: '百科数据库', path: '/databaseLibary' },
|
||||
{ title: '新建', path: '/databaseLibaryForm' },
|
||||
]
|
||||
}
|
||||
nextTick(() => {
|
||||
getLast10Years();
|
||||
getBusDependencyData();
|
||||
const id = route.params && route.params.Id
|
||||
if (id) {
|
||||
ruleForm.value.id = id
|
||||
formTitle.value = '编辑'
|
||||
getDetailInfo(id)
|
||||
levelList.value = [
|
||||
{ title: '百科数据库', path: '/databaseLibary' },
|
||||
{ title: '编辑', path: '/databaseLibaryForm' },
|
||||
]
|
||||
} else {
|
||||
ruleForm.value.id = null
|
||||
formTitle.value = '新建'
|
||||
levelList.value = [
|
||||
{ title: '百科数据库', path: '/databaseLibary' },
|
||||
{ title: '新建', path: '/databaseLibaryForm' },
|
||||
]
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
// 年度数据
|
||||
|
@ -230,16 +234,38 @@ const getDetailInfo = (id) => {
|
|||
getBusEncyclopediaDatabase(id).then(res => {
|
||||
if (res.code == 200) {
|
||||
ruleForm.value = res.data
|
||||
categorySelectedValue.value = [res.data.category]
|
||||
categoryTwoSelectedValue.value = [res.data.categoryTwo]
|
||||
editorRef.value.handleSetContent(res.data.mainText)
|
||||
docUploadList.value = JSON.parse(res.data.fileContent)
|
||||
|
||||
res.data.encyclopediaDatabaseLinkList.forEach(item => {
|
||||
item.editFlag = false
|
||||
showTableData.value.push(item)
|
||||
cachShowTableData.value.push(item)
|
||||
// 确保分类数据是数组
|
||||
categorySelectedValue.value = res.data.category ? [res.data.category] : []
|
||||
categoryTwoSelectedValue.value = res.data.categoryTwo ? [res.data.categoryTwo] : []
|
||||
|
||||
// 处理链接数据
|
||||
if (Array.isArray(res.data.encyclopediaDatabaseLinkList)) {
|
||||
res.data.encyclopediaDatabaseLinkList.forEach(item => {
|
||||
item.editFlag = false
|
||||
showTableData.value.push({ ...item }) // 深拷贝避免污染
|
||||
cachShowTableData.value.push({ ...item })
|
||||
})
|
||||
}
|
||||
// 安全解析 + 默认值处理
|
||||
const parsedFiles = res.data.fileContent
|
||||
? JSON.parse(res.data.fileContent)
|
||||
: []
|
||||
|
||||
// 确保是数组且包含必要字段
|
||||
docUploadList.value = Array.isArray(parsedFiles)
|
||||
? parsedFiles.map(file => ({
|
||||
name: file.name || String(file.name),
|
||||
url: file.url || '',
|
||||
status: 'success',
|
||||
uid: file.uid || Date.now()
|
||||
}))
|
||||
: []
|
||||
|
||||
|
||||
nextTick(() => {
|
||||
if (res.data.organPic) organPicRef.value.setFileInfo(res.data.organPic)
|
||||
});
|
||||
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -256,6 +282,9 @@ const handleChangeTwoType = (value) => {
|
|||
console.log('二级类目选择值', value)
|
||||
categoryTwoSelectedValue.value = [value] // 始终保持数组只有一个元素
|
||||
ruleForm.value.categoryTwo = value
|
||||
nextTick(() => {
|
||||
if (res.data.organPic) organPicRef.value.setFileInfo(ruleForm.value.organPic)
|
||||
});
|
||||
}
|
||||
// 设置组织架构图
|
||||
const handleSetorganPic = (filePath) => {
|
||||
|
@ -308,11 +337,15 @@ const requestDocUpload = (options) => {
|
|||
formData.append('file', file);
|
||||
uploadFile(formData).then(res => {
|
||||
if (res.code == 200) {
|
||||
docUploadList.value.push({
|
||||
name: res.originalFilename,
|
||||
url: baseUrl + res.fileName,
|
||||
suffix: res.suffix
|
||||
})
|
||||
docUploadList.value = [
|
||||
...docUploadList.value,
|
||||
{
|
||||
name: res.originalFilename,
|
||||
url: baseUrl + res.fileName,
|
||||
status: 'success', // 必须字段
|
||||
uid: Date.now() + Math.random()
|
||||
}
|
||||
]
|
||||
} else {
|
||||
proxy.$modal.msgError(res.msg);
|
||||
}
|
||||
|
@ -321,8 +354,8 @@ const requestDocUpload = (options) => {
|
|||
// 移除已上传文件列表
|
||||
const removeDocUpload = (file, fileList) => {
|
||||
docUploadList.value = docUploadList.value.filter(
|
||||
item => item.name != file.name
|
||||
);
|
||||
item => item.uid !== file.uid // 通过唯一标识符比对
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -41,6 +41,7 @@ const dialogVisible = ref(false)
|
|||
const suffix = ref('')
|
||||
|
||||
const setFileInfo = (filePath) => {
|
||||
console.log('接收', filePath)
|
||||
// 处理无后缀名情况
|
||||
if (!filePath || filePath.indexOf('.') === -1) return '';
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user