fix(StorageCellsSummary): 修复格口操作流程中的问题和样式
- 添加关闭弹窗时重置格口的功能 - 调整弹窗高度和样式以适应不同状态 - 优化密码验证失败和格口不可用的提示 - 修复数据刷新后默认选中格口类型的逻辑 - 增加操作失败时的错误处理和提示持续时间
This commit is contained in:
parent
8abfd0d094
commit
b471155bb9
|
|
@ -80,6 +80,7 @@
|
||||||
v-model:show="popupVisible"
|
v-model:show="popupVisible"
|
||||||
position="bottom"
|
position="bottom"
|
||||||
round
|
round
|
||||||
|
:close-on-click-overlay="false"
|
||||||
:style="popupStyle"
|
:style="popupStyle"
|
||||||
@close="handlePopupCancel">
|
@close="handlePopupCancel">
|
||||||
|
|
||||||
|
|
@ -156,7 +157,8 @@ import { showToast } from 'vant'
|
||||||
import {
|
import {
|
||||||
availableStorageCells,
|
availableStorageCells,
|
||||||
storeItemApi,
|
storeItemApi,
|
||||||
openByPassword
|
openByPassword,
|
||||||
|
resetByPassword
|
||||||
} from '@/common/apis/cabinet'
|
} from '@/common/apis/cabinet'
|
||||||
import type { AvailableStorageCellDTO } from '@/common/apis/cabinet/type'
|
import type { AvailableStorageCellDTO } from '@/common/apis/cabinet/type'
|
||||||
import { usePopupState } from '@/common/composables/usePopupState'
|
import { usePopupState } from '@/common/composables/usePopupState'
|
||||||
|
|
@ -217,7 +219,6 @@ const {
|
||||||
showCancelButton,
|
showCancelButton,
|
||||||
transitionTo,
|
transitionTo,
|
||||||
handlePasswordInputChange,
|
handlePasswordInputChange,
|
||||||
handlePopupCancel,
|
|
||||||
handleKeyboardInput,
|
handleKeyboardInput,
|
||||||
handleKeyboardDelete,
|
handleKeyboardDelete,
|
||||||
handleKeyboardClose
|
handleKeyboardClose
|
||||||
|
|
@ -227,13 +228,14 @@ const {
|
||||||
const popupStyle = computed(() => {
|
const popupStyle = computed(() => {
|
||||||
const baseStyle = {
|
const baseStyle = {
|
||||||
padding: '32px',
|
padding: '32px',
|
||||||
background: '#fff'
|
background: '#fff',
|
||||||
|
height: 'calc(100vh - 120px)',
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyboardVisible.value) {
|
if (keyboardVisible.value) {
|
||||||
return {
|
return {
|
||||||
...baseStyle,
|
...baseStyle,
|
||||||
maxHeight: 'calc(100vh - 360px)',
|
height: 'calc(100vh - 80px)',
|
||||||
overflow: 'auto'
|
overflow: 'auto'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -288,6 +290,11 @@ async function refresh() {
|
||||||
const response = await availableStorageCells(props.shopId)
|
const response = await availableStorageCells(props.shopId)
|
||||||
cellsData.value = response.data || []
|
cellsData.value = response.data || []
|
||||||
emit('refresh')
|
emit('refresh')
|
||||||
|
|
||||||
|
const availableTypes = cellTypeStats.value.filter(stat => stat.count > 0)
|
||||||
|
if (availableTypes.length > 0) {
|
||||||
|
selectedCellType.value = availableTypes[0].type
|
||||||
|
}
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
error.value = err as Error
|
error.value = err as Error
|
||||||
emit('error', err as Error)
|
emit('error', err as Error)
|
||||||
|
|
@ -347,15 +354,48 @@ async function handleDepositFlow() {
|
||||||
showToast({
|
showToast({
|
||||||
message: (err as any)?.message || '操作失败',
|
message: (err as any)?.message || '操作失败',
|
||||||
type: 'fail',
|
type: 'fail',
|
||||||
duration: 3000
|
duration: 5000,
|
||||||
|
overlay: true
|
||||||
})
|
})
|
||||||
transitionTo({ type: 'idle' })
|
transitionTo({ type: 'idle' })
|
||||||
} finally {
|
} finally {
|
||||||
depositLoading.value = false
|
depositLoading.value = false
|
||||||
|
// 刷新数据
|
||||||
|
await refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 弹窗相关事件处理
|
// 弹窗相关事件处理
|
||||||
|
async function handlePopupCancel() {
|
||||||
|
const state = currentState.value
|
||||||
|
|
||||||
|
// 如果在密码验证状态点击取消,需要重置格口
|
||||||
|
if (state.type === 'password-verify') {
|
||||||
|
try {
|
||||||
|
await resetByPassword({
|
||||||
|
shopId: props.shopId,
|
||||||
|
password: state.correctPassword
|
||||||
|
})
|
||||||
|
showToast({
|
||||||
|
message: '格口已重置',
|
||||||
|
type: 'success'
|
||||||
|
})
|
||||||
|
} catch (err) {
|
||||||
|
console.error('重置格口失败:', err)
|
||||||
|
showToast({
|
||||||
|
message: '重置格口失败',
|
||||||
|
type: 'fail'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 切换回空闲状态
|
||||||
|
transitionTo({ type: 'idle' })
|
||||||
|
|
||||||
|
// 刷新列表
|
||||||
|
await refresh()
|
||||||
|
}
|
||||||
|
|
||||||
async function handlePopupConfirm() {
|
async function handlePopupConfirm() {
|
||||||
const state = currentState.value
|
const state = currentState.value
|
||||||
|
|
||||||
|
|
@ -395,18 +435,18 @@ async function performOpenByPassword(password: string, action: 'deposit' | 'retr
|
||||||
message: '格口已打开',
|
message: '格口已打开',
|
||||||
type: 'success'
|
type: 'success'
|
||||||
})
|
})
|
||||||
|
|
||||||
// 刷新数据
|
|
||||||
await refresh()
|
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('打开格口失败:', err)
|
console.error('打开格口失败:', err)
|
||||||
showToast({
|
showToast({
|
||||||
message: (err as any)?.message || '操作失败',
|
message: '密码错误',
|
||||||
type: 'fail',
|
type: 'fail',
|
||||||
duration: 3000
|
duration: 4000,
|
||||||
|
overlay: true
|
||||||
})
|
})
|
||||||
} finally {
|
} finally {
|
||||||
transitionTo({ type: 'idle' })
|
transitionTo({ type: 'idle' })
|
||||||
|
// 刷新数据
|
||||||
|
await refresh()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -442,7 +482,8 @@ function handleCellTypeSelect(stat: { type: number; count: number }) {
|
||||||
showToast({
|
showToast({
|
||||||
message: '该类型格口暂不可用',
|
message: '该类型格口暂不可用',
|
||||||
type: 'fail',
|
type: 'fail',
|
||||||
duration: 1500
|
duration: 5000,
|
||||||
|
overlay: true
|
||||||
})
|
})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue