mouldBoard.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=1920">
  6. <!-- <meta
  7. name="viewport"
  8. content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=no, target-densitydpi=device-dpi"
  9. /> -->
  10. <title>index</title>
  11. <script type="text/javascript" src="../plugin/jquery.min.js"></script>
  12. <script type="text/javascript" src="../plugin/echarts.min.js"></script>
  13. <script type="text/javascript" src="../js/chart.js"></script>
  14. <script type="text/javascript" src="../plugin/vue.js"></script>
  15. <script type="text/javascript" src="../js/util.js"></script>
  16. <script type="text/javascript" src="../js/common.js"></script>
  17. <link rel="stylesheet" href="../css/common.css" />
  18. <link rel="stylesheet" href="../css/mould.css" />
  19. </head>
  20. <script>
  21. $(window).load(function () {
  22. $(".loading").fadeOut();
  23. });
  24. //动态设置视口
  25. const setSize = () => {
  26. // 获取html元素
  27. const html = document.getElementsByTagName("html")[0];
  28. // 获取屏幕宽度
  29. const pageWidth = html.getBoundingClientRect().width;
  30. // 动态计算字体大小(rem)
  31. html.style.fontSize = pageWidth / 20 + "px";
  32. };
  33. setSize();
  34. window.addEventListener("resize", setSize, false);
  35. </script>
  36. <body>
  37. <div class="loading">
  38. <div class="load_box">
  39. <img src="../images/loading.gif" /> 看板加载中,请稍等...
  40. </div>
  41. </div>
  42. <div id="app" class="container">
  43. <div class="head">
  44. <h1>模检具看板</h1>
  45. <span id="showTime"></span>
  46. </div>
  47. <ul class="clearfix">
  48. <li>
  49. <div class="box">
  50. <span class="count mo_total">模具总数</span>
  51. <div class="count_box total1">{{count.moldAllQuantity}}</div>
  52. <span class="count mo_store">模具在库数量</span>
  53. <div class="count_box store1">
  54. {{count.moldInWarehouseQuantity}}
  55. </div>
  56. <span class="count mo_line">模具产线数量</span>
  57. <div class="count_box line1">{{count.moldProduceQuantity}}</div>
  58. <span class="count gauge_total">检具总数</span>
  59. <div class="count_box total2">{{count.fixtureAllQuantity}}</div>
  60. <span class="count gauge_store">检具在库数量</span>
  61. <div class="count_box store2">
  62. {{count.fixtureInWarehouseQuantity}}
  63. </div>
  64. <span class="count gauge_line">检具产线数量</span>
  65. <div class="count_box line2">{{count.fixtureProduceQuantity}}</div>
  66. </div>
  67. <div class="box">
  68. <div
  69. class="chart"
  70. style="height: 5.4rem; margin-top: 0.5rem; left: 0.1rem"
  71. id="dieCountChart"
  72. ></div>
  73. </div>
  74. </li>
  75. <li>
  76. <div class="box">
  77. <div
  78. class="chart center"
  79. style="height: 8rem; top: -2.96rem; left: 1.26rem"
  80. id="workShopChart"
  81. ></div>
  82. </div>
  83. <div class="box">
  84. <div class="title malfunction center">模检具故障趋势图</div>
  85. <div
  86. class="chart center"
  87. style="height: 1rem; margin-top: 1.24rem; left: 0.6rem"
  88. id="malfunctionNumber"
  89. ></div>
  90. <div
  91. class="chart center"
  92. style="margin-top: 2rem; height: 3.4rem"
  93. id="malfunctionChart"
  94. ></div>
  95. </div>
  96. </li>
  97. <li>
  98. <div class="box">
  99. <div class="title aging center">模具维修时效</div>
  100. <div
  101. class="chart center"
  102. style="height: 4rem; margin-top: 0.6rem; left: -1.2rem"
  103. id="maintainChart"
  104. ></div>
  105. </div>
  106. <div class="box">
  107. <div class="title outIn center">近七天模检具出入库情况</div>
  108. <div
  109. class="chart center"
  110. style="height: 4rem; margin-top: 1rem; left: -1rem"
  111. id="outInChart"
  112. ></div>
  113. </div>
  114. </li>
  115. </ul>
  116. </div>
  117. <div class="back"></div>
  118. <script>
  119. var app = new Vue({
  120. el: "#app",
  121. data() {
  122. return {
  123. count: {
  124. moldAllQuantity: "",
  125. moldInWarehouseQuantity: "",
  126. moldProduceQuantity: "",
  127. fixtureAllQuantity: "",
  128. fixtureInWarehouseQuantity: "",
  129. fixtureProduceQuantity: "",
  130. },
  131. workShopChart: null,
  132. malfunctionChart: null,
  133. malfunctionNumber: null,
  134. dieCountChart: null,
  135. maintainChart: null,
  136. outInChart: null,
  137. warehouse: null,
  138. workShopDatas: null,
  139. warehouseId: null,
  140. warehouseName: "",
  141. };
  142. },
  143. methods: {
  144. // 创建并渲染中间车间环图
  145. createWorkShopChart() {
  146. const _self = this;
  147. const workShopOption = drawWorkShopChart(_self.workShopDatas);
  148. initChart(_self.workShopChart, workShopOption);
  149. _self.getBoardInfo();
  150. },
  151. // 创建并渲染左下角模检具数量图
  152. createCountChart() {
  153. const _self = this;
  154. const data = [];
  155. const countOption = drawCountChart(_self.dieCountChart, data);
  156. initChart(_self.dieCountChart, countOption);
  157. },
  158. // 更新左下角数据
  159. updateCountChart(newData) {
  160. newData.forEach((item) => {
  161. item.value = item.quantity;
  162. });
  163. let value = newData.reduce((a, b) => a + b.quantity, 0);
  164. this.dieCountChart.setOption({
  165. title: [{ text: "{a|" + "总数" + "\n " + value + "}{c|}" }],
  166. series: [{ type: "pie", name: "模检具数量", data: newData }],
  167. });
  168. },
  169. // 创建并渲染中间模检具故障数量图
  170. createMalfunctionNumberChart() {
  171. const _self = this;
  172. const malfunctionNumberOption = drawMalfunctionNumber();
  173. initChart(_self.malfunctionNumber, malfunctionNumberOption);
  174. },
  175. // 更新故障数量图数据
  176. updateNumberChart(newData) {
  177. let number = [];
  178. newData.forEach((item) => {
  179. item.value = item.quantity;
  180. number.push({ name: item.name, value: `${item.value}个` });
  181. });
  182. this.malfunctionNumber.setOption({
  183. series: [{ name: "故障数量", type: "bar", data: newData }],
  184. yAxis: [{ name: "right", data: number }],
  185. });
  186. },
  187. // 创建并渲染中间模检具故障趋势曲线图
  188. createMalfunctionChart() {
  189. const _self = this;
  190. const malfunctionOption = drawMalfunctionChart();
  191. initChart(_self.malfunctionChart, malfunctionOption);
  192. },
  193. // 更新检具故障趋势曲线图数据
  194. updateMalfunctionChart(newData) {
  195. this.malfunctionChart.setOption({
  196. xAxis: [{ name: "月份", data: newData.name }],
  197. series: [
  198. {
  199. name: "模具故障趋势",
  200. type: "line",
  201. data: newData.moldQuantity,
  202. },
  203. {
  204. name: "检具故障趋势",
  205. type: "line",
  206. data: newData.fixtureQuantity,
  207. },
  208. ],
  209. });
  210. },
  211. // 创建并渲染右上角模具维修时效图
  212. createMaintainChart() {
  213. const _self = this;
  214. const maintainOption = drawMaintainChart();
  215. initChart(_self.maintainChart, maintainOption);
  216. },
  217. // 更新维修时效图数据
  218. updateMaintainChart(newData) {
  219. const yData = [];
  220. newData.forEach((item) => {
  221. yData.push(item.quantity);
  222. });
  223. let value = newData.reduce((a, b) => a + b.quantity, 0);
  224. this.maintainChart.setOption({
  225. series: [
  226. { type: "custom", name: "时效", data: yData },
  227. {
  228. type: "bar",
  229. name: "比例",
  230. data: yData,
  231. label: {
  232. normal: {
  233. formatter: (e) => {
  234. if (value == 0) {
  235. value = 1;
  236. }
  237. return (e.value / value) * 100 + "%";
  238. },
  239. },
  240. },
  241. },
  242. ],
  243. });
  244. },
  245. // 创建并渲染右下角模近七天出入库图
  246. createOutInChart() {
  247. const _self = this;
  248. const outInOption = drawOutInChart();
  249. initChart(_self.outInChart, outInOption);
  250. },
  251. // 更新近七天出入库数据
  252. updateOutInChart(newData) {
  253. const xData = [];
  254. newData.forEach((item) => {
  255. if (item.name === "模具入库总数") {
  256. xData[0] = item.quantity;
  257. } else if (item.name === "模具出库总数") {
  258. xData[1] = item.quantity;
  259. } else if (item.name === "检具入库总数") {
  260. xData[2] = item.quantity;
  261. } else if (item.name === "检具出库总数") {
  262. xData[3] = item.quantity;
  263. }
  264. });
  265. this.outInChart.setOption({
  266. series: [{ name: "数量", type: "bar", data: xData }],
  267. });
  268. },
  269. // 屏幕自适应
  270. resizeChart() {
  271. const _self = this;
  272. _self.outInChart && _self.outInChart.resize();
  273. _self.workShopChart && _self.workShopChart.resize();
  274. _self.maintainChart && _self.maintainChart.resize();
  275. _self.dieCountChart && _self.dieCountChart.resize();
  276. _self.malfunctionChart && _self.malfunctionChart.resize();
  277. _self.malfunctionNumber && _self.malfunctionNumber.resize();
  278. },
  279. cancalDebounce: debounce(function () {
  280. this.resizeChart();
  281. }, 200),
  282. // 获取当前展示的仓库id
  283. getWarehouseId() {
  284. const _self = this;
  285. // 看板盒子从url获取
  286. // const params = getQueryString();
  287. // _self.warehouseId = params.warehouseId;
  288. // apk 安装包写死(需要多个页面)
  289. _self.warehouseId = 460335910907969;
  290. },
  291. // 获取所有车间信息
  292. getAllWarehouse() {
  293. const _self = this;
  294. const url = "/api/WarehouseResource/queryAllWarehouse";
  295. ajaxGet(url).then((success) => {
  296. if (success.errorCode === 0) {
  297. if (success.datas) {
  298. success.datas.forEach((item) => {
  299. if (item.id == _self.warehouseId) {
  300. item.selected = true;
  301. _self.warehouseName = item.name;
  302. }
  303. });
  304. _self.workShopDatas = success.datas;
  305. }
  306. _self.createWorkShopChart();
  307. } else {
  308. console.log(success.errorMessage);
  309. }
  310. });
  311. },
  312. // 获取看板信息
  313. getBoardInfo() {
  314. const _self = this;
  315. const url = "/api/BulletinBoardResource/queryBoardByWarehouse";
  316. const params = [["warehouseId", _self.warehouseId]];
  317. ajaxGet(url, params).then((success) => {
  318. if (success.errorCode === 0) {
  319. if (success.data) {
  320. const { boardInventoryQuantityDto } = success.data; // 左上角模检具数量
  321. const { boardInventoryPieDtos: count } = success.data; // 左下角饼图
  322. const { boardRepairInThirtyDaysDtos: number } = success.data; // 中间故障数量
  323. const { boardInventoryRepairDto: fault } = success.data; // 中间故障折线图
  324. const { boardMoldRepairDurationDtos: timer } = success.data; // 右上角时效图
  325. const { boardInventoryStockInOrOutDtos: inOut } =
  326. success.data; // 右下角出入库
  327. // 更新左上角
  328. if (boardInventoryQuantityDto) {
  329. _self.count = boardInventoryQuantityDto;
  330. }
  331. // 更新左下角
  332. if (count && count.length > 0) {
  333. _self.updateCountChart(count);
  334. }
  335. // 更新中间故障数量
  336. if (number && number.length > 0) {
  337. _self.updateNumberChart(number);
  338. }
  339. // 更新中间故障曲线
  340. _self.updateMalfunctionChart(fault);
  341. // 更新右上角
  342. if (timer && timer.length > 0) {
  343. _self.updateMaintainChart(timer);
  344. }
  345. // 更新右下角
  346. if (inOut && inOut.length > 0) {
  347. _self.updateOutInChart(inOut);
  348. }
  349. }
  350. } else {
  351. console.log(success.errorMessage);
  352. }
  353. });
  354. },
  355. // 销毁图表
  356. disposeChart(chart) {
  357. chart && chart.dispose();
  358. },
  359. },
  360. mounted() {
  361. const _self = this;
  362. _self.outInChart = getElement("outInChart");
  363. _self.workShopChart = getElement("workShopChart");
  364. _self.dieCountChart = getElement("dieCountChart");
  365. _self.maintainChart = getElement("maintainChart");
  366. _self.malfunctionChart = getElement("malfunctionChart");
  367. _self.malfunctionNumber = getElement("malfunctionNumber");
  368. _self.getWarehouseId();
  369. _self.getAllWarehouse();
  370. _self.$nextTick(() => {
  371. _self.createCountChart();
  372. _self.createOutInChart();
  373. _self.createMaintainChart();
  374. _self.createMalfunctionChart();
  375. _self.createMalfunctionNumberChart();
  376. window.addEventListener("resize", _self.cancalDebounce);
  377. window.addEventListener("onmessageChange", _self.getWarehouseId);
  378. });
  379. _self.timer = setInterval(() => {
  380. _self.getBoardInfo();
  381. }, 6000 * 10);
  382. },
  383. beforeUnmount() {
  384. const _self = this;
  385. clearInterval(_self.timer);
  386. _self.timer = null;
  387. _self.disposeChart(_self.outInChart);
  388. _self.disposeChart(_self.workShopChart);
  389. _self.disposeChart(_self.maintainChart);
  390. _self.disposeChart(_self.dieCountChart);
  391. _self.disposeChart(_self.malfunctionChart);
  392. _self.disposeChart(_self.malfunctionNumber);
  393. window.removeEventListener("resize", _self.cancalDebounce);
  394. window.removeEventListener("onmessageChange", _self.getWarehouseId);
  395. },
  396. });
  397. </script>
  398. </body>
  399. </html>