Commit 3c10db8d authored by xinzhedeai's avatar xinzhedeai

add:人员统计接口对接

parent 90fd5fb8
import request from '@/utils/request'
// 查询人员信息列表
export function getPersonCount(query) {
return request({
url: '/count/manage/getPersonCount',
method: 'get',
params: query
})
}
export function getPersonCountTrend(query) {
return request({
url: '/count/manage/getPersonCountTrend',
method: 'get',
params: query
})
}
export function listInfo(query) {
return request({
url: '/count/manage/getPersonDetails',
method: 'get',
params: query
})
}
......@@ -59,7 +59,7 @@
class="stat-value"
style="font-size: 18px; font-weight: 400; color: #2196f3"
>
3
{{ sumObj.person }}
</div>
</div>
</el-col>
......@@ -85,7 +85,7 @@
class="stat-value"
style="font-size: 18px; font-weight: 400; color: #2196f3"
>
3
{{ sumObj.visitor }}
</div>
</div>
</el-col>
......@@ -176,14 +176,18 @@
</template>
<script>
import { listInfo } from "@/api/jinrun/renyuan";
import { getDict } from "@/api/jinrun/common";
import {
getPersonCount,
getPersonCountTrend,
listInfo,
} from "@/api/jinrun/renyuantongji";
import * as echarts from "echarts"; // 导入ECharts
export default {
name: "Info",
data() {
return {
sumObj: {},
// 人员类型下拉列表数据
personTypeOptions: [],
// 遮罩层
......@@ -206,8 +210,7 @@ export default {
open: false,
// 查询参数
queryParams: {
dateRange: null,
realName: null,
dateRange: [],
pageNum: 1,
pageSize: 10,
},
......@@ -222,9 +225,29 @@ export default {
},
mounted() {
this.initChart();
this.getPersonCount();
this.getPersonCountTrend();
this.getList();
},
methods: {
getPersonCountTrend() {
// 处理日期范围参数
this.queryParams.startDate = this.queryParams.dateRange[0] || "";
this.queryParams.endDate = this.queryParams.dateRange[1] || "";
getPersonCountTrend(this.queryParams).then((response) => {
// this.sumObj = response.data;
console.log(response, " 人员数量趋势图数据");
this.updateChart(response.data.xData, response.data.yData);
});
},
getPersonCount() {
getPersonCount().then((response) => {
this.sumObj = response.data;
});
},
/** 初始化图表 */
initChart() {
// 获取DOM元素并初始化图表
const chartDom = document.querySelector(".qushitu");
......@@ -268,7 +291,7 @@ export default {
},
yAxis: {
type: "value",
name: "人员数量",
// name: "人员数量",
splitLine: {
show: true, // 显示每个刻度对应的横线
lineStyle: {
......@@ -323,49 +346,8 @@ export default {
},
/** 更新图表数据 */
updateChart() {
updateChart(dates, values) {
if (this.chartInstance) {
// 模拟数据(实际项目中应根据后端返回数据处理)
const dateRange = this.queryParams.dateRange;
let dates = [];
let values = [];
if (dateRange && dateRange.length === 2) {
// 有日期范围时生成模拟数据
const start = new Date(dateRange[0]);
const end = new Date(dateRange[1]);
const days = Math.ceil((end - start) / (1000 * 60 * 60 * 24));
for (let i = 0; i <= days; i++) {
const currentDate = new Date(start);
currentDate.setDate(start.getDate() + i);
const dateStr =
currentDate.getFullYear() +
"-" +
(currentDate.getMonth() + 1).toString().padStart(2, "0") +
"-" +
currentDate.getDate().toString().padStart(2, "0");
dates.push(dateStr);
// 生成随机数据,范围在1-10之间
values.push(Math.floor(Math.random() * 10) + 1);
}
} else {
// 默认显示最近7天的数据
for (let i = 6; i >= 0; i--) {
const currentDate = new Date();
currentDate.setDate(currentDate.getDate() - i);
const dateStr =
currentDate.getFullYear() +
"-" +
(currentDate.getMonth() + 1).toString().padStart(2, "0") +
"-" +
currentDate.getDate().toString().padStart(2, "0");
dates.push(dateStr);
// 生成随机数据,范围在1-10之间
values.push(Math.floor(Math.random() * 10) + 1);
}
}
// 更新图表数据
this.chartInstance.setOption({
xAxis: {
......@@ -390,6 +372,8 @@ export default {
/** 查询人员信息列表 */
getList() {
this.loading = true;
this.queryParams.startDate = this.queryParams.dateRange[0] || "";
this.queryParams.endDate = this.queryParams.dateRange[1] || "";
listInfo(this.queryParams).then((response) => {
this.infoList = response.records;
this.total = response.total;
......@@ -407,11 +391,15 @@ export default {
this.queryParams.pageNum = 1;
this.getList();
// 搜索时更新图表数据(添加这行)
this.updateChart();
// this.updateChart();
this.getPersonCountTrend();
},
/** 重置按钮操作 */
resetQuery() {
this.resetForm("queryForm");
// this.resetForm("queryForm");
this.queryParams.dateRange = [];
this.queryParams.startDate = "";
this.queryParams.endDate = "";
this.handleQuery();
},
// 多选框选中数据
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment