对接劳务管理右下角今日-实时数据。

This commit is contained in:
严妍 2023-07-14 17:44:33 +08:00
parent 3c22e2e7cc
commit 44138c463f
4 changed files with 375 additions and 391 deletions

View File

@ -267,7 +267,7 @@ function initOption() {
function drawChart() { function drawChart() {
initOption(); initOption();
console.log("绘制前数据", yData.value) console.log("绘制前数据", yData.value);
let EchartsTime = echarts.init(document.getElementById("EchartsTime")); let EchartsTime = echarts.init(document.getElementById("EchartsTime"));
EchartsTime.setOption(option.value); EchartsTime.setOption(option.value);
} }

View File

@ -63,7 +63,12 @@ import { getRealTimeDataApi, getDevListApi } from "@/api/modules/distribution";
import mitts from "@/utils/bus"; // import mitts from "@/utils/bus"; //
// import Card from "@/components/card.vue"; // import Card from "@/components/card.vue";
import { GlobalStore } from "@/stores"; import { GlobalStore } from "@/stores";
const store = GlobalStore();
function selectChange(e: any) {
//
mitts.emit("devSn", e);
}
// value // value
let devValue = ref(1 as any); let devValue = ref(1 as any);
let noiseList = ref([ let noiseList = ref([
@ -76,18 +81,14 @@ let noiseList = ref([
label: "电箱2" label: "电箱2"
} }
]); ]);
function selectChange(e: any) { const store = GlobalStore();
//
mitts.emit("devSn", e);
}
const getDevOption = async () => { const getDevOption = async () => {
const res: any = await getDevListApi({ const res: any = await getDevListApi({
projectSn: store.sn projectSn: store.sn
}); });
if (res.result) { if (res.result) {
devValue.value = res.result[0].devSn; devValue.value = res.result[0].devSn;
noiseList.value = res.result.map(item => { noiseList.value = res.result.map((item: any) => {
return { return {
value: item.devSn, value: item.devSn,
label: item.devName label: item.devName
@ -98,7 +99,7 @@ const getDevOption = async () => {
}; };
// let devSn = ref("" as any); // let devSn = ref("" as any);
let realTimeData = ref(null as any) let realTimeData = ref(null as any);
const getRealTimeList = async () => { const getRealTimeList = async () => {
const res: any = await getRealTimeDataApi({ const res: any = await getRealTimeDataApi({
projectSn: store.sn, projectSn: store.sn,

View File

@ -1,14 +1,14 @@
<template> <template>
<Card title="按分包单位分析"> <Card title="按分包单位分析">
<div class="rightHeader"> <div class="rightHeader">
<div class="day Selected">实时</div> <div class="day Selected" @click="getNowData">实时</div>
<div class="year Selected">今日</div> <div class="year Selected" @click="getTodayData">今日</div>
</div> </div>
<div id="echartsBottom" style="width: 100%; height: 100%"></div> <div id="echartsBottom" style="width: 100%; height: 100%"></div>
</Card> </Card>
</template> </template>
<script> <script lang="ts" setup>
import { onMounted, reactive, ref, onBeforeUnmount } from "vue"; import { onMounted, reactive, ref, onBeforeUnmount } from "vue";
import * as echarts from "echarts"; import * as echarts from "echarts";
import { getComapnyWorkTotalListApi } from "@/api/modules/labor"; import { getComapnyWorkTotalListApi } from "@/api/modules/labor";
@ -16,11 +16,6 @@ import Card from "@/components/card.vue";
import { GlobalStore } from "@/stores"; import { GlobalStore } from "@/stores";
const store = GlobalStore(); const store = GlobalStore();
export default {
components: {
Card
},
setup() {
const labelimg = ref(new URL("@/assets/images/larborManagement/greenX.png", import.meta.url).href); const labelimg = ref(new URL("@/assets/images/larborManagement/greenX.png", import.meta.url).href);
const labelimg2 = ref(new URL("@/assets/images/larborManagement/orangeX.png", import.meta.url).href); const labelimg2 = ref(new URL("@/assets/images/larborManagement/orangeX.png", import.meta.url).href);
let option = ref({ let option = ref({
@ -63,7 +58,7 @@ export default {
width: 10, width: 10,
show: true, show: true,
rotate: 0, rotate: 0,
interval: 0, interval: 2,
textStyle: { textStyle: {
// padding: [14, 0, 0, 0], // padding: [14, 0, 0, 0],
fontSize: 12, fontSize: 12,
@ -318,35 +313,56 @@ export default {
draw(); draw();
}); });
function getNowData() {
yData.value = companyWorkTotalData.value.map((item: any) => item.presencePersonNum);
option.value.series[0].data = option.value.series[0].data.map((item, index) => {
return {
...item,
value: yData.value[index]
};
});
draw();
// option.value.xAxis.data = xData.value;
// presencePersonNum
}
function getTodayData() {
yData.value = companyWorkTotalData.value.map((item: any) => item.attendancePersonNum);
option.value.series[0].data = option.value.series[0].data.map((item, index) => {
return {
...item,
value: yData.value[index]
};
});
draw();
// option.value.xAxis.data = xData.value;
// attendancePersonNum
}
let companyWorkTotalData = ref([] as any);
let xData = ref([] as any);
let yData = ref([] as any);
async function getProjectWorkerList() { async function getProjectWorkerList() {
let res = await getComapnyWorkTotalListApi({ let res = await getComapnyWorkTotalListApi({
projectSn: store.sn projectSn: store.sn
}); });
let xData = [];
let yData = [];
console.log("按分包单位分析数据", res);
if (res.result) { if (res.result) {
res.result.forEach(item => { res.result.forEach((item: any) => {
// //
if (item.totalPersonNum > 0) { if (item.totalPersonNum > 0) {
xData.push(item.enterpriseName); companyWorkTotalData.value.push(item);
yData.push(item.totalPersonNum); xData.value.push(item.enterpriseName);
// yData.value.push(item.totalPersonNum);
// max.value = max.value + item.totalPersonNum;
// projectWorkerTypeOption.push({
// value: item.totalPersonNum,
// name: item.enterpriseName
// });
} }
}); });
console.log(option.value.series[0].data, `series_old`); console.log("按分包单位分析数据", companyWorkTotalData.value);
// console.log(option.value.series[0].data, `series_old`);
option.value.series[0].data = option.value.series[0].data.map((item, index) => { option.value.series[0].data = option.value.series[0].data.map((item, index) => {
return { return {
...item, ...item,
value: yData[index] value: yData.value[index]
}; };
}); });
option.value.xAxis.data = xData; option.value.xAxis.data = xData.value;
// option.value.yAxis.data = yData; // option.value.yAxis.data = yData;
// //
// optionData.value = getData(data); // optionData.value = getData(data);
@ -359,8 +375,6 @@ export default {
// projectSn: store.sn // projectSn: store.sn
// }); // });
} }
}
};
</script> </script>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -1,8 +1,8 @@
<template> <template>
<Card title="按工种分析"> <Card title="按工种分析">
<div class="rightHeader"> <div class="rightHeader">
<!-- <div class="day Selected">实时</div> --> <!-- <div class="day Selected" @click="getNowData">实时</div> -->
<!-- <div class="year Selected">今日</div> --> <!-- <div class="year Selected" @click="getTodayData">今日</div> -->
</div> </div>
<div class="num">{{ max }}</div> <div class="num">{{ max }}</div>
<div id="echartTop" style="width: 100%; height: 100%"></div> <div id="echartTop" style="width: 100%; height: 100%"></div>
@ -31,42 +31,8 @@ let data = reactive(
return b.value - a.value; return b.value - a.value;
}) })
); );
// let data = reactive(
// [
// {
// name: "",
// value: 1969
// },
// {
// name: "",
// value: 1476
// },
// {
// name: "",
// value: 1500
// },
// {
// name: "",
// value: 1476
// },
// {
// name: "",
// value: 2997
// }
// ].sort(function (a, b) {
// return b.value - a.value;
// })
// );
// function array2obj(array, key) { function getData(data: any) {
// let resObj = {};
// for (let i = 0; i < array.length; i++) {
// resObj[array[i][key]] = array[i];
// }
// return resObj;
// }
function getData(data) {
let res = { let res = {
series: [], series: [],
yAxis: [] yAxis: []
@ -114,7 +80,7 @@ function getData(data) {
return res; return res;
} }
// let objData = array2obj(data, "name"); // let objData = array2obj(data, "name");
let option = ref({} as any) let option = ref({} as any);
let optionData = ref(null as any); let optionData = ref(null as any);
// option // option
@ -123,8 +89,8 @@ function initOption() {
legend: { legend: {
show: true, show: true,
itemGap: 20, itemGap: 20,
itemWidth: 40, itemWidth: 15,
itemHeight: 10, itemHeight: 15,
icon: "rect", icon: "rect",
orient: "horizontal", orient: "horizontal",
// x: "right", // x: "right",
@ -174,8 +140,8 @@ function draw() {
// console.log('',option.value); // console.log('',option.value);
} }
// //
let max = ref(0 as any) let max = ref(0 as any);
let projectWorkerTypeData = ref([] as any);
// //
// let timer = null // let timer = null
const getProjectWorkerList = async () => { const getProjectWorkerList = async () => {
@ -190,6 +156,9 @@ const getProjectWorkerList = async () => {
if (item.workerNum > 0) { if (item.workerNum > 0) {
// //
max.value = max.value + item.workerNum; max.value = max.value + item.workerNum;
//
projectWorkerTypeData.value.push(item);
//
projectWorkerTypeOption.push({ projectWorkerTypeOption.push({
value: item.workerNum, value: item.workerNum,
name: item.typeName name: item.typeName