fix(good): 商品审核/上下架/改分类/删除误报操作失败——httpGet/httpPost 已解包 data,r?.code===0 恒 false;改 isOk 兼容对象/布尔/null(同类修复 CompanyAccountListView 接管/解绑)
This commit is contained in:
parent
050e1c71e4
commit
b35beae5df
@ -49,6 +49,12 @@ const STATUS_MAP: Record<number, { label: string; type: string }> = {
|
|||||||
0: { label: '已停用', type: 'info' }
|
0: { label: '已停用', type: 'info' }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// httpGet/httpPost 已解包 code===0 的业务 data(拦截器已 reject 非 0 code),
|
||||||
|
// 拿到值即为成功;兼容对象/布尔/null 返回(与 InquiryDetailView 修复同源)
|
||||||
|
function isOk(r: any) {
|
||||||
|
return !(r && typeof r === 'object' && 'code' in r && Number(r.code) !== 0)
|
||||||
|
}
|
||||||
|
|
||||||
const list = ref<CompanyAccount[]>([])
|
const list = ref<CompanyAccount[]>([])
|
||||||
const total = ref(0)
|
const total = ref(0)
|
||||||
const loading = ref(false)
|
const loading = ref(false)
|
||||||
@ -200,7 +206,7 @@ async function takeoverConfirm() {
|
|||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const res = await httpPost('/sys/openapi/company/takeover', { ...takeoverForm })
|
const res = await httpPost('/sys/openapi/company/takeover', { ...takeoverForm })
|
||||||
if (res?.code !== 0) {
|
if (!isOk(res)) {
|
||||||
ElMessage.error(res?.msg || '接管失败')
|
ElMessage.error(res?.msg || '接管失败')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -224,7 +230,7 @@ function unbindHandle(row: CompanyAccount) {
|
|||||||
id: Number(row.id),
|
id: Number(row.id),
|
||||||
reason: '管理员解绑'
|
reason: '管理员解绑'
|
||||||
})
|
})
|
||||||
if (res?.code !== 0) {
|
if (!isOk(res)) {
|
||||||
ElMessage.error(res?.msg || '解绑失败')
|
ElMessage.error(res?.msg || '解绑失败')
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|||||||
@ -134,6 +134,12 @@ const batchCategoryDialogVisible = ref(false)
|
|||||||
const batchRejectDialogVisible = ref(false)
|
const batchRejectDialogVisible = ref(false)
|
||||||
const batchRejectForm = reactive({ reason: '' })
|
const batchRejectForm = reactive({ reason: '' })
|
||||||
|
|
||||||
|
// httpGet/httpPost 已解包 code===0 的业务 data(拦截器已 reject 非 0 code),
|
||||||
|
// 拿到值即为成功;兼容对象/布尔/null 返回(与 InquiryDetailView 修复同源)
|
||||||
|
function isOk(r: any) {
|
||||||
|
return !(r && typeof r === 'object' && 'code' in r && Number(r.code) !== 0)
|
||||||
|
}
|
||||||
|
|
||||||
const columns = [
|
const columns = [
|
||||||
{ type: 'selection' as const, label: '', width: 50 },
|
{ type: 'selection' as const, label: '', width: 50 },
|
||||||
{ prop: 'supplierGoodId', label: '商品ID', width: 100 },
|
{ prop: 'supplierGoodId', label: '商品ID', width: 100 },
|
||||||
@ -253,7 +259,7 @@ async function onSubmitCheck() {
|
|||||||
checkStatus: checkForm.checkStatus,
|
checkStatus: checkForm.checkStatus,
|
||||||
checkOpinion: checkForm.checkOpinion || ''
|
checkOpinion: checkForm.checkOpinion || ''
|
||||||
})
|
})
|
||||||
if (r?.code === 0) {
|
if (isOk(r)) {
|
||||||
ElMessage.success(checkForm.checkStatus === 2 ? '审核通过' : '已驳回')
|
ElMessage.success(checkForm.checkStatus === 2 ? '审核通过' : '已驳回')
|
||||||
checkDialogVisible.value = false
|
checkDialogVisible.value = false
|
||||||
load()
|
load()
|
||||||
@ -266,7 +272,7 @@ async function onOnShelf(row: Good) {
|
|||||||
try { await ElMessageBox.confirm(`确认${row.onShelf === 1 ? '下架' : '上架'}「${row.title}」?`, '提示', { type: 'warning' }) } catch { return }
|
try { await ElMessageBox.confirm(`确认${row.onShelf === 1 ? '下架' : '上架'}「${row.title}」?`, '提示', { type: 'warning' }) } catch { return }
|
||||||
try {
|
try {
|
||||||
const r: any = await httpGet('/supplier/good/onShelfGood', { id: row.id })
|
const r: any = await httpGet('/supplier/good/onShelfGood', { id: row.id })
|
||||||
if (r?.code === 0) { ElMessage.success(row.onShelf === 1 ? '已下架' : '已上架'); load() }
|
if (isOk(r)) { ElMessage.success(row.onShelf === 1 ? '已下架' : '已上架'); load() }
|
||||||
else ElMessage.error(r?.msg || '操作失败')
|
else ElMessage.error(r?.msg || '操作失败')
|
||||||
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
||||||
}
|
}
|
||||||
@ -279,7 +285,7 @@ async function onSubmitCategory() {
|
|||||||
secondCategoryId: categoryForm.secondCategoryId || undefined,
|
secondCategoryId: categoryForm.secondCategoryId || undefined,
|
||||||
thirdCategoryId: categoryForm.thirdCategoryId || undefined
|
thirdCategoryId: categoryForm.thirdCategoryId || undefined
|
||||||
})
|
})
|
||||||
if (r?.code === 0) { ElMessage.success('分类已修改'); categoryDialogVisible.value = false; load() }
|
if (isOk(r)) { ElMessage.success('分类已修改'); categoryDialogVisible.value = false; load() }
|
||||||
else ElMessage.error(r?.msg || '操作失败')
|
else ElMessage.error(r?.msg || '操作失败')
|
||||||
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
||||||
}
|
}
|
||||||
@ -287,7 +293,7 @@ async function onDelete(row: Good) {
|
|||||||
try { await ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }) } catch { return }
|
try { await ElMessageBox.confirm(`确认删除「${row.title}」?`, '提示', { type: 'warning' }) } catch { return }
|
||||||
try {
|
try {
|
||||||
const r: any = await httpGet('/supplier/good/delete', { id: row.id })
|
const r: any = await httpGet('/supplier/good/delete', { id: row.id })
|
||||||
if (r?.code === 0) { ElMessage.success('已删除'); load() }
|
if (isOk(r)) { ElMessage.success('已删除'); load() }
|
||||||
else ElMessage.error(r?.msg || '操作失败')
|
else ElMessage.error(r?.msg || '操作失败')
|
||||||
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
} catch (e: any) { ElMessage.error(e?.msg || e?.message || '操作失败') }
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user