对接右上按工种分析接口

This commit is contained in:
严妍 2023-07-12 16:46:53 +08:00
parent 1d0e7b9720
commit 2e062b9a6c
2 changed files with 108 additions and 98 deletions

View File

@ -29,3 +29,13 @@ export const getEnterpriseInfoApi = (params: {}) => {
export const getWorkerInfoApi = (params: {}) => {
return http.post(BASEURL + `/xmgl/workerInfo/selectAllProjectTeamList`, params);
};
// 右中 获取部门管理人员出勤分析
export const getworkerAttendanceTrendApi = (params: {}) => {
return http.get(BASEURL + `/xmgl/workerAttendance/queryAttendanceOfEachCompany`, params);
};
// 查询右下 获取按分包单位分析
export const getComapnyWorkTotalListApi = (params: {}) => {
return http.get(BASEURL + `/xmgl/workerInfo/selectProjectComapnyWorkTotalList`, params);
};

View File

@ -1,10 +1,10 @@
<template>
<Card title="按工种分析">
<div class="rightHeader">
<div class="day Selected">实时</div>
<div class="year Selected">今日</div>
<!-- <div class="day Selected">实时</div> -->
<!-- <div class="year Selected">今日</div> -->
</div>
<div class="num">168</div>
<div class="num">{{max}}</div>
<div id="echartTop" style="width: 100%; height: 100%"></div>
</Card>
</template>
@ -20,12 +20,12 @@ const store = GlobalStore();
let data = reactive(
[
{
value: 300,
name: "名字"
value: 400,
name: "名字1"
},
{
value: 500,
name: "名字"
value: 1500,
name: "名字2"
}
].sort(function (a, b) {
return b.value - a.value;
@ -57,15 +57,14 @@ let data = reactive(
// return b.value - a.value;
// })
// );
let max = reactive(Math.max(...data.map(item => item.value)) + 1000);
function array2obj(array, key) {
let resObj = {};
for (let i = 0; i < array.length; i++) {
resObj[array[i][key]] = array[i];
}
return resObj;
}
// function array2obj(array, key) {
// let resObj = {};
// for (let i = 0; i < array.length; i++) {
// resObj[array[i][key]] = array[i];
// }
// return resObj;
// }
function getData(data) {
let res = {
@ -81,14 +80,14 @@ function getData(data) {
radius: [87 - i * 10 + "%", 82 - i * 10 + "%"],
center: ["25%", "50%"],
label: {
show: false
show: true
},
itemStyle: {
label: {
show: false
show: true
},
labelLine: {
show: false
show: true
},
borderWidth: 10
},
@ -98,7 +97,7 @@ function getData(data) {
name: data[i].name
},
{
value: max - data[i].value,
value: max.value,
name: "",
itemStyle: {
color: "rgba(9, 26, 61)",
@ -114,14 +113,18 @@ function getData(data) {
}
return res;
}
let objData = reactive(array2obj(data, "name"));
let optionData = reactive(getData(data));
const option = reactive({
// let objData = array2obj(data, "name");
let option = ref({} as any)
let optionData = ref(null as any);
// option
function initOption() {
option.value = {
legend: {
show: true,
itemGap: 15,
itemWidth: 15,
itemHeight: 15,
itemGap: 20,
itemWidth: 40,
itemHeight: 10,
icon: "rect",
orient: "horizontal",
// x: "right",
@ -129,30 +132,11 @@ const option = reactive({
left: 260,
bottom: 10,
align: "left",
formatter: function (name) {
return "{title|" + name + "}{value|" + objData[name].value + "}";
},
textStyle: {
rich: {
title: {
width: 40,
color: "#fff",
padding: [0, 0, 0, 10]
},
value: {
color: "#fff",
padding: [0, 40]
}
}
color: "#EEEEEE"
}
},
color: ["#eea959", "#4cc4f8", "#6375c7", "#81f9e8", " #ec6266"],
// grid: {
// top: "0",
// left: "40%",
// right: "20%",
// containLabel: false
// },
color: ["#eea959", "#4cc4f8", "#6375c7", "#81f9e8", "#ec6266"],
yAxis: [
{
type: "category",
@ -167,12 +151,12 @@ const option = reactive({
interval: 0,
inside: true,
textStyle: {
color: "#fff",
color: "#EEEEEE",
fontSize: 16
},
show: true
},
data: optionData.yAxis
data: optionData.value.yAxis
}
],
xAxis: [
@ -180,35 +164,51 @@ const option = reactive({
show: false
}
],
series: optionData.series
});
series: optionData.value.series
};
}
//
function draw() {
let echartsTest = echarts.init(document.getElementById("echartTop"));
echartsTest.setOption(option);
echartsTest.setOption(option.value);
// console.log('',option.value);
}
//
let max = ref(0 as any)
//
// let timer = null
const getProjectWorkerList = async () => {
const res = await selectProjectWorkerTypeTotalListApi({
const res: any = await selectProjectWorkerTypeTotalListApi({
projectSn: store.sn
});
console.log("获取工种分析数据", res);
let projectWorkerTypeOption: any = [];
if (res.result) {
res.result.forEach(item => {
data.push({
value: item.typeName,
name: item.totalPersonNum
});
//
if (item.workerNum > 0) {
//
max.value = max.value + item.workerNum;
projectWorkerTypeOption.push({
value: item.workerNum,
name: item.typeName
});
}
setTimeout(() => {
draw();
}, 500);
});
data = projectWorkerTypeOption;
optionData.value = getData(data);
// option
initOption();
// console.log(option.value,'')
}
};
onMounted(async () => {
getProjectWorkerList();
// console.log('',optionData)
await getProjectWorkerList();
draw();
});
</script>