물건 상세 수정
This commit is contained in:
parent
05ef45bd38
commit
fcdd57cba2
@ -10,7 +10,7 @@ import { globalLocaleStore } from '@/store/localeAtom'
|
||||
import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import { useForm } from 'react-hook-form'
|
||||
import { useRecoilValue, useSetRecoilState } from 'recoil'
|
||||
import { useRecoilValue, useSetRecoilState, useResetRecoilState, useRecoilState } from 'recoil'
|
||||
import { SessionContext } from '@/app/SessionProvider'
|
||||
import FindAddressPop from './popup/FindAddressPop'
|
||||
import PlanRequestPop from './popup/PlanRequestPop'
|
||||
@ -20,8 +20,12 @@ import StuffPlanQGrid from './StuffPlanQGrid'
|
||||
import { floorPlanObjectState } from '@/store/floorPlanObjectAtom'
|
||||
import { ManagementContext } from '@/app/management/ManagementProvider'
|
||||
import DocDownOptionPop from '../estimate/popup/DocDownOptionPop'
|
||||
import { stuffSearchState } from '@/store/stuffAtom'
|
||||
|
||||
export default function StuffDetail() {
|
||||
const resetStuffRecoil = useResetRecoilState(stuffSearchState)
|
||||
const stuffSearchParams = useRecoilValue(stuffSearchState)
|
||||
|
||||
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //견적서 화면용 물건번호리코일
|
||||
|
||||
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
|
||||
@ -433,158 +437,160 @@ export default function StuffDetail() {
|
||||
}, [commonCode])
|
||||
|
||||
useEffect(() => {
|
||||
if (isObjectNotEmpty(managementState)) {
|
||||
// 도도부현API
|
||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setPrefCodeList(res)
|
||||
}
|
||||
})
|
||||
if (objectNo) {
|
||||
if (isObjectNotEmpty(managementState)) {
|
||||
// 도도부현API
|
||||
get({ url: '/api/object/prefecture/list' }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
setPrefCodeList(res)
|
||||
}
|
||||
})
|
||||
|
||||
//1차점 : X167 T01
|
||||
//2차점 : 10X22, 201X112
|
||||
let url
|
||||
let firstList
|
||||
let otherList
|
||||
let favList
|
||||
//1차점 : X167 T01
|
||||
//2차점 : 10X22, 201X112
|
||||
let url
|
||||
let firstList
|
||||
let otherList
|
||||
let favList
|
||||
|
||||
if (session?.storeId === 'T01') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
||||
} else {
|
||||
if (session.storeLvl === '1') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
if (session?.storeId === 'T01') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/firstList?userId=${session?.userId}`
|
||||
} else {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
}
|
||||
}
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
if (session?.storeId === 'T01') {
|
||||
firstList = res.filter((row) => row.saleStoreLevel === '1')
|
||||
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
|
||||
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(favList)
|
||||
setShowSaleStoreList(favList)
|
||||
|
||||
if (managementState.firstAgentId != null) {
|
||||
form.setValue('saleStoreId', managementState.firstAgentId)
|
||||
setSelOptions(managementState.firstAgentId)
|
||||
} else {
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
}
|
||||
|
||||
//상세데이터의 1차점 아이디로 2차점 목록 조회하기
|
||||
|
||||
let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
|
||||
url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
|
||||
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
res.map((row) => {
|
||||
row.value = row.saleStoreId
|
||||
row.label = row.saleStoreName
|
||||
})
|
||||
|
||||
otherList = res
|
||||
setOriginOtherSaleStoreList(otherList)
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
})
|
||||
if (session.storeLvl === '1') {
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
} else {
|
||||
//1차점 셀렉트박스
|
||||
if (session?.storeLvl === '1') {
|
||||
firstList = res
|
||||
favList = res.filter((row) => row.priority !== 'B')
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(firstList)
|
||||
setShowSaleStoreList(firstList)
|
||||
|
||||
setOtherSaleStoreList(otherList)
|
||||
} else {
|
||||
setSelOptions(res[0].saleStoreId)
|
||||
form.setValue('saleStoreId', res[0].saleStoreId)
|
||||
form.setValue('saleStoreLevel', res[0].storeLvl)
|
||||
setSaleStoreList(res)
|
||||
setFavoriteStoreList(res)
|
||||
setShowSaleStoreList(res)
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
url = `/api/object/saleStore/${session?.storeId}/list?firstFlg=1&userId=${session?.userId}`
|
||||
}
|
||||
}
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
if (session?.storeId === 'T01') {
|
||||
firstList = res.filter((row) => row.saleStoreLevel === '1')
|
||||
firstList.sort((a, b) => (a.saleStoreId !== 'T01') - (b.saleStoreId !== 'T01') || a.saleStoreId - b.saleStoreId)
|
||||
favList = firstList.filter((row) => row.saleStoreId === 'T01' || row.priority !== 'B')
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(favList)
|
||||
setShowSaleStoreList(favList)
|
||||
|
||||
//상세데이터가 1차점이면 1차점에 세팅
|
||||
//상세데이터가 2차점이면 2차점에 세팅하고 세션으로 1차점 세팅
|
||||
if (managementState.saleStoreLevel === '1') {
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
form.setValue('saleStoreLevel', managementState.saleStoreLevel)
|
||||
} else {
|
||||
setOtherSelOptions(managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreId', managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
|
||||
if (managementState.firstAgentId != null) {
|
||||
form.setValue('saleStoreId', managementState.firstAgentId)
|
||||
setSelOptions(managementState.firstAgentId)
|
||||
} else {
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
}
|
||||
|
||||
form.setValue('saleStoreLevel', '1')
|
||||
}
|
||||
//상세데이터의 1차점 아이디로 2차점 목록 조회하기
|
||||
|
||||
//설계의뢰No.
|
||||
form.setValue('planReqNo', managementState.planReqNo)
|
||||
//담당자
|
||||
form.setValue('receiveUser', managementState.receiveUser)
|
||||
let data = managementState?.firstAgentId ? managementState.firstAgentId : managementState.saleStoreId
|
||||
url = `/api/object/saleStore/${data}/list?firstFlg=0&userId=${session?.userId}`
|
||||
|
||||
//물건구분objectStatusId
|
||||
setSelectObjectStatusId(managementState.objectStatusId)
|
||||
form.setValue('objectStatusId', managementState.objectStatusId)
|
||||
get({ url: url }).then((res) => {
|
||||
if (!isEmptyArray(res)) {
|
||||
res.map((row) => {
|
||||
row.value = row.saleStoreId
|
||||
row.label = row.saleStoreName
|
||||
})
|
||||
|
||||
//물건명
|
||||
form.setValue('objectName', managementState.objectName)
|
||||
otherList = res
|
||||
setOriginOtherSaleStoreList(otherList)
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
})
|
||||
} else {
|
||||
//1차점 셀렉트박스
|
||||
if (session?.storeLvl === '1') {
|
||||
firstList = res
|
||||
favList = res.filter((row) => row.priority !== 'B')
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
|
||||
//경칭코드
|
||||
setSelHonorificCode(managementState.objectNameOmit)
|
||||
form.setValue('objectNameOmit', managementState.objectNameOmit)
|
||||
setSaleStoreList(firstList)
|
||||
setFavoriteStoreList(firstList)
|
||||
setShowSaleStoreList(firstList)
|
||||
|
||||
//물건명 후리가나
|
||||
form.setValue('objectNameKana', managementState.objectNameKana)
|
||||
setOtherSaleStoreList(otherList)
|
||||
} else {
|
||||
setSelOptions(res[0].saleStoreId)
|
||||
form.setValue('saleStoreId', res[0].saleStoreId)
|
||||
form.setValue('saleStoreLevel', res[0].storeLvl)
|
||||
setSaleStoreList(res)
|
||||
setFavoriteStoreList(res)
|
||||
setShowSaleStoreList(res)
|
||||
otherList = res.filter((row) => row.firstAgentYn === 'N')
|
||||
setOtherSaleStoreList(otherList)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//우편번호
|
||||
form.setValue('zipNo', managementState.zipNo)
|
||||
//상세데이터가 1차점이면 1차점에 세팅
|
||||
//상세데이터가 2차점이면 2차점에 세팅하고 세션으로 1차점 세팅
|
||||
if (managementState.saleStoreLevel === '1') {
|
||||
setSelOptions(managementState.saleStoreId)
|
||||
form.setValue('saleStoreId', managementState.saleStoreId)
|
||||
form.setValue('saleStoreLevel', managementState.saleStoreLevel)
|
||||
} else {
|
||||
setOtherSelOptions(managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreId', managementState.saleStoreId)
|
||||
form.setValue('otherSaleStoreLevel', managementState.saleStoreLevel)
|
||||
|
||||
//도도부현 / 주소
|
||||
setPrefValue(managementState.prefId)
|
||||
form.setValue('prefId', managementState.prefId)
|
||||
form.setValue('prefName', managementState.prefName)
|
||||
form.setValue('address', managementState.address)
|
||||
//발전시뮬
|
||||
form.setValue('areaId', managementState.areaId)
|
||||
form.setValue('saleStoreLevel', '1')
|
||||
}
|
||||
|
||||
//기준풍속
|
||||
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId)
|
||||
//수직적설량
|
||||
form.setValue('verticalSnowCover', managementState.verticalSnowCover)
|
||||
//한랭지대책시행 coldRegionFlg 1이면 true
|
||||
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
|
||||
//설계의뢰No.
|
||||
form.setValue('planReqNo', managementState.planReqNo)
|
||||
//담당자
|
||||
form.setValue('receiveUser', managementState.receiveUser)
|
||||
|
||||
//면조도구분 surfaceType null로 내려오면 셋팅 안하고 저장할때 필수값 체크하도록
|
||||
// form.setValue('surfaceType', 'Ⅱ')
|
||||
// form.setValue('surfaceType', 'Ⅲ・Ⅳ')
|
||||
form.setValue('surfaceType', managementState.surfaceType)
|
||||
//염해지역용아이템사용 saltAreaFlg 1이면 true
|
||||
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false)
|
||||
//설치높이
|
||||
form.setValue('installHeight', managementState.installHeight)
|
||||
//계약조건 null로 내려오면 0으로 디폴트셋팅
|
||||
if (managementState.conType === null) {
|
||||
form.setValue('conType', '0')
|
||||
} else {
|
||||
form.setValue('conType', managementState.conType)
|
||||
}
|
||||
//메모
|
||||
form.setValue('remarks', managementState.remarks)
|
||||
})
|
||||
//물건구분objectStatusId
|
||||
setSelectObjectStatusId(managementState.objectStatusId)
|
||||
form.setValue('objectStatusId', managementState.objectStatusId)
|
||||
|
||||
//물건명
|
||||
form.setValue('objectName', managementState.objectName)
|
||||
|
||||
//경칭코드
|
||||
setSelHonorificCode(managementState.objectNameOmit)
|
||||
form.setValue('objectNameOmit', managementState.objectNameOmit)
|
||||
|
||||
//물건명 후리가나
|
||||
form.setValue('objectNameKana', managementState.objectNameKana)
|
||||
|
||||
//우편번호
|
||||
form.setValue('zipNo', managementState.zipNo)
|
||||
|
||||
//도도부현 / 주소
|
||||
setPrefValue(managementState.prefId)
|
||||
form.setValue('prefId', managementState.prefId)
|
||||
form.setValue('prefName', managementState.prefName)
|
||||
form.setValue('address', managementState.address)
|
||||
//발전시뮬
|
||||
form.setValue('areaId', managementState.areaId)
|
||||
|
||||
//기준풍속
|
||||
form.setValue('standardWindSpeedId', managementState.standardWindSpeedId)
|
||||
//수직적설량
|
||||
form.setValue('verticalSnowCover', managementState.verticalSnowCover)
|
||||
//한랭지대책시행 coldRegionFlg 1이면 true
|
||||
form.setValue('coldRegionFlg', managementState.coldRegionFlg === '1' ? true : false)
|
||||
|
||||
//면조도구분 surfaceType null로 내려오면 셋팅 안하고 저장할때 필수값 체크하도록
|
||||
// form.setValue('surfaceType', 'Ⅱ')
|
||||
// form.setValue('surfaceType', 'Ⅲ・Ⅳ')
|
||||
form.setValue('surfaceType', managementState.surfaceType)
|
||||
//염해지역용아이템사용 saltAreaFlg 1이면 true
|
||||
form.setValue('saltAreaFlg', managementState.saltAreaFlg === '1' ? true : false)
|
||||
//설치높이
|
||||
form.setValue('installHeight', managementState.installHeight)
|
||||
//계약조건 null로 내려오면 0으로 디폴트셋팅
|
||||
if (managementState.conType === null) {
|
||||
form.setValue('conType', '0')
|
||||
} else {
|
||||
form.setValue('conType', managementState.conType)
|
||||
}
|
||||
//메모
|
||||
form.setValue('remarks', managementState.remarks)
|
||||
})
|
||||
}
|
||||
}
|
||||
}, [managementState])
|
||||
|
||||
@ -1267,7 +1273,7 @@ export default function StuffDetail() {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`)
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
@ -1276,8 +1282,7 @@ export default function StuffDetail() {
|
||||
if (res.status === 201) {
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
// router.refresh()
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`)
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
@ -1312,6 +1317,7 @@ export default function StuffDetail() {
|
||||
tempFlg: '1',
|
||||
workNo: null,
|
||||
workName: null,
|
||||
objectNo: objectNo ? objectNo : '',
|
||||
}
|
||||
|
||||
//1차점 or 2차점 안고르고 임시저장하면
|
||||
@ -1320,16 +1326,28 @@ export default function StuffDetail() {
|
||||
params.saleStoreLevel = session.storeLvl
|
||||
}
|
||||
|
||||
await promisePost({ url: '/api/object/save-object', data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.tempSave.message1'))
|
||||
router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`)
|
||||
}
|
||||
})
|
||||
const apiUrl = '/api/object/save-object'
|
||||
if (objectNo) {
|
||||
await promisePut({ url: apiUrl, data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
} else {
|
||||
Kle.log('썡판 신규', objectNo)
|
||||
await promisePost({ url: apiUrl, data: params }).then((res) => {
|
||||
if (res.status === 201) {
|
||||
alert(getMessage('stuff.detail.save'))
|
||||
router.push(`/management/stuff/tempdetail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// 물건삭제
|
||||
const onDelete = () => {
|
||||
// console.log('검색조건리코일값:::::', stuffSearchParams)
|
||||
const specificationConfirmDate = managementState.specificationConfirmDate
|
||||
if (specificationConfirmDate != null) {
|
||||
alert(getMessage('stuff.detail.delete.message1'))
|
||||
@ -1337,6 +1355,12 @@ export default function StuffDetail() {
|
||||
if (confirm(getMessage('common.message.data.delete'))) {
|
||||
del({ url: `/api/object/${objectNo}` }).then(() => {
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: '' })
|
||||
// console.log('초기화::::::::::')
|
||||
// resetStuffRecoil()
|
||||
// stuffSearchParams.code = 'DELETE'
|
||||
// stuffSearchParams.schSelSaleStoreId = ''
|
||||
// stuffSearchParams.schOtherSelSaleStoreId = ''
|
||||
// console.log('판매점 초기화도')
|
||||
router.push('/management/stuff')
|
||||
})
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user