|
|
|
@ -1,12 +1,13 @@
|
|
|
|
|
<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="'所选单位'" 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="'所选单位ID:'+orgCode" 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>
|
|
|
|
|
<!-- 概览统计 -->
|
|
|
|
@ -26,28 +27,39 @@
|
|
|
|
|
<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">
|
|
|
|
@ -58,13 +70,11 @@
|
|
|
|
|
<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>
|
|
|
|
@ -74,17 +84,26 @@
|
|
|
|
|
<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);
|
|
|
|
@ -106,8 +125,8 @@ const drillTitle = ref('');
|
|
|
|
|
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) => {
|
|
|
|
@ -122,22 +141,21 @@ const calculateAge = (birthDate) => {
|
|
|
|
|
};
|
|
|
|
|
// 加载数据
|
|
|
|
|
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.showToast({
|
|
|
|
|
title: '全厂数据较多,请选 下一层级...',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000
|
|
|
|
|
|
|
|
|
|
console.log(123242353)
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '全厂数据较多,耐心等待数据加载中...',
|
|
|
|
|
mask: true
|
|
|
|
|
});
|
|
|
|
|
isLoading.value = false;
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
uni.showLoading({
|
|
|
|
|
title: '数据加载中...',
|
|
|
|
@ -150,34 +168,34 @@ const departChange = async (e, data) => {
|
|
|
|
|
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((err) => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '数据加载失败',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
console.log(error);
|
|
|
|
|
console.log(error)
|
|
|
|
|
uni.showToast({
|
|
|
|
|
title: '数据加载失败',
|
|
|
|
|
icon: 'none',
|
|
|
|
|
duration: 1000
|
|
|
|
|
icon: 'none'
|
|
|
|
|
});
|
|
|
|
|
} finally {
|
|
|
|
|
// 隐藏加载状态
|
|
|
|
@ -186,15 +204,15 @@ const departChange = async (e, data) => {
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 数据处理
|
|
|
|
|
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;
|
|
|
|
@ -204,25 +222,27 @@ const processData = (data) => {
|
|
|
|
|
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
|
|
|
|
@ -236,8 +256,9 @@ const groupsData = (data) => {
|
|
|
|
|
ageGroupStaffs.value[ageRange] = [];
|
|
|
|
|
}
|
|
|
|
|
ageGroupStaffs.value[ageRange].push(cur);
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增年龄范围计算方法
|
|
|
|
|
const getAgeRange = (age) => {
|
|
|
|
@ -249,7 +270,9 @@ const getAgeRange = (age) => {
|
|
|
|
|
// 修改后的显示人员列表方法
|
|
|
|
|
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}人)`;
|
|
|
|
@ -284,13 +307,14 @@ const generateChartData = (data) => {
|
|
|
|
|
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]
|
|
|
|
|
},
|
|
|
|
@ -298,14 +322,14 @@ const generateChartData = (data) => {
|
|
|
|
|
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],
|
|
|
|
@ -353,7 +377,7 @@ const generateChartData = (data) => {
|
|
|
|
|
color: '#7F84B5',
|
|
|
|
|
fontWeight: 300,
|
|
|
|
|
interval: 0,
|
|
|
|
|
rotate: 0
|
|
|
|
|
rotate: 0,
|
|
|
|
|
},
|
|
|
|
|
padding: [0, 10, 0, 10],
|
|
|
|
|
axisTick: {
|
|
|
|
@ -363,8 +387,7 @@ const generateChartData = (data) => {
|
|
|
|
|
show: false //不显示坐标轴线
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
yAxis: [
|
|
|
|
|
{
|
|
|
|
|
yAxis: [{
|
|
|
|
|
show: true,
|
|
|
|
|
boundaryGap: false, //解决数据与线不对应问题
|
|
|
|
|
type: 'value',
|
|
|
|
@ -388,33 +411,37 @@ const generateChartData = (data) => {
|
|
|
|
|
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 = () => {
|
|
|
|
@ -428,7 +455,7 @@ const getHeight = () => {
|
|
|
|
|
.select('#top1')
|
|
|
|
|
.boundingClientRect((rect1) => {
|
|
|
|
|
// 计算上方组件高度总和
|
|
|
|
|
const topComponentsHeight = rect1.height;
|
|
|
|
|
const topComponentsHeight = rect1.height
|
|
|
|
|
// 计算下方组件的高度
|
|
|
|
|
bottomHeight.value = screenHeight - topComponentsHeight - 415;
|
|
|
|
|
})
|
|
|
|
@ -439,10 +466,10 @@ const getHeight = () => {
|
|
|
|
|
// 初始化图表
|
|
|
|
|
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>
|
|
|
|
|
|
|
|
|
@ -465,7 +492,7 @@ const initChart = () => {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
.query-btn {
|
|
|
|
|
background: #007aff;
|
|
|
|
|
background: #007AFF;
|
|
|
|
|
color: white;
|
|
|
|
|
padding: 0 40rpx;
|
|
|
|
|
border-radius: 8rpx;
|
|
|
|
@ -507,11 +534,12 @@ const initChart = () => {
|
|
|
|
|
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;
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* 内容样式 */
|
|
|
|
@ -530,5 +558,6 @@ const initChart = () => {
|
|
|
|
|
border-bottom: 1px solid #919191;
|
|
|
|
|
border-left: 1px solid #919191;
|
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
</style>
|