对接右上按工种分析接口

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