index.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215
  1. <template>
  2. <div class="ele-body">
  3. <el-row :gutter="5">
  4. <el-col :span="13" style="height: 50%">
  5. <el-card class="box-card">
  6. <div slot="header" class="clearfix">
  7. <span>采销统计</span>
  8. </div>
  9. <v-chart ref="barRef" style="height: 100%" :option="barOption" />
  10. </el-card>
  11. </el-col>
  12. <el-col :span="11" style="height: 50%">
  13. <el-card class="box-card">
  14. <div slot="header" class="clearfix">
  15. <span>销售订单进度情况</span>
  16. </div>
  17. <ele-pro-table
  18. ref="table"
  19. :pageSize="20"
  20. :columns="columns"
  21. :datasource="datasource"
  22. :toolbar="false"
  23. height="calc(100% - 45px)"
  24. >
  25. </ele-pro-table>
  26. </el-card>
  27. </el-col>
  28. <el-col :span="11" style="height: 50%; margin-top: 5px">
  29. <el-card class="box-card">
  30. <div slot="header" class="clearfix">
  31. <span>采购订单进度情况</span>
  32. </div>
  33. <ele-pro-table
  34. ref="table"
  35. :columns="columns1"
  36. :pageSize="20"
  37. :datasource="datasource1"
  38. :toolbar="false"
  39. height="calc(100% - 45px)"
  40. >
  41. </ele-pro-table>
  42. </el-card>
  43. </el-col>
  44. <el-col :span="13" style="height: 50%; margin-top: 5px">
  45. <el-card class="box-card">
  46. <div slot="header" class="clearfix">
  47. <span>应收应付统计</span>
  48. </div>
  49. <v-chart ref="barRef1" style="height: 100%" :option="barOption1" />
  50. </el-card>
  51. </el-col>
  52. </el-row>
  53. </div>
  54. </template>
  55. <script>
  56. import { pieOption, barOption, columns, columns1 } from './data';
  57. import { use } from 'echarts/core';
  58. import { CanvasRenderer } from 'echarts/renderers';
  59. import { BarChart } from 'echarts/charts';
  60. import {
  61. GridComponent,
  62. TooltipComponent,
  63. LegendComponent
  64. } from 'echarts/components';
  65. import VChart from 'vue-echarts';
  66. import { echartsMixin } from '@/utils/echarts-mixin';
  67. import { indexGroup } from '@/api/main/index.js';
  68. import { init } from 'echarts';
  69. import { getTableList } from '@/api/purchasingManage/purchaseOrder';
  70. import { getTableListHome } from '@/api/saleManage/saleorder';
  71. // 按需加载 echarts
  72. use([
  73. CanvasRenderer,
  74. BarChart,
  75. GridComponent,
  76. TooltipComponent,
  77. LegendComponent
  78. ]);
  79. export default {
  80. mixins: [echartsMixin(['barRef', 'barRef1'])],
  81. components: { VChart },
  82. data() {
  83. return {
  84. columns,
  85. columns1,
  86. barOption: {},
  87. barOption1: {},
  88. timer: null
  89. };
  90. },
  91. created() {},
  92. mounted() {
  93. this.init();
  94. this.timer = setInterval(() => {
  95. this.init();
  96. }, 3600000);
  97. },
  98. beforeDestroy() {
  99. clearInterval(this.timer);
  100. },
  101. methods: {
  102. init() {
  103. indexGroup().then((res) => {
  104. console.log(res, 'res');
  105. this.barOption = barOption(
  106. res.saleAndPurchaseGroup?.monthName,
  107. [
  108. {
  109. name: '采购',
  110. barWidth: '25%',
  111. data: res.saleAndPurchaseGroup.purchaseCounts,
  112. type: 'bar',
  113. yAxisIndex: 0, // 使用第一个Y轴
  114. itemStyle: {
  115. color: '#f9cd5d'
  116. }
  117. },
  118. {
  119. name: '销售',
  120. barWidth: '25%',
  121. data: res.saleAndPurchaseGroup.saleCounts,
  122. type: 'bar',
  123. yAxisIndex: 0, // 使用第一个Y轴
  124. itemStyle: {
  125. color: '#5893eb'
  126. }
  127. }
  128. ],
  129. );
  130. this.barOption1 = barOption(
  131. res.payableAndReceivableGroup?.monthName,
  132. [
  133. {
  134. name: '应收',
  135. barWidth: '25%',
  136. data: res.payableAndReceivableGroup?.receivableCounts,
  137. type: 'bar',
  138. yAxisIndex: 0 // 使用第一个Y轴
  139. },
  140. {
  141. name: '应付',
  142. barWidth: '25%',
  143. data: res.payableAndReceivableGroup?.payableCounts,
  144. type: 'bar',
  145. yAxisIndex: 0 // 使用第一个Y轴
  146. }
  147. ],
  148. '(万元)'
  149. );
  150. setTimeout(() => {
  151. this.$refs.barRef.resize();
  152. this.$refs.barRef1.resize();
  153. }, 300);
  154. });
  155. },
  156. datasource({ page, where, limit }) {
  157. return getTableListHome({
  158. ...where,
  159. pageNum: page,
  160. size: limit,
  161. // progress: 1000
  162. });
  163. },
  164. datasource1({ page, where, limit }) {
  165. return getTableList({
  166. ...where,
  167. pageNum: page,
  168. size: limit,
  169. // progress: 1000
  170. });
  171. }
  172. }
  173. };
  174. </script>
  175. <style lang="scss" scoped>
  176. .clearfix {
  177. font-size: 0.7vw;
  178. > span {
  179. font-weight: bold;
  180. }
  181. :deep(.el-radio-button__inner) {
  182. font-size: 0.7vw;
  183. }
  184. }
  185. .ele-body {
  186. height: calc(100vh - 100px);
  187. > .el-row {
  188. height: 100%;
  189. }
  190. .el-card {
  191. height: 100%;
  192. :deep(.el-card__body) {
  193. padding: 0.3vw;
  194. }
  195. :deep(.el-card__header) {
  196. padding: 0.6vw;
  197. }
  198. :deep(.el-card__body) {
  199. height: calc(100% - 2.3vw);
  200. }
  201. :deep(.ele-pro-table) {
  202. height: 99%;
  203. }
  204. :deep(.el-table) {
  205. font-size: 0.62vw;
  206. }
  207. }
  208. }
  209. </style>