wraparound.php 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505
  1. <?php
  2. use common\helpers\ComponentHelper;
  3. ComponentHelper::loadComponentView('com-system');
  4. ?>
  5. <div id="app" v-cloak>
  6. <com-system></com-system>
  7. <el-card class="generalization">
  8. <!-- 第二行:数据统计 -->
  9. <el-row :gutter="20" class="generalization_two">
  10. <el-col class="generalization_two_item" v-for="(item,index) in generalizationTwoList">
  11. <el-card>
  12. <div style="margin-bottom: 10px; display: flex;align-items: center">
  13. <el-image style="width: 30px; height: 30px"
  14. :src="item.icon"
  15. ></el-image>
  16. <span style="margin-left: 10px"> {{ item.value }} </span>
  17. </div>
  18. <div>{{ item.label }}</div>
  19. </el-card>
  20. </el-col>
  21. </el-row>
  22. <!-- 第三行:图表 -->
  23. <el-row :gutter="20" class="generalization_three">
  24. <el-col :span="8" class="generalization_three_item" style="position: relative">
  25. <div class="generalization_three_item_button" style="position: absolute; right: 10px; top: 10px; z-index: 9999">
  26. <el-radio-group v-model="sales_volume_type" @input="getChangeSalesVolume">
  27. <el-radio-button label="week">周</el-radio-button>
  28. <el-radio-button label="month">月</el-radio-button>
  29. </el-radio-group>
  30. </div>
  31. <div ref="echartsContainer" style="width: 100%; height:400px;"></div>
  32. </el-col>
  33. <el-col :span="8" class="generalization_three_item">
  34. <div ref="echartsAddPay" style="width: 100%; height:400px;"></div>
  35. </el-col>
  36. <el-col :span="8" class="generalization_three_item">
  37. <div ref="echartsUserActiveTrends" style="width: 100%; height:400px;"></div>
  38. </el-col>
  39. <!-- 其他图表(新客户支付趋势、客户留存趋势等)类似 -->
  40. </el-row>
  41. <!-- 第四行:排行榜 -->
  42. <el-row :gutter="20" class="generalization_four">
  43. <el-col :span="8">
  44. <el-card class="generalization_four_item">
  45. <div class="header">总业绩排行榜</div>
  46. <el-table :data="getTotalAchievementRanking" height="400"
  47. :header-cell-style="{'text-align':'center'}"
  48. :cell-style="{'text-align':'center'}">
  49. <el-table-column prop="rank" type="index" label="排序" width="80">
  50. <template slot-scope="scope">
  51. <div v-if="getIsInArray(scope.$index + 1,getRankingValueList )" style="display: flex; align-items: center;justify-content: center">
  52. <el-image style="width: 32px; height: 32px" :src="getRankingIconList[scope.$index].icon" :fit="fit"></el-image>
  53. </div>
  54. <span v-else> {{ scope.$index + 1 }} </span>
  55. </template>
  56. </el-table-column>
  57. <el-table-column prop="name" label="站点名称">
  58. <template slot-scope="scope">
  59. <div class="mall-logo">
  60. <el-avatar :size="40" :src="scope.row.logo"></el-avatar>
  61. <span style="margin-left: 10px">{{scope.row.mall_name}}</span>
  62. </div>
  63. </template>
  64. </el-table-column>
  65. <el-table-column prop="amount" label="总业绩">
  66. <template slot-scope="scope">
  67. <span>{{ scope.row.total_money }}</span>
  68. <div><span>昨天全天: {{scope.row.yesterdayMoney}}</span></div>
  69. </template>
  70. </el-table-column>
  71. </el-table>
  72. </el-card>
  73. </el-col>
  74. <el-col :span="8">
  75. <el-card class="generalization_four_item">
  76. <div class="header">销售额排行榜</div>
  77. <el-table :data="getSalesVolumeRanking" height="400"
  78. :header-cell-style="{'text-align':'center'}"
  79. :cell-style="{'text-align':'center'}">
  80. <el-table-column prop="rank" type="index" label="排序" width="80">
  81. <template slot-scope="scope">
  82. <div v-if="getIsInArray(scope.$index + 1,getRankingValueList )" style="display: flex; align-items: center;justify-content: center">
  83. <el-image style="width: 32px; height: 32px" :src="getRankingIconList[scope.$index].icon" :fit="fit"></el-image>
  84. </div>
  85. <span v-else> {{ scope.$index + 1 }} </span>
  86. </template>
  87. </el-table-column>
  88. <el-table-column prop="name" label="商品名称">
  89. <template slot-scope="scope">
  90. <div class="mall-logo">
  91. <div style="width: 40px;height: 40px">
  92. <el-avatar :src="scope.row.goods.cover_pic" shape="square"></el-avatar>
  93. </div>
  94. <span style="margin-left: 10px">{{scope.row.goods.goods_name}}</span>
  95. </div>
  96. </template>
  97. </el-table-column>
  98. <el-table-column prop="amount" label="站点名称" show-overflow-tooltip>
  99. <template slot-scope="scope">
  100. <span>{{ scope.row.mall.name }}</span>
  101. </template>
  102. </el-table-column>
  103. <el-table-column prop="amount" label="销售额">
  104. <template slot-scope="scope">
  105. <span>{{ scope.row.total_pay_money }}</span>
  106. </template>
  107. </el-table-column>
  108. </el-table>
  109. </el-card>
  110. </el-col>
  111. <el-col :span="8">
  112. <el-card class="generalization_four_item">
  113. <div class="header">热销商品榜</div>
  114. <el-table :data="getHotSalesGoodsRanking" height="400"
  115. :header-cell-style="{'text-align':'center'}"
  116. :cell-style="{'text-align':'center'}">
  117. <el-table-column prop="rank" label="排序" type="index" width="80">
  118. <template slot-scope="scope">
  119. <div v-if="getIsInArray(scope.$index + 1,getRankingValueList )" style="display: flex; align-items: center;justify-content: center">
  120. <el-image style="width: 32px; height: 32px" :src="getRankingIconList[scope.$index].icon" :fit="fit"></el-image>
  121. </div>
  122. <span v-else> {{ scope.$index + 1 }} </span>
  123. </template>
  124. </el-table-column>
  125. <el-table-column prop="name" label="商品名称" width="120" show-overflow-tooltip>
  126. <template slot-scope="scope">
  127. <div class="mall-logo">
  128. <div style="width: 40px;height: 40px">
  129. <el-avatar :src="scope.row.goods.cover_pic" shape="square"></el-avatar>
  130. </div>
  131. <span style="margin-left: 10px">{{scope.row.goods.goods_name}}</span>
  132. </div>
  133. </template>
  134. </el-table-column>
  135. <el-table-column prop="amount" label="站点名称" >
  136. <template slot-scope="scope">
  137. <span>{{ scope.row.mall.name }}</span>
  138. </template>
  139. </el-table-column>
  140. <el-table-column prop="amount" label="销售量">
  141. <template slot-scope="scope">
  142. <span>{{ scope.row.total_sales_volume }}</span>
  143. </template>
  144. </el-table-column>
  145. </el-table>
  146. </el-card>
  147. </el-col>
  148. <!-- 其他排行榜(销售额排行榜、热销商品榜等)类似 -->
  149. </el-row>
  150. </el-card>
  151. </div>
  152. <script>
  153. new Vue({
  154. el: '#app',
  155. data() {
  156. return {
  157. generalizationHeaderLists: [],
  158. getTotalAchievementRanking: [],
  159. getSalesVolumeRanking: [],
  160. getHotSalesGoodsRanking: [],
  161. sales_volume_type: 'month',
  162. generalizationTwoList: [
  163. {
  164. key: 'total_money',
  165. value: 0,
  166. label: '总业绩',
  167. icon: _diy_img_prefix + '/static/system-icon/summarize/ranking.png',
  168. },
  169. {
  170. key: 'total_users',
  171. value: 0,
  172. label: '会员总数',
  173. icon: _diy_img_prefix + '/static/system-icon/summarize/user.png',
  174. },
  175. {
  176. key: 'total_orders',
  177. value: 0,
  178. label: '订单总数',
  179. icon: _diy_img_prefix + '/static/system-icon/summarize/order.png',
  180. },
  181. {
  182. key: 'total_sales',
  183. value: 0,
  184. label: '总销量',
  185. icon: _diy_img_prefix + '/static/system-icon/summarize/sales.png',
  186. },
  187. {
  188. key: 'total_profit',
  189. value: 0,
  190. label: '总利润',
  191. icon: _diy_img_prefix + '/static/system-icon/summarize/profit.png',
  192. }
  193. ],
  194. getThreeDate: [],
  195. getThreeActivesList: [],// 活跃数
  196. getThreeAddUserList: [],// 新增用户数
  197. getThreeAddPayUserList: [],// 新增用户数
  198. getRankingIconList: [
  199. {
  200. icon: _diy_img_prefix + '/static/system-icon/summarize/one.png',
  201. },
  202. {
  203. icon: _diy_img_prefix + '/static/system-icon/summarize/two.png',
  204. },
  205. {
  206. icon: _diy_img_prefix + '/static/system-icon/summarize/three.png',
  207. }
  208. ],
  209. getRankingValueList: [1, 2 , 3],
  210. getSaleTrendHorizontal: [], // 销量趋势图横轴数据
  211. getSaleTrendPrice: [], // 销量趋势图营销额
  212. getSaleTrendProfitPrice: [], // 销量趋势图利润
  213. }
  214. },
  215. mounted() {
  216. /* this.loadList();
  217. this.initCharts()*/
  218. this.loadList();
  219. this.initSaleTrendStatus();
  220. this.initSaleTrendByMonth();
  221. },
  222. methods: {
  223. loadList() { // 初始数据
  224. this.$request({
  225. params: {
  226. r: 'admin/system/get-wraparound',
  227. },
  228. method: 'get',
  229. }).then(e => {
  230. if (e.data.code == 0) {
  231. this.generalizationTwoList.forEach((item, index) => {
  232. item.value = e.data.data.oneStatus[item.key]
  233. });
  234. this.getTotalAchievementRanking = e.data.data.threeStatus.total_achievement_ranking;
  235. this.getSalesVolumeRanking = e.data.data.threeStatus.sales_volume_ranking;
  236. this.getHotSalesGoodsRanking = e.data.data.threeStatus.hot_sales_goods_ranking;
  237. }
  238. }).catch(e => {
  239. console.log(e, "失败了?")
  240. });
  241. },
  242. initSaleTrendStatus() { // 柱状图
  243. this.$request({
  244. params: {
  245. r: 'admin/system/get-sale-trend',
  246. },
  247. method: 'get',
  248. }).then(e => {
  249. if (e.data.code == 0) {
  250. let data = e.data.data;
  251. data.saleTrendList.forEach((item, index) => {
  252. this.getThreeDate.push(item.date);
  253. this.getThreeActivesList.push(item.total_actives);
  254. this.getThreeAddUserList.push(item.add_users);
  255. this.getThreeAddPayUserList.push(item.add_pay_users);
  256. })
  257. this.initUserActiveTrends();
  258. this.initAddPay();
  259. }
  260. }).catch(e => {
  261. console.log(e, "失败了?")
  262. });
  263. },
  264. getChangeSalesVolume() {
  265. this.initSaleTrendByMonth();
  266. },
  267. initSaleTrendByMonth() {
  268. const SALES_VOLUME_TYPE_MONTH = 'month';
  269. this.$request({
  270. params: {
  271. r: 'admin/system/get-sale-trend-month',
  272. type: this.sales_volume_type,
  273. },
  274. method: 'get',
  275. }).then(e => {
  276. if (e.data.code == 0) {
  277. let data = e.data.data;
  278. let getSaleTrendHorizontal = [];
  279. let getSaleTrendPrice = [];
  280. let getSaleTrendProfitPrice = [];
  281. const formatDate = (item, index) => {
  282. if (this.sales_volume_type === SALES_VOLUME_TYPE_MONTH) {
  283. return `${item.year}年${item.month}月`;
  284. } else {
  285. return `第${index + 1}周`;
  286. }
  287. };
  288. data.orderDetailModel.forEach((item, index) => {
  289. getSaleTrendHorizontal.push(formatDate(item, index));
  290. getSaleTrendPrice.push(item.goods_price);
  291. getSaleTrendProfitPrice.push(item.profit_price);
  292. });
  293. this.getSaleTrendHorizontal = getSaleTrendHorizontal;
  294. this.getSaleTrendPrice = getSaleTrendPrice;
  295. this.getSaleTrendProfitPrice = getSaleTrendProfitPrice;
  296. this.initSaleTrend();
  297. }
  298. }).catch(e => {
  299. console.log(e, "失败了?")
  300. });
  301. },
  302. initUserActiveTrends() {
  303. const echartsUserActiveTrends = echarts.init(this.$refs.echartsUserActiveTrends);
  304. // 指定图表的配置项和数据
  305. const optionUserActiveTrends = {
  306. title: {
  307. text: '用户活跃趋势'
  308. },
  309. tooltip: {
  310. trigger: 'axis'
  311. },
  312. legend: {
  313. data: ['日活跃用户'],
  314. orient: 'horizontal',
  315. top: 'bottom',
  316. left: 'center'
  317. },
  318. xAxis: {
  319. type: 'category',
  320. data: this.getThreeDate
  321. },
  322. yAxis: {
  323. type: 'value'
  324. },
  325. series: [{
  326. name: '日活跃用户',
  327. type: 'line',
  328. data: this.getThreeActivesList,
  329. itemStyle : { normal: {label : {show: true}}},
  330. }]
  331. };
  332. // 使用刚指定的配置项和数据显示图表。
  333. echartsUserActiveTrends.setOption(optionUserActiveTrends);
  334. window.addEventListener("resize", function() {
  335. echartsUserActiveTrends.resize();
  336. });
  337. },
  338. initAddPay() {
  339. const echartsAddPay = echarts.init(this.$refs.echartsAddPay);
  340. // 指定图表的配置项和数据
  341. const optionAddPay = {
  342. title: {
  343. text: '新增&付费趋势'
  344. },
  345. tooltip: {
  346. trigger: 'axis'
  347. },
  348. legend: {
  349. data: ['新增用户', '新增付费用户'],
  350. orient: 'horizontal',
  351. top: 'bottom',
  352. left: 'center'
  353. },
  354. xAxis: {
  355. type: 'category',
  356. data: this.getThreeDate
  357. },
  358. yAxis: {
  359. type: 'value'
  360. },
  361. series: [{
  362. name: '新增用户',
  363. type: 'line',
  364. data: this.getThreeAddUserList,
  365. }, {
  366. name: '新增付费用户',
  367. type: 'line',
  368. data: this.getThreeAddPayUserList,
  369. }]
  370. };
  371. // 使用刚指定的配置项和数据显示图表。
  372. echartsAddPay.setOption(optionAddPay);
  373. window.addEventListener("resize", function() {
  374. echartsAddPay.resize();
  375. });
  376. },
  377. initSaleTrend() {
  378. const myChart = echarts.init(this.$refs.echartsContainer);
  379. // 指定图表的配置项和数据
  380. const option = {
  381. title: {
  382. text: '销售趋势'
  383. },
  384. tooltip: {
  385. trigger: 'axis'
  386. },
  387. legend: {
  388. data: ['销售额', '利润'],
  389. orient: 'horizontal',
  390. top: 'bottom',
  391. left: 'center'
  392. },
  393. xAxis: {
  394. type: 'category',
  395. boundaryGap: false,
  396. data: this.getSaleTrendHorizontal
  397. },
  398. yAxis: {
  399. type: 'value'
  400. },
  401. series: [
  402. {
  403. name: '销售额',
  404. type: 'line',
  405. stack: 'Total',
  406. data: this.getSaleTrendPrice
  407. },
  408. {
  409. name: '利润',
  410. type: 'line',
  411. stack: 'Total',
  412. data: this.getSaleTrendProfitPrice
  413. }
  414. ]
  415. };
  416. // 使用刚指定的配置项和数据显示图表。
  417. myChart.setOption(option);
  418. window.addEventListener("resize", function() {
  419. myChart.resize();
  420. });
  421. },
  422. initCharts() {
  423. // 初始化销售趋势图表
  424. let salesTrendChart = echarts.init(document.getElementById('salesTrendChart'))
  425. let salesTrendOption = {
  426. // ECharts配置项
  427. xAxis: {
  428. type: 'category',
  429. data: ['1月', '2月', '3月', '4月']
  430. },
  431. yAxis: {
  432. type: 'value'
  433. },
  434. series: [
  435. {
  436. data: [200, 400, 600, 800],
  437. type: 'line'
  438. }
  439. ]
  440. }
  441. salesTrendChart.setOption(salesTrendOption)
  442. window.addEventListener("resize", function() {
  443. salesTrendChart.resize();
  444. });
  445. // 初始化其他图表类似
  446. },
  447. getIsInArray(value, array) {
  448. return array.includes(value);
  449. }
  450. },
  451. });
  452. </script>
  453. <style >
  454. .generalization {
  455. min-width: 1200px;
  456. }
  457. .generalization_two{
  458. display: flex;
  459. justify-content: space-between;
  460. }
  461. .generalization_two_item{
  462. width: 20%;
  463. margin-bottom: 15px;
  464. }
  465. .generalization_two_item .el-card {
  466. display: flex;
  467. justify-content: center;
  468. align-items: center;
  469. height: 120px;
  470. text-align: center;
  471. font-size: 18px;
  472. }
  473. .mall-logo {
  474. display: flex;
  475. align-items: center;
  476. }
  477. .generalization_three {
  478. margin-top: 15px;
  479. }
  480. .generalization_three_item {
  481. height: 400px;
  482. }
  483. .generalization_four {
  484. margin-top: 40px;
  485. }
  486. .generalization_four_item {
  487. text-align: center;
  488. font-size: 18px;
  489. }
  490. .generalization_four_item .header{
  491. font-size: 22px;
  492. margin-bottom: 15px;
  493. }
  494. </style>