diff --git a/src/components/management/Stuff.jsx b/src/components/management/Stuff.jsx index 58cd7bff..07119205 100644 --- a/src/components/management/Stuff.jsx +++ b/src/components/management/Stuff.jsx @@ -123,8 +123,8 @@ export default function Stuff() { { field: 'dispCompanyName', headerName: getMessage('stuff.gridHeader.dispCompanyName'), cellStyle: { textAlign: 'left' } }, { field: 'receiveUser', headerName: getMessage('stuff.gridHeader.receiveUser'), cellStyle: { textAlign: 'left' } }, { - field: 'specDate', - headerName: getMessage('stuff.gridHeader.specDate'), + field: 'specificationConfirmDate', + headerName: getMessage('stuff.gridHeader.specificationConfirmDate'), valueFormatter: function (params) { if (params.value) { return dayjs(params?.value).format('YYYY.MM.DD') diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index 928d2234..46353f08 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -31,7 +31,7 @@ export default function StuffDetail() { const { getMessage } = useMessage() const globalLocaleState = useRecoilValue(globalLocaleStore) const ref = useRef() - const { get, del, promisePost } = useAxios(globalLocaleState) + const { get, del, promisePost, promisePut } = useAxios(globalLocaleState) //form const formInitValue = { // 물건번호 T...(임시) R...(진짜) @@ -71,6 +71,8 @@ export default function StuffDetail() { const [honorificCodeList, setHonorificCodeList] = useState([]) //경칭 공통코드 리스트 const [selHonorificCode, setSelHonorificCode] = useState('') //선택한 경칭코드 const [objectStatusList, setObjectStatusList] = useState([]) //물건구분 공통코드 리스트 + + const [selectObjectStatusId, setSelectObjectStatusId] = useState('0') //신축기축 선택값 const [windSpeedList, setWindSpeedList] = useState([]) //기준 풍속 공통코드 리스트 const [prefCodeList, setPrefCodeList] = useState([]) //도도부현 코트 리스트 const [prefValue, setPrefValue] = useState('') @@ -93,7 +95,6 @@ export default function StuffDetail() { // console.log('objectNo::', objectNo) if (objectNo) { - console.log('수정화면') setEditMode('EDIT') if (objectNo.substring(0, 1) === 'R') { @@ -116,7 +117,6 @@ export default function StuffDetail() { //1차점 : X167 T01 //2차점 : 10X22, 201X112 - // get({ url: `/api/object/saleStore/T100/list` }).then((res) => { get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { if (!isEmptyArray(res)) { const firstList = res.filter((row) => row.saleStoreLevel === '1') @@ -171,11 +171,8 @@ export default function StuffDetail() { } }) - //상세정보로 1차점 목록등 셋팅?? - // 임시 1차점 판매점코드 saleStoreId=201TES01 - // T01 - //1차점 : X167 - // get({ url: `/api/object/saleStore/T01/list` }).then((res) => { + //1차점 : X167 T01 + //2차점 : 10X22, 201X112 get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => { if (!isEmptyArray(res)) { const firstList = res.filter((row) => row.saleStoreLevel === '1') @@ -186,11 +183,44 @@ export default function StuffDetail() { setOriginOtherSaleStoreList(otherList) setOtherSaleStoreList(otherList) } - }) + console.log('상세데이타::세팅:::::', detailData) + //설계의뢰No. + form.setValue('planReqNo', detailData.planReqNo) + //담당자 + form.setValue('dispCompanyName', detailData.dispCompanyName) - console.log('상세데이타::세팅:::::', detailData) + //물건구분objectStatusId + setSelectObjectStatusId(detailData.objectStatusId) + form.setValue('objectStatusId', detailData.objectStatusId) + + //물건명 + form.setValue('objectName', detailData.objectName) + + //경칭코드 + + setSelHonorificCode(detailData.objectNameOmit) + form.setValue('objectNameOmit', detailData.objectNameOmit) + + //물건명 후리가나 + form.setValue('objectNameKana', detailData.objectNameKana) + + // console.log('1차점리스트::', firstList) + // console.log('2차점리스트::', otherList) + setSelOptions(detailData.saleStoreId) + form.setValue('saleStoreId', detailData.saleStoreId) + form.setValue('saleStoreLevel', sessionState?.storeLvl) + + //2차점까지 고른경우 확인필요 + console.log('2차점까지 고른경우 확인필요') + // setOtherSelOptions(sessionState?.storeId) + // form.setValue('saleStoreId', firstList[0].saleStoreId) + // form.setValue('otherSaleStoreId', sessionState?.storeId) + // form.setValue('otherSaleStoreLevel', sessionState?.storeLvl) + + form.setValue('zipNo', detailData.zipNo) + }) } - }, [detailData]) + }, [detailData, sessionState]) //경칭선택 변경 이벤트 const onChangeHonorificCode = (key) => { @@ -212,45 +242,117 @@ export default function StuffDetail() { } } + //물건구분 변경 이벤트 + const onRadioChange = (key) => { + setSelectObjectStatusId(key.target.value) + } //1차점 변경 이벤트 const onSelectionChange = (key) => { - if (isObjectNotEmpty(key)) { - setOtherSaleStoreList(otherSaleStoreList) - form.setValue('saleStoreId', key.saleStoreId) - form.setValue('saleStoreName', key.saleStoreName) - form.setValue('saleStoreLevel', key.saleStoreLevel) - setSelOptions(key.saleStoreId) - //선택한 1차점 정보로 2차점 list 추리기 - //長府工産株式会社 大阪支社 - let newOtherSaleStoreList = originOtherSaleStoreList.filter((row) => row.firstAgentId === key.saleStoreId) - setOtherSaleStoreList(newOtherSaleStoreList) + const planReqNo = form.watch('planReqNo') + + let delFlg = false + if (planReqNo !== '') { + if (confirm('stuff.detail.confirm.message1')) { + delFlg = true + } else { + delFlg = false + } + } + + if (planReqNo !== '') { + if (delFlg) { + form.setValue('planReqNo', '') + if (isObjectNotEmpty(key)) { + setOtherSaleStoreList(otherSaleStoreList) + form.setValue('saleStoreId', key.saleStoreId) + form.setValue('saleStoreName', key.saleStoreName) + form.setValue('saleStoreLevel', key.saleStoreLevel) + setSelOptions(key.saleStoreId) + //선택한 1차점 정보로 2차점 list 추리기 + //長府工産株式会社 大阪支社 + let newOtherSaleStoreList = originOtherSaleStoreList.filter((row) => row.firstAgentId === key.saleStoreId) + setOtherSaleStoreList(newOtherSaleStoreList) + } else { + //X누름 + setSelOptions('') + form.setValue('saleStoreId', '') + form.setValue('saleStoreName', '') + form.setValue('saleStoreLevel', '') + form.setValue('otherSaleStoreId', '') + form.setValue('otherSaleStoreName', '') + form.setValue('otherSaleStoreLevel', '') + //1차점 지웠을때 2차점 자동완성 초기화 + setOtherSaleStoreList(originOtherSaleStoreList) + handleClear() + } + } } else { - //X누름 - setSelOptions('') - form.setValue('saleStoreId', '') - form.setValue('saleStoreName', '') - form.setValue('saleStoreLevel', '') - form.setValue('otherSaleStoreId', '') - form.setValue('otherSaleStoreName', '') - form.setValue('otherSaleStoreLevel', '') - setOtherSaleStoreList(originOtherSaleStoreList) - //1차점 지웠을때 2차점 자동완성 초기화 - handleClear() + if (isObjectNotEmpty(key)) { + setOtherSaleStoreList(otherSaleStoreList) + form.setValue('saleStoreId', key.saleStoreId) + form.setValue('saleStoreName', key.saleStoreName) + form.setValue('saleStoreLevel', key.saleStoreLevel) + setSelOptions(key.saleStoreId) + //선택한 1차점 정보로 2차점 list 추리기 + //長府工産株式会社 大阪支社 + let newOtherSaleStoreList = originOtherSaleStoreList.filter((row) => row.firstAgentId === key.saleStoreId) + setOtherSaleStoreList(newOtherSaleStoreList) + } else { + //X누름 + setSelOptions('') + form.setValue('saleStoreId', '') + form.setValue('saleStoreName', '') + form.setValue('saleStoreLevel', '') + form.setValue('otherSaleStoreId', '') + form.setValue('otherSaleStoreName', '') + form.setValue('otherSaleStoreLevel', '') + //1차점 지웠을때 2차점 자동완성 초기화 + setOtherSaleStoreList(originOtherSaleStoreList) + handleClear() + } } } //2차점 변경 이벤트 const onSelectionChange2 = (key) => { - if (isObjectNotEmpty(key)) { - setOtherSelOptions(key.saleStoreId) - form.setValue('otherSaleStoreId', key.saleStoreId) - form.setValue('otherSaleStoreName', key.saleStoreName) - form.setValue('otherSaleStoreLevel', key.saleStoreLevel) + const planReqNo = form.watch('planReqNo') + + let delFlg = false + if (planReqNo !== '') { + if (confirm('stuff.detail.confirm.message1')) { + delFlg = true + } else { + delFlg = false + } + } + + if (planReqNo !== '') { + if (delFlg) { + form.setValue('planReqNo', '') + if (isObjectNotEmpty(key)) { + setOtherSelOptions(key.saleStoreId) + form.setValue('otherSaleStoreId', key.saleStoreId) + form.setValue('otherSaleStoreName', key.saleStoreName) + form.setValue('otherSaleStoreLevel', key.saleStoreLevel) + } else { + setOtherSelOptions('') + form.setValue('otherSaleStoreId', '') + form.setValue('otherSaleStoreName', '') + form.setValue('otherSaleStoreLevel', '') + } + } } else { - setOtherSelOptions('') - form.setValue('otherSaleStoreId', '') - form.setValue('otherSaleStoreName', '') - form.setValue('otherSaleStoreLevel', '') + if (isObjectNotEmpty(key)) { + setOtherSelOptions(key.saleStoreId) + form.setValue('otherSaleStoreId', key.saleStoreId) + form.setValue('otherSaleStoreName', key.saleStoreName) + form.setValue('otherSaleStoreLevel', key.saleStoreLevel) + } else { + setOtherSelOptions('') + form.setValue('otherSaleStoreId', '') + form.setValue('otherSaleStoreName', '') + form.setValue('otherSaleStoreLevel', '') + } } } @@ -295,8 +397,8 @@ export default function StuffDetail() { if (info.saleStoreLevel === '1') { setSelOptions(info.saleStoreId) form.setValue('saleStoreId', info.saleStoreId) - form.setValue('saleStoreName', key.saleStoreName) - form.setValue('saleStoreLevel', key.saleStoreLevel) + form.setValue('saleStoreName', info.saleStoreName) + form.setValue('saleStoreLevel', info.saleStoreLevel) } else { setOtherSelOptions(info.saleStoreId) form.setValue('otherSaleStoreId', info.saleStoreId) @@ -310,40 +412,32 @@ export default function StuffDetail() { form.setValue('windSpeed', info.windSpeed) } - //임시저장 저장 버튼 컨트롤 - // dispCompanyName: '', //담당자 - // objectName: '', //물건명 - // objectNameOmit: '', //경칭선택 - // saleStoreId: '', //판매점ID - // zipNo: '', //우편번호 - // prefId: '', //도도부현 - // address: '', //주소 - // areaId: '', //발전량시뮬레이션지역new - // windSpeed: '', //기준풍속 - // verticalSnowCover: '', //수직적설량 - // coldRegionFlg: false, //한랭지대책시행 - // surfaceType: 'Ⅲ・Ⅳ', //면조도구분(Ⅲ・Ⅳ / Ⅱ) - // saltAreaFlg: false, //염해지역용아이템사용 - // installHeight: '', //설치높이 - // conType : '0' //계약조건(잉여 / 전량) - // remarks: '', //메모 - // tempFlag: 'T', //임시저장(1) 저장(0) + //dispCompanyName: '', //담당자 const _dispCompanyName = watch('dispCompanyName') + //objectName: '', //물건명 const _objectName = watch('objectName') + // objectNameOmit: '', //경칭선택 const _objectNameOmit = watch('objectNameOmit') + // saleStoreId: '', //1차 판매점ID const _saleStoreId = watch('saleStoreId') - const _saleStoreLevel = watch('saleStoreLevel') + // zipNo: '', //우편번호 + const _zipNo = watch('zipNo') + // prefId: '', //도도부현 const _prefId = watch('prefId') + // address: '', //주소 const _address = watch('address') - const _areaId = watch('areaId') //new + // areaId: '', //발전량시뮬레이션지역 + const _areaId = watch('areaId') + // windSpeed: '', //기준풍속 const _windSpeed = watch('windSpeed') + // verticalSnowCover: '', //수직적설량 const _verticalSnowCover = watch('verticalSnowCover') + // installHeight: '', //설치높이 const _installHeight = watch('installHeight') useEffect(() => { if (editMode === 'NEW') { const formData = form.getValues() - // console.log('임시저장폼error체크::::::::::::', formData) let errors = {} if (!formData.dispCompanyName || formData.dispCompanyName.trim().length === 0) { errors.dispCompanyName = true @@ -358,6 +452,10 @@ export default function StuffDetail() { errors.saleStoreId = true } + if (!formData.zipNo) { + errors.zipNo = true + } + if (!formData.prefId) { errors.prefId = true } @@ -378,19 +476,57 @@ export default function StuffDetail() { errors.installHeight = true } - // console.log('임시저장용::', errors) setIsFormValid(Object.keys(errors).length === 0 ? true : false) } else { console.log('상세일때 폼체크') + const formData = form.getValues() + let errors = {} + if (!formData.dispCompanyName || formData.dispCompanyName.trim().length === 0) { + errors.dispCompanyName = true + } + if (!formData.objectName || formData.objectName.trim().length === 0) { + errors.objectName = true + } + if (!formData.objectNameOmit) { + errors.objectNameOmit = true + } + if (!formData.saleStoreId) { + errors.saleStoreId = true + } + + if (!formData.zipNo) { + errors.zipNo = true + } + + if (!formData.prefId) { + errors.prefId = true + } + + if (!formData.areaId) { + errors.areaId = true + } + + if (!formData.windSpeed) { + errors.windSpeed = true + } + + if (!formData.verticalSnowCover) { + errors.verticalSnowCover = true + } + + if (!formData.installHeight) { + errors.installHeight = true + } + + console.log('상세 저장용 에러결과?????::', errors) + setIsFormValid(Object.keys(errors).length === 0 ? true : false) } }, [ _dispCompanyName, _objectName, _objectNameOmit, _saleStoreId, - _saleStoreLevel, - // _otherSaleStoreId, - // _otherSaleStoreLevel, + _zipNo, _prefId, _address, _areaId, @@ -424,8 +560,6 @@ export default function StuffDetail() { // 발전량시뮬레이션 지역 목록 get({ url: `/api/object/prefecture/${prefValue}/list` }).then((res) => { if (!isEmptyArray(res)) { - // form.setValue('areaId', res[0].areaId) - // form.setValue('areaName', res[0].prefName) setAreaIdList(res) } }) @@ -439,29 +573,52 @@ export default function StuffDetail() { } //필수값 다 입력했을때 - const onValid = (data, e) => { + const onValid = async () => { const formData = form.getValues() - console.log('필수값 통과:::', data, formData) - // console.log('필수값 formData:::', formData) - // 수정모드일때는 PUT - // console.log('필수값 다 있고 저장') - // console.log('data::::::', data) - // console.log('formData::::', formData) - // const _dispCompanyName = watch('dispCompanyName') - // const _objectStatusId = watch('objectStatusId') - // const _objectNameOmit = watch('objectNameOmit') - // const _zipNo = watch('zipNo') - // const _prefId = watch('prefId') - // const _address = watch('address') - // const _coldRegionFlg = watch('coldRegionFlg') - // console.log(_dispCompanyName) - // console.log(_objectStatusId) - // console.log(_objectNameOmit) - // console.log(_zipNo) - // console.log(_prefId) - // console.log('prefValue::', prefValue) - // console.log(_address) - // console.log('_coldRegionFlg::', _coldRegionFlg) + console.log('필수값 통과:::', formData) + const apiUrl = '/api/object/save-object' + const params = { + saleStoreId: formData.otherSaleStoreId ? formData.otherSaleStoreId : formData.saleStoreId, + saleStoreName: formData.otherSaleStoreName ? formData.otherSaleStoreName : formData.saleStoreName, + saleStoreLevel: formData.otherSaleStoreLevel ? formData.otherSaleStoreLevel : formData.saleStoreLevel, + objectStatusId: formData.objectStatusId, + objectName: formData.objectName, + objectNameOmit: formData.objectNameOmit, + objectNameKana: formData.objectNameKana, + zipNo: formData.zipNo, + prefId: formData.prefId, + prefName: formData.prefName, + address: formData.address, + areaId: formData.areaId, + receiveUser: formData.dispCompanyName, + installHeight: formData.installHeight, + windSpeed: formData.windSpeed, + verticalSnowCover: formData.verticalSnowCover, + surfaceType: formData.surfaceType, + conType: formData.conType, + coldRegionFlg: formData.coldRegionFlg, + saltAreaFlg: formData.saltAreaFlg, + tempFlg: '0', + workNo: null, + workName: null, + } + console.log('params::', params) + alert('작업중') + return + if (editMode === 'NEW') { + await promisePost({ url: apiUrl, data: params }).then((res) => { + console.log('진짜저장결과::::', pathname, res) + + //상세화면으로 전환 + //router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`) + }) + } else { + // 수정모드일때는 PUT + await promisePut({ url: apiUrl, data: params }).then((res) => { + console.log('진짜데이터 수정 결과::::::::::', pathname, res) + //새로고침??? + }) + } } //필수값 안넣었을때 임시저장 form required사용시 @@ -474,8 +631,6 @@ export default function StuffDetail() { // 임시저장 const onTempSave = async () => { const formData = form.getValues() - console.log('임시저장누름:::::', formData) - return const params = { saleStoreId: formData.otherSaleStoreId ? formData.otherSaleStoreId : formData.saleStoreId, saleStoreName: formData.otherSaleStoreName ? formData.otherSaleStoreName : formData.saleStoreName, @@ -501,15 +656,17 @@ export default function StuffDetail() { workNo: null, workName: null, } + //1차점 or 2차점 안고르고 임시저장하면 if (params.saleStoreId == '') { params.saleStoreId = sessionState.storeId params.saleStoreLevel = sessionState.storeLvl } - + alert('작업중') + return 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()}`) } }) @@ -576,7 +733,7 @@ export default function StuffDetail() {
{/* 라디오시작 */} - {objectStatusList.map((row, index) => { + {objectStatusList.map((row) => { return (
@@ -597,7 +756,7 @@ export default function StuffDetail() {
-
*/} {/* 기준풍속sel시작 */}
- - - - -
*/}
@@ -905,7 +1054,7 @@ export default function StuffDetail() { ) : ( )} @@ -935,11 +1084,15 @@ export default function StuffDetail() {
- +
- + {objectNo.substring(0, 1) === 'T' ? ( + <> + + + ) : null}
@@ -969,6 +1122,8 @@ export default function StuffDetail() { value={row.clCode} id={`objectStatus${row.clCode}`} {...register('objectStatusId')} + onChange={onRadioChange} + checked={row.clCode === selectObjectStatusId} />
@@ -981,7 +1136,7 @@ export default function StuffDetail() {
@@ -1021,15 +1178,21 @@ export default function StuffDetail() {
- {/* */} + getOptionLabel={(x) => x.saleStoreName} + getOptionValue={(x) => x.saleStoreId} + isClearable={sessionState?.storeLvl === '1' ? true : false} + value={saleStoreList.filter(function (option) { + return option.saleStoreId === selOptions + })} + />
@@ -1037,6 +1200,64 @@ export default function StuffDetail() {
+ + +
+
{getMessage('stuff.detail.otherSaleStoreId')}
+
+ {getMessage('stuff.detail.tooltip.saleStoreId')} +
+
+ + +
+
+ +
+
+ + + + + {getMessage('stuff.detail.zipNo')} * + + +
+
+ +
+ +
{getMessage('stuff.detail.btn.addressPop.guide')}
+
+ +
diff --git a/src/locales/ja.json b/src/locales/ja.json index c4c09341..2b743e4a 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -454,7 +454,7 @@ "stuff.gridHeader.address": "商品アドレス", "stuff.gridHeader.dispCompanyName": "見積もり", "stuff.gridHeader.receiveUser": "担当者", - "stuff.gridHeader.specDate": "仕様確認日", + "stuff.gridHeader.specificationConfirmDate": "仕様確認日", "stuff.gridHeader.createDatetime": "登録日", "stuff.message.periodError": "最大1年間閲覧可能.", "stuff.addressPopup.title": "郵便番号", @@ -495,6 +495,8 @@ "stuff.detail.conType1": "全量", "stuff.detail.remarks": "メモ", "stuff.detail.tooltip.saleStoreId": "販売代理店または販売代理店IDを1文字以上入力してください", + "stuff.detail.tempSave.message1": "一時保存されました。商品番号を取得するには、必須項目をすべて入力してください。", + "stuff.detail.confirm.message1": "販売店情報を変更すると、設計依頼文書番号が削除されます。変更しますか?", "stuff.planReqPopup.popTitle": "設計依頼検索", "stuff.planReqPopup.btn1": "検索", "stuff.planReqPopup.btn2": "初期化", diff --git a/src/locales/ko.json b/src/locales/ko.json index f5394e2e..61f3ba9e 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -459,7 +459,7 @@ "stuff.gridHeader.address": "물건주소", "stuff.gridHeader.dispCompanyName": "견적처", "stuff.gridHeader.receiveUser": "담당자", - "stuff.gridHeader.specDate": "사양확인일", + "stuff.gridHeader.specificationConfirmDate": "사양확인일", "stuff.gridHeader.createDatetime": "등록일", "stuff.message.periodError": "최대1년 조회 가능합니다.", "stuff.addressPopup.title": "우편번호", @@ -500,6 +500,8 @@ "stuff.detail.conType1": "전량", "stuff.detail.remarks": "메모", "stuff.detail.tooltip.saleStoreId": "판매대리점 또는 판매대리점ID를 1자 이상 입력하세요", + "stuff.detail.tempSave.message1": "임시저장 되었습니다. 물건번호를 획득하려면 필수 항목을 모두 입력해 주십시오.", + "stuff.detail.confirm.message1": "판매점 정보를 변경하면, 설계의뢰 문서번호가 삭제됩니다. 변경하시겠습니까?", "stuff.planReqPopup.popTitle": "설계 요청 검색", "stuff.planReqPopup.btn1": "검색", "stuff.planReqPopup.btn2": "초기화",