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:
commit
aff8d2168a
@ -1,3 +1,3 @@
|
|||||||
# 开发环境
|
# 开发环境
|
||||||
# 请求接口地址
|
# 请求接口地址
|
||||||
VITE_REQUEST_BASE_URL = http://10.75.15.249:8080
|
VITE_REQUEST_BASE_URL = https://36.112.48.190
|
||||||
|
@ -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) { // 获取员工信息统计
|
export function cxcHrYgxxtj(parm) { // 获取员工信息统计
|
||||||
return https({
|
return https({
|
||||||
url: '/cxchrygxxtj/cxcHrYgxxtj/list',
|
url: '/cxchrygxxtj/cxcHrYgxxtj/list',
|
||||||
@ -82,33 +74,9 @@ export function cxcHrYgxxtj(parm) { // 获取员工信息统计
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export function cxcRyDatacountByXb(parm) { // 通过性别获取员工信息统计
|
export function cxcRyDataTongji(url, parm) { // 员工信息统计
|
||||||
return https({
|
return https({
|
||||||
url: '/cxcRyData/countByXb',
|
url: url,
|
||||||
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',
|
|
||||||
method: 'get',
|
method: 'get',
|
||||||
data: parm
|
data: parm
|
||||||
})
|
})
|
||||||
|
@ -230,7 +230,7 @@
|
|||||||
{
|
{
|
||||||
"path": "pages/views/renliziyuan/renyuanxinxi/tongji",
|
"path": "pages/views/renliziyuan/renyuanxinxi/tongji",
|
||||||
"style": {
|
"style": {
|
||||||
"navigationBarTitleText": "人员统计信息",
|
"navigationBarTitleText": "人员年龄分组统计信息",
|
||||||
"navigationBarTextStyle": "white"
|
"navigationBarTextStyle": "white"
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -98,17 +98,17 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
/*生产环境 begin */
|
/*生产环境 begin */
|
||||||
loginApi({
|
// loginApi({
|
||||||
username: un,
|
// username: un,
|
||||||
password: pw,
|
// password: pw,
|
||||||
ip: getDeviceIp()
|
// ip: getDeviceIp()
|
||||||
/*生产环境 end */
|
/*生产环境 end */
|
||||||
|
|
||||||
/*开发环境 begin */
|
/*开发环境 begin */
|
||||||
// localLoginApi({
|
localLoginApi({
|
||||||
// username: username.value,
|
username: username.value,
|
||||||
// password: password.value,
|
password: password.value,
|
||||||
// captcha: 'app'
|
captcha: 'app'
|
||||||
/*开发环境 end */
|
/*开发环境 end */
|
||||||
}).then((loginres) => {
|
}).then((loginres) => {
|
||||||
if (loginres.success) {
|
if (loginres.success) {
|
||||||
|
@ -317,9 +317,9 @@
|
|||||||
queryJxkhByRyLdhth({
|
queryJxkhByRyLdhth({
|
||||||
"ldhth": ldhth.value
|
"ldhth": ldhth.value
|
||||||
}).then((res) => {
|
}).then((res) => {
|
||||||
console.log(res);
|
// console.log(res);
|
||||||
jxkhxxList.value = res.result.records
|
jxkhxxList.value = res.result.records
|
||||||
console.log(jxkhxxList.value)
|
// console.log(jxkhxxList.value)
|
||||||
}).catch((err) => {
|
}).catch((err) => {
|
||||||
console.log(err);
|
console.log(err);
|
||||||
})
|
})
|
||||||
@ -379,15 +379,15 @@
|
|||||||
xlxxList.value = []
|
xlxxList.value = []
|
||||||
if (res.result.records.length > 0) {
|
if (res.result.records.length > 0) {
|
||||||
var rress = res.result.records
|
var rress = res.result.records
|
||||||
console.log(rress);
|
// console.log(rress);
|
||||||
for (let i = 0; i < rress.length; i++) {
|
for (let i = 0; i < rress.length; i++) {
|
||||||
if (rress[i].onexl == 1 & rress[i].zgxl == 1) {
|
if (rress[i].onexl == 1 & rress[i].zgxl == 1) {
|
||||||
rress[i].xllb = "第一学历"
|
rress[i].xllb = "第一学历"
|
||||||
xlxxList.value.push(JSON.parse(JSON.stringify(rress[i])))
|
xlxxList.value.push(JSON.parse(JSON.stringify(rress[i])))
|
||||||
console.log(xlxxList.value)
|
// console.log(xlxxList.value)
|
||||||
rress[i].xllb = "最高学历"
|
rress[i].xllb = "最高学历"
|
||||||
xlxxList.value.push(JSON.parse(JSON.stringify(rress[i])))
|
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) {
|
if (rress[i].onexl == 1 & rress[i].zgxl != 1) {
|
||||||
rress[i].xllb = "第一学历"
|
rress[i].xllb = "第一学历"
|
||||||
@ -578,7 +578,9 @@
|
|||||||
vertical-align: middle;
|
vertical-align: middle;
|
||||||
border-bottom: 1px solid #919191;
|
border-bottom: 1px solid #919191;
|
||||||
border-left: 1px solid #919191;
|
border-left: 1px solid #919191;
|
||||||
text-overflow: ellipsis;
|
text-align: center;
|
||||||
|
word-wrap: break-word;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<scroll-view :scroll-y="true">
|
<scroll-view :scroll-y="true" style="height: 100vh;">
|
||||||
<uni-card>
|
<uni-card>
|
||||||
<view>
|
<view>
|
||||||
<uni-row>
|
<uni-row>
|
||||||
@ -23,7 +23,8 @@
|
|||||||
</uni-row>
|
</uni-row>
|
||||||
<uni-row>
|
<uni-row>
|
||||||
<uni-col :span="24">
|
<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-col>
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</view>
|
</view>
|
||||||
@ -144,23 +145,42 @@
|
|||||||
function pagechange(e) {
|
function pagechange(e) {
|
||||||
current.value = e.current
|
current.value = e.current
|
||||||
pageNo.value = e.current
|
pageNo.value = e.current
|
||||||
getRenyuanByDepID()
|
let params = {
|
||||||
}
|
|
||||||
|
|
||||||
function departChange(e) {
|
|
||||||
departID.value = e
|
|
||||||
getRenyuanByDepID()
|
|
||||||
}
|
|
||||||
|
|
||||||
function getRenyuanByDepID() {
|
|
||||||
ryDataList.value = []
|
|
||||||
let queryParm = {
|
|
||||||
pageNo: pageNo.value,
|
pageNo: pageNo.value,
|
||||||
pageSize: pageSize.value,
|
pageSize: pageSize.value,
|
||||||
current: current.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) => {
|
queryRenyuanByDepartID(queryParm).then((res) => {
|
||||||
|
console.log(res)
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
ryDataList.value = res.result.records
|
ryDataList.value = res.result.records
|
||||||
total.value = res.result.total
|
total.value = res.result.total
|
||||||
@ -187,6 +207,7 @@
|
|||||||
if (ldhth.value !== '') {
|
if (ldhth.value !== '') {
|
||||||
queryParm.ldhth = '*' + ldhth.value + '*';
|
queryParm.ldhth = '*' + ldhth.value + '*';
|
||||||
}
|
}
|
||||||
|
console.log(queryParm)
|
||||||
queryRenyuanByDepartID(queryParm).then((res) => {
|
queryRenyuanByDepartID(queryParm).then((res) => {
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
ryDataList.value = res.result.records
|
ryDataList.value = res.result.records
|
||||||
|
@ -1,95 +1,342 @@
|
|||||||
<template>
|
<template>
|
||||||
<view>
|
<view>
|
||||||
<uni-card>
|
<view class="container" id="top1">
|
||||||
<uni-forms>
|
<uni-row style="margin-bottom: 10rpx;margin-left: 30rpx;margin-right: 30rpx;">
|
||||||
<uni-forms-item label="所属单位" label-position="top" name="depart">
|
<uni-col :span="24"><uni-title :title="'所选单位ID:'+orgCode" align="left" type="h4"></uni-title></uni-col>
|
||||||
<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>
|
|
||||||
</uni-row>
|
</uni-row>
|
||||||
</uni-card>
|
<uni-row style="margin-bottom: 20rpx;margin-left: 30rpx;margin-right: 30rpx;">
|
||||||
<uni-card>
|
<uni-col :span="24">
|
||||||
<view>
|
<trq-depart-select v-model="orgCode" returnCodeOrID="orgCode"
|
||||||
<l-echart ref="chartRef"></l-echart>
|
@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>
|
</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>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
|
import {
|
||||||
|
ref,
|
||||||
|
reactive,
|
||||||
|
onMounted
|
||||||
|
} from 'vue';
|
||||||
import * as echarts from 'echarts'
|
import * as echarts from 'echarts'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
onReady,
|
queryRenyuanByDepartID
|
||||||
onLoad
|
|
||||||
|
|
||||||
} from '@dcloudio/uni-app';
|
|
||||||
import {
|
|
||||||
reactive,
|
|
||||||
ref,
|
|
||||||
onMounted
|
|
||||||
} from 'vue';
|
|
||||||
import {
|
|
||||||
useStore
|
|
||||||
} from '@/store';
|
|
||||||
import {
|
|
||||||
cxcRyDatacountByXb,
|
|
||||||
cxcRyDatacountByNl,
|
|
||||||
cxcRyDatacountByXbTotal,
|
|
||||||
cxcRyDatacountByNlTotal
|
|
||||||
} from '@/api/renyuan.js'
|
} 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('');
|
||||||
|
|
||||||
|
function detail(record) {
|
||||||
const chartRef = ref(null)
|
// console.log(record)
|
||||||
const ryCountData = ref([])
|
uni.navigateTo({
|
||||||
const departID = ref("")
|
url: "/pages/views/renliziyuan/renyuanxinxi/detail?data=" + encodeURIComponent(JSON.stringify(record))
|
||||||
|
})
|
||||||
const option = ref({
|
|
||||||
notMerge: true,
|
|
||||||
backgroundColor: '#F8FAFF',
|
|
||||||
tooltip: {
|
|
||||||
trigger: 'axis',
|
|
||||||
showContent: "人员统计",
|
|
||||||
axisPointer: {
|
|
||||||
type: 'shadow',
|
|
||||||
label: {
|
|
||||||
show: true
|
|
||||||
}
|
}
|
||||||
|
// 计算年龄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: {
|
title: {
|
||||||
text: '人员统计图表'
|
text: '人员年龄分组统计',
|
||||||
|
padding: [0, 0, 0, 30],
|
||||||
},
|
},
|
||||||
toolbox: {
|
toolbox: {
|
||||||
padding: [0, 20, 20, 20],
|
padding: [0, 30, 0, 0],
|
||||||
show: true,
|
show: true,
|
||||||
feature: {
|
feature: {
|
||||||
//工具配置项
|
//工具配置项
|
||||||
mark: {
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
dataView: {
|
|
||||||
show: true
|
|
||||||
},
|
|
||||||
magicType: {
|
|
||||||
show: true, //是否显示该工具
|
|
||||||
type: ['line', 'bar'] //启用的动态类型
|
|
||||||
},
|
|
||||||
dataZoom: {
|
|
||||||
yAxisIndex: 'none'
|
|
||||||
},
|
|
||||||
restore: {
|
restore: {
|
||||||
show: true //是否显示该工具
|
show: true //是否显示该工具
|
||||||
},
|
},
|
||||||
@ -98,46 +345,48 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
calculable: false, //是否显示拖拽的手柄
|
// tooltip: {
|
||||||
// itemHeight: 0,
|
// trigger: 'axis',
|
||||||
legend: {
|
// axisPointer: {
|
||||||
//图例组件
|
// type: 'shadow',
|
||||||
data: [],
|
// label: {
|
||||||
itemGap: 24,
|
// show: false
|
||||||
padding: [5, 15, 10, 15],
|
// }
|
||||||
// y: 'bottom',
|
// }
|
||||||
itemHeight: 8, //高
|
// },
|
||||||
itemWidth: 8, //宽
|
|
||||||
type: 'scroll',
|
|
||||||
top: 40,
|
|
||||||
},
|
|
||||||
grid: {
|
grid: {
|
||||||
top: '15%',
|
top: '15%',
|
||||||
left: '4%',
|
left: '4%',
|
||||||
right: '4%',
|
right: '4%',
|
||||||
bottom: '6%',
|
bottom: '10%',
|
||||||
containLabel: true
|
containLabel: true
|
||||||
},
|
},
|
||||||
xAxis: [{
|
legend: {
|
||||||
show: true,
|
data: ageRanges,
|
||||||
type: 'category', //坐标轴类型
|
itemGap: 5,
|
||||||
// boundaryGap:false, //解决数据与线不对应问题
|
padding: [0, 15, 0, 15],
|
||||||
data: [],
|
y: 'bottom',
|
||||||
// offset:50,
|
itemHeight: 8, //高
|
||||||
//['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
|
itemWidth: 8, //宽
|
||||||
|
type: 'scroll'
|
||||||
|
},
|
||||||
|
xAxis: {
|
||||||
|
type: 'category',
|
||||||
|
data: xData,
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
color: '#7F84B5',
|
color: '#7F84B5',
|
||||||
fontWeight: 300,
|
fontWeight: 300,
|
||||||
interval: 0,
|
interval: 0,
|
||||||
rotate: 70
|
rotate: 0,
|
||||||
},
|
},
|
||||||
|
padding: [0, 10, 0, 10],
|
||||||
axisTick: {
|
axisTick: {
|
||||||
show: false //刻度线
|
show: false //刻度线
|
||||||
},
|
},
|
||||||
axisLine: {
|
axisLine: {
|
||||||
show: false //不显示坐标轴线
|
show: false //不显示坐标轴线
|
||||||
}
|
}
|
||||||
}],
|
},
|
||||||
yAxis: [{
|
yAxis: [{
|
||||||
show: true,
|
show: true,
|
||||||
boundaryGap: false, //解决数据与线不对应问题
|
boundaryGap: false, //解决数据与线不对应问题
|
||||||
@ -163,365 +412,152 @@
|
|||||||
show: false //不显示坐标轴线
|
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([])
|
series: seriesData,
|
||||||
const ySeries = ref([])
|
|
||||||
const legData = ref([])
|
|
||||||
|
|
||||||
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 () => {
|
setTimeout(async () => {
|
||||||
if (!chartRef.value) return
|
if (!chart.value) return
|
||||||
const myChart = await chartRef.value.init(echarts)
|
const myChart = await chart.value.init(echarts)
|
||||||
myChart.setOption(option.value)
|
myChart.setOption(chartOption.value)
|
||||||
|
myChart.on('click', (params) => {
|
||||||
|
console.log(params.seriesName)
|
||||||
|
tableData.value = getAgeGroupStaffs(params.seriesName)
|
||||||
|
|
||||||
|
})
|
||||||
}, 300)
|
}, 300)
|
||||||
|
|
||||||
|
|
||||||
}).catch((err) => {
|
// #ifdef APP
|
||||||
console.log(err);
|
getHeight();
|
||||||
})
|
// #endif
|
||||||
}
|
|
||||||
if (val == 1) {
|
|
||||||
|
|
||||||
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));
|
onMounted(() => {
|
||||||
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 = '人员性别统计';
|
|
||||||
|
|
||||||
}
|
// #ifdef APP
|
||||||
|
getHeight();
|
||||||
setTimeout(async () => {
|
// #endif
|
||||||
if (!chartRef.value) return
|
|
||||||
const myChart = await chartRef.value.init(echarts)
|
|
||||||
myChart.setOption(option.value)
|
|
||||||
}, 300)
|
|
||||||
|
|
||||||
|
|
||||||
}).catch((err) => {
|
|
||||||
console.log(err);
|
|
||||||
})
|
})
|
||||||
}
|
// #ifdef APP
|
||||||
}
|
|
||||||
|
|
||||||
function getRyBynl(val) {
|
const getHeight = () => {
|
||||||
ryCountData.value = []
|
// 获取屏幕高度
|
||||||
let queryParm = {};
|
const systemInfo = uni.getSystemInfoSync();
|
||||||
queryParm.orgCode = departID.value
|
const screenHeight = systemInfo.screenHeight;
|
||||||
if (val == 0) {
|
// 创建选择器查询对象
|
||||||
cxcRyDatacountByNl(queryParm).then((res) => {
|
const query = uni.createSelectorQuery();
|
||||||
if (res.success) {
|
// 获取上方组件的高度
|
||||||
ryCountData.value = res.result
|
query
|
||||||
xData.value = [];
|
.select('#top1')
|
||||||
ySeries.value = [];
|
.boundingClientRect((rect1) => {
|
||||||
legData.value = [];
|
// 计算上方组件高度总和
|
||||||
let serie = {
|
const topComponentsHeight = rect1.height
|
||||||
name: '',
|
// 计算下方组件的高度
|
||||||
type: 'bar',
|
bottomHeight.value = screenHeight - topComponentsHeight - 415;
|
||||||
data: [],
|
})
|
||||||
itemStyle: {
|
.exec();
|
||||||
label: {
|
|
||||||
show: true, //开启显示
|
|
||||||
position: 'top', //在上方显示
|
|
||||||
textStyle: {
|
|
||||||
//数值样式
|
|
||||||
color: 'black',
|
|
||||||
fontSize: 16
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// #endif
|
||||||
let serie20 = JSON.parse(JSON.stringify(serie));
|
// 初始化图表
|
||||||
serie20.name = '小于20岁';
|
const initChart = () => {
|
||||||
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 = '人员年龄统计';
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
setTimeout(async () => {
|
setTimeout(async () => {
|
||||||
if (!chartRef.value) return
|
if (!chart.value) return
|
||||||
const myChart = await chartRef.value.init(echarts)
|
const myChart = await chart.value.init(echarts)
|
||||||
myChart.setOption(option.value)
|
myChart.setOption(chartOption.value)
|
||||||
}, 300)
|
}, 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>
|
</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>
|
</style>
|
@ -2,12 +2,12 @@
|
|||||||
<view v-if="returnCodeOrID === 'orgCode'">
|
<view v-if="returnCodeOrID === 'orgCode'">
|
||||||
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true"
|
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true"
|
||||||
placeholder="请选择单位code" popup-title="请选择单位" :localdata="departList" @nodeclick="onnodeclick"
|
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>
|
||||||
<view v-else>
|
<view v-else>
|
||||||
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true" placeholder="请选择单位id"
|
<uni-data-picker v-model="selectDepartID" ref="depart" :openSearch="true" :ellipsis="true" placeholder="请选择单位id"
|
||||||
popup-title="请选择单位" :localdata="departList" @nodeclick="onnodeclick" @popupclosed="onpopupclosed"
|
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>
|
</view>
|
||||||
|
|
||||||
</template>
|
</template>
|
||||||
@ -46,6 +46,8 @@
|
|||||||
let selectDepartIDS = ref([]) //选中的级联单位ID数组
|
let selectDepartIDS = ref([]) //选中的级联单位ID数组
|
||||||
let tempSelectDepartID = ref("") //临时选择的单位ID
|
let tempSelectDepartID = ref("") //临时选择的单位ID
|
||||||
|
|
||||||
|
let departInfo = ref({}) //"单位的全部信息"
|
||||||
|
|
||||||
let $emit = defineEmits(['change']);
|
let $emit = defineEmits(['change']);
|
||||||
|
|
||||||
const getDepartList = () => {
|
const getDepartList = () => {
|
||||||
@ -59,17 +61,22 @@
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
const onnodeclick = ((e) => {
|
const onnodeclick = ((e) => {
|
||||||
// console.log(e)
|
departInfo.value = e;
|
||||||
if (props.returnCodeOrID = "orgCode") {
|
if (props.returnCodeOrID = "orgCode") {
|
||||||
tempSelectDepartID.value = e.orgCode
|
tempSelectDepartID.value = e.orgCode
|
||||||
} else {
|
} else {
|
||||||
tempSelectDepartID.value = e.value
|
tempSelectDepartID.value = e.value
|
||||||
}
|
}
|
||||||
|
|
||||||
|
})
|
||||||
|
|
||||||
|
const onchange = ((e) => {
|
||||||
|
$emit('change', e.detail.value[e.detail.value.length - 1].value, {})
|
||||||
})
|
})
|
||||||
|
|
||||||
const onpopupclosed = ((e) => {
|
const onpopupclosed = ((e) => {
|
||||||
selectDepartID.value = tempSelectDepartID.value
|
selectDepartID.value = tempSelectDepartID.value
|
||||||
$emit('change', selectDepartID.value)
|
$emit('change', selectDepartID.value, departInfo)
|
||||||
})
|
})
|
||||||
onLoad((e) => {
|
onLoad((e) => {
|
||||||
getDepartList();
|
getDepartList();
|
||||||
|
@ -1,4 +1,24 @@
|
|||||||
# trq-depart-select
|
# 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
|
属性 returnCodeOrID 默认值 orgCode, 组件返回单位的orgCode, 不设置属性或设置为其他,组件返回 单位ID
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user