智能柜详情接口请求错误处理
This commit is contained in:
1 parent
1af4cb1e8c
commit
dfbeed0839
4 files changed
+54
-25
No files matched your search
@@ -120,14 +120,18 @@ const openDialog = (cabinetItemId: string) => {
|
||||
// 点击上架
|
||||
const clickPutaway = async (row: any) => {
|
||||
if (!row.id) return useMessage().error("商品id不存在")
|
||||
const res = await hardSpu.putaway({ id: curCabinetItemId.value, hardSpuId: row.id })
|
||||
if (res.code == 0) {
|
||||
useMessage().success("上架成功")
|
||||
emit("refreshCabinet")
|
||||
visible.value = false
|
||||
return
|
||||
try {
|
||||
const res = await hardSpu.putaway({ id: curCabinetItemId.value, hardSpuId: row.id })
|
||||
if (res.code == 0) {
|
||||
useMessage().success("上架成功")
|
||||
emit("refreshCabinet")
|
||||
visible.value = false
|
||||
} else {
|
||||
useMessage().error(res.msg || "上架失败")
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg)
|
||||
}
|
||||
useMessage().error("上架失败")
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
||||
@@ -218,22 +218,32 @@ const getDetail = async () => {
|
||||
const id = query.id as unknown as any
|
||||
if (!id) return useMessage().error("设备id不存在")
|
||||
state.hardId = id
|
||||
const { data } = await hardDoorManager.getByHardId({ hardId: state.hardId })
|
||||
if (data) {
|
||||
state.deviceDetail = { ...data, cabinetList: JSON.parse(data.cabinetList) }
|
||||
try {
|
||||
const res = await hardDoorManager.getByHardId({ hardId: state.hardId })
|
||||
if (res.code == 0) {
|
||||
state.deviceDetail = res.data
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg)
|
||||
}
|
||||
}
|
||||
|
||||
// 获取柜子物品
|
||||
// 获取货柜物品
|
||||
const getCabinet = async (cabinetIndex: number = 0) => {
|
||||
if (!state.hardId) return useMessage().error("设备id不存在")
|
||||
if (!state.deviceDetail.cabinetList?.length) return useMessage().error("设备空间不存在")
|
||||
const { data } = await getByCabinetNo({
|
||||
hardId: state.hardId,
|
||||
cabinetNo: state.deviceDetail.cabinetList[cabinetIndex].cabinetNo,
|
||||
})
|
||||
if (data) {
|
||||
state.cabinetData = data
|
||||
try {
|
||||
const res = await getByCabinetNo({
|
||||
hardId: state.hardId,
|
||||
cabinetNo: state.deviceDetail.cabinetList[cabinetIndex].cabinetNo,
|
||||
})
|
||||
if (res.code == 0) {
|
||||
state.cabinetData = res.data
|
||||
} else {
|
||||
useMessage().error(res.msg || "获取货柜物品失败")
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,8 +49,17 @@ const openDialog = async (hardId: string) => {
|
||||
form.hardId = hardId
|
||||
dataFormRef.value?.resetFields()
|
||||
if (hardId) {
|
||||
const res = await hardDoorManager.getByHardId({ hardId: hardId })
|
||||
Object.assign(form, res.data)
|
||||
loading.value = true
|
||||
try {
|
||||
const res = await hardDoorManager.getByHardId({ hardId: hardId })
|
||||
if (res.code == 0) {
|
||||
Object.assign(form, res.data)
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -67,6 +76,8 @@ const onSubmit = async () => {
|
||||
useMessage().success("保存成功")
|
||||
visible.value = false
|
||||
emit("refreshInfo")
|
||||
} else {
|
||||
useMessage().error(res.msg || "保存失败")
|
||||
}
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
|
||||
@@ -57,12 +57,16 @@ const onSubmit = async () => {
|
||||
|
||||
try {
|
||||
loading.value = true
|
||||
await changeVolume(form)
|
||||
useMessage().success("保存成功")
|
||||
visible.value = false
|
||||
emit("refreshVolume", form)
|
||||
} catch (err: any) {
|
||||
useMessage().error(err.msg)
|
||||
const res = await changeVolume(form)
|
||||
if (res.code == 0) {
|
||||
useMessage().success("保存成功")
|
||||
visible.value = false
|
||||
emit("refreshVolume", form)
|
||||
} else {
|
||||
useMessage().error(res.msg || "保存失败")
|
||||
}
|
||||
} catch (error: any) {
|
||||
useMessage().error(error.msg)
|
||||
} finally {
|
||||
loading.value = false
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user