Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/workreport/workreport.vue
@@ -1,6 +1,12 @@
<template>
  <basic-container class="workreply">
  <basic-container
    :class="[
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
@@ -42,16 +48,17 @@
<script>
import { workreportColumn } from "./data";
import { mapState } from "vuex";
import {
  getListPage,
  remove,
  update,
  add,
  getDetail,
  getDetail
} from "@/api/workreport/workreport";
import { getDept } from "@/api/system/dept";
import { mapGetters } from "vuex";
import { getDictionaryBiz } from "@/api/system/dict";
export default {
  data() {
    return {
@@ -69,6 +76,7 @@
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      selectionList: [],
      option: {
@@ -80,6 +88,8 @@
        searchMenuSpan: 6,
        border: true, //liu
        addBtnText: "发起",
        saveBtnText: "发起",
        addTitle: "发起",
        index: true,
        stripe: true,
        viewBtn: true,
@@ -88,29 +98,35 @@
        menuWidth: 320,
        dialogClickModal: false,
        column: workreportColumn,
        ...this.$store.state.control.clearOtherBut
      },
      data: [],
      data: []
    };
  },
  computed: {
    ...mapGetters(["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),
        addBtn: this.vaildData(this.permission.workreport_add, false),
        viewBtn: this.vaildData(this.permission.workreport_view, false),
        delBtn: this.vaildData(this.permission.workreport_delete, false),
        editBtn: this.vaildData(this.permission.workreport_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ...mapState({
      userInfo: state => state.user.userInfo
    })
  },
  mounted() {},
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  methods: {
    rowSave(row, done, loading) {
      row.receivedIds = row.receivedIds.join(",");
@@ -121,11 +137,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -140,11 +156,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -154,7 +170,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -163,7 +179,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -192,7 +208,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -201,14 +217,14 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getDetail(this.form.id).then((res) => {
        getDetail(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
@@ -233,40 +249,93 @@
      ).content.user_id;
      var that = this;
      getDept(this.deptId).then((res) => {
        var deptCategory = res.data.data.deptCategory;
        deptCategory == 1
          ? (that.deptCategory = true)
          : (that.deptCategory = false);
      // getDept(this.deptId).then((res) => {
      //   var deptCategory = res.data.data.deptCategory;
      //   deptCategory == 1
      //     ? (that.deptCategory = true)
      //     : (that.deptCategory = false);
        // const { releaseTimeRange } = this.query;
        // if (that.deptCategory) {
        params["deptId"] = this.deptId;
        params["userId"] = this.userId;
        // }
        let values = {
          ...params,
      //1:保安公司  2:公安  3:培训公司
      if (
        this.userInfo.role_name == "保安公司管理员" ||
        this.userInfo.role_name == "保安"
      ) {
        const column = that.findObject(that.option.column, "category");
        var code = {
          code: "securityWorkReportCategory"
        };
        // if (releaseTimeRange) {
        //   values = {
        //     ...params,
        //     startTime: releaseTimeRange[0],
        //     endTime: releaseTimeRange[1],
        //     ...this.query,
        //   };
        //   values.releaseTimeRange = null;
        // }
        this.loading = true;
        getListPage(page.currentPage, page.pageSize, values).then((res) => {
        getDictionaryBiz(code).then(res => {
          // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=securityWorkReportCategory";
          column.dicData = res.data.data;
          const columnReceivedIds = that.findObject(
            that.option.column,
            "receivedIds"
          );
          columnReceivedIds.dicUrl =
            "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
            that.userInfo.dept_id;
          params["deptId"] = this.deptId;
          params["userId"] = this.userId;
          // }
          let values = {
            ...params
          };
          this.loading = true;
          getListPage(page.currentPage, page.pageSize, values).then(res => {
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            this.loading = false;
            this.$store.commit("setWindowSizeHeightAdd");
            this.selectionClear();
          });
        });
      } else if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        const column = that.findObject(that.option.column, "category");
        var code1 = { code: "workReportCategory" };
        getDictionaryBiz(code1).then(res => {
          // column.dicUrl = "/api/blade-system/dict-biz/dictionary?code=workReportCategory";
          column.dicData = res.data.data;
          const columnReceivedIds = that.findObject(
            that.option.column,
            "receivedIds"
          );
          columnReceivedIds.dicUrl =
            "/api/blade-system/dept/lazy-tree-users?type={{key}}&deptId=" +
            that.userInfo.dept_id;
          params["deptId"] = this.deptId;
          params["userId"] = this.userId;
          // }
          let values = {
            ...params
          };
          this.loading = true;
          getListPage(page.currentPage, page.pageSize, values).then(res => {
            const data = res.data.data;
            this.page.total = data.total;
            this.data = data.records;
            this.loading = false;
            this.$store.commit("setWindowSizeHeightAdd");
            this.selectionClear();
          });
        });
      } else if (this.userInfo.role_name == "administrator") {
        getListPage(page.currentPage, page.pageSize, params).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          this.loading = false;
          this.$store.commit("setWindowSizeHeightAdd");
          this.selectionClear();
        });
      });
    },
  },
      }
    }
  }
};
</script>