deason 6 years ago
parent
commit
e32880c3f8

+ 2 - 71
src/modules/print/constants/constants.js

@@ -1,8 +1,5 @@
 import Vue from "vue";
 
-/* 印刷平台-API */
-export const PRINT_API = "/api/ecs_prt";
-
 /* 单独备份袋设置-归集类型 */
 export const groupTypeList = [
   { value: "LEARN_CENTER", label: "学习中心" },
@@ -16,48 +13,6 @@ export const coursePaperStatusList = [
   { value: 2, label: "已有" }
 ];
 
-/* 是否为空字符串 */
-Vue.prototype.isEmptyStr = function(str) {
-  if (str == undefined || String(str).length < 1) {
-    return true;
-  }
-  return false;
-};
-
-/* 是否为空数字 */
-Vue.prototype.isEmptyNumber = function(number) {
-  let reg = /^[0-9]+$/;
-  if (!reg.test(number)) {
-    return true;
-  }
-  return false;
-};
-
-/* 日期格式处理 yyyy-MM-dd HH:mm:ss */
-Vue.prototype.formatDateStr = function(dateStr) {
-  if (!dateStr) {
-    return "";
-  }
-  let date = new Date(dateStr);
-  let year = date.getFullYear();
-  let month = this.fillZero(date.getMonth() + 1);
-  let day = this.fillZero(date.getDate());
-  let hour = this.fillZero(date.getHours());
-  let minute = this.fillZero(date.getMinutes());
-  let second = this.fillZero(date.getSeconds());
-  return (
-    year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
-  );
-};
-
-/* 个位数填充零 */
-Vue.prototype.fillZero = function(num) {
-  if (num < 10) {
-    return "0" + num;
-  }
-  return num;
-};
-
 /* 用户角色信息 */
 export const userRole = {
   /* 是否为印刷总负责人 */
@@ -72,8 +27,8 @@ export const userRole = {
   isOther: false
 };
 
-Vue.prototype.loadUserRole = function(loginUser) {
-  let roles = loginUser.roleList;
+Vue.prototype.loadUserRole = function(user) {
+  let roles = user.roleList;
   for (let role of roles) {
     let roleCode = role.roleCode;
     if (roleCode == "PRINT_SUPPLIER") {
@@ -88,28 +43,4 @@ Vue.prototype.loadUserRole = function(loginUser) {
       this.curUserRole.isOther = true;
     }
   }
-  //console.log("curUserRole:", this.curUserRole);
-};
-
-Vue.prototype.loadPmInfo = function(loginUser) {
-  this.pmList = [];
-  this.pmList.push({ id: loginUser.userId, name: loginUser.displayName });
-};
-
-Vue.prototype.loadSupplierInfo = function(loginUser) {
-  this.supplierList = [];
-  this.supplierList.push({ id: loginUser.userId, name: loginUser.displayName });
-};
-
-Vue.prototype.loadOrgList = function() {
-  var url = PRINT_API + "/printing/project/org/list";
-  this.$http.post(url).then(
-    response => {
-      this.orgList = response.data;
-      this.selectDefault();
-    },
-    error => {
-      console.log(error);
-    }
-  );
 };

+ 44 - 0
src/modules/print/utils/common.js

@@ -0,0 +1,44 @@
+/* 是否为整数数字(并包括0) */
+export function checkEmptyNumber(number) {
+  //console.log("number:" + number);
+  let reg = /^[0-9]+$/;
+  if (!reg.test(number)) {
+    return true;
+  }
+  return false;
+}
+
+/* 是否为空字符串(包含数字0时则返回true) */
+export function checkEmptyStr(str) {
+  //console.log("str:" + str);
+  if (str == undefined || String(str).length < 1) {
+    return true;
+  }
+  return false;
+}
+
+/* 将GMT日期字符串格式化为:yyyy-MM-dd HH:mm:ss */
+export function formatGMT(dateStr) {
+  //console.log("dateStr:" + dateStr);
+  if (!dateStr) {
+    return "";
+  }
+  let date = new Date(dateStr);
+  let year = date.getFullYear();
+  let month = fillZero(date.getMonth() + 1);
+  let day = fillZero(date.getDate());
+  let hour = fillZero(date.getHours());
+  let minute = fillZero(date.getMinutes());
+  let second = fillZero(date.getSeconds());
+  return (
+    year + "-" + month + "-" + day + " " + hour + ":" + minute + ":" + second
+  );
+}
+
+/* 个位数则填充零 */
+function fillZero(num) {
+  if (num < 10) {
+    return "0" + num;
+  }
+  return num;
+}

+ 47 - 32
src/modules/print/view/CourseStatistic.vue

@@ -14,7 +14,7 @@
               v-model="formSearch.orgId"
               placeholder="请选择"
               clearable
-              @change="searchExamList(formSearch.orgId);"
+              @change="loadExamList(formSearch.orgId);"
             >
               <el-option
                 v-for="item in orgList"
@@ -63,7 +63,7 @@
               filterable
               clearable
               remote
-              :remote-method="searchCourseList"
+              :remote-method="loadCourseList"
             >
               <el-option label="请选择" value=""></el-option>
               <el-option
@@ -258,7 +258,7 @@
           <el-form-item label="学校名称" prop="orgId">
             <el-select
               v-model="allotAllForm.orgId"
-              @change="searchAllotExamList(allotAllForm.orgId);"
+              @change="loadAllotExamList(allotAllForm.orgId);"
               placeholder="请选择"
               class="w220"
             >
@@ -350,7 +350,7 @@
           <el-form-item label="学校名称" prop="orgId">
             <el-select
               v-model="exportAllForm.orgId"
-              @change="searchExportExamList(exportAllForm.orgId);"
+              @change="loadExportExamList(exportAllForm.orgId);"
               placeholder="请选择"
               class="w220"
             >
@@ -366,7 +366,7 @@
           <el-form-item label="考试名称" prop="examId">
             <el-select
               v-model="exportAllForm.examId"
-              @change="searchExamCoursePaperTotal"
+              @change="loadExamCoursePaperTotal"
               placeholder="请选择"
               class="w220"
             >
@@ -418,6 +418,7 @@
 import { CORE_API, PRINT_API } from "@/constants/constants";
 import { userRole, coursePaperStatusList } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { checkEmptyStr, checkEmptyNumber } from "../utils/common.js";
 
 export default {
   data() {
@@ -505,7 +506,7 @@ export default {
     searchRecords() {
       /* 查询记录列表 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -514,7 +515,7 @@ export default {
       }
 
       let examId = this.formSearch.examId;
-      if (this.isEmptyNumber(examId)) {
+      if (checkEmptyNumber(examId)) {
         this.$notify({
           message: "请选择考试!",
           type: "warning"
@@ -536,53 +537,74 @@ export default {
         }
       );
     },
-    searchExamList(orgId) {
+    selectDefault() {
+      if (this.orgList.length > 0) {
+        let firstOrgId = this.orgList[0].orgId;
+        this.formSearch.orgId = firstOrgId;
+        this.loadExamList(firstOrgId);
+      }
+    },
+    loadOrgList() {
+      /* 查询学校列表 */
+      let url = PRINT_API + "/printing/project/org/list";
+      this.$http.post(url).then(
+        response => {
+          this.orgList = response.data;
+          this.selectDefault();
+        },
+        error => {
+          console.log(error);
+        }
+      );
+    },
+    loadExamList(orgId) {
       /* 查询考试列表 */
       this.formSearch.examId = "";
       this.examList = [];
       this.tableData = [];
-
-      if (!this.isEmptyNumber(orgId)) {
-        let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
-        this.$http.post(url).then(response => {
-          this.examList = response.data;
-          if (this.examList.length > 0) {
-            this.formSearch.examId = this.examList[0].examId;
-            this.searchRecords();
-          }
-        });
+      if (checkEmptyNumber(orgId)) {
+        return;
       }
+
+      let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
+      this.$http.post(url).then(response => {
+        this.examList = response.data;
+        if (this.examList.length > 0) {
+          this.formSearch.examId = this.examList[0].examId;
+          this.searchRecords();
+        }
+      });
     },
-    searchAllotExamList(orgId) {
+    loadAllotExamList(orgId) {
       /* 查询考试列表 */
       this.allotAllForm.examId = "";
       this.allotExamList = [];
 
-      if (!this.isEmptyNumber(orgId)) {
+      if (!checkEmptyNumber(orgId)) {
         let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
         this.$http.post(url).then(response => {
           this.allotExamList = response.data;
         });
       }
     },
-    searchExportExamList(orgId) {
+    loadExportExamList(orgId) {
       /* 查询考试列表 */
       this.exportAllForm.examId = "";
       this.exportExamList = [];
 
-      if (!this.isEmptyNumber(orgId)) {
+      if (!checkEmptyNumber(orgId)) {
         let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
         this.$http.post(url).then(response => {
           this.exportExamList = response.data;
         });
       }
     },
-    searchCourseList(query) {
+    loadCourseList(query) {
       /* 查询课程列表 */
       this.courseList = [];
       let url = CORE_API + "/course/query?enable=true";
 
-      if (!this.isEmptyStr(query)) {
+      if (!checkEmptyStr(query)) {
         url += "&name=" + query;
       }
 
@@ -838,7 +860,7 @@ export default {
         window.location.href = url;
       });
     },
-    searchExamCoursePaperTotal() {
+    loadExamCoursePaperTotal() {
       /* 查询考试的试卷数量情况 */
       let url =
         PRINT_API +
@@ -857,13 +879,6 @@ export default {
           console.log(error);
         }
       );
-    },
-    selectDefault() {
-      if (this.orgList.length > 0) {
-        let firstOrgId = this.orgList[0].orgId;
-        this.formSearch.orgId = firstOrgId;
-        this.searchExamList(firstOrgId);
-      }
     }
   },
   computed: {

+ 49 - 34
src/modules/print/view/ExamStructure.vue

@@ -14,7 +14,7 @@
               v-model="formSearch.orgId"
               placeholder="请选择"
               clearable
-              @change="searchExamList(formSearch.orgId);"
+              @change="loadExamList(formSearch.orgId);"
             >
               <el-option
                 v-for="item in orgList"
@@ -55,7 +55,7 @@
               type="primary"
               icon="el-icon-plus"
               :disabled="!hasPermit"
-              v-show="!isEmptyNumber(formSearch.orgId)"
+              v-show="!checkEmptyNumber(formSearch.orgId)"
               @click="openAddStructureDialog"
               >新增
             </el-button>
@@ -242,7 +242,7 @@
               <el-form-item label="学校名称" prop="newOrgId">
                 <el-select
                   v-model="cloneStructureForm.newOrgId"
-                  @change="searchCloneExamList(cloneStructureForm.newOrgId);"
+                  @change="loadCloneExamList(cloneStructureForm.newOrgId);"
                   placeholder="请选择"
                   class="w220"
                 >
@@ -286,12 +286,13 @@
 import { PRINT_API } from "@/constants/constants";
 import { userRole } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { checkEmptyNumber } from "../utils/common.js";
 
 export default {
   data() {
     let validateSingleChoiceTotal = (rule, value, callback) => {
       if (
-        this.isEmptyNumber(
+        checkEmptyNumber(
           this.addStructureForm.questionStructure.singleChoiceTotal
         )
       ) {
@@ -303,7 +304,7 @@ export default {
 
     let validateMultipleChoiceTotal = (rule, value, callback) => {
       if (
-        this.isEmptyNumber(
+        checkEmptyNumber(
           this.addStructureForm.questionStructure.multipleChoiceTotal
         )
       ) {
@@ -315,7 +316,7 @@ export default {
 
     let validateBoolChoiceTotal = (rule, value, callback) => {
       if (
-        this.isEmptyNumber(
+        checkEmptyNumber(
           this.addStructureForm.questionStructure.boolQuestionTotal
         )
       ) {
@@ -409,7 +410,7 @@ export default {
     searchRecords() {
       /* 查询记录列表 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -431,13 +432,33 @@ export default {
         }
       );
     },
-    searchExamList(orgId) {
+    selectDefault() {
+      if (this.orgList.length > 0) {
+        let firstOrgId = this.orgList[0].orgId;
+        this.formSearch.orgId = firstOrgId;
+        this.loadExamList(firstOrgId);
+      }
+    },
+    loadOrgList() {
+      /* 查询学校列表 */
+      let url = PRINT_API + "/printing/project/org/list";
+      this.$http.post(url).then(
+        response => {
+          this.orgList = response.data;
+          this.selectDefault();
+        },
+        error => {
+          console.log(error);
+        }
+      );
+    },
+    loadExamList(orgId) {
       /* 查询考试列表 */
       this.formSearch.examId = "";
       this.examList = [];
       this.tableData = [];
 
-      if (!this.isEmptyNumber(orgId)) {
+      if (!checkEmptyNumber(orgId)) {
         let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
         this.$http.post(url).then(response => {
           this.examList = response.data;
@@ -448,18 +469,34 @@ export default {
         });
       }
     },
-    searchCloneExamList(orgId) {
+    loadCloneExamList(orgId) {
       /* 查询考试列表 */
       this.cloneStructureForm.newExamId = "";
       this.cloneExamList = [];
 
-      if (!this.isEmptyNumber(orgId)) {
+      if (!checkEmptyNumber(orgId)) {
         let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
         this.$http.post(url).then(response => {
           this.cloneExamList = response.data;
         });
       }
     },
+    getOrgNameById(orgList, orgId) {
+      for (let i = 0; i < orgList.length; i++) {
+        if (orgList[i].orgId == orgId) {
+          return orgList[i].orgName;
+        }
+      }
+      return "";
+    },
+    getExamNameById(examList, examId) {
+      for (let i = 0; i < examList.length; i++) {
+        if (examList[i].examId == examId) {
+          return examList[i].examName;
+        }
+      }
+      return "";
+    },
     openAddStructureDialog() {
       /* 打开考试结构弹窗 */
       this.addStructureDialog = true;
@@ -583,29 +620,7 @@ export default {
           /*ignore*/
         });
     },
-    getOrgNameById(orgList, orgId) {
-      for (let i = 0; i < orgList.length; i++) {
-        if (orgList[i].orgId == orgId) {
-          return orgList[i].orgName;
-        }
-      }
-      return "";
-    },
-    getExamNameById(examList, examId) {
-      for (let i = 0; i < examList.length; i++) {
-        if (examList[i].examId == examId) {
-          return examList[i].examName;
-        }
-      }
-      return "";
-    },
-    selectDefault() {
-      if (this.orgList.length > 0) {
-        let firstOrgId = this.orgList[0].orgId;
-        this.formSearch.orgId = firstOrgId;
-        this.searchExamList(firstOrgId);
-      }
-    }
+    checkEmptyNumber: checkEmptyNumber
   },
   computed: {
     ...mapState({ user: state => state.user })

+ 106 - 88
src/modules/print/view/Project.vue

@@ -14,7 +14,7 @@
               v-model="formSearch.orgId"
               placeholder="请选择"
               clearable
-              @change="searchExamList(formSearch.orgId);"
+              @change="loadExamList(formSearch.orgId);"
             >
               <el-option
                 v-for="item in orgList"
@@ -47,7 +47,8 @@
               filterable
               clearable
               remote
-              :remote-method="searchPmList"
+              :disabled="curUserRole.isPM"
+              :remote-method="loadPmList"
             >
               <el-option label="请选择" value=""></el-option>
               <el-option
@@ -66,7 +67,8 @@
               filterable
               clearable
               remote
-              :remote-method="searchSupplierList"
+              :disabled="curUserRole.isSupplier"
+              :remote-method="loadSupplierList"
             >
               <el-option label="请选择" value=""></el-option>
               <el-option
@@ -327,6 +329,7 @@
 import { CORE_API, PRINT_API } from "@/constants/constants";
 import { userRole } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { checkEmptyStr, checkEmptyNumber, formatGMT } from "../utils/common.js";
 
 export default {
   data() {
@@ -565,7 +568,7 @@ export default {
     searchRecords() {
       /* 查询记录列表 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -574,7 +577,7 @@ export default {
       }
 
       let examId = this.formSearch.examId;
-      if (this.isEmptyNumber(examId)) {
+      if (checkEmptyNumber(examId)) {
         this.$notify({
           message: "请选择考试!",
           type: "warning"
@@ -596,29 +599,51 @@ export default {
         }
       );
     },
-    searchExamList(orgId) {
+    selectDefault() {
+      if (this.orgList.length > 0) {
+        let firstOrgId = this.orgList[0].orgId;
+        this.formSearch.orgId = firstOrgId;
+        this.loadExamList(firstOrgId);
+      }
+    },
+    loadOrgList() {
+      /* 查询学校列表 */
+      let url = PRINT_API + "/printing/project/org/list";
+      this.$http.post(url).then(
+        response => {
+          this.orgList = response.data;
+          this.selectDefault();
+        },
+        error => {
+          console.log(error);
+        }
+      );
+    },
+    loadExamList(orgId) {
       /* 查询考试列表 */
       this.formSearch.examId = "";
       this.examList = [];
       this.tableData = [];
-      if (!this.isEmptyNumber(orgId)) {
-        let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
-        this.$http.post(url).then(response => {
-          this.examList = response.data;
-          if (this.examList.length > 0) {
-            this.formSearch.examId = this.examList[0].examId;
-            this.searchRecords();
-          }
-        });
+      if (checkEmptyNumber(orgId)) {
+        return;
       }
+
+      let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
+      this.$http.post(url).then(response => {
+        this.examList = response.data;
+        if (this.examList.length > 0) {
+          this.formSearch.examId = this.examList[0].examId;
+          this.searchRecords();
+        }
+      });
     },
-    searchPmList(query) {
+    loadPmList(query) {
       /* 查询项目经理列表 */
       this.pmList = [];
       let url =
         CORE_API + "/user/query?rootOrgCode=qmth&roleCode=PRINT_PROJECT_LEADER";
 
-      if (!this.isEmptyStr(query)) {
+      if (!checkEmptyStr(query)) {
         url += "&name=" + query;
       }
 
@@ -626,13 +651,13 @@ export default {
         this.pmList = response.data;
       });
     },
-    searchSupplierList(query) {
+    loadSupplierList(query) {
       /* 查询印刷供应商列表 */
       this.supplierList = [];
       let url =
         CORE_API + "/user/query?rootOrgCode=qmth-print&roleCode=PRINT_SUPPLIER";
 
-      if (!this.isEmptyStr(query)) {
+      if (!checkEmptyStr(query)) {
         url += "&name=" + query;
       }
 
@@ -640,6 +665,39 @@ export default {
         this.supplierList = response.data;
       });
     },
+    loadPmInfo(loginUser) {
+      this.pmList = [];
+      this.pmList.push({ id: loginUser.userId, name: loginUser.displayName });
+    },
+    loadSupplierInfo(loginUser) {
+      this.supplierList = [];
+      this.supplierList.push({
+        id: loginUser.userId,
+        name: loginUser.displayName
+      });
+    },
+    selectPmName(key) {
+      /* 处理项目经理名称 */
+      if (checkEmptyNumber(key)) {
+        return;
+      }
+      let obj = {};
+      obj = this.pmList.find(function(item) {
+        return item.id === key;
+      });
+      this.projectSettingForm.pmName = obj.name;
+    },
+    selectSupplierName(key) {
+      /* 处理供应商名称 */
+      if (checkEmptyNumber(key)) {
+        return;
+      }
+      let obj = {};
+      obj = this.supplierList.find(function(item) {
+        return item.id === key;
+      });
+      this.projectSettingForm.supplierName = obj.name;
+    },
     gotoProjectStatistic(row) {
       /* 查看项目统计 */
       let url = "/print/project/statistic/" + row.orgId + "/" + row.examId;
@@ -655,22 +713,22 @@ export default {
 
         this.selectSupplierName(this.projectSettingForm.supplierId);
 
-        this.projectSettingForm.prepareStartTime = this.formatDateStr(
+        this.projectSettingForm.prepareStartTime = formatGMT(
           this.projectSettingForm.prepareStartTime
         );
-        this.projectSettingForm.prepareEndTime = this.formatDateStr(
+        this.projectSettingForm.prepareEndTime = formatGMT(
           this.projectSettingForm.prepareEndTime
         );
-        this.projectSettingForm.printStartTime = this.formatDateStr(
+        this.projectSettingForm.printStartTime = formatGMT(
           this.projectSettingForm.printStartTime
         );
-        this.projectSettingForm.printEndTime = this.formatDateStr(
+        this.projectSettingForm.printEndTime = formatGMT(
           this.projectSettingForm.printEndTime
         );
-        this.projectSettingForm.mailStartTime = this.formatDateStr(
+        this.projectSettingForm.mailStartTime = formatGMT(
           this.projectSettingForm.mailStartTime
         );
-        this.projectSettingForm.mailEndTime = this.formatDateStr(
+        this.projectSettingForm.mailEndTime = formatGMT(
           this.projectSettingForm.mailEndTime
         );
 
@@ -704,72 +762,30 @@ export default {
       this.projectSettingForm.pmName = row.pmName;
       this.projectSettingForm.supplierId = row.supplierId;
       this.projectSettingForm.supplierName = row.supplierName;
-
-      if (row.prepareStartTime) {
-        this.projectSettingForm.prepareStartTime = new Date(
-          row.prepareStartTime
-        );
-      } else {
-        this.projectSettingForm.prepareStartTime = "";
-      }
-      if (row.prepareEndTime) {
-        this.projectSettingForm.prepareEndTime = new Date(row.prepareEndTime);
-      } else {
-        this.projectSettingForm.prepareEndTime = "";
-      }
-      if (row.printStartTime) {
-        this.projectSettingForm.printStartTime = new Date(row.printStartTime);
-      } else {
-        this.projectSettingForm.printStartTime = "";
-      }
-      if (row.printEndTime) {
-        this.projectSettingForm.printEndTime = new Date(row.printEndTime);
-      } else {
-        this.projectSettingForm.printEndTime = "";
-      }
-      if (row.mailStartTime) {
-        this.projectSettingForm.mailStartTime = new Date(row.mailStartTime);
-      } else {
-        this.projectSettingForm.mailStartTime = "";
-      }
-      if (row.mailEndTime) {
-        this.projectSettingForm.mailEndTime = new Date(row.mailEndTime);
-      } else {
-        this.projectSettingForm.mailEndTime = "";
-      }
+      this.projectSettingForm.prepareStartTime = this.settingDate(
+        row.prepareStartTime
+      );
+      this.projectSettingForm.prepareEndTime = this.settingDate(
+        row.prepareEndTime
+      );
+      this.projectSettingForm.printStartTime = this.settingDate(
+        row.printStartTime
+      );
+      this.projectSettingForm.printEndTime = this.settingDate(row.printEndTime);
+      this.projectSettingForm.mailStartTime = this.settingDate(
+        row.mailStartTime
+      );
+      this.projectSettingForm.mailEndTime = this.settingDate(row.mailEndTime);
     },
     closeProjectSettingDialog() {
       /* 关闭项目设置弹窗 */
       this.projectSettingDialog = false;
     },
-    selectPmName(key) {
-      /* 处理项目经理名称 */
-      if (this.isEmptyNumber(key)) {
-        return;
-      }
-      let obj = {};
-      obj = this.pmList.find(function(item) {
-        return item.id === key;
-      });
-      this.projectSettingForm.pmName = obj.name;
-    },
-    selectSupplierName(key) {
-      /* 处理供应商名称 */
-      if (this.isEmptyNumber(key)) {
-        return;
-      }
-      let obj = {};
-      obj = this.supplierList.find(function(item) {
-        return item.id === key;
-      });
-      this.projectSettingForm.supplierName = obj.name;
-    },
-    selectDefault() {
-      if (this.orgList.length > 0) {
-        let firstOrgId = this.orgList[0].orgId;
-        this.formSearch.orgId = firstOrgId;
-        this.searchExamList(firstOrgId);
+    settingDate(dateStr) {
+      if (dateStr) {
+        return new Date(dateStr);
       }
+      return "";
     }
   },
   computed: {
@@ -782,14 +798,16 @@ export default {
 
     if (this.curUserRole.isSuperLeader) {
       this.hasPermit = true;
-      this.searchPmList();
-      this.searchSupplierList();
+      this.loadPmList();
+      this.loadSupplierList();
     } else if (this.curUserRole.isPM) {
-      this.hasPermit = true;
+      this.hasPermit = false;
       this.loadPmInfo(this.user);
+      this.formSearch.pmId = this.user.userId;
     } else if (this.curUserRole.isSupplier) {
       this.hasPermit = false;
       this.loadSupplierInfo(this.user);
+      this.formSearch.supplierId = this.user.userId;
     } else {
       this.hasPermit = false;
     }

+ 56 - 39
src/modules/print/view/ProjectStatistic.vue

@@ -15,7 +15,7 @@
               v-model="formSearch.orgId"
               placeholder="请选择"
               clearable
-              @change="searchExamList(formSearch.orgId);"
+              @change="loadExamList(formSearch.orgId);"
             >
               <el-option
                 v-for="item in orgList"
@@ -56,7 +56,7 @@
               type="primary"
               icon="el-icon-plus"
               :disabled="!hasPermit"
-              v-show="formSearch.examId != ''"
+              v-show="!checkEmptyNumber(formSearch.examId)"
               @click="openOtherSettingDialog"
               >新增其它事项
             </el-button>
@@ -66,7 +66,7 @@
               type="primary"
               icon="el-icon-refresh"
               :disabled="!hasPermit"
-              v-show="formSearch.examId != ''"
+              v-show="!checkEmptyNumber(formSearch.examId)"
               @click="refreshStatistic"
               >刷新
             </el-button>
@@ -287,12 +287,13 @@
 import { PRINT_API } from "@/constants/constants";
 import { userRole, groupTypeList } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { checkEmptyStr, checkEmptyNumber } from "../utils/common.js";
 
 export default {
   data() {
     let validateEachPkgPercent = (rule, value, callback) => {
       if (this.backupSettingForm.needEachPkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.eachPkgPercent)) {
+        if (checkEmptyNumber(this.backupSettingForm.eachPkgPercent)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -302,7 +303,7 @@ export default {
 
     let validateEachPkgMax = (rule, value, callback) => {
       if (this.backupSettingForm.needEachPkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.eachPkgMax)) {
+        if (checkEmptyNumber(this.backupSettingForm.eachPkgMax)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -312,7 +313,7 @@ export default {
 
     let validateEachPkgMin = (rule, value, callback) => {
       if (this.backupSettingForm.needEachPkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.eachPkgMin)) {
+        if (checkEmptyNumber(this.backupSettingForm.eachPkgMin)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -322,7 +323,7 @@ export default {
 
     let validateAlonePkgPercent = (rule, value, callback) => {
       if (this.backupSettingForm.needAlonePkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.alonePkgPercent)) {
+        if (checkEmptyNumber(this.backupSettingForm.alonePkgPercent)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -332,7 +333,7 @@ export default {
 
     let validateAlonePkgMax = (rule, value, callback) => {
       if (this.backupSettingForm.needAlonePkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.alonePkgMax)) {
+        if (checkEmptyNumber(this.backupSettingForm.alonePkgMax)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -342,7 +343,7 @@ export default {
 
     let validateAlonePkgMin = (rule, value, callback) => {
       if (this.backupSettingForm.needAlonePkg) {
-        if (this.isEmptyNumber(this.backupSettingForm.alonePkgMin)) {
+        if (checkEmptyNumber(this.backupSettingForm.alonePkgMin)) {
           callback(new Error("请输入正确的数值!"));
           return;
         }
@@ -352,7 +353,7 @@ export default {
 
     let validateGroupType = (rule, value, callback) => {
       if (this.backupSettingForm.needAlonePkg) {
-        if (this.isEmptyStr(this.backupSettingForm.groupType)) {
+        if (checkEmptyStr(this.backupSettingForm.groupType)) {
           callback(new Error("请选择归集参数!"));
           return;
         }
@@ -458,7 +459,7 @@ export default {
     searchRecords() {
       /* 查询记录列表 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -467,7 +468,7 @@ export default {
       }
 
       let examId = this.formSearch.examId;
-      if (this.isEmptyNumber(examId)) {
+      if (checkEmptyNumber(examId)) {
         this.$notify({
           message: "请选择考试!",
           type: "warning"
@@ -525,30 +526,55 @@ export default {
       };
       this.tableData.push(totalColumn);
     },
-    searchExamList(orgId) {
+    selectDefault() {
+      if (this.loaded) {
+        return;
+      }
+      if (this.orgList.length > 0) {
+        let firstOrgId = this.orgList[0].orgId;
+        this.formSearch.orgId = firstOrgId;
+        this.loadExamList(firstOrgId);
+      }
+    },
+    loadOrgList() {
+      /* 查询学校列表 */
+      let url = PRINT_API + "/printing/project/org/list";
+      this.$http.post(url).then(
+        response => {
+          this.orgList = response.data;
+          this.selectDefault();
+        },
+        error => {
+          console.log(error);
+        }
+      );
+    },
+    loadExamList(orgId) {
       /* 查询考试列表 */
       this.formSearch.examId = "";
       this.examList = [];
       this.tableData = [];
       this.projectId = "";
-      if (!this.isEmptyNumber(orgId)) {
-        let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
-        this.$http.post(url).then(response => {
-          this.examList = response.data;
-          if (this.loaded) {
-            return;
-          }
-          if (this.examList.length > 0) {
-            this.formSearch.examId = this.examList[0].examId;
-            this.searchRecords();
-          }
-        });
+      if (checkEmptyNumber(orgId)) {
+        return;
       }
+
+      let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
+      this.$http.post(url).then(response => {
+        this.examList = response.data;
+        if (this.loaded) {
+          return;
+        }
+        if (this.examList.length > 0) {
+          this.formSearch.examId = this.examList[0].examId;
+          this.searchRecords();
+        }
+      });
     },
     refreshStatistic() {
       /* 刷新当前统计信息 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -557,7 +583,7 @@ export default {
       }
 
       let examId = this.formSearch.examId;
-      if (this.isEmptyNumber(examId)) {
+      if (checkEmptyNumber(examId)) {
         this.$notify({
           message: "请选择考试!",
           type: "warning"
@@ -741,7 +767,7 @@ export default {
     },
     openOtherSettingDialog(row) {
       /* 打开其它事项弹窗 */
-      if (this.isEmptyNumber(this.projectId)) {
+      if (checkEmptyNumber(this.projectId)) {
         this.$notify({
           message: "请选择学校和考试!",
           type: "warning"
@@ -769,16 +795,7 @@ export default {
       /* 返回上级界面 */
       this.$router.push({ path: "/print/project/list" });
     },
-    selectDefault() {
-      if (this.loaded) {
-        return;
-      }
-      if (this.orgList.length > 0) {
-        let firstOrgId = this.orgList[0].orgId;
-        this.formSearch.orgId = firstOrgId;
-        this.searchExamList(firstOrgId);
-      }
-    }
+    checkEmptyNumber: checkEmptyNumber
   },
   computed: {
     ...mapState({ user: state => state.user })
@@ -798,7 +815,7 @@ export default {
     if (orgId != "0" || examId != "0") {
       this.loaded = true;
       this.loadOrgList();
-      this.searchExamList(orgId);
+      this.loadExamList(orgId);
       this.showGoBack = true;
       this.formSearch.orgId = parseInt(orgId);
       this.formSearch.examId = parseInt(examId);

+ 38 - 22
src/modules/print/view/ProjectTemplate.vue

@@ -14,7 +14,7 @@
               v-model="formSearch.orgId"
               placeholder="请选择"
               clearable
-              @change="searchExamList(formSearch.orgId);"
+              @change="loadExamList(formSearch.orgId);"
             >
               <el-option
                 v-for="item in orgList"
@@ -92,7 +92,7 @@
               <el-button
                 size="mini"
                 icon="el-icon-download"
-                :disabled="isEmptyStr(scope.row.fileName)"
+                :disabled="checkEmptyStr(scope.row.fileName)"
                 @click="download(scope.row);"
                 >下载
               </el-button>
@@ -103,7 +103,7 @@
               <el-button
                 size="mini"
                 icon="el-icon-view"
-                :disabled="isEmptyStr(scope.row.fileUrl)"
+                :disabled="checkEmptyStr(scope.row.fileUrl)"
                 @click="preview(scope.row);"
                 >预览
               </el-button>
@@ -119,6 +119,7 @@
 import { PRINT_API } from "@/constants/constants";
 import { userRole } from "../constants/constants.js";
 import { mapState } from "vuex";
+import { checkEmptyStr, checkEmptyNumber } from "../utils/common.js";
 
 export default {
   data() {
@@ -152,7 +153,7 @@ export default {
     searchRecords() {
       /* 查询记录列表 */
       let orgId = this.formSearch.orgId;
-      if (this.isEmptyNumber(orgId)) {
+      if (checkEmptyNumber(orgId)) {
         this.$notify({
           message: "请选择学校!",
           type: "warning"
@@ -161,7 +162,7 @@ export default {
       }
 
       let examId = this.formSearch.examId;
-      if (this.isEmptyNumber(examId)) {
+      if (checkEmptyNumber(examId)) {
         this.$notify({
           message: "请选择考试!",
           type: "warning"
@@ -182,22 +183,43 @@ export default {
         }
       );
     },
-    searchExamList(orgId) {
+    selectDefault() {
+      if (this.orgList.length > 0) {
+        let firstOrgId = this.orgList[0].orgId;
+        this.formSearch.orgId = firstOrgId;
+        this.loadExamList(firstOrgId);
+      }
+    },
+    loadOrgList() {
+      /* 查询学校列表 */
+      let url = PRINT_API + "/printing/project/org/list";
+      this.$http.post(url).then(
+        response => {
+          this.orgList = response.data;
+          this.selectDefault();
+        },
+        error => {
+          console.log(error);
+        }
+      );
+    },
+    loadExamList(orgId) {
       /* 查询考试列表 */
       this.formSearch.examId = "";
       this.examList = [];
       this.tableData = [];
 
-      if (!this.isEmptyNumber(orgId)) {
-        let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
-        this.$http.post(url).then(response => {
-          this.examList = response.data;
-          if (this.examList.length > 0) {
-            this.formSearch.examId = this.examList[0].examId;
-            this.searchRecords();
-          }
-        });
+      if (checkEmptyNumber(orgId)) {
+        return;
       }
+      let url = PRINT_API + "/printing/project/exam/list?orgId=" + orgId;
+      this.$http.post(url).then(response => {
+        this.examList = response.data;
+        if (this.examList.length > 0) {
+          this.formSearch.examId = this.examList[0].examId;
+          this.searchRecords();
+        }
+      });
     },
     uploadSuccess(response, file, fileList, row) {
       /* 上传模板 */
@@ -257,13 +279,7 @@ export default {
       let url = PRINT_API + "/common/download?filePath=" + filePath;
       window.location.href = url;
     },
-    selectDefault() {
-      if (this.orgList.length > 0) {
-        let firstOrgId = this.orgList[0].orgId;
-        this.formSearch.orgId = firstOrgId;
-        this.searchExamList(firstOrgId);
-      }
-    }
+    checkEmptyStr: checkEmptyStr
   },
   computed: {
     ...mapState({ user: state => state.user })