wr: 수요처 수정
This commit is contained in:
@@ -21,6 +21,7 @@ Main technologies:
|
||||
|
||||
## 주석 comment
|
||||
- 한글 주석을 삭제하지 말 것
|
||||
- 신규 component나 함수 자동 생성시 주석을 추가할 것(기본 함수의 역할과 인수 설명)
|
||||
|
||||
## Monorepo structure
|
||||
apps/
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
"use client";
|
||||
|
||||
/**
|
||||
* 수요처관리
|
||||
*/
|
||||
import { useWrStore } from "@/app/store";
|
||||
import { btnClass } from "@/app/store/common/code";
|
||||
import { excelCoSttnParsing } from "@/app/store/matDmd/coSttn/excel";
|
||||
@@ -188,6 +191,47 @@ export default function CoSttn() {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 등록/수정 : SdmInsertForm에서 저장 버튼을 눌렀을 때, 폼 데이터가 부모로 넘어오는 콜백
|
||||
* @param data
|
||||
* @returns
|
||||
*/
|
||||
const handleRtnInputData = async (data: DemandCompType) => {
|
||||
const con =
|
||||
objSearch.sgg && objSearch.sgg !== "0"
|
||||
? objSearch.sgg
|
||||
: objSearch.city;
|
||||
|
||||
if (updateData?.dmdInfoId) { // 수정
|
||||
const message = await updateDemandCompany(data);
|
||||
alert(message);
|
||||
coSttnInit("1", "13", String(con));
|
||||
setIsDmdModal({
|
||||
isMoal: false,
|
||||
data,
|
||||
});
|
||||
setIsResetSelection(true);
|
||||
return;
|
||||
}
|
||||
|
||||
const dmd = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/${data.dmdInfoId}`
|
||||
);
|
||||
if (dmd) {
|
||||
alert(`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`);
|
||||
return;
|
||||
}
|
||||
|
||||
const message = await regDemandCompany(data); // 등록
|
||||
alert(message);
|
||||
coSttnInit("1", "13", String(con));
|
||||
setIsDmdModal({
|
||||
isMoal: false,
|
||||
data,
|
||||
});
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<ContentsDiv>
|
||||
@@ -284,12 +328,12 @@ export default function CoSttn() {
|
||||
headlist={coSttn.coSttHeadList}
|
||||
pageSize={13}
|
||||
total={coSttnResCount || 0}
|
||||
cellClick={ async(index: number | undefined) => {
|
||||
const uuid = await getMyUUID();
|
||||
const updateData = coSttnRes[index as number];
|
||||
if (updateData && typeof uuid === "string") {
|
||||
updateData.mdfr = uuid;
|
||||
}
|
||||
cellClick={async(index: number | undefined) => {
|
||||
const uuid = await getMyUUID();
|
||||
const updateData = coSttnRes[index as number];
|
||||
if (updateData && typeof uuid === "string") {
|
||||
updateData.mdfr = uuid;
|
||||
}
|
||||
setUpdateData(coSttnRes[index as number]);
|
||||
}}
|
||||
onPageChange={(page) => {
|
||||
@@ -321,38 +365,7 @@ export default function CoSttn() {
|
||||
rtnValue={(searchText: string, pageCnt: number) => {
|
||||
getDemandCompList(searchText, pageCnt);
|
||||
}}
|
||||
rtnInputData={async (data) => {
|
||||
const con =
|
||||
objSearch.sgg && objSearch.sgg !== "0"
|
||||
? objSearch.sgg
|
||||
: objSearch.city;
|
||||
if (updateData?.dmdInfoId) {
|
||||
const message = await updateDemandCompany(data as DemandCompType);
|
||||
alert(message);
|
||||
coSttnInit("1", "13", String(con));
|
||||
setIsDmdModal({
|
||||
isMoal: false,
|
||||
data: data as DemandCompType,
|
||||
});
|
||||
setIsResetSelection(true);
|
||||
} else {
|
||||
const dmd = await getFetch(
|
||||
fetchType.WR,
|
||||
`/reuseFc/request/${data.dmdInfoId}`
|
||||
);
|
||||
if (dmd) {
|
||||
alert(`사업자번호 ${dmd.dmdInfoId}는 이미 등록되었습니다. 다시등록해주세요`);
|
||||
return;
|
||||
}
|
||||
const message = await regDemandCompany(data as DemandCompType);
|
||||
alert(message);
|
||||
coSttnInit("1", "13", String(con));
|
||||
setIsDmdModal({
|
||||
isMoal: false,
|
||||
data: data as DemandCompType,
|
||||
});
|
||||
}
|
||||
}}
|
||||
rtnInputData={handleRtnInputData}
|
||||
bodyClassNm={"w-full mx-auto bg-white rounded-lg shadow-md p-6"}
|
||||
updateList={updateData}
|
||||
openNetwork={true}
|
||||
|
||||
@@ -38,6 +38,7 @@ export type DemandCompType = {
|
||||
crmty: number | "";
|
||||
rmrk: string | "";
|
||||
reqDt: string | "";
|
||||
zip: string | "";
|
||||
};
|
||||
|
||||
type SelectDataType = {
|
||||
@@ -50,6 +51,7 @@ interface FormSchema {
|
||||
sggCd: string;
|
||||
dmdCoNm: string;
|
||||
dmdInfoId: string;
|
||||
zip?: string;
|
||||
daddr: string;
|
||||
telno: string;
|
||||
bznmTotNo?: string; // 종사업자등록번호
|
||||
@@ -219,6 +221,10 @@ export function SdmRegForm({
|
||||
handleCheckboxChange(false);
|
||||
}
|
||||
|
||||
setZoneNo(rtnCompData?.zip || "");
|
||||
form.setValue("zip", rtnCompData?.zip || "");
|
||||
setAddress(rtnCompData?.daddr || "");
|
||||
setDetailedAddress("");
|
||||
form.setValue("daddr", rtnCompData?.daddr || "");
|
||||
form.setValue("telno", rtnCompData?.telno || "");
|
||||
|
||||
@@ -316,6 +322,10 @@ export function SdmRegForm({
|
||||
handleCheckboxChange(true);
|
||||
}
|
||||
form.setValue("dmdInfoId", updateList?.dmdInfoId.slice(0, 10));
|
||||
setZoneNo(updateList?.zip || "");
|
||||
form.setValue("zip", updateList?.zip || "");
|
||||
setAddress(updateList?.daddr || "");
|
||||
setDetailedAddress("");
|
||||
setUpdateNm(updateList?.dmdCoNm);
|
||||
// setSigunValue(updateList?.sggCd)
|
||||
} else {
|
||||
@@ -336,6 +346,10 @@ export function SdmRegForm({
|
||||
}
|
||||
}, [address, detailedAddress, form]);
|
||||
|
||||
useEffect(() => {
|
||||
form.setValue("zip", zoneNo, { shouldValidate: true });
|
||||
}, [form, zoneNo]);
|
||||
|
||||
|
||||
const formFields: Array<{
|
||||
name: keyof FormSchema;
|
||||
@@ -468,10 +482,10 @@ export function SdmRegForm({
|
||||
type="text"
|
||||
className="!text-xl text-gray-600 w-64"
|
||||
readOnly={true}
|
||||
value={zoneNo}
|
||||
value={form.watch("zip") ?? ""}
|
||||
placeholder="우편번호"
|
||||
/>
|
||||
<Button className="px-4 py-2 rounded-md" onClick={() => setIsZipModalOpen(true)}>우편번호 검색</Button>
|
||||
<Button type="button" className="px-4 py-2 rounded-md" onClick={() => setIsZipModalOpen(true)}>우편번호 검색</Button>
|
||||
</div>
|
||||
{/* 주소 */}
|
||||
<Input
|
||||
@@ -625,6 +639,7 @@ export function SdmRegForm({
|
||||
setZoneNo(zip.zoneNo || "");
|
||||
setAddress(zip.zipAddr || "");
|
||||
setDetailedAddress("");
|
||||
form.setValue("zip", zip.zoneNo || "", { shouldValidate: true });
|
||||
applyZipRegion(zip.ctpvNm, zip.sggNm);
|
||||
}}
|
||||
/>
|
||||
|
||||
@@ -32,6 +32,7 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean ,up
|
||||
.min(1, "사업자등록번호를 입력해주세요")
|
||||
.regex(/^\d{10}$/, "사업자등록번호는 10자리 숫자만 입력 가능합니다")
|
||||
.refine(() => isBznmTotNoDisabled ? !isDuplicate : true, "이미 등록된 사업자등록번호입니다"),
|
||||
zip: z.string().optional(),
|
||||
bznmTotNo: isBznmTotNoDisabled
|
||||
? z.string().optional()
|
||||
: z.string()
|
||||
@@ -73,6 +74,7 @@ const defaultValues: FormSchema = {
|
||||
sggCd: '',
|
||||
dmdCoNm: '',
|
||||
dmdInfoId: '',
|
||||
zip: '',
|
||||
bznmTotNo: '',
|
||||
daddr: '',
|
||||
telno: '',
|
||||
@@ -88,11 +90,11 @@ const defaultValues: FormSchema = {
|
||||
* @param selectSigunData 시/군/구 데이터
|
||||
* @param dataList 수요처 목록
|
||||
* @param rtnValue 검색 결과(텍스트) 콜백
|
||||
* @param rtnInputData 수요처 리스트 콜백
|
||||
* @param rtnInputData 수요처관리 콜백 : 등록/수정 처리
|
||||
* @returns
|
||||
*/
|
||||
|
||||
export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData,bodyClassNm, updateList,readOnly,openNetwork}: thisProps) {
|
||||
export default function SdmInsertForm({selectSidoData, selectSigunData, dataList, rtnValue, rtnInputData
|
||||
, bodyClassNm, updateList, readOnly, openNetwork}: thisProps) {
|
||||
|
||||
const [isBznmTotNoDisabled, setIsBznmTotNoDisabled] = useState(false); // 종사업자등록번호 해당없음
|
||||
const [isDuplicate, setIsDuplicate] = useState(false);
|
||||
@@ -144,7 +146,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
|
||||
|
||||
/* await insertSdmData(formData); */
|
||||
rtnInputData(formData as unknown as DemandCompType); // 수요처 리스트
|
||||
rtnInputData(formData as unknown as DemandCompType); // 수요처 등록/수정 처리
|
||||
|
||||
|
||||
//router.push(`/pages/sdmMng/sdmInfoInsert?${queryParams.toString()}`);
|
||||
@@ -157,7 +159,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
<>
|
||||
<div className="text-center mb-8">
|
||||
<h1 className="text-4xl font-bold text-gray-900 underline">
|
||||
{readOnly==true? '수요처 정보':'수요처 등록'}
|
||||
{!updateList? '수요처 등록' :readOnly==true? '수요처 정보':'수요처 수정'}
|
||||
</h1>
|
||||
</div>
|
||||
|
||||
@@ -194,4 +196,4 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
<Toaster position="top-center" />
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user