mouldBoard.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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: 6rem; margin-top: -0.4rem; 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: 0.7rem; left: 0.6rem"
  87. id="malfunctionNumber"
  88. ></div>
  89. <div class="chart center" id="malfunctionChart"></div>
  90. </div>
  91. </li>
  92. <li>
  93. <div class="box">
  94. <div class="title aging center">模具维修时效</div>
  95. <div
  96. class="chart center"
  97. style="height: 4rem; margin-top: 0.6rem; left: -1.2rem"
  98. id="maintainChart"
  99. ></div>
  100. </div>
  101. <div class="box">
  102. <div class="title outIn center">近七天模检具出入库情况</div>
  103. <div
  104. class="chart center"
  105. style="height: 4rem; margin-top: 0.4rem; left: -1rem"
  106. id="outInChart"
  107. ></div>
  108. </div>
  109. </li>
  110. </ul>
  111. </div>
  112. <div class="back"></div>
  113. <script>
  114. var app = new Vue({
  115. el: "#app",
  116. data() {
  117. return {
  118. count: {
  119. moldAllQuantity: "",
  120. moldInWarehouseQuantity: "",
  121. moldProduceQuantity: "",
  122. fixtureAllQuantity: "",
  123. fixtureInWarehouseQuantity: "",
  124. fixtureProduceQuantity: "",
  125. },
  126. workShopChart: null,
  127. malfunctionChart: null,
  128. malfunctionNumber: null,
  129. dieCountChart: null,
  130. maintainChart: null,
  131. outInChart: null,
  132. warehouse: null,
  133. workShopDatas: null,
  134. warehouseId: null,
  135. };
  136. },
  137. methods: {
  138. // 创建并渲染中间车间环图
  139. createWorkShopChart() {
  140. const _self = this;
  141. const workShopOption = drawWorkShopChart(
  142. _self.workShopChart,
  143. _self.workShopDatas
  144. );
  145. initChart(_self.workShopChart, workShopOption);
  146. },
  147. // 创建并渲染左下角模检具数量图
  148. createCountChart() {
  149. const _self = this;
  150. const data = [];
  151. const countOption = drawCountChart(_self.dieCountChart, data);
  152. initChart(_self.dieCountChart, countOption);
  153. },
  154. // 更新左下角数据
  155. updateCountChart(newData) {
  156. newData.forEach((item) => {
  157. item.value = item.quantity;
  158. });
  159. let value = newData.reduce((a, b) => a + b.quantity, 0);
  160. this.dieCountChart.setOption({
  161. title: [{ text: "{a|" + "总数" + "\n " + value + "}{c|}" }],
  162. series: [{ type: "pie", name: "模检具数量", data: newData }],
  163. });
  164. },
  165. // 创建并渲染中间模检具故障数量图
  166. createMalfunctionNumberChart() {
  167. const _self = this;
  168. const malfunctionNumberOption = drawMalfunctionNumber();
  169. initChart(_self.malfunctionNumber, malfunctionNumberOption);
  170. },
  171. // 更新故障数量图数据
  172. updateNumberChart(newData) {
  173. let number = [];
  174. newData.forEach((item) => {
  175. item.value = item.quantity;
  176. number.push({ name: item.name, value: `${item.value}个` });
  177. });
  178. this.malfunctionNumber.setOption({
  179. series: [{ name: "故障数量", type: "bar", data: newData }],
  180. yAxis: [{ name: "right", data: number }],
  181. });
  182. },
  183. // 创建并渲染中间模检具故障趋势曲线图
  184. createMalfunctionChart() {
  185. const _self = this;
  186. const malfunctionOption = drawMalfunctionChart();
  187. initChart(_self.malfunctionChart, malfunctionOption);
  188. },
  189. // 更新检具故障趋势曲线图数据
  190. updateMalfunctionChart(newData) {
  191. this.malfunctionChart.setOption({
  192. xAxis: [{ name: "月份", data: newData.name }],
  193. series: [
  194. {
  195. name: "模具故障趋势",
  196. type: "line",
  197. data: newData.moldQuantity,
  198. },
  199. {
  200. name: "检具故障趋势",
  201. type: "line",
  202. data: newData.fixtureQuantity,
  203. },
  204. ],
  205. });
  206. },
  207. // 创建并渲染右上角模具维修时效图
  208. createMaintainChart() {
  209. const _self = this;
  210. const maintainOption = drawMaintainChart();
  211. initChart(_self.maintainChart, maintainOption);
  212. },
  213. // 更新维修时效图数据
  214. updateMaintainChart(newData) {
  215. const yData = [];
  216. newData.forEach((item) => {
  217. yData.push(item.quantity);
  218. });
  219. this.maintainChart.setOption({
  220. series: [
  221. { type: "custom", name: "时效", data: yData },
  222. { type: "bar", name: "比例", data: yData },
  223. ],
  224. });
  225. },
  226. // 创建并渲染右下角模近七天出入库图
  227. createOutInChart() {
  228. const _self = this;
  229. const outInOption = drawOutInChart();
  230. initChart(_self.outInChart, outInOption);
  231. },
  232. // 更新近七天出入库数据
  233. updateOutInChart(newData) {
  234. const xData = [];
  235. newData.forEach((item) => {
  236. if (item.name === "模具入库总数") {
  237. xData[0] = item.quantity;
  238. } else if (item.name === "模具出库总数") {
  239. xData[1] = item.quantity;
  240. } else if (item.name === "检具入库总数") {
  241. xData[2] = item.quantity;
  242. } else if (item.name === "检具出库总数") {
  243. xData[3] = item.quantity;
  244. }
  245. });
  246. this.outInChart.setOption({
  247. series: [{ name: "数量", type: "bar", data: xData }],
  248. });
  249. },
  250. // 屏幕自适应
  251. resizeChart() {
  252. const _self = this;
  253. _self.outInChart && _self.outInChart.resize();
  254. _self.workShopChart && _self.workShopChart.resize();
  255. _self.maintainChart && _self.maintainChart.resize();
  256. _self.dieCountChart && _self.dieCountChart.resize();
  257. _self.malfunctionChart && _self.malfunctionChart.resize();
  258. _self.malfunctionNumber && _self.malfunctionNumber.resize();
  259. },
  260. cancalDebounce: debounce(function () {
  261. this.resizeChart();
  262. }, 200),
  263. // 获取当前展示的仓库id
  264. getWarehouseId({ detail }) {
  265. const _self = this;
  266. _self.warehouseId = detail.warehouseId;
  267. },
  268. // 获取所有车间信息
  269. getAllWarehouse() {
  270. const _self = this;
  271. const url = "/api/WarehouseResource/queryAllWarehouse";
  272. ajaxGet(url).then((success) => {
  273. if (success.errorCode === 0) {
  274. _self.workShopDatas = success.datas;
  275. _self.createWorkShopChart();
  276. } else {
  277. console.log(success.errorMessage);
  278. }
  279. });
  280. },
  281. // 获取看板信息
  282. getBoardInfo(warehouseId) {
  283. const _self = this;
  284. const url = "/api/BulletinBoardResource/queryBoardByWarehouse";
  285. const params = [["warehouseId", warehouseId]];
  286. ajaxGet(url, params).then((success) => {
  287. if (success.errorCode === 0) {
  288. if (success.data) {
  289. const { boardInventoryQuantityDto } = success.data; // 左上角模检具数量
  290. const { boardInventoryPieDtos: count } = success.data; // 左下角饼图
  291. const { boardRepairInThirtyDaysDtos: number } = success.data; // 中间故障数量
  292. const { boardInventoryRepairDto: fault } = success.data; // 中间故障折线图
  293. const { boardMoldRepairDurationDtos: timer } = success.data; // 右上角时效图
  294. const { boardInventoryStockInOrOutDtos: inOut } =
  295. success.data; // 右下角出入库
  296. // 更新左上角
  297. _self.count = boardInventoryQuantityDto;
  298. // 更新左下角
  299. if (count && count.length > 0) {
  300. _self.updateCountChart(count);
  301. }
  302. // 更新中间故障数量
  303. if (number && number.length > 0) {
  304. _self.updateNumberChart(number);
  305. }
  306. // 更新中间故障曲线
  307. _self.updateMalfunctionChart(fault);
  308. // 更新右上角
  309. if (timer && timer.length > 0) {
  310. _self.updateMaintainChart(timer);
  311. }
  312. // 更新右下角
  313. if (inOut && inOut.length > 0) {
  314. _self.updateOutInChart(inOut);
  315. }
  316. }
  317. } else {
  318. console.log(success.errorMessage);
  319. }
  320. });
  321. },
  322. // 销毁图表
  323. disposeChart(chart) {
  324. chart && chart.dispose();
  325. },
  326. },
  327. watch: {
  328. warehouseId(newVal, oldValue) {
  329. var _self = this;
  330. if (newVal !== oldValue) {
  331. _self.getBoardInfo(newVal);
  332. }
  333. },
  334. },
  335. mounted() {
  336. const _self = this;
  337. _self.outInChart = getElement("outInChart");
  338. _self.workShopChart = getElement("workShopChart");
  339. _self.dieCountChart = getElement("dieCountChart");
  340. _self.maintainChart = getElement("maintainChart");
  341. _self.malfunctionChart = getElement("malfunctionChart");
  342. _self.malfunctionNumber = getElement("malfunctionNumber");
  343. _self.getAllWarehouse();
  344. _self.$nextTick(() => {
  345. _self.createCountChart();
  346. _self.createOutInChart();
  347. _self.createMaintainChart();
  348. _self.createMalfunctionChart();
  349. _self.createMalfunctionNumberChart();
  350. window.addEventListener("resize", _self.cancalDebounce);
  351. window.addEventListener("onmessageChange", _self.getWarehouseId);
  352. });
  353. },
  354. beforeUnmount() {
  355. const _self = this;
  356. window.clearInterval(window.timeTicket);
  357. _self.disposeChart(_self.outInChart);
  358. _self.disposeChart(_self.workShopChart);
  359. _self.disposeChart(_self.maintainChart);
  360. _self.disposeChart(_self.dieCountChart);
  361. _self.disposeChart(_self.malfunctionChart);
  362. _self.disposeChart(_self.malfunctionNumber);
  363. window.removeEventListener("resize", _self.cancalDebounce);
  364. window.removeEventListener("onmessageChange", _self.getWarehouseId);
  365. },
  366. });
  367. </script>
  368. </body>
  369. </html>