import React, { useRef, useEffect, useState, useCallback } from "react";
import Footer from "../../../components/screen/Footer";
import Header from "../../../components/screen/Header";
import Row from "../../../components/screen/Row";
import Card from "../../../components/screen/Card";
import Chart from "../../../components/screen/Chart";
import Table from "../../../components/screen/Table";
import TableProgress from "../../../components/screen/TableProgress";
import io from "../../../utils/socket.io.js";
const gutter = 20;
const bottom = 20;
const tableToNextPage = 6000;
const polarBarOpt = {
title: {
text: "计划总数",
left: "center",
bottom: 24,
textStyle: {
fontSize: 20,
},
},
legend: {
show: false,
},
radiusAxis: {
show: false,
type: "category",
data: ["%"],
},
tooltip: {
show: false,
},
series: {
type: "gauge",
center: ["50%", "40%"],
radius: "70%",
startAngle: 90,
endAngle: -270,
pointer: {
show: false,
},
progress: {
show: true,
overlap: false,
roundCap: false,
clip: false,
itemStyle: {
borderWidth: 0,
},
},
axisLine: {
lineStyle: {
width: 20,
color: [[1, "rgba(40, 163, 255, 0.2)"]],
},
},
splitLine: {
show: false,
},
axisTick: {
show: false,
},
axisLabel: {
show: false,
},
data: [
{
value: 0,
name: "生产总数",
},
],
title: {
offsetCenter: ["0%", "20"],
color: "#fff",
fontSize: 20,
},
detail: {
show: true,
offsetCenter: ["0%", "-20"],
width: "auto",
height: 32,
fontSize: 32,
color: "#00E1FA",
borderColor: "auto",
borderWidth: 0,
formatter: "{value}",
},
},
};
const setNumOpt = (total, done, title) => {
let res = Object.assign({}, polarBarOpt);
if (title) res.title.text = `${title}:${total}`;
let percent = ((100 * done) / (total || 1)).toFixed(2);
res.series.data[0].value = percent;
res.series.detail.formatter = () => done;
return res;
};
const setOkNumOpt = (total, done, title) => {
let res = Object.assign({}, polarBarOpt);
let percent = ((100 * done) / (total || 1)).toFixed(2);
if (title) res.title.text = `${title}:${percent}%`;
res.series.data[0].value = percent;
res.series.data[0].name = "实际总量";
res.series.detail.formatter = () => done;
res.series.detail.color = "#6FE621";
res.series.progress.itemStyle.color = "#6FE621";
return res;
};
const barOpt = {
legend: {
show: true,
data: ["生产数量", "合格数量"],
top: 10,
right: 10,
textStyle: {
fontSize: 14,
},
},
tooltip: {
trigger: "axis",
axisPointer: {
type: "shadow",
},
},
xAxis: {
type: "category",
axisTick: {
lineStyle: { opacity: 0.3 },
alignWithLabel: true,
},
axisLine: {
lineStyle: { opacity: 0.3 },
},
axisLabel: {
color: "rgba(255, 255, 255, 0.8)",
},
data: [],
},
yAxis: {
type: "value",
axisTick: {
lineStyle: { opacity: 0.3 },
},
axisLine: {
lineStyle: { opacity: 0.3 },
},
axisLabel: {
color: "rgba(255, 255, 255, 0.8)",
},
},
grid: {
bottom: 40,
top: 60,
left: 50,
},
barWidth: 20,
series: [
{
name: "生产数量",
type: "bar",
barGap: -1,
data: [],
},
{
name: "合格数量",
itemStyle: {
color: "#6FE621",
},
type: "bar",
data: [],
},
],
};
const setBarOpt = ({ product = {}, qualify = {} }) => {
let res = Object.assign({}, barOpt);
for (let n = 0; n < 24; n++) {
res.xAxis.data.push(`${n}:00`.padStart(5, "0"));
}
for (let index in product) {
res.series[0].data[parseInt(index)] = product[index];
}
for (let index in qualify) {
res.series[1].data[parseInt(index)] = qualify[index];
}
return res;
};
const productTableColumns = [
{ title: "客户编码", code: "vendorCode" },
{ title: "客户名称", code: "vendorName" },
{ title: "销售名称", code: "userName" },
{ title: "客户分类", code: "customType" },
{ title: "产品型号", code: "productMode" },
{ title: "计划发货日期", code: "planDeliveryTime" },
{ title: "计划发货数量", code: "planDeliveryQty" },
{ title: "实际发货数量", code: "deliveryQty" },
{
title: "发货率",
code: "deliveryRateNew",
render: (value, config, rowData) => {
console.log(config, rowData);
return