需求变更,增加默认时段合计
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
<script>
|
<script>
|
||||||
|
const getHourRange = hour => `${hour.padStart(2, '0')}:00-${`${Number(hour) + 1}`.padStart(2, '0')}:00`
|
||||||
export default {
|
export default {
|
||||||
name: "AppHourSale",
|
name: "AppHourSale",
|
||||||
label: "市场看板-全门店时段销售",
|
label: "市场看板-全门店时段销售",
|
||||||
@@ -85,12 +86,12 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
getTableData() {
|
getTableData() {
|
||||||
const {$http, $waitFor} = window
|
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
|
...this.search, limit: 999
|
||||||
})).then(res => {
|
})).then(res => {
|
||||||
if (res?.data) {
|
if (res?.data) {
|
||||||
this.summary = res.data.total
|
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.compareValidOrderNum += Number(e.compareValidOrderNum || 0)
|
||||||
summary.currentSaleAmt += Number(e.currentSaleAmt || 0)
|
summary.currentSaleAmt += Number(e.currentSaleAmt || 0)
|
||||||
summary.currentValidOrderNum += Number(e.currentValidOrderNum || 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) {
|
if (i == rowIndex) {
|
||||||
summary.compareSaleAmt = summary.compareSaleAmt.toFixed(2)
|
summary.compareSaleAmt = summary.compareSaleAmt.toFixed(2)
|
||||||
@@ -148,19 +150,24 @@ export default {
|
|||||||
const i = this.tableData.findIndex(e => e.hour == '时段合计')
|
const i = this.tableData.findIndex(e => e.hour == '时段合计')
|
||||||
if (i == -1) return;
|
if (i == -1) return;
|
||||||
this.tableData.splice(i, 1)
|
this.tableData.splice(i, 1)
|
||||||
|
},
|
||||||
|
initHourSta() {
|
||||||
|
const {dayjs} = window
|
||||||
|
const hour = getHourRange(`${dayjs().hour()}`)
|
||||||
|
this.handleSta({hour})
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
search: {
|
search: {
|
||||||
immediate: true, deep: true, handler() {
|
immediate: true, deep: true, handler() {
|
||||||
this.getTableData()
|
this.getTableData().then(() => this.initHourSta())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
document.addEventListener('click', evt => {
|
document.addEventListener('click', evt => {
|
||||||
if (!this.$el.contains(evt.target)) {
|
if (!this.$el.contains(evt.target)) {
|
||||||
this.handleMouseout()
|
this.initHourSta()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user