From 8c6cf205affbbc8ada74f00a7ca25ebca867e9ed Mon Sep 17 00:00:00 2001
From: liuyg <376836862@qq.com>
Date: Mon, 27 Sep 2021 11:44:44 +0800
Subject: [PATCH] 图表颜色

---
 src/views/trainingRegistration/index.vue |  538 ++++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 475 insertions(+), 63 deletions(-)

diff --git a/src/views/trainingRegistration/index.vue b/src/views/trainingRegistration/index.vue
index 3206f12..5f4ad34 100644
--- a/src/views/trainingRegistration/index.vue
+++ b/src/views/trainingRegistration/index.vue
@@ -1,22 +1,30 @@
 <template>
-  <div class="recruitmentManagement">
+  <basic-container>
     <avue-crud
       :option="option"
+      :table-loading="loading"
       :data="data"
       :page.sync="page"
-      ref="crudrec"
-      @on-load="onLoad"
-      :table-loading="loading"
+      :search.sync="search"
+      ref="crud"
+      @row-del="rowDel"
+      v-model="form"
+      :permission="permissionList"
+      @row-update="rowUpdate"
       @row-save="rowSave"
+      :before-open="beforeOpen"
+      @filter="filterChange"
       @search-change="searchChange"
       @search-reset="searchReset"
-      @row-update="rowUpdate"
-      @row-del="rowDel"
       @selection-change="selectionChange"
+      @current-change="currentChange"
+      @size-change="sizeChange"
       @refresh-change="refreshChange"
+      @on-load="onLoad"
     >
       <template slot="menuLeft">
         <el-button
+          style="display: none"
           type="danger"
           size="small"
           plain
@@ -24,24 +32,278 @@
           @click="handleDelete"
           >删 除
         </el-button>
+        <el-button
+          type="primary"
+          size="small"
+          plain
+          icon="el-icon-folder-checked"
+          @click="handleBatchExam"
+          v-if="permission.trainingRegistration_exam"
+          >考试申请
+        </el-button>
+        <el-button
+          type="primary"
+          size="small"
+          plain
+          icon="el-icon-folder-checked"
+          v-if="permission.trainingRegistration_import"
+          @click="handleImport"
+          >批量导入
+        </el-button>
+      </template>
+      <template slot-scope="{ type, size, row }" slot="menu">
+        <el-button
+          icon="el-icon-refresh-right"
+          @click="revoke(row)"
+          :size="size"
+          :type="type"
+          v-if="permission.trainingRegistration_cancel"
+          :disabled="row.cancel==2"
+          >取消报名</el-button
+        >
+        <el-button
+          :type="type"
+          size="small"
+          icon="el-icon-receiving"
+          v-if="permission.trainingRegistration_print"
+          :disabled="row.candidateNo == '' || row.cancel==2"
+          @click="handlePrint(row)"
+          >准考证打印
+        </el-button>
+        <el-button
+          icon="el-icon-folder-checked"
+          style="display: none"
+          @click="affirmApply(row)"
+          :size="size"
+          :type="type"
+          >确认报名</el-button
+        >
       </template>
     </avue-crud>
-  </div>
+
+    <el-dialog
+      title="清册数据导入"
+      append-to-body
+      :visible.sync="excelBox"
+      width="555px"
+    >
+      <avue-form
+        :option="excelOption"
+        v-model="excelForm"
+        :upload-after="uploadAfter"
+      >
+        <template slot="excelTemplate">
+          <el-button type="primary" @click="handleTemplate">
+            点击下载<i class="el-icon-download el-icon--right"></i>
+          </el-button>
+        </template>
+      </avue-form>
+    </el-dialog>
+
+    <el-dialog
+      title="考试申请"
+      append-to-body
+      :visible.sync="dialogExamFormVisible"
+      width="1000px"
+      @close="closeDialog"
+    >
+      <avue-form
+        ref="formExamApply"
+        v-model="examApply"
+        :option="optionExamApply"
+        @reset-change="emptytChange"
+        @submit="submitExamApply"
+      ></avue-form>
+    </el-dialog>
+  </basic-container>
 </template>
 
 <script>
-import { data, column } from "./data";
+import { column } from "./data";
 import {
   getdata,
   adddata,
   update,
   remove,
+  cancelTrain,
+  addExam,
 } from "@/api/trainingRegistration/trainingRegistration";
-
+import { mapGetters } from "vuex";
+import { getRoleDetail } from "@/api/system/role";
 export default {
   data() {
     return {
       loading: true,
+      excelBox: false,
+      dialogExamFormVisible: false,
+      search:{},
+      optionExamApply: {
+        height: "auto",
+        filterBtn: true,
+        calcHeight: 30,
+        dialogWidth: 950,
+        tip: false,
+        searchShow: true,
+        searchMenuSpan: 6,
+        border: true, //liu
+        index: true,
+        stripe: true,
+        viewBtn: true,
+        selection: false,
+        excelBtn: false,
+        menuWidth: 380,
+        dialogClickModal: false,
+        column: [
+          // {
+          //   label: "考试人数",
+          //   prop: "number",
+          //   type: 'number',
+          //   span: 12,
+          //   precision:0,
+          //   step:50,
+          //   mock:{
+          //     type:'number',
+          //     max:1000,
+          //     min:0,
+          //     precision:0
+          //   },
+          //   rules: [
+          //     {
+          //       required: true,
+          //       message: "请输入考试人数",
+          //       trigger: "blur",
+          //     },
+          //   ],
+          //   minRows: 0,
+          //   maxRows: 1000,
+          //   value:50,
+          // },
+          {
+            label: "序号开始",
+            prop: "serialStart",
+            span: 12,
+            value:1,
+            mock:{
+              type:'number',
+              max:1000,
+              min:1,
+              precision:0
+            },
+            minRows: 1,
+            maxRows: 1000,
+            type:"number",
+            rules: [
+              {
+                required: true,
+                message: "请输入序号",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "序号结束",
+            prop: "serialEnd",
+            span: 12,
+            value:50,
+            mock:{
+              type:'number',
+              max:1000,
+              min:1,
+              precision:0
+            },
+            minRows: 1,
+            maxRows: 1000,
+            type:"number",
+            rules: [
+              {
+                required: true,
+                message: "请输入序号",
+                trigger: "blur",
+              },
+            ],
+          },
+          {
+            label: "考试时间",
+            prop: "startTime",
+            type: "datetime",
+            format: "yyyy-MM-dd HH:mm",
+            valueFormat: "yyyy-MM-dd HH:mm",
+            // 表单新增时是否禁止
+            addDisabled: false,
+            // 表单新增时是否可见
+            addDisplay: true,
+            // 表单新增时是否为查看模式
+            addDetail: false,
+            // 表单编辑时是否禁止
+            editDisabled: false,
+            // 表单编辑时是否可见
+            editDisplay: true,
+            // 表单编辑时是否为查看模式
+            editDetail: false,
+            rules: [
+              {
+                required: true,
+                message: "请选择考试时间",
+                trigger: "blur",
+              },
+            ],
+            span: 12,
+          },
+          {
+            label: "截止时间",
+            prop: "endTime",
+            type: "datetime",
+            format: "yyyy-MM-dd HH:mm",
+            valueFormat: "yyyy-MM-dd HH:mm",
+            // 表单新增时是否禁止
+            addDisabled: false,
+            // 表单新增时是否可见
+            addDisplay: true,
+            // 表单新增时是否为查看模式
+            addDetail: false,
+            // 表单编辑时是否禁止
+            editDisabled: false,
+            // 表单编辑时是否可见
+            editDisplay: true,
+            // 表单编辑时是否为查看模式
+            editDetail: false,
+            rules: [
+              {
+                required: true,
+                message: "请选择考试时间",
+                trigger: "blur",
+              },
+            ],
+            span: 12,
+          },
+        ],
+      },
+      excelForm: {},
+      excelOption: {
+        submitBtn: false,
+        emptyBtn: false,
+        column: [
+          {
+            label: "模板上传",
+            prop: "excelFile",
+            type: "upload",
+            drag: true,
+            loadText: "模板上传中,请稍等",
+            span: 24,
+            propsHttp: {
+              res: "data",
+            },
+            tip: "请上传 .xls,.xlsx 标准格式文件",
+            action: "/api/trainingRegistration/import-trainingRegistration",
+          },
+          {
+            label: "模板下载",
+            prop: "excelTemplate",
+            formslot: true,
+            span: 24,
+          },
+        ],
+      },
       selectionList: [],
       page: {
         pageSize: 10,
@@ -53,13 +315,18 @@
       option: {
         // card: true,
         tip: false,
-        searchSize: "mini",
+        // searchSize: "mini",
         searchMenuSpan: 6,
-        height: 627,
-        menuWidth: 160,
+        height: 583,
+        index: true,
+        labelWidth: "120",
+        menuWidth: 200,
         align: "center",
-        selection: true,
+        selection: false,
         column: column,
+        delBtn: false,
+        editBtn: false,
+        addBtn: false,
       },
     };
   },
@@ -71,31 +338,60 @@
       });
       return ids.join(",");
     },
+    ...mapGetters(["userInfo", "permission"]),
+    permissionList() {
+      return {
+        addBtn: this.vaildData(this.permission.notice_add, false),
+        viewBtn: this.vaildData(this.permission.notice_view, false),
+        delBtn: this.vaildData(this.permission.notice_delete, false),
+        editBtn: this.vaildData(this.permission.notice_edit, false),
+      };
+    },
+   
+  },
+  created(){
+    this.search['cancel'] = 1;
+    this.search['auditStatus'] = 4;
   },
   methods: {
+    //准考证查看
+    handlePrint(row) {
+      var obj = row;
+      obj["name"] = "准考证信息";
+      this.$router.push({
+        path: `/applyexam/papers`,
+        query: obj,
+      });
+    },
     sizeChange(val) {
-      this.page1.currentPage = 1;
-      this.page1.pageSize = val;
+      this.page.pageSize = val;
       this.getData();
-      //   this.$message.success("行数" + val);
     },
     currentChange(val) {
-      this.page1.currentPage = val;
+      this.page.currentPage = val;
       this.getData();
-      //   this.$message.success("页码" + val);
     },
     rowSave(form, done, loading) {
       var that = this;
-      //   var form = this.data[0];
-      //   delete form.id;
-      //   for (var k = 0; k < 13; k++) {
       adddata(form).then(
         (res) => {
           this.onLoad(this.page);
-          this.$message({
-            type: "success",
-            message: "操作成功!",
-          });
+          if (res.data.data == 201) {
+            this.$message({
+              type: "warning",
+              message: "已报名,不能重复报名",
+            });
+          } else if (res.data.data == 201) {
+            this.$message({
+              type: "warning",
+              message: "报名失败",
+            });
+          } else {
+            this.$message({
+              type: "success",
+              message: "报名成功",
+            });
+          }
           done();
         },
         (error) => {
@@ -103,7 +399,6 @@
           loading();
         }
       );
-      //   }
     },
     searchChange(params, done) {
       this.query = params;
@@ -116,7 +411,6 @@
       this.onLoad(this.page);
     },
     rowUpdate(row, index, done, loading) {
-      console.log(row);
       update(row).then(
         () => {
           this.onLoad(this.page);
@@ -131,6 +425,53 @@
           loading();
         }
       );
+    },
+    //确认报名
+    affirmApply(row, done, loading) {
+      this.$confirm("确认报名?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        row.cancel = 3;
+        update(row).then(
+          () => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "确认报名成功!",
+            });
+            done();
+          },
+          (error) => {
+            window.console.log(error);
+            loading();
+          }
+        );
+      });
+    },
+    revoke(row, done, loading) {
+      this.$confirm("确定取消报名?", {
+        confirmButtonText: "确定",
+        cancelButtonText: "取消",
+        type: "warning",
+      }).then(() => {
+        row.cancel = 2;
+        cancelTrain(row).then(
+          () => {
+            this.onLoad(this.page);
+            this.$message({
+              type: "success",
+              message: "取消报名成功!",
+            });
+            done();
+          },
+          (error) => {
+            window.console.log(error);
+            loading();
+          }
+        );
+      });
     },
     rowDel(row) {
       this.$confirm("确定将选择数据删除?", {
@@ -179,44 +520,115 @@
     },
     onLoad(page, params = {}) {
       this.loading = true;
-      getdata(
-        page.currentPage,
-        page.pageSize,
-        Object.assign(params, this.query)
-      ).then((res) => {
-        // console.log(res);
-        const data = res.data.data;
-        this.page.total = data.total;
-        this.data = data.records;
-        console.log(this.data);
-        this.loading = false;
-      });
+      //判断角色,如果是保安公司管理员或保安,只能查看当前公司的考试成绩
+      var that = this;
+      //获取当前登录人员的角色信息
+      var roleIds = this.userInfo.role_id.split(",");
+      params = this.search;
+      roleIds.forEach((roleId) => {
+        getRoleDetail(roleId).then((res) => {
+            var roleAlias = res.data.data.roleAlias;
+            if (
+              roleAlias == "保安公司管理员" ||
+              roleAlias == "保安"
+            ) {
+              //如果是保安公司管理员
+              params["deptId"] = that.userInfo.dept_id;
+            }
+            if (
+              roleAlias == "培训公司管理员"
+            ) {
+              //如果是培训公司管理员
+              params["trainingUnitId"] = that.userInfo.dept_id;
+            }
+            params['isExam'] = 1;
+            getdata(
+              page.currentPage,
+              page.pageSize,
+              Object.assign(params, this.query)
+            ).then((res) => {
+              // console.log(res);
+              const data = res.data.data;
+              this.page.total = data.total;
+              this.data = data.records;
+              console.log(this.data);
+              this.loading = false;
+            });
+        })
+      })
     },
-  },
-  mounted() {
-    // this.Ourdata = data;
-    // this.getData();
-    // this.onLoad(this.page);
-    // var dept_id = JSON.parse(
-    //   window.localStorage.getItem("saber-userInfo")
-    // ).content.dept_id;
+    handleImport() {
+      this.excelBox = true;
+    },
+
+    handleTemplate() {
+      window.open(`/api/trainingRegistration/export-template`);
+    },
+    uploadAfter(res, done, loading, column) {
+      window.console.log(column);
+      this.excelBox = false;
+      this.refreshChange();
+      done();
+    },
+
+    //生成考试弹窗
+    handleBatchExam() {
+      this.dialogExamFormVisible = true;
+      if (this.selectionList.length === 0) {
+        this.ids = "";
+      }
+    },
+    //生成考试
+    submitExamApply(row, done, loading) {
+      var that = this;
+      row.startTime = row.startTime + ":00";
+      row.endTime = row.endTime + ":00";
+      // if(row.number!=((row.serialEnd-row.serialStart)+1)){
+      //     this.$message({
+      //       type: "error",
+      //       message: "考试人数与序号不匹配!",
+      //     });
+      //    done();
+      //    return;
+      // }
+
+      var s = new Date(row.startTime);
+      var e = new Date(row.endTime);
+      if(s>e){
+        this.$message({
+            type: "error",
+            message: "截止时间不能早于考试考试开始时间!",
+          });
+         done();
+         return;
+      }
+
+      row['number'] = (row.serialEnd-row.serialStart)+1;
+      
+      addExam(Object.assign(row, this.search)).then(
+        () => {
+          this.onLoad(this.page);
+          that.$refs.formExamApply.resetFields();
+          that.dialogExamFormVisible = false;
+          this.$message({
+            type: "success",
+            message: "操作成功",
+          });
+          done();
+        },
+        (error) => {
+          window.console.log(error);
+          loading();
+        }
+      );
+    },
+    //关闭窗口清除数据
+    closeDialog() {
+      this.$refs.formExamApply.resetFields();
+    },
   },
 };
 </script>
 
-<style lang="scss">
-.recruitmentManagement {
-  width: 100%;
-  height: 100%;
-  //   border: 1px solid #000;
-  box-sizing: border-box;
-}
-// .el-card__body {
-//   padding-bottom: 5px !important;
-// }
-// .avue-crud__tip,
-// .el-tag,
-// .el-tag--light {
-//   padding: 0 !important;
-// }
-</style>
\ No newline at end of file
+<style>
+</style>

--
Gitblit v1.9.3