退料扫码确认按钮去除三秒等待

This commit is contained in:
hayu 2026-01-22 18:08:08 +08:00
parent 1564fe2048
commit 5cbebd285d
3 changed files with 146 additions and 52 deletions

View File

@ -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>

View File

@ -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
})
}
}

View File

@ -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
})
}
}