dawotezhexian.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <template>
  2. <div class="home-container">
  3. <el-card class="home-container__card">
  4. <div class="title">
  5. <span>
  6. 销售趋势
  7. </span>
  8. <span>
  9. <i
  10. class="el-icon-refresh-right"
  11. style="cursor: pointer;font-size:20px"
  12. @click="refresh"
  13. ></i>
  14. </span>
  15. </div>
  16. <div class="content" v-loading="loading">
  17. <div class="content-year">
  18. <el-date-picker
  19. v-model="annual"
  20. type="year"
  21. size="mini"
  22. placeholder="选择年"
  23. value-format="yyyy"
  24. style="margin-right:10px"
  25. @change="getsalesTrend"
  26. />
  27. </div>
  28. <div
  29. id="polylineData"
  30. ref="polylineData"
  31. style="width:55vw;height:33vh"
  32. />
  33. </div>
  34. </el-card>
  35. </div>
  36. </template>
  37. <script>
  38. import {salesTrend} from "@/api/wel";
  39. import {getYearDate} from "@/util/date";
  40. export default {
  41. data(){
  42. return {
  43. loading: false,
  44. annual: "",
  45. tradeType:''
  46. }
  47. },
  48. created() {
  49. this.annual = getYearDate().toString();
  50. this.getSysType();
  51. },
  52. mounted() {
  53. this.init();
  54. },
  55. methods:{
  56. refresh() {
  57. this.init();
  58. },
  59. init() {
  60. if (this.tradeType == null) {
  61. return
  62. }else {
  63. this.getsalesTrend();
  64. }
  65. },
  66. getSysType() {
  67. const sysType = localStorage.getItem("sysitemType");
  68. if (sysType == 6) {
  69. this.tradeType = "JXS";
  70. } else if (sysType == 5) {
  71. this.tradeType = "SW";
  72. } else if (sysType == 4) {
  73. this.tradeType = "CK";
  74. } else if (sysType == 3) {
  75. this.tradeType = "JK";
  76. } else if (sysType == 2) {
  77. this.tradeType = "GN";
  78. } else if (sysType == 1) {
  79. this.tradeType = "XX";
  80. } else if (sysType == 999) {
  81. this.tradeType = "ADMIN";
  82. }
  83. },
  84. getsalesTrend() {
  85. this.loading = true;
  86. this.moneyList = [];
  87. salesTrend({
  88. tradeType: this.tradeType,
  89. billType: "XS",
  90. annual: this.annual
  91. })
  92. .then(res => {
  93. res.data.data.forEach(e => {
  94. this.moneyList.push(Number(e.money));
  95. });
  96. })
  97. .finally(() => {
  98. this.loading = false;
  99. this.polylineData();
  100. });
  101. },
  102. polylineData() {
  103. let polylineData = this.$echarts.init(
  104. document.getElementById("polylineData")
  105. );
  106. polylineData.setOption({
  107. tooltip: {
  108. trigger: "axis",
  109. axisPointer: {
  110. type: "line"
  111. }
  112. },
  113. xAxis: {
  114. type: "category",
  115. data: [
  116. "一月",
  117. "二月",
  118. "三月",
  119. "四月",
  120. "五月",
  121. "六月",
  122. "七月",
  123. "八月",
  124. "九月",
  125. "十月",
  126. "十一月",
  127. "十二月"
  128. ]
  129. },
  130. yAxis: {
  131. type: "value"
  132. },
  133. series: [
  134. {
  135. data: this.moneyList,
  136. type: "line",
  137. smooth: true
  138. }
  139. ]
  140. });
  141. },
  142. }
  143. }
  144. </script>
  145. <style lang="scss" scoped>
  146. .home-container {
  147. padding: 0px 5px 5px 0px;
  148. box-sizing: border-box;
  149. height: 100%;
  150. ::v-deep .el-card__body {
  151. padding: 10px 15px;
  152. font-size: 14px;
  153. }
  154. &__card {
  155. width: 100%;
  156. height: 100%;
  157. }
  158. .title {
  159. display: flex;
  160. justify-content: space-between;
  161. }
  162. }
  163. </style>