保安服务企业管理项目备份
liuyg
2021-09-24 c4e67a8942e514b65ab41bb19781d50576c15725
src/views/traincompany/index.vue
@@ -3,7 +3,7 @@
 * @Date: 2021-07-07 17:30:05
 * @Last Modified by: Morpheus
 * @Last Modified time: 2021-07-10 16:06:14
 * menu-name 保安培训单位
 * menu-name 保安培训报名
 */
<template>
  <basic-container>
@@ -30,18 +30,28 @@
    >
      <template slot-scope="{ type,row }" slot="menu">
                            <el-button
                            :type="type"
                            size="small"
                            icon="el-icon-edit"
                            @click="handleTrainApply(row)"
                            >报名
                            </el-button>
                        </template>
          <el-button
          :type="type"
          size="small"
          icon="el-icon-edit"
          v-if="permission.traincompany_addTrain"
          :disabled="auditStatus"
          @click="handleTrainApply(row)"
          >报名
          </el-button>
          <el-button
          :type="type"
          size="small"
          icon="el-icon-edit"
          v-if="permission.traincompany_batchAddTrain"
          @click="handleTrainApplyBatch(row)"
          >批量报名
          </el-button>
      </template>
    </avue-crud>
    <el-dialog
        title="报名"
        title="批量报名"
        append-to-body
        :visible.sync="dialogDisable"
        width="1000px"
@@ -59,17 +69,19 @@
  update,
  remove,
} from "@/api/securityCompany/train";
import {adddata} from "@/api/trainingRegistration/trainingRegistration";
import {adddata,batchTrain} from "@/api/trainingRegistration/trainingRegistration";
import { mapGetters } from "vuex";
import { mapState } from 'vuex';
import {getUser} from "@/api/system/user";
export default {
  data() {
    return {
      form: {},
      auditStatus:false,
      formTrainApply: {},
      query: {},
      deptId:null,
      loading: true,
      dialogDisable:false,
      page: {
@@ -106,45 +118,27 @@
            display: false,
          },
          {
            label: "法定代表人",
            label: "校长",
            prop: "representative",
            display: false,
            search: true,
            searchSpan: 4,
            searchLabelWidth: 95,
            width: 120,
          },
          {
            label: "成立日期",
            prop: "establishtime",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            mock: {
              type: "datetime",
              format: "yyyy-MM-dd",
            },
            display: false,
            width: 180,
            label: "负责人",
            prop: "contacts",
            display: false
          },
          {
            label: "注册资金",
            prop: "registeredcapital",
            label: "联系方式",
            prop: "contactscell",
            display: false,
            width: 130,
          },
          {
            label: "实缴资金",
            prop: "capital",
            display: false,
            width: 130,
          },
          {
            label: "公司类型",
            prop: "enterprises",
            display: false,
          },
          {
            label: "注册地址",
            label: "联系地址",
            prop: "address",
            display: false,
            width: 280,
@@ -186,60 +180,49 @@
              span:24
          },
          // {
          //     label: "考试名称",
          //     prop: "trainExamId",
          //     dicUrl: "/api/trainExam/page-tree?deptId={{key}}",
          //     label: "单位名称",
          //     prop: "deptId",
          //     dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
          //     // dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=0",
          //     cascaderItem: ["userId"],
          //     props: {
          //         label: "trainExamName",
          //         label: "title",
          //         value: "id"
          //     },
          //     // search: true,
          //     type: "select",
          //     hide: true,
          //     rules: [{
          //         required: true,
          //         message: "请输入考试名称",
          //         message: "请输入单位名称",
          //         trigger: "blur"
          //     }],
          //     hide: true,
          // },
          //     span: 24
          // },
          {
              label: "单位名称",
              prop: "deptId",
              // width: 70,
              // search: true,
              // searchSpan: 4,
              dicUrl: "/api/blade-system/dept/security_lazy-tree?parentId=1413470343230877697",
              cascaderItem: ["userId"],
              props: {
                  label: "title",
                  value: "id"
            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",
              },
              // search: true,
              type: "select",
              hide: true,
              rules: [{
                  required: true,
                  message: "请输入单位名称",
                  trigger: "blur"
              }],
              overHidden: true
          }, {
              label: "姓名",
              prop: "userId",
              type: "select",
              hide: true,
              dicUrl: "/api/blade-user/page-security-unit?deptId={{key}}",
              props: {
                  label: "realName",
                  value: "id"
              },
              searchSpan: 5,
              rules: [{
                  required: true,
                  message: "请输入姓名",
                  trigger: "blur"
              }],
            ],
            span: 24,
          },
        ],
      },
      data: [],
@@ -249,10 +232,10 @@
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.post_add, false),
        viewBtn: this.vaildData(this.permission.post_view, false),
        delBtn: this.vaildData(this.permission.post_delete, false),
        editBtn: this.vaildData(this.permission.post_edit, false),
        addBtn: this.vaildData(null, false),
        viewBtn: this.vaildData(null, false),
        delBtn: this.vaildData(null, false),
        editBtn: this.vaildData(null, false),
      };
    },
    ids() {
@@ -265,48 +248,110 @@
    ...mapState({
        userInfo: state => state.user.userInfo
    })
  },
  created() {
      this.optionTrainApply.column[1].dicUrl =
        "/api/blade-user/security-apply-tree?examType=2&deptId=" +
        this.userInfo.dept_id;
      this.getUserDetail();
  },
  methods: {
    handleTrainApply(row){
    //获取用户信息
    getUserDetail(){
      var that = this;
      getUser(this.userInfo.Id).then((res)=>{
          var status = res.data.data.examinationType;
          if(status=='1'){
            that.auditStatus = true;
          }
          console.log(that.auditStatus,3333);
      })
    },
    //保安公司批量报名
    handleTrainApplyBatch(row){
      this.dialogDisable = true;
      this.optionTrainApply.column.trainingUnitId = row.departmentid;
      // this.deptId= this.userInfo.dept_id;
      this.formTrainApply = {
        trainingUnitId: row.departmentid
      }
    },
    //批量报名提交
    submit(){
        batchTrain({
          userIds: this.formTrainApply.userId.join(","),
          trainingUnitId: this.formTrainApply.trainingUnitId
        }).then(
          (res) => {
            this.onLoad(this.page);
            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.formTrainApply.resetFields();
              this.dialogDisable = false;
            }
          },
          (error) => {
            window.console.log(error);
          }
        );
    },
    //未持证保安人员报名
    handleTrainApply(row,done,loading){
      this.$confirm("是否确定报名?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        row['userId'] = this.userInfo.user_id;
        row['trainingUnitId'] = row.departmentid;
        adddata(row).then(
          (res) => {
            // this.onLoad(this.page);
            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();
          }
        );
      })
    },
    //关闭窗口清除数据
    closeDialog(){
      this.$refs.formTrainApply.resetFields();
    },
    submit(row, done, loading) {
      adddata(row).then(
        (res) => {
          // this.onLoad(this.page);
          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.dialogDisable = false;
              this.$refs.formTrainApply.resetFields();
          }
          done();
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowSave(row, done, loading) {
      add(row).then(