statisDetails.vue 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <template>
  2. <div style="background-color: #f0f2f5; padding-bottom: 20px; min-height: 100%; " >
  3. <div style="padding: 20px; background-color: #fff;">
  4. 数据分析
  5. </div>
  6. <div class="contentx" v-if="item!=null">
  7. <div class="desct">
  8. 数据分析
  9. </div>
  10. <div class="statistics-container">
  11. <el-row :gutter="20" type="flex" justify="space-between">
  12. <el-col :span="6" >
  13. <el-card style="height: 100px">
  14. <div class="statistic-item">
  15. <h2>{{ item.addNum }} </h2>
  16. <p>添加人数</p>
  17. </div>
  18. </el-card>
  19. </el-col>
  20. <el-col :span="6" >
  21. <el-card style="height: 100px">
  22. <div class="statistic-item">
  23. <h2>{{ item.deleteNum }} </h2>
  24. <p>流失人数</p>
  25. </div>
  26. </el-card>
  27. </el-col>
  28. <el-col :span="6" >
  29. <el-card style="height: 100px">
  30. <div class="statistic-item">
  31. <h2>{{ item.addNum-item.deleteNum }} </h2>
  32. <p>剩余人数</p>
  33. </div>
  34. </el-card>
  35. </el-col>
  36. </el-row>
  37. </div>
  38. </div>
  39. <div class="contentx" v-if="item!=null">
  40. <div class="desct">
  41. 数据统计
  42. </div>
  43. <div>
  44. <el-select v-model="value" placeholder="请选择日期" style="margin-left: 40px;" @change="changeValue">
  45. <el-option
  46. v-for="item in options"
  47. :key="item.value"
  48. :label="item.label"
  49. :value="item.value">
  50. </el-option>
  51. </el-select>
  52. </div>
  53. <div id="echart-customer" style="width: 100%; height: 400px;"></div>
  54. </div>
  55. <div class="contentx" v-if="item!=null">
  56. <div class="desct">
  57. 数据表格
  58. </div>
  59. <div>
  60. <el-table
  61. :data="list"
  62. border
  63. :summary-method="getSummaries"
  64. show-summary
  65. max-height="500"
  66. style="width: 100%;">
  67. <el-table-column
  68. prop="type"
  69. label="日期">
  70. </el-table-column>
  71. <el-table-column
  72. prop="addNum"
  73. label="添加人数">
  74. </el-table-column>
  75. <el-table-column
  76. prop="deleteNum"
  77. label="流失人数">
  78. </el-table-column>
  79. <el-table-column
  80. prop="num"
  81. label="净人数">
  82. </el-table-column>
  83. </el-table>
  84. </div>
  85. </div>
  86. </div>
  87. </template>
  88. <script>
  89. import {statistics, sync,listContactWay, getContactWay, delContactWay, addContactWay, updateContactWay, exportContactWay } from "@/api/qw/contactWay";
  90. import echarts from 'echarts'
  91. export default {
  92. name: "statisDetails",
  93. props:["data"],
  94. data() {
  95. return {
  96. item:null,
  97. value: '5',
  98. options: [{
  99. value: '1',
  100. label: '今天'
  101. }, {
  102. value: '2',
  103. label: '昨天'
  104. }, {
  105. value: '3',
  106. label: '本周'
  107. }, {
  108. value: '4',
  109. label: '上周'
  110. }, {
  111. value: '5',
  112. label: '本月'
  113. }
  114. , {
  115. value: '6',
  116. label: '上月'
  117. }
  118. , {
  119. value: '7',
  120. label: '本季度'
  121. }
  122. , {
  123. value: '8',
  124. label: '上季度'
  125. }
  126. , {
  127. value: '9',
  128. label: '本年'
  129. }
  130. , {
  131. value: '10',
  132. label: '上年'
  133. }],
  134. list:[],
  135. dates:[],
  136. addNum:[],
  137. deleteNum:[],
  138. num:[],
  139. };
  140. },
  141. created() {
  142. },
  143. methods: {
  144. getDetails(orderId) {
  145. this.item=null;
  146. this.list=null;
  147. getContactWay(orderId).then(response => {
  148. this.item = response.data;
  149. this.getStatisList()
  150. });
  151. },
  152. changeValue(){
  153. this.getStatisList()
  154. },
  155. getStatisList(){
  156. var data={type:this.value,wayId:this.item.id}
  157. statistics(data).then(response => {
  158. this.list=response.list;
  159. this.dates=response.dates;
  160. this.addNum=response.addNum;
  161. this.deleteNum=response.deleteNum;
  162. this.num=response.num;
  163. setTimeout(() => {
  164. this.initEchart();
  165. }, 500);
  166. });
  167. },
  168. initEchart(){
  169. var option = {
  170. tooltip: {
  171. trigger: 'axis',
  172. axisPointer: { // 坐标轴指示器,坐标轴触发有效
  173. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  174. }
  175. },
  176. legend: {
  177. data: ['添加人数', '流失人数','净人数']
  178. },
  179. grid: {
  180. left: '3%',
  181. right: '4%',
  182. bottom: '3%',
  183. containLabel: true
  184. },
  185. xAxis: [
  186. {
  187. type: 'category',
  188. data: this.dates
  189. }
  190. ],
  191. yAxis: [
  192. {
  193. type: 'value',
  194. axisLabel:{
  195. formatter:'{value}'
  196. }
  197. }
  198. ],
  199. series: [
  200. {
  201. name: '添加人数',
  202. type: 'line',
  203. emphasis: {
  204. focus: 'series'
  205. },
  206. data: this.addNum
  207. },
  208. {
  209. name: '流失人数',
  210. type: 'line',
  211. emphasis: {
  212. focus: 'series'
  213. },
  214. data: this.deleteNum
  215. },
  216. {
  217. name: '净人数',
  218. type: 'line',
  219. emphasis: {
  220. focus: 'series'
  221. },
  222. data: this.num
  223. }
  224. ]
  225. };
  226. this.chart=echarts.init(document.getElementById("echart-customer"));
  227. this.chart.setOption(option,true);
  228. },
  229. }
  230. }
  231. </script>
  232. <style>
  233. .contentx{
  234. height: 100%;
  235. background-color: #fff;
  236. padding: 0px 20px 20px;
  237. margin: 20px;
  238. }
  239. .el-descriptions-item__label.is-bordered-label{
  240. font-weight: normal;
  241. }
  242. .el-descriptions-item__content {
  243. max-width: 150px;
  244. min-width: 100px;
  245. }
  246. .desct{
  247. padding-top: 20px;
  248. padding-bottom: 20px;
  249. color: #524b4a;
  250. font-weight: bold;
  251. }
  252. .require:before {
  253. content: '* ';
  254. color: red;
  255. }
  256. .noRequire:before{
  257. content: '* ';
  258. color: white;
  259. }
  260. .statistics-container {
  261. padding: 20px;
  262. }
  263. .statistic-item {
  264. text-align: center;
  265. margin-top: 5%;
  266. }
  267. .statistic-item h2 {
  268. font-size: 24px;
  269. margin: 0;
  270. }
  271. .statistic-item p {
  272. margin: 5px 0 0;
  273. color: #666;
  274. }
  275. .echart-box{
  276. margin: 0 auto;
  277. text-align: center;
  278. }
  279. </style>