大屏以及质量管理
This commit is contained in:
@ -22,7 +22,8 @@
|
||||
</div>
|
||||
<p>总人数</p>
|
||||
<div class="peopleNum">
|
||||
<span>{{ constructionUserData?.peopleCount }} </span>人
|
||||
<span>{{ constructionUserData?.headcount }}</span
|
||||
>人
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
@ -31,7 +32,8 @@
|
||||
</div>
|
||||
<p>出勤人</p>
|
||||
<div class="peopleNum">
|
||||
<span>{{ constructionUserData?.attendanceCount }} </span>人
|
||||
<span>{{ constructionUserData?.responseCunt }}</span
|
||||
>人
|
||||
</div>
|
||||
</div>
|
||||
<div class="card">
|
||||
@ -40,7 +42,7 @@
|
||||
</div>
|
||||
<p>出勤率</p>
|
||||
<div class="peopleNum">
|
||||
<span>{{ constructionUserData?.attendanceRate }} </span>%
|
||||
<span>{{ constructionUserData?.ratio }} </span>%
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@ -97,35 +99,48 @@ const machineryOption = ref<MachineryrVO[]>([]); //机械
|
||||
const orderOption = ref<MaterialsVO[]>([]); //材料
|
||||
const stopMachineryScroll = ref(null);
|
||||
const stopOrderScroll = ref(null);
|
||||
const machineryDataAxis = computed(() => machineryOption.value.map((item) => item.machineryName)); //x轴数据
|
||||
const machineryData = computed(() => machineryOption.value.map((item) => item.machineryCount)); //柱状图数据
|
||||
const orderDataAxis = computed(() => orderOption.value.map((item) => item.materialsName)); //材料x轴数据
|
||||
const orderPutData = computed(() => orderOption.value.map((item) => item.putCount)); //柱状图领用量数据
|
||||
const orderOutData = computed(() => orderOption.value.map((item) => item.outCount)); //柱状图出库量数据
|
||||
const machineryDataAxis = computed(() => machineryOption.value.map((item) => item.statusName)); //x轴数据
|
||||
const machineryData = computed(() => machineryOption.value.map((item) => item.statusNumber)); //柱状图数据
|
||||
const orderDataAxis = computed(() => orderOption.value.map((item) => item.equipmentMaterialsName)); //材料x轴数据
|
||||
const orderPutData = computed(() => orderOption.value.map((item) => item.inventoryNumber)); //柱状图领用量数据
|
||||
const orderOutData = computed(() => orderOption.value.map((item) => item.outboundNumber)); //柱状图出库量数据
|
||||
const orderRankingData = computed(() => orderOption.value.map((item) => item.value)); //柱状图库存数据
|
||||
// 从 store 中获取项目列表和当前选中的项目
|
||||
const currentProject = computed(() => userStore.selectedProject);
|
||||
|
||||
//获取施工人员信息
|
||||
const getConstructionUserData = async () => {
|
||||
const res = await getConstructionUserList({ projectId: currentProject.value.id });
|
||||
if (res.code !== 200) return;
|
||||
const res = await getConstructionUserList({ projectId: currentProject.value.goId });
|
||||
if (res.code !== 0) return;
|
||||
constructionUserData.value = res.data;
|
||||
};
|
||||
|
||||
//查询大屏机械列表
|
||||
const getMachineryData = async () => {
|
||||
const res = await getMachineryrList({ projectId: currentProject.value.id });
|
||||
if (res.code !== 200) return;
|
||||
machineryOption.value = res.data;
|
||||
const res = await getMachineryrList({ projectId: currentProject.value.goId });
|
||||
if (res.code !== 0) return;
|
||||
const merged = Object.values(
|
||||
res.data.list.reduce(
|
||||
(acc, item) => {
|
||||
if (!acc[item.statusName]) {
|
||||
acc[item.statusName] = { ...item };
|
||||
} else {
|
||||
acc[item.statusName].statusNumber += item.statusNumber;
|
||||
}
|
||||
return acc;
|
||||
},
|
||||
{} as Record<string, { statusName: string; statusNumber: number }>
|
||||
)
|
||||
);
|
||||
machineryOption.value = merged as any;
|
||||
initMachinerycharts();
|
||||
};
|
||||
|
||||
//查询大屏材料信息
|
||||
const getOrderData = async () => {
|
||||
const res = await getMaterialsList({ projectId: currentProject.value.id });
|
||||
if (res.code !== 200) return;
|
||||
orderOption.value = res.data;
|
||||
const res = await getMaterialsList({ projectId: currentProject.value.goId });
|
||||
if (res.code !== 0) return;
|
||||
orderOption.value = res.data.list;
|
||||
initOrderChart();
|
||||
};
|
||||
|
||||
@ -133,7 +148,7 @@ const initMachinerycharts = () => {
|
||||
let chartDom = document.getElementById('machineryMain');
|
||||
myMachineryChart.value = markRaw(echarts.init(chartDom));
|
||||
let option: EChartsOption;
|
||||
|
||||
const { max, interval, splitNumber } = calcYAxisOptions(machineryData.value);
|
||||
option = {
|
||||
title: {
|
||||
subtext: '单位:台数'
|
||||
@ -149,8 +164,17 @@ const initMachinerycharts = () => {
|
||||
// inside: true,
|
||||
color: 'rgba(202, 218, 226, 1)',
|
||||
|
||||
fontSize: 10,
|
||||
interval: 0
|
||||
fontSize: 13,
|
||||
interval: 0,
|
||||
formatter: function (value: string) {
|
||||
// 每5个字符换行(你可以根据需要改成4或6)
|
||||
const maxLineLength = 5;
|
||||
let result = '';
|
||||
for (let i = 0; i < value.length; i += maxLineLength) {
|
||||
result += value.slice(i, i + maxLineLength) + '\n';
|
||||
}
|
||||
return result;
|
||||
}
|
||||
},
|
||||
axisTick: {
|
||||
show: false
|
||||
@ -162,6 +186,9 @@ const initMachinerycharts = () => {
|
||||
z: 10
|
||||
},
|
||||
yAxis: {
|
||||
max,
|
||||
interval,
|
||||
splitNumber,
|
||||
axisLine: {
|
||||
show: false
|
||||
},
|
||||
@ -172,8 +199,6 @@ const initMachinerycharts = () => {
|
||||
color: '#999',
|
||||
fontSize: 12
|
||||
},
|
||||
interval: 1,
|
||||
splitNumber: 5,
|
||||
splitLine: {
|
||||
show: true,
|
||||
lineStyle: {
|
||||
@ -237,7 +262,7 @@ const initMachinerycharts = () => {
|
||||
},
|
||||
start: 0,
|
||||
// 计算初始结束百分比
|
||||
end: (6 / machineryData.value.length) * 100
|
||||
end: (3 / machineryData.value.length) * 100
|
||||
}
|
||||
],
|
||||
|
||||
@ -261,6 +286,21 @@ const initMachinerycharts = () => {
|
||||
stopMachineryScroll.value = enableEchartsAutoScroll(myMachineryChart.value, machineryDataAxis.value.length, 6, 2000);
|
||||
};
|
||||
|
||||
const calcYAxisOptions = (data: number[]) => {
|
||||
const maxValue = Math.max(...data);
|
||||
const paddedMax = Math.ceil(maxValue * 1.2); // 给柱子顶部留空间
|
||||
|
||||
// 自动控制 Y 轴分几段:比如让每段差不多 2~5 个单位
|
||||
let interval = Math.ceil(paddedMax / 5);
|
||||
let splitNumber = Math.ceil(paddedMax / interval);
|
||||
|
||||
return {
|
||||
max: paddedMax,
|
||||
interval,
|
||||
splitNumber
|
||||
};
|
||||
};
|
||||
|
||||
const initOrderChart = () => {
|
||||
let chartDom = document.getElementById('orderMain');
|
||||
|
||||
|
Reference in New Issue
Block a user