mouldBoard.html 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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. let value = newData.reduce((a, b) => a + b.quantity, 0);
  224. this.maintainChart.setOption({
  225. series: [
  226. { type: "custom", name: "时效", data: yData },
  227. { type: "bar", name: "比例", data: yData,
  228. label: {
  229. normal: {
  230. formatter: (e) => {
  231. if(value == 0){
  232. value = 1;
  233. }
  234. return e.value / value * 100 + '%';
  235. },
  236. }
  237. }},
  238. ],
  239. });
  240. },
  241. // 创建并渲染右下角模近七天出入库图
  242. createOutInChart() {
  243. const _self = this;
  244. const outInOption = drawOutInChart();
  245. initChart(_self.outInChart, outInOption);
  246. },
  247. // 更新近七天出入库数据
  248. updateOutInChart(newData) {
  249. const xData = [];
  250. newData.forEach((item) => {
  251. if (item.name === "模具入库总数") {
  252. xData[0] = item.quantity;
  253. } else if (item.name === "模具出库总数") {
  254. xData[1] = item.quantity;
  255. } else if (item.name === "检具入库总数") {
  256. xData[2] = item.quantity;
  257. } else if (item.name === "检具出库总数") {
  258. xData[3] = item.quantity;
  259. }
  260. });
  261. this.outInChart.setOption({
  262. series: [{ name: "数量", type: "bar", data: xData }],
  263. });
  264. },
  265. // 屏幕自适应
  266. resizeChart() {
  267. const _self = this;
  268. _self.outInChart && _self.outInChart.resize();
  269. _self.workShopChart && _self.workShopChart.resize();
  270. _self.maintainChart && _self.maintainChart.resize();
  271. _self.dieCountChart && _self.dieCountChart.resize();
  272. _self.malfunctionChart && _self.malfunctionChart.resize();
  273. _self.malfunctionNumber && _self.malfunctionNumber.resize();
  274. },
  275. cancalDebounce: debounce(function () {
  276. this.resizeChart();
  277. }, 200),
  278. // 获取当前展示的仓库id
  279. getWarehouseId({ detail }) {
  280. const _self = this;
  281. _self.warehouseId = detail.warehouseId;
  282. },
  283. // 获取所有车间信息
  284. getAllWarehouse() {
  285. const _self = this;
  286. const url = "/api/WarehouseResource/queryAllWarehouse";
  287. ajaxGet(url).then((success) => {
  288. if (success.errorCode === 0) {
  289. _self.workShopDatas = success.datas;
  290. _self.createWorkShopChart();
  291. } else {
  292. console.log(success.errorMessage);
  293. }
  294. });
  295. },
  296. // 获取看板信息
  297. getBoardInfo(warehouseId) {
  298. const _self = this;
  299. const url = "/api/BulletinBoardResource/queryBoardByWarehouse";
  300. const params = [["warehouseId", warehouseId]];
  301. ajaxGet(url, params).then((success) => {
  302. if (success.errorCode === 0) {
  303. if (success.data) {
  304. const { boardInventoryQuantityDto } = success.data; // 左上角模检具数量
  305. const { boardInventoryPieDtos: count } = success.data; // 左下角饼图
  306. const { boardRepairInThirtyDaysDtos: number } = success.data; // 中间故障数量
  307. const { boardInventoryRepairDto: fault } = success.data; // 中间故障折线图
  308. const { boardMoldRepairDurationDtos: timer } = success.data; // 右上角时效图
  309. const { boardInventoryStockInOrOutDtos: inOut } =
  310. success.data; // 右下角出入库
  311. // 更新左上角
  312. _self.count = boardInventoryQuantityDto;
  313. // 更新左下角
  314. if (count && count.length > 0) {
  315. _self.updateCountChart(count);
  316. }
  317. // 更新中间故障数量
  318. if (number && number.length > 0) {
  319. _self.updateNumberChart(number);
  320. }
  321. // 更新中间故障曲线
  322. _self.updateMalfunctionChart(fault);
  323. // 更新右上角
  324. if (timer && timer.length > 0) {
  325. _self.updateMaintainChart(timer);
  326. }
  327. // 更新右下角
  328. if (inOut && inOut.length > 0) {
  329. _self.updateOutInChart(inOut);
  330. }
  331. }
  332. } else {
  333. console.log(success.errorMessage);
  334. }
  335. });
  336. },
  337. // 销毁图表
  338. disposeChart(chart) {
  339. chart && chart.dispose();
  340. },
  341. },
  342. watch: {
  343. warehouseId(newVal, oldValue) {
  344. var _self = this;
  345. if (newVal !== oldValue) {
  346. _self.getBoardInfo(newVal);
  347. }
  348. },
  349. },
  350. mounted() {
  351. const _self = this;
  352. _self.outInChart = getElement("outInChart");
  353. _self.workShopChart = getElement("workShopChart");
  354. _self.dieCountChart = getElement("dieCountChart");
  355. _self.maintainChart = getElement("maintainChart");
  356. _self.malfunctionChart = getElement("malfunctionChart");
  357. _self.malfunctionNumber = getElement("malfunctionNumber");
  358. _self.getAllWarehouse();
  359. _self.$nextTick(() => {
  360. _self.createCountChart();
  361. _self.createOutInChart();
  362. _self.createMaintainChart();
  363. _self.createMalfunctionChart();
  364. _self.createMalfunctionNumberChart();
  365. window.addEventListener("resize", _self.cancalDebounce);
  366. window.addEventListener("onmessageChange", _self.getWarehouseId);
  367. });
  368. },
  369. beforeUnmount() {
  370. const _self = this;
  371. window.clearInterval(window.timeTicket);
  372. window.timeTicket = null;
  373. _self.disposeChart(_self.outInChart);
  374. _self.disposeChart(_self.workShopChart);
  375. _self.disposeChart(_self.maintainChart);
  376. _self.disposeChart(_self.dieCountChart);
  377. _self.disposeChart(_self.malfunctionChart);
  378. _self.disposeChart(_self.malfunctionNumber);
  379. window.removeEventListener("resize", _self.cancalDebounce);
  380. window.removeEventListener("onmessageChange", _self.getWarehouseId);
  381. },
  382. });
  383. </script>
  384. </body>
  385. </html>