sales-trend.vue 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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 { getYearDate } from "@/util/date";
  62. import { salesTrend } from "@/api/wel";
  63. export default {
  64. name: "basicContainer",
  65. props: {
  66. sysType: Number
  67. },
  68. data() {
  69. return {
  70. loading: false,
  71. annual:"",
  72. tradeType: null,
  73. moneyList: []
  74. };
  75. },
  76. created() {
  77. this.annual=getYearDate().toString()
  78. this.getSysType();
  79. },
  80. mounted() {
  81. this.init();
  82. },
  83. methods: {
  84. init() {
  85. this.getsalesTrend();
  86. },
  87. getSysType() {
  88. const sysType = localStorage.getItem("sysitemType");
  89. if (sysType == 6) {
  90. this.tradeType = "JXS";
  91. } else if (sysType == 5) {
  92. this.tradeType = "SW";
  93. } else if (sysType == 4) {
  94. this.tradeType = "CK";
  95. } else if (sysType == 3) {
  96. this.tradeType = "JK";
  97. } else if (sysType == 2) {
  98. this.tradeType = "GN";
  99. } else if (sysType == 1) {
  100. this.tradeType = "XX";
  101. } else if (sysType == 999) {
  102. this.tradeType = "ADMIN";
  103. }
  104. },
  105. getsalesTrend() {
  106. this.loading = true;
  107. this.moneyList = [];
  108. salesTrend({
  109. tradeType: this.tradeType,
  110. billType: "XS",
  111. annual: this.annual
  112. })
  113. .then(res => {
  114. res.data.data.forEach(e => {
  115. this.moneyList.push(Number(e.money));
  116. });
  117. })
  118. .finally(() => {
  119. this.loading = false;
  120. this.polylineData();
  121. });
  122. },
  123. refresh() {
  124. this.init();
  125. },
  126. polylineData() {
  127. let polylineData = this.$echarts.init(
  128. document.getElementById("polylineData")
  129. );
  130. polylineData.setOption({
  131. xAxis: {
  132. type: "category",
  133. data: [
  134. "一月",
  135. "二月",
  136. "三月",
  137. "四月",
  138. "五月",
  139. "六月",
  140. "七月",
  141. "八月",
  142. "九月",
  143. "十月",
  144. "十一月",
  145. "十二月"
  146. ]
  147. },
  148. yAxis: {
  149. type: "value"
  150. },
  151. series: [
  152. {
  153. data: this.moneyList,
  154. type: "line",
  155. smooth: true
  156. }
  157. ]
  158. });
  159. }
  160. }
  161. };
  162. </script>
  163. <style lang="scss" scoped>
  164. .home-container {
  165. padding: 0px 5px 5px 0px;
  166. box-sizing: border-box;
  167. height: 100%;
  168. ::v-deep .el-card__body {
  169. padding: 10px 15px;
  170. font-size: 14px;
  171. }
  172. &__card {
  173. width: 100%;
  174. height: 100%;
  175. }
  176. .title {
  177. display: flex;
  178. justify-content: space-between;
  179. }
  180. }
  181. .content {
  182. display: flex;
  183. flex-direction: column;
  184. &-year {
  185. display: flex;
  186. justify-content: right;
  187. }
  188. }
  189. </style>