智能柜详情接口请求错误处理
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) => {
|
const clickPutaway = async (row: any) => {
|
||||||
if (!row.id) return useMessage().error("商品id不存在")
|
if (!row.id) return useMessage().error("商品id不存在")
|
||||||
const res = await hardSpu.putaway({ id: curCabinetItemId.value, hardSpuId: row.id })
|
try {
|
||||||
if (res.code == 0) {
|
const res = await hardSpu.putaway({ id: curCabinetItemId.value, hardSpuId: row.id })
|
||||||
useMessage().success("上架成功")
|
if (res.code == 0) {
|
||||||
emit("refreshCabinet")
|
useMessage().success("上架成功")
|
||||||
visible.value = false
|
emit("refreshCabinet")
|
||||||
return
|
visible.value = false
|
||||||
|
} else {
|
||||||
|
useMessage().error(res.msg || "上架失败")
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
useMessage().error(error.msg)
|
||||||
}
|
}
|
||||||
useMessage().error("上架失败")
|
|
||||||
}
|
}
|
||||||
|
|
||||||
defineExpose({
|
defineExpose({
|
||||||
|
|||||||
@@ -218,22 +218,32 @@ const getDetail = async () => {
|
|||||||
const id = query.id as unknown as any
|
const id = query.id as unknown as any
|
||||||
if (!id) return useMessage().error("设备id不存在")
|
if (!id) return useMessage().error("设备id不存在")
|
||||||
state.hardId = id
|
state.hardId = id
|
||||||
const { data } = await hardDoorManager.getByHardId({ hardId: state.hardId })
|
try {
|
||||||
if (data) {
|
const res = await hardDoorManager.getByHardId({ hardId: state.hardId })
|
||||||
state.deviceDetail = { ...data, cabinetList: JSON.parse(data.cabinetList) }
|
if (res.code == 0) {
|
||||||
|
state.deviceDetail = res.data
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
useMessage().error(error.msg)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 获取柜子物品
|
// 获取货柜物品
|
||||||
const getCabinet = async (cabinetIndex: number = 0) => {
|
const getCabinet = async (cabinetIndex: number = 0) => {
|
||||||
if (!state.hardId) return useMessage().error("设备id不存在")
|
if (!state.hardId) return useMessage().error("设备id不存在")
|
||||||
if (!state.deviceDetail.cabinetList?.length) return useMessage().error("设备空间不存在")
|
if (!state.deviceDetail.cabinetList?.length) return useMessage().error("设备空间不存在")
|
||||||
const { data } = await getByCabinetNo({
|
try {
|
||||||
hardId: state.hardId,
|
const res = await getByCabinetNo({
|
||||||
cabinetNo: state.deviceDetail.cabinetList[cabinetIndex].cabinetNo,
|
hardId: state.hardId,
|
||||||
})
|
cabinetNo: state.deviceDetail.cabinetList[cabinetIndex].cabinetNo,
|
||||||
if (data) {
|
})
|
||||||
state.cabinetData = data
|
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
|
form.hardId = hardId
|
||||||
dataFormRef.value?.resetFields()
|
dataFormRef.value?.resetFields()
|
||||||
if (hardId) {
|
if (hardId) {
|
||||||
const res = await hardDoorManager.getByHardId({ hardId: hardId })
|
loading.value = true
|
||||||
Object.assign(form, res.data)
|
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("保存成功")
|
useMessage().success("保存成功")
|
||||||
visible.value = false
|
visible.value = false
|
||||||
emit("refreshInfo")
|
emit("refreshInfo")
|
||||||
|
} else {
|
||||||
|
useMessage().error(res.msg || "保存失败")
|
||||||
}
|
}
|
||||||
} catch (err: any) {
|
} catch (err: any) {
|
||||||
useMessage().error(err.msg)
|
useMessage().error(err.msg)
|
||||||
|
|||||||
@@ -57,12 +57,16 @@ const onSubmit = async () => {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
loading.value = true
|
loading.value = true
|
||||||
await changeVolume(form)
|
const res = await changeVolume(form)
|
||||||
useMessage().success("保存成功")
|
if (res.code == 0) {
|
||||||
visible.value = false
|
useMessage().success("保存成功")
|
||||||
emit("refreshVolume", form)
|
visible.value = false
|
||||||
} catch (err: any) {
|
emit("refreshVolume", form)
|
||||||
useMessage().error(err.msg)
|
} else {
|
||||||
|
useMessage().error(res.msg || "保存失败")
|
||||||
|
}
|
||||||
|
} catch (error: any) {
|
||||||
|
useMessage().error(error.msg)
|
||||||
} finally {
|
} finally {
|
||||||
loading.value = false
|
loading.value = false
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user