Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/desk/notice.vue
@@ -1,6 +1,13 @@
<template>
  <basic-container class="desk1">
  <basic-container
    :class="[
      'desk1',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      :option="option"
      :table-loading="loading"
      :data="data"
@@ -26,6 +33,7 @@
          type="danger"
          size="small"
          icon="el-icon-delete"
          v-if="permission.notice_delete"
          plain
          @click="handleDelete"
          >删 除
@@ -39,6 +47,7 @@
        <el-button
          :size="size"
          :type="type"
          v-if="permission.notice_upload"
          @click="handleUploadPage(row)"
          >附件上传
        </el-button>
@@ -58,6 +67,7 @@
import { getListPage, remove, update, add, getNotice } from "@/api/desk/notice";
import { getDept } from "@/api/system/dept";
import { mapGetters } from "vuex";
import { mapState } from "vuex";
export default {
  data() {
@@ -75,6 +85,7 @@
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      selectionList: [],
      option: {
@@ -85,28 +96,33 @@
        tip: false,
        searchShow: true,
        searchMenuSpan: 6,
        border: false,
        border: true,
        index: true,
        stripe: true,
        viewBtn: true,
        selection: true,
        excelBtn: false,
        addBtnText: "发布",
        addTitle: "发布",
        saveBtnText: "发布",
        menuWidth: 320,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "通知标题",
            prop: "title",
            span: 24,
            searchSpan: 4,
            row: true,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入通知标题",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "通知类型",
@@ -114,7 +130,7 @@
            dicUrl: "/api/blade-system/dict/dictionary?code=notice",
            props: {
              label: "dictValue",
              value: "dictKey",
              value: "dictKey"
            },
            dataType: "number",
            slot: true,
@@ -123,14 +139,14 @@
            defaultValue: "1",
            prop: "category",
            search: true,
            searchSpan:5,
            searchSpan: 4,
            rules: [
              {
                required: true,
                message: "请输入通知类型",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "发布单位",
@@ -139,7 +155,7 @@
            dicUrl: "/api/blade-system/dept/lazy-tree",
            props: {
              label: "title",
              value: "id",
              value: "id"
            },
            addDisplay: false,
            editDisplay: false,
@@ -147,29 +163,30 @@
              {
                required: true,
                message: "所属组织机构",
                trigger: "click",
              },
            ],
                trigger: "click"
              }
            ]
          },
          {
            label: "通知时间",
            prop: "releaseTimeRange",
            type: "datetime",
            format: "yyyy-MM-dd hh:mm:ss",
            valueFormat: "yyyy-MM-dd hh:mm:ss",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            searchSpan: 6,
            rules: [
              {
                required: true,
                message: "请输入通知时间",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "通知日期",
@@ -181,9 +198,9 @@
              {
                required: true,
                message: "请输入通知日期",
                trigger: "click",
              },
            ],
                trigger: "click"
              }
            ]
          },
          {
            label: "通知内容",
@@ -193,95 +210,104 @@
              action: "/api/blade-resource/oss/endpoint/put-file",
              props: {
                res: "data",
                url: "link",
              },
                url: "link"
              }
            },
            hide: true,
            minRows: 6,
            span: 24,
          },
        ],
            span: 24
          }
        ]
      },
      data: [],
      data: []
    };
  },
  computed: {
    ...mapGetters(["permission"]),
    ...mapGetters(["userInfo", "permission"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permissionAdd, true),
        viewBtn: this.vaildData(this.permissionView, true),
        delBtn: this.vaildData(this.permissionDelete, true),
        editBtn: this.vaildData(this.permissionEdit, true),
        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)
      };
    },
    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.getDeptInfo(this.userInfo.dept_id);
    this.$store.commit("setWindowSizeHeightAdd");
  },
  methods: {
    //获取当前用户部门信息
    getDeptInfo(deptId) {
      var that = this;
      getDept(deptId).then((res) => {
      getDept(deptId).then(res => {
        var deptCategory = res.data.data.deptCategory;
        deptCategory == 1
          ? (that.deptCategory = true)
          : (that.deptCategory = false);
        // if (that.deptCategory) {
          that.permissionAdd = this.permission.notice_add;
          that.permissionView = this.permission.notice_view;
          that.permissionDelete = this.permission.notice_delete;
          that.permissionEdit = this.permission.notice_edit;
        // }
      });
    },
    //跳转到附近列表页面
    //跳转到附件列表页面
    handleUploadPage(row) {
      this.$router.push({
        path: `/resource/attach`,
        path: `/resource/uploadNotice`,
        query: {
          deptId: row.deptId,
        },
          noticeId: row.id
        }
      });
    },
    rowSave(row, done, loading) {
      row.category = 1;
      if (this.deptCategory) {
        row.category = 1;
      } else {
        row.category = 2;
      }
      row["type"] = 1;
      row.deptId = this.deptId;
      add(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowUpdate(row, index, done, loading) {
      row.category = 1;
      // if (this.deptCategory) {
      //   row.category = 1;
      // }else{
      //   row.category = 2;
      // }
      row.deptId = this.deptId;
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -291,7 +317,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -300,7 +326,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -329,7 +355,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -338,14 +364,14 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crud.toggleSelection();
        });
    },
    beforeOpen(done, type) {
      if (["edit", "view"].includes(type)) {
        getNotice(this.form.id).then((res) => {
        getNotice(this.form.id).then(res => {
          this.form = res.data.data;
        });
      }
@@ -367,61 +393,51 @@
      //获取当前用户部门信息,判断是否为公安,如果是公安,则只能查看公告信息
      var that = this;
      getDept(this.deptId).then((res) => {
      getDept(this.deptId).then(res => {
        var deptCategory = res.data.data.deptCategory;
        deptCategory == 1
          ? (that.deptCategory = true)
          : (that.deptCategory = false);
        // if (that.deptCategory) {
          that.permissionAdd = this.permission.notice_add;
          that.permissionView = this.permission.notice_view;
          that.permissionDelete = this.permission.notice_delete;
          that.permissionEdit = this.permission.notice_edit;
        // }
        if (
          this.userInfo.role_name == "保安公司管理员" ||
          this.userInfo.role_name == "分公司管理员" ||
          this.userInfo.role_name == "保安" ||
          this.userInfo.role_name == "装备管理员"
        ) {
          params["deptId"] = this.userInfo.dept_id;
        }else{
          params["jurisdiction"] = this.userInfo.jurisdiction;
        }
        const { releaseTimeRange } = this.query;
        // if (that.deptCategory) {
          params["deptId"] = this.deptId;
          params["jurisdiction"] = this.jurisdiction;
        // }
        params["type"] = 1;
        let values = {
          ...params,
          ...params
        };
        if (releaseTimeRange) {
          values = {
            ...params,
            startTime: releaseTimeRange[0],
            endTime: releaseTimeRange[1],
            ...this.query,
            ...this.query
          };
          values.releaseTimeRange = null;
        }
        this.loading = true;
        getListPage(page.currentPage, page.pageSize, values).then((res) => {
        getListPage(page.currentPage, page.pageSize, values).then(res => {
          const data = res.data.data;
          this.page.total = data.total;
          this.data = data.records;
          // this.data.forEach((item) => {
          //   if (item.category == 2) {
          //     that.option.addBtn = false;
          //     that.option.editBtn = false;
          //     that.option.delBtn = false;
          //   }
          //   if (item.category == 1) {
          //     that.option.addBtn = true;
          //     that.option.editBtn = true;
          //     that.option.delBtn = true;
          //   }
          // });
          this.loading = false;
          this.$store.commit("setWindowSizeHeightAdd");
          this.selectionClear();
        });
      });
    },
  },
    }
  }
};
</script>
<style>
</style>
<style></style>