Administrator
2022-04-11 79d9fc857559982b00b68b2d709807bdc4cd286f
src/views/dispatch/dispatch.vue
@@ -1,12 +1,20 @@
<template>
  <div class="dispatch">
  <basic-container
    :class="[
      'dispatch',
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : ''
    ]"
  >
    <!-- <avue-tabs :option="optionTABS" @change="handleChangeTABS"></avue-tabs>
    <span v-if="typeTABS.prop === 'tab1'"> -->
    <avue-crud
      class="tablesss"
      :option="option"
      :data="data"
      :page.sync="page"
      ref="crudrec"
      :permission="permissionList"
      @on-load="onLoad"
      :table-loading="loading"
      @row-save="rowSave"
@@ -24,11 +32,46 @@
          size="small"
          plain
          icon="el-icon-delete"
          v-if="permission.dispatch_delete"
          @click="handleDelete"
          >删 除
        </el-button>
        <el-button
          type="success"
          size="small"
          plain
          icon="el-icon-upload2"
          v-if="permission.dispatch_import"
          @click="handleImport"
          >批量导入
        </el-button>
      </template>
      <template slot-scope="{ row }" slot="jurisdiction">
        {{ row.jurisdiction == -1 ? "" : row.jurisdiction }}
      </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>
    <!-- </span>
    <span v-else-if="typeTABS.prop === 'tab2'">
      <avue-crud
@@ -59,25 +102,24 @@
      </avue-crud>
    </span> -->
    <!-- <span v-else-if="typeTABS.prop === 'tab3'">选项卡内容3</span> -->
  </div>
</template>
  </basic-container>
</template>
<script>
import { data, column, column1 } from "./data";
import {
  getdata,
  adddata,
  update,
  remove,
  getdata1,
  adddata1,
  update1,
  remove1,
} from "@/api/dispatch/dispatch";
import { getdata, adddata, update, remove } from "@/api/dispatch/dispatch";
import { mapGetters } from "vuex";
import { mapState } from "vuex";
import { getToken } from "@/util/auth";
export default {
  data() {
    var phones = (rule, value, callback) => {
      window.yanzhengphons = /^1([358][0-9]|4[579]|66|7[0135678]|9[89])[0-9]{8}$/;
      if (!yanzhengphons.test(value)) {
        callback(new Error("请输入正确电话"));
      } else {
        callback();
      }
    };
    return {
      typeTABS: {}, //标签页
      deptId: "",
@@ -86,19 +128,19 @@
          {
            icon: "el-icon-info",
            label: "派遣服务公司登记",
            prop: "tab1",
            prop: "tab1"
          },
          {
            icon: "el-icon-info",
            label: "派遣记录",
            prop: "tab2",
          },
            prop: "tab2"
          }
          // {
          //   icon: "el-icon-info",
          //   label: "选项卡3",
          //   prop: "tab3",
          // },
        ],
        ]
      },
      loading: true, //派遣服务公司登记
@@ -107,12 +149,65 @@
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize
      },
      query: {},
      data: [],
      excelBox: false,
      excelForm: {},
      excelOption: {
        submitBtn: false,
        emptyBtn: false,
        column: [
          {
            label: "模板上传",
            prop: "excelFile",
            type: "upload",
            drag: true,
            loadText: "模板上传中,请稍等",
            span: 24,
            propsHttp: {
              res: "data"
            },
            tip: "请上传 .xls,.xlsx 标准格式文件",
            action: "/api/dispatcherUnit/import-dispatcherUnit"
          },
          // {
          //     label: "数据覆盖",
          //     prop: "isCovered",
          //     type: "switch",
          //     align: "center",
          //     width: 80,
          //     dicData: [
          //     {
          //         label: "否",
          //         value: 0,
          //     },
          //     {
          //         label: "是",
          //         value: 1,
          //     },
          //     ],
          //     value: 0,
          //     slot: true,
          //     rules: [
          //     {
          //         required: true,
          //         message: "请选择是否覆盖",
          //         trigger: "blur",
          //     },
          //     ],
          // },
          {
            label: "模板下载",
            prop: "excelTemplate",
            formslot: true,
            span: 24
          }
        ]
      },
      option: {
        tip: false,
        // card: true,
        index: true,
        searchSize: "mini",
        searchMenuSpan: 6,
@@ -120,77 +215,338 @@
        menuWidth: 160,
        align: "center",
        selection: true,
        column: column,
        // group: [
        //   {
        //     label: "基础信息",
        //     prop: "baseInfo",
        //     icon: "el-icon-user-solid",
        //     column: [
        //       {
        //         label: "所属保安单位",
        //         prop: "tenantId",
        //         type: "tree",
        //         dicUrl: "/api/blade-system/tenant/select",
        //         props: {
        //           label: "tenantName",
        //           value: "tenantId",
        //         },
        //         hide: !website.tenantMode,
        //         addDisplay: website.tenantMode,
        //         editDisplay: website.tenantMode,
        //         viewDisplay: website.tenantMode,
        //         rules: [
        //           {
        //             required: true,
        //             message: "请输入所属保安单位",
        //             trigger: "click",
        //           },
        //         ],
        //         span: 24,
        //       },
        //     ],
        //   },
        // ],
        // menu: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "派遣单位名称",
            prop: "name",
            search: true,
            searchLabelWidth: 110,
            overHidden: true,
            searchSpan: 4,
            width: 210,
            labelWidth: 138,
            rules: [
              {
                required: true,
                message: "请输入派遣单位名称",
                trigger: "click"
              }
            ]
          },
          {
            label: "派遣单位类型",
            prop: "district",
            type: "select",
            search: false,
            dicUrl:
              "/api/blade-system/dict-biz/dictionary?code=dispatcherUnitType",
            props: {
              label: "dictValue",
              value: "dictKey"
            },
            searchLabelWidth: 110,
            overHidden: true,
            searchSpan: 4,
            width: 100,
            labelWidth: 138,
            rules: [
              {
                required: true,
                message: "请选择派遣单位类型",
                trigger: "click"
              }
            ],
            dataType: "number"
          },
          {
            label: "企业名称",
            prop: "deptId",
            type: "tree",
            overHidden: true,
            dicUrl: "",
            props: {
              label: "title",
              value: "id"
            },
            rules: [
              {
                required: true,
                message: "请选择企业名称",
                trigger: "click"
              }
            ],
            labelWidth: 138,
            width: 180,
            searchLabelWidth: 80,
            search: true,
            searchSpan: 4
          },
          {
            label: "保安服务类型",
            prop: "serveType",
            // search: true,
            searchLabelWidth: 110,
            searchSpan: 4,
            overHidden: true,
            // span: 12,
            labelWidth: 138
          },
          {
            label: "合同生效时间",
            prop: "releaseTimeRange",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchValue: [this.getStartTime(), this.getEndTime()],
            searchRange: true,
            searchSpan: 5,
            searchLabelWidth: 110,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            rules: [
              {
                required: true,
                message: "请输入时间",
                trigger: "blur"
              }
            ]
          },
          {
            label: "所属辖区",
            prop: "jurisdiction",
            hide: true,
            searchLabelWidth: 80,
            search: true,
            searchSpan: 4,
            overHidden: true,
            labelWidth: 138,
            parent: false,
            type: "tree",
            dicUrl: "/api/jurisdiction/lazy-tree",
            props: {
              label: "title",
              value: "id"
            },
            checkStrictly: true,
            slot: true,
            rules: [
              {
                required: false,
                message: "请选择所属辖区",
                trigger: "click"
              }
            ]
          },
          {
            label: "所属辖区",
            prop: "jurisdictionName",
            // multiple: true,
            searchLabelWidth: 80,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            overHidden: true,
            labelWidth: 138,
            width: 100,
            type: "tree",
            dicUrl: "/api/jurisdiction/lazy-tree",
            props: {
              label: "title",
              value: "id"
            },
            checkStrictly: true,
            slot: true,
            rules: [
              {
                required: false,
                message: "请选择所属辖区",
                trigger: "click"
              }
            ]
          },
          {
            label: " 派遣单位地址",
            prop: "address",
            labelWidth: 138
          },
          {
            label: "合同开始时间",
            prop: "startTime",
            labelWidth: 138,
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            // search: true,
            rules: [
              {
                required: true,
                message: "请选择开始时间",
                trigger: "click"
              }
            ]
          },
          {
            label: "合同结束时间",
            prop: "endTime",
            labelWidth: 138,
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            // search: true,
            rules: [
              {
                required: true,
                message: "请选择结束时间",
                trigger: "click"
              }
            ]
            // searchSpan: 4,
            // overHidden: true
          },
          {
            label: " 派遣单位联系人",
            prop: "linkman",
            labelWidth: 138
            // rules: [
            //   {
            //     required: true,
            //     message: "请输入派遣单位联系人",
            //     trigger: "click",
            //   },
            // ],
          },
          {
            label: "派遣单位联系方式",
            prop: "phone",
            labelWidth: 138,
            width: 130
          },
          {
            label: " 负责人",
            prop: "securityLinkman",
            labelWidth: 138,
            rules: [
              {
                required: true,
                message: "请输入负责人",
                trigger: "click"
              }
            ]
          },
          {
            label: "负责人联系方式",
            prop: "cell",
            labelWidth: 138,
            width: 110,
            rules: [
              {
                required: true,
                message: "请输入联系方式",
                trigger: "click"
              }
              // {
              //   validator: phones,
              //   trigger: ["change", "blur"],
              // },
            ]
          },
          {
            label: "派遣保安员数",
            prop: "num",
            type: "number",
            labelWidth: 138,
            width: 110,
            rules: [
              {
                required: true,
                message: "请输入派遣保安员数",
                trigger: "click"
              }
            ]
          }
        ]
      },
      // loading1: true, //派遣记录
      // selectionList1: [],
      // page1: {
      //   pageSize: 10,
      //   currentPage: 1,
      //   total: 0,
      // },
      // query1: {},
      // data1: [],
      // option1: {
      //   card: true,
      //   searchSize: "mini",
      //   searchMenuSpan: 6,
      //   height: 547,
      //   menuWidth: 160,
      //   align: "center",
      //   selection: true,
      //   column: column1,
      // },
      useifid: 266
    };
  },
  created() {
    var that = this;
    var roleName = this.userInfo.role_name;
    // if (this.userInfo.role_name == "保安公司管理员") {
    //   const deptColumn = this.findObject(this.option.column, "deptId");
    //   deptColumn.search = false;
    //   deptColumn.addDisplay = false;
    //   deptColumn.editDisplay = false;
    //   deptColumn.viewDisplay = false;
    //   deptColumn.hide = true;
    //   this.useifid = this.userInfo.dept_id;
    // }
    if (
      roleName == "保安公司管理员" ||
      roleName == "保安" ||
      roleName == "分公司管理员"
    ) {
      //查询保安单位信息(包含子级)
      const column = this.findObject(this.option.column, "deptId");
      // column.search = false;
      //默认全部展开
      column.defaultExpandAll = true;
      column.dicUrl =
        "/api/blade-system/dept/security_lazy-tree?deptId=" +
        this.userInfo.dept_id;
      //赋值
      column.value = that.userInfo.dept_id;
      this.useifid = this.userInfo.dept_id;
    } else if (roleName == "公安管理员" || roleName == "administrator" || roleName == "民警") {
      var columnDept = that.findObject(that.option.column, "deptId");
      columnDept.dicUrl =
        "/api/blade-system/dept/security_lazy-tree?jurisdiction=" +
        that.userInfo.jurisdiction;
    } else {
      //查询保安单位信息(包含子级)
      const column = this.findObject(this.option.column, "deptId");
      // column.search = false;
      //默认全部展开
      column.dicUrl = "/api/blade-system/dept/security_lazy-tree";
    }
  },
  computed: {
    ...mapGetters(["userInfo"]),
    ...mapGetters(["permission", "userInfo"]),
    permissionList() {
      return {
        addBtn: this.vaildData(this.permission.dispatch_add, false),
        viewBtn: this.vaildData(this.permission.dispatch_view, true),
        delBtn: this.vaildData(this.permission.dispatch_delete, false),
        editBtn: this.vaildData(this.permission.dispatch_edit, false)
      };
    },
    ids() {
      let ids = [];
      this.selectionList.forEach((ele) => {
      this.selectionList.forEach(ele => {
        ids.push(ele.id);
      });
      return ids.join(",");
    },
    ids1() {
      let ids1 = [];
      this.selectionList1.forEach((ele) => {
      this.selectionList1.forEach(ele => {
        ids1.push(ele.id);
      });
      return ids1.join(",");
    },
    ...mapState({
      userInfo: state => state.user.userInfo
    })
  },
  methods: {
    handleChangeTABS(column) {
      this.typeTABS = column;
@@ -218,23 +574,19 @@
      //   this.$message.success("页码" + val);
    },
    rowSave(form, done, loading) {
      // var that = this;
      // var form = this.data[0];
      // delete form.id;
      // for (var k = 0; k < 13; k++) {
      form["deptId"] = this.userInfo.dept_id;
      // form["tenantName"] = form.this.userInfo.user_name;
      if (this.useifid != 266) {
        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();
        }
@@ -252,17 +604,19 @@
      this.onLoad(this.page);
    },
    rowUpdate(row, index, done, loading) {
      console.log(row);
      if (this.useifid != 266) {
        row["deptId"] = this.useifid;
      }
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          done();
        },
        (error) => {
        error => {
          window.console.log(error);
          loading();
        }
@@ -272,7 +626,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(row.id);
@@ -281,7 +635,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
        });
    },
@@ -296,7 +650,7 @@
      this.$confirm("确定将选择数据删除?", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
        type: "warning"
      })
        .then(() => {
          return remove(this.ids);
@@ -305,7 +659,7 @@
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
            message: "操作成功!"
          });
          this.$refs.crudrec.toggleSelection();
        });
@@ -314,171 +668,105 @@
      this.onLoad(this.page, this.query);
    },
    rowClick(row) {
      // console.log(row);
      window.localStorage.setItem("paqiandata", JSON.stringify(row));
      this.$router.push({
        path: "/dispatchChild",
        // redirect: { name: "foo" },
        // query: { row: row },
        query: { rowdispatch: "fromDispatch" },
        // params: { row: row.identificationnumber },
        query: { rowdispatch: "fromDispatch" }
      });
    },
    getStartTime() {
      if (
        this.$route.query.startTime != undefined &&
        this.$route.query.startTime != null &&
        this.$route.query.startTime != ""
      ) {
        return this.$route.query.startTime;
      }
      return "";
    },
    getEndTime() {
      if (
        this.$route.query.endTime != undefined &&
        this.$route.query.endTime != null &&
        this.$route.query.endTime != ""
      ) {
        return this.$route.query.endTime;
      }
      return "";
    },
    onLoad(page, params = {}) {
      var that = this;
      this.loading = true;
      var values;
      const { releaseTimeRange } = this.query;
      if (releaseTimeRange) {
        values = {
          ...params,
          beginTime: releaseTimeRange[0],
          overTime: releaseTimeRange[1],
          ...this.query
        };
        // values.releaseTimeRange = null;
      } else {
        values = {
          ...params,
          ...this.query
        };
      }
      if (this.useifid != 266) {
        values["deptId"] = this.useifid;
      }
      if (this.userInfo.role_name == "公安管理员" || this.userInfo.role_name == "民警") {
        values["jurisdiction"] = that.userInfo.jurisdiction;
      }
      getdata(
        page.currentPage,
        page.pageSize,
        Object.assign(params, this.query)
      ).then((res) => {
        // console.log(res);
        // Object.assign(params, this.query)
        values
      ).then(res => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        for (var k in this.data) {
          this.data[k]["deptId"] = that.userInfo.dept_id;
          // this.data[k]["deptId"] = that.userInfo.dept_id;
          this.data[k]["tenantName"] = that.userInfo.user_name;
          // console.log(this.data[k], 123456);
          if (this.data[k].num == -1) {
            this.data[k].num = null;
          }
          if (this.data[k].district == -1) {
            this.data[k].district = null;
          }
        }
        window.localStorage.setItem("paqiandataS", JSON.stringify(this.data));
        this.$store.commit("setWindowSizeHeightAdd");
        this.loading = false;
      });
    },
    //派遣服务公司登记
    //派遣记录
    // sizeChange1(val) {
    //   this.page1.currentPage = 1;
    //   this.page1.pageSize = val;
    //   // this.getData();
    //   this.onLoad1(this.page1, this.query1);
    //   //   this.$message.success("行数" + val);
    // },
    // currentChange1(val) {
    //   this.page1.currentPage = val;
    //   // this.getData();
    //   this.onLoad1(this.page1, this.query1);
    //   //   this.$message.success("页码" + val);
    // },
    // rowSave1(form, done, loading) {
    //   var that = this;
    //   var form = this.data1[0];
    //   delete form.id;
    //   for (var k = 0; k < 13; k++) {
    //     adddata1(form).then(
    //       (res) => {
    //         this.onLoad1(this.page1);
    //         this.$message({
    //           type: "success",
    //           message: "操作成功!",
    //         });
    //         done();
    //       },
    //       (error) => {
    //         window.console.log(error);
    //         loading();
    //       }
    //     );
    //   }
    // },
    // searchChange1(params, done) {
    //   this.query1 = params;
    //   this.page1.currentPage = 1;
    //   this.onLoad1(this.page1, params);
    //   done();
    // },
    // searchReset1() {
    //   this.query = {};
    //   this.onLoad1(this.page1);
    // },
    // rowUpdate1(row, index, done, loading) {
    //   console.log(row);
    //   update1(row).then(
    //     () => {
    //       this.onLoad1(this.page1);
    //       this.$message({
    //         type: "success",
    //         message: "操作成功!",
    //       });
    //       done();
    //     },
    //     (error) => {
    //       window.console.log(error);
    //       loading();
    //     }
    //   );
    // },
    // rowDel1(row) {
    //   this.$confirm("确定将选择数据删除?", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       return remove1(row.id);
    //     })
    //     .then(() => {
    //       this.onLoad1(this.page1);
    //       this.$message({
    //         type: "success",
    //         message: "操作成功!",
    //       });
    //     });
    // },
    // selectionChange1(list) {
    //   this.selectionList1 = list;
    //   console.log(this.selectionList1.length);
    // },
    // handleDelete1() {
    //   console.log(this.selectionList1);
    //   if (this.selectionList1.length === 0) {
    //     this.$message.warning("请选择至少一条数据");
    //     return;
    //   }
    //   this.$confirm("确定将选择数据删除?", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //     type: "warning",
    //   })
    //     .then(() => {
    //       return remove1(this.ids1);
    //     })
    //     .then(() => {
    //       this.onLoad1(this.page1);
    //       this.$message({
    //         type: "success",
    //         message: "操作成功!",
    //       });
    //       this.$refs.crudrec1.toggleSelection();
    //     });
    // },
    // refreshChange1() {
    //   // console.log(4534)
    //   this.onLoad1(this.page1, this.query1);
    // },
    // //
    // onLoad1(page, params = {}) {
    //   this.loading1 = true;
    //   // console.log(page);
    //   getdata1(
    //     page.currentPage,
    //     page.pageSize,
    //     Object.assign(params, this.query)
    //   ).then((res) => {
    //     // console.log(res);
    //     const data = res.data.data;
    //     this.page1.total = data.total;
    //     this.data1 = data.records;
    //     console.log(this.data1, 1);
    //     this.loading1 = false;
    //   });
    // },
    //派遣记录
    handleTemplate() {
      window.open(
        `/api/dispatcherUnit/export-template?${
          this.website.tokenHeader
        }=${getToken()}&`
      );
    },
    handleImport() {
      this.excelBox = true;
    },
    uploadAfter(res, done, loading, column) {
      window.console.log(column);
      this.excelBox = false;
      this.refreshChange();
      done();
    }
  },
  mounted() {
    this.$store.commit("setWindowSizeHeightAdd");
    this.typeTABS = this.optionTABS.column[0];
  },
  }
};
</script>
@@ -500,4 +788,4 @@
.el-collapse-item {
  padding-top: 15px !important;
}
</style>
</style>