zhengpz
2021-08-20 7fbe838496148877bc5fe055e3098b3bc00a113d
src/views/securityUnitOperation/operationTable.vue
@@ -1,77 +1,345 @@
<template>
  <div class="table">
    <div class="about">
      <el-button @click="downExcel">下载</el-button>
      <el-table id="table" :data="tableData" stripe style="width: 100%">
        <el-table-column prop="date" label="日期" width="180">
        </el-table-column>
        <el-table-column prop="name" label="姓名" width="180">
        </el-table-column>
        <el-table-column prop="address" label="地址"> </el-table-column>
      </el-table>
      <el-pagination background layout="prev, pager, next" :total="1000">
      </el-pagination>
    </div>
  </div>
  <basic-container>
    <avue-crud
      :option="tableOption"
      :data="tableData"
      :table-loading="loading"
      :page.sync="tablePage"
      :permission="permissionList"
      :before-open="beforeOpen"
      @date-change="dateChange"
    >
    </avue-crud>
  </basic-container>
</template>
<script>
import FileSaver from "file-saver";
import XLSX from "xlsx";
import { selectTb } from "../../api/securityUnitOperation/securityUnitOperation";
import { lazyTreeJu } from "../../api/index/index";
export default {
  name: "公司运营情况智能分析详情表",
  data() {
    return {
      value1: "",
      value2: "",
      tableData: [
        {
          date: "2016-05-02",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1518 弄"
        },
        {
          date: "2016-05-04",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1517 弄"
        },
        {
          date: "2016-05-01",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1519 弄"
        },
        {
          date: "2016-05-03",
          name: "王小虎",
          address: "上海市普陀区金沙江路 1516 弄"
        }
      ]
        // {
        //   company: "江西省永安保安服务有限公司",
        //   subOffice: "南昌市公安局",
        //   time: "2020-07-21",
        //   totalSec: "1200",
        //   normalSec: "1150",
        //   holderSec: "1160",
        //   sendSec: "1000",
        //   passSec: "1180",
        //   unit: "52",
        //   socialSec: "1160",
        //   bz: ""
        // },
        // {
        //   company: "南昌市赣水保安服务有限公司",
        //   subOffice: "东湖分局",
        //   time: "2021-06-11",
        //   totalSec: "1360",
        //   normalSec: "1250",
        //   holderSec: "1258",
        //   sendSec: "1210",
        //   passSec: "1180",
        //   unit: "48",
        //   socialSec: "1200",
        //   bz: ""
        // },
        // {
        //   company: "江西中业兴达保安服务有限公司",
        //   subOffice: "西湖分局",
        //   time: "2020-01-21",
        //   totalSec: "1269",
        //   normalSec: "1250",
        //   holderSec: "1042",
        //   sendSec: "1040",
        //   passSec: "1180",
        //   unit: "41",
        //   socialSec: "1025",
        //   bz: ""
        // }
      ],
      tablePage: {
        pageSize: 10,
        currentPage: 1,
        total: 0
      },
      tableOption: {
        excelBtn: true,
        delBtn: false,
        editBtn: false,
        addBtn: false,
        selection: true,
        menu: false,
        // dateBtn: true,
        align: "center",
        height: "auto",
        calcHeight: 30,
        tip: false,
        searchShowBtn: false,
        searchShow: true,
        searchMenuSpan: 6,
        index: true,
        viewBtn: true,
        dialogClickModal: false,
        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: "保安派遣数"
              },
              {
                value: "5",
                label: "过考保安数"
              },
              {
                value: "6",
                label: "服务单位数"
              },
              {
                value: "7",
                label: "缴纳社保保安数"
              }
            ],
            search: true,
            rules: [
              {
                required: true,
                message: "请选择类别",
                trigger: "blur"
              }
            ]
          },
          {
            label: "公司名称",
            prop: "enterpriseName",
            search: true,
            searchSpan: 4,
            display: false
          },
          {
            label: "所属辖区",
            prop: "jurname",
            searchSpan: 4,
            type: "select",
            props: {
              label: "title",
              value: "value"
            },
            // cascaderItem: ["city", "area"],
            // dicUrl:subofficeOptions,
            dicData: this.subOfficeData,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "blur"
              }
            ]
          },
          // {
          //   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: "znum",
            display: false
          },
          {
            label: "正常保安数",
            prop: "zcnum",
            display: false
          },
          {
            label: "持证保安数",
            prop: "cznum",
            display: false
          },
          {
            label: "保安派遣数",
            prop: "pcnum",
            display: false
          },
          // {
          //   label: "过考保安数",
          //   prop: "passSec",
          //   display: false
          // },
          {
            label: "服务单位数",
            prop: "ghnum",
            display: false
          },
          {
            label: "缴纳社保保安数",
            prop: "sbnum",
            display: false
          },
          {
            label: "备注",
            prop: "bz",
            display: false
          }
        ]
      },
      typeValue: "0",
      companyName: "",
      subOfficeData: [],
      subOfficeValue: "",
      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"
    getSubOfficeData() {
      lazyTreeJu().then(res => {
        if (res.data.code === 200) {
          this.subOfficeData = res.data.data;
          this.subOfficeValue = this.subOfficeData[0].value || "";
        } else {
          this.$message.error(res.msg);
        }
      });
      try {
        FileSaver.saveAs(
          new Blob([etout], {
            type: "application/octet-stream"
          }),
          `表.xlsx`
        ); //导出的文件名
      } catch (e) {
        console.log(e, etout);
      }
      return etout;
    },
    getTableData() {
      selectTb().then(res => {
        if (res.data.code === 200) {
          this.tableData = res.data.data;
          this.loading = false;
        }
      });
    }
    // 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() {}
  mounted() {
    this.getSubOfficeData();
    this.getTableData();
  }
};
</script>
<style>
.table {
<style lang="scss" scoped>
.operation-table {
  height: 100%;
  width: 1005;
  display: none;
  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>