index.vue 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285
  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="pieOption" />
  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 } 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 } 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. form: {
  119. finishTime: '',
  120. timeType: '1'
  121. }
  122. };
  123. },
  124. created() {
  125. this.pieOption = pieOption([
  126. { value: 40, name: ' 外观检测' },
  127. { value: 30, name: ' 尺寸检测' },
  128. { value: 15, name: ' 性能检测' },
  129. { value: 10, name: ' 密度检测' },
  130. { value: 5, name: ' 重量检测' }
  131. ]);
  132. this.getCount();
  133. this.getCompletionCount();
  134. },
  135. mounted(){
  136. setTimeout(() => {
  137. this.$refs.barRef.resize();
  138. this.$refs.pieRef.resize();
  139. }, 300);
  140. },
  141. methods: {
  142. datasource({page, where, limit}) {
  143. where.factoriesId = 0;
  144. return getOrderList({
  145. ...where,
  146. pageNum: page,
  147. size: limit
  148. });
  149. },
  150. //首页统计
  151. async getCount() {
  152. let rest = await getCount({factoriesId: 0});
  153. this.arr.forEach((item, index) => {
  154. if (item.name === '生产总数') {
  155. item.num = rest.formingNum || 0;
  156. } else if (item.name === '待生产数量') {
  157. item.num = rest.pendingProductionCount || 0;
  158. } else if (item.name === '已完成数量') {
  159. item.num = rest.formedNum || 0;
  160. } else if (item.name === '生产中数量') {
  161. item.num = rest.inProgressWorkOrderCount || 0;
  162. }
  163. })
  164. // console.log(rest, 'rest');
  165. },
  166. //工单完成统计
  167. async getCompletionCount() {
  168. let params = {
  169. startDate: new Date().getFullYear() + '-01-01',
  170. endDate: new Date().getFullYear() + '-12-31',
  171. factoriesId: 0,
  172. }
  173. let rest = await getCompletionCount(params);
  174. let inWarehouseCountList = []; //入库数量
  175. let inProductCountList = []; //在制工单数
  176. for (let i = 0; i < rest.length; i++) {
  177. inWarehouseCountList.push(rest[i].inWarehouseCount)
  178. inProductCountList.push(rest[i].inProductCountList)
  179. }
  180. this.barOption = barOption(
  181. [
  182. {
  183. name: '工单入库数量',
  184. barWidth: '25%',
  185. data: inWarehouseCountList,
  186. type: 'bar',
  187. yAxisIndex: 0 // 使用第一个Y轴
  188. }, {
  189. name: '工单数',
  190. symbolSize: 10,
  191. data: inProductCountList,
  192. type: 'line', smooth: true,
  193. itemStyle: {
  194. color: '#ffab08'
  195. },
  196. }
  197. ]);
  198. }
  199. }
  200. };
  201. </script>
  202. <style lang="scss" scoped>
  203. .clearfix {
  204. font-size: 0.7vw;
  205. > span {
  206. font-weight: bold;
  207. }
  208. :deep(.el-radio-button__inner) {
  209. font-size: 0.7vw;
  210. }
  211. }
  212. .ele-body {
  213. height: calc(100vh - 111px);
  214. > .el-row {
  215. height: 100%;
  216. }
  217. .el-card {
  218. height: 100%;
  219. :deep(.el-card__body) {
  220. padding: 0.3vw;
  221. }
  222. :deep(.el-card__header) {
  223. padding: 0.8vw;
  224. }
  225. :deep(.el-card__body) {
  226. height: calc(100% - 1.6vw - 39px);
  227. }
  228. :deep(.ele-pro-table) {
  229. height: 99%;
  230. }
  231. :deep(.el-table) {
  232. font-size: 0.65vw;
  233. }
  234. }
  235. }
  236. .item {
  237. width: 100%;
  238. display: flex;
  239. margin-bottom: 15px;
  240. margin-top: 15px;
  241. > div {
  242. border-radius: 4px;
  243. flex: 1;
  244. margin-left: 15px;
  245. background: url(../../assets/item_frame.png) no-repeat;
  246. background-size: 100% 100%;
  247. display: flex;
  248. align-items: center;
  249. padding: 12px;
  250. img {
  251. width: 2.3vw;
  252. // height:1.7vw;
  253. }
  254. > div {
  255. display: flex;
  256. flex-direction: column;
  257. // margin-left: 0.8vw;
  258. justify-content: center;
  259. align-items: center;
  260. width: 80%;
  261. span:nth-of-type(1) {
  262. font-size: 0.75vw;
  263. }
  264. span:nth-of-type(2) {
  265. font-weight: bold;
  266. font-size: 1.2vw;
  267. margin-top: 0.8vw;
  268. span {
  269. font-size: 0.7vw;
  270. }
  271. }
  272. }
  273. }
  274. }
  275. </style>