sales-trend.vue 4.0 KB

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