|
@@ -119,7 +119,8 @@
|
|
|
</el-form-item>
|
|
|
<el-col :span="1.5">
|
|
|
<!-- 使用分片上传组件,每个分片 -->
|
|
|
- <chunk-upload ref="chunkUploadRef" :max-file-size="50 * 1024 * 1024" :max-files="5" />
|
|
|
+<!-- <chunk-upload ref="chunkUploadRef" :max-file-size="50 * 1024 * 1024" :max-files="5" />-->
|
|
|
+ <FileUpload v-model="form.fileNames" />
|
|
|
</el-col>
|
|
|
</el-form>
|
|
|
<template #footer>
|
|
@@ -137,9 +138,10 @@ import { ref, reactive, onMounted } from 'vue';
|
|
|
import { ElMessage } from 'element-plus';
|
|
|
import { fetchReports, addReport, updateReport, deleteReport } from '@/api/kenowledge';
|
|
|
import {AddReportParams, QueryParams, ReportItem} from '@/api/kenowledge/types';
|
|
|
-import ChunkUpload from '@/components/ChunkUpload/index.vue';
|
|
|
+// import ChunkUpload from '@/components/ChunkUpload/index.vue';
|
|
|
import {getDicts} from "@/api/system/dict/data";
|
|
|
import router from "@/router";
|
|
|
+import axios,{ AxiosError,isAxiosError } from "axios";
|
|
|
|
|
|
const demoFormRef = ref(null);
|
|
|
const demoList = ref<ReportItem[]>([]);
|
|
@@ -155,6 +157,7 @@ let proxy = getCurrentInstance()?.proxy;
|
|
|
const { mm_event_type } = toRefs<any>(proxy?.useDict('mm_event_type'));
|
|
|
const chunkUploadRef = ref(null);
|
|
|
|
|
|
+
|
|
|
// 这是是查询条件
|
|
|
const queryParams = reactive<QueryParams>({
|
|
|
query: "",
|
|
@@ -195,13 +198,13 @@ const dialog = reactive({
|
|
|
});
|
|
|
|
|
|
|
|
|
-// 更新 getList 函数
|
|
|
+// getLists是获取列表数据的方法
|
|
|
const getList = async () => {
|
|
|
+ // 开始加载数据
|
|
|
loading.value = true;
|
|
|
try {
|
|
|
// 这里格式化日期范围参数
|
|
|
// 将-分割转换为/分割
|
|
|
-
|
|
|
const [startDate, endDate] = queryParams.publishDate;
|
|
|
const formattedStartDate = startDate ? startDate.replace(/-/g, '/') : '';
|
|
|
const formattedEndDate = endDate ? endDate.replace(/-/g, '/') : '';
|
|
@@ -214,9 +217,11 @@ const getList = async () => {
|
|
|
publishDate: undefined, // 移除原来的 publishDate 参数
|
|
|
};
|
|
|
|
|
|
+ // 发送请求
|
|
|
const response = await fetchReports(requestParams);
|
|
|
|
|
|
if (response && response.code === 200) {
|
|
|
+ // demoLIst是ref对象,需要通过.value赋值
|
|
|
demoList.value = response.data.map((item: ReportItem) => {
|
|
|
return {
|
|
|
...item,
|
|
@@ -238,7 +243,7 @@ const getList = async () => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
-
|
|
|
+// 查询
|
|
|
const handleQuery = () => {
|
|
|
queryParams.pageNum = 1;
|
|
|
getList();
|
|
@@ -253,6 +258,7 @@ const resetQuery = () => {
|
|
|
queryParams.subject = '';
|
|
|
queryParams.sortBy = 'publishDate'; // 重置排序字段
|
|
|
queryParams.sortOrder = 'desc'; // 重置排序方式
|
|
|
+ queryParams.query = '';
|
|
|
getList();
|
|
|
};
|
|
|
|
|
@@ -270,7 +276,7 @@ const handleAdd = () => {
|
|
|
dialog.visible = true;
|
|
|
dialog.title = '添加报告';
|
|
|
};
|
|
|
-
|
|
|
+ // 修改报告
|
|
|
const handleUpdate = (row: ReportItem) => {
|
|
|
if (row) {
|
|
|
resetForm();
|
|
@@ -317,9 +323,6 @@ const submitForm = () => {
|
|
|
if (valid) {
|
|
|
buttonLoading.value = true;
|
|
|
try {
|
|
|
- // 使用新定义的 getUploadedFileNames 方法
|
|
|
- form.fileNames = chunkUploadRef.value?.getUploadedFileNames() || [];
|
|
|
-
|
|
|
// 格式化日期为后端所需的格式
|
|
|
form.publishDate = formatDate(new Date(form.publishDate));
|
|
|
|
|
@@ -340,14 +343,14 @@ const submitForm = () => {
|
|
|
dialog.visible = false;
|
|
|
getList(); // 刷新列表
|
|
|
} catch (error) {
|
|
|
- if (error.response) {
|
|
|
- console.error('后端响应错误:', error.response.data);
|
|
|
- ElMessage.error(`操作失败: ${error.response.data.message || '未知错误'}`);
|
|
|
+ if (isAxiosError(error)) {
|
|
|
+ console.error('后端响应错误:', error.response?.data);
|
|
|
+ ElMessage.error(`操作失败: ${error.response?.data.message || '未知错误'}`);
|
|
|
} else {
|
|
|
console.error('提交失败:', error);
|
|
|
ElMessage.error('操作失败,无法连接到服务器');
|
|
|
}
|
|
|
- } finally {
|
|
|
+ }finally {
|
|
|
buttonLoading.value = false;
|
|
|
}
|
|
|
}
|