diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index f8cf0aab..e857fd4e 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -269,8 +269,8 @@ export default function StuffDetail() { } } if (managementState?.createUser === 'T01' && session?.userId !== 'T01') { - //createUser가 T01인데 로그인사용자가 T01이 아니면 버튼숨기기 - buttonStyle = { display: 'none' } + //createUser가 T01인데 로그인사용자가 T01이 아니면 버튼숨기기 적용할지 미정!!!!!!!! + //buttonStyle = { display: 'none' } } return ( <> @@ -282,8 +282,6 @@ export default function StuffDetail() { onClick={() => { //mid:5(견적서), /pid:플랜번호 setFloorPlanObjectNo({ floorPlanObjectNo: params.data.objectNo }) - // router.push(`/floor-plan/estimate/5/${params.data.planNo}`) - // /floor-plan/estimate/5?pid=플랜번호&objectNo=물건번호 router.push(`/floor-plan/estimate/5?pid=${params.data.planNo}&objectNo=${objectNo}`) }} > @@ -332,7 +330,7 @@ export default function StuffDetail() { //createUser가 T01인데 로그인사용자가 T01이 아니면 버튼숨기기 setShowButton('none') } - // console.log('상세::', res.data) + console.log('상세::', res.data) if (isObjectNotEmpty(res.data)) { let surfaceTypeValue if (res.data.surfaceType === 'Ⅲ・Ⅳ') { @@ -482,8 +480,6 @@ export default function StuffDetail() { } }) - //1차점 : X167 T01 - //2차점 : 10X22, 201X112 let url let firstList let otherList @@ -928,10 +924,13 @@ export default function StuffDetail() { const setPlanReqInfo = (info) => { // console.log('session 정보:::::::', session) // console.log('설계의뢰에서 넘어온 정보:::::::', info) + form.setValue('planReqNo', info.planReqNo) + form.setValue('objectStatusId', info.building) setSelectObjectStatusId(info.building) - form.setValue('objectName', info.planReqName) + + form.setValue('objectName', info.title) form.setValue('zipNo', info.zipNo) form.setValue('address', info.address2) @@ -1323,6 +1322,12 @@ export default function StuffDetail() { return alert(getMessage('stuff.detail.tempSave.message2')) } } + //로그인이 2차점인데 otherSaleStoreId가 없으면 알럿 + if (session.storeLvl !== '1') { + if (params.saleStoreLevel === '1') { + return alert(getMessage('stuff.detail.tempSave.message4')) + } + } if (editMode === 'NEW') { await promisePost({ url: apiUrl, data: params }) @@ -1731,7 +1736,10 @@ export default function StuffDetail() {
-
{getMessage('stuff.detail.otherSaleStoreId')}
+
+ {getMessage('stuff.detail.otherSaleStoreId')} + {session.storeLvl !== '1' && *} +
{getMessage('stuff.detail.tooltip.saleStoreId')}
@@ -1752,7 +1760,16 @@ export default function StuffDetail() { onChange={onSelectionChange2} getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} - isDisabled={otherSaleStoreList != null && otherSaleStoreList.length === 1 ? true : false} + isDisabled={ + session?.storeLvl === '1' + ? otherSaleStoreList.length > 0 + ? false + : true + : otherSaleStoreList.length === 1 + ? true + : false + } + // isDisabled={otherSaleStoreList != null && otherSaleStoreList.length === 1 ? true : false} isClearable={true} value={otherSaleStoreList.filter(function (option) { return option.saleStoreId === otherSelOptions @@ -2302,14 +2319,16 @@ export default function StuffDetail() { onChange={onSelectionChange2} getOptionLabel={(x) => x.saleStoreName} getOptionValue={(x) => x.saleStoreId} - isDisabled={ - managementState?.tempFlg === '0' - ? true - : session?.storeLvl === '1' && form.watch('saleStoreId') != '' - ? false - : true - } - isClearable={managementState?.tempFlg === '0' ? false : session?.storeLvl === '1' ? true : false} + // isDisabled={ + // managementState?.tempFlg === '0' + // ? true + // : session?.storeLvl === '1' && form.watch('saleStoreId') != '' + // ? false + // : false + // } + isDisabled={managementState?.tempFlg === '0' ? true : false} + isClearable={managementState?.tempFlg === '0' ? false : true} + // isClearable={managementState?.tempFlg === '0' ? false : session?.storeLvl === '1' ? true : true} value={otherSaleStoreList.filter(function (option) { return option.saleStoreId === otherSelOptions })} diff --git a/src/components/management/StuffPlanQGrid.jsx b/src/components/management/StuffPlanQGrid.jsx index 72c74eb5..90bcda91 100644 --- a/src/components/management/StuffPlanQGrid.jsx +++ b/src/components/management/StuffPlanQGrid.jsx @@ -40,7 +40,6 @@ export default function StuffPlanQGrid(props) { rowData={rowData} columnDefs={colDefs} defaultColDef={defaultColDef} - rowSelection={'singleRow'} pagination={isPageable} domLayout="autoHeight" suppressCellFocus={true} diff --git a/src/components/management/popup/FindAddressPopQGrid.jsx b/src/components/management/popup/FindAddressPopQGrid.jsx index ba703625..6447dd48 100644 --- a/src/components/management/popup/FindAddressPopQGrid.jsx +++ b/src/components/management/popup/FindAddressPopQGrid.jsx @@ -56,7 +56,6 @@ export default function FindAddressPopGrid(props) { rowData={rowData} columnDefs={colDefs} defaultColDef={defaultColDef} - rowSelection={'singleRow'} pagination={isPageable} onSelectionChanged={onSelectionChanged} overlayNoRowsTemplate={`${getMessage('stuff.grid.noData')}`} diff --git a/src/components/management/popup/PlanRequestPop.jsx b/src/components/management/popup/PlanRequestPop.jsx index aa415edd..34fba57f 100644 --- a/src/components/management/popup/PlanRequestPop.jsx +++ b/src/components/management/popup/PlanRequestPop.jsx @@ -50,7 +50,6 @@ export default function PlanRequestPop(props) { const [schSaleStoreName, setSchSaleStoreName] = useState('') //판매대리점명 const [schPlanReqName, setSchPlanReqName] = useState('') //의뢰자명 const [schPlanStatCd, setSchPlanStatCd] = useState('') //상태코드 - const [schDateGbn, setSchDateGbn] = useState('S') //기간구분코드(S/R) //초기화 const resetRecoil = () => { @@ -59,7 +58,6 @@ export default function PlanRequestPop(props) { setSchAddress('') setSchSaleStoreName('') setSchPlanReqName('') - setSchDateGbn('S') setStartDate(dayjs(new Date()).add(-3, 'month').format('YYYY-MM-DD')) setEndDate(dayjs(new Date()).format('YYYY-MM-DD')) setSchPlanStatCd('') @@ -85,10 +83,7 @@ export default function PlanRequestPop(props) { // 조회 const onSubmit = (page, type) => { - //2차점 테스트 201X112 const params = { - // saleStoreId: 'X112', - // saleStoreLevel: '1', saleStoreId: props?.otherSaleStoreId ? props.otherSaleStoreId : props.saleStoreId, saleStoreLevel: props?.otherSaleStoreLevel ? props.otherSaleStoreLevel : props.saleStoreLevel, schPlanReqNo: schPlanReqNo, @@ -97,7 +92,7 @@ export default function PlanRequestPop(props) { schSaleStoreName: schSaleStoreName, schPlanReqName: schPlanReqName, schPlanStatCd: schPlanStatCd, - schDateGbn: schDateGbn, + schDateGbn: 'R', schStartDt: startDate ? dayjs(startDate).format('YYYY-MM-DD') : '', schEndDt: endDate ? dayjs(endDate).format('YYYY-MM-DD') : '', startRow: type === 'S' ? (1 - 1) * pageSize + 1 : (page - 1) * pageSize + 1, @@ -135,8 +130,6 @@ export default function PlanRequestPop(props) { //페이지 갯수 변경 이벤트 const onChangePerPage = (e) => { const params = { - // saleStoreId: 'T100', - // saleStoreLevel: '1', saleStoreId: props?.otherSaleStoreId ? props.otherSaleStoreId : props.saleStoreId, saleStoreLevel: props?.otherSaleStoreLevel ? props.otherSaleStoreLevel : props.saleStoreLevel, schTitle: schTitle, @@ -145,7 +138,7 @@ export default function PlanRequestPop(props) { schSaleStoreName: schSaleStoreName, schPlanReqName: schPlanReqName, schPlanStatCd: schPlanStatCd, - schDateGbn: schDateGbn, + schDateGbn: 'R', schStartDt: dayjs(startDate).format('YYYY-MM-DD'), schEndDt: dayjs(endDate).format('YYYY-MM-DD'), startRow: (1 - 1) * e.target.value + 1, @@ -412,34 +405,6 @@ export default function PlanRequestPop(props) { {getMessage('stuff.planReqPopup.search.period')}
-
-
- { - setSchDateGbn(e.target.value) - }} - /> - -
-
- { - setSchDateGbn(e.target.value) - }} - /> - -
-
diff --git a/src/components/management/popup/PlanRequestPopQGrid.jsx b/src/components/management/popup/PlanRequestPopQGrid.jsx index 955a24ff..f7dbba0f 100644 --- a/src/components/management/popup/PlanRequestPopQGrid.jsx +++ b/src/components/management/popup/PlanRequestPopQGrid.jsx @@ -56,7 +56,6 @@ export default function PlanRequestPopQGrid(props) { rowData={rowData} columnDefs={colDefs} defaultColDef={defaultColDef} - rowSelection={'singleRow'} pagination={isPageable} onSelectionChanged={onSelectionChanged} overlayNoRowsTemplate={`${getMessage('stuff.grid.noData')}`} diff --git a/src/hooks/option/useCanvasSetting.js b/src/hooks/option/useCanvasSetting.js index bdad3643..1691d2cc 100644 --- a/src/hooks/option/useCanvasSetting.js +++ b/src/hooks/option/useCanvasSetting.js @@ -273,7 +273,7 @@ export function useCanvasSetting() { // 기본설정(PlacementShapeSetting) 조회 및 초기화 const fetchBasicSettings = async () => { try { - await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/0/${correntObjectNo}` }).then((res) => { + await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => { let roofsRow = {} let roofsArray = {} @@ -288,7 +288,7 @@ export function useCanvasSetting() { roofsArray = res.map((item) => { return { roofApply: true, - roofSeq: 1, + roofSeq: 0, roofMatlCd: item.roofMatlCd, roofWidth: item.roofWidth, roofHeight: item.roofHeight, @@ -308,7 +308,7 @@ export function useCanvasSetting() { roofsArray = [ { roofApply: true, - roofSeq: 1, + roofSeq: 0, roofMatlCd: 'ROOF_ID_WA_53A', roofWidth: 265, roofHeight: 235, @@ -391,7 +391,7 @@ export function useCanvasSetting() { setCanvasSetting({ ...basicSetting }) fetchBasicSettings() } catch (error) { - swalFire({ text: getMessage(res.returnMessage), icon: 'error' }) + swalFire({ text: error.message, icon: 'error' }) } } diff --git a/src/hooks/roofcover/useRoofAllocationSetting.js b/src/hooks/roofcover/useRoofAllocationSetting.js index 0671f502..70c421b9 100644 --- a/src/hooks/roofcover/useRoofAllocationSetting.js +++ b/src/hooks/roofcover/useRoofAllocationSetting.js @@ -1,9 +1,10 @@ import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil' import { canvasState, currentMenuState, currentObjectState } from '@/store/canvasAtom' import { useEffect, useRef, useState } from 'react' +import { useAxios } from '@/hooks/useAxios' import { useSwal } from '@/hooks/useSwal' import { usePolygon } from '@/hooks/usePolygon' -import { addedRoofsState, basicSettingState, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector } from '@/store/settingAtom' +import { correntObjectNoState, addedRoofsState, basicSettingState, roofDisplaySelector, roofMaterialsSelector, selectedRoofMaterialSelector } from '@/store/settingAtom' import { usePopup } from '@/hooks/usePopup' import { POLYGON_TYPE } from '@/common/common' import { v4 as uuidv4 } from 'uuid' @@ -14,10 +15,12 @@ import { useCanvasMenu } from '@/hooks/common/useCanvasMenu' import { menuTypeState } from '@/store/menuAtom' import { useRoofFn } from '@/hooks/common/useRoofFn' import { ROOF_MATERIAL_LAYOUT } from '@/components/floor-plan/modal/placementShape/PlacementShapeSetting' +import { globalLocaleStore } from '@/store/localeAtom' // 지붕면 할당 export function useRoofAllocationSetting(id) { const canvas = useRecoilValue(canvasState) + const [correntObjectNo, setCorrentObjectNo] = useRecoilState(correntObjectNoState) const roofDisplay = useRecoilValue(roofDisplaySelector) const { drawDirectionArrow, addLengthText, splitPolygonWithLines, splitPolygonWithSeparate } = usePolygon() const [popupId, setPopupId] = useState(uuidv4()) @@ -35,6 +38,9 @@ export function useRoofAllocationSetting(id) { const [editingLines, setEditingLines] = useState([]) const [currentRoofList, setCurrentRoofList] = useState(roofList) + const globalLocaleState = useRecoilValue(globalLocaleStore) + const { get, post } = useAxios(globalLocaleState) + const { setSurfaceShapePattern } = useRoofFn() useEffect(() => { @@ -74,8 +80,120 @@ export function useRoofAllocationSetting(id) { swalFire({ text: '할당할 지붕이 없습니다.' }) closePopup(id) } + + // console.log('🚀 ~ useEffect ~ roofMaterials >>>>>>>>>>>>> :', roofMaterials) + // console.log('🚀 ~ useEffect ~ basicSetting >>>>>>>>>>>>> :', basicSetting) + // console.log('🚀 ~ useEffect ~ roofList >>>>>>>>>>>>> :', roofList) + // console.log('🚀 ~ useEffect ~ currentRoofList >>>>>>>>>>>>> :', currentRoofList) + + fetchBasicSettings() }, []) + // 조회 및 초기화 + const fetchBasicSettings = async () => { + try { + await get({ url: `/api/canvas-management/canvas-basic-settings/by-object/1/${correntObjectNo}` }).then((res) => { + console.log('🚀 ~ useRoofAllocationSetting ~ fetchBasicSettings ~ res >>>>>>>>>>>>>>>>>>>>> :', res) + let roofsArray = {} + + if (res.length > 0) { + roofsArray = res.map((item) => { + return { + roofApply: item.roofApply, + roofSeq: item.roofSeq, + roofMatlCd: item.roofMatlCd, + roofWidth: item.roofWidth, + roofHeight: item.roofHeight, + roofHajebichi: item.roofHajebichi, + roofGap: item.roofGap, + roofLayout: item.roofLayout, + } + }) + } else { + + roofsArray = [ + { + roofApply: true, + roofSeq: 0, + roofMatlCd: 'ROOF_ID_WA_53A', + roofWidth: 265, + roofHeight: 235, + roofHajebichi: 0, + roofGap: 'HEI_455', + roofLayout: 'P', + }, + ] + } + + // 나머지 데이터와 함께 'roofs' 배열을 patternData에 넣음 + const patternData = { + roofs: roofsArray, // 만들어진 roofs 배열 + } + + console.log('fetchBasicSettings roofsArray', roofsArray) + + // 데이터 설정 + const selectRoofs = [] + for (let i = 0; i < roofsArray.length; i++) { + roofMaterials?.map((material) => { + if (material.roofMatlCd === roofsArray[i].roofMatlCd) { + selectRoofs.push({ ...material + , selected: roofsArray[i].roofApply + , index: roofsArray[i].roofSeq + , id: roofsArray[i].roofMatlCd + , width: roofsArray[i].roofWidth + , length: roofsArray[i].roofHeight + , hajebichi: roofsArray[i].roofHajebichi + , raft: roofsArray[i].roofGap + , layout: roofsArray[i].roofLayout + }) + setCurrentRoofList(selectRoofs) + } + }) + } + setBasicSetting({ ...basicSetting, roofsData: roofsArray}) + }) + } catch (error) { + console.error('Data fetching error:', error) + } + } + + // 저장 + const basicSettingSave = async () => { + + const patternData = { + objectNo: correntObjectNo, + roofSizeSet: basicSetting.roofSizeSet, + roofAngleSet: basicSetting.roofAngleSet, + roofMaterialsAddList: currentRoofList.map((item) => ({ + roofApply: item.selected === null || item.selected === undefined ? 'true' : item.selected, + roofSeq: item.index === null || item.index === undefined ? 0 : item.index, + roofMatlCd: item.roofMatlCd === null || item.roofMatlCd === undefined ? 'ROOF_ID_WA_53A' : item.roofMatlCd, + roofWidth: item.width === null || item.width === undefined ? 0 : item.width, + roofHeight: item.length === null || item.length === undefined ? 0 : item.length, + roofHajebichi: item.hajebichi === null || item.hajebichi === undefined ? 0 : item.hajebichi, + roofGap: item.raft === null || item.raft === undefined ? 'HEI_455' : item.raft, + roofLayout: item.layout === null || item.layout === undefined ? 'P' : item.layout, + }) + ), + } + + console.log('🚀 ~ basicSettingSave ~ patternData >>>>>>>>>>>>> :', patternData) + + // HTTP POST 요청 보내기 + await post({ url: `/api/canvas-management/canvas-basic-settings`, data: patternData }) + .then((res) => { + swalFire({ text: getMessage(res.returnMessage) }) + + //Recoil 설정 + // setCanvasSetting({ ...basicSetting }) + fetchBasicSettings() + }) + .catch((error) => { + swalFire({ text: error.message, icon: 'error' }) + }) + } + const onAddRoofMaterial = () => { if (currentRoofList.length >= 4) { swalFire({ type: 'alert', icon: 'error', text: getMessage('지붕재는 4개까지 선택 가능합니다.') }) @@ -103,13 +221,17 @@ export function useRoofAllocationSetting(id) { } // 선택한 지붕재로 할당 - const handleSave = () => { + const handleSave = () => { + + basicSettingSave() + // 모두 actualSize 있으면 바로 적용 없으면 actualSize 설정 - if (checkInnerLines()) { + if (checkInnerLines()) { addPopup(popupId, 1, ) } else { apply() } + } // 지붕재 오른쪽 마우스 클릭 후 단일로 지붕재 변경 필요한 경우 diff --git a/src/locales/ja.json b/src/locales/ja.json index dce33100..8a9eb01a 100644 --- a/src/locales/ja.json +++ b/src/locales/ja.json @@ -685,6 +685,7 @@ "stuff.detail.save.valierror1": "垂直説説は0より大きい値を入力してください", "stuff.detail.save.valierror2": "設置高さ0より大きい値を入力してください", "stuff.detail.save.valierror3": "{0} 必須入力項目です.", + "stuff.detail.save.valierror4": "二次販売店名は必須オプションです.", "stuff.planReqPopup.popTitle": "設計依頼検索", "stuff.planReqPopup.btn1": "検索", "stuff.planReqPopup.btn2": "初期化", diff --git a/src/locales/ko.json b/src/locales/ko.json index cbd263c7..e8320632 100644 --- a/src/locales/ko.json +++ b/src/locales/ko.json @@ -695,6 +695,7 @@ "stuff.detail.save.valierror1": "수직적설량은 0보다 큰 값을 입력하세요", "stuff.detail.save.valierror2": "설치높이는 0보다 큰 값을 입력하세요", "stuff.detail.save.valierror3": "{0} 필수 입력 항목입니다.", + "stuff.detail.save.valierror4": "2차 판매점명은 필수 선택사항입니다.", "stuff.planReqPopup.popTitle": "설계 요청 검색", "stuff.planReqPopup.btn1": "검색", "stuff.planReqPopup.btn2": "초기화",