data.js 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695
  1. // 引入Day.js库
  2. const dayjs = require('dayjs');
  3. let statusOpt= [
  4. { label: '待生产', value: 4 },
  5. { label: '生产中', value: 5 },
  6. { label: '待下达', value: 8 }
  7. ];
  8. // 获取本月日期列表的函数
  9. function getDatesInMonth() {
  10. let year = dayjs().year()
  11. let month = dayjs().month()
  12. const dates = [];
  13. const startDate = dayjs(new Date(year, month, 1));
  14. const endDate = dayjs(new Date(year, month + 1, 1)).subtract(1, 'day');
  15. let currentDate = startDate;
  16. while (currentDate.isBefore(endDate) || currentDate.isSame(endDate, 'day')) {
  17. dates.push(currentDate.format('YYYY-MM-DD'));
  18. currentDate = currentDate.add(1, 'day');
  19. }
  20. return dates;
  21. }
  22. export const columns = [
  23. {
  24. columnKey: 'index',
  25. slot: 'index',
  26. label: '序号',
  27. type: 'index',
  28. width: 55,
  29. align: 'center',
  30. showOverflowTooltip: true,
  31. fixed: 'left'
  32. },
  33. {
  34. slot: 'code',
  35. prop: 'code',
  36. label: '生产订单号',
  37. align: 'center',
  38. minWidth: 180,
  39. sortable: true
  40. },
  41. {
  42. prop: 'productionPlanCode',
  43. label: '计划编号',
  44. align: 'center',
  45. minWidth: 150
  46. },
  47. {
  48. prop: 'produceRoutingName',
  49. label: '工艺路线',
  50. align: 'center',
  51. minWidth: 170
  52. },
  53. {
  54. prop: 'productCode',
  55. label: '编码',
  56. align: 'center',
  57. minWidth: 110
  58. },
  59. {
  60. prop: 'productName',
  61. label: '名称',
  62. align: 'center',
  63. minWidth: 170
  64. },
  65. {
  66. prop: 'brandNo',
  67. label: '牌号',
  68. align: 'center'
  69. },
  70. {
  71. prop: 'batchNo',
  72. label: '批次号',
  73. align: 'center',
  74. minWidth: 100,
  75. showOverflowTooltip: true
  76. },
  77. {
  78. prop: 'model',
  79. label: '型号',
  80. align: 'center',
  81. showOverflowTooltip: true
  82. },
  83. {
  84. prop: 'priority',
  85. label: '优先级',
  86. align: 'center',
  87. minWidth: 120,
  88. slot: 'priority',
  89. sortable: 'custom'
  90. },
  91. {
  92. prop: 'formingNum',
  93. label: '要求生产数量',
  94. align: 'center',
  95. showOverflowTooltip: true,
  96. minWidth: 110
  97. },
  98. {
  99. prop: 'formingWeight',
  100. label: '要求生产重量',
  101. align: 'center',
  102. showOverflowTooltip: true,
  103. minWidth: 110,
  104. slot: 'formingWeight'
  105. },
  106. {
  107. prop: 'planStartTime',
  108. label: '计划开始时间',
  109. align: 'center',
  110. showOverflowTooltip: true,
  111. minWidth: 110
  112. },
  113. {
  114. prop: 'planCompleteTime',
  115. label: '计划结束时间',
  116. align: 'center',
  117. showOverflowTooltip: true,
  118. minWidth: 110
  119. },
  120. {
  121. prop: 'workCenterName',
  122. label: '工作中心',
  123. align: 'center',
  124. minWidth: 110,
  125. showOverflowTooltip: true
  126. },
  127. {
  128. prop: 'firstTaskName',
  129. label: '首工序',
  130. align: 'center',
  131. minWidth: 110,
  132. showOverflowTooltip: true
  133. },
  134. {
  135. prop: 'createTime',
  136. label: '创建时间',
  137. align: 'center',
  138. showOverflowTooltip: true,
  139. minWidth: 110,
  140. sortable: 'custom'
  141. },
  142. {
  143. slot: 'status',
  144. label: '状态',
  145. align: 'center',
  146. formatter: (row) => {
  147. const obj = statusOpt.find((i) => i.value == row.status);
  148. return obj && obj.label;
  149. }
  150. },
  151. {
  152. prop: 'serialNo',
  153. label: '客户代号',
  154. align: 'center',
  155. showOverflowTooltip: true
  156. },
  157. {
  158. prop: 'simpleName',
  159. label: '客户简称',
  160. align: 'center',
  161. showOverflowTooltip: true
  162. }
  163. ];
  164. export const lineOption = (data, itemStyle = {}) => {
  165. const colors = [
  166. ['#2f9bff', 'rgba(47, 155, 255, 0.08)'],
  167. ['#5ee0b0', 'rgba(94, 224, 176, 0.1)']
  168. ];
  169. return {
  170. tooltip: {
  171. formatter: (item) => {
  172. if (Array.isArray(item)) {
  173. const title = item[0] ? item[0].name : '';
  174. const rows = item
  175. .map((i) => i.marker + i.seriesName + ":" + i.value + '%')
  176. .join('<br/>');
  177. return title + '<br/>' + rows;
  178. }
  179. return item.name + ":" + item.seriesName + " " + item.value
  180. },
  181. trigger: 'axis',
  182. axisPointer: {
  183. type: 'line',
  184. lineStyle: {
  185. color: 'rgba(82, 217, 230, 0.42)',
  186. width: 1,
  187. type: 'dashed'
  188. }
  189. },
  190. backgroundColor: 'rgba(6, 17, 17, 0.92)',
  191. borderColor: 'rgba(82, 217, 230, 0.35)',
  192. textStyle: {
  193. color: '#e8fbff'
  194. }
  195. },
  196. legend: {
  197. // bottom: '2%',
  198. itemGap: window.innerHeight * 0.014,
  199. icon: 'roundRect',
  200. textStyle: {
  201. fontSize: window.innerHeight * 0.013,
  202. color: '#c8e9ee'
  203. }
  204. },
  205. grid: {
  206. left: 38,
  207. right: 24,
  208. top: 40,
  209. bottom: 24,
  210. containLabel: true
  211. },
  212. color: colors.map((item) => item[0]),
  213. xAxis: {
  214. type: 'category',
  215. data: ['10/2', '10/3', '10/4', '10/5', '10/6', '10/7', '10/8'],
  216. boundaryGap: false,
  217. axisLine: {
  218. lineStyle: {
  219. color: 'rgba(82, 217, 230, 0.44)'
  220. }
  221. },
  222. axisTick: {
  223. show: false
  224. },
  225. axisLabel: {
  226. fontSize: window.innerHeight * 0.012,
  227. color: '#b9dce2',
  228. margin: 10
  229. },
  230. splitLine: {
  231. show: true,
  232. lineStyle: {
  233. color: 'rgba(82, 217, 230, 0.06)'
  234. }
  235. }
  236. },
  237. yAxis: [
  238. {
  239. type: 'value',
  240. max: 100,
  241. min: 0,
  242. axisLabel: {
  243. show: true,
  244. color: '#b9dce2',
  245. formatter: "{value}%", //右侧Y轴文字显示
  246. },
  247. axisLine: {
  248. show: false
  249. },
  250. axisTick: {
  251. show: false
  252. },
  253. splitLine: {
  254. lineStyle: {
  255. color: 'rgba(82, 217, 230, 0.16)',
  256. type: 'dashed'
  257. }
  258. },
  259. nameTextStyle: {
  260. align: 'center',
  261. color: "#333",
  262. fontSize: window.innerHeight * 0.012,
  263. padding: [0, 20, -3, 0]
  264. },
  265. },
  266. ],
  267. series: [
  268. {
  269. name: '过程控',
  270. symbol: 'circle',
  271. symbolSize: 8,
  272. data: data[0],
  273. type: 'line',
  274. smooth: true,
  275. showSymbol: true,
  276. lineStyle: {
  277. width: 3,
  278. color: colors[0][0],
  279. shadowBlur: 12,
  280. shadowColor: colors[0][0]
  281. },
  282. areaStyle: {
  283. color: {
  284. type: 'linear',
  285. x: 0,
  286. y: 0,
  287. x2: 0,
  288. y2: 1,
  289. colorStops: [
  290. { offset: 0, color: 'rgba(47, 155, 255, 0.22)' },
  291. { offset: 0.62, color: colors[0][1] },
  292. { offset: 1, color: 'rgba(47, 155, 255, 0)' }
  293. ]
  294. }
  295. },
  296. itemStyle: {
  297. color: colors[0][0],
  298. borderColor: '#dff5ff',
  299. borderWidth: 2,
  300. shadowBlur: 10,
  301. shadowColor: colors[0][0]
  302. },
  303. emphasis: {
  304. focus: 'series',
  305. scale: true
  306. },
  307. z: 4
  308. }, {
  309. name: '产品控',
  310. symbol: 'circle',
  311. symbolSize: 8,
  312. data: data[1],
  313. type: 'line',
  314. smooth: true,
  315. showSymbol: true,
  316. lineStyle: {
  317. width: 3,
  318. color: colors[1][0],
  319. shadowBlur: 12,
  320. shadowColor: colors[1][0]
  321. },
  322. areaStyle: {
  323. color: {
  324. type: 'linear',
  325. x: 0,
  326. y: 0,
  327. x2: 0,
  328. y2: 1,
  329. colorStops: [
  330. { offset: 0, color: 'rgba(94, 224, 176, 0.2)' },
  331. { offset: 0.62, color: colors[1][1] },
  332. { offset: 1, color: 'rgba(94, 224, 176, 0)' }
  333. ]
  334. }
  335. },
  336. itemStyle: {
  337. color: colors[1][0],
  338. borderColor: '#e4fff5',
  339. borderWidth: 2,
  340. shadowBlur: 10,
  341. shadowColor: colors[1][0]
  342. },
  343. emphasis: {
  344. focus: 'series',
  345. scale: true
  346. },
  347. z: 5
  348. }
  349. ]
  350. }
  351. }
  352. export const barOption = ( xData,series) => {
  353. const monthLabelMap = {
  354. '一月': '1月',
  355. '二月': '2月',
  356. '三月': '3月',
  357. '四月': '4月',
  358. '五月': '5月',
  359. '六月': '6月',
  360. '七月': '7月',
  361. '八月': '8月',
  362. '九月': '9月',
  363. '十月': '10月',
  364. '十一月': '11月',
  365. '十二月': '12月'
  366. };
  367. const barColors = [
  368. ['rgba(255, 209, 102, 0.96)', 'rgba(236, 178, 87, 0.36)'],
  369. ['rgba(47, 155, 255, 0.98)', 'rgba(35, 150, 255, 0.32)'],
  370. ['rgba(91, 210, 167, 0.96)', 'rgba(91, 210, 167, 0.3)']
  371. ];
  372. const chartSeries = series.map((item, index) => {
  373. if (item.type === 'bar') {
  374. const color = barColors[index % barColors.length];
  375. return {
  376. ...item,
  377. barWidth: item.barWidth || 14,
  378. barMaxWidth: 18,
  379. barGap: '38%',
  380. showBackground: true,
  381. backgroundStyle: {
  382. color: 'rgba(82, 217, 230, 0.055)',
  383. borderColor: 'rgba(82, 217, 230, 0.14)',
  384. borderWidth: 1
  385. },
  386. itemStyle: {
  387. ...(item.itemStyle || {}),
  388. borderRadius: [3, 3, 0, 0],
  389. color: {
  390. type: 'linear',
  391. x: 0,
  392. y: 0,
  393. x2: 0,
  394. y2: 1,
  395. colorStops: [
  396. { offset: 0, color: color[0] },
  397. { offset: 0.52, color: color[0] },
  398. { offset: 1, color: color[1] }
  399. ]
  400. },
  401. shadowBlur: 12,
  402. shadowColor: color[0]
  403. },
  404. emphasis: {
  405. focus: 'series',
  406. itemStyle: {
  407. shadowBlur: 18,
  408. shadowColor: color[0]
  409. }
  410. },
  411. z: 3
  412. };
  413. }
  414. if (item.type === 'line') {
  415. return {
  416. ...item,
  417. symbol: 'circle',
  418. symbolSize: item.symbolSize || 10,
  419. lineStyle: {
  420. width: 3,
  421. color: item.itemStyle && item.itemStyle.color ? item.itemStyle.color : '#ff8a4c',
  422. shadowBlur: 12,
  423. shadowColor: item.itemStyle && item.itemStyle.color ? item.itemStyle.color : '#ff8a4c'
  424. },
  425. itemStyle: {
  426. ...(item.itemStyle || {}),
  427. borderColor: '#fff7ef',
  428. borderWidth: 2,
  429. shadowBlur: 10,
  430. shadowColor: item.itemStyle && item.itemStyle.color ? item.itemStyle.color : '#ff8a4c'
  431. },
  432. z: 5
  433. };
  434. }
  435. return item;
  436. });
  437. return {
  438. tooltip: {
  439. formatter: (item) => {
  440. if (Array.isArray(item)) {
  441. const title = item[0] ? item[0].name : '';
  442. const rows = item
  443. .map((i) => i.seriesName + ":" + i.value)
  444. .join('<br/>');
  445. return title + '<br/>' + rows;
  446. }
  447. return item.name + ":" + item.seriesName + " " + item.value
  448. },
  449. trigger: 'axis',
  450. axisPointer: {
  451. type: 'shadow',
  452. shadowStyle: {
  453. color: 'rgba(82, 217, 230, 0.08)'
  454. }
  455. },
  456. backgroundColor: 'rgba(6, 17, 17, 0.92)',
  457. borderColor: 'rgba(82, 217, 230, 0.35)',
  458. textStyle: {
  459. color: '#e8fbff'
  460. }
  461. },
  462. legend: {
  463. // bottom: '2%',
  464. itemGap: window.innerHeight * 0.014,
  465. textStyle: {
  466. fontSize: window.innerHeight * 0.013,
  467. color: '#9fc7cf'
  468. }
  469. },
  470. grid: {
  471. left: 34,
  472. right: 44,
  473. top: 36,
  474. bottom: 30,
  475. containLabel: true
  476. },
  477. color: ['#2396ff', '#5bd2a7', '#ff844a', '#ffd166'],
  478. xAxis: {
  479. type: 'category',
  480. data:xData ,
  481. axisLine: {
  482. lineStyle: {
  483. color: 'rgba(185, 220, 226, 0.45)'
  484. }
  485. },
  486. axisTick: {
  487. show: false
  488. },
  489. axisLabel: {
  490. fontSize: Math.max(11, Math.min(13, window.innerHeight * 0.012)),
  491. color: '#b9dce2',
  492. interval: 0,
  493. margin: 9,
  494. hideOverlap: false,
  495. formatter: (value) => monthLabelMap[value] || value
  496. }
  497. },
  498. yAxis: [
  499. {
  500. type: 'value',
  501. // name: '(个)',
  502. axisLabel: {
  503. color: '#b9dce2'
  504. },
  505. axisLine: {
  506. show: false
  507. },
  508. axisTick: {
  509. show: false
  510. },
  511. splitLine: {
  512. lineStyle: {
  513. color: 'rgba(82, 217, 230, 0.16)',
  514. type: 'dashed'
  515. }
  516. },
  517. nameTextStyle: {
  518. align: 'center',
  519. color: "#333",
  520. fontSize: window.innerHeight * 0.012,
  521. padding: [0, 20, -3, 0]
  522. },
  523. },
  524. {
  525. type: 'value',
  526. max: 100,
  527. min: 0,
  528. axisLabel: {
  529. show: true,
  530. color: '#b9dce2',
  531. formatter: "{value}%", //右侧Y轴文字显示
  532. },
  533. axisLine: {
  534. show: false
  535. },
  536. axisTick: {
  537. show: false
  538. },
  539. splitLine: {
  540. show: false
  541. }
  542. }
  543. ],
  544. series: chartSeries
  545. }
  546. }
  547. export const pieOption = (data) => {
  548. const colors = [
  549. ['#4ee6a3', '#1d8b68'],
  550. ['#36adff', '#1762c7'],
  551. ['#ffd66b', '#b88421'],
  552. ['#ff7070', '#b83243'],
  553. ['#9b79ff', '#5c40bd'],
  554. ['#48dfea', '#1c8590']
  555. ];
  556. const pieData = data.map((item, index) => {
  557. const color = colors[index % colors.length];
  558. return {
  559. ...item,
  560. itemStyle: {
  561. borderRadius: 6,
  562. borderWidth: 2,
  563. borderColor: '#071719',
  564. color: {
  565. type: 'linear',
  566. x: 0,
  567. y: 0,
  568. x2: 1,
  569. y2: 1,
  570. colorStops: [
  571. { offset: 0, color: color[0] },
  572. { offset: 1, color: color[1] }
  573. ]
  574. },
  575. shadowBlur: 10,
  576. shadowColor: color[0]
  577. }
  578. };
  579. });
  580. return {
  581. color: colors.map((item) => item[0]),
  582. tooltip: {
  583. // formatter: '{b}:{c}' + '%',
  584. trigger: 'item',
  585. backgroundColor: 'rgba(6, 17, 17, 0.92)',
  586. borderColor: 'rgba(82, 217, 230, 0.35)',
  587. textStyle: {
  588. color: '#e8fbff'
  589. }
  590. },
  591. // legend: {
  592. // orient: 'horizontal',
  593. // left: 'right',
  594. // right: '15%',
  595. // bottom: '5%',
  596. // itemGap: window.innerHeight * 0.018,
  597. // textStyle: {
  598. // fontSize: window.innerHeight * 0.014,
  599. // }
  600. // },
  601. series: [
  602. {
  603. type: 'pie',
  604. center: ['50%', '50%'],
  605. radius: ['0%', '29%'],
  606. silent: true,
  607. label: {
  608. show: false
  609. },
  610. labelLine: {
  611. show: false
  612. },
  613. itemStyle: {
  614. color: {
  615. type: 'radial',
  616. x: 0.5,
  617. y: 0.5,
  618. r: 0.7,
  619. colorStops: [
  620. { offset: 0, color: 'rgba(82, 217, 230, 0.18)' },
  621. { offset: 0.56, color: 'rgba(8, 24, 27, 0.92)' },
  622. { offset: 1, color: 'rgba(6, 17, 17, 0.98)' }
  623. ]
  624. },
  625. shadowBlur: 18,
  626. shadowColor: 'rgba(82, 217, 230, 0.16)'
  627. },
  628. z: 1,
  629. data: [{ value: 1 }]
  630. },
  631. {
  632. center: ['50%', '50%'],
  633. avoidLabelOverlap: true,
  634. label: {
  635. position: 'outside',
  636. show: true,
  637. bleedMargin: 12,
  638. formatter: (item) => {
  639. return item.name + '\n' + item.value + '/' + item.percent + '%'
  640. },
  641. lineHeight: 18,
  642. fontSize: Math.max(12, window.innerHeight * 0.011),
  643. color:"#d9edf2",
  644. overflow: 'break'
  645. },
  646. labelLine: {
  647. show: true,
  648. length: 10,
  649. length2: 18,
  650. lineStyle: {
  651. width: 1.2,
  652. opacity: 0.86
  653. }
  654. },
  655. type: 'pie',
  656. radius: ['36%', '58%'],
  657. clockwise: true,
  658. minAngle: 6,
  659. emphasis: {
  660. focus: 'self',
  661. scaleSize: 5,
  662. label: {
  663. color: '#f2fbfb',
  664. fontWeight: 700
  665. },
  666. itemStyle: {
  667. shadowBlur: 18
  668. }
  669. },
  670. z: 2,
  671. data: pieData
  672. }
  673. ]
  674. }
  675. }