【类 型】:factor 销售统计模块

【原  因】:
【过  程】:1.调整按需加载2.按选择条件日 月 年 分为三个 异步加载搜索内容 3.调整ui 包裹手机端竖屏自适应 4.点击跳转到订单管理页面,跳转前设置订单全局搜索条件
【影  响】:
This commit is contained in:
tk 2024-08-06 16:00:15 +08:00
parent 0fba1af61b
commit 5abd57755e
2 changed files with 339 additions and 236 deletions

View File

@ -42,11 +42,6 @@
<el-table-column prop="controler" label="操作"> <el-table-column prop="controler" label="操作">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button-group> <el-button-group>
<!-- 已付款 未接单 -->
<!-- <template v-if="scope.row.main_status === '已付款' && scope.row.shipment_status === '未接单'">
<el-button type="danger" icon="el-icon-delete">取消订单</el-button>
<el-button type="primary" icon="el-icon-search">确认接单</el-button>
</template> -->
<el-button type="success" icon="el-icon-search" <el-button type="success" icon="el-icon-search"
@click="$router.replace(`/order/show/${scope.row.id}`)">查看</el-button> @click="$router.replace(`/order/show/${scope.row.id}`)">查看</el-button>
</el-button-group> </el-button-group>

View File

@ -1,25 +1,23 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<!-- 用户select选项 --> <!-- 用户select选项 -->
<el-row :gutter="15" class="m-t-0"> <SelectionShopId class="w-40" v-model="shop_id" :allSel="true" />
<el-col :span="4">
<SelectionShopId class="w-100" v-model="shop_id" :allSel="true" />
</el-col>
</el-row>
<!-- 统计标签 --> <!-- 统计标签 -->
<el-row :gutter="10" class="m-t-20"> <el-row :gutter="10" class="m-t-20">
<!-- 日统计标签 --> <!-- 日统计标签 -->
<!-- <el-col :span="8"> <el-col :span="8" :xs="24" v-loading="dayBoxLoading" class="m-b-10">
<div class="dayStatBox rad4 flex p-10 column"> <div class="dayStatBox rad4 flex p-10 column" @click="handlerRouteCilck('day')">
<el-date-picker class="w-100" v-model="dayTime" align="right" type="date" placeholder="今日" <div @click.stop>
:picker-options="dayPickerOptions" /> <el-date-picker class="w-100" v-model="dayTime" align="right" type="date" placeholder="今日"
:picker-options="dayPickerOptions" />
</div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="flex3 flex mc column"> <div class="flex3 flex mc column">
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-b fb fc">营业额</div> <div class="p-4 bg-white rad2 fc-b fb fc">营业额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ dayPaidTotal }}</div> <div class="p-4 m-l-5 fr">{{ dayPaidTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
@ -31,7 +29,7 @@
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-b fb fc">退款额</div> <div class="p-4 bg-white rad2 fc-b fb fc">退款额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ dayRefundTotal }}</div> <div class="p-4 m-l-5 fr">{{ dayRefundTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
@ -45,37 +43,39 @@
</div> </div>
</div> </div>
</div> </div>
</el-col> --> </el-col>
<!-- 月统计标签 --> <!-- 月统计标签 -->
<!-- <el-col :span="8"> <el-col :span="8" :xs="24" v-loading="monthBoxLoading" class="m-b-10">
<div class="monthStatBox rad4 flex p-10 column"> <div class="monthStatBox rad4 flex p-10 column" @click="handlerRouteCilck('month')">
<el-date-picker class="w-100" v-model="monthTime" align="right" type="month" placeholder="本月" <div @click.stop>
:picker-options="monthPickerOptions" /> <el-date-picker class="w-100" v-model="monthTime" align="right" type="month" placeholder="本月"
:picker-options="monthPickerOptions" />
</div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="flex3 flex mc column"> <div class="flex3 flex mc column">
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-s fb fc">营业额</div> <div class="p-4 bg-white rad2 fc-s fb fc">营业额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ 23441.44 }}</div> <div class="p-4 m-l-5 fr">{{ monthPaidTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-s fb fc">收款单</div> <div class="p-4 bg-white rad2 fc-s fb fc">收款单</div>
</div> </div>
<div class="p-4 m-l-5 fr">18</div> <div class="p-4 m-l-5 fr">{{ monthPaid.length }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-s fb fc">退款额</div> <div class="p-4 bg-white rad2 fc-s fb fc">退款额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ 23441.44 }}</div> <div class="p-4 m-l-5 fr">{{ monthRefundTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-s fb fc">已退单</div> <div class="p-4 bg-white rad2 fc-s fb fc">已退单</div>
</div> </div>
<div class="p-4 m-l-5 fr">18</div> <div class="p-4 m-l-5 fr">{{ monthRefund.length }}</div>
</div> </div>
</div> </div>
<div class="flex1 flex mc mac ofh"> <div class="flex1 flex mc mac ofh">
@ -83,37 +83,39 @@
</div> </div>
</div> </div>
</div> </div>
</el-col> --> </el-col>
<!-- 年统计标签 --> <!-- 年统计标签 -->
<!-- <el-col :span="8"> <el-col :span="8" :xs="24" v-loading="yearBoxLoading" class="m-b-10">
<div class="yearStatBox rad4 flex p-10 column"> <div class="yearStatBox rad4 flex p-10 column" @click="handlerRouteCilck('year')">
<el-date-picker class="w-100" v-model="yearTime" align="right" type="year" placeholder="本年" <div @click.stop>
:picker-options="yearPickerOptions" /> <el-date-picker class="w-100" v-model="yearTime" align="right" type="year" placeholder="本年"
:picker-options="yearPickerOptions" />
</div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="flex3 flex mc column"> <div class="flex3 flex mc column">
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-w fb fc">营业额</div> <div class="p-4 bg-white rad2 fc-w fb fc">营业额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ 23441.44 }}</div> <div class="p-4 m-l-5 fr">{{ yearPaidTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-w fb fc">收款单</div> <div class="p-4 bg-white rad2 fc-w fb fc">收款单</div>
</div> </div>
<div class="p-4 m-l-5 fr">18</div> <div class="p-4 m-l-5 fr">{{ yearPaid.length }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-w fb fc">退款额</div> <div class="p-4 bg-white rad2 fc-w fb fc">退款额</div>
</div> </div>
<div class="p-4 m-l-5 fr">{{ 23441.44 }}</div> <div class="p-4 m-l-5 fr">{{ yearRefundTotal }}</div>
</div> </div>
<div class="flex m-t-5"> <div class="flex m-t-5">
<div class="w-40 flex ml p-l-5 p-r-5"> <div class="w-40 flex ml p-l-5 p-r-5">
<div class="p-4 bg-white rad2 fc-w fb fc">已退单</div> <div class="p-4 bg-white rad2 fc-w fb fc">已退单</div>
</div> </div>
<div class="p-4 m-l-5 fr">18</div> <div class="p-4 m-l-5 fr">{{ yearRefund.length }}</div>
</div> </div>
</div> </div>
<div class="flex1 flex mc mac ofh"> <div class="flex1 flex mc mac ofh">
@ -121,14 +123,14 @@
</div> </div>
</div> </div>
</div> </div>
</el-col> --> </el-col>
</el-row> </el-row>
</div> </div>
</template> </template>
<script> <script>
import SelectionShopId from '@/components/SelectionShopId.vue' import SelectionShopId from '@/components/SelectionShopId.vue'
// import { formatPrice } from '@/utils' import { formatPrice } from '@/utils'
import { getOrderList } from '@/utils/api/table' import { getOrderList } from '@/utils/api/table'
export default { export default {
@ -136,223 +138,329 @@ export default {
data () { data () {
return { return {
shop_id: '', // id shop_id: '', // id
dayOrderList: [] // dayOrderList: [], //
// // monthOrderList: [], //
// dayPickerOptions: { yearOrderList: [], //
// disabledDate (time) {
// return time.getTime() > Date.now()
// },
// shortcuts: [{
// text: '',
// onClick (picker) {
// const start = new Date()
// start.setHours(0, 0, 0, 0)
// picker.$emit('pick', start)
// }
// }, {
// text: '',
// onClick (picker) {
// const start = new Date()
// start.setDate(start.getDate() - 1)
// start.setHours(0, 0, 0, 0)
// picker.$emit('pick', start)
// }
// }, {
// text: '',
// onClick (picker) {
// const start = new Date()
// start.setDate(start.getDate() - 2)
// start.setHours(0, 0, 0, 0)
// picker.$emit('pick', start)
// }
// }]
// },
// dayTime: new Date(), //
// monthPickerOptions: { dayBoxLoading: true, //
// disabledDate (time) { monthBoxLoading: true, //
// return time.getTime() > Date.now() yearBoxLoading: true, //
// },
// shortcuts: [{ //
// text: '', dayPickerOptions: {
// onClick (picker) { disabledDate (time) {
// const start = new Date() return time.getTime() > Date.now()
// start.setDate(1) },
// start.setHours(0, 0, 0, 0) shortcuts: [{
// picker.$emit('pick', start) text: '今天',
// } onClick (picker) {
// }, { const start = new Date()
// text: '', start.setHours(0, 0, 0, 0)
// onClick (picker) { picker.$emit('pick', start)
// const start = new Date() }
// start.setMonth(start.getMonth() - 1) }, {
// start.setDate(1) text: '昨天',
// start.setHours(0, 0, 0, 0) onClick (picker) {
// picker.$emit('pick', start) const start = new Date()
// } start.setDate(start.getDate() - 1)
// }, { start.setHours(0, 0, 0, 0)
// text: '', picker.$emit('pick', start)
// onClick (picker) { }
// const start = new Date() }, {
// start.setMonth(start.getMonth() - 2) text: '前天',
// start.setDate(1) onClick (picker) {
// start.setHours(0, 0, 0, 0) const start = new Date()
// picker.$emit('pick', start) start.setDate(start.getDate() - 2)
// } start.setHours(0, 0, 0, 0)
// }] picker.$emit('pick', start)
// }, }
// monthTime: new Date(), // }]
// yearPickerOptions: { },
// disabledDate (time) { dayTime: new Date(), //
// return time.getTime() > Date.now()
// }, monthPickerOptions: {
// shortcuts: [{ disabledDate (time) {
// text: '', return time.getTime() > Date.now()
// onClick (picker) { },
// const start = new Date() shortcuts: [{
// start.setMonth(0) text: '本月',
// start.setDate(1) onClick (picker) {
// start.setHours(0, 0, 0, 0) const start = new Date()
// picker.$emit('pick', start) start.setDate(1)
// } start.setHours(0, 0, 0, 0)
// }, { picker.$emit('pick', start)
// text: '', }
// onClick (picker) { }, {
// const start = new Date() text: '上月',
// start.setFullYear(start.getFullYear() - 1) onClick (picker) {
// start.setMonth(0) const start = new Date()
// start.setDate(1) start.setMonth(start.getMonth() - 1)
// start.setHours(0, 0, 0, 0) start.setDate(1)
// picker.$emit('pick', start) start.setHours(0, 0, 0, 0)
// } picker.$emit('pick', start)
// }, { }
// text: '', }, {
// onClick (picker) { text: '前月',
// const start = new Date() onClick (picker) {
// start.setFullYear(start.getFullYear() - 2) const start = new Date()
// start.setMonth(0) start.setMonth(start.getMonth() - 2)
// start.setDate(1) start.setDate(1)
// start.setHours(0, 0, 0, 0) start.setHours(0, 0, 0, 0)
// picker.$emit('pick', start) picker.$emit('pick', start)
// } }
// }] }]
// }, },
// yearTime: new Date() // monthTime: new Date(), //
yearPickerOptions: {
disabledDate (time) {
return time.getTime() > Date.now()
},
shortcuts: [{
text: '本年',
onClick (picker) {
const start = new Date()
start.setMonth(0)
start.setDate(1)
start.setHours(0, 0, 0, 0)
picker.$emit('pick', start)
}
}, {
text: '去年',
onClick (picker) {
const start = new Date()
start.setFullYear(start.getFullYear() - 1)
start.setMonth(0)
start.setDate(1)
start.setHours(0, 0, 0, 0)
picker.$emit('pick', start)
}
}, {
text: '前年',
onClick (picker) {
const start = new Date()
start.setFullYear(start.getFullYear() - 2)
start.setMonth(0)
start.setDate(1)
start.setHours(0, 0, 0, 0)
picker.$emit('pick', start)
}
}]
},
yearTime: new Date() //
} }
}, },
components: { components: {
SelectionShopId SelectionShopId
}, },
computed: { computed: {
/** //
* @description: 搜索条件 集合 dayTimestamps () {
*/ if (!this.dayTime) {
orderSerch () { return { start: null, end: null }
return this.$store.getters['app/getOrderSerch'] }
} const start = new Date(this.dayTime)
// // start.setHours(0, 0, 0, 0)
// monthOrderList () { const end = new Date(this.dayTime)
// return this.$store.state.orderList.filter(item => Number(item.order_time) > Number(this.monthTimestamps.start) && Number(item.order_time) < Number(this.monthTimestamps.end)) end.setHours(23, 59, 59, 999)
// }, return {
// // start: Math.floor(start.getTime() / 1000), //
// yearOrderList () { end: Math.floor(end.getTime() / 1000) //
// return this.$store.state.orderList.filter(item => Number(item.order_time) > Number(this.yearTimestamps.start) && Number(item.order_time) < Number(this.yearTimestamps.end)) }
// }, },
//
dayOrderSerch () {
return {
shop_id: this.shop_id, // id
start_time: Math.floor(this.dayTimestamps.start), //
end_time: Math.floor(this.dayTimestamps.end), //
main_status: ['已付款', '已退款', '已完成'], //
shipment_status: [], //
refund_status: [], // 退
search: ['orderSn', '']//
}
},
// //
// dayPaid () { dayPaid () {
// return this.dayOrderList.filter(item => item.main_status === '' || item.main_status === '') return this.dayOrderList
// }, },
// // //
// dayPaidTotal () { dayPaidTotal () {
// return this.dayPaid.reduce((total, item) => total + Number(item.total_price), 0).toFixed(2) return formatPrice(this.dayPaid.reduce((total, item) => total + Number(item.total_price) - Number(item.refund_price), 0))
// }, },
// // 退 // 退
// dayRefund () { dayRefund () {
// return this.dayOrderList.filter(item => item.main_status === '退') return this.dayOrderList.filter(item => item.main_status === '已退款')
// }, },
// // 退 // 退
// dayRefundTotal () { dayRefundTotal () {
// return this.dayRefund.reduce((total, item) => total + Number(item.refund_price), 0).toFixed(2) return formatPrice(this.dayRefund.reduce((total, item) => total + Number(item.refund_price), 0))
// }, },
// // //
// dayTimestamps () { monthTimestamps () {
// if (!this.dayTime) { if (!this.monthTime) {
// return { start: null, end: null } return { start: null, end: null }
// } }
// const start = new Date(this.dayTime) const start = new Date(this.monthTime)
// start.setHours(0, 0, 0, 0) start.setDate(1)
// const end = new Date(this.dayTime) start.setHours(0, 0, 0, 0)
// end.setHours(23, 59, 59, 999) const end = new Date(this.monthTime)
// return { end.setMonth(end.getMonth() + 1)
// start: Math.floor(start.getTime() / 1000), // end.setDate(0)
// end: Math.floor(end.getTime() / 1000) // end.setHours(23, 59, 59, 999)
// } return {
// } start: Math.floor(start.getTime() / 1000), //
// // end: Math.floor(end.getTime() / 1000) //
// monthTimestamps () { }
// if (!this.monthTime) { },
// return { start: null, end: null } //
// } monthOrderSerch () {
// const start = new Date(this.monthTime) return {
// start.setDate(1) shop_id: this.shop_id, // id
// start.setHours(0, 0, 0, 0) start_time: Math.floor(this.monthTimestamps.start), //
// const end = new Date(this.monthTime) end_time: Math.floor(this.monthTimestamps.end), //
// end.setMonth(end.getMonth() + 1) main_status: ['已付款', '已退款', '已完成'], //
// end.setDate(0) shipment_status: [], //
// end.setHours(23, 59, 59, 999) refund_status: [], // 退
// return { search: ['orderSn', '']//
// start: Math.floor(start.getTime() / 1000), // }
// end: Math.floor(end.getTime() / 1000) // },
// } //
// }, monthPaid () {
// // return this.monthOrderList
// yearTimestamps () { },
// if (!this.yearTime) { //
// return { start: null, end: null } monthPaidTotal () {
// } return formatPrice(this.monthPaid.reduce((total, item) => total + Number(item.total_price) - Number(item.refund_price), 0))
// const start = new Date(this.yearTime) },
// start.setMonth(0) // 退
// start.setDate(1) monthRefund () {
// start.setHours(0, 0, 0, 0) return this.monthOrderList.filter(item => item.main_status === '已退款')
// const end = new Date(this.yearTime) },
// end.setMonth(11) // 退
// end.setDate(31) monthRefundTotal () {
// end.setHours(23, 59, 59, 999) return formatPrice(this.monthRefund.reduce((total, item) => total + Number(item.refund_price), 0))
// return { },
// start: Math.floor(start.getTime() / 1000), // //
// end: Math.floor(end.getTime() / 1000) // yearTimestamps () {
// } if (!this.yearTime) {
// } return { start: null, end: null }
}
const start = new Date(this.yearTime)
start.setMonth(0)
start.setDate(1)
start.setHours(0, 0, 0, 0)
const end = new Date(this.yearTime)
end.setMonth(11)
end.setDate(31)
end.setHours(23, 59, 59, 999)
return {
start: Math.floor(start.getTime() / 1000), //
end: Math.floor(end.getTime() / 1000) //
}
},
//
yearOrderSerch () {
return {
shop_id: this.shop_id, // id
start_time: Math.floor(this.yearTimestamps.start), //
end_time: Math.floor(this.yearTimestamps.end), //
main_status: ['已付款', '已退款', '已完成'], //
shipment_status: [], //
refund_status: [], // 退
search: ['orderSn', '']//
}
},
//
yearPaid () {
return this.yearOrderList
},
//
yearPaidTotal () {
return formatPrice(this.yearPaid.reduce((total, item) => total + Number(item.total_price) - Number(item.refund_price), 0))
},
// 退
yearRefund () {
return this.yearOrderList.filter(item => item.main_status === '已退款')
},
// 退
yearRefundTotal () {
return formatPrice(this.yearRefund.reduce((total, item) => total + Number(item.refund_price), 0))
}
}, },
methods: { methods: {
async getDayOrderList (orderSerch) { /**
* 获取订单列表
* @param orderSerch 搜索条件
* @param type 请求类型 day month year 按条件给对应 属性列表赋值
*/
async getOrderList (orderSerch, type) {
const res = await getOrderList(orderSerch) const res = await getOrderList(orderSerch)
if (res.data.status === 1) { if (type === 'day') {
this.dayOrderList = res.data.orderList if (res.data.status === 1) {
} else { this.dayOrderList = res.data.orderList
this.$message.error('获取日订单列表失败') } else {
this.$message.error('日订单列表获取失败')
}
this.dayBoxLoading = false //
} else if (type === 'month') {
if (res.data.status === 1) {
this.monthOrderList = res.data.orderList
} else {
this.$message.error('月订单列表获取失败')
}
this.monthBoxLoading = false //
} else if (type === 'year') {
if (res.data.status === 1) {
this.yearOrderList = res.data.orderList
} else {
this.$message.error('年订单列表获取失败')
}
this.yearBoxLoading = false //
} }
},
/**
* 点击路由到订单管理页面
* @param type 路由时 判断全局的搜索条件
*/
handlerRouteCilck (type) {
if (type === 'day') {
this.$store.commit('app/setOrderSerch', this.dayOrderSerch)
} else if (type === 'month') {
this.$store.commit('app/setOrderSerch', this.monthOrderSerch)
} else if (type === 'year') {
this.$store.commit('app/setOrderSerch', this.yearOrderSerch)
}
this.$router.push('/order/index')
} }
}, },
watch: { watch: {
// monthTimestamps (val) { dayOrderSerch: {
// console.log(val) handler (val) {
// }, this.dayBoxLoading = true//
// dayTimestamps (val) { this.getOrderList(val, 'day')
// console.log(val) },
// }, deep: true
// dayPaid (val) { },
// console.log(val) monthOrderSerch: {
// }, handler (val) {
// yearOrderList (val) { this.monthBoxLoading = true//
// console.log(val) this.getOrderList(val, 'month')
// } },
deep: true
},
yearOrderSerch: {
handler (val) {
this.yearBoxLoading = true//
this.getOrderList(val, 'year')
},
deep: true
}
}, },
created () { created () {
this.getDayOrderList(this.orderSerch) this.getOrderList(this.dayOrderSerch, 'day')
setTimeout(() => { this.getOrderList(this.monthOrderSerch, 'month')
console.error(this.dayOrderList) this.getOrderList(this.yearOrderSerch, 'year')
}, 3000)
} }
} }
</script> </script>