물건 상세 api 에러 메세지 띄우도록

This commit is contained in:
basssy 2024-12-06 14:10:33 +09:00
parent 96b163f1ac
commit 9042731ff8

View File

@ -917,7 +917,11 @@ export default function StuffDetail() {
})
// WL_
form.setValue('standardWindSpeedId', `WL_${info.windSpeed}`)
if (info.windSpeed !== '') {
form.setValue('standardWindSpeedId', `WL_${info.windSpeed}`)
} else {
form.setValue('standardWindSpeedId', `WL_${info.windSpeed}`)
}
form.setValue('verticalSnowCover', info.verticalSnowCover)
form.setValue('surfaceType', info.surfaceType)
@ -1046,7 +1050,7 @@ export default function StuffDetail() {
errors.prefId = true
}
if (!formData.areaId) {
if (!formData.areaId || formData.areaId === '0') {
errors.areaId = true
}
@ -1290,23 +1294,34 @@ export default function StuffDetail() {
}
if (editMode === 'NEW') {
await promisePost({ url: apiUrl, data: params }).then((res) => {
//
if (res.status === 201) {
alert(getMessage('stuff.detail.save'))
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
await promisePost({ url: apiUrl, data: params })
.then((res) => {
//
if (res.status === 201) {
alert(getMessage('stuff.detail.save'))
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
.catch((error) => {
console.log('error::::::', error)
alert(error?.response.data.message)
})
} else {
// PUT
await promisePut({ url: apiUrl, data: params }).then((res) => {
if (res.status === 201) {
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
alert(getMessage('stuff.detail.save'))
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
// await promisePut({ url: apiUrl, data: params }).then((res) => {
await promisePut({ url: apiUrl, data: params })
.then((res) => {
if (res.status === 201) {
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
alert(getMessage('stuff.detail.save'))
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
.catch((error) => {
console.log('error::::::', error)
alert(error?.response.data.message)
})
}
}
@ -1351,19 +1366,29 @@ export default function StuffDetail() {
const apiUrl = '/api/object/save-object'
if (objectNo) {
await promisePut({ url: apiUrl, data: params }).then((res) => {
if (res.status === 201) {
alert(getMessage('stuff.detail.tempSave.message1'))
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
await promisePut({ url: apiUrl, data: params })
.then((res) => {
if (res.status === 201) {
alert(getMessage('stuff.detail.tempSave.message1'))
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
.catch((error) => {
console.log('error::::::', error)
alert(error?.response.data.message)
})
} else {
await promisePost({ url: apiUrl, data: params }).then((res) => {
if (res.status === 201) {
alert(getMessage('stuff.detail.tempSave.message1'))
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
await promisePost({ url: apiUrl, data: params })
.then((res) => {
if (res.status === 201) {
alert(getMessage('stuff.detail.tempSave.message1'))
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
}
})
.catch((error) => {
console.log('error::::::', error)
alert(error?.response.data.message)
})
}
}