统计查询修改

This commit is contained in:
廖德云 2025-02-13 23:03:49 +08:00
parent 9808821b70
commit 8cf96126fe
2 changed files with 410 additions and 445 deletions

View File

@ -85,7 +85,6 @@
import { ref, reactive, onMounted, computed } from 'vue';
import * as echarts from 'echarts';
import { cxcRyDatAstatistics, cxcRyDatAstatisticsDetails } from '@/api/renyuan.js';
import { initDictOption } from '@/api/common.js';
// tableData
const bottomHeight = ref(0);
@ -757,7 +756,7 @@ const onChartClick = (e) => {
/* 图表容器 */
.chart-container {
height: 200px;
height: 250px;
margin: 20rpx 0;
border-radius: 24rpx;
overflow: hidden;
@ -850,14 +849,9 @@ scroll-view {
/* 响应式调整优化 */
@media (max-width: 768px) {
.chart-container {
height: 200px;
height: 250px;
border-radius: 20rpx;
}
.titleStyle {
font-size: 26rpx;
padding: 24rpx 0;
}
}
/* 数据行高亮效果 */

View File

@ -1,13 +1,12 @@
<template>
<view>
<view class="container" id="top1">
<uni-row style="margin-bottom: 10rpx;margin-left: 30rpx;margin-right: 30rpx;">
<uni-col :span="24"><uni-title :title="'所选单位ID:'+orgCode" align="left" type="h4"></uni-title></uni-col>
<uni-row style="margin-bottom: 10rpx; margin-left: 30rpx; margin-right: 30rpx">
<uni-col :span="24"><uni-title :title="'所选单位'" align="left" type="h4"></uni-title></uni-col>
</uni-row>
<uni-row style="margin-bottom: 20rpx;margin-left: 30rpx;margin-right: 30rpx;">
<uni-row style="margin-bottom: 20rpx; margin-left: 30rpx; margin-right: 30rpx">
<uni-col :span="24">
<trq-depart-select v-model="orgCode" returnCodeOrID="orgCode"
@change="departChange"></trq-depart-select>
<trq-depart-select v-model="orgCode" returnCodeOrID="orgCode" @change="departChange"></trq-depart-select>
</uni-col>
</uni-row>
<!-- 概览统计 -->
@ -27,39 +26,28 @@
<l-echart ref="chart" @finished="initChart" />
</view>
<!-- 数据表格 -->
<uni-row style="margin-top: 10px; margin-left: 30rpx;margin-right: 30rpx;" v-if="tableData.length>0">
<uni-row style="margin-top: 10px; margin-left: 30rpx; margin-right: 30rpx" v-if="tableData.length > 0">
<uni-col :span="3">
<view class="titleStyle">
序号
</view>
<view class="titleStyle">序号</view>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
姓名
</view>
<view class="titleStyle">姓名</view>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
性别
</view>
<view class="titleStyle">性别</view>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
年龄
</view>
<view class="titleStyle">年龄</view>
</uni-col>
<uni-col :span="6">
<view class="titleStyle">
操作
</view>
<view class="titleStyle">操作</view>
</uni-col>
</uni-row>
<scroll-view scroll-y :style="{ height: bottomHeight + 'px' }">
<uni-row style="margin-bottom: 10rpx;margin-left: 30rpx;margin-right: 30rpx;">
<uni-row style="margin-bottom: 10rpx; margin-left: 30rpx; margin-right: 30rpx">
<view v-for="(item, index) in tableData">
<uni-col :span="3">
<view class="dataStyle">
@ -70,11 +58,13 @@
<view class="dataStyle">
{{ item.xm }}
</view>
</uni-col><uni-col :span="5">
</uni-col>
<uni-col :span="5">
<view class="dataStyle">
{{ item.xb_dictText }}
</view>
</uni-col><uni-col :span="5">
</uni-col>
<uni-col :span="5">
<view class="dataStyle">
{{ item.nl }}
</view>
@ -84,26 +74,17 @@
<button size="mini" type="primary" @click="detail(item)">详情</button>
</view>
</uni-col>
</view>
</uni-row>
</scroll-view>
</view>
</template>
<script setup>
import {
ref,
reactive,
onMounted
} from 'vue';
import * as echarts from 'echarts'
import { ref, reactive, onMounted } from 'vue';
import * as echarts from 'echarts';
import {
queryRenyuanByDepartID
} from '@/api/renyuan.js'
import { queryRenyuanByDepartID } from '@/api/renyuan.js';
//
const bottomHeight = ref(0);
@ -125,8 +106,8 @@
function detail(record) {
// console.log(record)
uni.navigateTo({
url: "/pages/views/renliziyuan/renyuanxinxi/detail?data=" + encodeURIComponent(JSON.stringify(record))
})
url: '/pages/views/renliziyuan/renyuanxinxi/detail?data=' + encodeURIComponent(JSON.stringify(record))
});
}
// initChart
const calculateAge = (birthDate) => {
@ -141,21 +122,22 @@
};
//
const departChange = async (e, data) => {
tableData.value = []
console.log(e)
tableData.value = [];
console.log(e);
orgCode.value = e;
try {
//
isLoading.value = true;
if (orgCode.value.length <= 6) {
console.log(123242353)
uni.showLoading({
title: '全厂数据较多,耐心等待数据加载中...',
mask: true
console.log(123242353);
uni.showToast({
title: '全厂数据较多,请选 下一层级...',
icon: 'none',
duration: 1000
});
isLoading.value = false;
return;
} else {
uni.showLoading({
title: '数据加载中...',
@ -168,34 +150,34 @@
fields: ['xm', 'nl', 'xb', 'xb_dictText', 'orgCode', 'jcdw', 'jcxd', 'jcxdCode']
};
if (orgCode.value.length <= 9) {
params.orgCode = orgCode.value
params.orgCode = orgCode.value;
} else {
params.jcxd_code = orgCode.value
params.jcxd_code = orgCode.value;
}
queryRenyuanByDepartID(params).then((res) => {
queryRenyuanByDepartID(params)
.then((res) => {
if (res.success) {
processData(res.result.records);
//
isLoading.value = false;
uni.hideLoading();
}
}).catch((err) => {
console.log(err)
uni.showToast({
title: '数据加载失败',
icon: 'none'
});
})
} catch (error) {
console.log(error)
.catch((err) => {
console.log(err);
uni.showToast({
title: '数据加载失败',
icon: 'none'
icon: 'none',
duration: 1000
});
});
} catch (error) {
console.log(error);
uni.showToast({
title: '数据加载失败',
icon: 'none',
duration: 1000
});
} finally {
//
@ -204,15 +186,15 @@
}
};
//
const processData = (data) => {
//
const validData = data.map(item => ({
const validData = data
.map((item) => ({
...item,
nl: calculateAge(item.cssj)
})).filter(item => item.nl >= 21 && item.nl <= 64);
}))
.filter((item) => item.nl >= 21 && item.nl <= 64);
//
summary.total = validData.length;
summary.avgAge = validData.reduce((sum, cur) => sum + cur.nl, 0) / summary.total || 0;
@ -222,27 +204,25 @@
groupsData(validData);
//
generateChartData(validData);
};
// ...
const subOrgStaffs = ref({}); //
const ageGroupStaffs = ref({}); //
const groupsData = (data) => {
//
subOrgStaffs.value = {};
ageGroupStaffs.value = {};
data.reduce((acc, cur) => {
// console.log(cur)
let subOrg = "";
let subOrg = '';
let ageRange = getAgeRange(cur.nl);
// console.log(cur.orgCode, cur.jcxdCode)
if (cur.orgCode <= 6) {
subOrg = cur.orgCode
subOrg = cur.orgCode;
} else {
subOrg = cur.jcxdCode
subOrg = cur.jcxdCode;
}
// subOrgStaffs
@ -256,9 +236,8 @@
ageGroupStaffs.value[ageRange] = [];
}
ageGroupStaffs.value[ageRange].push(cur);
})
}
});
};
//
const getAgeRange = (age) => {
@ -270,9 +249,7 @@
//
const showStaffList = (subOrg, ageRange) => {
//
const targetStaffs = subOrgStaffs.value[subOrg].filter(staff =>
getAgeRange(staff.nl) === ageRange
);
const targetStaffs = subOrgStaffs.value[subOrg].filter((staff) => getAgeRange(staff.nl) === ageRange);
staffList.value = targetStaffs;
popupTitle.value = `${subOrg} ${ageRange}人员列表(共${targetStaffs.length}人)`;
@ -307,14 +284,13 @@
return acc;
}, {});
//
const xData = Object.keys(jcdwGroups);
const seriesData = ageRanges.map((range, index) => ({
name: range,
type: 'bar',
data: xData.map(jcdw => jcdwGroups[jcdw].ageGroups[index] || 0),
data: xData.map((jcdw) => jcdwGroups[jcdw].ageGroups[index] || 0),
itemStyle: {
color: ['#5470C6', '#91CC75', '#FAC858', '#EE6666', '#73C0DE'][index]
},
@ -322,14 +298,14 @@
label: {
show: true,
position: 'top'
},
}
// 20
// barWidth: 20
}))
}));
chartOption.value = {
title: {
text: '人员年龄分组统计',
padding: [0, 0, 0, 30],
padding: [0, 0, 0, 30]
},
toolbox: {
padding: [0, 30, 0, 0],
@ -377,7 +353,7 @@
color: '#7F84B5',
fontWeight: 300,
interval: 0,
rotate: 0,
rotate: 0
},
padding: [0, 10, 0, 10],
axisTick: {
@ -387,7 +363,8 @@
show: false //线
}
},
yAxis: [{
yAxis: [
{
show: true,
boundaryGap: false, //线
type: 'value',
@ -411,37 +388,33 @@
axisLine: {
show: false //线
}
}],
series: seriesData,
}
],
series: seriesData
};
//
setTimeout(async () => {
if (!chart.value) return
const myChart = await chart.value.init(echarts)
myChart.setOption(chartOption.value)
if (!chart.value) return;
const myChart = await chart.value.init(echarts);
myChart.setOption(chartOption.value);
myChart.on('click', (params) => {
console.log(params.seriesName)
tableData.value = getAgeGroupStaffs(params.seriesName)
})
}, 300)
console.log(params.seriesName);
tableData.value = getAgeGroupStaffs(params.seriesName);
});
}, 300);
// #ifdef APP
getHeight();
// #endif
};
onMounted(() => {
// #ifdef APP
getHeight();
// #endif
})
});
// #ifdef APP
const getHeight = () => {
@ -455,7 +428,7 @@
.select('#top1')
.boundingClientRect((rect1) => {
//
const topComponentsHeight = rect1.height
const topComponentsHeight = rect1.height;
//
bottomHeight.value = screenHeight - topComponentsHeight - 415;
})
@ -466,10 +439,10 @@
//
const initChart = () => {
setTimeout(async () => {
if (!chart.value) return
const myChart = await chart.value.init(echarts)
myChart.setOption(chartOption.value)
}, 300)
if (!chart.value) return;
const myChart = await chart.value.init(echarts);
myChart.setOption(chartOption.value);
}, 300);
};
</script>
@ -492,7 +465,7 @@
}
.query-btn {
background: #007AFF;
background: #007aff;
color: white;
padding: 0 40rpx;
border-radius: 8rpx;
@ -534,12 +507,11 @@
color: #747474;
line-height: 30px;
height: 30px;
background: #F2F9FC;
background: #f2f9fc;
text-align: center;
vertical-align: middle;
border-left: 1px solid #919191;
border-bottom: 1px solid #919191;
;
}
/* 内容样式 */
@ -558,6 +530,5 @@
border-bottom: 1px solid #919191;
border-left: 1px solid #919191;
text-overflow: ellipsis;
}
</style>