You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

150 lines
4.7 KiB

4 years ago
<template>
<div class="container">
<!-- 查询配置 -->
<div style="padding: 0px 20px">
<div ref="lxHeader">
<LxHeader icon="md-apps" text="性别分析报表" style="margin-bottom: 10px; border: 0px; margin-top: 15px">
<div slot="content"></div>
<slot>
<div>
3 years ago
<el-date-picker v-model="daterange" type="daterange" range-separator="" start-placeholder=""
end-placeholder="结束日期" @change="daterangeChange">
</el-date-picker>
4 years ago
<Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
3 years ago
<Button type="primary" @click="viewPart" style="margin-left: 10px">{{btnText}}</Button>
<Button type="primary" style="margin-left: 10px" @click="handleGo"></Button>
4 years ago
</div>
</slot>
</LxHeader>
</div>
<div class="table-tree" v-if="showData">
<el-table :data="tableData" :height="tableHeight" class="v-table" style="width: 100%">
<el-table-column type="index" align="center">
</el-table-column>
<el-table-column prop="sex_name" label="性别" sortable width="180">
</el-table-column>
<el-table-column prop="plan_total" label="预约人数" sortable>
</el-table-column>
<el-table-column prop="use_total" label="入场人数" sortable>
</el-table-column>
<el-table-column prop="per" label="核销比" sortable>
</el-table-column>
</el-table>
</div>
4 years ago
<div v-else style="background-color: #fff;">
4 years ago
<pie-chart :chartData="rptData" :height="chartHeight" />
4 years ago
</div>
</div>
</div>
</template>
<script>
import LxHeader from "@/components/LxHeader/index.vue";
3 years ago
import PieChart from '../components/PieChart'
import {
ElMapExportTable
} from "table-excel";
4 years ago
import {
sexRpt
} from "@/api/report/visit.js";
export default {
components: {
4 years ago
LxHeader,
PieChart
4 years ago
},
created() {
this.initLoad()
this.load()
},
mounted() {},
data() {
3 years ago
return {
daterange: "",
4 years ago
showData: false,
3 years ago
searchFields: {
start_date: "",
end_date: ""
},
4 years ago
tableData: [],
3 years ago
tableHeight: 0,
btnText: "数据展示",
chartHeight: "",
4 years ago
rptData: {
yArr: [],
radiusArr: "50%"
}
4 years ago
}
},
3 years ago
methods: {
daterangeChange(e) {
console.log(e);
this.searchFields.start_date = this.$moment(e[0]).format("yyyy-MM-DD");
this.searchFields.end_date = this.$moment(e[1]).format("yyyy-MM-DD");
},
/** 导出按钮操作 */
handleGo() {
var data = this.tableData; // 这里面是数据列表
const column = [{
title: "性别",
dataIndex: "sex_name"
}, // dataIndex为数据列表中的数据字段
{
title: "预约人数",
dataIndex: "plan_total"
},
{
title: "入场人数",
dataIndex: "use_total"
},
{
title: "核销比",
dataIndex: "per"
},
];
const instance = new ElMapExportTable({
column,
data
}, {
progress: progress => console.log(progress)
} // 进度条回调
);
instance.download("性别分析报表"); // 导出的文件名
4 years ago
},
4 years ago
viewPart() {
3 years ago
this.showData = !this.showData;
4 years ago
this.btnText = this.showData ? "图表展示" : "数据展示"
4 years ago
},
initLoad() {
var that = this;
var clientHeight = document.documentElement.clientHeight
var lxHeader_height = 96.5; //查询 头部
var paginationHeight = 37; //分页的高度
var topHeight = 50; //页面 头部
let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
3 years ago
that.tableHeight = tableHeight;
that.chartHeight = tableHeight + "px";
4 years ago
},
load() {
4 years ago
// this.showData = true;
4 years ago
var arr = [];
3 years ago
sexRpt(this.searchFields).then((res) => {
4 years ago
for (var m of res) {
4 years ago
m.per = ((m.use_total / (m.plan_total == 0 ? 1 : m.plan_total)) * 100).toFixed(2) + "%"
4 years ago
arr.push({
name: m.sex_name,
value: m.plan_total
})
4 years ago
}
4 years ago
this.rptData.yArr = arr;
4 years ago
this.tableData = res;
}).catch((res) => {})
}
}
};
</script>