This commit is contained in:
@@ -442,6 +442,12 @@
|
||||
import { AUDIT_PERMISSIONS } from '@/config/constants/audit'
|
||||
import { resolveAuditResourceTarget } from '@/utils/business/auditNavigation'
|
||||
import { openAuditInvestigation } from '@/components/business/audit/investigationController'
|
||||
import { AUGUST_PERMISSIONS } from '@/config/constants/augustIteration'
|
||||
import { normalizeApiError } from '@/utils/business/apiError'
|
||||
import {
|
||||
getExchangePhoneConflictMessage,
|
||||
getExchangeBusinessErrorMessage
|
||||
} from '@/utils/business/exchangeError'
|
||||
|
||||
defineOptions({ name: 'ExchangeManagement' })
|
||||
|
||||
@@ -449,6 +455,38 @@
|
||||
const userStore = useUserStore()
|
||||
const router = useRouter()
|
||||
|
||||
const handleExchangeFailure = async (failure: unknown, fallback: string) => {
|
||||
const conflictMessage = getExchangePhoneConflictMessage(failure)
|
||||
if (!conflictMessage) {
|
||||
const normalized = normalizeApiError(failure)
|
||||
if (normalized.kind === 'auth') return // 登录失效由统一 HTTP 层反馈。
|
||||
ElMessage.error(
|
||||
getExchangeBusinessErrorMessage(failure) ||
|
||||
(normalized.kind === 'unknown' ? fallback : normalized.message)
|
||||
)
|
||||
return
|
||||
}
|
||||
const canManageAssociations = hasAuth(AUGUST_PERMISSIONS.phoneAssetAssociation.list)
|
||||
try {
|
||||
await ElMessageBox.confirm(
|
||||
canManageAssociations
|
||||
? conflictMessage
|
||||
: `${conflictMessage}。您暂无管理权限,请联系管理员解除。`,
|
||||
'新资产手机号绑定冲突',
|
||||
{
|
||||
type: 'warning',
|
||||
confirmButtonText: canManageAssociations ? '前往手机号资产关联' : '知道了',
|
||||
cancelButtonText: '暂不处理',
|
||||
showCancelButton: canManageAssociations,
|
||||
dangerouslyUseHTMLString: false
|
||||
}
|
||||
)
|
||||
if (canManageAssociations) await router.push(RoutesAlias.PhoneAssetAssociation)
|
||||
} catch {
|
||||
// 用户关闭提示,不执行解绑或改写换货状态。
|
||||
}
|
||||
}
|
||||
|
||||
const currentExchangeRow = ref<ExchangeResponse | null>(null)
|
||||
const loading = ref(false)
|
||||
const shipDialogVisible = ref(false)
|
||||
@@ -871,7 +909,7 @@
|
||||
label: '换货单号',
|
||||
width: 230,
|
||||
showOverflowTooltip: true,
|
||||
fixed:true,
|
||||
fixed: true,
|
||||
formatter: (row: any) =>
|
||||
h(
|
||||
ElButton,
|
||||
@@ -1535,7 +1573,9 @@
|
||||
requestData.migrate_data = createForm.migrate_data
|
||||
}
|
||||
|
||||
const res = await ExchangeService.createExchange(requestData)
|
||||
const res = await ExchangeService.createExchange(requestData, {
|
||||
requestOptions: { errorMessageMode: 'none' }
|
||||
})
|
||||
if (res.code === 0) {
|
||||
ElMessage.success('换货单创建成功')
|
||||
createDialogVisible.value = false
|
||||
@@ -1543,9 +1583,9 @@
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.error(res.msg || '换货单创建失败')
|
||||
await handleExchangeFailure(res, '换货单创建失败')
|
||||
} catch (error) {
|
||||
console.error('创建换货单失败:', error)
|
||||
await handleExchangeFailure(error, '换货单创建失败')
|
||||
} finally {
|
||||
createLoading.value = false
|
||||
}
|
||||
@@ -1767,48 +1807,36 @@
|
||||
}
|
||||
|
||||
// 确认完成
|
||||
const handleCompleteExchange = (row: ExchangeResponse) => {
|
||||
const handleCompleteExchange = async (row: ExchangeResponse) => {
|
||||
if (completeLoadingId.value === row.id) return
|
||||
|
||||
completeLoadingId.value = row.id
|
||||
|
||||
ElMessageBox.confirm('确定要确认换货完成吗?', '确认操作', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning',
|
||||
beforeClose: async (action, instance, done) => {
|
||||
if (action !== 'confirm') {
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
||||
instance.confirmButtonLoading = true
|
||||
instance.confirmButtonText = '提交中...'
|
||||
|
||||
try {
|
||||
const res = await ExchangeService.completeExchange(row.id)
|
||||
if (res.code === 0) {
|
||||
await refreshExchangeDetail(row.id)
|
||||
await loadExchangeList()
|
||||
ElMessage.success('操作成功')
|
||||
done()
|
||||
return
|
||||
}
|
||||
|
||||
ElMessage.error(res.msg || '确认完成失败')
|
||||
} catch (error) {
|
||||
console.error('确认完成失败:', error)
|
||||
} finally {
|
||||
instance.confirmButtonLoading = false
|
||||
instance.confirmButtonText = '确定'
|
||||
}
|
||||
}
|
||||
})
|
||||
.then(() => {})
|
||||
.finally(() => {
|
||||
completeLoadingId.value = null
|
||||
try {
|
||||
await ElMessageBox.confirm('确定要确认换货完成吗?', '确认操作', {
|
||||
confirmButtonText: '确定',
|
||||
cancelButtonText: '取消',
|
||||
type: 'warning'
|
||||
})
|
||||
.catch(() => {})
|
||||
} catch {
|
||||
completeLoadingId.value = null
|
||||
return
|
||||
}
|
||||
try {
|
||||
const res = await ExchangeService.completeExchange(row.id, {
|
||||
requestOptions: { errorMessageMode: 'none' }
|
||||
})
|
||||
// 刷新失败也不能吞掉原操作的 1202 业务响应。
|
||||
await Promise.allSettled([refreshExchangeDetail(row.id), loadExchangeList()])
|
||||
if (res.code === 0) ElMessage.success('操作成功')
|
||||
else await handleExchangeFailure(res, '确认完成失败')
|
||||
} catch (error) {
|
||||
// 仅重新读取原单状态,不乐观标记完成,错误对象可能包含完整手机号,不输出日志。
|
||||
await Promise.allSettled([refreshExchangeDetail(row.id), loadExchangeList()])
|
||||
await handleExchangeFailure(error, '确认完成失败')
|
||||
} finally {
|
||||
completeLoadingId.value = null
|
||||
}
|
||||
}
|
||||
|
||||
// 旧资产转新
|
||||
|
||||
Reference in New Issue
Block a user