src/views/trainingRegistration/index.vue
@@ -129,6 +129,7 @@
  addExam,
} from "@/api/trainingRegistration/trainingRegistration";
import { mapGetters } from "vuex";
import { getRoleDetail } from "@/api/system/role";
export default {
  data() {
    return {
@@ -518,20 +519,42 @@
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      params = this.search;
      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;
            }
            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;
            });
        })
      })
    },
    handleImport() {
      this.excelBox = true;