mesMaterialScreen.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518
  1. <!DOCTYPE html>
  2. <html lang="zh-CN">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>物料管理看板</title>
  7. <style>
  8. * { box-sizing: border-box; }
  9. html, body {
  10. width: 100%;
  11. height: 100%;
  12. margin: 0;
  13. overflow: hidden;
  14. background: #061521;
  15. color: #ddfbff;
  16. font-family: "Microsoft YaHei", Arial, sans-serif;
  17. }
  18. .screen {
  19. position: relative;
  20. width: 1920px;
  21. height: 1080px;
  22. padding: 16px;
  23. transform-origin: left top;
  24. overflow: hidden;
  25. background:
  26. linear-gradient(130deg, rgba(11, 107, 114, .2), transparent 38%),
  27. linear-gradient(235deg, rgba(48, 96, 147, .18), transparent 42%),
  28. linear-gradient(180deg, #071623 0%, #092235 52%, #06121e 100%);
  29. }
  30. .screen:before {
  31. content: "";
  32. position: absolute;
  33. inset: 0;
  34. pointer-events: none;
  35. background-image:
  36. linear-gradient(rgba(94, 222, 255, .045) 1px, transparent 1px),
  37. linear-gradient(90deg, rgba(94, 222, 255, .045) 1px, transparent 1px);
  38. background-size: 44px 44px;
  39. }
  40. .shell {
  41. position: relative;
  42. z-index: 1;
  43. display: grid;
  44. grid-template-rows: 72px 104px 1fr;
  45. gap: 14px;
  46. width: 100%;
  47. height: 100%;
  48. }
  49. .header {
  50. display: grid;
  51. grid-template-columns: 1fr 600px 1fr;
  52. align-items: center;
  53. }
  54. .title {
  55. position: relative;
  56. text-align: center;
  57. font-size: 36px;
  58. font-weight: 700;
  59. color: #f1ffff;
  60. text-shadow: 0 0 18px rgba(61, 226, 255, .85);
  61. }
  62. .title:before,
  63. .title:after {
  64. content: "";
  65. position: absolute;
  66. top: 50%;
  67. width: 170px;
  68. height: 1px;
  69. background: linear-gradient(90deg, transparent, rgba(83, 221, 255, .95));
  70. }
  71. .title:before { right: calc(100% + 18px); }
  72. .title:after { left: calc(100% + 18px); transform: rotate(180deg); }
  73. .time {
  74. justify-self: end;
  75. color: #8edbef;
  76. font-size: 16px;
  77. white-space: nowrap;
  78. }
  79. .kpis {
  80. display: grid;
  81. grid-template-columns: repeat(8, minmax(0, 1fr));
  82. gap: 12px;
  83. }
  84. .kpi,
  85. .panel {
  86. position: relative;
  87. border: 1px solid rgba(72, 206, 255, .42);
  88. background: linear-gradient(180deg, rgba(9, 43, 68, .9), rgba(6, 24, 39, .78));
  89. box-shadow: inset 0 0 24px rgba(52, 194, 228, .13), 0 0 20px rgba(0, 148, 210, .08);
  90. overflow: hidden;
  91. }
  92. .kpi:before,
  93. .panel:before {
  94. content: "";
  95. position: absolute;
  96. inset: 0;
  97. border: 1px solid rgba(158, 238, 255, .08);
  98. pointer-events: none;
  99. }
  100. .kpi {
  101. display: flex;
  102. flex-direction: column;
  103. justify-content: center;
  104. padding: 12px 14px;
  105. min-width: 0;
  106. }
  107. .kpi-label {
  108. color: #a1cfdb;
  109. font-size: 13px;
  110. line-height: 18px;
  111. overflow: hidden;
  112. text-overflow: ellipsis;
  113. white-space: nowrap;
  114. }
  115. .kpi-value {
  116. margin-top: 8px;
  117. font-family: Impact, "Arial Narrow", sans-serif;
  118. font-size: 32px;
  119. line-height: 1;
  120. color: #45f1ff;
  121. text-shadow: 0 0 16px rgba(69, 241, 255, .5);
  122. }
  123. .kpi.warn .kpi-value { color: #ffcf5b; text-shadow: 0 0 16px rgba(255, 207, 91, .38); }
  124. .main {
  125. display: grid;
  126. grid-template-columns: minmax(0, 30fr) minmax(0, 40fr) minmax(0, 30fr);
  127. gap: 14px;
  128. min-width: 0;
  129. min-height: 0;
  130. }
  131. .column {
  132. display: grid;
  133. gap: 14px;
  134. min-width: 0;
  135. min-height: 0;
  136. }
  137. .left { grid-template-rows: 44% 28% 28%; }
  138. .center { grid-template-rows: 58% 42%; }
  139. .right { grid-template-rows: 35% 32% 33%; }
  140. .panel-title {
  141. height: 42px;
  142. display: flex;
  143. align-items: center;
  144. padding: 0 16px;
  145. border-bottom: 1px solid rgba(88, 211, 255, .23);
  146. color: #f1fdff;
  147. font-size: 17px;
  148. font-weight: 700;
  149. }
  150. .panel-title:before {
  151. content: "";
  152. width: 4px;
  153. height: 18px;
  154. margin-right: 9px;
  155. background: #3be7ff;
  156. box-shadow: 0 0 12px #3be7ff;
  157. }
  158. .chart {
  159. width: 100%;
  160. height: calc(100% - 42px);
  161. min-width: 0;
  162. min-height: 0;
  163. }
  164. .dual, .quad {
  165. display: grid;
  166. height: calc(100% - 42px);
  167. min-width: 0;
  168. min-height: 0;
  169. }
  170. .dual { grid-template-columns: 1fr 1fr; }
  171. .quad { grid-template-columns: 1fr 1fr; grid-template-rows: 1fr 1fr; }
  172. .dual .chart, .quad .chart { height: 100%; }
  173. .table-wrap {
  174. height: calc(100% - 42px);
  175. padding: 10px 12px 12px;
  176. overflow: hidden;
  177. }
  178. .scroll-body {
  179. height: calc(100% - 30px);
  180. overflow-y: auto;
  181. scrollbar-width: thin;
  182. scrollbar-color: rgba(77, 221, 255, .55) rgba(12, 52, 76, .38);
  183. }
  184. .scroll-body::-webkit-scrollbar { width: 6px; }
  185. .scroll-body::-webkit-scrollbar-track { background: rgba(12, 52, 76, .38); }
  186. .scroll-body::-webkit-scrollbar-thumb { background: rgba(77, 221, 255, .55); border-radius: 6px; }
  187. .table-head,
  188. .table-row {
  189. display: grid;
  190. gap: 10px;
  191. align-items: center;
  192. min-width: 0;
  193. }
  194. .stock-table .table-head,
  195. .stock-table .table-row {
  196. grid-template-columns: 1.15fr .75fr .9fr .8fr 70px .9fr;
  197. }
  198. .action-table .table-head,
  199. .action-table .table-row {
  200. grid-template-columns: 70px 1.15fr .9fr .75fr 62px 78px;
  201. }
  202. .expire-table .table-head,
  203. .expire-table .table-row {
  204. grid-template-columns: 1fr .85fr .75fr 62px .85fr;
  205. }
  206. .table-head {
  207. height: 30px;
  208. color: #7dbdd0;
  209. font-size: 13px;
  210. border-bottom: 1px solid rgba(96, 202, 255, .18);
  211. }
  212. .table-row {
  213. height: 36px;
  214. color: #dff8ff;
  215. font-size: 13px;
  216. border-bottom: 1px solid rgba(105, 199, 232, .08);
  217. }
  218. .cell {
  219. min-width: 0;
  220. overflow: hidden;
  221. text-overflow: ellipsis;
  222. white-space: nowrap;
  223. }
  224. .tag {
  225. display: inline-flex;
  226. align-items: center;
  227. justify-content: center;
  228. min-width: 54px;
  229. height: 22px;
  230. padding: 0 8px;
  231. border: 1px solid rgba(79, 219, 255, .34);
  232. background: rgba(22, 118, 147, .25);
  233. color: #9ff4ff;
  234. font-size: 12px;
  235. }
  236. .empty {
  237. height: 100%;
  238. display: flex;
  239. align-items: center;
  240. justify-content: center;
  241. color: #6fa9bb;
  242. font-size: 14px;
  243. }
  244. </style>
  245. </head>
  246. <body>
  247. <div class="screen" id="screen">
  248. <div class="shell">
  249. <div class="header">
  250. <div></div>
  251. <div class="title">物料管理看板</div>
  252. <div class="time" id="timeText"></div>
  253. </div>
  254. <div class="kpis">
  255. <div class="kpi"><div class="kpi-label">线边物料种类</div><div class="kpi-value" id="materialCount">0</div></div>
  256. <div class="kpi"><div class="kpi-label">库存批次数</div><div class="kpi-value" id="stockBatchCount">0</div></div>
  257. <div class="kpi"><div class="kpi-label">当前库存总量</div><div class="kpi-value" id="stockTotal">0</div></div>
  258. <div class="kpi"><div class="kpi-label">今日领料入库</div><div class="kpi-value" id="todayInbound">0</div></div>
  259. <div class="kpi"><div class="kpi-label">今日领料单</div><div class="kpi-value" id="todayPickBill">0</div></div>
  260. <div class="kpi"><div class="kpi-label">关联生产订单</div><div class="kpi-value" id="moCount">0</div></div>
  261. <div class="kpi warn"><div class="kpi-label">未关联订单</div><div class="kpi-value" id="unlinkedBatch">0</div></div>
  262. <div class="kpi warn"><div class="kpi-label">领料下推失败</div><div class="kpi-value" id="pickFailCount">0</div></div>
  263. </div>
  264. <div class="main">
  265. <div class="column left">
  266. <div class="panel">
  267. <div class="panel-title">近7日领料流转</div>
  268. <div class="chart" id="trendChart"></div>
  269. </div>
  270. <div class="panel">
  271. <div class="panel-title">领料业务概览</div>
  272. <div class="quad">
  273. <div class="chart" id="pickResultChart"></div>
  274. <div class="chart" id="pickChannelChart"></div>
  275. <div class="chart" id="stockMoStatusChart"></div>
  276. <div class="chart" id="pickMaterialMixChart"></div>
  277. </div>
  278. </div>
  279. <div class="panel">
  280. <div class="panel-title">线边物料TOP</div>
  281. <div class="chart" id="pickMaterialTopChart"></div>
  282. </div>
  283. </div>
  284. <div class="column center">
  285. <div class="panel">
  286. <div class="panel-title">线边库存明细</div>
  287. <div class="table-wrap stock-table">
  288. <div class="table-head"><div>物料</div><div>ERP</div><div>批次</div><div>生产订单</div><div>数量</div><div>领料单号</div></div>
  289. <div class="scroll-body" id="stockList"></div>
  290. </div>
  291. </div>
  292. <div class="panel">
  293. <div class="panel-title">最新领料动态</div>
  294. <div class="table-wrap action-table">
  295. <div class="table-head"><div>类型</div><div>物料</div><div>批次</div><div>状态</div><div>数量</div><div>时间</div></div>
  296. <div class="scroll-body" id="actionList"></div>
  297. </div>
  298. </div>
  299. </div>
  300. <div class="column right">
  301. <div class="panel">
  302. <div class="panel-title">生产订单库存TOP</div>
  303. <div class="chart" id="moTopChart"></div>
  304. </div>
  305. <div class="panel">
  306. <div class="panel-title">物料库存TOP</div>
  307. <div class="chart" id="materialTopChart"></div>
  308. </div>
  309. <div class="panel">
  310. <div class="panel-title">未关联订单库存</div>
  311. <div class="table-wrap expire-table">
  312. <div class="table-head"><div>物料</div><div>批次</div><div>领料单</div><div>数量</div><div>入库时间</div></div>
  313. <div class="scroll-body" id="unlinkedList"></div>
  314. </div>
  315. </div>
  316. </div>
  317. </div>
  318. </div>
  319. </div>
  320. <script src="${ctxStatic}/jquery-1.11.3.min.js"></script>
  321. <script src="${ctxStatic}/leaflet/js/echarts.min.js"></script>
  322. <script>
  323. var charts = {};
  324. var colors = ['#37e4ff', '#ffcf5a', '#65ffb4', '#ff7676', '#9c8cff', '#58a6ff', '#f28bff', '#b7e75b'];
  325. var scrollTimers = {};
  326. var scrollPaused = {};
  327. function initCharts() {
  328. ['trendChart', 'pickResultChart', 'pickChannelChart', 'stockMoStatusChart', 'pickMaterialMixChart',
  329. 'pickMaterialTopChart', 'moTopChart', 'materialTopChart'].forEach(function(id) {
  330. charts[id] = echarts.init(document.getElementById(id));
  331. });
  332. }
  333. function textStyle(size) {
  334. return { color: '#a8d8e8', fontSize: size || 12 };
  335. }
  336. function render(data) {
  337. var summary = data.summary || {};
  338. ['materialCount', 'stockBatchCount', 'stockTotal', 'todayInbound', 'todayPickBill', 'moCount', 'unlinkedBatch', 'pickFailCount'].forEach(function(key) {
  339. $('#' + key).text(summary[key] || 0);
  340. });
  341. renderTrend(data.days || [], data.trend || {});
  342. setPie('pickResultChart', '下推结果', data.pickResult);
  343. setPie('pickChannelChart', '领料渠道', data.pickChannel);
  344. setPie('stockMoStatusChart', '订单关联', data.stockMoStatus);
  345. setPie('pickMaterialMixChart', '物料占比', data.pickMaterialMix);
  346. var materialTop = splitData(data.stockByMaterial);
  347. setBar('pickMaterialTopChart', materialTop.names, materialTop.values);
  348. var moTop = splitData(data.stockByMo);
  349. setBar('moTopChart', moTop.names, moTop.values);
  350. setBar('materialTopChart', materialTop.names, materialTop.values);
  351. renderStock(data.stockList || []);
  352. renderActions(data.latestActions || []);
  353. renderUnlinked(data.unlinkedList || []);
  354. }
  355. function renderTrend(days, trend) {
  356. charts.trendChart.setOption({
  357. color: ['#3de7ff', '#ffcf5a', '#66ffb4', '#ff6f6f'],
  358. tooltip: { trigger: 'axis' },
  359. legend: { top: 10, right: 14, textStyle: textStyle(12), data: ['领料入库', '线边出库', '领料单', '生产订单'] },
  360. grid: { left: 48, right: 22, top: 48, bottom: 34 },
  361. xAxis: { type: 'category', data: days, axisLabel: textStyle(12), axisLine: { lineStyle: { color: '#286982' } } },
  362. yAxis: { type: 'value', axisLabel: textStyle(12), splitLine: { lineStyle: { color: 'rgba(95,196,230,.12)' } } },
  363. series: [
  364. { name: '领料入库', type: 'bar', barWidth: 12, data: trend.inbound || [] },
  365. { name: '线边出库', type: 'bar', barWidth: 12, data: trend.outbound || [] },
  366. { name: '领料单', type: 'line', smooth: true, data: trend.pickBill || [] },
  367. { name: '生产订单', type: 'line', smooth: true, data: trend.moBill || [] }
  368. ]
  369. });
  370. }
  371. function setPie(id, title, data) {
  372. charts[id].setOption({
  373. color: colors,
  374. tooltip: { trigger: 'item' },
  375. title: { text: title, left: 'center', top: 'center', textStyle: { color: '#e9fbff', fontSize: 13, fontWeight: 400 } },
  376. series: [{
  377. type: 'pie',
  378. radius: ['48%', '70%'],
  379. center: ['50%', '50%'],
  380. label: { color: '#cceff8', formatter: '{b}\n{c}', fontSize: 11 },
  381. labelLine: { lineStyle: { color: 'rgba(180,235,255,.45)' } },
  382. data: data || []
  383. }]
  384. });
  385. }
  386. function setBar(id, names, values) {
  387. charts[id].setOption({
  388. color: ['#39e7ff'],
  389. grid: { left: 92, right: 22, top: 24, bottom: 28 },
  390. tooltip: { trigger: 'axis' },
  391. xAxis: { type: 'value', axisLabel: textStyle(11), splitLine: { lineStyle: { color: 'rgba(95,196,230,.12)' } } },
  392. yAxis: { type: 'category', data: names, axisLabel: textStyle(11), axisLine: { lineStyle: { color: '#286982' } } },
  393. series: [{ type: 'bar', data: values, barWidth: 12, itemStyle: { borderRadius: [0, 8, 8, 0] } }]
  394. });
  395. }
  396. function splitData(list) {
  397. var names = [], values = [];
  398. (list || []).forEach(function(item) {
  399. names.push(item.name);
  400. values.push(item.value);
  401. });
  402. return { names: names, values: values };
  403. }
  404. function renderStock(list) {
  405. renderRows('stockList', list, function(item) {
  406. return '<div class="table-row">'
  407. + cell(item.material) + cell(item.erpSn) + cell(item.batchSn) + cell(item.moBillNo) + cell(item.nums) + cell(item.pickBillNo)
  408. + '</div>';
  409. }, '暂无ERP领料线边库存');
  410. }
  411. function renderActions(list) {
  412. renderRows('actionList', list, function(item) {
  413. return '<div class="table-row">'
  414. + cell(item.type) + cell(item.material) + cell(item.batch) + '<div class="cell"><span class="tag">' + escapeHtml(item.state) + '</span></div>' + cell(item.nums) + cell(item.time)
  415. + '</div>';
  416. }, '最近7天暂无领料动态');
  417. }
  418. function renderUnlinked(list) {
  419. renderRows('unlinkedList', list, function(item) {
  420. return '<div class="table-row">'
  421. + cell(item.material) + cell(item.batchSn) + cell(item.pickBillNo) + cell(item.nums) + cell(item.inboundTime)
  422. + '</div>';
  423. }, '暂无未关联订单库存');
  424. }
  425. function renderRows(id, list, renderer, emptyText) {
  426. var html = '';
  427. (list || []).forEach(function(item) { html += renderer(item); });
  428. $('#' + id).html(html || '<div class="empty">' + emptyText + '</div>');
  429. startAutoScroll(id, 80);
  430. }
  431. function cell(value) {
  432. return '<div class="cell" title="' + escapeHtml(value) + '">' + escapeHtml(value) + '</div>';
  433. }
  434. function startAutoScroll(id, speed) {
  435. var box = document.getElementById(id);
  436. if (scrollTimers[id]) {
  437. clearInterval(scrollTimers[id]);
  438. scrollTimers[id] = null;
  439. }
  440. if (!box || box.scrollHeight <= box.clientHeight) {
  441. if (box) { box.scrollTop = 0; }
  442. return;
  443. }
  444. scrollTimers[id] = setInterval(function() {
  445. if (scrollPaused[id]) { return; }
  446. if (box.scrollTop + box.clientHeight >= box.scrollHeight - 2) {
  447. box.scrollTop = 0;
  448. } else {
  449. box.scrollTop += 1;
  450. }
  451. }, speed);
  452. }
  453. function escapeHtml(text) {
  454. return String(text == null ? '' : text).replace(/[&<>"']/g, function(ch) {
  455. return ({ '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' })[ch];
  456. });
  457. }
  458. function loadData() {
  459. $.post('${ctx}/mes/mesMaterial/materialScreenData', function(ret) {
  460. if (ret && ret.result === 'true') {
  461. render(ret.data || {});
  462. }
  463. });
  464. }
  465. function updateTime() {
  466. var d = new Date();
  467. var pad = function(n) { return n < 10 ? '0' + n : n; };
  468. $('#timeText').text(d.getFullYear() + '-' + pad(d.getMonth() + 1) + '-' + pad(d.getDate()) + ' ' + pad(d.getHours()) + ':' + pad(d.getMinutes()) + ':' + pad(d.getSeconds()));
  469. }
  470. $(function() {
  471. fitScreen();
  472. initCharts();
  473. updateTime();
  474. loadData();
  475. setInterval(updateTime, 1000);
  476. setInterval(loadData, 60000);
  477. $('#stockList, #actionList, #unlinkedList').on('mouseenter', function() { scrollPaused[this.id] = true; });
  478. $('#stockList, #actionList, #unlinkedList').on('mouseleave', function() { scrollPaused[this.id] = false; });
  479. $(window).on('resize', function() {
  480. fitScreen();
  481. Object.keys(charts).forEach(function(key) { charts[key].resize(); });
  482. ['stockList', 'actionList', 'unlinkedList'].forEach(function(id) { startAutoScroll(id, 80); });
  483. });
  484. });
  485. function fitScreen() {
  486. var scaleX = window.innerWidth / 1920;
  487. var scaleY = window.innerHeight / 1080;
  488. $('#screen').css({
  489. transform: 'scale(' + scaleX + ',' + scaleY + ')',
  490. transformOrigin: 'left top'
  491. });
  492. }
  493. </script>
  494. </body>
  495. </html>