优化
This commit is contained in:
@@ -792,7 +792,7 @@ const calculateWeight = () => {
|
||||
|
||||
|
||||
// 处理确定
|
||||
const handleConfirm = () => {
|
||||
const handleConfirm = () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
Message.error('请输入数量')
|
||||
@@ -803,6 +803,12 @@ const handleConfirm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 抓拍当前画面
|
||||
let captureUrl = ''
|
||||
if (cameraVideo.value && cameraStatus.value === 'connected') {
|
||||
captureUrl = capturePhoto();
|
||||
}
|
||||
|
||||
// 生成新的列表数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
@@ -825,7 +831,7 @@ const handleConfirm = () => {
|
||||
}
|
||||
|
||||
// 抓拍功能 - 内部方法,不暴露按钮
|
||||
const capturePhoto = async (): Promise<string> => {
|
||||
const capturePhoto = (): Promise<string> => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
try {
|
||||
const video = cameraVideo.value
|
||||
@@ -852,7 +858,7 @@ const capturePhoto = async (): Promise<string> => {
|
||||
|
||||
// 调用后端接口
|
||||
const response = await catchPhoto(formData)
|
||||
if (!response.code === '200') {
|
||||
if (response.code !== '200') {
|
||||
reject(new Error('上传失败'))
|
||||
return
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user