index.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. <template>
  2. <div class="ele-body">
  3. <el-row :gutter="15">
  4. <el-col :span="16" style="height: calc(57% - 51px)">
  5. <el-radio-group v-model="form.timeType" @change="timeTypeChange">
  6. <el-radio-button label="1">企业</el-radio-button>
  7. <el-radio-button label="2">工厂</el-radio-button>
  8. <el-radio-button label="3">班组</el-radio-button>
  9. <el-radio-button label="4">产线</el-radio-button>
  10. </el-radio-group>
  11. <div style="height: 20%" class="item">
  12. <div v-for="item in arr" :key="item" :style="{ color: item.color }">
  13. <img :src="item.imgUrl" />
  14. <div>
  15. <span>
  16. {{ item.name }}
  17. </span>
  18. <span>
  19. {{ item.num }}
  20. <span>{{ item.unit }}</span>
  21. </span>
  22. </div>
  23. </div>
  24. </div>
  25. <el-card class="box-card" style="height: calc(80% - 15px)">
  26. <div slot="header" class="clearfix">
  27. <span>工单完成统计</span>
  28. </div>
  29. <v-chart ref="barRef" style="height: 100%" :option="barOption" />
  30. </el-card>
  31. </el-col>
  32. <el-col :span="8" style="height: 57%">
  33. <el-card class="box-card">
  34. <div slot="header" class="clearfix">
  35. <span>不良品分布图</span>
  36. </div>
  37. <v-chart ref="pieRef" style="height: 100%" :option="pieOptions" />
  38. </el-card>
  39. </el-col>
  40. <el-col :span="24" style="height: 43%; margin-top: 15px">
  41. <el-card class="box-card">
  42. <div slot="header" class="clearfix">
  43. <span>工单进度执行跟踪</span>
  44. </div>
  45. <ele-pro-table
  46. ref="table"
  47. height="calc(100%)"
  48. :columns="columns"
  49. :datasource="datasource"
  50. :toolbar="false"
  51. :needPage="false"
  52. >
  53. </ele-pro-table>
  54. </el-card>
  55. </el-col>
  56. </el-row>
  57. </div>
  58. </template>
  59. <script>
  60. import dictMixins from '@/mixins/dictMixins';
  61. import { pieOption, barOption, columns, pieOptions } from './data';
  62. import { use } from 'echarts/core';
  63. import { CanvasRenderer } from 'echarts/renderers';
  64. import { BarChart, PieChart, LineChart } from 'echarts/charts';
  65. import {
  66. GridComponent,
  67. TooltipComponent,
  68. LegendComponent
  69. } from 'echarts/components';
  70. import VChart from 'vue-echarts';
  71. import { echartsMixin } from '@/utils/echarts-mixin';
  72. import { getCount, getCompletionCount, getOrderList,queryProportionDefectiveTypes } from '@/api/mes/index';
  73. // 按需加载 echarts
  74. use([
  75. CanvasRenderer,
  76. BarChart,
  77. PieChart,
  78. GridComponent,
  79. TooltipComponent,
  80. LegendComponent,
  81. LineChart
  82. ]);
  83. export default {
  84. mixins: [dictMixins, echartsMixin(['pieRef', 'barRef'])],
  85. components: { VChart },
  86. data() {
  87. return {
  88. columns,
  89. arr: [
  90. {
  91. name: '生产总数',
  92. num: '188',
  93. imgUrl: require('../../assets/Group1.png'),
  94. unit: ''
  95. },
  96. {
  97. name: '待生产数量',
  98. num: '188',
  99. imgUrl: require('../../assets/Group2.png'),
  100. unit: ''
  101. },
  102. {
  103. name: '已完成数量',
  104. num: '188',
  105. imgUrl: require('../../assets/Group3.png'),
  106. unit: ''
  107. },
  108. {
  109. name: '生产中数量',
  110. num: '188',
  111. imgUrl: require('../../assets/Group4.png'),
  112. unit: '',
  113. color: '#f97876'
  114. }
  115. ],
  116. pieOption: {},
  117. barOption: {},
  118. pieOptions: {},
  119. form: {
  120. finishTime: '',
  121. timeType: '1'
  122. }
  123. };
  124. },
  125. created() {
  126. // this.pieOption = pieOption([
  127. // { value: 40, name: ' 外观检测' },
  128. // { value: 30, name: ' 尺寸检测' },
  129. // { value: 15, name: ' 性能检测' },
  130. // { value: 10, name: ' 密度检测' },
  131. // { value: 5, name: ' 重量检测' }
  132. // ]);
  133. this.getCount();
  134. this.getCompletionCount();
  135. },
  136. mounted() {
  137. this.proportion();
  138. setTimeout(() => {
  139. this.$refs.barRef.resize();
  140. this.$refs.pieRef.resize();
  141. }, 300);
  142. },
  143. methods: {
  144. async proportion() {
  145. const res = await queryProportionDefectiveTypes();
  146. let list = res.map((el) => {
  147. return {
  148. value: el.unQualifiedNumber,
  149. name: el.categoryLevelClassName
  150. };
  151. });
  152. this.pieOptions = pieOptions(list);
  153. console.log(res, 'res ----');
  154. },
  155. datasource({ page, where, limit }) {
  156. where.factoriesId = 0;
  157. return getOrderList({
  158. ...where,
  159. pageNum: page,
  160. size: limit
  161. });
  162. },
  163. timeTypeChange(){},
  164. //首页统计
  165. async getCount() {
  166. let rest = await getCount({ factoriesId: 0 });
  167. this.arr.forEach((item, index) => {
  168. if (item.name === '生产总数') {
  169. item.num = rest.formingNum || 0;
  170. } else if (item.name === '待生产数量') {
  171. item.num = rest.pendingProductionCount || 0;
  172. } else if (item.name === '已完成数量') {
  173. item.num = rest.formedNum || 0;
  174. } else if (item.name === '生产中数量') {
  175. item.num = rest.inProgressWorkOrderCount || 0;
  176. }
  177. });
  178. // console.log(rest, 'rest');
  179. },
  180. //工单完成统计
  181. async getCompletionCount() {
  182. let params = {
  183. startDate: new Date().getFullYear() + '-01-01',
  184. endDate: new Date().getFullYear() + '-12-31',
  185. factoriesId: 0
  186. };
  187. let rest = await getCompletionCount(params);
  188. let inWarehouseCountList = []; //入库数量
  189. let inProductCountList = []; //在制工单数
  190. for (let i = 0; i < rest.length; i++) {
  191. inWarehouseCountList.push(rest[i].inWarehouseCount);
  192. inProductCountList.push(rest[i].inProductCountList);
  193. }
  194. this.barOption = barOption([
  195. {
  196. name: '工单入库数量',
  197. barWidth: '25%',
  198. data: inWarehouseCountList,
  199. type: 'bar',
  200. yAxisIndex: 0 // 使用第一个Y轴
  201. },
  202. {
  203. name: '工单数',
  204. symbolSize: 10,
  205. data: inProductCountList,
  206. type: 'line',
  207. smooth: true,
  208. itemStyle: {
  209. color: '#ffab08'
  210. }
  211. }
  212. ]);
  213. }
  214. }
  215. };
  216. </script>
  217. <style lang="scss" scoped>
  218. .clearfix {
  219. font-size: 0.7vw;
  220. > span {
  221. font-weight: bold;
  222. }
  223. :deep(.el-radio-button__inner) {
  224. font-size: 0.7vw;
  225. }
  226. }
  227. .ele-body {
  228. height: calc(100vh - 111px);
  229. > .el-row {
  230. height: 100%;
  231. }
  232. .el-card {
  233. height: 100%;
  234. :deep(.el-card__body) {
  235. padding: 0.3vw;
  236. }
  237. :deep(.el-card__header) {
  238. padding: 0.8vw;
  239. }
  240. :deep(.el-card__body) {
  241. height: calc(100% - 1.6vw - 39px);
  242. }
  243. :deep(.ele-pro-table) {
  244. height: 99%;
  245. }
  246. :deep(.el-table) {
  247. font-size: 0.65vw;
  248. }
  249. }
  250. }
  251. .item {
  252. width: 100%;
  253. display: flex;
  254. margin-bottom: 15px;
  255. margin-top: 15px;
  256. > div {
  257. border-radius: 4px;
  258. flex: 1;
  259. margin-left: 15px;
  260. background: url(../../assets/item_frame.png) no-repeat;
  261. background-size: 100% 100%;
  262. display: flex;
  263. align-items: center;
  264. padding: 12px;
  265. img {
  266. width: 2.3vw;
  267. // height:1.7vw;
  268. }
  269. > div {
  270. display: flex;
  271. flex-direction: column;
  272. // margin-left: 0.8vw;
  273. justify-content: center;
  274. align-items: center;
  275. width: 80%;
  276. span:nth-of-type(1) {
  277. font-size: 0.75vw;
  278. }
  279. span:nth-of-type(2) {
  280. font-weight: bold;
  281. font-size: 1.2vw;
  282. margin-top: 0.8vw;
  283. span {
  284. font-size: 0.7vw;
  285. }
  286. }
  287. }
  288. }
  289. }
  290. </style>