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

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() {
initOption();
console.log("绘制前数据", yData.value)
console.log("绘制前数据", yData.value);
let EchartsTime = echarts.init(document.getElementById("EchartsTime"));
EchartsTime.setOption(option.value);
}

View File

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

View File

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

View File

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