提交代码

This commit is contained in:
wangchengming 2025-07-20 13:15:42 +08:00
parent 4a452976ee
commit 679e5f4287
4 changed files with 98 additions and 61 deletions

View File

@ -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>&nbsp;</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>&nbsp;</p>'
}

View File

@ -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,

View File

@ -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 //
)
}

View File

@ -41,6 +41,7 @@ const dialogVisible = ref(false)
const suffix = ref('')
const setFileInfo = (filePath) => {
console.log('接收', filePath)
//
if (!filePath || filePath.indexOf('.') === -1) return '';