123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501 |
- <template>
- <div class="reportTable-security">
- <div class="report-query">
- <ReportQuery
- :show="['time']"
- :query-data.sync="queryData"
- :search="search"
- >
- <template #extraItem>
- <a-form-model-item label="人员姓名: ">
- <a-input
- style="width: 200px"
- v-model="queryData.name"
- placeholder="请输入姓名"
- />
- </a-form-model-item>
- <a-form-model-item label="所属部门名称: ">
- <a-select v-model="queryData.dept" style="width: 200px">
- <a-select-option
- v-for="(item, index) in deptData"
- :key="index"
- :value="item.value"
- >
- {{ item.label }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- <a-form-model-item label="人员类型: ">
- <a-select v-model="queryData.people" style="width: 200px">
- <a-select-option
- v-for="(item, index) in peopleOptions"
- :key="index"
- :value="item.value"
- >
- {{ item.label }}
- </a-select-option>
- </a-select>
- </a-form-model-item>
- </template>
- </ReportQuery>
- </div>
- <div class="report-table-view">
- <Card title="报告预览">
- <template #title-extra>
- <div style="padding-right: 20px">
- <span style="color: #b2b2b2; font-size: 12px"
- >支持 pdf,word,excel</span
- >
- <a-button type="link" size="small" @click="exportFunc"
- >导出</a-button
- >
- <a-button type="link" size="small">打印</a-button>
- </div>
- </template>
- <a-table
- :columns="tableColumns"
- :data-source="tableData"
- :pagination="true"
- :scroll="{ y: tableContainerHeight }"
- bordered
- ></a-table>
- </Card>
- </div>
- </div>
- </template>
- <script>
- import ReportQuery from "@/components/report/common/reportQuery.vue";
- import Card from "@/components/common/card.vue";
- import * as XLSX from "xlsx";
- import html2canvas from "html2canvas";
- import jsPDF from "jspdf";
- export default {
- components: {
- Card,
- ReportQuery,
- },
- data() {
- let timeRange = this.$util.dateUtil.getNearlyMonthRange();
- return {
- timeRange: "",
- queryData: {
- timeRange: timeRange,
- statis: "0",
- name: "",
- dept: "0",
- people: "0",
- },
- oriTableData: [],
- // 部门数据
- deptData: [
- {
- label: "全部",
- value: "0",
- },
- {
- label: "业务一部",
- value: "1",
- },
- {
- label: "业务二部",
- value: "2",
- },
- {
- label: "业务三部",
- value: "3",
- },
- ],
- peopleOptions: [
- {
- label: "全部",
- value: "0",
- },
- {
- label: "自有员工",
- value: "1",
- },
- {
- label: "协作员工",
- value: "2",
- },
- {
- label: "访客",
- value: "3",
- },
- ],
- tableContainerHeight: 500,
- tableColumns: [
- {
- title: "序号",
- dataIndex: "index",
- key: "index",
- align: "center",
- width: 80,
- customRender: (text, record, index) => `${index + 1}`,
- },
- {
- title: "姓名",
- dataIndex: "name",
- key: "name",
- align: "center",
- },
- {
- title: "身份证号",
- dataIndex: "ID",
- key: "ID",
- align: "center",
- },
- {
- title: "人员类型",
- dataIndex: "people_type",
- key: "people_type",
- align: "center",
- },
- {
- title: "所属部门名称",
- dataIndex: "department",
- key: "department",
- align: "center",
- },
- {
- title: "通行时间",
- dataIndex: "time",
- key: "time",
- },
- {
- title: "设备名称",
- dataIndex: "equipment",
- key: "equipment",
- align: "center",
- },
- {
- title: "通行方向",
- dataIndex: "direction",
- key: "direction",
- align: "center",
- },
- {
- title: "异常类型",
- key: "operation",
- fixed: "right",
- width: 100,
- scopedSlots: { customRender: "action" },
- },
- ],
- originalData: [
- {
- key: "1",
- name: "潘夏彤",
- ID:"332987********8765",
- people_type: "自有员工",
- department: "业务一部",
- time: "2023-03-11 12:00:00",
- equipment: "ZX010012",
- direction: "进入B3",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "2",
- name: "庞慧",
- ID:"332987********8765",
- people_type: "协作员工",
- department: "业务二部",
- time: "2023-03-15 12:00:00",
- equipment: "ZX010012",
- direction: "进入1F",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "3",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务二部",
- time: "2023-03-24 12:00:00",
- equipment: "ZX010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "4",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务二部",
- time: "2022-09-11 12:00:00",
- equipment: "ZX010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "5",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务二部",
- time: "2022-09-11 12:00:00",
- equipment: "ZX010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "6",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务二部",
- time: "2022-09-11 12:00:00",
- equipment: "ZX010017",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "7",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZX010017",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "8",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZX010017",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "9",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "10",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "11",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "12",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "13",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "14",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "15",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "16",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "17",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "进入B2",
- behavior: "",
- directionStatus: "进",
- },
- {
- key: "18",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务一部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "19",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "20",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- {
- key: "21",
- name: "李天泽",
- ID:"332987********8765",
- people_type: "访客",
- department: "业务三部",
- time: "2022-08-26 12:00:00",
- equipment: "ZY010012",
- direction: "出去B2",
- behavior: "",
- directionStatus: "出",
- },
- ],
- tableData: [],
- };
- },
- mounted() {
- this.initData();
- },
- methods: {
- initData() {
- this.tableData = JSON.parse(JSON.stringify(this.originalData));
- },
- exportFunc() {
- // 获取表格的 DOM 节点
- const table = document.querySelector(".ant-table-wrapper");
- // 使用 html2canvas 将表格转换成图片
- html2canvas(table, {
- allowTaint: true,
- useCORS: true,
- }).then((canvas) => {
- // 获取图片的 base64 编码
- const base64URL = canvas.toDataURL("image/png");
- // 将图片导出成 PDF 或者图片文件
- const pdf = new jsPDF("landscape", "px", [canvas.width, canvas.height]);
- pdf.addImage(base64URL, "PNG", 0, 0, canvas.width, canvas.height);
- pdf.save("智慧安防-安防人员.pdf"); // 保存为 PDF 文件
- // window.open(base64URL); // 在新窗口中打开图片
- });
- },
- exportFunc1() {
- console.log("打印报表");
- const data = [
- ["姓名", "年龄", "性别", "毕业院校"],
- ["张三", 18, "男", "清华大学"],
- ["李四", 22, "女", "北京大学"],
- ["王五", 20, "男", "上海交通大学"],
- ];
- const worksheet = XLSX.utils.aoa_to_sheet(data);
- const workbook = XLSX.utils.book_new();
- XLSX.utils.book_append_sheet(workbook, worksheet, "表格名字");
- XLSX.writeFile(workbook, "智慧安防-安防人员.xlsx");
- },
- search() {},
- },
- };
- </script>
- <style lang="less" scoped>
- .reportTable-security {
- width: 100%;
- height: 100%;
- .report-query {
- background-color: #ffffff;
- padding: 12px;
- margin-bottom: 12px;
- }
- .report-table-view {
- width: 100%;
- height: 690px;
- background-color: #ffffff;
- }
- }
- </style>
|