liuyg
2021-07-20 eed39ea913dddfe6572f37de8c7de3f1523b6816
src/views/securityUnitOperation/economicTable.vue
@@ -1,7 +1,351 @@
/*
 * @Author: mikey.zhaopeng
 * @Date: 2021-07-17 00:19:50
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2021-07-17 00:20:33
  * @description:公司经济情况智能分析统计
 */
<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>
</template>
<script>
import FileSaver from "file-saver";
import XLSX from "xlsx";
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]);
            }
          }
        ]
      },
      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: ""
        }
      ],
      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,
        editBtn: false,
        addBtn: false,
        delBtn: false,
        menuWidth: 150,
        dialogClickModal: false,
        column: [
          {
            label: "公司名称",
            prop: "company"
          },
          {
            label: "所属分局",
            prop: "subOffice"
          },
          {
            label: "时间",
            prop: "time"
          },
          {
            label: "社保缴纳人数",
            prop: "sbjnrs"
          },
          {
            label: "社保缴纳总额(万)",
            prop: "sbjnze"
          },
          {
            label: "公司派遣人数",
            prop: "gspqrs"
          },
          {
            label: "社保缴纳人数占比(%)",
            prop: "sbjnrszb"
          },
          {
            label: "备注",
            prop: "bz"
          }
        ]
      },
      typeValue: "0",
      typeOptions: [
        {
          value: "0",
          label: "全部"
        },
        {
          value: "1",
          label: "社保缴纳人数"
        },
        {
          value: "2",
          label: "社保缴纳总额"
        },
        {
          value: "3",
          label: "公司派遣人数"
        },
        {
          value: "4",
          label: "社保缴纳人数占比"
        }
      ],
      subofficeValue: "0",
      subofficeOptions: [
        {
          value: "0",
          label: "南昌市公安局"
        },
        {
          value: "2",
          label: "东湖分局"
        },
        {
          value: "3",
          label: "西湖分局"
        },
        {
          value: "4",
          label: "青云谱分局"
        },
        {
          value: "5",
          label: "青山湖分局"
        }
      ],
      companyName: ""
    };
  },
  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;
    }
  },
  mounted() {}
};
</script>
<style lang="scss" scoped>
.operation-table {
  height: 100%;
  width: 100%;
  .el-row:first-child {
    height: 100px;
    margin-bottom: 20px;
    // background: rgba(255, 255, 255, 0.1);
    // box-shadow: 0px 0px 1px #fff;
    .el-col {
      padding: 20px;
      .el-date-editor {
        margin-right: 20px;
      }
      .el-select {
        width: 115px;
        margin-right: 20px;
      }
      .el-input {
        width: 115px;
        margin-right: 20px;
      }
      .el-button {
        width: 70px !important;
      }
    }
  }
  .el-row:nth-child(2) {
    height: calc(100% - 120px);
    // background: rgba(255, 255, 255, 0.1);
    // box-shadow: 0px 0px 1px #fff;
  }
  .el-col {
    height: 100%;
    span {
      color: #fff;
    }
  }
}
.table {
  padding: 20px;
  height: calc(100% - 40px);
  width: calc(100% - 40px);
  .el-button {
    width: 55px;
    height: 30px;
    padding: 0px;
    margin-left: calc(100% - 55px);
  }
}
/deep/ .el-table {
  width: 100%;
  height: calc(100% - 100px);
  margin: 10px 0px;
  .cell {
    color: #fff;
    text-align: center;
  }
}
.el-pagination {
  height: 40px;
  float: right;
}
</style>