index.vue 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559
  1. <template>
  2. <div class="app-container">
  3. <div class="address-layout">
  4. <!-- <el-row :gutter="20">
  5. <el-col :span="6">
  6. <div class="out-border">
  7. <div class="layout-title">后台项目</div>
  8. <div class="color-main address-content">
  9. <a href="https://github.com/macrozheng/mall">mall</a>
  10. </div>
  11. </div>
  12. </el-col>
  13. <el-col :span="6">
  14. <div class="out-border">
  15. <div class="layout-title">前端项目</div>
  16. <div class="color-main address-content">
  17. <a href="https://github.com/macrozheng/mall-admin-web">mall-admin-web</a>
  18. </div>
  19. </div>
  20. </el-col>
  21. <el-col :span="6">
  22. <div class="out-border">
  23. <div class="layout-title">学习教程</div>
  24. <div class="color-main address-content">
  25. <a href="https://github.com/macrozheng/mall-learning">mall-learning</a>
  26. </div>
  27. </div>
  28. </el-col>
  29. </el-row> -->
  30. </div>
  31. <div class="total-layout">
  32. <el-row :gutter="20">
  33. <el-col :span="6">
  34. <div class="total-frame">
  35. <img :src="img_home_order" class="total-icon" />
  36. <div class="total-title">今日订单总数</div>
  37. <div class="total-value">{{ staticeDate.todayOrderNum }}</div>
  38. </div>
  39. </el-col>
  40. <el-col :span="6">
  41. <div class="total-frame">
  42. <img :src="img_home_today_amount" class="total-icon" />
  43. <div class="total-title">今日销售总额</div>
  44. <div class="total-value">¥{{ staticeDate.todayOrderAmount }}</div>
  45. </div>
  46. </el-col>
  47. <el-col :span="6">
  48. <div class="total-frame">
  49. <img :src="img_home_yesterday_amount" class="total-icon" />
  50. <div class="total-title">昨日销售总额</div>
  51. <div class="total-value">
  52. ¥{{ staticeDate.yesterdayOrderAmount }}
  53. </div>
  54. </div>
  55. </el-col>
  56. <!--<el-col :span="6">-->
  57. <!--<div class="total-frame">-->
  58. <!--<svg-icon icon-class="total-week" class="total-icon">-->
  59. <!--</svg-icon>-->
  60. <!--<div class="total-title">近7天销售总额</div>-->
  61. <!--<div class="total-value">¥50000.00</div>-->
  62. <!--</div>-->
  63. <!--</el-col>-->
  64. </el-row>
  65. </div>
  66. <div class="un-handle-layout">
  67. <div class="layout-title">待处理事务</div>
  68. <div class="un-handle-content">
  69. <el-row :gutter="20">
  70. <el-col :span="8">
  71. <div class="un-handle-item" @click="gotoOrder(0)">
  72. <span class="font-medium">待付款订单</span>
  73. <span style="float: right" class="color-danger"
  74. >({{ staticeDate.waitPayOrder }})</span
  75. >
  76. </div>
  77. </el-col>
  78. <el-col :span="8">
  79. <div class="un-handle-item" @click="gotoOrder(3)">
  80. <span class="font-medium">已完成订单</span>
  81. <span style="float: right" class="color-danger"
  82. >({{ staticeDate.successOrder }})</span
  83. >
  84. </div>
  85. </el-col>
  86. <el-col :span="8">
  87. <div class="un-handle-item" @click="gotoOrder(2)">
  88. <span class="font-medium">待确认收货订单</span>
  89. <span style="float: right" class="color-danger"
  90. >({{ staticeDate.waitReceiptOrder }})</span
  91. >
  92. </div>
  93. </el-col>
  94. </el-row>
  95. <el-row :gutter="20">
  96. <el-col :span="8">
  97. <div class="un-handle-item" @click="gotoOrder(1)">
  98. <span class="font-medium">待发货订单</span>
  99. <span style="float: right" class="color-danger"
  100. >({{ staticeDate.waitOutOrder }})</span
  101. >
  102. </div>
  103. </el-col>
  104. <el-col :span="8">
  105. <div class="un-handle-item" @click="gotoShop(1)">
  106. <span class="font-medium">缺货登记</span>
  107. <span style="float: right" class="color-danger"
  108. >({{ staticeDate.outStockProduct }})</span
  109. >
  110. </div>
  111. </el-col>
  112. <el-col :span="8">
  113. <!-- 待处理 -->
  114. <div class="un-handle-item" @click="gotoBack(0)">
  115. <span class="font-medium">待处理退款申请</span>
  116. <span style="float: right" class="color-danger"
  117. >({{ staticeDate.waitDisposeRefund }})</span
  118. >
  119. </div>
  120. </el-col>
  121. </el-row>
  122. <el-row :gutter="20">
  123. <el-col :span="8">
  124. <div class="un-handle-item" @click="gotoOrder(1)">
  125. <span class="font-medium">已发货订单</span>
  126. <span style="float: right" class="color-danger"
  127. >({{ staticeDate.outOrder }})</span
  128. >
  129. </div>
  130. </el-col>
  131. <el-col :span="8">
  132. <!-- 退货中 -->
  133. <div class="un-handle-item" @click="gotoBack(1)">
  134. <span class="font-medium">待处理退货订单</span>
  135. <span style="float: right" class="color-danger"
  136. >({{ staticeDate.waitDisposeRefundOrder }})</span
  137. >
  138. </div>
  139. </el-col>
  140. <!-- <el-col :span="8">
  141. <div class="un-handle-item">
  142. <span class="font-medium">广告位即将到期</span>
  143. <span style="float: right" class="color-danger">({{staticeDate.waitDisposeRefund}})</span>
  144. </div>
  145. </el-col> -->
  146. </el-row>
  147. </div>
  148. </div>
  149. <div class="overview-layout">
  150. <el-row :gutter="20">
  151. <el-col :span="24">
  152. <div class="out-border">
  153. <div class="layout-title">商品总览</div>
  154. <div style="padding: 40px">
  155. <el-row>
  156. <el-col :span="6" class="color-danger overview-item-value">{{
  157. staticeDate.delisted
  158. }}</el-col>
  159. <el-col :span="6" class="color-danger overview-item-value">{{
  160. staticeDate.shelves
  161. }}</el-col>
  162. <el-col :span="6" class="color-danger overview-item-value">{{
  163. staticeDate.outStock
  164. }}</el-col>
  165. <el-col :span="6" class="color-danger overview-item-value">{{
  166. staticeDate.productNum
  167. }}</el-col>
  168. </el-row>
  169. <el-row class="font-medium">
  170. <el-col :span="6" class="overview-item-title">已下架</el-col>
  171. <el-col :span="6" class="overview-item-title">已上架</el-col>
  172. <el-col :span="6" class="overview-item-title">库存紧张</el-col>
  173. <el-col :span="6" class="overview-item-title">全部商品</el-col>
  174. </el-row>
  175. </div>
  176. </div>
  177. </el-col>
  178. <!-- <el-col :span="12">
  179. <div class="out-border">
  180. <div class="layout-title">用户总览</div>
  181. <div style="padding: 40px">
  182. <el-row>
  183. <el-col :span="6" class="color-danger overview-item-value"
  184. >{{staticeDate.productNum}}</el-col
  185. >
  186. <el-col :span="6" class="color-danger overview-item-value"
  187. >{{staticeDate.productNum}}</el-col
  188. >
  189. <el-col :span="6" class="color-danger overview-item-value"
  190. >{{staticeDate.productNum}}</el-col
  191. >
  192. <el-col :span="6" class="color-danger overview-item-value"
  193. >{{staticeDate.productNum}}</el-col
  194. >
  195. </el-row>
  196. <el-row class="font-medium">
  197. <el-col :span="6" class="overview-item-title">今日新增</el-col>
  198. <el-col :span="6" class="overview-item-title">昨日新增</el-col>
  199. <el-col :span="6" class="overview-item-title">本月新增</el-col>
  200. <el-col :span="6" class="overview-item-title">会员总数</el-col>
  201. </el-row>
  202. </div>
  203. </div>
  204. </el-col> -->
  205. </el-row>
  206. </div>
  207. <div class="statistics-layout">
  208. <div class="layout-title">订单统计</div>
  209. <el-row>
  210. <el-col :span="4">
  211. <div style="padding: 20px">
  212. <div>
  213. <div style="color: #909399; font-size: 14px">本月订单总数</div>
  214. <div style="color: #606266; font-size: 24px; padding: 10px 0">
  215. {{orderStatistis.monthOrderCount}}
  216. </div>
  217. <div>
  218. <span class="color-success" style="font-size: 14px">{{orderStatistis.monthOrderCountProportion}}%</span>
  219. <span style="color: #c0c4cc; font-size: 14px">同比上月</span>
  220. </div>
  221. </div>
  222. <div style="margin-top: 20px">
  223. <div style="color: #909399; font-size: 14px">本周订单总数</div>
  224. <div style="color: #606266; font-size: 24px; padding: 10px 0">
  225. {{orderStatistis.weekOrderCount}}
  226. </div>
  227. <div>
  228. <span class="color-danger" style="font-size: 14px"> {{orderStatistis.weekOrderCountProportion}}%</span>
  229. <span style="color: #c0c4cc; font-size: 14px">同比上周</span>
  230. </div>
  231. </div>
  232. <div style="margin-top: 20px">
  233. <div style="color: #909399; font-size: 14px">本月销售总额</div>
  234. <div style="color: #606266; font-size: 24px; padding: 10px 0">
  235. {{orderStatistis.monthOrderAmount}}
  236. </div>
  237. <div>
  238. <span class="color-success" style="font-size: 14px"> {{orderStatistis.monthOrderAmountProportion}}%</span>
  239. <span style="color: #c0c4cc; font-size: 14px">同比上月</span>
  240. </div>
  241. </div>
  242. <div style="margin-top: 20px">
  243. <div style="color: #909399; font-size: 14px">本周销售总额</div>
  244. <div style="color: #606266; font-size: 24px; padding: 10px 0">
  245. {{orderStatistis.weekOrderAmount}}
  246. </div>
  247. <div>
  248. <span class="color-danger" style="font-size: 14px"> {{orderStatistis.weekOrderAmountProportion}}%</span>
  249. <span style="color: #c0c4cc; font-size: 14px">同比上周</span>
  250. </div>
  251. </div>
  252. </div>
  253. </el-col>
  254. <el-col :span="20">
  255. <div style="padding: 10px; border-left: 1px solid #dcdfe6">
  256. <el-date-picker
  257. style="float: right; z-index: 1"
  258. size="small"
  259. v-model="orderCountDate"
  260. type="daterange"
  261. align="right"
  262. unlink-panels
  263. range-separator="至"
  264. start-placeholder="开始日期"
  265. end-placeholder="结束日期"
  266. format="yyyy-MM-dd"
  267. value-format="yyyy-MM-dd"
  268. @change="handleDateChange"
  269. :picker-options="pickerOptions"
  270. :clearable="false"
  271. >
  272. </el-date-picker>
  273. <div>
  274. <ve-line
  275. :data="chartData"
  276. :legend-visible="false"
  277. :loading="loading"
  278. :data-empty="dataEmpty"
  279. :settings="chartSettings"
  280. ></ve-line>
  281. </div>
  282. </div>
  283. </el-col>
  284. </el-row>
  285. </div>
  286. </div>
  287. </template>
  288. <script>
  289. import { str2Date } from "@/utils/date";
  290. import dayjs from "dayjs";
  291. import img_home_order from "@/assets/images/home_order.png";
  292. import img_home_today_amount from "@/assets/images/home_today_amount.png";
  293. import img_home_yesterday_amount from "@/assets/images/home_yesterday_amount.png";
  294. import { getHomeStatistical, getOrderStatisticall } from "./api";
  295. export default {
  296. name: "home",
  297. data() {
  298. return {
  299. pickerOptions: {
  300. shortcuts: [
  301. {
  302. text: "最近一周",
  303. onClick(picker) {
  304. const start = dayjs(new Date())
  305. .add(-1, "week")
  306. .startOf("week")
  307. .add(1, "day")
  308. .valueOf();
  309. const end = dayjs(new Date())
  310. .add(-1, "week")
  311. .endOf("week")
  312. .add(1, "day")
  313. .valueOf();
  314. picker.$emit("pick", [new Date(start), new Date(end)]);
  315. },
  316. },
  317. {
  318. text: "最近一月",
  319. onClick(picker) {
  320. const start = dayjs(new Date()).startOf("month").valueOf();
  321. const end = dayjs(new Date()).valueOf();
  322. var now = dayjs().format("DD"); // 判断今天几号
  323. picker.$emit("pick", [new Date(start), new Date(end)]);
  324. },
  325. },
  326. ],
  327. },
  328. orderCountDate: "",
  329. chartSettings: {
  330. // xAxisType: "time",
  331. area: true,
  332. axisSite: { right: ["orderAmount"] },
  333. labelMap: { orderNum: "订单数量", orderAmount: "订单金额" },
  334. },
  335. chartData: {
  336. columns: [],
  337. rows: [],
  338. },
  339. loading: false,
  340. dataEmpty: false,
  341. img_home_order,
  342. img_home_today_amount,
  343. img_home_yesterday_amount,
  344. staticeDate: {
  345. delisted: 0,
  346. outOrder: 0,
  347. outStock: 0,
  348. outStockProduct: 0,
  349. productNum: 0,
  350. shelves: 0,
  351. successOrder: 0,
  352. todayOrderAmount: 0,
  353. todayOrderNum: 0,
  354. waitDisposeRefund: 0,
  355. waitDisposeRefundOrder: 0,
  356. waitOutOrder: 0,
  357. waitPayOrder: 0,
  358. waitReceiptOrder: 0,
  359. yesterdayOrderAmount: 0,
  360. yesterdayOrderNum: 0,
  361. },
  362. orderStatistis: {
  363. monthOrderAmount: 0,
  364. monthOrderAmountProportion: 0,
  365. monthOrderCount: 0,
  366. monthOrderCountProportion: 0,
  367. orderStatisticalList: [],
  368. weekOrderAmount: 0,
  369. weekOrderAmountProportion: 0,
  370. weekOrderCount: 0,
  371. weekOrderCountProportion: 0,
  372. },
  373. };
  374. },
  375. created() {
  376. this.initOrderCountDate();
  377. this.getData();
  378. },
  379. mounted() {
  380. this.getHomeStatisticalDate();
  381. },
  382. methods: {
  383. async getHomeStatisticalDate() {
  384. try {
  385. const res = await getHomeStatistical();
  386. this.staticeDate = { ...res.data };
  387. } catch (e) {
  388. console.log(e);
  389. }
  390. },
  391. handleDateChange() {
  392. this.getData();
  393. },
  394. initOrderCountDate() {
  395. let start = new Date();
  396. // start.setFullYear(2018);
  397. // start.setMonth(10);
  398. start.setDate(1);
  399. start = dayjs(start).format("YYYY-MM-DD");
  400. const end = dayjs(new Date()).format("YYYY-MM-DD");
  401. // end.setTime(start.getTime() + 1000 * 60 * 60 * 24 * 7);
  402. this.orderCountDate = [start, end];
  403. },
  404. async getData() {
  405. try {
  406. const res = await getOrderStatisticall({
  407. startDate: this.orderCountDate[0],
  408. endDate: this.orderCountDate[1],
  409. });
  410. this.orderStatistis = {...res.data}
  411. this.chartData = {
  412. columns: ["date", "orderNum", "orderAmount"],
  413. rows: [],
  414. };
  415. for (let i = 0; i < this.orderStatistis.orderStatisticalList.length; i++) {
  416. let item = this.orderStatistis.orderStatisticalList[i];
  417. this.chartData.rows.push(item);
  418. }
  419. this.dataEmpty = false;
  420. this.loading = false;
  421. } catch (e) {
  422. console.log(e);
  423. }
  424. // setTimeout(() => {
  425. // this.chartData = {
  426. // columns: ["date", "orderCount", "orderAmount"],
  427. // rows: [],
  428. // };
  429. // for (let i = 0; i < DATA_FROM_BACKEND.rows.length; i++) {
  430. // let item = DATA_FROM_BACKEND.rows[i];
  431. // let currDate = str2Date(item.date);
  432. // let start = this.orderCountDate[0];
  433. // let end = this.orderCountDate[1];
  434. // if (
  435. // currDate.getTime() >= start.getTime() &&
  436. // currDate.getTime() <= end.getTime()
  437. // ) {
  438. // this.chartData.rows.push(item);
  439. // }
  440. // }
  441. // this.dataEmpty = false;
  442. // this.loading = false;
  443. // }, 1000);
  444. },
  445. gotoOrder(status){
  446. this.$router.push({name:'order',params:{status}})
  447. },
  448. gotoShop(status){
  449. this.$router.push({name:'product',params:{stock:status}})
  450. },
  451. gotoBack(status){
  452. this.$router.push({name:'returnApply',params:{status}})
  453. }
  454. },
  455. };
  456. </script>
  457. <style scoped>
  458. .app-container {
  459. margin-top: 40px;
  460. margin-left: 120px;
  461. margin-right: 120px;
  462. }
  463. .address-layout {
  464. }
  465. .total-layout {
  466. margin-top: 20px;
  467. }
  468. .total-frame {
  469. border: 1px solid #dcdfe6;
  470. padding: 20px;
  471. height: 100px;
  472. }
  473. .total-icon {
  474. color: #409eff;
  475. width: 60px;
  476. height: 60px;
  477. }
  478. .total-title {
  479. position: relative;
  480. font-size: 16px;
  481. color: #909399;
  482. left: 70px;
  483. top: -50px;
  484. }
  485. .total-value {
  486. position: relative;
  487. font-size: 18px;
  488. color: #606266;
  489. left: 70px;
  490. top: -40px;
  491. }
  492. .un-handle-layout {
  493. margin-top: 20px;
  494. border: 1px solid #dcdfe6;
  495. }
  496. .layout-title {
  497. color: #606266;
  498. padding: 15px 20px;
  499. background: #f2f6fc;
  500. font-weight: bold;
  501. }
  502. .un-handle-content {
  503. padding: 20px 40px;
  504. }
  505. .un-handle-item {
  506. cursor: pointer;
  507. border-bottom: 1px solid #ebeef5;
  508. padding: 10px;
  509. }
  510. .overview-layout {
  511. margin-top: 20px;
  512. }
  513. .overview-item-value {
  514. font-size: 24px;
  515. text-align: center;
  516. }
  517. .overview-item-title {
  518. margin-top: 10px;
  519. text-align: center;
  520. }
  521. .out-border {
  522. border: 1px solid #dcdfe6;
  523. }
  524. .statistics-layout {
  525. margin-top: 20px;
  526. border: 1px solid #dcdfe6;
  527. }
  528. .mine-layout {
  529. position: absolute;
  530. right: 140px;
  531. top: 107px;
  532. width: 250px;
  533. height: 235px;
  534. }
  535. .address-content {
  536. padding: 20px;
  537. font-size: 18px;
  538. }
  539. </style>