Administrator
2021-08-10 59eb270f54888f039d93fc8c250309f17209831b
报名考试修改
2 files modified
2 files added
785 ■■■■■ changed files
src/api/examapi/applyexam.js 9 ●●●●● patch | view | raw | blame | history
src/api/securityGuard/securityGuard.js 21 ●●●●● patch | view | raw | blame | history
src/views/companyApply/index.vue 634 ●●●●● patch | view | raw | blame | history
src/views/securityApply/index.vue 121 ●●●●● patch | view | raw | blame | history
src/api/examapi/applyexam.js
@@ -21,6 +21,15 @@
    })
}
export const cancelApply = (row) => {
    return request({
        url: '/api/apply/cancelApply',
        method: 'post',
        data: row
    })
}
export const updateApply = (row) => {
    return request({
        url: '/api/apply/submit',
src/api/securityGuard/securityGuard.js
@@ -12,6 +12,18 @@
    })
}
export const getListApply = (current, size, params) => {
    return request({
        url: '/api/blade-user/page-security-apply',
        method: 'get',
        params: {
            ...params,
            current,
            size
        }
    })
}
export const remove = (ids) => {
    return request({
        url: '/api/blade-user/remove',
@@ -30,6 +42,15 @@
    })
}
export const addBatchApply = (row) => {
    return request({
        url: '/api/apply/batchApply',
        method: 'post',
        data: row
    })
}
export const update = (row) => {
    return request({
        url: '/api/blade-user/update',
src/views/companyApply/index.vue
New file
@@ -0,0 +1,634 @@
/*
 * @Author: Morpheus
 * @Date: 2021-07-05 16:31:54
 * @Last Modified by: Morpheus
 * @Last Modified time: 2021-07-19 19:39:45
 * menu-name 报名考试
 */
<template>
  <el-row class="morpheus-box-apply-exam">
    <el-col :span="24" class="hasButOne">
      <el-card>
        <div class="exam-card-body">
          <avue-crud
            v-model="obj"
            class="company-box"
            :option="questionBankOption"
            :search.sync="questionBankSearch"
            :table-loading="questionBankLoading"
            :data="questionBankData"
            ref="questionBankCrud"
            :page.sync="questionBankPage"
            @on-load="questionBankOnLoad"
            @selection-change="questionBankSelectionChange"
            @search-change="questionBankSearchChange"
            @search-reset="questionBankSearchReset"
            @current-change="questionBankCurrentChange"
            @size-change="questionBankSizeChange"
            @row-save="questionBankRowSave"
            @row-del="questionBankRowDel"
          >
            <!-- 自定义按钮 -->
            <template slot="menuLeft">
              <el-button
                type="primary"
                size="small"
                plain
                icon="el-icon-folder-checked"
                @click="handleBatchApply"
                >报 名
              </el-button>
            </template>
            <template slot-scope="{ type, row }" slot="menu">
              <el-button
                :type="type"
                size="small"
                icon="el-icon-refresh-left"
                :disabled="row.isApply == 2 || row.isApply == -1"
                @click="handleCancel(row)"
                >取消报名
              </el-button>
              <el-button
                :type="type"
                size="small"
                icon="el-icon-folder-checked"
                @click="questionBankRowSave(row)"
                >报名
              </el-button>
              <el-button
                :type="type"
                style="display: none"
                size="small"
                icon="el-icon-receiving"
                :disabled="row.isApply == 2"
                @click="handlePrint(row)"
                >准考证打印
              </el-button>
            </template>
          </avue-crud>
          <el-dialog
            title="考试资格审核"
            :visible.sync="dialogFormVisible"
            modal-append-to-body="false"
            append-to-body="true"
            :close-on-click-model="true"
          >
            <avue-form
              ref="formAudit"
              v-model="Audit"
              :option="optionAudit"
              @reset-change="emptytChange"
              @submit="submit"
            ></avue-form>
          </el-dialog>
          <el-dialog
            title="报名"
            append-to-body
            :visible.sync="dialogBatchFormVisible"
            width="1000px"
            @close='closeDialog'
          >
            <avue-form
              ref="formBatchApply"
              v-model="BatchApply"
              :option="optionBatchApply"
              @reset-change="emptytChange"
              @submit="submitBatchApply"
            ></avue-form>
          </el-dialog>
        </div>
      </el-card>
    </el-col>
  </el-row>
</template>
<script>
import { addApply, updateApply, remove } from "@/api/examapi/applyexam";
import { getListApply,addBatchApply } from "@/api/securityGuard/securityGuard";
import { mapState } from "vuex";
var DIC = {
  applyStatus: [
    {
      label: "已报名",
      value: 1,
    },
    {
      label: "已取消",
      value: 2,
    },
  ],
};
export default {
  data() {
    return {
      dialogFormVisible: false,
      dialogBatchFormVisible: false,
      Audit: {},
      BatchApply: {},
      optionAudit: {
        height: "auto",
        calcHeight: 30,
        dialogWidth: 1000,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: false,
        index: true,
        stripe: true,
        viewBtn: false,
        addBtn: false,
        selection: true,
        excelBtn: false,
        menuWidth: 230,
        dialogClickModal: false,
        column: [
          {
            label: "审核状态",
            search: true,
            searchSpan: 5,
            span: 24,
            prop: "auditStatus",
            slot: true,
            editDisplay: false,
            addDisplay: false,
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择审核类型",
                trigger: "blur",
              },
            ],
            dicData: [
              {
                label: "审核通过",
                value: 2,
              },
              {
                label: "不通过",
                value: 3,
              },
            ],
          },
          {
            label: "审核明细",
            span: 24,
            type: "textarea",
            prop: "auditDetail",
          },
        ],
      },
      optionBatchApply: {
        height: "auto",
        filterBtn: true,
        calcHeight: 30,
        dialogWidth: 950,
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: false,
        index: true,
        stripe: true,
        viewBtn: true,
        selection: true,
        excelBtn: false,
        menuWidth: 320,
        dialogClickModal: false,
        column: [
          {
            label: "姓名",
            prop: "userId",
            type: "tree",
            hide: true,
            // dicUrl: "/api/blade-user/page-security-unit?deptId="+this.deptId,
            props: {
              label: "name",
              value: "id",
            },
            //不包含父节点值
            leafOnly:true,
            multiple: true,
            searchSpan: 5,
            rules: [
              {
                required: true,
                message: "请输入姓名",
                trigger: "blur",
              },
            ],
            span: 24,
          },
        ],
      },
      questionBankOption: {
        // 操作栏多余按钮去除
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: true,
        menu: true,
        // 导出按钮
        // excelBtn: true,
        viewBtn: false,
        // title: '题库',
        align: "center",
        height: "auto",
        calcHeight: 80,
        tip: false,
        searchShow: true,
        searchMenuSpan: 4,
        index: true,
        indexLabel: "#",
        //dialogType: 'drawer',
        dialogClickModal: false,
        //tree 默认展开
        defaultExpandAll: true,
        // 操作栏宽度
        menuWidth: 200,
        column: [
          {
            label: "姓名",
            prop: "realName",
            search: true,
            searchSpan: 4,
            searchLabelWidth: 50,
            display: false,
          },
          {
            label: "性别",
            prop: "sex",
            type: "select",
            dicData: [
              {
                label: "男",
                value: 1,
              },
              {
                label: "女",
                value: 2,
              },
              {
                label: "未知",
                value: 3,
              },
              {
                label: " ",
                value: -1,
              },
            ],
            display: false,
          },
          {
            label: "籍贯",
            prop: "nativeplace",
            display: false,
          },
          {
            label: "联系电话",
            prop: "phone",
            display: false,
          },
          {
            label: "入职时间",
            prop: "rtime",
            display: false,
          },
          {
            label: "保安公司名称",
            searchLabelWidth: "110",
            // prop: "deptName",
            prop: "deptId",
            type: "tree",
            dicUrl:
              "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
            props: {
              label: "title",
              value: "id",
            },
            slot: true,
            searchSpan: 4,
            display: false,
            search: false,
            width: 260,
          },
          {
            label: "是否持证",
            prop: "hold",
            slot: true,
            display: false,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=equipage",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            type: "select",
            rules: [
              {
                required: true,
                message: "请选择",
                trigger: "blur",
              },
            ],
          },
          {
            label: "在职状态",
            prop: "status",
            type: "select",
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=workerState",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dataType: "number",
            display: false,
            searchSpan: 4,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择在职状态",
                trigger: "blur",
              },
            ],
          },
          {
            label: "是否报名",
            prop: "isApply",
            type: "select",
            dicData: [
              {
                label: "是",
                value: 1,
              },
              {
                label: "已取消",
                value: 2,
              },
              {
                label: "",
                value: -1,
              },
            ],
            dataType: "number",
            display: false,
            searchSpan: 4,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择在职状态",
                trigger: "blur",
              },
            ],
          },
        ],
      },
      questionBankSearch: {},
      questionBankLoading: true,
      questionBankData: [],
      questionBankPage: {
        pageSize: 10,
        currentPage: 1,
        total: 16,
      },
      questionBankQuery: {},
      questionBankSelectionList: [],
    };
  },
  created() {
    console.log(this.userInfo);
    if (this.userInfo.role_name.indexOf("ksxtadmin") != -1) {
      this.questionBankOption.column[0].dicUrl =
        "/api/blade-system/dept/lazy-tree-user?parentId=";
    } else {
      this.questionBankOption.column[0].dicUrl =
        "/api/blade-system/dept/lazy-tree-user?parentId=" +
        this.userInfo.dept_id;
    }
    this.optionBatchApply.column[0].dicUrl =
        "/api/blade-user/security-apply-tree?deptId=" +
        this.userInfo.dept_id;
  },
  mounted() {
  },
  computed: {
    ...mapState({
      userInfo: (state) => state.user.userInfo,
    }),
    ids() {
      let ids = [];
      this.questionBankSelectionList.forEach((ele) => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
  },
  methods: {
    //准考证查看
    handlePrint(row) {
      var obj = row;
      obj["name"] = "准考证信息";
      this.$router.push({
        path: `/applyexam/papers`,
        query: obj,
      });
    },
    questionBankOnLoad(page, params = {}) {
      this.questionBankLoading = false;
      params["deptId"] = this.userInfo.dept_id;
      getListApply(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.questionBankQuery)
      ).then((res) => {
        const data = res.data.data;
        this.questionBankPage.total = data.total;
        this.questionBankData = data.records;
        this.questionBankLoading = false;
        this.questionBankSelectionClear();
      });
    },
    questionBankSelectionClear() {
      this.questionBankSelectionList = [];
      this.$refs.questionBankCrud.toggleSelection();
    },
    questionBankSelectionChange(list) {
      this.questionBankSelectionList = list;
    },
    questionBankSearchChange(params, done) {
      this.questionBankQuery = params;
      this.questionBankPage.currentPage = 1;
      this.questionBankOnLoad(this.questionBankPage, params);
      done();
    },
    questionBankSearchReset() {
      this.questionBankQuery = {};
      this.questionBankOnLoad(this.questionBankPage);
    },
    questionBankCurrentChange(currentPage) {
      this.questionBankPage.currentPage = currentPage;
    },
    questionBankSizeChange(pageSize) {
      this.questionBankPage.pageSize = pageSize;
    },
    // 新增
    questionBankRowSave(row, done, loading) {
      // debugger;
      addApply({
        userId: row.id,
      }).then(
        (res) => {
          this.questionBankOnLoad(this.questionBankPage);
          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) => {
          window.console.log(error);
          loading();
        }
      );
    },
    questionBankRowDel(row) {
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(row.id);
        })
        .then(() => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    //取消报名
    handleCancel(row) {
      this.$confirm("确定取消报名?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          var apply = {
            applyStatus: 4,
            id: row.applyId,
          };
          return updateApply(apply);
        })
        .then(() => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    //批量报名
    handleBatchApply() {
      this.dialogBatchFormVisible = true;
    },
    //批量报名提交
    submitBatchApply(){
        addBatchApply({
          userIds: this.BatchApply.userId.join(","),
        }).then(
          (res) => {
            this.questionBankOnLoad(this.questionBankPage);
            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: "报名成功",
              });
              this.$refs.formBatchApply.resetFields();
              this.dialogBatchFormVisible = false;
            }
          },
          (error) => {
            window.console.log(error);
          }
        );
    },
    //关闭窗口清除数据
    closeDialog(){
        this.$refs.formBatchApply.resetFields();
    },
    questionBankHandleDelete() {
      if (this.questionBankSelectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          return remove(this.ids);
        })
        .then(() => {
          this.questionBankOnLoad(this.questionBankPage);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.questionBankCrud.toggleSelection();
        });
    },
    handleAudit(row) {
      this.dialogFormVisible = true;
      this.Audit = row;
    },
  },
};
</script>
<style lang="scss" scoped>
</style>
src/views/securityApply/index.vue
New file
@@ -0,0 +1,121 @@
<template>
    <div>
        <div class="security-apply">
            <div class = "security-title">
                <span>2021 保安证考试报名</span>
            </div>
            <div>
                <button class="security-btn" @click="applySubmit">报 名</button>
                <button class="security-btn" @click="cancelApply">取 消 报 名</button>
            </div>
            <!-- <div class = "apply-status">
                 <span>{{status}}</span>
            </div> -->
        </div>
    </div>
</template>
<script>
import { mapState } from 'vuex';
import {
  addApply,
  cancelApply
} from "@/api/examapi/applyexam";
export default {
  data() {
    return {
        status:"未报名"
    };
  },
  computed: {
      ...mapState({
            userInfo: state => state.user.userInfo
        }),
  },
  mounted() {},
  methods:{
    applySubmit(){
      addApply({
        userId: this.userInfo.user_id
      }).then(
        (res) => {
          if (res.data.data == 201) {
            this.$message({
              type: "warning",
              message: "已报名,不能重复报名",
            });
          } else if (res.data.data == 202) {
            this.$message({
              type: "warning",
              message: "报名失败",
            });
          } else {
            this.$message({
              type: "success",
              message: "报名成功",
            });
          }
        },
        (error) => {
          window.console.log(error);
        }
      );
    },
    cancelApply(){
        cancelApply({
        userId: this.userInfo.user_id
      }).then(
        (res) => {
          if (res.data.data == 201) {
            this.$message({
              type: "warning",
              message: "尚未报名",
            });
          } else {
            this.$message({
              type: "success",
              message: "取消报名成功",
            });
          }
        },
        (error) => {
          window.console.log(error);
        }
      );
    }
  }
};
</script>
<style lang="scss">
    .security-apply{
        width: 100%;
        height: 100%;
        margin-top: 250px;
        .security-title{
            width: 30%;
            font-size: 28px;
            margin-left: 35%;
            text-align: center;
            color: cadetblue;
        }
        .security-btn{
            width: 10%;
            margin-left: 45%;
            text-align: center;
            margin-top: 20px;
        }
        .apply-status{
            width: 10%;
            margin-left: 45%;
            text-align: center;
            margin-top: 20px;
        }
    }
</style>