Commit 20f3394205e55398a4090d95f60c945dc18b1c0b
1 parent
e8ea9e62
反正多次提交
Showing
5 changed files
with
62 additions
and
15 deletions
components/common/tui-utils/tui-utils.js
| ... | ... | @@ -332,3 +332,21 @@ export default { |
| 332 | 332 | debounce: utils.debounce, |
| 333 | 333 | throttle: utils.throttle |
| 334 | 334 | } |
| 335 | +// 👇 新增:补充具名导出(关键步骤) | |
| 336 | +export const { | |
| 337 | + trim, | |
| 338 | + trimAll, | |
| 339 | + replaceAll, | |
| 340 | + formatNumber, | |
| 341 | + formatMoney, | |
| 342 | + formatDate, | |
| 343 | + rgbToHex, | |
| 344 | + hexToRGB, | |
| 345 | + unique, | |
| 346 | + distinctArray, | |
| 347 | + getDateTimeSlot, | |
| 348 | + getUrlParam, | |
| 349 | + getUUID, | |
| 350 | + debounce, | |
| 351 | + throttle // 单独导出 throttle 方法 | |
| 352 | +} = utils; | |
| 335 | 353 | \ No newline at end of file | ... | ... |
pages/work/daily/inspection/add.vue
| ... | ... | @@ -48,7 +48,9 @@ export default { |
| 48 | 48 | }, |
| 49 | 49 | // 提交记录 |
| 50 | 50 | onSubmit() { |
| 51 | - this.$refs.form.validate(this.formData, rules).then(res => { | |
| 51 | + // 关键:如果正在加载中(请求未完成),直接拦截后续点击 | |
| 52 | + if (this.isLoading) return; | |
| 53 | + this.$refs.form.validate(this.formData, rules).then(res => { | |
| 52 | 54 | if (!res.isPass) { |
| 53 | 55 | uni.$tui.toast(res.errorMsg) |
| 54 | 56 | return |
| ... | ... | @@ -60,17 +62,19 @@ export default { |
| 60 | 62 | this.isLoading = true |
| 61 | 63 | apiInspectionAdd({data:{...this.formData}}).then(res => { |
| 62 | 64 | uni.$tui.toast('提交成功') |
| 63 | - const pages = getCurrentPages() | |
| 64 | - const beforePage = pages[pages.length - 2] | |
| 65 | - const id = this.id | |
| 66 | - setTimeout(() => { | |
| 67 | - uni.navigateBack({ | |
| 68 | - success () { | |
| 69 | - // 刷新页面数据 | |
| 70 | - beforePage.$vm.getInspectionInfo(id) | |
| 71 | - } | |
| 72 | - }) | |
| 73 | - }, 1500) | |
| 65 | + uni.navigateBack() | |
| 66 | + | |
| 67 | + // const pages = getCurrentPages() | |
| 68 | + // const beforePage = pages[pages.length - 2] | |
| 69 | + // const id = this.id | |
| 70 | + // setTimeout(() => { | |
| 71 | + // uni.navigateBack({ | |
| 72 | + // success () { | |
| 73 | + // // 刷新页面数据 | |
| 74 | + // beforePage.$vm.getInspectionInfo(id) | |
| 75 | + // } | |
| 76 | + // }) | |
| 77 | + // }, 1500) | |
| 74 | 78 | }).finally(() => { |
| 75 | 79 | this.isLoading = false |
| 76 | 80 | }) | ... | ... |
pages/work/daily/inspection/record.vue
| 1 | 1 | <template> |
| 2 | 2 | <view class="container"> |
| 3 | - <z-paging ref="paging" v-model="dataList" @query="queryList"> | |
| 3 | + <z-paging ref="paging" v-model="dataList" @query="queryList" :auto="false"> | |
| 4 | 4 | <view class="ul fs-p20"> |
| 5 | 5 | <view class="li fs-bg__white fs-p30 fs-size__h4 fs-radius__sm fs-mt20" v-for="(item, index) in dataList"> |
| 6 | 6 | <view class="fs-color__subtitle">{{item.remark}}</view> |
| ... | ... | @@ -28,6 +28,11 @@ export default { |
| 28 | 28 | onLoad(options) { |
| 29 | 29 | this.planNo = options.planno |
| 30 | 30 | }, |
| 31 | + onShow(){ | |
| 32 | + if (this.$refs.paging) { | |
| 33 | + this.$refs.paging.refresh() // 重置到第一页并触发query事件 | |
| 34 | + } | |
| 35 | + }, | |
| 31 | 36 | methods: { |
| 32 | 37 | // 获取巡检记录 |
| 33 | 38 | queryList(pageNo, pageSize) { | ... | ... |
pages/work/daily/reporting.vue
| ... | ... | @@ -128,7 +128,6 @@ export default { |
| 128 | 128 | this.getTypeList() |
| 129 | 129 | this.hotlinenumber = options.hotlinenumber |
| 130 | 130 | if(this.hotlinenumber){ |
| 131 | - | |
| 132 | 131 | // 1. 获取 eventChannel 实例 |
| 133 | 132 | const eventChannel = this.getOpenerEventChannel(); |
| 134 | 133 | |
| ... | ... | @@ -344,6 +343,7 @@ export default { |
| 344 | 343 | }, |
| 345 | 344 | // 提交 |
| 346 | 345 | onSubmit() { |
| 346 | + if (this.isLoading) return; | |
| 347 | 347 | this.$refs.form.validate(this.formData, rules).then(res => { |
| 348 | 348 | if (!res.isPass) { |
| 349 | 349 | uni.$tui.toast(res.errorMsg) |
| ... | ... | @@ -362,7 +362,7 @@ export default { |
| 362 | 362 | |
| 363 | 363 | apiCaseAdd({data:{...this.formData}}).then(res => { |
| 364 | 364 | uni.$tui.toast('提交成功') |
| 365 | - setTimeout(() => { uni.navigateBack() }, 1500) | |
| 365 | + uni.navigateBack() | |
| 366 | 366 | }).finally(() => { |
| 367 | 367 | this.isLoading = false |
| 368 | 368 | }) | ... | ... |
utils/utils.js
0 → 100644
| 1 | +export function debounce(func, wait = 1000, immediate = true) { | |
| 2 | + let timer; | |
| 3 | + return function() { | |
| 4 | + let context = this, | |
| 5 | + args = arguments; | |
| 6 | + if (timer) clearTimeout(timer); | |
| 7 | + if (immediate) { | |
| 8 | + let callNow = !timer; | |
| 9 | + timer = setTimeout(() => { | |
| 10 | + timer = null; | |
| 11 | + }, wait); | |
| 12 | + if (callNow) func.apply(context, args); | |
| 13 | + } else { | |
| 14 | + timer = setTimeout(() => { | |
| 15 | + func.apply(context, args); | |
| 16 | + }, wait) | |
| 17 | + } | |
| 18 | + } | |
| 19 | +} | |
| 20 | + | ... | ... |