Browse Source

接口修改

zhangjie 4 years ago
parent
commit
ea8b4898ee

+ 5 - 1
card/mixins/exchange.js

@@ -322,12 +322,16 @@ export default {
       return infos.map(num => num.toFixed(10) * 1);
     },
     getPageModel({ cardConfig, paperParams, pages }) {
+      let npages = this.parsePageExchange(pages);
+      npages.forEach(page => {
+        page.exchange.page_size = cardConfig.pageSize;
+      });
       return JSON.stringify(
         {
           version: CARD_VERSION,
           cardConfig,
           paperParams,
-          pages: this.parsePageExchange(pages)
+          pages: npages
         },
         (k, v) => (k.startsWith("_") ? undefined : v)
       );

+ 1 - 0
src/modules/admin/components/ModifyUser.vue

@@ -159,6 +159,7 @@ export default {
       if (!data) return;
 
       this.$message.success("修改成功!");
+      this.$emit("modified");
       this.cancel();
     }
   }

+ 1 - 7
src/modules/admin/views/AdminUserManage.vue

@@ -139,13 +139,7 @@ export default {
       ABLE_TYPE,
       roles: [],
       users: [],
-      curUser: {},
-      downloadUrl: "/temps/用户导入模板.xlsx",
-      // import
-      uploadUrl: "/api/admin/sys/user/import",
-      uploadData: {
-        type: "FILE"
-      }
+      curUser: {}
     };
   },
   created() {

+ 35 - 2
src/modules/base/components/ModifyUser.vue

@@ -79,11 +79,12 @@
             </el-option>
           </el-select>
         </el-form-item>
-        <el-form-item label="所属学院:">
+        <el-form-item prop="orgId" label="所属学院:">
           <select-orgs
             ref="SelectOrgs"
             v-model="modalForm.orgId"
             :multiple="false"
+            @change="orgChange"
           ></select-orgs>
         </el-form-item>
       </el-form>
@@ -102,6 +103,7 @@ import { updateUser, courseQuery } from "../api";
 import { logout } from "../../login/api";
 import { phone } from "@/plugins/formRules";
 import SelectOrgs from "./SelectOrgs";
+import { SYS_ADMIN_NAME } from "@/constants/enumerate";
 
 const initModalForm = {
   id: "",
@@ -156,6 +158,19 @@ export default {
         callback();
       }
     };
+    const orgIdValidator = (rule, value, callback) => {
+      if (this.IS_SUPER_ADMIN) return callback();
+
+      if (!value || !value.length) {
+        callback(new Error("请选择所属学院"));
+      } else {
+        callback();
+      }
+    };
+
+    const IS_SUPER_ADMIN =
+      this.$ls.get("user", { loginName: "" }).loginName === SYS_ADMIN_NAME;
+
     return {
       modalIsShow: false,
       isSubmit: false,
@@ -189,11 +204,19 @@ export default {
             validator: courseIdsValidator,
             trigger: "change"
           }
+        ],
+        orgId: [
+          {
+            required: !IS_SUPER_ADMIN,
+            validator: orgIdValidator,
+            trigger: "change"
+          }
         ]
       },
       user: {},
       courses: [],
-      roleTypes: []
+      roleTypes: [],
+      IS_SUPER_ADMIN
     };
   },
   created() {
@@ -229,6 +252,11 @@ export default {
         .filter(role => roleIds.includes(role.id))
         .map(role => role.type);
     },
+    orgChange() {
+      this.$nextTick(() => {
+        this.$refs.modalFormComp.validateField("orgId");
+      });
+    },
     async submit() {
       const valid = await this.$refs.modalFormComp.validate().catch(() => {});
       if (!valid) return;
@@ -246,6 +274,11 @@ export default {
       this.$message.success("修改成功!");
       this.cancel();
 
+      if (!this.isEdit) {
+        this.$emit("modified");
+        return;
+      }
+
       // 自己把自己的角色改了之后要重新登录,重新获取权限
       const oldRoleIds = this.instance.roles
         .map(item => item.id)

+ 7 - 0
src/modules/base/components/SelectOrgs.vue

@@ -100,6 +100,13 @@ export default {
     checkClick(data) {
       if (this.multiple) return;
 
+      const checkedIds = this.$refs.MenuTree.getCheckedKeys();
+      console.log(checkedIds);
+      console.log(data.id);
+      if (!checkedIds.includes(data.id)) {
+        this.emitChange([]);
+        return;
+      }
       const selectedOrgs = [data.id];
       this.$refs.MenuTree.setCheckedKeys([data.id]);
       this.emitChange(selectedOrgs);

+ 3 - 32
src/modules/base/views/UserManage.vue

@@ -49,22 +49,6 @@
         </el-form-item>
       </el-form>
       <div class="part-box-action">
-        <upload-button
-          btn-icon="icon icon-share"
-          btn-type="warning"
-          btn-content="导入"
-          :upload-url="uploadUrl"
-          :upload-data="uploadData"
-          :format="['xls', 'xlsx']"
-          @upload-error="uplaodError"
-          @upload-success="uploadSuccess"
-        >
-        </upload-button>
-        <el-button icon="icon icon-download-act">
-          <a :href="downloadUrl" download="用户导入模板.xlsx"
-            >用户导入模板下载</a
-          >
-        </el-button>
         <el-button type="primary" @click="toAdd">新增用户</el-button>
       </div>
     </div>
@@ -94,6 +78,7 @@
           label="手机号"
           width="120"
         ></el-table-column>
+        <el-table-column prop="orgName" label="所在机构"></el-table-column>
         <el-table-column prop="courses" label="课程名称(编码)">
           <template slot-scope="scope">
             {{ scope.row.courses | coursesFilter }}
@@ -163,7 +148,6 @@
 </template>
 
 <script>
-import UploadButton from "@/components/UploadButton";
 import ModifyUser from "../components/ModifyUser";
 import { ABLE_TYPE } from "@/constants/enumerate";
 import { userListPage, ableUser, resetPwd, userRoleListPage } from "../api";
@@ -171,7 +155,7 @@ import { logout } from "@/modules/login/api";
 
 export default {
   name: "user-manage",
-  components: { UploadButton, ModifyUser },
+  components: { ModifyUser },
   data() {
     return {
       filter: {
@@ -186,13 +170,7 @@ export default {
       ABLE_TYPE,
       roles: [],
       users: [],
-      curUser: {},
-      downloadUrl: "/temps/用户导入模板.xlsx",
-      // import
-      uploadUrl: "/api/admin/sys/user/import",
-      uploadData: {
-        type: "FILE"
-      }
+      curUser: {}
     };
   },
   created() {
@@ -270,13 +248,6 @@ export default {
       this.$ls.clear();
       this.$router.push({ name: "Login" });
       this.$message.info("您的密码已经变更,请重新登录系统!");
-    },
-    uplaodError(errorData) {
-      this.$notify.error({ title: "错误提示", message: errorData.message });
-    },
-    uploadSuccess() {
-      this.$message.success("上传成功!");
-      this.getList();
     }
   }
 };

+ 1 - 1
src/modules/exam/components/CardOptionDialog.vue

@@ -183,7 +183,7 @@ export default {
       this.modalForm.makeMethod =
         this.data.makeMethod || this.cardSourceTypes[0].type;
 
-      // this.getCardList();
+      this.getCardList();
     },
     getCardSourceTypes() {
       let cardSourceTypes = [];

+ 0 - 2
src/modules/exam/store.js

@@ -17,14 +17,12 @@ const mutations = {
 
 const actions = {
   async updateWaitTaskCount({ commit }, userRoles = []) {
-    console.log(userRoles);
     const apis = {
       QUESTION_TEACHER: [waitExamTaskCount],
       EXAM_TEACHER: [waitExamTaskNewCount, waitTaskReviewCount]
     };
     let countAll = [];
     Object.keys(apis).forEach(roleCode => {
-      console.log(roleCode);
       if (userRoles.includes(roleCode))
         countAll = [...countAll, ...apis[roleCode]];
     });

+ 29 - 45
src/modules/exam/views/DataTaskManage.vue

@@ -39,7 +39,7 @@
         </el-form-item>
       </el-form>
       <div class="part-box-action">
-        <el-button
+        <!-- <el-button
           type="danger"
           icon="el-icon-delete"
           @click="toRemove('DELETE')"
@@ -50,7 +50,7 @@
           icon="el-icon-delete-solid"
           @click="toRemove('CLEAR')"
           >清空</el-button
-        >
+        > -->
       </div>
     </div>
     <div class="part-box">
@@ -70,21 +70,9 @@
           :index="indexMethod"
         ></el-table-column>
         <el-table-column prop="printPlanName" label="项目"></el-table-column>
-        <el-table-column prop="type" label="类别">
-          <!-- <template slot-scope="scope">
-            {{ scope.row.type | dataTaskTypeFilter }}
-          </template> -->
-        </el-table-column>
-        <el-table-column prop="status" label="状态">
-          <!-- <template slot-scope="scope">
-            {{ scope.row.status | dataTaskStatusFilter }}
-          </template> -->
-        </el-table-column>
-        <el-table-column prop="result" label="结果">
-          <template slot-scope="scope">
-            {{ scope.row.result | dataTaskResultFilter }}
-          </template>
-        </el-table-column>
+        <el-table-column prop="type" label="类别"> </el-table-column>
+        <el-table-column prop="status" label="状态"> </el-table-column>
+        <el-table-column prop="result" label="结果"> </el-table-column>
         <el-table-column prop="createTime" label="创建时间" width="180">
           <span slot-scope="scope">{{
             scope.row.createTime | timestampFilter
@@ -108,7 +96,6 @@
               title="导出日志"
             ></el-button>
             <el-button
-              v-if="scope.row.hasResultFile"
               class="btn-table-icon"
               type="text"
               icon="icon icon-circle-right"
@@ -141,7 +128,8 @@ import {
   DATA_TASK_RESULT
 } from "@/constants/enumerate";
 import { dataTaskList, removeDataTask } from "../api";
-import { download, randomCode } from "@/plugins/utils";
+import { attachmentDownload } from "../../login/api";
+import { downloadBlob } from "@/plugins/utils";
 
 export default {
   name: "data-task-manage",
@@ -219,39 +207,35 @@ export default {
       if (this.loading) return;
 
       this.loading = true;
-      const res = await download({
-        type: "post",
-        url: this.GLOBAL.domain + "/api/admin/exam/task_review/export",
-        data: {
-          id: row.id
-        },
-        fileName: `${Date.now()}${randomCode()}.zip`,
-        header: this.getHeadIds()
-      }).catch(error => {
-        this.$message.error(error + "文件下载失败,请重新尝试!");
-      });
+      const res = await downloadBlob(() => {
+        return attachmentDownload({ id: row.id, type: "REPORT" });
+      }, `${row.printPlanName}-日志文件.txt`).catch(() => {});
+
       this.loading = false;
-      if (!res) return;
-      this.$message.success("文件下载成功!");
+
+      if (res) {
+        this.$message.success("文件下载成功!");
+      } else {
+        this.$message.error("文件下载失败,请重新尝试!");
+      }
     },
     async toDonwloadFile(row) {
       if (this.loading) return;
 
       this.loading = true;
-      const res = await download({
-        type: "post",
-        url: this.GLOBAL.domain + "/api/admin/exam/task_review/export",
-        data: {
-          id: row.id
-        },
-        fileName: `${Date.now()}${randomCode()}.zip`,
-        header: this.getHeadIds()
-      }).catch(error => {
-        this.$message.error(error + "文件下载失败,请重新尝试!");
-      });
+      const type = row.hasResultFile ? "RESULT" : "IMPORT_FILE";
+      const typeName = row.hasResultFile ? "导出文件" : "导入文件";
+      const res = await downloadBlob(() => {
+        return attachmentDownload({ id: row.id, type });
+      }, `${row.printPlanName}-${typeName}.txt`).catch(() => {});
+
       this.loading = false;
-      if (!res) return;
-      this.$message.success("文件下载成功!");
+
+      if (res) {
+        this.$message.success("文件下载成功!");
+      } else {
+        this.$message.error("文件下载失败,请重新尝试!");
+      }
     }
   }
 };

+ 3 - 0
src/modules/login/api.js

@@ -15,6 +15,9 @@ export const sysMenu = () => {
 export const attachmentPreview = id => {
   return $postParam("/api/admin/common/file/get_one", { id });
 };
+export const attachmentDownload = ({ id, type }) => {
+  return $postParam("/api/admin/common/file/download", { id, type });
+};
 export const getEnums = type => {
   return $postParam("/api/admin/common/get_enums", { type });
 };

+ 3 - 0
src/modules/print/api.js

@@ -34,6 +34,9 @@ export const businessDataListPage = datas => {
 export const businessTotalData = datas => {
   return $postParam("/api/admin/exam/print/data_total", datas);
 };
+export const businessDataExport = datas => {
+  return $postParam("/api/admin/exam/print/data_export", datas);
+};
 export const businessTemplateDownload = () => {
   return $postParam(
     "/api/admin/exam/print/template_download",

+ 15 - 6
src/modules/print/components/ModifyPrintPlan.vue

@@ -251,7 +251,7 @@ import {
   PAPER_BACKUP_TYPE,
   TEMPLATE_CLASSIFY
 } from "@/constants/enumerate";
-// import { deepCopy } from "@/plugins/utils";
+import { deepCopy } from "@/plugins/utils";
 import { updatePrintPlan, printPlanTemplateList } from "../api";
 
 const initModalForm = {
@@ -358,7 +358,7 @@ export default {
     return {
       modalIsShow: false,
       isSubmit: false,
-      modalForm: { ...initModalForm },
+      modalForm: deepCopy(initModalForm),
       createTime: [],
       PRINT_CONTENT_TYPE,
       DRAW_RULE_TYPE,
@@ -455,12 +455,13 @@ export default {
     initData(val) {
       if (val.id) {
         this.createTime = [val.examStartTime, val.examEndTime];
-        this.modalForm = this.$objAssign(initModalForm, val);
+        this.modalForm = this.$objAssign(deepCopy(initModalForm), val);
         const transformInfo = item => {
+          const templateIds = item.templateId ? [item.templateId] : [];
           return {
             type: item.type,
-            templateId: [item.templateId],
-            oldTemplateId: [item.templateId],
+            templateId: templateIds,
+            oldTemplateId: templateIds,
             backupMethod: item.backupMethod,
             backupCount: item.backupCount
           };
@@ -471,7 +472,14 @@ export default {
           ? val.printContent.split(",")
           : [];
       } else {
-        this.modalForm = { ...initModalForm };
+        let modalForm = deepCopy(initModalForm);
+        modalForm.variableContent = modalForm.variableContent.filter(
+          item => this.templateSources[item.type]
+        );
+        modalForm.ordinaryContent = modalForm.ordinaryContent.filter(
+          item => this.templateSources[item.type]
+        );
+        this.modalForm = modalForm;
         this.createTime = [];
       }
     },
@@ -523,6 +531,7 @@ export default {
       datas.ordinaryContent = JSON.stringify(
         this.modalForm.ordinaryContent.map(transformInfo)
       );
+
       const data = await updatePrintPlan(datas).catch(() => {});
       this.isSubmit = false;
       if (!data) return;

+ 2 - 2
src/modules/print/views/BusinessDataDetail.vue

@@ -38,9 +38,9 @@
             clearable
           ></room-select>
         </el-form-item>
-        <el-form-item label="卷袋号:" label-width="70px">
+        <el-form-item label="考生:" label-width="70px">
           <el-input
-            v-model="filter.packageCode"
+            v-model="filter.studentParams"
             placeholder="请输入"
             clearable
           ></el-input>

+ 29 - 4
src/modules/print/views/BusinessDataExport.vue

@@ -60,7 +60,12 @@
         >
           考务数据模板下载
         </el-button>
-        <el-button icon="icon icon-download" type="primary" @click="toExport">
+        <el-button
+          icon="icon icon-download"
+          type="primary"
+          :loading="loading"
+          @click="toExport"
+        >
           导出查询结果
         </el-button>
         <upload-button
@@ -156,11 +161,16 @@
 import {
   businessDataListPage,
   businessTotalData,
-  businessTemplateDownload
+  businessTemplateDownload,
+  businessDataExport
 } from "../api";
 import UploadButton from "@/components/UploadButton";
 import PreviewBusinessDetail from "../components/PreviewBusinessDetail";
-import { downloadBlob, parseTimeRangeDateAndTime } from "@/plugins/utils";
+import {
+  downloadBlob,
+  parseTimeRangeDateAndTime,
+  randomCode
+} from "@/plugins/utils";
 
 export default {
   name: "business-data-export",
@@ -242,7 +252,22 @@ export default {
       this.$message.success("上传成功!");
       this.getList();
     },
-    toExport() {},
+    async toExport() {
+      if (this.loading) return;
+
+      this.loading = true;
+      const res = await downloadBlob(() => {
+        return businessDataExport({ ...this.filter });
+      }, `${randomCode()}-查询结果.xlsx`).catch(() => {});
+
+      this.loading = false;
+
+      if (res) {
+        this.$message.success("文件下载成功!");
+      } else {
+        this.$message.error("文件下载失败,请重新尝试!");
+      }
+    },
     async toDownloadTemplate() {
       if (this.loading) return;