smodule57.vue 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246
  1. <template>
  2. <div class="module-main">
  3. <div class="module-box">
  4. <div class="header">
  5. <span @click="clickTask">任务数据统计</span>
  6. <span class="pull-right" @click="clickMore">更多></span>
  7. <select v-model="type" class="module-select" @change="updateData">
  8. <option value="1">日统计</option>
  9. <option value="2">周统计</option>
  10. <option value="3">月统计</option>
  11. </select>
  12. <select v-model="mode" class="module-select" @change="updateData">
  13. <option value="1">报修</option>
  14. <option value="2">保洁</option>
  15. <option value="3">运送</option>
  16. <option value="4">应急</option>
  17. </select>
  18. </div>
  19. <echarts :data="echartsOption" class="data" />
  20. </div>
  21. <popup-7 :visible="taskVisible" :ctype="type" :cmode="mode" @closeClick="()=>{taskVisible=false}" />
  22. </div>
  23. </template>
  24. <script>
  25. import Vue from 'vue';
  26. import Component from 'vue-class-component';
  27. import echarts from '@/common/components/echarts.vue';
  28. import Popup7 from '../popup/popup7.vue';
  29. import api from '../../api';
  30. @Component({
  31. props: {
  32. data: {
  33. type: Object,
  34. default: null,
  35. },
  36. },
  37. components: {
  38. echarts,
  39. Popup7,
  40. },
  41. })
  42. export default class Echarts extends Vue {
  43. taskVisible = false;
  44. echartsOption = {
  45. color: ['#1CC6DA', '#FBFE25'],
  46. tooltip: {
  47. trigger: 'axis',
  48. axisPointer: {
  49. type: 'cross',
  50. crossStyle: {
  51. color: '#999',
  52. },
  53. },
  54. },
  55. legend: {
  56. show: true,
  57. data: ['工单数', '订单数'],
  58. itemWidth: 20, // 颜色块宽度
  59. itemHeight: 5, // 颜色块高度
  60. textStyle: {
  61. fontSize: 12, // 颜色块后字体大小
  62. color: '#fff', // 颜色块后字体颜色
  63. },
  64. top: '-3px',
  65. },
  66. grid: {
  67. top: '15px',
  68. left: '0',
  69. right: '0',
  70. bottom: '0',
  71. containLabel: true,
  72. },
  73. xAxis: [
  74. {
  75. type: 'category',
  76. data: [],
  77. // 设置轴线的属性
  78. axisLine: {
  79. lineStyle: {
  80. color: '#FFFFFF',
  81. width: 1, // 这里是为了突出显示加上的
  82. },
  83. },
  84. // splitLine: {
  85. // show: false, // 去掉网格线
  86. // },
  87. },
  88. ],
  89. yAxis: [
  90. {
  91. type: 'value',
  92. name: '数量',
  93. // min: 0,
  94. // max: 250,
  95. // interval: 50,
  96. axisLabel: {
  97. formatter: '{value}',
  98. },
  99. // 设置轴线的属性
  100. axisLine: {
  101. show: true,
  102. lineStyle: {
  103. color: '#FFFFFF',
  104. width: 1, // 这里是为了突出显示加上的
  105. },
  106. },
  107. axisTick: { // y轴刻度线
  108. show: true,
  109. },
  110. splitLine: { // 网格线
  111. show: false,
  112. },
  113. },
  114. ],
  115. series: [
  116. {
  117. name: '工单数',
  118. type: 'bar',
  119. barWidth: '10px',
  120. data: [],
  121. },
  122. {
  123. name: '订单数',
  124. type: 'line',
  125. data: [],
  126. },
  127. ],
  128. };
  129. loading = true;
  130. mode = '1';
  131. type = '1';
  132. timer=null;
  133. created() {
  134. this.updateData();
  135. // this.getOrderCount();
  136. // setInterval(() => {
  137. // this.getOrderCount();
  138. // }, 1000 * 60 * 5);
  139. }
  140. updateData() {
  141. if (this.timer) { // 清除定时器
  142. clearInterval(this.timer);
  143. }
  144. this.getOrderCount();
  145. this.timer = setInterval(() => {
  146. this.getOrderCount();
  147. }, 1000 * 60 * 5);
  148. }
  149. getOrderCount() {
  150. api.getOrderCount({
  151. type: this.type,
  152. mode: this.mode,
  153. }).then((res) => {
  154. this.$nextTick(() => {
  155. this.echartsOption.xAxis = [
  156. {
  157. type: 'category',
  158. data: res.data.d,
  159. // 设置轴线的属性
  160. axisLine: {
  161. lineStyle: {
  162. color: '#FFFFFF',
  163. width: 1, // 这里是为了突出显示加上的
  164. },
  165. },
  166. // splitLine: {
  167. // show: false, // 去掉网格线
  168. // },
  169. },
  170. ];
  171. this.echartsOption.series = [
  172. {
  173. name: '工单数',
  174. type: 'bar',
  175. barWidth: '5px',
  176. data: res.data.d1,
  177. },
  178. {
  179. name: '订单数',
  180. type: 'line',
  181. data: res.data.d2,
  182. },
  183. ];
  184. });
  185. }).catch(() => {}).finally(() => {});
  186. }
  187. clickTask() {
  188. this.taskVisible = true;
  189. }
  190. clickMore() {
  191. const url = `${process.env.VUE_APP_PHP_URL}/admin/orders/index.html?mode=0`;
  192. window.open(url);
  193. }
  194. }
  195. </script>
  196. <style scoped lang="scss">
  197. .header{
  198. width: calc(100% - 20px);
  199. height: 50px;
  200. line-height: 50px;
  201. padding: 0 10px;
  202. font-size: 18px;
  203. }
  204. .header span{
  205. font-size: 16px;
  206. font-family: Source Han Sans CN;
  207. // font-weight: bold;
  208. color: #FFFFFF;
  209. cursor: pointer;
  210. }
  211. .data{
  212. width: calc(100% - 20px);
  213. height: calc(100% - 70px);
  214. margin: 0px 10px;
  215. }
  216. .module-select{
  217. width: 80px;
  218. height: 20px;
  219. color: #A6D6FF;
  220. background-color: #3D7FFF;
  221. outline: none;
  222. border: 1px solid #A6D6FF;
  223. float: right;
  224. vertical-align: middle;
  225. margin-top: 16px;
  226. margin-right: 5px;
  227. }
  228. .pull-right{
  229. float: right !important;
  230. }
  231. </style>