zhongrj
2024-03-27 cc1c0a396698648256c350f6f0fe2cb2f0b02c7e
src/views/securityUnitOperation/economicTable.vue
@@ -1,288 +1,363 @@
<template>
  <basic-container>
    <div class="operation-table">
      <el-row>
        <el-col>
          <span>时间范围:</span>
          <el-date-picker
            v-model="value2"
            type="daterange"
            align="right"
            unlink-panels
            range-separator="至"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
            :picker-options="pickerOptions"
          >
          </el-date-picker>
          <span>类别:</span>
          <el-select v-model="typeValue" placeholder="请选择">
            <el-option
              v-for="item in typeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <span>所属辖区:</span>
          <el-select v-model="subofficeValue" placeholder="请选择">
            <el-option
              v-for="item in subofficeOptions"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
          <span>公司名称:</span>
          <el-input v-model="companyName"></el-input>
          <el-button>查询</el-button>
          <el-button>重置</el-button>
        </el-col>
      </el-row>
      <el-row>
        <el-col>
          <div class="table">
            <el-button @click="downExcel">下载</el-button>
            <avue-crud
              :option="tableOption"
              :data="tableData"
              :page.sync="tablePage"
              :permission="permissionList"
              :before-open="beforeOpen"
            >
            </avue-crud>
            <!-- <el-table id="table" :data="tableData" style="width: 100%">
            <el-table-column type="index" label="序号" width="50">
            </el-table-column>
            <el-table-column prop="company" label="公司名称" width="180">
            </el-table-column>
            <el-table-column prop="subOffice" label="所属分局" width="180">
            </el-table-column>
            <el-table-column prop="time" label="时间"> </el-table-column>
            <el-table-column prop="sbjnrs" label="社保缴纳人数">
            </el-table-column>
            <el-table-column prop="sbjnze" label="社保缴纳总额(万)">
            </el-table-column>
            <el-table-column prop="gspqrs" label="公司派遣人数">
            </el-table-column>
            <el-table-column prop="sbjnrszb" label="社保缴纳人数占比(%)">
            </el-table-column>
            <el-table-column prop="bz" label="备注"> </el-table-column>
          </el-table> -->
            <el-pagination
              background
              layout="prev, pager, next"
              :total="tableData.length"
            >
            </el-pagination>
          </div>
        </el-col>
      </el-row>
    </div>
  <basic-container
    :class="[
      $store.state.control.screenSize == 1366 ? 'smallSize' : 'normalSize',
      $store.state.control.windowWidth >= 1024 ? 'tooRowSearch1' : '',
    ]"
  >
    <avue-crud
      class="tablesss smileTableFromSize"
      :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"
    >
    </avue-crud>
  </basic-container>
</template>
<script>
import FileSaver from "file-saver";
import XLSX from "xlsx";
import { mapGetters } from "vuex";
import { selectJj } from "../../api/securityUnitOperation/securityUnitOperation";
import { lazyTreeJu, lazyTrees } from "../../api/index/index";
export default {
  name: "公司经济情况智能分析详情表",
  data() {
    return {
      pickerOptions: {
        shortcuts: [
          {
            text: "最近一周",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 7);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近一个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 30);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近三个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setTime(start.getTime() - 3600 * 1000 * 24 * 90);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
        ...this.$store.state.control.changePageSize,
      },
      query: {},
      value1: "",
      value2: "",
      tableData: [
        {
          company: "江西省永安保安服务有限公司",
          subOffice: "南昌市公安局",
          time: "2021年6月",
          sbjnrs: "12200",
          sbjnze: "400",
          gspqrs: "110",
          sbjnrszb: "10",
          bz: ""
        },
        {
          company: "南昌市赣水保安服务有限公司",
          subOffice: "东湖分局",
          time: "2021年6月",
          sbjnrs: "12200",
          sbjnze: "400",
          gspqrs: "110",
          sbjnrszb: "10",
          bz: ""
        },
        {
          company: "江西中业兴达保安服务有限公司",
          subOffice: "西湖分局",
          time: "2021年6月",
          sbjnrs: "12200",
          sbjnze: "400",
          gspqrs: "110",
          sbjnrszb: "10",
          bz: ""
        }
        // {
        //   company: "江西省永安保安服务有限公司",
        //   subOffice: "南昌市公安局",
        //   time: "2021-06-1",
        //   sbjnrs: "2100",
        //   sbjnze: "350",
        //   gspqrs: "110",
        //   sbjnrszb: "10",
        //   bz: ""
        // },
        // {
        //   company: "南昌市赣水保安服务有限公司",
        //   subOffice: "东湖分局",
        //   time: "2020-05-21",
        //   sbjnrs: "1800",
        //   sbjnze: "310",
        //   gspqrs: "160",
        //   sbjnrszb: "21",
        //   bz: ""
        // },
        // {
        //   company: "江西中业兴达保安服务有限公司",
        //   subOffice: "西湖分局",
        //   time: "2021-08-11",
        //   sbjnrs: "2300",
        //   sbjnze: "612",
        //   gspqrs: "80",
        //   sbjnrszb: "7",
        //   bz: ""
        // }
      ],
      tablePage: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      tableOption: {
        lazy: true,
        tip: false,
        simplePage: true,
        searchShow: true,
        searchMenuSpan: 6,
        dialogWidth: "60%",
        tree: true,
        border: true,
        index: true,
        selection: true,
        viewBtn: false,
        excelBtn: true,
        delBtn: false,
        editBtn: false,
        addBtn: false,
        delBtn: false,
        menuWidth: 150,
        selection: true,
        menu: false,
        // dateBtn: true,
        align: "center",
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShowBtn: false,
        searchShow: true,
        searchMenuSpan: 6,
        index: true,
        indexLabel: "序号",
        viewBtn: true,
        dialogClickModal: false,
        ...this.$store.state.control.clearOtherBut,
        column: [
          // {
          //   label: "类别",
          //   hide: true,
          //   prop: "",
          //   search: true,
          //   searchSpan: 4,
          //   display: true,
          //   type: "select",
          //   props: {
          //     label: "label",
          //     value: "value"
          //   },
          //   // cascaderItem: ["city", "area"],
          //   // dicUrl:subofficeOptions,
          //   dicData: [
          //     {
          //       value: "0",
          //       label: "全部"
          //     },
          //     {
          //       value: "1",
          //       label: "社保缴纳人数"
          //     },
          //     {
          //       value: "2",
          //       label: "社保缴纳总额"
          //     },
          //     {
          //       value: "3",
          //       label: "公司派遣人数"
          //     },
          //     {
          //       value: "4",
          //       label: "社保缴纳人数占比"
          //     }
          //   ],
          //   search: true,
          //   rules: [
          //     {
          //       required: true,
          //       message: "请选择类别",
          //       trigger: "blur"
          //     }
          //   ]
          // },
          {
            label: "公司名称",
            prop: "company"
            prop: "enterpriseName",
            search: true,
            searchSpan: 4,
            width: 300,
            display: false,
          },
          {
            label: "所属分局",
            prop: "subOffice"
            label: "所属辖区",
            prop: "jurname",
            searchSpan: 4,
            type: "tree",
            props: {
              label: "title",
              value: "id",
            },
            // cascaderItem: ["city", "area"],
            // dicUrl:subofficeOptions,
            dicData: [],
            search: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "blur",
              },
            ],
          },
          {
            label: "时间",
            prop: "time"
          },
          // {
          //   label: "时间",
          //   prop: "time",
          //   type: "date",
          //   format: "yyyy-MM-dd hh:mm:ss",
          //   valueFormat: "yyyy-MM-dd hh:mm:ss",
          //   searchSpan: 6,
          //   searchRange: true,
          //   search: true,
          //   display: false
          // },
          {
            label: "社保缴纳人数",
            prop: "sbjnrs"
            prop: "sbnum",
            display: false,
          },
          {
            label: "社保缴纳总额(万)",
            prop: "sbjnze"
            prop: "sbcount",
            display: false,
            formatter: function (row, value) {
              return (value = value / 10000);
            },
          },
          {
            label: "公司派遣人数",
            prop: "gspqrs"
            prop: "pcnum",
            display: false,
          },
          {
            label: "社保缴纳人数占比(%)",
            prop: "sbjnrszb"
            label: "社保缴纳人数占比",
            prop: "zb",
            display: false,
            formatter: function (row, value) {
              return (value = value * 100 + "%");
            },
          },
          {
            label: "备注",
            prop: "bz"
          }
        ]
            prop: "bz",
            display: false,
          },
        ],
      },
      typeValue: "0",
      typeOptions: [
        {
          value: "0",
          label: "全部"
          label: "全部",
        },
        {
          value: "1",
          label: "社保缴纳人数"
          label: "社保缴纳人数",
        },
        {
          value: "2",
          label: "社保缴纳总额"
          label: "社保缴纳总额",
        },
        {
          value: "3",
          label: "公司派遣人数"
          label: "公司派遣人数",
        },
        {
          value: "4",
          label: "社保缴纳人数占比"
        }
          label: "社保缴纳人数占比",
        },
      ],
      subofficeValue: "0",
      subofficeOptions: [
        {
          value: "0",
          label: "南昌市公安局"
        },
        {
          value: "2",
          label: "东湖分局"
        },
        {
          value: "3",
          label: "西湖分局"
        },
        {
          value: "4",
          label: "青云谱分局"
        },
        {
          value: "5",
          label: "青山湖分局"
        }
      ],
      companyName: ""
      companyName: "",
      loading: true,
    };
  },
  methods: {
    downExcel() {
      let et = XLSX.utils.table_to_book(document.getElementById("table"));
      let etout = XLSX.write(et, {
        bookType: "xlsx",
        bookSST: true,
        type: "array"
      });
      try {
        FileSaver.saveAs(
          new Blob([etout], {
            type: "application/octet-stream"
          }),
          `表.xlsx`
        ); //导出的文件名
      } catch (e) {
        console.log(e, etout);
      }
      return etout;
    }
  computed: {
    ...mapGetters(["permission"]),
    permissionList() {
      return {
        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),
      };
    },
  },
  mounted() {}
  methods: {
    rowSave(row, done, loading) {
      adddata(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    rowUpdates(row, index, done, loading) {
      update(row).then(
        () => {
          this.onLoad(this.page);
          this.$message({
            type: "success",
            message: "操作成功!",
          });
          done();
        },
        (error) => {
          window.console.log(error);
          loading();
        }
      );
    },
    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 = {}) {
      this.loading = true;
      let param = {};
      param["jurisdiction"] = params["jurname"] || "";
      param["enterpriseName"] = params["enterpriseName"] || "";
      param["current"] = page.currentPage;
      param["size"] = page.pageSize;
      selectJj(param).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.tableData = data.records;
        this.$store.commit("setWindowSizeHeightAdd");
        this.loading = false;
      });
    },
    getSubOfficeData() {
      lazyTrees().then((res) => {
        if (res.data.code === 200) {
          this.tableOption.column.forEach((item) => {
            if (item.label == "所属辖区") {
              item.dicData = res.data.data;
            }
          });
        } else {
          this.$message.error(res.msg);
        }
      });
    },
    getLocationParams() {
      let url = window.location.href;
      let urlArr = url.split("?")[1].split("&");
      var object = new Object();
      for (var i = 0; i < urlArr.length; i++) {
        let mm = urlArr[i].split("=");
        object[decodeURIComponent(mm[0])] = decodeURIComponent(mm[1]);
      }
      let jurisdiction = object["jurisdiction1"] || "";
      let enterpriseName = object["enterpriseName"] || "";
      this.query = {
        jurisdiction: jurisdiction,
        enterpriseName: enterpriseName,
      };
      this.onLoad(this.page, this.query);
    },
  },
  mounted() {
    this.getLocationParams();
    this.getSubOfficeData();
    this.$store.commit("setWindowSizeHeightAdd");
  },
};
</script>
<style lang="scss" scoped>