zhengpz
2021-08-18 e8f9a6ab3d258c028da4fdc4a51c3985a9eba67c
src/views/securityUnitOperation/operationTable.vue
@@ -3,6 +3,7 @@
    <avue-crud
      :option="tableOption"
      :data="tableData"
      :table-loading="loading"
      :page.sync="tablePage"
      :permission="permissionList"
      :before-open="beforeOpen"
@@ -10,88 +11,12 @@
    >
    </avue-crud>
  </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>
          <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="totalSec" label="总保安人数">
            </el-table-column>
            <el-table-column prop="normalSec" label="正常保安数">
            </el-table-column>
            <el-table-column prop="holderSec" label="持证保安数">
            </el-table-column>
            <el-table-column prop="sendSec" label="保安派遣数">
            </el-table-column>
            <el-table-column prop="passSec" label="过考保安数">
            </el-table-column>
            <el-table-column prop="unit" label="服务单位数"> </el-table-column>
            <el-table-column prop="socialSec" 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> -->
</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() {
@@ -99,50 +24,50 @@
      value1: "",
      value2: "",
      tableData: [
        {
          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: "",
        },
        // {
        //   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,
        total: 0
      },
      tableOption: {
        excelBtn: true,
@@ -173,183 +98,185 @@
            type: "select",
            props: {
              label: "label",
              value: "value",
              value: "value"
            },
            // cascaderItem: ["city", "area"],
            // dicUrl:subofficeOptions,
            dicData: [
              {
                value: "0",
                label: "全部",
                label: "全部"
              },
              {
                value: "1",
                label: "总保安人数",
                label: "总保安人数"
              },
              {
                value: "2",
                label: "正常保安数",
                label: "正常保安数"
              },
              {
                value: "3",
                label: "持证保安数",
                label: "持证保安数"
              },
              {
                value: "4",
                label: "保安派遣数",
                label: "保安派遣数"
              },
              {
                value: "5",
                label: "过考保安数",
                label: "过考保安数"
              },
              {
                value: "6",
                label: "服务单位数",
                label: "服务单位数"
              },
              {
                value: "7",
                label: "缴纳社保保安数",
              },
                label: "缴纳社保保安数"
              }
            ],
            search: true,
            rules: [
              {
                required: true,
                message: "请选择类别",
                trigger: "blur",
              },
            ],
                trigger: "blur"
              }
            ]
          },
          {
            label: "公司名称",
            prop: "company",
            prop: "enterpriseName",
            search: true,
            searchSpan: 4,
            display: false,
            display: false
          },
          {
            label: "所属辖区",
            prop: "subOffice",
            prop: "jurname",
            searchSpan: 4,
            type: "select",
            props: {
              label: "label",
              value: "value",
              label: "title",
              value: "value"
            },
            // cascaderItem: ["city", "area"],
            // dicUrl:subofficeOptions,
            dicData: [
              {
                value: "0",
                label: "南昌市公安局",
              },
              {
                value: "2",
                label: "东湖分局",
              },
              {
                value: "3",
                label: "西湖分局",
              },
              {
                value: "4",
                label: "青云谱分局",
              },
              {
                value: "5",
                label: "青山湖分局",
              },
            ],
            dicData: this.subOfficeData,
            search: true,
            rules: [
              {
                required: true,
                message: "请选择所属辖区",
                trigger: "blur",
              },
            ],
                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: "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: "totalSec",
            display: false,
            prop: "znum",
            display: false
          },
          {
            label: "正常保安数",
            prop: "normalSec",
            display: false,
            prop: "zcnum",
            display: false
          },
          {
            label: "持证保安数",
            prop: "holderSec",
            display: false,
            prop: "cznum",
            display: false
          },
          {
            label: "保安派遣数",
            prop: "sendSec",
            display: false,
            prop: "pcnum",
            display: false
          },
          {
            label: "过考保安数",
            prop: "passSec",
            display: false,
          },
          // {
          //   label: "过考保安数",
          //   prop: "passSec",
          //   display: false
          // },
          {
            label: "服务单位数",
            prop: "unit",
            display: false,
            prop: "ghnum",
            display: false
          },
          {
            label: "缴纳社保保安数",
            prop: "socialSec",
            display: false,
            prop: "sbnum",
            display: false
          },
          {
            label: "备注",
            prop: "bz",
            display: false,
          },
        ],
            display: false
          }
        ]
      },
      typeValue: "0",
      subofficeValue: "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 lang="scss" scoped>