wuheng 1 year ago
parent
commit
87058a9cc2

+ 4 - 0
src/views/archives/students/component/api.ts

@@ -122,3 +122,7 @@ export function deleteArchives(id: number): Promise<Service.RequestResult<Archiv
 export function downloadArchives(studentNumber: string): Promise<Service.RequestResult<ArchivesRes>> {
   return request.post(`/student/downloadArchives?studentNumber=${studentNumber}`);
 }
+
+export function refreshArchive(studentNumber: string): Promise<Service.RequestResult<ArchivesRes>> {
+  return request.get(`/archive/refreshArchive?studentNumber=${studentNumber}`);
+}

+ 31 - 5
src/views/archives/students/component/crud.ts

@@ -4,9 +4,10 @@ import dayjs from 'dayjs';
 import { dict } from '@fast-crud/fast-crud';
 import axios from 'axios';
 import { usePermission } from '@/composables';
+import { localStg } from '@/utils';
 import { getServiceEnvConfig } from '~/.env-config';
 import type { AddArchivesParams } from './api';
-import { getArchives, getFile, addArchives, deleteArchives, downloadArchives } from './api';
+import { getArchives, getFile, addArchives, deleteArchives, downloadArchives, refreshArchive } from './api';
 const { url, proxyPattern } = getServiceEnvConfig(import.meta.env);
 const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y';
 const { hasPermission } = usePermission();
@@ -116,6 +117,31 @@ export default function createCrudOptions(crudOptionsProps: CreateCrudOptionsPro
                 window.location.href = fileUrl;
               }
             }
+          },
+          refreshArchive: {
+            text: '刷新档案',
+            title: '刷新当前学员档案',
+            circle: false,
+            tooltip: {
+              slots: {
+                default() {
+                  return '刷新当前学员档案';
+                }
+              }
+            },
+            click: async () => {
+              if (!crudOptionsProps.context) {
+                return;
+              }
+              if (!crudOptionsProps.context.studentNumber) {
+                crudOptionsProps.context.message.info('没有筛选人员的情况下 , 不允许刷新档案!');
+                return;
+              }
+              const { status } = await refreshArchive(crudOptionsProps.context.studentNumber);
+              if (status) {
+                window.$message?.success('操作成功!');
+              }
+            }
           }
         }
       },
@@ -196,17 +222,17 @@ export default function createCrudOptions(crudOptionsProps: CreateCrudOptionsPro
                     crudOptionsProps.context.message.info('请先选择类别, 在上传档案!');
                     throw new Error('请先选择类别, 在上传档案!');
                   }
-                  const action = isHttpProxy
-                    ? `${proxyPattern}/student/upload?fileType`
-                    : `${url}/student/upload?fileType`;
+                  const action = isHttpProxy ? `${proxyPattern}/student/upload` : `${url}/student/upload`;
                   const { file, onProgress } = props;
+                  const token = localStg.get('token');
                   const data = new FormData();
                   data.append('file', file);
                   data.append('fileType', crudOptionsProps.context.archivesForm.filetype);
                   data.append('studentNumber', crudOptionsProps.context.archivesForm.studentNumber);
                   const res = await axios.post(action, data, {
                     headers: {
-                      'Content-Type': 'multipart/form-data'
+                      'Content-Type': 'multipart/form-data',
+                      Authorization: token
                     },
                     timeout: 60000,
                     onUploadProgress(progress) {

+ 5 - 3
src/views/archives/students/component/index.vue

@@ -34,6 +34,7 @@
 import { watch, ref } from 'vue';
 import { useMessage } from 'naive-ui';
 import { useFs } from '@fast-crud/fast-crud';
+import { getServiceEnvConfig } from '~/.env-config';
 import createCrudOptions from './crud';
 import ExcelView from './excelView.vue';
 import WordView from './wordView.vue';
@@ -44,20 +45,21 @@ const fileURL = ref<string>('');
 const fileType = ref<string>('');
 const active = ref<boolean>(false);
 const message = useMessage();
-
+const { url, proxyPattern } = getServiceEnvConfig(import.meta.env);
+const isHttpProxy = import.meta.env.VITE_HTTP_PROXY === 'Y';
 const props = defineProps({
   studentNumber: {
     type: String,
     default: 'default'
   }
 });
-
+const action = isHttpProxy ? `${proxyPattern}/archive/getFileByToken` : `${url}/archive/getFileByToken`;
 const context = {
   message,
   archivesForm: {},
   studentNumber: props.studentNumber,
   viewActiveFunc: (type: string, token: string) => {
-    fileURL.value = `http://localhost:3200/proxy-pattern/archive/getFileByToken?archiveToken=${token}`;
+    fileURL.value = `${action}?archiveToken=${token}`;
     fileType.value = type;
     active.value = true;
   }