123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559 |
- <template>
- <div class="app-container">
- <div class="address-layout">
- <!-- <el-row :gutter="20">
- <el-col :span="6">
- <div class="out-border">
- <div class="layout-title">后台项目</div>
- <div class="color-main address-content">
- <a href="https://github.com/macrozheng/mall">mall</a>
- </div>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="out-border">
- <div class="layout-title">前端项目</div>
- <div class="color-main address-content">
- <a href="https://github.com/macrozheng/mall-admin-web">mall-admin-web</a>
- </div>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="out-border">
- <div class="layout-title">学习教程</div>
- <div class="color-main address-content">
- <a href="https://github.com/macrozheng/mall-learning">mall-learning</a>
- </div>
- </div>
- </el-col>
- </el-row> -->
- </div>
- <div class="total-layout">
- <el-row :gutter="20">
- <el-col :span="6">
- <div class="total-frame">
- <img :src="img_home_order" class="total-icon" />
- <div class="total-title">今日订单总数</div>
- <div class="total-value">{{ staticeDate.todayOrderNum }}</div>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="total-frame">
- <img :src="img_home_today_amount" class="total-icon" />
- <div class="total-title">今日销售总额</div>
- <div class="total-value">¥{{ staticeDate.todayOrderAmount }}</div>
- </div>
- </el-col>
- <el-col :span="6">
- <div class="total-frame">
- <img :src="img_home_yesterday_amount" class="total-icon" />
- <div class="total-title">昨日销售总额</div>
- <div class="total-value">
- ¥{{ staticeDate.yesterdayOrderAmount }}
- </div>
- </div>
- </el-col>
- <!--<el-col :span="6">-->
- <!--<div class="total-frame">-->
- <!--<svg-icon icon-class="total-week" class="total-icon">-->
- <!--</svg-icon>-->
- <!--<div class="total-title">近7天销售总额</div>-->
- <!--<div class="total-value">¥50000.00</div>-->
- <!--</div>-->
- <!--</el-col>-->
- </el-row>
- </div>
- <div class="un-handle-layout">
- <div class="layout-title">待处理事务</div>
- <div class="un-handle-content">
- <el-row :gutter="20">
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoOrder(0)">
- <span class="font-medium">待付款订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.waitPayOrder }})</span
- >
- </div>
- </el-col>
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoOrder(3)">
- <span class="font-medium">已完成订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.successOrder }})</span
- >
- </div>
- </el-col>
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoOrder(2)">
- <span class="font-medium">待确认收货订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.waitReceiptOrder }})</span
- >
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoOrder(1)">
- <span class="font-medium">待发货订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.waitOutOrder }})</span
- >
- </div>
- </el-col>
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoShop(1)">
- <span class="font-medium">缺货登记</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.outStockProduct }})</span
- >
- </div>
- </el-col>
- <el-col :span="8">
- <!-- 待处理 -->
- <div class="un-handle-item" @click="gotoBack(0)">
- <span class="font-medium">待处理退款申请</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.waitDisposeRefund }})</span
- >
- </div>
- </el-col>
- </el-row>
- <el-row :gutter="20">
- <el-col :span="8">
- <div class="un-handle-item" @click="gotoOrder(1)">
- <span class="font-medium">已发货订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.outOrder }})</span
- >
- </div>
- </el-col>
- <el-col :span="8">
- <!-- 退货中 -->
- <div class="un-handle-item" @click="gotoBack(1)">
- <span class="font-medium">待处理退货订单</span>
- <span style="float: right" class="color-danger"
- >({{ staticeDate.waitDisposeRefundOrder }})</span
- >
- </div>
- </el-col>
- <!-- <el-col :span="8">
- <div class="un-handle-item">
- <span class="font-medium">广告位即将到期</span>
- <span style="float: right" class="color-danger">({{staticeDate.waitDisposeRefund}})</span>
- </div>
- </el-col> -->
- </el-row>
- </div>
- </div>
- <div class="overview-layout">
- <el-row :gutter="20">
- <el-col :span="24">
- <div class="out-border">
- <div class="layout-title">商品总览</div>
- <div style="padding: 40px">
- <el-row>
- <el-col :span="6" class="color-danger overview-item-value">{{
- staticeDate.delisted
- }}</el-col>
- <el-col :span="6" class="color-danger overview-item-value">{{
- staticeDate.shelves
- }}</el-col>
- <el-col :span="6" class="color-danger overview-item-value">{{
- staticeDate.outStock
- }}</el-col>
- <el-col :span="6" class="color-danger overview-item-value">{{
- staticeDate.productNum
- }}</el-col>
- </el-row>
- <el-row class="font-medium">
- <el-col :span="6" class="overview-item-title">已下架</el-col>
- <el-col :span="6" class="overview-item-title">已上架</el-col>
- <el-col :span="6" class="overview-item-title">库存紧张</el-col>
- <el-col :span="6" class="overview-item-title">全部商品</el-col>
- </el-row>
- </div>
- </div>
- </el-col>
- <!-- <el-col :span="12">
- <div class="out-border">
- <div class="layout-title">用户总览</div>
- <div style="padding: 40px">
- <el-row>
- <el-col :span="6" class="color-danger overview-item-value"
- >{{staticeDate.productNum}}</el-col
- >
- <el-col :span="6" class="color-danger overview-item-value"
- >{{staticeDate.productNum}}</el-col
- >
- <el-col :span="6" class="color-danger overview-item-value"
- >{{staticeDate.productNum}}</el-col
- >
- <el-col :span="6" class="color-danger overview-item-value"
- >{{staticeDate.productNum}}</el-col
- >
- </el-row>
- <el-row class="font-medium">
- <el-col :span="6" class="overview-item-title">今日新增</el-col>
- <el-col :span="6" class="overview-item-title">昨日新增</el-col>
- <el-col :span="6" class="overview-item-title">本月新增</el-col>
- <el-col :span="6" class="overview-item-title">会员总数</el-col>
- </el-row>
- </div>
- </div>
- </el-col> -->
- </el-row>
- </div>
- <div class="statistics-layout">
- <div class="layout-title">订单统计</div>
- <el-row>
- <el-col :span="4">
- <div style="padding: 20px">
- <div>
- <div style="color: #909399; font-size: 14px">本月订单总数</div>
- <div style="color: #606266; font-size: 24px; padding: 10px 0">
- {{orderStatistis.monthOrderCount}}
- </div>
- <div>
- <span class="color-success" style="font-size: 14px">{{orderStatistis.monthOrderCountProportion}}%</span>
- <span style="color: #c0c4cc; font-size: 14px">同比上月</span>
- </div>
- </div>
- <div style="margin-top: 20px">
- <div style="color: #909399; font-size: 14px">本周订单总数</div>
- <div style="color: #606266; font-size: 24px; padding: 10px 0">
- {{orderStatistis.weekOrderCount}}
- </div>
- <div>
- <span class="color-danger" style="font-size: 14px"> {{orderStatistis.weekOrderCountProportion}}%</span>
- <span style="color: #c0c4cc; font-size: 14px">同比上周</span>
- </div>
- </div>
- <div style="margin-top: 20px">
- <div style="color: #909399; font-size: 14px">本月销售总额</div>
- <div style="color: #606266; font-size: 24px; padding: 10px 0">
- {{orderStatistis.monthOrderAmount}}
- </div>
- <div>
- <span class="color-success" style="font-size: 14px"> {{orderStatistis.monthOrderAmountProportion}}%</span>
- <span style="color: #c0c4cc; font-size: 14px">同比上月</span>
- </div>
- </div>
- <div style="margin-top: 20px">
- <div style="color: #909399; font-size: 14px">本周销售总额</div>
- <div style="color: #606266; font-size: 24px; padding: 10px 0">
- {{orderStatistis.weekOrderAmount}}
- </div>
- <div>
- <span class="color-danger" style="font-size: 14px"> {{orderStatistis.weekOrderAmountProportion}}%</span>
- <span style="color: #c0c4cc; font-size: 14px">同比上周</span>
- </div>
- </div>
- </div>
- </el-col>
- <el-col :span="20">
- <div style="padding: 10px; border-left: 1px solid #dcdfe6">
- <el-date-picker
- style="float: right; z-index: 1"
- size="small"
- v-model="orderCountDate"
- type="daterange"
- align="right"
- unlink-panels
- range-separator="至"
- start-placeholder="开始日期"
- end-placeholder="结束日期"
- format="yyyy-MM-dd"
- value-format="yyyy-MM-dd"
- @change="handleDateChange"
- :picker-options="pickerOptions"
- :clearable="false"
- >
- </el-date-picker>
- <div>
- <ve-line
- :data="chartData"
- :legend-visible="false"
- :loading="loading"
- :data-empty="dataEmpty"
- :settings="chartSettings"
- ></ve-line>
- </div>
- </div>
- </el-col>
- </el-row>
- </div>
- </div>
- </template>
- <script>
- import { str2Date } from "@/utils/date";
- import dayjs from "dayjs";
- import img_home_order from "@/assets/images/home_order.png";
- import img_home_today_amount from "@/assets/images/home_today_amount.png";
- import img_home_yesterday_amount from "@/assets/images/home_yesterday_amount.png";
- import { getHomeStatistical, getOrderStatisticall } from "./api";
- export default {
- name: "home",
- data() {
- return {
- pickerOptions: {
- shortcuts: [
- {
- text: "最近一周",
- onClick(picker) {
- const start = dayjs(new Date())
- .add(-1, "week")
- .startOf("week")
- .add(1, "day")
- .valueOf();
- const end = dayjs(new Date())
- .add(-1, "week")
- .endOf("week")
- .add(1, "day")
- .valueOf();
- picker.$emit("pick", [new Date(start), new Date(end)]);
- },
- },
- {
- text: "最近一月",
- onClick(picker) {
- const start = dayjs(new Date()).startOf("month").valueOf();
- const end = dayjs(new Date()).valueOf();
- var now = dayjs().format("DD"); // 判断今天几号
- picker.$emit("pick", [new Date(start), new Date(end)]);
- },
- },
- ],
- },
- orderCountDate: "",
- chartSettings: {
- // xAxisType: "time",
- area: true,
- axisSite: { right: ["orderAmount"] },
- labelMap: { orderNum: "订单数量", orderAmount: "订单金额" },
- },
- chartData: {
- columns: [],
- rows: [],
- },
- loading: false,
- dataEmpty: false,
- img_home_order,
- img_home_today_amount,
- img_home_yesterday_amount,
- staticeDate: {
- delisted: 0,
- outOrder: 0,
- outStock: 0,
- outStockProduct: 0,
- productNum: 0,
- shelves: 0,
- successOrder: 0,
- todayOrderAmount: 0,
- todayOrderNum: 0,
- waitDisposeRefund: 0,
- waitDisposeRefundOrder: 0,
- waitOutOrder: 0,
- waitPayOrder: 0,
- waitReceiptOrder: 0,
- yesterdayOrderAmount: 0,
- yesterdayOrderNum: 0,
- },
- orderStatistis: {
- monthOrderAmount: 0,
- monthOrderAmountProportion: 0,
- monthOrderCount: 0,
- monthOrderCountProportion: 0,
- orderStatisticalList: [],
- weekOrderAmount: 0,
- weekOrderAmountProportion: 0,
- weekOrderCount: 0,
- weekOrderCountProportion: 0,
- },
- };
- },
- created() {
- this.initOrderCountDate();
- this.getData();
- },
- mounted() {
- this.getHomeStatisticalDate();
- },
- methods: {
- async getHomeStatisticalDate() {
- try {
- const res = await getHomeStatistical();
- this.staticeDate = { ...res.data };
- } catch (e) {
- console.log(e);
- }
- },
- handleDateChange() {
- this.getData();
- },
- initOrderCountDate() {
- let start = new Date();
- // start.setFullYear(2018);
- // start.setMonth(10);
- start.setDate(1);
- start = dayjs(start).format("YYYY-MM-DD");
- const end = dayjs(new Date()).format("YYYY-MM-DD");
- // end.setTime(start.getTime() + 1000 * 60 * 60 * 24 * 7);
- this.orderCountDate = [start, end];
- },
- async getData() {
- try {
- const res = await getOrderStatisticall({
- startDate: this.orderCountDate[0],
- endDate: this.orderCountDate[1],
- });
- this.orderStatistis = {...res.data}
- this.chartData = {
- columns: ["date", "orderNum", "orderAmount"],
- rows: [],
- };
- for (let i = 0; i < this.orderStatistis.orderStatisticalList.length; i++) {
- let item = this.orderStatistis.orderStatisticalList[i];
- this.chartData.rows.push(item);
- }
- this.dataEmpty = false;
- this.loading = false;
- } catch (e) {
- console.log(e);
- }
- // setTimeout(() => {
- // this.chartData = {
- // columns: ["date", "orderCount", "orderAmount"],
- // rows: [],
- // };
- // for (let i = 0; i < DATA_FROM_BACKEND.rows.length; i++) {
- // let item = DATA_FROM_BACKEND.rows[i];
- // let currDate = str2Date(item.date);
- // let start = this.orderCountDate[0];
- // let end = this.orderCountDate[1];
- // if (
- // currDate.getTime() >= start.getTime() &&
- // currDate.getTime() <= end.getTime()
- // ) {
- // this.chartData.rows.push(item);
- // }
- // }
- // this.dataEmpty = false;
- // this.loading = false;
- // }, 1000);
- },
- gotoOrder(status){
- this.$router.push({name:'order',params:{status}})
- },
- gotoShop(status){
- this.$router.push({name:'product',params:{stock:status}})
- },
- gotoBack(status){
- this.$router.push({name:'returnApply',params:{status}})
- }
- },
- };
- </script>
- <style scoped>
- .app-container {
- margin-top: 40px;
- margin-left: 120px;
- margin-right: 120px;
- }
- .address-layout {
- }
- .total-layout {
- margin-top: 20px;
- }
- .total-frame {
- border: 1px solid #dcdfe6;
- padding: 20px;
- height: 100px;
- }
- .total-icon {
- color: #409eff;
- width: 60px;
- height: 60px;
- }
- .total-title {
- position: relative;
- font-size: 16px;
- color: #909399;
- left: 70px;
- top: -50px;
- }
- .total-value {
- position: relative;
- font-size: 18px;
- color: #606266;
- left: 70px;
- top: -40px;
- }
- .un-handle-layout {
- margin-top: 20px;
- border: 1px solid #dcdfe6;
- }
- .layout-title {
- color: #606266;
- padding: 15px 20px;
- background: #f2f6fc;
- font-weight: bold;
- }
- .un-handle-content {
- padding: 20px 40px;
- }
- .un-handle-item {
- cursor: pointer;
- border-bottom: 1px solid #ebeef5;
- padding: 10px;
- }
- .overview-layout {
- margin-top: 20px;
- }
- .overview-item-value {
- font-size: 24px;
- text-align: center;
- }
- .overview-item-title {
- margin-top: 10px;
- text-align: center;
- }
- .out-border {
- border: 1px solid #dcdfe6;
- }
- .statistics-layout {
- margin-top: 20px;
- border: 1px solid #dcdfe6;
- }
- .mine-layout {
- position: absolute;
- right: 140px;
- top: 107px;
- width: 250px;
- height: 235px;
- }
- .address-content {
- padding: 20px;
- font-size: 18px;
- }
- </style>
|