uu
This commit is contained in:
parent
4783cc3e6c
commit
6168e1c43e
@ -95,10 +95,12 @@ const numberToChinese = (num)=> {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - 获取地址详情
|
||||||
const getAddressDetail = (item= {})=> {
|
const getAddressDetail = (item= {})=> {
|
||||||
return `${item.countryName||''}${item.provinceName||''}${item.cityName||''}${item.countyName||''}${item.address||''}`
|
return `${item.countryName||''}${item.provinceName||''}${item.cityName||''}${item.countyName||''}${item.address||''}`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// - 转换list的key val
|
||||||
const transListKeyTitle = ({ valKey = '', titleKey = '', list = [] })=> {
|
const transListKeyTitle = ({ valKey = '', titleKey = '', list = [] })=> {
|
||||||
list.map(t=> {
|
list.map(t=> {
|
||||||
t.title = t[titleKey]
|
t.title = t[titleKey]
|
||||||
@ -107,11 +109,49 @@ const transListKeyTitle = ({ valKey = '', titleKey = '', list = [] })=> {
|
|||||||
return list
|
return list
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// -防抖
|
||||||
|
const debounce = (fn, wait) => {
|
||||||
|
let delay = wait || 500
|
||||||
|
let timer
|
||||||
|
return function() {
|
||||||
|
let args = arguments;
|
||||||
|
if (timer) {
|
||||||
|
clearTimeout(timer)
|
||||||
|
console.log('拦截')
|
||||||
|
}
|
||||||
|
let callNow = !timer
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
console.log('发送')
|
||||||
|
timer = null
|
||||||
|
}, delay)
|
||||||
|
if (callNow) fn.apply(this, args)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// -节流
|
||||||
|
const throttle = (fn, wait) => {
|
||||||
|
let delay = wait || 500
|
||||||
|
let timer = null
|
||||||
|
return function() {
|
||||||
|
if (timer) {
|
||||||
|
console.log('拦截');
|
||||||
|
return
|
||||||
|
}
|
||||||
|
timer = setTimeout(() => {
|
||||||
|
console.log('发送');
|
||||||
|
fn.apply(this, arguments)
|
||||||
|
timer = null
|
||||||
|
}, delay)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getAddressDetail,
|
getAddressDetail,
|
||||||
numberToChinese,
|
numberToChinese,
|
||||||
formatTime,
|
formatTime,
|
||||||
formatLocation,
|
formatLocation,
|
||||||
dateUtils,
|
dateUtils,
|
||||||
transListKeyTitle
|
transListKeyTitle,
|
||||||
|
debounce,
|
||||||
|
throttle,
|
||||||
}
|
}
|
||||||
|
|||||||
@ -15,11 +15,15 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
import { throttle } from "@/common/util"
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
watch: {
|
watch: {
|
||||||
searchParam: {
|
searchParam: {
|
||||||
handler(cval, oval) {
|
handler(cval, oval) {
|
||||||
this.getDataList(true)
|
throttle(()=> {
|
||||||
|
this.getDataList(true)
|
||||||
|
}, 500)
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
}
|
}
|
||||||
@ -102,7 +106,7 @@
|
|||||||
page: this.page,
|
page: this.page,
|
||||||
showLoadMore: this.showLoadMore,
|
showLoadMore: this.showLoadMore,
|
||||||
loadedAll: this.loadedAll,
|
loadedAll: this.loadedAll,
|
||||||
reqLoading: this.reqLoading
|
reqLoading: this.reqLoading,
|
||||||
...obj,
|
...obj,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user