Compare commits
No commits in common. "fa45d28552e061d0b5c05d9036a3d68baf320e98" and "224e4578dbe04e1c588330f47f315031c11292f2" have entirely different histories.
fa45d28552
...
224e4578db
@ -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
|
@ -1,16 +0,0 @@
|
|||||||
import {
|
|
||||||
https
|
|
||||||
} from '@/utils/http.js';
|
|
||||||
/*
|
|
||||||
这是后端系统通用的系统类的基础性的api路径,后续的大家分类建js存放
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
export function initDictOption(dictCode) { // 获取部门所有人员信息
|
|
||||||
return https({
|
|
||||||
url: ' /sys/dict/getDictItems',
|
|
||||||
method: 'get',
|
|
||||||
data: dictCode
|
|
||||||
})
|
|
||||||
}
|
|
@ -12,31 +12,33 @@
|
|||||||
</uni-card>
|
</uni-card>
|
||||||
|
|
||||||
<uni-card :is-shadow="false">
|
<uni-card :is-shadow="false">
|
||||||
<button type="primary" @click="toQtTongji">通用字段统计</button>
|
<button type="primary" @click="toQtTongji">其他统计</button>
|
||||||
</uni-card>
|
</uni-card>
|
||||||
</uni-section>
|
</uni-section>
|
||||||
</uni-card>
|
</uni-card>
|
||||||
|
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
function toTaizhang() {
|
function toTaizhang() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/views/renliziyuan/renyuanxinxi/taizhang'
|
url: "/pages/views/renliziyuan/renyuanxinxi/taizhang"
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toTongji() {
|
function toTongji() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/views/renliziyuan/renyuanxinxi/tongji'
|
url: "/pages/views/renliziyuan/renyuanxinxi/tongji"
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
function toQtTongji() {
|
function toQtTongji() {
|
||||||
uni.navigateTo({
|
uni.navigateTo({
|
||||||
url: '/pages/views/renliziyuan/renyuanxinxi/qttongji'
|
url: "/pages/views/renliziyuan/renyuanxinxi/qttongji"
|
||||||
});
|
})
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style></style>
|
<style>
|
||||||
|
</style>
|
@ -1,75 +1,80 @@
|
|||||||
<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="5"><uni-title :title="'选择单位'" 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-col :span="19">
|
<uni-row style="margin-bottom: 20rpx;margin-left: 30rpx;margin-right: 30rpx;">
|
||||||
|
<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="5"><uni-title :title="'选择字段'" align="left" type="h4"></uni-title></uni-col>
|
<uni-col :span="24">
|
||||||
<uni-col :span="19">
|
<picker mode="selector" :range="fieldList" range-key="label" @change="onFieldChange">
|
||||||
<uni-data-select v-model="selectedField" :localdata="fieldList"
|
<view class="picker">选择字段: {{ selectedFieldLabel }}</view>
|
||||||
@change="onFieldChange"></uni-data-select>
|
</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" />
|
<l-echart ref="chart" @finished="initChart" @tap="onChartClick" />
|
||||||
</view>
|
</view>
|
||||||
|
|
||||||
<!-- 翻页按钮 -->
|
|
||||||
<view style="display: flex; justify-content: center; margin-top: 20px">
|
|
||||||
<button @click="prevPage" :disabled="currentPage === 1">上一页</button>
|
|
||||||
<button @click="nextPage" :disabled="currentPage * pageSize >= chartDataCount.value">下一页</button>
|
|
||||||
</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>
|
<view class="titleStyle">
|
||||||
|
序号
|
||||||
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="5">
|
<uni-col :span="5">
|
||||||
<view class="titleStyle">姓名</view>
|
<view class="titleStyle">
|
||||||
|
姓名
|
||||||
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="5">
|
<uni-col :span="5">
|
||||||
<view class="titleStyle">性别</view>
|
<view class="titleStyle">
|
||||||
|
性别
|
||||||
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="5">
|
<uni-col :span="5">
|
||||||
<view class="titleStyle">年龄</view>
|
<view class="titleStyle">
|
||||||
|
年龄
|
||||||
|
</view>
|
||||||
</uni-col>
|
</uni-col>
|
||||||
<uni-col :span="6">
|
<uni-col :span="6">
|
||||||
<view class="titleStyle">操作</view>
|
<view class="titleStyle">
|
||||||
|
操作
|
||||||
|
</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><uni-col :span="5">
|
||||||
<uni-col :span="5">
|
|
||||||
<view class="dataStyle">
|
<view class="dataStyle">
|
||||||
{{ item.xb_dictText }}
|
{{item.xb_dictText}}
|
||||||
</view>
|
</view>
|
||||||
</uni-col>
|
</uni-col><uni-col :span="5">
|
||||||
<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">
|
||||||
@ -87,79 +92,71 @@
|
|||||||
import {
|
import {
|
||||||
ref,
|
ref,
|
||||||
reactive,
|
reactive,
|
||||||
onMounted,
|
onMounted
|
||||||
computed
|
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
import * as echarts from 'echarts';
|
import * as echarts from 'echarts';
|
||||||
import {
|
import {
|
||||||
cxcRyDatAstatistics,
|
cxcRyDatAstatistics,
|
||||||
cxcRyDatAstatisticsDetails
|
cxcRyDatAstatisticsDetails
|
||||||
} from '@/api/renyuan.js';
|
} from '@/api/renyuan.js';
|
||||||
import {
|
|
||||||
initDictOption
|
|
||||||
} from '@/api/common.js';
|
|
||||||
|
|
||||||
// 存储下方组件的高度 tableData
|
// 存储下方组件的高度 tableData
|
||||||
const bottomHeight = ref(0);
|
const bottomHeight = ref(0);
|
||||||
// 新增加载状态
|
// 新增加载状态
|
||||||
const chart = ref(null);
|
const chart = ref(null);
|
||||||
const chartDataCount = ref(0);
|
|
||||||
const fieldList = ref([{
|
const fieldList = ref([{
|
||||||
text: '性别',
|
label: '性别',
|
||||||
value: 'xb',
|
value: 'xb'
|
||||||
isDict: true,
|
|
||||||
dictCode: 'sex'
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '政治面貌',
|
label: '年龄',
|
||||||
value: 'zzmm',
|
value: 'nl'
|
||||||
isDict: false,
|
|
||||||
dictCode: ''
|
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
text: '民族',
|
label: '学历',
|
||||||
value: 'mz',
|
value: 'whcd1'
|
||||||
isDict: true,
|
},
|
||||||
dictCode: 'mz'
|
|
||||||
}
|
|
||||||
]); // 字段列表
|
]); // 字段列表
|
||||||
|
|
||||||
const dictCode = ref("")
|
|
||||||
const fieldisDict = ref(true);
|
|
||||||
|
|
||||||
|
|
||||||
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 fieldValues = ref([]);
|
|
||||||
const chartOption = ref({});
|
|
||||||
|
|
||||||
const chartTitle = computed(() => {
|
const chartOption = ref({
|
||||||
return selectedOrgCodeLabel.value + '人员(' + selectedFieldLabel.value + ')分组统计';
|
tooltip: {
|
||||||
});
|
trigger: 'axis',
|
||||||
|
axisPointer: {
|
||||||
//图标翻页
|
type: 'shadow',
|
||||||
const pageSize = ref(3); // 每页显示的项目数量
|
},
|
||||||
const currentPage = ref(1); // 当前页码
|
},
|
||||||
|
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 = () => {
|
||||||
@ -173,7 +170,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;
|
||||||
})
|
})
|
||||||
@ -185,451 +182,39 @@
|
|||||||
// 初始化图表
|
// 初始化图表
|
||||||
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 prevPage = () => {
|
|
||||||
if (currentPage.value > 1) {
|
|
||||||
currentPage.value--;
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const nextPage = () => {
|
|
||||||
if (currentPage.value * pageSize.value < chartDataCount.value) {
|
|
||||||
currentPage.value++;
|
|
||||||
// 计算当前页数据的起始和结束索引
|
|
||||||
const startIndex = (currentPage.value - 1) * pageSize.value;
|
|
||||||
const endIndex = startIndex + pageSize.value;
|
|
||||||
|
|
||||||
// const tempChartData = temp.slice(startIndex, endIndex);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 更具数据生成图标的option
|
|
||||||
const getChartOption = (tempChartData) => {
|
|
||||||
// let temp = JSON.parse(JSON.stringify(tempchartData[0].children));
|
|
||||||
// chartDataCount.value = temp.length;
|
|
||||||
// // 计算当前页数据的起始和结束索引
|
|
||||||
// const startIndex = (currentPage.value - 1) * pageSize.value;
|
|
||||||
// const endIndex = startIndex + pageSize.value;
|
|
||||||
// // 截取当前页的数据
|
|
||||||
// const tempChartData = temp.slice(startIndex, endIndex);
|
|
||||||
let xData = [];
|
|
||||||
let seriesData = [];
|
|
||||||
// console.log(1, temp);
|
|
||||||
//当前机构下的数据 transformDataForEcharts
|
|
||||||
|
|
||||||
tempChartData.forEach((item) => {
|
|
||||||
xData.push(item.name);
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let i = 0; i < fieldValues.value.length; i++) {
|
|
||||||
let tempData = [];
|
|
||||||
tempChartData.forEach((item) => {
|
|
||||||
if (item.data[i]) {
|
|
||||||
tempData.push(item.data[i]);
|
|
||||||
} else {
|
|
||||||
tempData.push(0);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
seriesData.push({
|
|
||||||
name: fieldValues.value[i],
|
|
||||||
type: 'bar',
|
|
||||||
data: tempData
|
|
||||||
});
|
|
||||||
}
|
|
||||||
let tempOption = {
|
|
||||||
title: {
|
|
||||||
text: chartTitle.value,
|
|
||||||
padding: [0, 0, 0, 30]
|
|
||||||
},
|
|
||||||
toolbox: {
|
|
||||||
padding: [0, 30, 0, 0],
|
|
||||||
show: true,
|
|
||||||
feature: {
|
|
||||||
//工具配置项
|
|
||||||
|
|
||||||
restore: {
|
|
||||||
show: true //是否显示该工具
|
|
||||||
},
|
|
||||||
saveAsImage: {
|
|
||||||
show: true //是否显示该工具
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
xAxis: {
|
|
||||||
type: 'category',
|
|
||||||
data: xData,
|
|
||||||
axisLabel: {
|
|
||||||
color: '#7F84B5',
|
|
||||||
fontWeight: 300,
|
|
||||||
interval: 0,
|
|
||||||
rotate: 0
|
|
||||||
},
|
|
||||||
padding: [0, 10, 0, 10],
|
|
||||||
axisTick: {
|
|
||||||
show: false //刻度线
|
|
||||||
},
|
|
||||||
axisLine: {
|
|
||||||
show: false //不显示坐标轴线
|
|
||||||
}
|
|
||||||
},
|
|
||||||
yAxis: [{
|
|
||||||
show: true,
|
|
||||||
boundaryGap: false, //解决数据与线不对应问题
|
|
||||||
type: 'value',
|
|
||||||
// name: 'Budget (million USD)',
|
|
||||||
// data: this.yList,
|
|
||||||
minInterval: 1,
|
|
||||||
axisLabel: {
|
|
||||||
interval: 0
|
|
||||||
},
|
|
||||||
splitLine: {
|
|
||||||
show: true,
|
|
||||||
lineStyle: {
|
|
||||||
//背景网格线
|
|
||||||
type: 'dashed'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
|
|
||||||
axisTick: {
|
|
||||||
show: true //刻度线
|
|
||||||
},
|
|
||||||
axisLine: {
|
|
||||||
show: false //不显示坐标轴线
|
|
||||||
}
|
|
||||||
}],
|
|
||||||
series: seriesData,
|
|
||||||
|
|
||||||
legend: {
|
|
||||||
data: fieldValues.value,
|
|
||||||
itemGap: 5,
|
|
||||||
padding: [0, 15, 0, 15],
|
|
||||||
y: 'bottom',
|
|
||||||
itemHeight: 8, //高
|
|
||||||
itemWidth: 18, //宽
|
|
||||||
type: 'scroll'
|
|
||||||
}
|
|
||||||
};
|
|
||||||
return tempOption
|
|
||||||
}
|
|
||||||
|
|
||||||
// 更新图表
|
// 更新图表
|
||||||
const updateChart = (tempchartData) => {
|
const updateChart = () => {
|
||||||
// 初始化图表
|
if (!chart) return;
|
||||||
setTimeout(async () => {
|
const {
|
||||||
if (!chart.value) return;
|
xb,
|
||||||
const myChart = await chart.value.init(echarts);
|
number
|
||||||
console.log(tempchartData);
|
} = chartData.value;
|
||||||
|
chart.setOption({
|
||||||
|
xAxis: {
|
||||||
myChart.setOption(getChartOption(temp));
|
data: xb,
|
||||||
// 点击钻取事件
|
},
|
||||||
myChart.on('click', (params) => {
|
series: [{
|
||||||
console.log(params.name, params.seriesIndex, params.dataIndex);
|
data: number,
|
||||||
console.log(orgCodeGroupData.value);
|
}, ],
|
||||||
let updateData = findRyByOrgCode(orgCodeGroupData.value.children, params.name);
|
|
||||||
// console.log(updateData);
|
|
||||||
|
|
||||||
const ldhth = updateData.fieldValues[params.dataIndex].ldhth;
|
|
||||||
|
|
||||||
console.log(ldhth);
|
|
||||||
|
|
||||||
if (ldhth && ldhth.length > 0) {
|
|
||||||
fetchPersonnelList(ldhth);
|
|
||||||
}
|
|
||||||
// updateChart(updateData);
|
|
||||||
});
|
|
||||||
}, 300);
|
|
||||||
};
|
|
||||||
//根据一个键值查找数据
|
|
||||||
//查找人员劳动合同号
|
|
||||||
function findRyByOrgCode(treeData, targetOrgCode) {
|
|
||||||
// console.log(treeData, targetOrgCode);
|
|
||||||
for (const node of treeData) {
|
|
||||||
// 如果当前节点匹配,直接返回该节点及其子节点
|
|
||||||
if (node.orgCode === targetOrgCode) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
// 递归检查子节点
|
|
||||||
if (node.children && node.children.length > 0) {
|
|
||||||
const found = findNodeByOrgCode(node.children, targetOrgCode);
|
|
||||||
if (found) return found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 从echart图标的树状数据中根据 orgCode 获取节点及其子节点数据
|
|
||||||
* @param {Array} treeData 树状数据
|
|
||||||
* @param {string} targetOrgCode 目标 orgCode
|
|
||||||
* @returns {Object|null} 匹配的节点及其子节点数据,未找到返回 null
|
|
||||||
*/
|
|
||||||
function findNodeByOrgCode(treeData, targetOrgCode) {
|
|
||||||
// console.log(treeData, targetOrgCode);
|
|
||||||
for (const node of treeData) {
|
|
||||||
// 如果当前节点匹配,直接返回该节点及其子节点
|
|
||||||
if (node.name === targetOrgCode) {
|
|
||||||
return node;
|
|
||||||
}
|
|
||||||
// 递归检查子节点
|
|
||||||
if (node.children && node.children.length > 0) {
|
|
||||||
const found = findNodeByOrgCode(node.children, targetOrgCode);
|
|
||||||
if (found) return found;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
//获取所有的fieldValue
|
|
||||||
function collectUniqueKeyValues(tree, key) {
|
|
||||||
const uniqueValues = new Set(); // 使用Set来自动处理唯一性
|
|
||||||
|
|
||||||
function traverse(node) {
|
|
||||||
if (node[key] !== undefined) {
|
|
||||||
uniqueValues.add(node[key]);
|
|
||||||
}
|
|
||||||
if (node.children && Array.isArray(node.children)) {
|
|
||||||
node.children.forEach((child) => traverse(child));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
tree.forEach((node) => traverse(node)); // 假设tree是一个数组
|
|
||||||
|
|
||||||
return Array.from(uniqueValues); // 将Set转换为数组
|
|
||||||
}
|
|
||||||
|
|
||||||
// 示例用法
|
|
||||||
// const result = findNodeByOrgCode(echartData, "A01A01A01A01");
|
|
||||||
// console.log(result);
|
|
||||||
/**
|
|
||||||
* 转换数据为支持钻取的ECharts格式
|
|
||||||
* @param {Array} data 原始数据
|
|
||||||
* @param {string} selectOrgCode 当前选择的组织编码
|
|
||||||
* @returns {Object} 包含当前层级数据和子节点信息的对象 符合echart的格式
|
|
||||||
*/
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------
|
|
||||||
function transformData(selectOrgCode, data) {
|
|
||||||
const nodes = new Map();
|
|
||||||
//获取所有的fieldValue 用于图例和钻取和data[]中的数据顺序保持一致 动态建立fieldValue的数据
|
|
||||||
fieldValues.value = collectUniqueKeyValues(data, 'fieldValue');
|
|
||||||
// 获取orgCode的所有层级
|
|
||||||
function getHierarchy(orgCode) {
|
|
||||||
const hierarchy = [];
|
|
||||||
for (let i = selectOrgCode.length; i <= orgCode.length; i += 3) {
|
|
||||||
hierarchy.push(orgCode.substring(0, i));
|
|
||||||
}
|
|
||||||
// console.log('hierarchy', hierarchy);
|
|
||||||
return hierarchy;
|
|
||||||
}
|
|
||||||
// 获取父级orgCode
|
|
||||||
function getParentCode(code) {
|
|
||||||
if (code.length <= 3) return null;
|
|
||||||
return code.substring(0, code.length - 3);
|
|
||||||
}
|
|
||||||
// 动态赋值series的数据长度
|
|
||||||
let tempArrayValue = new Array(fieldValues.value.length).fill(0);
|
|
||||||
// 创建所有节点并建立父子关系
|
|
||||||
data.forEach((entry) => {
|
|
||||||
const hierarchy = getHierarchy(entry.orgCode);
|
|
||||||
hierarchy.forEach((code) => {
|
|
||||||
if (!nodes.has(code)) {
|
|
||||||
nodes.set(code, {
|
|
||||||
orgCode: code,
|
|
||||||
type: 'bar',
|
|
||||||
data: JSON.parse(JSON.stringify(tempArrayValue)), // 初始化data为[0, 0] 动态
|
|
||||||
children: []
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// console.log('fieldValues', fieldValues.value, fieldValues.value.length, hierarchy);
|
|
||||||
|
|
||||||
// 更新当前节点的data
|
|
||||||
const node = nodes.get(entry.orgCode);
|
|
||||||
const fieldValue = parseInt(entry.fieldValue, 10);
|
|
||||||
|
|
||||||
for (let i = 0; i < fieldValues.value.length; i++) {
|
|
||||||
if (fieldValue === parseInt(fieldValues.value[i], 10)) {
|
|
||||||
// console.log(555, i, fieldValue, fieldValues.value[i], entry.number);
|
|
||||||
node.data[i] += entry.number;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log(11, node);
|
|
||||||
|
|
||||||
// 建立父子关系
|
|
||||||
for (let i = 0; i < hierarchy.length - 1; i++) {
|
|
||||||
const parentCode = hierarchy[i];
|
|
||||||
const childCode = hierarchy[i + 1];
|
|
||||||
const parentNode = nodes.get(parentCode);
|
|
||||||
const childNode = nodes.get(childCode);
|
|
||||||
if (!parentNode.children.some((c) => c.orgCode === childCode)) {
|
|
||||||
parentNode.children.push(childNode);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// 计算非叶子节点的data(子节点之和)
|
|
||||||
function computeData(node) {
|
|
||||||
if (node.children.length === 0) return;
|
|
||||||
node.data = JSON.parse(JSON.stringify(tempArrayValue));
|
|
||||||
node.children.forEach((child) => {
|
|
||||||
computeData(child);
|
|
||||||
for (let i = 0; i < fieldValues.value.length; i++) {
|
|
||||||
// console.log(666, i, node.data[i], child.data[i]);
|
|
||||||
node.data[i] += child.data[i];
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
// 获取所有根节点(没有父节点或父节点不存在)
|
|
||||||
const rootNodes = [];
|
|
||||||
nodes.forEach((node, code) => {
|
|
||||||
const parentCode = getParentCode(code);
|
|
||||||
// console.log(parentCode);
|
|
||||||
if (!parentCode || !nodes.has(parentCode)) {
|
|
||||||
rootNodes.push(node);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// 递归计算每个根节点的data
|
|
||||||
rootNodes.forEach((root) => computeData(root));
|
|
||||||
// console.log('rootNodes', rootNodes);
|
|
||||||
// 转换为目标格式
|
|
||||||
function formatTree(node) {
|
|
||||||
return {
|
|
||||||
name: node.orgCode,
|
|
||||||
type: 'bar',
|
|
||||||
data: node.data,
|
|
||||||
children: node.children.map((child) => formatTree(child))
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
return rootNodes.map((root) => formatTree(root));
|
|
||||||
}
|
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------------------
|
|
||||||
|
|
||||||
//根据 orgCode 的分级格式,递归地汇总本级及其所有下级的数据,并将下级数据放在本级的 children 属性中。 deepseek
|
|
||||||
|
|
||||||
const groupByOrgCode = (orgCode, data) => {
|
|
||||||
// 过滤出本级和所有下级的数据
|
|
||||||
console.log(1, data)
|
|
||||||
const filteredData = data.filter((item) => item.orgCode.startsWith(orgCode));
|
|
||||||
console.log(2, filteredData)
|
|
||||||
// 如果过滤后的数据为空,返回 null
|
|
||||||
if (filteredData.length === 0) {
|
|
||||||
uni.showToast({
|
|
||||||
title: "过滤后数据为空",
|
|
||||||
duration: 1000
|
|
||||||
})
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 按照 fieldValue 分组
|
|
||||||
const groupedByFieldValue = {};
|
|
||||||
try {
|
|
||||||
filteredData.forEach((item) => {
|
|
||||||
// console.log(item.orgCode, 11, groupedByFieldValue[item.fieldValue]);
|
|
||||||
if (!groupedByFieldValue[item.fieldValue]) {
|
|
||||||
groupedByFieldValue[item.fieldValue] = {
|
|
||||||
number: 0,
|
|
||||||
ldhth: []
|
|
||||||
};
|
|
||||||
}
|
|
||||||
// console.log(item.orgCode, 22, groupedByFieldValue[item.fieldValue]);
|
|
||||||
groupedByFieldValue[item.fieldValue].number += item.number;
|
|
||||||
groupedByFieldValue[item.fieldValue].ldhth.push(...item.ldhth.split(','));
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
// 构建本级结果
|
|
||||||
const result = {
|
|
||||||
orgCode: orgCode,
|
|
||||||
fieldValues: Object.keys(groupedByFieldValue).map((fieldValue) => ({
|
|
||||||
fieldValue: fieldValue,
|
|
||||||
number: groupedByFieldValue[fieldValue].number,
|
|
||||||
ldhth: [...new Set(groupedByFieldValue[fieldValue].ldhth)] // 去重
|
|
||||||
})),
|
|
||||||
children: []
|
|
||||||
};
|
|
||||||
|
|
||||||
// console.log('本级', result);
|
|
||||||
|
|
||||||
// 获取所有下一级的 orgCode
|
|
||||||
const nextLevelOrgCodes = new Set();
|
|
||||||
try {
|
|
||||||
filteredData.forEach((item) => {
|
|
||||||
if (item.orgCode !== orgCode && item.orgCode.startsWith(orgCode)) {
|
|
||||||
const nextLevelOrgCode = item.orgCode.substring(0, orgCode.length + 3);
|
|
||||||
nextLevelOrgCodes.add(nextLevelOrgCode);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error)
|
|
||||||
}
|
|
||||||
// 递归处理下一级数据
|
|
||||||
try {
|
|
||||||
|
|
||||||
nextLevelOrgCodes.forEach((nextLevelOrgCode) => {
|
|
||||||
const child = groupByOrgCode(nextLevelOrgCode, data);
|
|
||||||
if (child) {
|
|
||||||
result.children.push(child);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
} catch (error) {
|
|
||||||
console.log(error)
|
|
||||||
}
|
|
||||||
|
|
||||||
// console.log('全部', result);
|
|
||||||
|
|
||||||
return result;
|
|
||||||
};
|
};
|
||||||
// 获取统计数据 then filter
|
// 获取统计数据
|
||||||
const fetchStatisticsData = async () => {
|
const fetchStatisticsData = async () => {
|
||||||
if (!selectedOrgCode.value || !selectedField.value) return;
|
if (!selectedOrgCode.value || !selectedField.value) return;
|
||||||
let res = []
|
|
||||||
try {
|
try {
|
||||||
res = await cxcRyDatAstatistics({
|
const res = await cxcRyDatAstatistics({
|
||||||
orgCode: selectedOrgCode.value,
|
orgCode: selectedOrgCode.value,
|
||||||
field: selectedField.value,
|
field: selectedField.value,
|
||||||
dictCode: dictCode.value,
|
|
||||||
fieldisDict: fieldisDict.value
|
|
||||||
});
|
});
|
||||||
console.log(res); //deepseek
|
console.log(res)
|
||||||
if (res.length = 0) {
|
chartData.value = res.data;
|
||||||
uni.showToast({
|
updateChart();
|
||||||
title: "查询数据为空"
|
|
||||||
})
|
|
||||||
return
|
|
||||||
} else {
|
|
||||||
console.log(selectedOrgCode.value, res);
|
|
||||||
orgCodeGroupData.value = groupByOrgCode(selectedOrgCode.value, res);
|
|
||||||
console.log(orgCodeGroupData.value);
|
|
||||||
chartData.value = transformData(selectedOrgCode.value, res);
|
|
||||||
|
|
||||||
let temp = []
|
|
||||||
if (chartData.value[0].children.length > 0) {
|
|
||||||
temp = JSON.parse(JSON.stringify(chartData.value[0].children));
|
|
||||||
} else {
|
|
||||||
temp = chartData.value[0]
|
|
||||||
}
|
|
||||||
console.log(temp)
|
|
||||||
chartDataCount.value = temp.length;
|
|
||||||
// console.log(chartData.value);
|
|
||||||
updateChart(temp);
|
|
||||||
}
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('获取统计数据失败:', error);
|
console.error('获取统计数据失败:', error);
|
||||||
}
|
}
|
||||||
@ -641,39 +226,26 @@
|
|||||||
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, data) => {
|
const onOrgCodeChange = (e) => {
|
||||||
|
console.log(e)
|
||||||
selectedOrgCode.value = e;
|
selectedOrgCode.value = e;
|
||||||
console.log(data.value.title);
|
|
||||||
selectedOrgCodeLabel.value = data.value.title;
|
|
||||||
fetchStatisticsData();
|
fetchStatisticsData();
|
||||||
};
|
};
|
||||||
|
|
||||||
const onFieldChange = (e) => {
|
const onFieldChange = (e) => {
|
||||||
console.log(e);
|
const index = e.detail.value;
|
||||||
try {
|
selectedField.value = fieldList.value[index].value;
|
||||||
selectedField.value = e;
|
selectedFieldLabel.value = fieldList.value[index].label;
|
||||||
for (var index = 0; index < fieldList.value.length; index++) {
|
fetchStatisticsData();
|
||||||
var element = fieldList.value[index];
|
|
||||||
console.log(element);
|
|
||||||
if (element.value === e) {
|
|
||||||
selectedFieldLabel.value = element.text;
|
|
||||||
dictCode.value = element.dictCode
|
|
||||||
fieldisDict.value = element.isDict
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fetchStatisticsData();
|
|
||||||
} catch (error) {
|
|
||||||
//TODO handle the exception
|
|
||||||
console.log(error);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onChartClick = (e) => {
|
const onChartClick = (e) => {
|
||||||
@ -685,155 +257,92 @@
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
/* 颜色变量 */
|
|
||||||
:root {
|
|
||||||
--primary-blue: #409eff;
|
|
||||||
--deep-blue: #2c7be5;
|
|
||||||
--light-blue: #ecf5ff;
|
|
||||||
--gradient-start: #6b8cff;
|
|
||||||
--gradient-end: #4364f7;
|
|
||||||
--hover-blue: #66b1ff;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 全局容器 */
|
|
||||||
.container {
|
.container {
|
||||||
margin: 10rpx 10rpx;
|
margin: 20, 20, 20, 20rpx;
|
||||||
padding: 10rpx;
|
|
||||||
background: linear-gradient(145deg, #f5f9ff, var(--light-blue));
|
|
||||||
border-radius: 24rpx;
|
|
||||||
box-shadow: 0 8rpx 24rpx rgba(64, 158, 255, 0.15);
|
|
||||||
border: 2rpx solid rgba(64, 158, 255, 0.1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 图表容器 */
|
.input-group {
|
||||||
.chart-container {
|
display: flex;
|
||||||
height: 50vh;
|
gap: 20rpx;
|
||||||
margin: 20rpx 0;
|
margin-bottom: 30rpx;
|
||||||
border-radius: 24rpx;
|
|
||||||
overflow: hidden;
|
|
||||||
background: #ffffff;
|
|
||||||
box-shadow: 0 8rpx 32rpx rgba(64, 158, 255, 0.12);
|
|
||||||
border: 2rpx solid rgba(64, 158, 255, 0.08);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 表格标题行 */
|
.input {
|
||||||
.titleStyle {
|
flex: 1;
|
||||||
font-size: 28rpx;
|
border: 1rpx solid #ddd;
|
||||||
font-weight: 600;
|
padding: 15rpx;
|
||||||
color: #ffffff;
|
border-radius: 8rpx;
|
||||||
background: linear-gradient(135deg, var(--gradient-start), var(--gradient-end));
|
|
||||||
padding: 28rpx 0;
|
|
||||||
border-radius: 16rpx 16rpx 0 0;
|
|
||||||
box-shadow: 0 4rpx 12rpx rgba(67, 100, 247, 0.2);
|
|
||||||
letter-spacing: 1rpx;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 数据行 */
|
.query-btn {
|
||||||
.dataStyle {
|
background: #007AFF;
|
||||||
font-size: 28rpx;
|
color: white;
|
||||||
color: #3a466b;
|
padding: 0 40rpx;
|
||||||
padding: 32rpx 0;
|
border-radius: 8rpx;
|
||||||
background: #ffffff;
|
|
||||||
border-bottom: 2rpx solid #f0f6ff;
|
|
||||||
transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.dataStyle:hover {
|
.stats-box {
|
||||||
background: #f8fbff;
|
display: flex;
|
||||||
transform: translateY(-2rpx);
|
justify-content: space-around;
|
||||||
}
|
|
||||||
|
|
||||||
/* 操作按钮 */
|
|
||||||
button[type='primary'] {
|
|
||||||
background: linear-gradient(135deg, var(--primary-blue), var(--deep-blue));
|
|
||||||
border: none;
|
|
||||||
border-radius: 12rpx;
|
|
||||||
padding: 12rpx 32rpx;
|
|
||||||
font-size: 26rpx;
|
|
||||||
box-shadow: 0 6rpx 16rpx rgba(64, 158, 255, 0.3);
|
|
||||||
transition: all 0.25s ease;
|
|
||||||
}
|
|
||||||
|
|
||||||
button[type='primary']:active {
|
|
||||||
transform: scale(0.96);
|
|
||||||
box-shadow: 0 4rpx 8rpx rgba(64, 158, 255, 0.3);
|
|
||||||
background: linear-gradient(135deg, var(--deep-blue), var(--primary-blue));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 滚动区域 */
|
|
||||||
scroll-view {
|
|
||||||
background: #ffffff;
|
|
||||||
border-radius: 0 0 16rpx 16rpx;
|
|
||||||
box-shadow: 0 8rpx 24rpx rgba(0, 35, 111, 0.08);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 输入框聚焦效果 */
|
|
||||||
.trq-depart-select:focus-within {
|
|
||||||
box-shadow: 0 0 0 4rpx rgba(64, 158, 255, 0.2);
|
|
||||||
border-color: var(--primary-blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 加载动画优化 */
|
|
||||||
@keyframes fadeIn {
|
|
||||||
from {
|
|
||||||
opacity: 0;
|
|
||||||
transform: translateY(20rpx);
|
|
||||||
}
|
|
||||||
|
|
||||||
to {
|
|
||||||
opacity: 1;
|
|
||||||
transform: translateY(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.container>* {
|
|
||||||
animation: fadeIn 0.6s cubic-bezier(0.23, 1, 0.32, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 自定义滚动条美化 */
|
|
||||||
::-webkit-scrollbar {
|
|
||||||
width: 8rpx;
|
|
||||||
background: rgba(64, 158, 255, 0.05);
|
|
||||||
}
|
|
||||||
|
|
||||||
::-webkit-scrollbar-thumb {
|
|
||||||
background: linear-gradient(45deg, var(--primary-blue), var(--deep-blue));
|
|
||||||
border-radius: 12rpx;
|
|
||||||
border: 2rpx solid white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 筛选行间距优化 */
|
|
||||||
.filter-row {
|
|
||||||
margin: 30rpx 0;
|
margin: 30rpx 0;
|
||||||
padding: 20rpx 0;
|
padding: 20rpx;
|
||||||
border-radius: 16rpx;
|
background: #f8f8f8;
|
||||||
|
border-radius: 12rpx;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 响应式调整优化 */
|
.stat-item {
|
||||||
@media (max-width: 768px) {
|
display: flex;
|
||||||
.chart-container {
|
flex-direction: column;
|
||||||
height: 55vh;
|
align-items: center;
|
||||||
border-radius: 20rpx;
|
|
||||||
}
|
|
||||||
|
|
||||||
.titleStyle {
|
|
||||||
font-size: 26rpx;
|
|
||||||
padding: 24rpx 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
button[type='primary'] {
|
|
||||||
padding: 10rpx 24rpx;
|
|
||||||
font-size: 24rpx;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* 数据行高亮效果 */
|
.label {
|
||||||
.data-row:nth-child(even) {
|
font-size: 24rpx;
|
||||||
background: rgba(236, 245, 255, 0.3);
|
color: #666;
|
||||||
}
|
}
|
||||||
|
|
||||||
.data-row:hover {
|
.value {
|
||||||
box-shadow: 0 4rpx 12rpx rgba(64, 158, 255, 0.1);
|
font-size: 36rpx;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #0000ff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.chart-container {
|
||||||
|
height: 400rpx;
|
||||||
|
margin-top: 20rpx;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleStyle {
|
||||||
|
font-size: 12px;
|
||||||
|
color: #747474;
|
||||||
|
line-height: 30px;
|
||||||
|
height: 30px;
|
||||||
|
background: #F2F9FC;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-left: 1px solid #919191;
|
||||||
|
border-bottom: 1px solid #919191;
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* 内容样式 */
|
||||||
|
.dataStyle {
|
||||||
|
max-font-size: 14px;
|
||||||
|
/* 最大字体限制 */
|
||||||
|
min-font-size: 10px;
|
||||||
|
/* 最小字体限制 */
|
||||||
|
font-size: 12px;
|
||||||
|
color: #00007f;
|
||||||
|
line-height: 30px;
|
||||||
|
height: 30px;
|
||||||
|
font-weight: 500;
|
||||||
|
text-align: center;
|
||||||
|
vertical-align: middle;
|
||||||
|
border-bottom: 1px solid #919191;
|
||||||
|
border-left: 1px solid #919191;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue
Block a user