Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/securityEquipment/equipments.vue
@@ -1,65 +1,68 @@
<template>
  <basic-container>
    <div
      :class="[
        'equipments',
        $store.state.control.windowWidth >= 1024 ? 'oneRowSearch' : '',
      ]"
  <basic-container
    :class="[
      'equipments',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <avue-crud
      class="tablesss"
      v-if="visible"
      :option="option"
      :data="data"
      :page.sync="page"
      ref="crudrec"
      :permission="permissionList"
      @on-load="onLoad"
      :table-loading="loading"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @row-update="rowUpdate"
      @row-del="rowDel"
      @selection-change="selectionChange"
      @refresh-change="refreshChange"
    >
      <avue-crud
        v-if="visible"
        :option="option"
        :data="data"
        :page.sync="page"
        ref="crudrec"
        @on-load="onLoad"
        :table-loading="loading"
        @row-save="rowSave"
        @search-change="searchChange"
        @search-reset="searchReset"
        @row-update="rowUpdate"
        @row-del="rowDel"
        @selection-change="selectionChange"
        @refresh-change="refreshChange"
      <template slot="menuLeft">
        <el-button
          type="danger"
          size="small"
          plain
          icon="el-icon-delete"
          v-if="permission.equipments_delete"
          @click="handleDelete"
          >删 除
        </el-button>
        <el-button
          type="success"
          size="small"
          plain
          icon="el-icon-upload2"
          v-if="permission.equipments_import"
          @click="handleImport"
          >批量导入
        </el-button>
      </template>
    </avue-crud>
    <el-dialog
      title="装备附件批量导入"
      append-to-body
      :visible.sync="excelBox"
      width="555px"
    >
      <avue-form
        :option="excelOption"
        v-model="excelForm"
        :upload-after="uploadAfter"
      >
        <template slot="menuLeft">
          <el-button
            type="danger"
            size="small"
            plain
            icon="el-icon-delete"
            @click="handleDelete"
            >删 除
          </el-button>
          <el-button
            type="success"
            size="small"
            plain
            icon="el-icon-upload2"
            @click="handleImport"
            >批量导入
        <template slot="excelTemplate">
          <el-button type="primary" @click="handleTemplate">
            点击下载<i class="el-icon-download el-icon--right"></i>
          </el-button>
        </template>
      </avue-crud>
      <el-dialog
        title="装备附件批量导入"
        append-to-body
        :visible.sync="excelBox"
        width="555px"
      >
        <avue-form
          :option="excelOption"
          v-model="excelForm"
          :upload-after="uploadAfter"
        >
          <template slot="excelTemplate">
            <el-button type="primary" @click="handleTemplate">
              点击下载<i class="el-icon-download el-icon--right"></i>
            </el-button>
          </template>
        </avue-form>
      </el-dialog>
    </div>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
@@ -67,21 +70,10 @@
import { data, column } from "./equipments";
import { getdata, adddata, update, remove } from "@/api/equipments/equipments";
import { mapGetters } from "vuex";
import { getToken } from "@/util/auth";
export default {
  props: ["fromDeptId", "windowHeight"],
  watch: {
    windowHeight() {
      if (!this.windowHeight) {
        return;
      }
      this.option.height = this.windowHeight - 320;
      this.visible = false;
      this.$nextTick(() => {
        this.visible = true;
        this.refreshChange();
      });
    },
  },
  data() {
    return {
      visible: true,
@@ -99,18 +91,18 @@
            loadText: "文件上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
              res: "data"
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/equipage/import-equipage",
            action: "/api/equipage/import-equipage"
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
            span: 24
          }
        ]
      },
      loading: true,
@@ -119,7 +111,7 @@
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize,
        ...this.$store.state.control.changePageSize
      },
      query: {},
      data: [],
@@ -137,21 +129,32 @@
        column: column,
        ...this.$store.state.control.clearOtherBut,
        labelWidth: 110,
        ...this.$store.state.control.clearOtherBut,
        ...this.$store.state.control.clearOtherBut
      },
      useifid: 266,
      useifid: 266
    };
  },
  computed: {
    ...mapGetters(["userInfo"]),
    ...mapGetters(["permission", "userInfo"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.equipments_add, false),
        viewBtn: this.vaildData(this.permission.equipments_view, true),
        delBtn: this.vaildData(this.permission.equipments_delete, false),
        editBtn: this.vaildData(this.permission.equipments_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    }
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
  },
  created() {
    if (this.windowHeight) {
@@ -178,7 +181,7 @@
      //赋值
      column.value = that.userInfo.dept_id;
      this.useifid = this.userInfo.dept_id;
    } else if (roleName == "公安管理员" || roleName == "administrator") {
    } else if (roleName == "公安管理员" || roleName == "administrator" || this.userInfo.role_name == "民警") {
      var columnDept = that.findObject(that.option.column, "deptId");
      columnDept.dicUrl =
        "/api/blade-system/dept/security_lazy-tree?jurisdiction=" +
@@ -202,7 +205,11 @@
      done();
    },
    handleTemplate() {
      window.open(`/api/equipage/export-template`);
      window.open(
        `/api/equipage/export-template?${
          this.website.tokenHeader
        }=${getToken()}`
      );
    },
    sizeChange(val) {
      this.page1.currentPage = 1;
@@ -232,15 +239,15 @@
        form["deptId"] = this.useifid;
      }
      adddata(form).then(
        (res) => {
        res => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -273,11 +280,11 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -287,7 +294,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -296,7 +303,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -311,7 +318,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -320,7 +327,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crudrec.toggleSelection();
        });
@@ -362,7 +369,7 @@
        this.openDep("deptId");
      }
      //公安局进入
      if (this.userInfo.role_name == "公安管理员") {
      if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        params["jurisdiction"] = that.userInfo.jurisdiction;
      }
@@ -370,15 +377,16 @@
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
      ).then(res => {
        // console.log(res);
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        console.log(this.data);
        this.$store.commit("setWindowSizeHeightAdd");
        // console.log(this.data);
        this.loading = false;
      });
    },
    }
  },
  mounted() {
    // this.Ourdata = data;
@@ -387,7 +395,7 @@
    // var dept_id = JSON.parse(
    //   window.localStorage.getItem("saber-userInfo")
    // ).content.dept_id;
  },
  }
};
</script>
@@ -406,4 +414,4 @@
// .el-tag--light {
//   padding: 0 !important;
// }
</style>
</style>