Browse Source

完善界面优化

愿你天天开心 9 months ago
parent
commit
7f315fa1ab

+ 4 - 2
src/api/kenowledge/index.ts

@@ -39,6 +39,8 @@ export const fetchReportDetail = (reportId: string): AxiosPromise<ReportItem> =>
   });
 };
 
+
+// 待定
 // 修改报告
 export const updateReport = (data: {
   summary: UnwrapRef<AddReportParams["summary"]>;
@@ -58,9 +60,9 @@ export const updateReport = (data: {
 };
 
 // 删除报告
-export const deleteReport = (reportNumber: string): AxiosPromise<void> => {
+export const deleteReport = (reportId: string): AxiosPromise<void> => {
   return request({
-    url: `/api/reports/delete/${reportNumber}`,
+    url: `/api/reports/delete/${reportId}`,
     method: 'delete',
   });
 };

+ 0 - 8
src/types/components.d.ts

@@ -25,13 +25,9 @@ declare module 'vue' {
     ElButton: typeof import('element-plus/es')['ElButton']
     ElCard: typeof import('element-plus/es')['ElCard']
     ElCheckbox: typeof import('element-plus/es')['ElCheckbox']
-    ElCheckboxGroup: typeof import('element-plus/es')['ElCheckboxGroup']
     ElCol: typeof import('element-plus/es')['ElCol']
-    ElCollapse: typeof import('element-plus/es')['ElCollapse']
-    ElCollapseItem: typeof import('element-plus/es')['ElCollapseItem']
     ElColorPicker: typeof import('element-plus/es')['ElColorPicker']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
-    ElContainer: typeof import('element-plus/es')['ElContainer']
     ElDatePicker: typeof import('element-plus/es')['ElDatePicker']
     ElDescriptions: typeof import('element-plus/es')['ElDescriptions']
     ElDescriptionsItem: typeof import('element-plus/es')['ElDescriptionsItem']
@@ -44,13 +40,11 @@ declare module 'vue' {
     ElEmpty: typeof import('element-plus/es')['ElEmpty']
     ElForm: typeof import('element-plus/es')['ElForm']
     ElFormItem: typeof import('element-plus/es')['ElFormItem']
-    ElHeader: typeof import('element-plus/es')['ElHeader']
     ElIcon: typeof import('element-plus/es')['ElIcon']
     ElImage: typeof import('element-plus/es')['ElImage']
     ElInput: typeof import('element-plus/es')['ElInput']
     ElInputNumber: typeof import('element-plus/es')['ElInputNumber']
     ElLink: typeof import('element-plus/es')['ElLink']
-    ElMain: typeof import('element-plus/es')['ElMain']
     ElMenu: typeof import('element-plus/es')['ElMenu']
     ElMenuItem: typeof import('element-plus/es')['ElMenuItem']
     ElOption: typeof import('element-plus/es')['ElOption']
@@ -58,12 +52,10 @@ declare module 'vue' {
     ElPopover: typeof import('element-plus/es')['ElPopover']
     ElProgress: typeof import('element-plus/es')['ElProgress']
     ElRadio: typeof import('element-plus/es')['ElRadio']
-    ElRadioButton: typeof import('element-plus/es')['ElRadioButton']
     ElRadioGroup: typeof import('element-plus/es')['ElRadioGroup']
     ElRow: typeof import('element-plus/es')['ElRow']
     ElScrollbar: typeof import('element-plus/es')['ElScrollbar']
     ElSelect: typeof import('element-plus/es')['ElSelect']
-    ElSpace: typeof import('element-plus/es')['ElSpace']
     ElStep: typeof import('element-plus/es')['ElStep']
     ElSteps: typeof import('element-plus/es')['ElSteps']
     ElSubMenu: typeof import('element-plus/es')['ElSubMenu']

+ 25 - 8
src/views/knowledge/knowledge-management/detail.vue

@@ -51,7 +51,7 @@
     <div class="attachments">
       <strong>报告附件:</strong>
     </div>
-    <el-link :href="report.attachmentUrl" target="_blank" class="value">{{ report.attachmentName }}</el-link>
+    <el-link :href="report.attachmentUrl" target="_blank" class="value url-color">{{ report.attachmentName }}</el-link>
   </div>
 </template>
 
@@ -86,17 +86,28 @@ const goBack = () => {
   router.go(-1);
 };
 
+// 编辑报告
 const handleEdit = () => {
-  ElMessageBox.prompt('编辑报告', '提示', {
+  ElMessageBox.prompt('编辑报告标题', '提示', {
     confirmButtonText: '确定',
     cancelButtonText: '取消',
     inputValue: report.value.title
-  }).then(({ value }) => {
-    report.value.title = value;
-    ElMessage({
-      type: 'success',
-      message: '报告已更新'
-    });
+  }).then(async ({ value }) => {
+    try {
+      const updatedReport = { ...report.value, title: value };
+      // 调用API更新报告标题
+      await updateReportDetail(updatedReport);
+      report.value.title = value;
+      ElMessage({
+        type: 'success',
+        message: '报告已成功更新'
+      });
+    } catch (error) {
+      ElMessage({
+        type: 'error',
+        message: '更新报告失败,请重试'
+      });
+    }
   }).catch(() => {
     ElMessage({
       type: 'info',
@@ -105,6 +116,7 @@ const handleEdit = () => {
   });
 };
 
+// 删除报告
 const handleDelete = () => {
   ElMessageBox.confirm('此操作将永久删除该报告, 是否继续?', '提示', {
     confirmButtonText: '确定',
@@ -134,6 +146,7 @@ onMounted(async () => {
       value: item.dictValue,
     }));
 
+    // 获取报告详情
     const reportId = route.query.reportID;
     const response = await fetchReportDetail(reportId);
     const data = response.data[0];
@@ -147,6 +160,7 @@ onMounted(async () => {
       second: '2-digit',
     }).replace(/\//g, '-');
 
+    // 更新报告详情
     report.value = {
       reportId: data.report_id,
       title: data.reportName,
@@ -188,6 +202,9 @@ onMounted(async () => {
   font-weight: normal; /* 去除后端数据的加粗 */
   color: #333; /* 可选:更改字体颜色 */
 }
+.url-color {
+  color: #409EFF;
+}
 
 .el-divider {
   margin-top: 1px;

+ 16 - 13
src/views/knowledge/knowledge-management/index.vue

@@ -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;
       }
     }