mouldBoard.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta
  6. name="viewport"
  7. content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"
  8. />
  9. <title>index</title>
  10. <script type="text/javascript" src="../plugin/jquery.min.js"></script>
  11. <script type="text/javascript" src="../plugin/echarts.min.js"></script>
  12. <script type="text/javascript" src="../js/chart.js"></script>
  13. <script type="text/javascript" src="../plugin/vue.js"></script>
  14. <script type="text/javascript" src="../js/util.js"></script>
  15. <script type="text/javascript" src="../js/common.js"></script>
  16. <link rel="stylesheet" href="../css/common.css" />
  17. <link rel="stylesheet" href="../css/mould.css" />
  18. </head>
  19. <script>
  20. $(window).load(function () {
  21. $(".loading").fadeOut();
  22. });
  23. //动态设置视口
  24. const setSize = () => {
  25. // 获取html元素
  26. const html = document.getElementsByTagName("html")[0];
  27. // 获取屏幕宽度
  28. const pageWidth = html.getBoundingClientRect().width;
  29. // 动态计算字体大小(rem)
  30. html.style.fontSize = pageWidth / 20 + "px";
  31. };
  32. setSize();
  33. window.addEventListener("resize", setSize, false);
  34. </script>
  35. <body>
  36. <div class="loading">
  37. <div class="load_box">
  38. <img src="../images/loading.gif" /> 看板加载中,请稍等...
  39. </div>
  40. </div>
  41. <div id="app" class="container">
  42. <div class="head">
  43. <h1>模检具看板</h1>
  44. <span id="showTime"></span>
  45. </div>
  46. <ul class="clearfix">
  47. <li>
  48. <div class="box">
  49. <span class="count mo_total">模具总数</span>
  50. <div class="count_box total1">{{count.moldAllQuantity}}</div>
  51. <span class="count mo_store">模具在库数量</span>
  52. <div class="count_box store1">
  53. {{count.moldInWarehouseQuantity}}
  54. </div>
  55. <span class="count mo_line">模具产线数量</span>
  56. <div class="count_box line1">{{count.moldProduceQuantity}}</div>
  57. <span class="count gauge_total">检具总数</span>
  58. <div class="count_box total2">{{count.fixtureAllQuantity}}</div>
  59. <span class="count gauge_store">检具在库数量</span>
  60. <div class="count_box store2">
  61. {{count.fixtureInWarehouseQuantity}}
  62. </div>
  63. <span class="count gauge_line">检具产线数量</span>
  64. <div class="count_box line2">{{count.fixtureProduceQuantity}}</div>
  65. </div>
  66. <div class="box">
  67. <div
  68. class="chart"
  69. style="height: 5.4rem; margin-top: 0.5rem; left: 0.1rem"
  70. id="dieCountChart"
  71. ></div>
  72. </div>
  73. </li>
  74. <li>
  75. <div class="box">
  76. <div
  77. class="chart center"
  78. style="height: 8rem; top: -2.96rem; left: 1.26rem"
  79. id="workShopChart"
  80. ></div>
  81. </div>
  82. <div class="box">
  83. <div class="title malfunction center">模检具故障趋势图</div>
  84. <div
  85. class="chart center"
  86. style="height: 1rem; margin-top: 1.24rem; left: 0.6rem"
  87. id="malfunctionNumber"
  88. ></div>
  89. <div
  90. class="chart center"
  91. style="margin-top: 2rem; height: 3.4rem"
  92. id="malfunctionChart"
  93. ></div>
  94. </div>
  95. </li>
  96. <li>
  97. <div class="box">
  98. <div class="title aging center">模具维修时效</div>
  99. <div
  100. class="chart center"
  101. style="height: 4rem; margin-top: 0.6rem; left: -1.2rem"
  102. id="maintainChart"
  103. ></div>
  104. </div>
  105. <div class="box">
  106. <div class="title outIn center">近七天模检具出入库情况</div>
  107. <div
  108. class="chart center"
  109. style="height: 4rem; margin-top: 1rem; left: -1rem"
  110. id="outInChart"
  111. ></div>
  112. </div>
  113. </li>
  114. </ul>
  115. </div>
  116. <div class="back"></div>
  117. <script>
  118. var app = new Vue({
  119. el: "#app",
  120. data() {
  121. return {
  122. count: {
  123. moldAllQuantity: "",
  124. moldInWarehouseQuantity: "",
  125. moldProduceQuantity: "",
  126. fixtureAllQuantity: "",
  127. fixtureInWarehouseQuantity: "",
  128. fixtureProduceQuantity: "",
  129. },
  130. workShopChart: null,
  131. malfunctionChart: null,
  132. malfunctionNumber: null,
  133. dieCountChart: null,
  134. maintainChart: null,
  135. outInChart: null,
  136. warehouse: null,
  137. workShopDatas: null,
  138. warehouseId: null,
  139. };
  140. },
  141. methods: {
  142. // 创建并渲染中间车间环图
  143. createWorkShopChart() {
  144. const _self = this;
  145. const workShopOption = drawWorkShopChart(
  146. _self.workShopChart,
  147. _self.workShopDatas
  148. );
  149. initChart(_self.workShopChart, workShopOption);
  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. this.maintainChart.setOption({
  224. series: [
  225. { type: "custom", name: "时效", data: yData },
  226. { type: "bar", name: "比例", data: yData },
  227. ],
  228. });
  229. },
  230. // 创建并渲染右下角模近七天出入库图
  231. createOutInChart() {
  232. const _self = this;
  233. const outInOption = drawOutInChart();
  234. initChart(_self.outInChart, outInOption);
  235. },
  236. // 更新近七天出入库数据
  237. updateOutInChart(newData) {
  238. const xData = [];
  239. newData.forEach((item) => {
  240. if (item.name === "模具入库总数") {
  241. xData[0] = item.quantity;
  242. } else if (item.name === "模具出库总数") {
  243. xData[1] = item.quantity;
  244. } else if (item.name === "检具入库总数") {
  245. xData[2] = item.quantity;
  246. } else if (item.name === "检具出库总数") {
  247. xData[3] = item.quantity;
  248. }
  249. });
  250. this.outInChart.setOption({
  251. series: [{ name: "数量", type: "bar", data: xData }],
  252. });
  253. },
  254. // 屏幕自适应
  255. resizeChart() {
  256. const _self = this;
  257. _self.outInChart && _self.outInChart.resize();
  258. _self.workShopChart && _self.workShopChart.resize();
  259. _self.maintainChart && _self.maintainChart.resize();
  260. _self.dieCountChart && _self.dieCountChart.resize();
  261. _self.malfunctionChart && _self.malfunctionChart.resize();
  262. _self.malfunctionNumber && _self.malfunctionNumber.resize();
  263. },
  264. cancalDebounce: debounce(function () {
  265. this.resizeChart();
  266. }, 200),
  267. // 获取当前展示的仓库id
  268. getWarehouseId({ detail }) {
  269. const _self = this;
  270. _self.warehouseId = detail.warehouseId;
  271. },
  272. // 获取所有车间信息
  273. getAllWarehouse() {
  274. const _self = this;
  275. const url = "/api/WarehouseResource/queryAllWarehouse";
  276. ajaxGet(url).then((success) => {
  277. if (success.errorCode === 0) {
  278. _self.workShopDatas = success.datas;
  279. _self.createWorkShopChart();
  280. } else {
  281. console.log(success.errorMessage);
  282. }
  283. });
  284. },
  285. // 获取看板信息
  286. getBoardInfo(warehouseId) {
  287. const _self = this;
  288. const url = "/api/BulletinBoardResource/queryBoardByWarehouse";
  289. const params = [["warehouseId", warehouseId]];
  290. ajaxGet(url, params).then((success) => {
  291. if (success.errorCode === 0) {
  292. if (success.data) {
  293. const { boardInventoryQuantityDto } = success.data; // 左上角模检具数量
  294. const { boardInventoryPieDtos: count } = success.data; // 左下角饼图
  295. const { boardRepairInThirtyDaysDtos: number } = success.data; // 中间故障数量
  296. const { boardInventoryRepairDto: fault } = success.data; // 中间故障折线图
  297. const { boardMoldRepairDurationDtos: timer } = success.data; // 右上角时效图
  298. const { boardInventoryStockInOrOutDtos: inOut } =
  299. success.data; // 右下角出入库
  300. // 更新左上角
  301. _self.count = boardInventoryQuantityDto;
  302. // 更新左下角
  303. if (count && count.length > 0) {
  304. _self.updateCountChart(count);
  305. }
  306. // 更新中间故障数量
  307. if (number && number.length > 0) {
  308. _self.updateNumberChart(number);
  309. }
  310. // 更新中间故障曲线
  311. _self.updateMalfunctionChart(fault);
  312. // 更新右上角
  313. if (timer && timer.length > 0) {
  314. _self.updateMaintainChart(timer);
  315. }
  316. // 更新右下角
  317. if (inOut && inOut.length > 0) {
  318. _self.updateOutInChart(inOut);
  319. }
  320. }
  321. } else {
  322. console.log(success.errorMessage);
  323. }
  324. });
  325. },
  326. // 销毁图表
  327. disposeChart(chart) {
  328. chart && chart.dispose();
  329. },
  330. },
  331. watch: {
  332. warehouseId(newVal, oldValue) {
  333. var _self = this;
  334. if (newVal !== oldValue) {
  335. _self.getBoardInfo(newVal);
  336. }
  337. },
  338. },
  339. mounted() {
  340. const _self = this;
  341. _self.outInChart = getElement("outInChart");
  342. _self.workShopChart = getElement("workShopChart");
  343. _self.dieCountChart = getElement("dieCountChart");
  344. _self.maintainChart = getElement("maintainChart");
  345. _self.malfunctionChart = getElement("malfunctionChart");
  346. _self.malfunctionNumber = getElement("malfunctionNumber");
  347. _self.getAllWarehouse();
  348. _self.$nextTick(() => {
  349. _self.createCountChart();
  350. _self.createOutInChart();
  351. _self.createMaintainChart();
  352. _self.createMalfunctionChart();
  353. _self.createMalfunctionNumberChart();
  354. window.addEventListener("resize", _self.cancalDebounce);
  355. window.addEventListener("onmessageChange", _self.getWarehouseId);
  356. });
  357. },
  358. beforeUnmount() {
  359. const _self = this;
  360. window.clearInterval(window.timeTicket);
  361. window.timeTicket = null;
  362. _self.disposeChart(_self.outInChart);
  363. _self.disposeChart(_self.workShopChart);
  364. _self.disposeChart(_self.maintainChart);
  365. _self.disposeChart(_self.dieCountChart);
  366. _self.disposeChart(_self.malfunctionChart);
  367. _self.disposeChart(_self.malfunctionNumber);
  368. window.removeEventListener("resize", _self.cancalDebounce);
  369. window.removeEventListener("onmessageChange", _self.getWarehouseId);
  370. },
  371. });
  372. </script>
  373. </body>
  374. </html>