Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/securityUnit/armedEscort.vue
@@ -1,10 +1,635 @@
<template>
  <div>武装压运公司</div>
  <basic-container>
    <div
      :class="[
        'securityUnit',
        $store.state.control.windowWidth >= 1024 ? 'oneRowSearch' : '',
      ]"
    >
      <avue-crud
        :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"
      >
        <!-- @row-click="rowClick" -->
        <template slot-scope="{ row }" slot="znum">
          <el-tag
            class="rowClickSelf"
            @click="rowClickSelf(row)"
            title="点击查看保安人员情况"
            >{{ row.znum }}</el-tag
          >
        </template>
        <template slot-scope="{ type, size, row }" slot="menu">
          <el-button
            icon="el-icon-s-custom"
            :size="size"
            :type="type"
            @click.stop="rowClick(row)"
            >查看
          </el-button>
          <el-button
            :size="size"
            :type="type"
            @click="handleUploadPage(row)"
            icon="el-icon-circle-check"
            >附件上传
          </el-button>
        </template>
        <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="handleImport1"
            >批量导入
          </el-button>
        </template>
      </avue-crud>
    </div>
    <el-dialog
      title="保安单位导入"
      append-to-body
      :visible.sync="excelBox1"
      width="555px"
    >
      <avue-form
        :option="excelOption1"
        v-model="excelForm1"
        :upload-after="uploadAfter1"
      >
        <template slot="excelTemplate">
          <el-button type="primary" @click="handleTemplate1">
            点击下载<i class="el-icon-download el-icon--right"></i>
          </el-button>
        </template>
      </avue-form>
    </el-dialog>
  </basic-container>
</template>
<script>
export default {};
import { column, column0, column1, column2 } from "./data";
import {
  getdata,
  adddata,
  update,
  remove,
} from "@/api/securityUnit/securityUnit";
import { mapGetters } from "vuex";
export default {
  data() {
    return {
      excelBox1: false,
      excelForm1: {},
      excelOption1: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "文件上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "文件上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data",
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/information/import-informaton",
          },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24,
          },
        ],
      },
      loading: true, //保安单位基本信息
      selectionList: [],
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize,
      },
      treeData: [],
      treeOption: {
        title: "我是标题",
        filterText: "搜索关键字自定义",
        defaultExpandAll: true,
        addBtn: false,
        menu: false,
        size: "small",
        formOption: {
          labelWidth: 100,
          column: [
            {
              label: "自定义项",
              prop: "label",
            },
          ],
        },
        props: {
          labelText: "标题",
          label: "title",
          value: "id",
          children: "children",
        },
      },
      forms: false,
      noshehuibianma: 0,
      nobumen: 0,
      query: {},
      data: [],
      option: {
        index: true,
        addBtn: true,
        tip: false,
        searchSize: "mini",
        searchMenuSpan: 6,
        height: 583,
        menuWidth: 275,
        border: true,
        align: "center",
        selection: true,
        column: [
          {
            label: "企业名称",
            prop: "enterprisename",
            search: true,
            searchSpan: 4,
            labelWidth: 145,
            minWidth: 160,
            rules: [
              {
                required: true,
                message: "请选择企业名称",
                trigger: "click",
              },
            ],
            overHidden: true,
          },
          {
            label: "所属辖区",
            prop: "jurisdiction",
            //父节点不能选
            parent: false,
            labelWidth: 145,
            type: "tree",
            dicUrl: "/api//jurisdiction/lazy-trees",
            props: {
              label: "title",
              value: "id",
            },
            rules: [
              {
                required: false,
                message: "请选择所属辖区",
                trigger: "click",
              },
            ],
            overHidden: true,
          },
          {
            label: "法定代表人",
            prop: "representative",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: false,
                message: "请输入法定代表人",
                trigger: "blur",
              },
            ],
          },
          {
            label: "法定代表人电话",
            prop: "representativecell",
            span: 12,
            labelWidth: 145,
            disabled: false,
            rules: [
              {
                required: false,
                message: "请输入法定代表人电话",
                trigger: "blur",
              },
            ],
          },
          {
            label: "联系人",
            prop: "contacts",
            labelWidth: 145,
            hide: true,
          },
          {
            label: "联系电话",
            prop: "contactscell",
            labelWidth: 145,
            hide: true,
          },
          {
            label: "保安人数",
            labelWidth: 145,
            prop: "znum",
            searchSpan: 4,
            addDisabled: false,
            addDisplay: false,
            editDisabled: false,
            editDisplay: false,
            viewDisabled: false,
            viewDisplay: false,
            searchLabelWidth: 100,
          },
          {
            label: "派遣人数",
            labelWidth: 145,
            prop: "pnum",
            addDisabled: false,
            addDisplay: false,
            editDisabled: false,
            editDisplay: false,
            viewDisabled: false,
            viewDisplay: false,
            searchSpan: 4,
            searchLabelWidth: 100,
          },
          {
            label: "持证人数",
            labelWidth: 145,
            prop: "cnum",
            addDisabled: false,
            addDisplay: false,
            editDisabled: false,
            editDisplay: false,
            viewDisabled: false,
            viewDisplay: false,
            searchSpan: 4,
            searchLabelWidth: 100,
          },
          {
            label: "企业属性",
            prop: "stats",
            type: "tree",
            hide: true,
            labelWidth: 145,
            dicUrl: "/api/blade-system/dict-biz/dictionary?code=stats",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            rules: [
              {
                required: true,
                message: "请选择企业属性",
                trigger: "click",
              },
            ],
          },
          {
            label: "注册地址",
            prop: "address",
            labelWidth: 145,
            // search: true,
            hide: true,
          },
          {
            label: "注册时间",
            prop: "establishtime",
            span: 12,
            labelWidth: 145,
            disabled: true,
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            // 表单新增时是否禁止
            addDisabled: false,
            // 表单新增时是否可见
            addDisplay: false,
            // 表单新增时是否为查看模式
            addDetail: false,
            // 表单编辑时是否禁止
            editDisabled: false,
            // 表单编辑时是否可见
            editDisplay: false,
            // 表单编辑时是否为查看模式
            editDetail: false,
            rules: [
              {
                required: false,
                message: "请选择注册时间",
                trigger: "blur",
              },
            ],
          },
          {
              label: "办公地址",
              prop: "industry",
              span: 12,
              labelWidth: 145,
              disabled: false,
              hide:true,
              rules: [{
                  required: false,
                  message: "请选择办公地址",
                  trigger: "blur",
              }, ],
          },
          {
            label: "登记机关",
            prop: "registration",
            // search: true,
            labelWidth: 145,
            // width: 88,
            overHidden: true,
            hide: true,
          },
        ],
        ...this.$store.state.control.clearOtherBut,
      },
    };
  },
  created() {
    const column = this.findObject(this.option.column, "stats");
    column.value = "3";
    column.editDisabled = true;
    column.addDisabled = true;
    if(this.userInfo.role_name == "administrator" ){
      column.editDisabled = false;
      column.addDisabled = false;
    }
  },
  computed: {
    ...mapGetters(["userInfo"]),
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
        ids.push(ele.creditcode);
      });
      return ids.join(",");
    },
    ids1() {
      let ids1 = [];
      this.selectionList.forEach((ele) => {
        ids1.push(ele.departmentid);
      });
      return ids1.join(",");
    },
    haveID() {
      return this.obj0.creditcode;
    },
  },
  methods: {
    rowClickSelf(val) {
      this.$router.push({
        path: "/securityGuardOnce/index",
        query: { departmentid: val.departmentid },
      });
    },
    handleImport1() {
      this.excelBox1 = true;
    },
    uploadAfter1(res, done, loading, column) {
      window.console.log(column);
      this.excelBox1 = false;
      // this.refreshChange();
      done();
    },
    handleTemplate1() {
      window.open(`/api/examSubjectChoices/export-template`);
    },
    //保安单位基本信息
    sizeChange(val) {
      this.page1.currentPage = 1;
      this.page1.pageSize = val;
      // this.getData();
      this.onLoad(this.page, this.query);
      //   this.$message.success("行数" + val);
    },
    currentChange(val) {
      this.page1.currentPage = val;
      // this.getData();
      this.onLoad(this.page, this.query);
      //   this.$message.success("页码" + val);
    },
    rowSave(form, done, loading) {
      form["createUserId"] = this.userInfo.Id;
      adddata(form).then((res) => {
        if (res.data.success) {
          this.$message({
            message: "操作成功",
            type: "success",
          });
          this.refreshChange();
          done();
          this.forms = false;
        } else {
          this.$message({
            message: "操作失败",
            type: "warning",
          });
          done();
        }
      });
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    rowUpdate(row, index, done, loading) {
      delete row.tenantid;
      delete row.regstsat;
      console.log(row, 0);
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowDel(row) {
      this.$confirm(
        "该操作将会把保安员数据一并删除,不可恢复!确定将选择公司删除?",
        {
          confirmButtonText: "确定",
          cancelButtonText: "取消",
          type: "warning",
        }
      )
        .then(() => {
          console.log(row);
          return remove(row.creditcode, row.departmentid).then((res) => {
            this.refreshChange();
          });
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
        });
    },
    selectionChange(list) {
      this.selectionList = list;
    },
    handleDelete() {
      if (this.selectionList.length === 0) {
        this.$message.warning("请选择至少一条数据");
        return;
      }
      this.$confirm("确定批量将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          // console.log(this.ids);
          return remove(this.ids, this.ids1);
        })
        .then(() => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          this.$refs.crudrec.toggleSelection();
        })
        .catch((res) => {});
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    rowClick(row) {
      window.localStorage.setItem("danweidata", JSON.stringify(row));
      var data = JSON.stringify(row);
      this.$router.push({
        path: "/securityUnitChild",
        query: { data: data },
      });
    },
    //跳转到附近列表页面
    handleUploadPage(row) {
      this.$router.push({
        path: `/resource/attachCopy`,
        query: {
          deptId: row.departmentid,
          enterprisename: row.enterprisename,
        },
      });
    },
    onLoad(page, params = {}) {
      if (this.userInfo.role_id == "1414840172333842433") {
        console.log("是公安add jurisdiction");
        params["jurisdiction"] = this.userInfo.jurisdiction;
      }
      params["stats"] = "3";
      this.loading = true;
      getdata(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        window.localStorage.setItem("danweidataS", JSON.stringify(this.data));
        console.log(this.data);
        this.loading = false;
      });
    },
  },
  mounted() {},
};
</script>
<style>
</style>
<style lang="scss">
.securityUnit {
  width: 100%;
  height: 100%;
  //   border: 1px solid #000;
  box-sizing: border-box;
}
.lod {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba($color: #000000, $alpha: 0.5);
  padding: 100px 0 0 0;
  z-index: 500 !important;
  display: flex;
  // align-items: center;
  justify-content: center;
  .trees {
    z-index: 501 !important;
    position: absolute;
    width: 15%;
    top: 100px;
    left: 0;
    // display: none;
  }
  .lod-in {
    width: 70%;
    height: auto;
    background-color: transparent;
    // padding: 10px 0 0 0;
  }
  .el-collapse-item {
    padding-top: 15px !important;
  }
}
.el-collapse {
  border-top: 1px solid transparent !important;
}
.rowClickSelf {
  &:hover {
    cursor: pointer;
  }
}
</style>