Merge remote-tracking branch 'remotes/origin/ldeyun' into yzqUniapp

# Conflicts:
#	api/renyuan.js
#	manifest.json
#	pages/views/renliziyuan/renyuanxinxi/detail.vue
#	pages/views/renliziyuan/renyuanxinxi/tongji.vue
This commit is contained in:
yangzhq68909 2025-02-07 10:29:20 +08:00
commit aff8d2168a
9 changed files with 611 additions and 557 deletions

View File

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

View File

@ -66,14 +66,6 @@ export function queryJxkhByRyLdhth(ldhth) { // 绩效考核信息
})
}
// ryList: '/cxchrygxxtj/cxcHrYgxxtj/list',
// ryByXb: '/cxcRyData/countByXb',
// ryByNl: '/cxcRyData/countByNl',
// ryByXbTotal: '/cxcRyData/countByXbTotal',
// ryByNlTotal: '/cxcRyData/countByNlTotal',
// bmList: '/sys/sysDepart/queryTreeList'
export function cxcHrYgxxtj(parm) { // 获取员工信息统计
return https({
url: '/cxchrygxxtj/cxcHrYgxxtj/list',
@ -82,33 +74,9 @@ export function cxcHrYgxxtj(parm) { // 获取员工信息统计
})
}
export function cxcRyDatacountByXb(parm) { // 通过性别获取员工信息统计
export function cxcRyDataTongji(url, parm) { // 员工信息统计
return https({
url: '/cxcRyData/countByXb',
method: 'get',
data: parm
})
}
export function cxcRyDatacountByNl(parm) { // 通过年龄获取员工信息统计
return https({
url: '/cxcRyData/countByNl',
method: 'get',
data: parm
})
}
export function cxcRyDatacountByXbTotal(parm) { // 通过性别获取员工信息统计
return https({
url: '/cxcRyData/countByXbTotal',
method: 'get',
data: parm
})
}
export function cxcRyDatacountByNlTotal(parm) { // 通过年龄获取员工信息统计
return https({
url: '/cxcRyData/countByNlTotal',
url: url,
method: 'get',
data: parm
})

View File

@ -230,7 +230,7 @@
{
"path": "pages/views/renliziyuan/renyuanxinxi/tongji",
"style": {
"navigationBarTitleText": "人员统计信息",
"navigationBarTitleText": "人员年龄分组统计信息",
"navigationBarTextStyle": "white"
}

View File

@ -98,17 +98,17 @@
});
/*生产环境 begin */
loginApi({
username: un,
password: pw,
ip: getDeviceIp()
// loginApi({
// username: un,
// password: pw,
// ip: getDeviceIp()
/*生产环境 end */
/*开发环境 begin */
// localLoginApi({
// username: username.value,
// password: password.value,
// captcha: 'app'
localLoginApi({
username: username.value,
password: password.value,
captcha: 'app'
/*开发环境 end */
}).then((loginres) => {
if (loginres.success) {

View File

@ -317,9 +317,9 @@
queryJxkhByRyLdhth({
"ldhth": ldhth.value
}).then((res) => {
console.log(res);
// console.log(res);
jxkhxxList.value = res.result.records
console.log(jxkhxxList.value)
// console.log(jxkhxxList.value)
}).catch((err) => {
console.log(err);
})
@ -379,15 +379,15 @@
xlxxList.value = []
if (res.result.records.length > 0) {
var rress = res.result.records
console.log(rress);
// console.log(rress);
for (let i = 0; i < rress.length; i++) {
if (rress[i].onexl == 1 & rress[i].zgxl == 1) {
rress[i].xllb = "第一学历"
xlxxList.value.push(JSON.parse(JSON.stringify(rress[i])))
console.log(xlxxList.value)
// console.log(xlxxList.value)
rress[i].xllb = "最高学历"
xlxxList.value.push(JSON.parse(JSON.stringify(rress[i])))
console.log(xlxxList.value)
// console.log(xlxxList.value)
}
if (rress[i].onexl == 1 & rress[i].zgxl != 1) {
rress[i].xllb = "第一学历"
@ -578,7 +578,9 @@
vertical-align: middle;
border-bottom: 1px solid #919191;
border-left: 1px solid #919191;
text-overflow: ellipsis;
text-align: center;
word-wrap: break-word;
overflow-wrap: break-word;
}
</style>

View File

@ -1,6 +1,6 @@
<template>
<view>
<scroll-view :scroll-y="true">
<scroll-view :scroll-y="true" style="height: 100vh;">
<uni-card>
<view>
<uni-row>
@ -23,7 +23,8 @@
</uni-row>
<uni-row>
<uni-col :span="24">
<trq-depart-select returnCodeOrID="orgCode" @change="departChange"></trq-depart-select>
<trq-depart-select v-model="departID" returnCodeOrID="orgCode"
@change="departChange"></trq-depart-select>
</uni-col>
</uni-row>
</view>
@ -144,23 +145,42 @@
function pagechange(e) {
current.value = e.current
pageNo.value = e.current
getRenyuanByDepID()
}
function departChange(e) {
departID.value = e
getRenyuanByDepID()
}
function getRenyuanByDepID() {
ryDataList.value = []
let queryParm = {
let params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
current: current.value
};
queryParm.orgCode = departID.value
if (departID.value.length <= 9) {
params.orgCode = departID.value
} else {
params.jcxd_code = departID.value
}
getRenyuanByDepID(params)
}
function departChange(e, data) {
departID.value = e
let params = {
pageNo: pageNo.value,
pageSize: pageSize.value,
current: current.value
};
console.log(e)
if (e.length <= 9) {
params.orgCode = departID.value
} else {
params.jcxd_code = departID.value
}
getRenyuanByDepID(params)
}
function getRenyuanByDepID(queryParm) {
ryDataList.value = []
console.log(queryParm)
queryRenyuanByDepartID(queryParm).then((res) => {
console.log(res)
if (res.success) {
ryDataList.value = res.result.records
total.value = res.result.total
@ -187,6 +207,7 @@
if (ldhth.value !== '') {
queryParm.ldhth = '*' + ldhth.value + '*';
}
console.log(queryParm)
queryRenyuanByDepartID(queryParm).then((res) => {
if (res.success) {
ryDataList.value = res.result.records

View File

@ -1,95 +1,342 @@
<template>
<view>
<uni-card>
<uni-forms>
<uni-forms-item label="所属单位" label-position="top" name="depart">
<trq-depart-select returnCodeOrID="orgCode" @change="departChange"></trq-depart-select>
</uni-forms-item>
</uni-forms>
<uni-row>
<uni-col :span="12"><button @click="getRyByxb(0)" type="primary" size="mini"
style="margin: 10px 10px 10px 10px;">性别分组统计</button></uni-col>
<uni-col :span="12"><button @click="getRyBynl(0)" type="primary" size="mini"
style="margin: 10px 10px 10px 10px;">年龄分组统计</button></uni-col>
</uni-row><uni-row><uni-col :span="12"><button @click="getRyByxb(1)" type="primary" size="mini"
style="margin: 10px 10px 10px 10px;">性别全厂统计</button></uni-col>
<uni-col :span="12"><button @click="getRyBynl(1)" type="primary" size="mini"
style="margin: 10px 10px 10px 10px;">年龄全厂统计</button></uni-col>
<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>
</uni-card>
<uni-card>
<view>
<l-echart ref="chartRef"></l-echart>
<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>
</uni-col>
</uni-row>
<!-- 概览统计 -->
<view class="stats-box" v-if="summary.total">
<view class=" stat-item">
<text class="label">总人数</text>
<text class="value">{{ summary.total }}</text>
</view>
<view class="stat-item">
<text class="label">平均年龄</text>
<text class="value">{{ summary.avgAge.toFixed(1) }}</text>
</view>
</view>
</view>
<!-- ECharts图表 -->
<view class="chart-container">
<l-echart ref="chart" @finished="initChart" />
</view>
</uni-card>
<!-- 数据表格 -->
<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>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
姓名
</view>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
性别
</view>
</uni-col>
<uni-col :span="5">
<view class="titleStyle">
年龄
</view>
</uni-col>
<uni-col :span="6">
<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;">
<view v-for="(item,index) in tableData">
<uni-col :span="3">
<view class="dataStyle">
{{index+1}}
</view>
</uni-col>
<uni-col :span="5">
<view class="dataStyle">
{{item.xm}}
</view>
</uni-col><uni-col :span="5">
<view class="dataStyle">
{{item.xb_dictText}}
</view>
</uni-col><uni-col :span="5">
<view class="dataStyle">
{{item.nl}}
</view>
</uni-col>
<uni-col :span="6">
<view class="dataStyle">
<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 {
onReady,
onLoad
} from '@dcloudio/uni-app';
import {
reactive,
ref,
onMounted
} from 'vue';
import {
useStore
} from '@/store';
import {
cxcRyDatacountByXb,
cxcRyDatacountByNl,
cxcRyDatacountByXbTotal,
cxcRyDatacountByNlTotal
queryRenyuanByDepartID
} from '@/api/renyuan.js'
//
const bottomHeight = ref(0);
//
const isLoading = ref(false);
const orgCode = ref('');
const rawData = ref([]);
const tableData = ref([]);
const summary = reactive({
total: 0,
avgAge: 0
});
const chart = ref(null);
const chartOption = ref({});
const drillPopup = ref(null);
const drillList = ref([]);
const drillTitle = ref('');
const chartRef = ref(null)
const ryCountData = ref([])
const departID = ref("")
const option = ref({
notMerge: true,
backgroundColor: '#F8FAFF',
tooltip: {
trigger: 'axis',
showContent: "人员统计",
axisPointer: {
type: 'shadow',
label: {
show: true
function detail(record) {
// console.log(record)
uni.navigateTo({
url: "/pages/views/renliziyuan/renyuanxinxi/detail?data=" + encodeURIComponent(JSON.stringify(record))
})
}
// initChart
const calculateAge = (birthDate) => {
const today = new Date();
const birth = new Date(birthDate);
let age = today.getFullYear() - birth.getFullYear();
const monthDiff = today.getMonth() - birth.getMonth();
if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birth.getDate())) {
age--;
}
return age;
};
//
const departChange = async (e, data) => {
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
});
} else {
uni.showLoading({
title: '数据加载中...',
mask: true
});
}
let params = {
pageSize: 3000,
fields: ['xm', 'nl', 'xb', 'xb_dictText', 'orgCode', 'jcdw', 'jcxd', 'jcxdCode']
};
if (orgCode.value.length <= 9) {
params.orgCode = orgCode.value
} else {
params.jcxd_code = orgCode.value
}
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)
uni.showToast({
title: '数据加载失败',
icon: 'none'
});
} finally {
//
isLoading.value = false;
uni.hideLoading();
}
};
//
const processData = (data) => {
//
const validData = data.map(item => ({
...item,
nl: calculateAge(item.cssj)
})).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;
//
// tableData.value = validData;
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 ageRange = getAgeRange(cur.nl);
// console.log(cur.orgCode, cur.jcxdCode)
if (cur.orgCode <= 6) {
subOrg = cur.orgCode
} else {
subOrg = cur.jcxdCode
}
// subOrgStaffs
if (!subOrgStaffs.value[subOrg]) {
subOrgStaffs.value[subOrg] = [];
}
subOrgStaffs.value[subOrg].push(cur);
// ageGroupStaffs
if (!ageGroupStaffs.value[ageRange]) {
ageGroupStaffs.value[ageRange] = [];
}
ageGroupStaffs.value[ageRange].push(cur);
})
}
//
const getAgeRange = (age) => {
const ranges = ['21-30岁', '31-40岁', '41-50岁', '51-60岁', '61-64岁'];
const index = Math.floor((age - 21) / 10);
return ranges[index] || '其他';
};
//
const showStaffList = (subOrg, ageRange) => {
//
const targetStaffs = subOrgStaffs.value[subOrg].filter(staff =>
getAgeRange(staff.nl) === ageRange
);
staffList.value = targetStaffs;
popupTitle.value = `${subOrg} ${ageRange}人员列表(共${targetStaffs.length}人)`;
popup.value.open();
};
//
const getSubOrgStaffs = (subOrgCode) => {
return subOrgStaffs.value[subOrgCode] || [];
};
//
const getAgeGroupStaffs = (ageRange) => {
return ageGroupStaffs.value[ageRange] || [];
};
//
const generateChartData = (data) => {
//
const ageRanges = ['21-30岁', '31-40岁', '41-50岁', '51-60岁', '61-64岁'];
const jcdwGroups = data.reduce((acc, cur) => {
if (!acc[cur.jcdw]) {
acc[cur.jcdw] = {
ageGroups: [0, 0, 0, 0, 0] // 21-30,31-40,41-50,51-60,61-64
};
}
const ageGroup = Math.floor((cur.nl - 21) / 10);
// console.log(ageGroup, cur.jcdw)
if (ageGroup >= 0 && ageGroup <= 4) {
acc[cur.jcdw].ageGroups[ageGroup]++;
}
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),
itemStyle: {
color: ['#5470C6', '#91CC75', '#FAC858', '#EE6666', '#73C0DE'][index]
},
//
label: {
show: true,
position: 'top'
},
// 20
// barWidth: 20
}))
chartOption.value = {
title: {
text: '人员统计图表'
text: '人员年龄分组统计',
padding: [0, 0, 0, 30],
},
toolbox: {
padding: [0, 20, 20, 20],
padding: [0, 30, 0, 0],
show: true,
feature: {
//
mark: {
show: true
},
dataView: {
show: true
},
magicType: {
show: true, //
type: ['line', 'bar'] //
},
dataZoom: {
yAxisIndex: 'none'
},
restore: {
show: true //
},
@ -98,46 +345,48 @@
}
}
},
calculable: false, //
// itemHeight: 0,
legend: {
//
data: [],
itemGap: 24,
padding: [5, 15, 10, 15],
// y: 'bottom',
itemHeight: 8, //
itemWidth: 8, //
type: 'scroll',
top: 40,
},
// tooltip: {
// trigger: 'axis',
// axisPointer: {
// type: 'shadow',
// label: {
// show: false
// }
// }
// },
grid: {
top: '15%',
left: '4%',
right: '4%',
bottom: '6%',
bottom: '10%',
containLabel: true
},
xAxis: [{
show: true,
type: 'category', //
// boundaryGap:false, //线
data: [],
// offset:50,
//['7.1', '7.2', '7.3', '7.4', '7.5', '7.6', '7.7', '7.8', '7.9', '7.10','7.11', ], //this.xList, //obama_budget_2012.names
legend: {
data: ageRanges,
itemGap: 5,
padding: [0, 15, 0, 15],
y: 'bottom',
itemHeight: 8, //
itemWidth: 8, //
type: 'scroll'
},
xAxis: {
type: 'category',
data: xData,
axisLabel: {
color: '#7F84B5',
fontWeight: 300,
interval: 0,
rotate: 70
rotate: 0,
},
padding: [0, 10, 0, 10],
axisTick: {
show: false //线
},
axisLine: {
show: false //线
}
}],
},
yAxis: [{
show: true,
boundaryGap: false, //线
@ -163,365 +412,152 @@
show: false //线
}
}],
dataZoom: [{
show: true,
start: 80,
end: 100,
handleSize: 10
},
{
type: 'inside',
start: 0,
end: 50
},
{
show: false,
yAxisIndex: 0,
filterMode: 'empty',
width: 12,
height: '80%',
showDataShadow: false,
left: '93%',
handleSize: 8
}
],
series: []
});
const xData = ref([])
const ySeries = ref([])
const legData = ref([])
series: seriesData,
function departChange(e) {
departID.value = e
}
function getRyByxb(val) {
ryCountData.value = []
let queryParm = {};
queryParm.orgCode = departID.value
if (val == 0) {
cxcRyDatacountByXb(queryParm).then((res) => {
if (res.success) {
ryCountData.value = res.result
// console.log(ryCountData.value);
xData.value = [];
ySeries.value = [];
legData.value = [];
let serie = {
name: '',
type: 'bar',
data: [],
itemStyle: {
label: {
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 16
}
}
}
};
let serieMan = JSON.parse(JSON.stringify(serie));
let serieTotal = JSON.parse(JSON.stringify(serie));
serieTotal.name = '总数';
serieMan.name = '男';
let serieWoman = JSON.parse(JSON.stringify(serie));
serieWoman.name = '女';
ryCountData.value.map(item => {
xData.value.push(item.depart_name);
serieMan.data.push(item.man);
serieWoman.data.push(item.woman);
serieTotal.data.push(item.total);
});
ySeries.value.push(serieTotal);
ySeries.value.push(serieMan);
ySeries.value.push(serieWoman);
legData.value = ['总数', '男', '女'];
option.value.legend.data = legData.value;
option.value.xAxis[0].data = xData.value;
option.value.series = ySeries.value;
option.value.title.text = '人员性别统计';
}
//
setTimeout(async () => {
if (!chartRef.value) return
const myChart = await chartRef.value.init(echarts)
myChart.setOption(option.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)
}).catch((err) => {
console.log(err);
})
}
if (val == 1) {
// #ifdef APP
getHeight();
// #endif
cxcRyDatacountByXbTotal(queryParm).then((res) => {
if (res.success) {
ryCountData.value = res.result
xData.value = [];
ySeries.value = [];
legData.value = [];
let serie = {
name: '',
type: 'bar',
data: [],
itemStyle: {
label: {
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 16
}
}
}
};
let serieMan = JSON.parse(JSON.stringify(serie));
let serieTotal = JSON.parse(JSON.stringify(serie));
serieTotal.name = '总数';
serieMan.name = '男';
let serieWoman = JSON.parse(JSON.stringify(serie));
serieWoman.name = '女';
ryCountData.value.map(item => {
xData.value.push("全厂");
serieMan.data.push(item.man);
serieWoman.data.push(item.woman);
serieTotal.data.push(item.total);
});
ySeries.value.push(serieTotal);
ySeries.value.push(serieMan);
ySeries.value.push(serieWoman);
legData.value = ['总数', '男', '女'];
option.value.legend.data = legData.value;
option.value.xAxis[0].data = xData.value;
option.value.series = ySeries.value;
option.value.title.text = '人员性别统计';
onMounted(() => {
}
setTimeout(async () => {
if (!chartRef.value) return
const myChart = await chartRef.value.init(echarts)
myChart.setOption(option.value)
}, 300)
}).catch((err) => {
console.log(err);
// #ifdef APP
getHeight();
// #endif
})
}
}
// #ifdef APP
function getRyBynl(val) {
ryCountData.value = []
let queryParm = {};
queryParm.orgCode = departID.value
if (val == 0) {
cxcRyDatacountByNl(queryParm).then((res) => {
if (res.success) {
ryCountData.value = res.result
xData.value = [];
ySeries.value = [];
legData.value = [];
let serie = {
name: '',
type: 'bar',
data: [],
itemStyle: {
label: {
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 16
}
}
}
const getHeight = () => {
//
const systemInfo = uni.getSystemInfoSync();
const screenHeight = systemInfo.screenHeight;
//
const query = uni.createSelectorQuery();
//
query
.select('#top1')
.boundingClientRect((rect1) => {
//
const topComponentsHeight = rect1.height
//
bottomHeight.value = screenHeight - topComponentsHeight - 415;
})
.exec();
};
let serie20 = JSON.parse(JSON.stringify(serie));
serie20.name = '小于20岁';
let serie21_30 = JSON.parse(JSON.stringify(serie));
serie21_30.name = '21-30岁';
let serie31_40 = JSON.parse(JSON.stringify(serie));
serie31_40.name = '31-40岁';
let serie41_50 = JSON.parse(JSON.stringify(serie));
serie41_50.name = '41-50岁';
let serie51_60 = JSON.parse(JSON.stringify(serie));
serie51_60.name = '51-60岁';
let serie45 = JSON.parse(JSON.stringify(serie));
serie45.name = '45岁及以下';
let serie46_60 = JSON.parse(JSON.stringify(serie));
serie46_60.name = '45岁以上';
let serie51_55 = JSON.parse(JSON.stringify(serie));
serie51_55.name = '51-55岁';
let serie55 = JSON.parse(JSON.stringify(serie));
serie55.name = '55岁以上';
let serietotal = JSON.parse(JSON.stringify(serie));
serietotal.name = '总数';
let serieavgage = JSON.parse(JSON.stringify(serie));
serieavgage.name = '平均年龄';
ryCountData.value.map(item => {
xData.value.push(item.depart_name);
serietotal.data.push(item.total);
serie20.data.push(item.age20);
serie21_30.data.push(item.age21_30);
serie31_40.data.push(item.age31_40);
serie41_50.data.push(item.age41_50);
serie51_60.data.push(item.age51_60);
serie45.data.push(item.age45);
serie46_60.data.push(item.age46_60);
serie51_55.data.push(item.age51_55);
serie55.data.push(item.age55);
serieavgage.data.push(item.avgage);
});
this.ySeries.push(serietotal);
this.ySeries.push(serieavgage);
this.ySeries.push(serie20);
this.ySeries.push(serie21_30);
this.ySeries.push(serie31_40);
this.ySeries.push(serie41_50);
this.ySeries.push(serie51_60);
this.ySeries.push(serie45);
this.ySeries.push(serie46_60);
this.ySeries.push(serie51_55);
this.ySeries.push(serie55);
legData.value = ['总数', '平均年龄', '小于20岁', '21-30岁', '31-40岁', '41-50岁', '51-60岁', '45岁及以下',
'45岁以上', '51-55岁', '55岁以上'
];
option.value.legend.data = legData.value;
option.value.xAxis[0].data = xData.value;
option.value.series = ySeries.value;
option.value.title.text = '人员年龄统计';
}
// #endif
//
const initChart = () => {
setTimeout(async () => {
if (!chartRef.value) return
const myChart = await chartRef.value.init(echarts)
myChart.setOption(option.value)
if (!chart.value) return
const myChart = await chart.value.init(echarts)
myChart.setOption(chartOption.value)
}, 300)
}).catch((err) => {
console.log(err);
})
}
if (val == 1) {
cxcRyDatacountByNlTotal(queryParm).then((res) => {
if (res.success) {
ryCountData.value = res.result
xData.value = [];
ySeries.value = [];
legData.value = [];
let serie = {
name: '',
type: 'bar',
data: [],
itemStyle: {
label: {
show: true, //
position: 'top', //
textStyle: {
//
color: 'black',
fontSize: 16
}
}
}
};
let serie20 = JSON.parse(JSON.stringify(serie));
serie20.name = '小于20岁';
let serie21_30 = JSON.parse(JSON.stringify(serie));
serie21_30.name = '21-30岁';
let serie31_40 = JSON.parse(JSON.stringify(serie));
serie31_40.name = '31-40岁';
let serie41_50 = JSON.parse(JSON.stringify(serie));
serie41_50.name = '41-50岁';
let serie51_60 = JSON.parse(JSON.stringify(serie));
serie51_60.name = '51-60岁';
let serie45 = JSON.parse(JSON.stringify(serie));
serie45.name = '45岁及以下';
let serie46_60 = JSON.parse(JSON.stringify(serie));
serie46_60.name = '45岁以上';
let serie51_55 = JSON.parse(JSON.stringify(serie));
serie51_55.name = '51-55岁';
let serie55 = JSON.parse(JSON.stringify(serie));
serie55.name = '55岁以上';
let serietotal = JSON.parse(JSON.stringify(serie));
serietotal.name = '总数';
let serieavgage = JSON.parse(JSON.stringify(serie));
serieavgage.name = '平均年龄';
ryCountData.value.map(item => {
xData.value.push("全厂");
serietotal.data.push(item.total);
serie20.data.push(item.age20);
serie21_30.data.push(item.age21_30);
serie31_40.data.push(item.age31_40);
serie41_50.data.push(item.age41_50);
serie51_60.data.push(item.age51_60);
serie45.data.push(item.age45);
serie46_60.data.push(item.age46_60);
serie51_55.data.push(item.age51_55);
serie55.data.push(item.age55);
serieavgage.data.push(item.avgage);
});
this.ySeries.push(serietotal);
this.ySeries.push(serieavgage);
this.ySeries.push(serie20);
this.ySeries.push(serie21_30);
this.ySeries.push(serie31_40);
this.ySeries.push(serie41_50);
this.ySeries.push(serie51_60);
this.ySeries.push(serie45);
this.ySeries.push(serie46_60);
this.ySeries.push(serie51_55);
this.ySeries.push(serie55);
legData.value = ['总数', '平均年龄', '小于20岁', '21-30岁', '31-40岁', '41-50岁', '51-60岁', '45岁及以下',
'45岁以上', '51-55岁', '55岁以上'
];
option.value.legend.data = legData.value;
option.value.xAxis[0].data = xData.value;
option.value.series = ySeries.value;
option.value.title.text = '人员年龄统计';
}
setTimeout(async () => {
if (!chartRef.value) return
const myChart = await chartRef.value.init(echarts)
myChart.setOption(option.value)
}, 300)
}).catch((err) => {
console.log(err);
})
}
}
</script>
<style>
<style scoped>
.container {
margin: 20, 20, 20, 20rpx;
}
.input-group {
display: flex;
gap: 20rpx;
margin-bottom: 30rpx;
}
.input {
flex: 1;
border: 1rpx solid #ddd;
padding: 15rpx;
border-radius: 8rpx;
}
.query-btn {
background: #007AFF;
color: white;
padding: 0 40rpx;
border-radius: 8rpx;
}
.stats-box {
display: flex;
justify-content: space-around;
margin: 30rpx 0;
padding: 20rpx;
background: #f8f8f8;
border-radius: 12rpx;
}
.stat-item {
display: flex;
flex-direction: column;
align-items: center;
}
.label {
font-size: 24rpx;
color: #666;
}
.value {
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>

View File

@ -2,12 +2,12 @@
<view v-if="returnCodeOrID === 'orgCode'">
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true"
placeholder="请选择单位code" popup-title="请选择单位" :localdata="departList" @nodeclick="onnodeclick"
@popupclosed="onpopupclosed" :map="{'text':'title','value':'orgCode'}"></uni-data-picker>
@popupclosed="onpopupclosed" @change="onchange" :map="{'text':'title','value':'orgCode'}"></uni-data-picker>
</view>
<view v-else>
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true" placeholder="请选择单位id"
popup-title="请选择单位" :localdata="departList" @nodeclick="onnodeclick" @popupclosed="onpopupclosed"
:map="{'text':'title','value':'id'}"></uni-data-picker>
@change="onchange" :map="{'text':'title','value':'id'}"></uni-data-picker>
</view>
</template>
@ -46,6 +46,8 @@
let selectDepartIDS = ref([]) //ID
let tempSelectDepartID = ref("") //ID
let departInfo = ref({}) //""
let $emit = defineEmits(['change']);
const getDepartList = () => {
@ -59,17 +61,22 @@
})
}
const onnodeclick = ((e) => {
// console.log(e)
departInfo.value = e;
if (props.returnCodeOrID = "orgCode") {
tempSelectDepartID.value = e.orgCode
} else {
tempSelectDepartID.value = e.value
}
})
const onchange = ((e) => {
$emit('change', e.detail.value[e.detail.value.length - 1].value, {})
})
const onpopupclosed = ((e) => {
selectDepartID.value = tempSelectDepartID.value
$emit('change', selectDepartID.value)
$emit('change', selectDepartID.value, departInfo)
})
onLoad((e) => {
getDepartList();

View File

@ -1,4 +1,24 @@
# trq-depart-select
# 1.0.1
更新,添加返回值,将整个机构对象返回父组件
```javascript
const onpopupclosed = ((e) => {
selectDepartID.value = tempSelectDepartID.value
$emit('change', selectDepartID.value, departInfo)
})
```
增加选择到最后层级触发的change时间返回数据到父组件的功能
```javascript
const onchange = ((e) => {
$emit('change', e.detail.value[e.detail.value.length - 1].value, {})
})
```
# 1.0
属性 returnCodeOrID 默认值 orgCode 组件返回单位的orgCode 不设置属性或设置为其他,组件返回 单位ID