data.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515
  1. // 引入Day.js库
  2. const dayjs = require('dayjs');
  3. // 获取本月日期列表的函数
  4. function getDatesInMonth() {
  5. let year = dayjs().year();
  6. let month = dayjs().month();
  7. const dates = [];
  8. const startDate = dayjs(new Date(year, month, 1));
  9. const endDate = dayjs(new Date(year, month + 1, 1)).subtract(1, 'day');
  10. let currentDate = startDate;
  11. while (currentDate.isBefore(endDate) || currentDate.isSame(endDate, 'day')) {
  12. dates.push(currentDate.format('YYYY-MM-DD'));
  13. currentDate = currentDate.add(1, 'day');
  14. }
  15. return dates;
  16. }
  17. let statusOpt = [
  18. { label: '待生产', value: '4' },
  19. { label: '生产中', value: '5' },
  20. { label: '已完成', value: '6' },
  21. { label: '已延期', value: '7' }
  22. ];
  23. let daysOpt = [
  24. { label: '已延期', value: -1 },
  25. { label: '已完成', value: 0 }
  26. ];
  27. export const columns = [
  28. {
  29. columnKey: 'index',
  30. label: '序号',
  31. type: 'index',
  32. width: 55,
  33. align: 'center',
  34. showOverflowTooltip: true,
  35. fixed: 'left'
  36. },
  37. {
  38. prop: 'batchNo',
  39. label: '批次号',
  40. align: 'center',
  41. showOverflowTooltip: true
  42. },
  43. {
  44. prop: 'code',
  45. label: '生产工单编码',
  46. align: 'center',
  47. showOverflowTooltip: true
  48. },
  49. {
  50. prop: 'status',
  51. label: '工单状态',
  52. align: 'center',
  53. showOverflowTooltip: true,
  54. formatter: (row) => {
  55. let result = statusOpt.find((item) => item.value == row.status);
  56. return result ? result.label : '';
  57. }
  58. },
  59. {
  60. prop: 'planStartTime',
  61. label: '计划开始时间',
  62. minWidth: '120',
  63. align: 'center',
  64. showOverflowTooltip: true
  65. },
  66. {
  67. prop: 'planCompleteTime',
  68. label: '计划完成时间',
  69. minWidth: '120',
  70. align: 'center',
  71. showOverflowTooltip: true
  72. },
  73. {
  74. prop: 'productName',
  75. label: '产品名称',
  76. align: 'center',
  77. showOverflowTooltip: true
  78. },
  79. {
  80. prop: 'productCode',
  81. label: '产品编码',
  82. align: 'center',
  83. showOverflowTooltip: true
  84. },
  85. // {
  86. // prop: 'specification',
  87. // label: '规格型号',
  88. // align: 'center',
  89. // showOverflowTooltip: true,
  90. // },
  91. {
  92. prop: 'formingNum',
  93. label: '数量(个)',
  94. align: 'center',
  95. showOverflowTooltip: true
  96. },
  97. {
  98. prop: 'taskName',
  99. label: '生产工序',
  100. align: 'center',
  101. showOverflowTooltip: true
  102. },
  103. {
  104. prop: 'days',
  105. label: '交期状态',
  106. align: 'center',
  107. showOverflowTooltip: true,
  108. formatter: (row) => {
  109. let result = daysOpt.find((item) => item.value == row.days);
  110. return result ? result.label : row.days ? '剩余' + row.days + '天' : '';
  111. }
  112. }
  113. ];
  114. export const barOption = (series, itemStyle = {}) => {
  115. const axisLabel = {
  116. color: 'rgba(203, 231, 244, 0.72)',
  117. fontSize: Math.max(11, window.innerHeight * 0.011),
  118. hideOverlap: true
  119. };
  120. const formatAxisValue = (value) => {
  121. if (Math.abs(value) >= 10000) {
  122. return (value / 10000).toFixed(value % 10000 === 0 ? 0 : 1) + '万';
  123. }
  124. return value;
  125. };
  126. const defaultXAxis = {
  127. type: 'category',
  128. data: [
  129. '一月',
  130. '二月',
  131. '三月',
  132. '四月',
  133. '五月',
  134. '六月',
  135. '七月',
  136. '八月',
  137. '九月',
  138. '十月',
  139. '十一月',
  140. '十二月'
  141. ],
  142. axisLabel,
  143. axisLine: {
  144. lineStyle: {
  145. color: 'rgba(125, 211, 252, 0.35)'
  146. }
  147. },
  148. axisTick: {
  149. lineStyle: {
  150. color: 'rgba(125, 211, 252, 0.35)'
  151. }
  152. }
  153. };
  154. const xAxis = {
  155. ...defaultXAxis,
  156. ...(itemStyle.xAxis || {}),
  157. axisLabel: {
  158. ...defaultXAxis.axisLabel,
  159. ...((itemStyle.xAxis && itemStyle.xAxis.axisLabel) || {})
  160. },
  161. axisLine: {
  162. ...defaultXAxis.axisLine,
  163. ...((itemStyle.xAxis && itemStyle.xAxis.axisLine) || {})
  164. },
  165. axisTick: {
  166. ...defaultXAxis.axisTick,
  167. ...((itemStyle.xAxis && itemStyle.xAxis.axisTick) || {})
  168. }
  169. };
  170. return {
  171. backgroundColor: 'transparent',
  172. tooltip: {
  173. formatter: (item) => {
  174. return item.name + ':' + item.seriesName + ' ' + item.value + '个';
  175. },
  176. trigger: 'item',
  177. borderWidth: 1,
  178. borderColor: 'rgba(103, 232, 249, 0.42)',
  179. backgroundColor: 'rgba(4, 13, 25, 0.94)',
  180. extraCssText: 'box-shadow:0 8px 24px rgba(0,0,0,.28);border-radius:6px;',
  181. textStyle: {
  182. color: '#e0faff'
  183. }
  184. },
  185. legend: {
  186. // bottom: '2%',
  187. itemGap: window.innerHeight * 0.014,
  188. textStyle: {
  189. color: 'rgba(224, 242, 254, 0.78)',
  190. fontSize: Math.max(12, window.innerHeight * 0.013)
  191. },
  192. icon: 'roundRect'
  193. },
  194. grid: {
  195. top: 50,
  196. left: 34,
  197. right: 22,
  198. bottom: 20,
  199. containLabel: true
  200. },
  201. color: [
  202. {
  203. type: 'linear',
  204. x: 0,
  205. y: 0,
  206. x2: 0,
  207. y2: 1,
  208. colorStops: [
  209. { offset: 0, color: '#67e8f9' },
  210. { offset: 0.52, color: '#22d3ee' },
  211. { offset: 1, color: '#0369a1' }
  212. ]
  213. },
  214. '#fbbf24'
  215. ],
  216. xAxis,
  217. yAxis: [
  218. {
  219. type: 'value',
  220. name: '(个)',
  221. splitNumber: 4,
  222. minInterval: 1,
  223. nameTextStyle: {
  224. align: 'center',
  225. color: 'rgba(224, 242, 254, 0.72)',
  226. fontSize: Math.max(11, window.innerHeight * 0.011),
  227. padding: [0, 12, -3, 0]
  228. },
  229. axisLabel: {
  230. ...axisLabel,
  231. margin: 12,
  232. formatter: formatAxisValue
  233. },
  234. splitLine: {
  235. lineStyle: {
  236. color: 'rgba(125, 211, 252, 0.14)',
  237. type: [4, 6]
  238. }
  239. },
  240. axisLine: {
  241. show: true,
  242. lineStyle: {
  243. color: 'rgba(125, 211, 252, 0.3)'
  244. }
  245. }
  246. }
  247. ],
  248. ...itemStyle,
  249. xAxis,
  250. series: series.map((item) => {
  251. if (item.type === 'bar') {
  252. return {
  253. ...item,
  254. barMaxWidth: 26,
  255. barMinWidth: 8,
  256. showBackground: true,
  257. backgroundStyle: {
  258. color: 'rgba(56, 189, 248, 0.04)',
  259. borderRadius: [8, 8, 0, 0]
  260. },
  261. itemStyle: {
  262. borderRadius: [8, 8, 0, 0],
  263. shadowBlur: 14,
  264. shadowColor: 'rgba(56, 189, 248, 0.36)',
  265. ...(item.itemStyle || {})
  266. }
  267. };
  268. }
  269. return {
  270. ...item,
  271. lineStyle: {
  272. width: 3,
  273. color: '#fbbf24',
  274. shadowBlur: 12,
  275. shadowColor: 'rgba(251, 191, 36, 0.5)',
  276. ...(item.lineStyle || {})
  277. },
  278. itemStyle: {
  279. color: '#fbbf24',
  280. borderColor: '#fff7ad',
  281. borderWidth: 2,
  282. ...(item.itemStyle || {})
  283. }
  284. };
  285. })
  286. };
  287. };
  288. export const pieOption = (data) => {
  289. return {
  290. color: ['#398f4e', '#458ef7', '#fdc537', '#fe6869', '#975fe6'],
  291. tooltip: {
  292. formatter: '{b}:{c}' + '%',
  293. trigger: 'item'
  294. },
  295. legend: {
  296. orient: 'horizontal',
  297. left: 'right',
  298. right: '15%',
  299. bottom: '5%',
  300. itemGap: window.innerHeight * 0.018,
  301. textStyle: {
  302. fontSize: window.innerHeight * 0.014
  303. }
  304. },
  305. series: [
  306. {
  307. center: ['50%', '40%'],
  308. label: {
  309. position: 'outside',
  310. show: true,
  311. formatter: (item) => {
  312. return item.name + ':' + item.value + '%';
  313. },
  314. fontSize: window.innerHeight * 0.014
  315. // color:"#fff"
  316. },
  317. labelLine: {
  318. show: true
  319. },
  320. type: 'pie',
  321. radius: '60%',
  322. itemStyle: {
  323. borderWidth: 0,
  324. shadowBlur: 10,
  325. shadowColor: 'rgba(0, 0, 0, 0.5)'
  326. },
  327. data
  328. }
  329. ]
  330. };
  331. };
  332. export const pieOptions = (data) => {
  333. return {
  334. backgroundColor: 'transparent',
  335. color: ['#22d87a', '#35c9ff', '#ffd247', '#ff7890', '#9b78e6', '#2dd4bf', '#fb923c'],
  336. tooltip: {
  337. // formatter: '{b}:{c}' + '%',
  338. formatter: function (params) {
  339. return `${params.name}<br/>数量: ${params.value}<br/>占比: ${params.percent}%`;
  340. },
  341. trigger: 'item',
  342. borderWidth: 1,
  343. borderColor: 'rgba(103, 232, 249, 0.42)',
  344. backgroundColor: 'rgba(4, 13, 25, 0.94)',
  345. extraCssText: 'box-shadow:0 8px 24px rgba(0,0,0,.28);border-radius:6px;',
  346. textStyle: {
  347. color: '#e0faff'
  348. }
  349. },
  350. // legend: {
  351. // orient: 'horizontal',
  352. // left: 'right',
  353. // right: '15%',
  354. // bottom: '5%',
  355. // itemGap: window.innerHeight * 0.018,
  356. // textStyle: {
  357. // fontSize: window.innerHeight * 0.014
  358. // }
  359. // },
  360. series: [
  361. {
  362. center: ['52%', '52%'],
  363. label: {
  364. position: 'outside',
  365. show: true,
  366. formatter: (item) => {
  367. return `{name|${item.name}} {value|${item.value}}`;
  368. },
  369. color: 'rgba(224, 242, 254, 0.84)',
  370. width: 128,
  371. overflow: 'break',
  372. lineHeight: 19,
  373. rich: {
  374. name: {
  375. color: 'rgba(169, 197, 210, 0.92)',
  376. fontSize: 12,
  377. fontWeight: 600,
  378. lineHeight: 19,
  379. textShadowBlur: 8,
  380. textShadowColor: 'rgba(56, 189, 248, 0.2)'
  381. },
  382. value: {
  383. color: '#ffe37a',
  384. fontSize: 15,
  385. fontWeight: 700,
  386. lineHeight: 19,
  387. textBorderColor: 'rgba(7, 18, 31, 0.68)',
  388. textBorderWidth: 2,
  389. textShadowBlur: 14,
  390. textShadowColor: 'rgba(250, 204, 21, 0.68)'
  391. }
  392. }
  393. },
  394. labelLine: {
  395. show: true,
  396. length: 16,
  397. length2: 24,
  398. smooth: true,
  399. lineStyle: {
  400. width: 1.6,
  401. color: 'rgba(125, 211, 252, 0.68)'
  402. }
  403. },
  404. type: 'pie',
  405. radius: ['43%', '66%'],
  406. startAngle: 120,
  407. minAngle: 4,
  408. avoidLabelOverlap: true,
  409. itemStyle: {
  410. borderRadius: 10,
  411. borderWidth: 3,
  412. borderColor: '#07111f',
  413. shadowBlur: 20,
  414. shadowColor: 'rgba(34, 211, 238, 0.26)'
  415. },
  416. emphasis: {
  417. scaleSize: 7,
  418. itemStyle: {
  419. shadowBlur: 26,
  420. shadowColor: 'rgba(103, 232, 249, 0.48)'
  421. }
  422. },
  423. data
  424. },
  425. {
  426. type: 'pie',
  427. center: ['52%', '52%'],
  428. radius: ['35%', '36%'],
  429. silent: true,
  430. label: {
  431. show: false
  432. },
  433. data: [
  434. {
  435. value: 1,
  436. itemStyle: {
  437. color: 'rgba(103, 232, 249, 0.24)',
  438. shadowBlur: 18,
  439. shadowColor: 'rgba(56, 189, 248, 0.32)'
  440. }
  441. }
  442. ]
  443. }
  444. ]
  445. };
  446. };
  447. // ==================== 首页大屏静态数据 ====================
  448. // 数据来源:五品四数.xlsx(各分厂生产指标 + 1-12月工单入库数量)
  449. // metrics 顺序:计划数、投入数、产出数、在制品数、合格品数
  450. // defective 顺序:返工品、返修品、废品
  451. // inWarehouse 顺序:1月 ~ 12月
  452. export const monthLabels = [
  453. '一月',
  454. '二月',
  455. '三月',
  456. '四月',
  457. '五月',
  458. '六月',
  459. '七月',
  460. '八月',
  461. '九月',
  462. '十月',
  463. '十一月',
  464. '十二月'
  465. ];
  466. // 工厂(分厂)切换选项
  467. export const factoryOptions = [
  468. { id: '1', name: '机加一分厂' },
  469. { id: '2', name: '机加二分厂' },
  470. { id: '3', name: '特种作业分厂' },
  471. { id: '4', name: '总装分厂' }
  472. ];
  473. export const mesStaticData = {
  474. // 机加一分厂
  475. 1: {
  476. metrics: [24386, 20500, 9412, 10730, 8630],
  477. defective: [314, 113, 355],
  478. inWarehouse: [1030, 1058, 1098, 1073, 1104, 1093, 1055, 1046, 500, 0, 0, 0]
  479. },
  480. // 机加二分厂
  481. 2: {
  482. metrics: [19828, 17700, 8461, 8616, 7840],
  483. defective: [230, 102, 289],
  484. inWarehouse: [960, 983, 971, 969, 978, 975, 982, 950, 400, 0, 0, 0]
  485. },
  486. // 特种作业分厂
  487. 3: {
  488. metrics: [10256, 9000, 4840, 4080, 4535],
  489. defective: [35, 0, 270],
  490. inWarehouse: [550, 538, 544, 552, 546, 540, 551, 547, 202, 0, 0, 0]
  491. },
  492. // 总装分厂(返修数、1月入库数原表为空,按 0 处理)
  493. 4: {
  494. metrics: [3600, 2600, 1530, 980, 1452],
  495. defective: [18, 0, 60],
  496. inWarehouse: [0, 33, 230, 220, 225, 212, 240, 223, 87, 0, 0, 0]
  497. },
  498. // 企业合计
  499. ALL: {
  500. metrics: [58070, 49800, 24243, 24406, 22457],
  501. defective: [597, 215, 974],
  502. inWarehouse: [2540, 2612, 2843, 2814, 2853, 2820, 2828, 2766, 1189, 0, 0, 0]
  503. }
  504. };