需求变更,增加默认时段合计

This commit is contained in:
aixianling
2024-10-23 10:44:40 +08:00
parent e6253c9ac8
commit 398b3e799c

View File

@@ -1,4 +1,5 @@
<script>
const getHourRange = hour => `${hour.padStart(2, '0')}:00-${`${Number(hour) + 1}`.padStart(2, '0')}:00`
export default {
name: "AppHourSale",
label: "市场看板-全门店时段销售",
@@ -85,12 +86,12 @@ export default {
methods: {
getTableData() {
const {$http, $waitFor} = window
$waitFor($http).then(() => $http.post("/data-boot/la/screen/marketBoard/hourSale", {
return $waitFor($http).then(() => $http.post("/data-boot/la/screen/marketBoard/hourSale", {
...this.search, limit: 999
})).then(res => {
if (res?.data) {
this.summary = res.data.total
this.tableData = res.data?.page?.records?.map(e => ({...e, hour: `${e.hour.padStart(2, '0')}:00-${`${Number(e.hour) + 1}`.padStart(2, '0')}:00`, index: e.hour})).sort((a, b) => a.index - b.index) || []
return this.tableData = res.data?.page?.records?.map(e => ({...e, hour: getHourRange(e.hour), index: e.hour})).sort((a, b) => a.index - b.index) || []
}
})
},
@@ -107,7 +108,8 @@ export default {
summary.compareValidOrderNum += Number(e.compareValidOrderNum || 0)
summary.currentSaleAmt += Number(e.currentSaleAmt || 0)
summary.currentValidOrderNum += Number(e.currentValidOrderNum || 0)
summary.saleGrowthRate += Number(e.saleGrowthRate.replace("%", "") || 0)
const {currentSaleAmt, compareSaleAmt} = summary
summary.saleGrowthRate = Number((currentSaleAmt - compareSaleAmt) / compareSaleAmt * 100 || 0)
}
if (i == rowIndex) {
summary.compareSaleAmt = summary.compareSaleAmt.toFixed(2)
@@ -148,19 +150,24 @@ export default {
const i = this.tableData.findIndex(e => e.hour == '时段合计')
if (i == -1) return;
this.tableData.splice(i, 1)
},
initHourSta() {
const {dayjs} = window
const hour = getHourRange(`${dayjs().hour()}`)
this.handleSta({hour})
}
},
watch: {
search: {
immediate: true, deep: true, handler() {
this.getTableData()
this.getTableData().then(() => this.initHourSta())
}
}
},
mounted() {
document.addEventListener('click', evt => {
if (!this.$el.contains(evt.target)) {
this.handleMouseout()
this.initHourSta()
}
})
}