# Conflicts:
#	.env.development
#	pages/views/renliziyuan/renyuanxinxi/index.vue
This commit is contained in:
ldeyun 2025-02-12 13:58:11 +08:00
commit 60ce182912
3 changed files with 258 additions and 90 deletions

View File

@ -1,4 +1,4 @@
# 开发环境 # 开发环境
# 请求接口地址 # 请求接口地址
VITE_REQUEST_BASE_URL = https://36.112.48.190 #VITE_REQUEST_BASE_URL = https://36.112.48.190
#VITE_REQUEST_BASE_URL = http://10.75.15.247:8080 VITE_REQUEST_BASE_URL = http://10.75.15.247:8080

View File

@ -15,6 +15,11 @@
<button type="primary" @click="toQtTongji">其他统计</button> <button type="primary" @click="toQtTongji">其他统计</button>
</uni-card> </uni-card>
</uni-section> </uni-section>
<uni-section title="人员统计" type="line">
<uni-card :is-shadow="false">
<button type="primary">人员统计</button>
</uni-card>
</uni-section>
</uni-card> </uni-card>
</view> </view>

View File

@ -1,80 +1,70 @@
<template> <template>
<view> <view>
<view class="container" id="top1"> <view class="container" id="top1">
<uni-row style="margin-bottom: 10rpx;margin-left: 30rpx;margin-right: 30rpx;"> <uni-row style="margin-bottom: 10rpx; margin-left: 30rpx; margin-right: 30rpx">
<uni-col :span="24"><uni-title :title="'所选单位ID'" align="left" type="h4"></uni-title></uni-col> <uni-col :span="24"><uni-title :title="'所选单位ID'" align="left" type="h4"></uni-title></uni-col>
</uni-row> </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"> <uni-col :span="24">
<trq-depart-select v-model="selectedOrgCode" returnCodeOrID="orgCode" <trq-depart-select v-model="selectedOrgCode" returnCodeOrID="orgCode"
@change="onOrgCodeChange"></trq-depart-select> @change="onOrgCodeChange"></trq-depart-select>
</uni-col> </uni-col>
</uni-row> </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"> <uni-col :span="24">
<picker mode="selector" :range="fieldList" range-key="label" @change="onFieldChange"> <picker mode="selector" :range="fieldList" range-key="label" @change="onFieldChange">
<view class="picker">选择字段: {{ selectedFieldLabel }}</view> <view class="picker">选择字段: {{ selectedFieldLabel }}</view>
</picker> </picker>
</uni-col> </uni-col>
</uni-row> </uni-row>
</view> </view>
<!-- ECharts图表 --> <!-- ECharts图表 -->
<view class="chart-container"> <view class="chart-container">
<l-echart ref="chart" @finished="initChart" @tap="onChartClick" /> <l-echart ref="chart" @finished="initChart" />
</view> </view>
<!-- 数据表格 --> <!-- 数据表格 -->
<uni-row style="margin-top: 10px; margin-left: 30rpx;margin-right: 30rpx;" v-if="personnelList.length>0"> <uni-row style="margin-top: 10px; margin-left: 30rpx; margin-right: 30rpx" v-if="personnelList.length > 0">
<uni-col :span="3"> <uni-col :span="3">
<view class="titleStyle"> <view class="titleStyle">序号</view>
序号
</view>
</uni-col> </uni-col>
<uni-col :span="5"> <uni-col :span="5">
<view class="titleStyle"> <view class="titleStyle">姓名</view>
姓名
</view>
</uni-col> </uni-col>
<uni-col :span="5"> <uni-col :span="5">
<view class="titleStyle"> <view class="titleStyle">性别</view>
性别
</view>
</uni-col> </uni-col>
<uni-col :span="5"> <uni-col :span="5">
<view class="titleStyle"> <view class="titleStyle">年龄</view>
年龄
</view>
</uni-col> </uni-col>
<uni-col :span="6"> <uni-col :span="6">
<view class="titleStyle"> <view class="titleStyle">操作</view>
操作
</view>
</uni-col> </uni-col>
</uni-row> </uni-row>
<scroll-view scroll-y :style="{height: bottomHeight + 'px' }"> <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 personnelList"> <view v-for="(item, index) in personnelList">
<uni-col :span="3"> <uni-col :span="3">
<view class="dataStyle"> <view class="dataStyle">
{{index+1}} {{ index + 1 }}
</view> </view>
</uni-col> </uni-col>
<uni-col :span="5"> <uni-col :span="5">
<view class="dataStyle"> <view class="dataStyle">
{{item.xm}} {{ item.xm }}
</view> </view>
</uni-col><uni-col :span="5"> </uni-col>
<uni-col :span="5">
<view class="dataStyle"> <view class="dataStyle">
{{item.xb_dictText}} {{ item.xb_dictText }}
</view> </view>
</uni-col><uni-col :span="5"> </uni-col>
<uni-col :span="5">
<view class="dataStyle"> <view class="dataStyle">
{{item.nl}} {{ item.nl }}
</view> </view>
</uni-col> </uni-col>
<uni-col :span="6"> <uni-col :span="6">
@ -113,50 +103,31 @@
}, },
{ {
label: '学历', label: '学历',
value: 'whcd1' value: 'rylb1'
}, }
]); // ]); //
const selectedOrgCode = ref(''); // orgCode const selectedOrgCode = ref(''); // orgCode
const selectedOrgCodeLabel = ref('请选择单位'); // const selectedOrgCodeLabel = ref('请选择单位'); //
const selectedField = ref(''); // const selectedField = ref(''); //
const selectedFieldLabel = ref('请选择字段'); // const selectedFieldLabel = ref('请选择字段'); //
const orgCodeGroupData = ref([]); //orgcode
const chartData = ref({}); // const chartData = ref({}); //
const personnelList = ref([]); // initChart const personnelList = ref([]); // initChart
const chartOption = ref({ const chartOption = ref({});
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow',
},
},
xAxis: {
type: 'category',
data: [],
},
yAxis: {
type: 'value',
},
series: [{
name: '数量',
type: 'bar',
data: [],
}, ],
})
function detail(record) { function detail(record) {
// console.log(record) // console.log(record)
uni.navigateTo({ uni.navigateTo({
url: "/pages/views/renliziyuan/renyuanxinxi/detail?data=" + encodeURIComponent(JSON.stringify(record)) url: '/pages/views/renliziyuan/renyuanxinxi/detail?data=' + encodeURIComponent(JSON.stringify(record))
}) });
} }
onMounted(() => { onMounted(() => {
// #ifdef APP // #ifdef APP
getHeight(); getHeight();
// #endif // #endif
}) });
// #ifdef APP // #ifdef APP
const getHeight = () => { const getHeight = () => {
@ -170,7 +141,7 @@
.select('#top1') .select('#top1')
.boundingClientRect((rect1) => { .boundingClientRect((rect1) => {
// //
const topComponentsHeight = rect1.height const topComponentsHeight = rect1.height;
// //
bottomHeight.value = screenHeight - topComponentsHeight - 415; bottomHeight.value = screenHeight - topComponentsHeight - 415;
}) })
@ -182,38 +153,232 @@
// //
const initChart = () => { const initChart = () => {
setTimeout(async () => { setTimeout(async () => {
if (!chart.value) return if (!chart.value) return;
const myChart = await chart.value.init(echarts) const myChart = await chart.value.init(echarts);
myChart.setOption(chartOption.value) myChart.setOption(chartOption.value);
}, 300) }, 300);
}; };
// //
const updateChart = () => { const updateChart = () => {
if (!chart) return; //
const { setTimeout(async () => {
xb, if (!chart.value) return;
number const myChart = await chart.value.init(echarts);
} = chartData.value; chartOption.value = transformDataForEcharts(chartData.value, selectedOrgCode.value);
chart.setOption({ myChart.setOption({
xAxis: { xAxis: {
data: xb, type: 'category',
data: chartOption.value.categories.map((code) =>
`${code}${chartOption.value.children ? ' ▶' : ''}`)
}, },
series: [{ yAxis: {
data: number, type: 'value'
}, ], },
series: chartOption.value.series,
tooltip: {
trigger: 'axis'
},
legend: {
data: chartOption.value.series.map((s) => s.name)
}
}); });
//
myChart.on('click', (params) => {
const clickedCode = params.name.split(' ')[0];
const nextData = transformDataForEcharts(originalData, clickedCode);
if (nextData.categories.length > 0) {
historyStack.push(currentLevel);
currentLevel = clickedCode;
renderChart(nextData);
} else if (nextData.children) {
historyStack.push(currentLevel);
currentLevel = clickedCode;
chartData = transformDataForEcharts(originalData, currentLevel);
renderChart(chartData);
} else {
console.log('已是最末级节点');
}
});
}, 300);
}; };
//
/**
* 转换数据为支持钻取的ECharts格式
* @param {Array} data 原始数据
* @param {string} currentOrgCode 当前组织编码
* @returns {Object} 包含当前层级数据和子节点信息的对象
*/
function transformDataForEcharts(data, currentOrgCode = '') {
// +3
const currentLevel = currentOrgCode.length;
const nextLevel = currentLevel + 3;
console.log(currentLevel, nextLevel, currentOrgCode, data);
//
let currentLevelData = {}
currentLevelData.orgCode = currentOrgCode
currentLevelData.data = data.fieldValues;
console.log(1, data.children);
// orgCode
const xAxisData = [];
// fieldValue
const legendData = [];
// fieldValue
const seriesData = [];
//
const processNode = (node) => {
try {
const orgCode = node.orgCode;
if (!xAxisData.includes(orgCode)) {
xAxisData.push(orgCode);
}
let tempseries = {}
tempseries.name = node.orgCode
tempseries.type = 'bar'
tempseries.data = []
node.fieldValues.forEach(fieldValueObj => {
let number = 0;
if (!fieldValueObj) {
const fieldValue = fieldValueObj.fieldValue;
if (!legendData.includes(fieldValue)) {
legendData.push(fieldValue);
}
number = fieldValueObj.number;
tempseries.data.push(number)
} else {
tempseries.data.push(0)
}
console.log(22, node.orgCode, number)
})
seriesData.push(tempseries)
};
// console.log(2, seriesData)
} catch (error) {
console.log(error)
}
if (node.children && node.children.length > 0) {
node.children.forEach(child => {
processNode(child);
});
}
}
console.log(3, seriesData)
//
data.children.forEach(node => {
processNode(node);
});
// seriesData ECharts
const series = Array.from(legendData).map(fieldValue => ({
name: fieldValue,
type: 'bar',
data: seriesData[fieldValue]
}));
console.log(2, xAxisData)
console.log(3, JSON.stringify(legendData))
console.log(4, series)
return {
xAxis: {
type: 'category',
data: xAxisData
},
legend: {
data: Array.from(legendData)
},
series: series
};
}
// 使
// let currentLevel = 'A01A01'; //
// let chartData = transformDataForEcharts(originalData, currentLevel);
// orgCode children deepseek
const groupByOrgCode = (orgCode, data) => {
//
const filteredData = data.filter((item) => item.orgCode.startsWith(orgCode));
// null
if (filteredData.length === 0) {
return null;
}
// fieldValue
const groupedByFieldValue = {};
filteredData.forEach((item) => {
if (!groupedByFieldValue[item.fieldValue]) {
groupedByFieldValue[item.fieldValue] = {
number: 0,
ldhth: []
};
}
groupedByFieldValue[item.fieldValue].number += item.number;
groupedByFieldValue[item.fieldValue].ldhth.push(...item.ldhth.split(','));
});
//
const result = {
orgCode: orgCode,
fieldValues: Object.keys(groupedByFieldValue).map((fieldValue) => ({
fieldValue: fieldValue,
number: groupedByFieldValue[fieldValue].number,
ldhth: [...new Set(groupedByFieldValue[fieldValue].ldhth)] //
})),
children: []
};
// orgCode
const nextLevelOrgCodes = new Set();
filteredData.forEach((item) => {
if (item.orgCode !== orgCode && item.orgCode.startsWith(orgCode)) {
const nextLevelOrgCode = item.orgCode.substring(0, orgCode.length + 3);
nextLevelOrgCodes.add(nextLevelOrgCode);
}
});
//
nextLevelOrgCodes.forEach((nextLevelOrgCode) => {
const child = groupByOrgCode(nextLevelOrgCode, data);
if (child) {
result.children.push(child);
}
});
return result;
};
//-----------------------------------------------------------------------------------------
// then
const fetchStatisticsData = async () => { const fetchStatisticsData = async () => {
if (!selectedOrgCode.value || !selectedField.value) return; if (!selectedOrgCode.value || !selectedField.value) return;
try { try {
const res = await cxcRyDatAstatistics({ const res = await cxcRyDatAstatistics({
orgCode: selectedOrgCode.value, orgCode: selectedOrgCode.value,
field: selectedField.value, field: selectedField.value
}); });
console.log(res) // console.log(res); //deepseek
chartData.value = res.data; orgCodeGroupData.value = groupByOrgCode(selectedOrgCode.value, res);
console.log(orgCodeGroupData.value);
chartData.value = orgCodeGroupData.value;
updateChart(); updateChart();
} catch (error) { } catch (error) {
console.error('获取统计数据失败:', error); console.error('获取统计数据失败:', error);
@ -226,18 +391,18 @@
const res = await cxcRyDatAstatisticsDetails({ const res = await cxcRyDatAstatisticsDetails({
ldhth: ldhthList ldhth: ldhthList
}); });
console.log(res) console.log(res);
personnelList.value = res.data; personnelList.value = res.data;
} catch (error) { } catch (error) {
console.error('获取人员列表失败:', error); console.error('获取人员列表失败:', error);
} }
}; };
// //
const onOrgCodeChange = (e) => { const onOrgCodeChange = (e, data) => {
console.log(e)
selectedOrgCode.value = e; selectedOrgCode.value = e;
console.log(data.value.title);
selectedOrgCodeLabel.value = data.value.title;
fetchStatisticsData(); fetchStatisticsData();
}; };
@ -277,7 +442,7 @@
} }
.query-btn { .query-btn {
background: #007AFF; background: #007aff;
color: white; color: white;
padding: 0 40rpx; padding: 0 40rpx;
border-radius: 8rpx; border-radius: 8rpx;
@ -310,7 +475,7 @@
} }
.chart-container { .chart-container {
height: 400rpx; height: 800rpx;
margin-top: 20rpx; margin-top: 20rpx;
} }
@ -319,12 +484,11 @@
color: #747474; color: #747474;
line-height: 30px; line-height: 30px;
height: 30px; height: 30px;
background: #F2F9FC; background: #f2f9fc;
text-align: center; text-align: center;
vertical-align: middle; vertical-align: middle;
border-left: 1px solid #919191; border-left: 1px solid #919191;
border-bottom: 1px solid #919191; border-bottom: 1px solid #919191;
;
} }
/* 内容样式 */ /* 内容样式 */
@ -343,6 +507,5 @@
border-bottom: 1px solid #919191; border-bottom: 1px solid #919191;
border-left: 1px solid #919191; border-left: 1px solid #919191;
text-overflow: ellipsis; text-overflow: ellipsis;
} }
</style> </style>