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,3 +332,21 @@ export default { | ||
| 332 | debounce: utils.debounce, | 332 | debounce: utils.debounce, |
| 333 | throttle: utils.throttle | 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 | \ No newline at end of file | 353 | \ No newline at end of file |
pages/work/daily/inspection/add.vue
| @@ -48,7 +48,9 @@ export default { | @@ -48,7 +48,9 @@ export default { | ||
| 48 | }, | 48 | }, |
| 49 | // 提交记录 | 49 | // 提交记录 |
| 50 | onSubmit() { | 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 | if (!res.isPass) { | 54 | if (!res.isPass) { |
| 53 | uni.$tui.toast(res.errorMsg) | 55 | uni.$tui.toast(res.errorMsg) |
| 54 | return | 56 | return |
| @@ -60,17 +62,19 @@ export default { | @@ -60,17 +62,19 @@ export default { | ||
| 60 | this.isLoading = true | 62 | this.isLoading = true |
| 61 | apiInspectionAdd({data:{...this.formData}}).then(res => { | 63 | apiInspectionAdd({data:{...this.formData}}).then(res => { |
| 62 | uni.$tui.toast('提交成功') | 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 | }).finally(() => { | 78 | }).finally(() => { |
| 75 | this.isLoading = false | 79 | this.isLoading = false |
| 76 | }) | 80 | }) |
pages/work/daily/inspection/record.vue
| 1 | <template> | 1 | <template> |
| 2 | <view class="container"> | 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 | <view class="ul fs-p20"> | 4 | <view class="ul fs-p20"> |
| 5 | <view class="li fs-bg__white fs-p30 fs-size__h4 fs-radius__sm fs-mt20" v-for="(item, index) in dataList"> | 5 | <view class="li fs-bg__white fs-p30 fs-size__h4 fs-radius__sm fs-mt20" v-for="(item, index) in dataList"> |
| 6 | <view class="fs-color__subtitle">{{item.remark}}</view> | 6 | <view class="fs-color__subtitle">{{item.remark}}</view> |
| @@ -28,6 +28,11 @@ export default { | @@ -28,6 +28,11 @@ export default { | ||
| 28 | onLoad(options) { | 28 | onLoad(options) { |
| 29 | this.planNo = options.planno | 29 | this.planNo = options.planno |
| 30 | }, | 30 | }, |
| 31 | + onShow(){ | ||
| 32 | + if (this.$refs.paging) { | ||
| 33 | + this.$refs.paging.refresh() // 重置到第一页并触发query事件 | ||
| 34 | + } | ||
| 35 | + }, | ||
| 31 | methods: { | 36 | methods: { |
| 32 | // 获取巡检记录 | 37 | // 获取巡检记录 |
| 33 | queryList(pageNo, pageSize) { | 38 | queryList(pageNo, pageSize) { |
pages/work/daily/reporting.vue
| @@ -128,7 +128,6 @@ export default { | @@ -128,7 +128,6 @@ export default { | ||
| 128 | this.getTypeList() | 128 | this.getTypeList() |
| 129 | this.hotlinenumber = options.hotlinenumber | 129 | this.hotlinenumber = options.hotlinenumber |
| 130 | if(this.hotlinenumber){ | 130 | if(this.hotlinenumber){ |
| 131 | - | ||
| 132 | // 1. 获取 eventChannel 实例 | 131 | // 1. 获取 eventChannel 实例 |
| 133 | const eventChannel = this.getOpenerEventChannel(); | 132 | const eventChannel = this.getOpenerEventChannel(); |
| 134 | 133 | ||
| @@ -344,6 +343,7 @@ export default { | @@ -344,6 +343,7 @@ export default { | ||
| 344 | }, | 343 | }, |
| 345 | // 提交 | 344 | // 提交 |
| 346 | onSubmit() { | 345 | onSubmit() { |
| 346 | + if (this.isLoading) return; | ||
| 347 | this.$refs.form.validate(this.formData, rules).then(res => { | 347 | this.$refs.form.validate(this.formData, rules).then(res => { |
| 348 | if (!res.isPass) { | 348 | if (!res.isPass) { |
| 349 | uni.$tui.toast(res.errorMsg) | 349 | uni.$tui.toast(res.errorMsg) |
| @@ -362,7 +362,7 @@ export default { | @@ -362,7 +362,7 @@ export default { | ||
| 362 | 362 | ||
| 363 | apiCaseAdd({data:{...this.formData}}).then(res => { | 363 | apiCaseAdd({data:{...this.formData}}).then(res => { |
| 364 | uni.$tui.toast('提交成功') | 364 | uni.$tui.toast('提交成功') |
| 365 | - setTimeout(() => { uni.navigateBack() }, 1500) | 365 | + uni.navigateBack() |
| 366 | }).finally(() => { | 366 | }).finally(() => { |
| 367 | this.isLoading = false | 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 | + |