export function debounce(func, wait, immediate) {
let timeout
console.log('wait', wait)
return function(...args) {
const context = this
if (timeout) clearTimeout(timeout)
if (immediate) {
const callNow = !timeout
timeout = setTimeout(function() {
timeout = null
}, wait)
if (callNow) func.apply(context, args)
} else {
console.log(wait)
timeout = setTimeout(function() {
func.apply(context, args)
}, wait)
}
}
}
import { debounce } from '@/utils/util'
change: debounce(
async function() {
const par = {}
par.motorcadeId = this.$route.query.motorcadeId
par.carTypeCode = this.$route.query.carTypeCode
par.reconfirmInvoicePrice = this.formInfo.reconfirmInvoicePrice
if (this.formInfo.reconfirmInvoicePrice) {
const res = await fetchSecondMsrpPriceApp(par)
if (!res.data.success) {
Toast.fail({
message: res.data.message,
forbidClick: true,
duration: 2000
})
return
}
this.formInfo.marketPriceOrginRemark = res.data.info.marketPriceOrginRemark || ''
} else {
this.formInfo.marketPriceOrginRemark = ''
}
this.$forceUpdate()
},
500,
false
),