退料扫码确认按钮去除三秒等待
This commit is contained in:
parent
1564fe2048
commit
5cbebd285d
|
|
@ -0,0 +1,108 @@
|
|||
<template>
|
||||
<div>
|
||||
<!-- 弹框确认组件 -->
|
||||
<uni-popup ref="popupDialog" type="dialog" :mask-click="false">
|
||||
<view class="popup-content">
|
||||
<view class="popup-title">{{ title }}</view>
|
||||
<view class="popup-message" v-if="!showRemark">{{ content }}</view>
|
||||
<uni-easyinput v-else type="textarea" v-model="remark" placeholder="请输入" autoHeight />
|
||||
<view class="popup-btns">
|
||||
<view class="btn cancel" v-if="showClose" @click="closePopup">{{ leftBtn }}</view>
|
||||
<view class="btn confirm" @click="confirm">
|
||||
<span>{{ rightBtn }}</span>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup>
|
||||
import { ref } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
title: { type: String, default: '提示' },
|
||||
content: { type: String, default: '是否确定提交?' },
|
||||
showClose: { type: Boolean, default: true },
|
||||
leftBtn: { type: String, default: '取 消' },
|
||||
rightBtn: { type: String, default: '确 定' },
|
||||
showRemark: { type: Boolean, default: false },
|
||||
})
|
||||
|
||||
const emit = defineEmits(['confirm'])
|
||||
|
||||
const popupDialog = ref(null)
|
||||
const remark = ref('')
|
||||
let resolvePromise = null // 用于存储 Promise 的 resolve
|
||||
|
||||
// 打开弹框,返回 Promise
|
||||
const openPopupWaitFree = () => {
|
||||
return new Promise((resolve) => {
|
||||
resolvePromise = resolve // 保存 resolve
|
||||
popupDialog.value.open()
|
||||
remark.value = '' // 每次打开清空
|
||||
})
|
||||
}
|
||||
|
||||
// 关闭弹框
|
||||
const closePopup = () => {
|
||||
popupDialog.value.close()
|
||||
if (resolvePromise) resolvePromise({ data: false })
|
||||
resolvePromise = null
|
||||
}
|
||||
|
||||
// 点击确认
|
||||
const confirm = () => {
|
||||
popupDialog.value.close()
|
||||
const params = {
|
||||
data: true,
|
||||
remark: remark.value,
|
||||
}
|
||||
if (!remark.value) delete params.remark
|
||||
if (resolvePromise) resolvePromise(params)
|
||||
resolvePromise = null
|
||||
}
|
||||
|
||||
// 暴露方法
|
||||
defineExpose({ openPopupWaitFree })
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.popup-content {
|
||||
padding: 20rpx;
|
||||
background-color: #fff;
|
||||
border-radius: 10rpx;
|
||||
width: 80vw;
|
||||
}
|
||||
.popup-title {
|
||||
font-size: 32rpx;
|
||||
font-weight: bold;
|
||||
margin-bottom: 20rpx;
|
||||
}
|
||||
.popup-message {
|
||||
font-size: 36rpx;
|
||||
font-weight: bold;
|
||||
margin: 30px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.popup-btns {
|
||||
display: flex;
|
||||
border-top: 1px solid #eee;
|
||||
height: 88rpx;
|
||||
line-height: 88rpx;
|
||||
text-align: center;
|
||||
}
|
||||
.btn {
|
||||
margin-top: 3px;
|
||||
flex: 1;
|
||||
font-size: 34rpx;
|
||||
}
|
||||
.cancel {
|
||||
color: #666;
|
||||
border-right: 1px solid #eee;
|
||||
}
|
||||
.confirm {
|
||||
color: #007aff;
|
||||
font-weight: 500;
|
||||
}
|
||||
</style>
|
||||
|
|
@ -8,15 +8,6 @@
|
|||
fixed
|
||||
@clickLeft="leftClick"
|
||||
>
|
||||
<!-- 使用右侧插槽自定义提交按钮 -->
|
||||
<!-- <template #right>
|
||||
<button
|
||||
class="submit-btn"
|
||||
@click="submitCode"
|
||||
>
|
||||
确定
|
||||
</button>
|
||||
</template> -->
|
||||
</uni-nav-bar>
|
||||
<view class="accept page-common">
|
||||
<div class="card top-content" :class="{ 'is-expanded': isExpanded }">
|
||||
|
|
@ -90,9 +81,6 @@
|
|||
<uni-col :span="6">
|
||||
<view class="coding-btn" @click="onCodeIdentify">编码识别</view>
|
||||
</uni-col>
|
||||
<!-- <uni-col :span="6">
|
||||
<view class="coding-btn" @click="scanStart">二维码识别</view>
|
||||
</uni-col> -->
|
||||
<uni-col :span="6">
|
||||
<view class="coding-btn" @click="moveNum">转至数量</view>
|
||||
</uni-col>
|
||||
|
|
@ -100,39 +88,6 @@
|
|||
</div>
|
||||
|
||||
<div class="card" style="margin-top: 10px">
|
||||
<!-- <uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
|
||||
<uni-col :span="6">设备编码:</uni-col>
|
||||
<uni-col :span="12">
|
||||
<uni-data-select
|
||||
style="width: 100%; height: 90rpx"
|
||||
v-model="maCode"
|
||||
:localdata="codeList"
|
||||
@change="changeMaCode"
|
||||
@clear="clearMaCode"
|
||||
></uni-data-select>
|
||||
</uni-col>
|
||||
<uni-col :span="6">
|
||||
<view class="coding-btn search-btn" @click="getMaInfo">编码检索</view>
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
|
||||
<uni-col :span="6">物资类型:</uni-col>
|
||||
<uni-col :span="16">
|
||||
{{ typeName }}
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
|
||||
<uni-col :span="6">规格型号:</uni-col>
|
||||
<uni-col :span="16">
|
||||
{{ materialName }}
|
||||
</uni-col>
|
||||
</uni-row>
|
||||
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
|
||||
<uni-col :span="6">设备状态:</uni-col>
|
||||
<uni-col :span="16">
|
||||
{{ maStatusName }}
|
||||
</uni-col>
|
||||
</uni-row> -->
|
||||
<uni-row :gutter="24" style="display: flex; align-items: center; margin-bottom: 10px">
|
||||
<uni-col :span="6">规格型号:</uni-col>
|
||||
<uni-col :span="18">
|
||||
|
|
@ -234,9 +189,6 @@
|
|||
</div>
|
||||
</scroll-view>
|
||||
|
||||
<!-- <div class="btn">
|
||||
<button class="btn-cont" @click="submitCode">确认</button>
|
||||
</div> -->
|
||||
</view>
|
||||
<PopupConfirm ref="popupConfirm" />
|
||||
</template>
|
||||
|
|
@ -257,7 +209,7 @@ import { baseURL } from '@/utils/http'
|
|||
import eselect from '@/components/tree-select/eselect.vue'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
import PreviewImg from '@/components/PreviewImg/index.vue'
|
||||
import PopupConfirm from '@/components/PopupConfirm'
|
||||
import PopupConfirm from '@/components/PopupConfirm/waitFree'
|
||||
|
||||
const taskInfo = ref({})
|
||||
const maId = ref('') //编码
|
||||
|
|
@ -286,6 +238,9 @@ const remark = ref('')
|
|||
const isRadioCheck = ref(true)
|
||||
const popupConfirm = ref()
|
||||
|
||||
// 添加提交状态锁
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const leftClick = () => {
|
||||
// 返回
|
||||
uni.navigateBack({
|
||||
|
|
@ -716,14 +671,23 @@ const onCodeIdentify = () => {
|
|||
}
|
||||
//提交
|
||||
const submitCode = async () => {
|
||||
// 防止重复提交:如果正在提交中,直接返回
|
||||
if (isSubmitting.value) {
|
||||
return
|
||||
}
|
||||
|
||||
console.log(taskInfo.value)
|
||||
if (selectCodeList.value.length == 0) {
|
||||
uni.showToast({ title: '请添加退料设备!', icon: 'none' })
|
||||
} else if (apDetection.value == '不合格' && bmFileInfos.value.length == 0) {
|
||||
uni.showToast({ title: '请上传附件!', icon: 'none' })
|
||||
} else {
|
||||
const { data: confirm } = await popupConfirm.value.openPopup()
|
||||
const { data: confirm } = await popupConfirm.value.openPopupWaitFree()
|
||||
if (!confirm) return
|
||||
|
||||
// 设置提交锁为true
|
||||
isSubmitting.value = true
|
||||
|
||||
let obj = {
|
||||
// maId: maId.value,
|
||||
// maCode: maCode.value,
|
||||
|
|
@ -779,6 +743,11 @@ const submitCode = async () => {
|
|||
console.log(error)
|
||||
uni.hideLoading()
|
||||
})
|
||||
.finally(() => {
|
||||
// 无论成功失败,都释放提交锁
|
||||
isSubmitting.value = false
|
||||
uni.hideLoading() // 确保loading被关闭
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -130,7 +130,7 @@ import ScanQrCode from '@/pages/devicesSearch/ScanQrCode.vue'
|
|||
import eselect from '@/components/tree-select/eselect.vue'
|
||||
import { decryptWithSM4, encryptWithSM4, hashWithSM3AndSalt } from '@/utils/sm'
|
||||
import PreviewImg from '@/components/PreviewImg/index.vue'
|
||||
import PopupConfirm from '@/components/PopupConfirm'
|
||||
import PopupConfirm from '@/components/PopupConfirm/waitFree'
|
||||
|
||||
const taskInfo = ref({})
|
||||
const apDetection = ref('完好') //外观判定
|
||||
|
|
@ -144,6 +144,9 @@ const isRadioCheck = ref(true)
|
|||
const popupConfirm = ref()
|
||||
const codeInfo = ref({})
|
||||
|
||||
// 添加提交状态锁
|
||||
const isSubmitting = ref(false)
|
||||
|
||||
const leftClick = () => {
|
||||
// 返回
|
||||
uni.navigateBack({
|
||||
|
|
@ -239,14 +242,23 @@ const getMaInfoScan = () => {
|
|||
|
||||
//提交
|
||||
const submitCode = async () => {
|
||||
// 防止重复提交:如果正在提交中,直接返回
|
||||
if (isSubmitting.value) {
|
||||
return
|
||||
}
|
||||
|
||||
console.log(taskInfo.value)
|
||||
if (!codeInfo.value.maCode) {
|
||||
uni.showToast({ title: '请添加退料设备!', icon: 'none' })
|
||||
} else if (apDetection.value == '不合格' && bmFileInfos.value.length == 0) {
|
||||
uni.showToast({ title: '请上传附件!', icon: 'none' })
|
||||
} else {
|
||||
const { data: confirm } = await popupConfirm.value.openPopup()
|
||||
const { data: confirm } = await popupConfirm.value.openPopupWaitFree()
|
||||
if (!confirm) return
|
||||
|
||||
// 设置提交锁为true
|
||||
isSubmitting.value = true
|
||||
|
||||
let obj = {
|
||||
// maId: codeInfo.value.maId.value,
|
||||
// maCode: codeInfo.value.maCode.value,
|
||||
|
|
@ -293,6 +305,11 @@ const submitCode = async () => {
|
|||
console.log(error)
|
||||
uni.hideLoading()
|
||||
})
|
||||
.finally(() => {
|
||||
// 无论成功失败,都释放提交锁
|
||||
isSubmitting.value = false
|
||||
uni.hideLoading() // 确保loading被关闭
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue