zhongrj
2024-03-27 cc1c0a396698648256c350f6f0fe2cb2f0b02c7e
src/views/statisticalQueryManagement/businessStatistics.vue
@@ -1,70 +1,121 @@
<template>
  <basic-container>
    <avue-crud
      :option="tableOption"
      :table-loading="loading"
      :data="tableData"
      :page.sync="page"
      :permission="permissionList"
      ref="crud"
      @row-update="rowUpdates"
      @row-save="rowSave"
      @search-change="searchChange"
      @search-reset="searchReset"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
      @on-load="onLoad"
      @cell-click="handleRowClick"
      :cell-style="cellStyle"
      class="businessStatisticsStyle"
  <div>
    <basic-container
      :class="[
        'witerFontColorInput',
        $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
        $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : '',
      ]"
    >
    </avue-crud>
  </basic-container>
      <avue-crud
        :option="tableOption"
        :table-loading="loading"
        :data="tableData"
        :page.sync="page"
        :permission="permissionList"
        ref="crud"
        :search.sync="search"
        @row-update="rowUpdates"
        @row-save="rowSave"
        @search-change="searchChange"
        @search-reset="searchReset"
        @current-change="currentChange"
        @size-change="sizeChange"
        @refresh-change="refreshChange"
        @on-load="onLoad"
        @cell-click="handleRowClick"
        class="businessStatisticsStyle tablesss"
      >
        <template slot="menuLeft">
          <el-button
            type="warning"
            size="small"
            plain
            icon="el-icon-download"
            @click="handleExportBusinessStatis"
            >导出
          </el-button>
        </template>
      </avue-crud>
    </basic-container>
    <el-dialog
      class="tongji-class"
      :title="dialogTitle"
      width="80%"
      append-to-body
      :visible.sync="dialogShow"
      v-if="dialogShow"
    >
      <businessStatisticsDetail
        v-if="searchitem === 'fw'"
        :fwdeptId="fwdeptId"
      ></businessStatisticsDetail>
      <businessStatisticsPq
        v-if="searchitem === 'pq'"
        :fwdeptId="fwdeptId"
      ></businessStatisticsPq>
      <businessStatisticsFwdq
        v-if="searchitem === 'dq'"
        :fwdeptId="fwdeptId"
      ></businessStatisticsFwdq>
      <securityGuardDetail
        v-if="searchitem === 'zong'"
        :fwdeptId="fwdeptId"
        :paramCz="paramCz"
      ></securityGuardDetail>
      <!-- <avue-crud
        :option="option2"
        :data="data2"
        :page.sync="page2"
        @row-save="rowSave2"
        @row-update="rowUpdate2"
        @row-del="rowDel2"
        :table-loading="loading2"
      >
      </avue-crud> -->
    </el-dialog>
  </div>
</template>
<script>
import FileSaver from "file-saver";
import XLSX from "xlsx";
import { mapGetters } from "vuex";
import { selectYw } from "../../api/statisticalQueryManagement/statisticalQueryManagement";
import { lazyTreeJu } from "../../api/index/index";
import {
  selectYw,
  dictionaryList,
} from "../../api/statisticalQueryManagement/statisticalQueryManagement";
import { lazyTrees } from "../../api/index/index";
import businessStatisticsDetail from "./businessStatisticsDetail";
import businessStatisticsPq from "./businessStatisticsPq";
import businessStatisticsFwdq from "./businessStatisticsFwdq";
import securityGuardDetail from "./securityGuardDetail";
import Qs from "qs";
import { getToken } from "@/util/auth";
export default {
  name: "业务情况统计",
  components: {
    businessStatisticsDetail,
    businessStatisticsPq,
    businessStatisticsFwdq,
    securityGuardDetail,
  },
  data() {
    return {
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0
        total: 0,
        ...this.$store.state.control.changePageSize,
      },
      search: {},
      query: {},
      value1: "",
      value2: "",
      tableData: [
        // {
        //   company: "江西省永安保安服务有限公司",
        //   subOffice: "南昌市公安局",
        //   customer: "76",
        //   num: "1124"
        // },
        // {
        //   company: "南昌市赣水保安服务有限公司",
        //   subOffice: "东湖分局",
        //   customer: "85",
        //   num: "1428"
        // },
        // {
        //   company: "江西中业兴达保安服务有限公司",
        //   subOffice: "西湖分局",
        //   customer: "46",
        //   num: "974"
        // }
      ],
      tableData: [],
      tableOption: {
        excelBtn: true,
        // excelBtn: true,
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: true,
        selection: false,
        menu: false,
        // dateBtn: true,
        align: "center",
@@ -75,25 +126,40 @@
        searchShow: true,
        searchMenuSpan: 6,
        index: true,
        indexLabel: "序号",
        viewBtn: true,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          {
            label: "公司名称",
            label: "企业名称",
            prop: "enterpriseName",
            search: true,
            searchSpan: 4,
            display: false
            width: 300,
            display: false,
          },
          {
            label: "企业属性",
            prop: "stats",
            search: true,
            searchSpan: 4,
            display: false,
            type: "select",
            props: {
              label: "dictValue",
              value: "dictKey",
            },
            dicData: [],
          },
          {
            label: "所属辖区",
            prop: "jurname",
            searchSpan: 4,
            type: "select",
            type: "tree",
            props: {
              label: "title",
              value: "id"
              value: "id",
            },
            dicData: [],
            search: true,
@@ -101,23 +167,67 @@
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "blur"
              }
            ]
          },
          {
            label: "服务对象数量",
            prop: "fwnum",
            display: false
                trigger: "blur",
              },
            ],
          },
          {
            label: "保安员人数",
            prop: "znum",
            display: false
          }
        ]
            display: false,
          },
          {
            label: "持证人数",
            prop: "cznum",
            display: false,
          },
          {
            label: "派遣人数",
            prop: "pqnum",
            display: false,
          },
          {
            label: "服务对象数量",
            prop: "fwnum",
            display: false,
          },
          {
            label: "服务到期数量",
            prop: "dqnum",
            display: false,
          },
          {
            label: "单位注册时间",
            prop: "releaseTimeRange",
            type: "date",
            format: "yyyy-MM-dd",
            valueFormat: "yyyy-MM-dd",
            searchRange: true,
            searchSpan: 6,
            searchLabelWidth: 120,
            labelWidth: 160,
            hide: true,
            addDisplay: false,
            editDisplay: false,
            viewDisplay: false,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择单位注册时间",
                trigger: "blur",
              },
            ],
          },
        ],
      },
      loading: true
      loading: true,
      dialogTitle: "",
      dialogShow: false,
      pqdialogShow: false,
      fwdeptId: "",
      searchitem: "",
      paramCz: false,
    };
  },
  computed: {
@@ -127,15 +237,45 @@
        addBtn: this.vaildData(this.permission.post_add, false),
        viewBtn: this.vaildData(this.permission.post_view, false),
        delBtn: this.vaildData(this.permission.post_delete, false),
        editBtn: this.vaildData(this.permission.post_edit, false)
        editBtn: this.vaildData(this.permission.post_edit, false),
      };
    }
    },
  },
  methods: {
    //业务情况统计信息导出
    handleExportBusinessStatis() {
      this.$confirm("是否导出业务情况统计信息数据?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        //获取查询条件
        const { releaseTimeRange } = this.search;
        if (releaseTimeRange) {
          this.search["startTime"] = releaseTimeRange[0];
          this.search["endTime"] = releaseTimeRange[1];
        }
        var data = {
          jurisdiction: this.search.jurname,
          stats: this.search.stats,
          deptid: this.search.enterpriseName,
          startTime: this.search.startTime,
          endTime: this.search.endTime,
        };
        // console.log(data,123);
        //序列号url形式,用&拼接
        data = Qs.stringify(data);
        window.open(
          `/api/information/export-business-statis?${
            this.website.tokenHeader
          }=${getToken()}&` + data
        );
      });
    },
    getSubOfficeData() {
      lazyTreeJu().then(res => {
      lazyTrees().then((res) => {
        if (res.data.code === 200) {
          this.tableOption.column.forEach(item => {
          this.tableOption.column.forEach((item) => {
            if (item.label == "所属辖区") {
              item.dicData = res.data.data;
            }
@@ -145,66 +285,139 @@
        }
      });
    },
    getDictionaryList() {
      dictionaryList().then((res) => {
        if (res.data.code === 200) {
          this.tableOption.column.forEach((item) => {
            if (item.label == "企业属性") {
              item.dicData = res.data.data;
            }
          });
        }
      });
    },
    searchChange(params, done) {
      this.query = params;
      this.page.currentPage = 1;
      this.onLoad(this.page, params);
      done();
    },
    searchReset() {
      this.query = {};
      this.onLoad(this.page);
    },
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.onLoad(this.page, this.query);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.onLoad(this.page, this.query);
    },
    refreshChange() {
      this.onLoad(this.page, this.query);
    },
    onLoad(page, params = {}) {
      params = this.search;
      this.loading = true;
      let param = {};
      param["jurisdiction"] = params["jurname"] ? params["jurname"] : "";
      param["deptid"] = "";
      param["jurisdiction"] = params["jurname"] || "";
      param["deptid"] = params["enterpriseName"] || "";
      param["stats"] = params["stats"] || "";
      param["current"] = page.currentPage;
      param["size"] = page.pageSize;
      selectYw(param).then(res => {
      const { releaseTimeRange } = this.query;
      let values = {
        ...param,
      };
      if (releaseTimeRange) {
        values = {
          ...param,
          startTime: releaseTimeRange[0],
          endTime: releaseTimeRange[1],
          ...this.query,
        };
        values.releaseTimeRange = null;
      }
      selectYw(values).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.tableData = data.records;
        this.$store.commit("setWindowSizeHeightAdd");
        this.loading = false;
      });
    },
    handleRowClick(row, column, cell, event) {
      this.paramCz = false;
      if (column.label == "服务对象数量") {
        this.$router.push({
          path: "/statisticalQueryManagement/businessStatisticsDetail"
        });
        this.dialogTitle = "业务统计明细---服务对象清单";
        this.searchitem = "fw";
        this.fwdeptId = row.departmentid;
        this.dialogShow = true;
        // dispatcherUnit({
        //   deptId: row.departmentid
        // }).then(res => {
        //   if (res.data.code === 200) {
        //     this.page = {
        //       pageSize: 10,
        //       currentPage: 1,
        //       total: res.data.data.total
        //     };
        //     this.tableData = res.data.data.records;
        //   }
        // });
        // this.$router.push({
        //   path:
        //     "/statisticalQueryManagement/businessStatisticsDetail?&departmentid=" +
        //     row.departmentid
        // });
      } else if (column.label == "保安员人数") {
        this.$router.push({
          path:
            "/statisticalQueryManagement/securityGuardDetail?enterpriseName=" +
            row.enterpriseName
        });
        this.dialogTitle = "业务统计明细---保安员清单";
        this.searchitem = "zong";
        this.fwdeptId = row.departmentid;
        this.dialogShow = true;
        // this.$router.push({
        //   path:
        //     "/statisticalQueryManagement/securityGuardDetail?departmentid=" +
        //     row.departmentid
        // });
      } else if (column.label == "派遣人数") {
        this.dialogTitle = "业务统计明细---派遣人员清单";
        this.searchitem = "pq";
        this.fwdeptId = row.departmentid;
        this.dialogShow = true;
      } else if (column.label == "服务到期数量") {
        this.dialogTitle = "业务统计明细---服务到期公司清单";
        this.searchitem = "dq";
        this.fwdeptId = row.departmentid;
        this.dialogShow = true;
      } else if (column.label == "持证人数") {
        this.dialogTitle = "业务统计明细---持证保安人员清单";
        this.searchitem = "zong";
        this.paramCz = true;
        this.fwdeptId = row.departmentid;
        this.dialogShow = true;
      } else {
        this.dialogShow = false;
      }
    },
    cellStyle(row, column, rowIndex, columnIndex) {
      // if (columnIndex == 4 || columnIndex == 5) {
      // }
    }
  },
  mounted() {
    this.getSubOfficeData();
  }
    this.getDictionaryList();
    this.$store.commit("setWindowSizeHeightAdd");
  },
};
</script>
<style lang="scss" scoped>
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(5),
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(6) {
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(7),
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(6),
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(8),
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(9),
/deep/ .businessStatisticsStyle .el-table__row:hover td:nth-child(10) {
  cursor: pointer !important;
}
</style>