刘洋 6 месяцев назад
Родитель
Сommit
4e499e4a8d
4 измененных файлов с 131 добавлено и 13 удалено
  1. 10 1
      src/apis/user.ts
  2. 94 9
      src/pages/subjects-manage/index.vue
  3. 25 1
      src/pages/user-manage/index.vue
  4. 2 2
      vite.config.ts

+ 10 - 1
src/apis/user.ts

@@ -4,7 +4,9 @@ import { getUserInfo, cacheUserInfo } from "@/utils/auth";
 /**
  * @description 获取当前用户信息
  */
-export const getUserInfoHttp = (force:boolean = false): Promise<SystemUserInfo> => {
+export const getUserInfoHttp = (
+  force: boolean = false
+): Promise<SystemUserInfo> => {
   const cachedUserInfo = getUserInfo();
 
   return cachedUserInfo && !force
@@ -72,3 +74,10 @@ export const downloadImportUserHttp = () => {
     download: true,
   });
 };
+
+export const exportUserData = (data: any) => {
+  return request.post<Blob>("/api/user/export", data, {
+    responseType: "blob",
+    download: true,
+  });
+};

+ 94 - 9
src/pages/subjects-manage/index.vue

@@ -114,7 +114,7 @@
         <a-button
           type="primary"
           class="tw-flex tw-items-center operation-button"
-          @click="downloadPaperStruct"
+          @click="showExportModal = true"
         >
           <!--          <template #icon>-->
           <!--            <UploadOutlined />-->
@@ -238,6 +238,50 @@
         </a-form-item>
       </a-form>
     </a-modal>
+
+    <a-modal
+      v-model:visible="showExportModal"
+      :maskClosable="false"
+      :title="`导出`"
+      okText="确认导出"
+      cancelText="取消"
+      @ok="downloadPaperStruct"
+    >
+      <a-form
+        :labelCol="{ span: 6 }"
+        :model="exportParams"
+        :rules="exportRules"
+        ref="exportRef"
+      >
+        <a-form-item label="学校名称" name="schoolId">
+          <a-select
+            v-model:value="exportParams.schoolId"
+            show-search
+            placeholder="学校名称"
+            :options="uploadQuery.schoolTableData.result"
+            :fieldNames="{ label: 'name', value: 'id' }"
+            optionFilterProp="name"
+          >
+          </a-select>
+        </a-form-item>
+        <a-form-item label="考试批次" name="examId">
+          <a-select
+            v-model:value="exportParams.examId"
+            :filterOption="false"
+            show-search
+            @search="(name:string) => queryExamList(name, 'export')"
+            placeholder="考试批次"
+          >
+            <a-select-option
+              v-for="exam in uploadQuery.examTableData.result"
+              :key="exam.id"
+              :value="`${exam.id}`"
+              >{{ exam.name }}</a-select-option
+            >
+          </a-select>
+        </a-form-item>
+      </a-form>
+    </a-modal>
   </div>
 </template>
 
@@ -275,6 +319,11 @@ const showImportModal = ref(false);
 
 const tableLoading = ref(false);
 
+const exportParams = reactive<any>({
+  schoolId: "",
+  examId: "",
+});
+
 const ImportDownloadApi: Record<
   ImportType,
   {
@@ -316,6 +365,10 @@ const uploadRules = {
     { required: true, type: "array", len: 1, message: "请选择导入文件" },
   ],
 };
+const exportRules = {
+  schoolId: [{ required: true, message: "请选择学校" }],
+  examId: [{ required: true, message: "请选择考试批次" }],
+};
 
 const { validate, validateInfos, resetFields } = Form.useForm(
   uploadQuery,
@@ -344,6 +397,16 @@ const query = reactive<
   pageNumber: 1,
 });
 
+const showExportModal = ref(false);
+watch(showExportModal, (val: any) => {
+  if (val) {
+    exportParams.schoolId = query.schoolId;
+    exportParams.examId = query.examId;
+    querySchoolList("", "form");
+  } else {
+  }
+});
+
 /** table配置 */
 const columns: TableColumnType[] = [
   { title: "序号", dataIndex: "index", align: "center", width: 60 },
@@ -407,10 +470,14 @@ const querySchoolList = throttle(
 
 /** 查询考试列表 */
 const queryExamList = throttle(
-  async (name: string = "", type: "list" | "form" = "list") => {
+  async (name: string = "", type: "list" | "form" | "export" = "list") => {
     try {
       const isList = type === "list";
-      const schoolId = isList ? query.schoolId : uploadQuery.schoolId;
+      const schoolId = isList
+        ? query.schoolId
+        : type === "form"
+        ? uploadQuery.schoolId
+        : exportParams.schoolId;
       if (!schoolId) {
         return Promise.reject(`schoolId got : ${schoolId}`);
       }
@@ -482,6 +549,17 @@ watch(
   }
 );
 
+watch(
+  () => exportParams.schoolId,
+  () => {
+    exportParams.examId = void 0;
+    Object.assign(uploadQuery.examTableData, { result: [], totalCount: 0 });
+    if (exportParams.schoolId) {
+      queryExamList("", "export");
+    }
+  }
+);
+
 const currentPageChange = ({
   current,
   pageSize,
@@ -494,15 +572,22 @@ const currentPageChange = ({
   query.pageSize = pageSize;
 };
 
+const exportRef = ref();
 /** 导出主观题 */
 const downloadPaperStruct = async () => {
   try {
-    await downloadPaperStructHttp({
-      ...query,
-      groupFinish: [void 0, true, false][query.groupFinish],
-    });
-  } catch (error) {
-    return Promise.reject(error);
+    await exportRef.value.validateFields();
+    try {
+      await downloadPaperStructHttp({
+        ...query,
+        groupFinish: [void 0, true, false][query.groupFinish],
+        ...exportParams,
+      });
+    } catch (error) {
+      return Promise.reject(error);
+    }
+  } catch (errorInfo) {
+    console.log("Failed:", errorInfo);
   }
 };
 

+ 25 - 1
src/pages/user-manage/index.vue

@@ -66,10 +66,20 @@
         @click="importUserList"
       >
         <template #icon>
-          <DownloadOutlined />
+          <ImportOutlined />
         </template>
         导入
       </a-button>
+      <a-button
+        type="primary"
+        class="tw-flex tw-items-center operation-button"
+        @click="exportFile"
+      >
+        <template #icon>
+          <DownloadOutlined />
+        </template>
+        导出
+      </a-button>
     </Block>
     <Block class="user-table">
       <a-table
@@ -280,6 +290,7 @@ import {
   CheckCircleFilled,
   CloseCircleFilled,
   DownloadOutlined,
+  ImportOutlined,
 } from "@ant-design/icons-vue";
 import {
   getUserListHttp,
@@ -288,6 +299,7 @@ import {
   resetUserPwdHttp,
   importUserHttp,
   downloadImportUserHttp,
+  exportUserData,
 } from "@/apis/user";
 import Block from "@/components/block/index.vue";
 import { message } from "ant-design-vue";
@@ -581,6 +593,18 @@ const importUserList = () => {
   querySchoolList("", "import");
 };
 
+const exportFile = async () => {
+  try {
+    await exportUserData({
+      loginName: query.loginName,
+      schoolId: query.schoolId,
+      role: query.role,
+    });
+  } catch (error) {
+    return Promise.reject(error);
+  }
+};
+
 const handleRemove: UploadProps["onRemove"] = (file) => {
   const index = importUserForm.fileList!.indexOf(file);
   const newFileList = importUserForm.fileList!.slice();

+ 2 - 2
vite.config.ts

@@ -55,9 +55,9 @@ export default defineConfig({
   server: {
     proxy: {
       "^/api": {
-        // target: "http://192.168.10.39:7100",
+        target: "http://192.168.10.39:7102",
         // target: "http://192.168.11.28:7101",
-        target: "http://test.markingtool.cn",
+        // target: "http://test.markingtool.cn",
       },
     },
   },