Merge branch 'main' of https://www.onasys.co.kr:3000/ONAANDALL/frontend
This commit is contained in:
@@ -18,6 +18,7 @@ export type DemandCompType = {
|
||||
daddr: string | "";
|
||||
telno: string | "";
|
||||
rgtr: string | "";
|
||||
mdfr?:string ;
|
||||
useUsgCd: string | "";
|
||||
ctpvCd: string | "";
|
||||
sggCd: string | "";
|
||||
@@ -54,6 +55,7 @@ interface FormSchema {
|
||||
telno: string;
|
||||
bznmTotNo?: string;
|
||||
rgtr?: string | "";
|
||||
mdfr?: string | null;
|
||||
dmdAplyPswd?: string;
|
||||
dmdAplyPswdConfirm?: string;
|
||||
}
|
||||
@@ -261,8 +263,6 @@ export function SdmRegForm({
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
form.setValue("rgtr", "2d4b151d-1828-41e0-91d9-4cd28ea1cc7e");
|
||||
|
||||
if (updateList?.dmdInfoId) {
|
||||
form.reset(updateList);
|
||||
if (updateList?.dmdInfoId.slice(10, 14) !== "0000") {
|
||||
@@ -375,7 +375,7 @@ export function SdmRegForm({
|
||||
type="text"
|
||||
className="!text-xl text-gray-600"
|
||||
onChange={(e) => bznNoChange(e, "dmdInfoId", field)}
|
||||
value={formatBusinessNumber(field.value || "")}
|
||||
value={formatBusinessNumber(field.value ?? "")}
|
||||
readOnly={!!updateList?.dmdInfoId}
|
||||
/>
|
||||
),
|
||||
@@ -396,7 +396,7 @@ export function SdmRegForm({
|
||||
disabled={isBznmTotNoDisabled}
|
||||
onChange={(e) => bznNoChange(e, "bznmTotNo", field)}
|
||||
// {...field}
|
||||
value={field.value}
|
||||
value={field.value ?? ""}
|
||||
readOnly={!!updateList?.dmdInfoId}
|
||||
/>
|
||||
</FormUi>
|
||||
@@ -421,6 +421,7 @@ export function SdmRegForm({
|
||||
className="!text-xl text-gray-600"
|
||||
readOnly={readOnly}
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
/>
|
||||
),
|
||||
},
|
||||
@@ -456,6 +457,7 @@ export function SdmRegForm({
|
||||
className="!text-xl text-gray-600"
|
||||
readOnly={readOnly}
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
/>
|
||||
),
|
||||
},
|
||||
@@ -469,6 +471,7 @@ export function SdmRegForm({
|
||||
className="!text-xl text-gray-600"
|
||||
readOnly={readOnly}
|
||||
{...field}
|
||||
value={field.value ?? ""}
|
||||
/>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -7,6 +7,7 @@ import { FormProvider, useForm, type SubmitHandler } from "react-hook-form";
|
||||
import { toast, Toaster } from "sonner";
|
||||
import * as z from "zod";
|
||||
import type { SelectDataType } from "../search_input_select";
|
||||
import { getCookie } from "@common/components/lib";
|
||||
|
||||
|
||||
type thisProps = {
|
||||
@@ -45,6 +46,7 @@ const createFormSchema = (isBznmTotNoDisabled: boolean, isDuplicate: boolean ,up
|
||||
.max(11, "전화번호는 11자 이내로 입력해주세요")
|
||||
.regex(/^[0-9]+$/, "전화번호는 숫자만 입력 가능합니다"),
|
||||
rgtr: z.string().optional(),
|
||||
mdfr: z.string().nullish(),
|
||||
dmdAplyPswd : updateList?.dmdInfoId // 업데이트일경우
|
||||
? z.string().optional() // 패스워드는 선택 사항이며 길이 제한 없음
|
||||
: z.string().optional()
|
||||
@@ -75,6 +77,7 @@ const defaultValues: FormSchema = {
|
||||
daddr: '',
|
||||
telno: '',
|
||||
rgtr: '',
|
||||
mdfr: '',
|
||||
dmdAplyPswd: '',
|
||||
dmdAplyPswdConfirm: '',
|
||||
};
|
||||
@@ -120,20 +123,25 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
try {
|
||||
// form 에러 체크
|
||||
const formErrors = form.formState.errors;
|
||||
if (Object.keys(formErrors).length > 0) {
|
||||
|
||||
const myUUID = getCookie('token-id') ||'c475824c-0e82-4a06-a282-2b55a20df265';
|
||||
|
||||
if (Object.keys(formErrors).length > 0 ) {
|
||||
const errorMessage = Object.values(formErrors)[0]?.message || '입력값을 확인해주세요.';
|
||||
toast.error(errorMessage);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
const dmdInfoId = data.dmdInfoId + (data.bznmTotNo || '0000');
|
||||
const formData = {
|
||||
...data,
|
||||
dmdInfoId,
|
||||
bzmnNo: data.dmdInfoId,
|
||||
rgtr: myUUID ,
|
||||
};
|
||||
|
||||
console.log(' formData ', formData)
|
||||
|
||||
/* await insertSdmData(formData); */
|
||||
rtnInputData(formData as unknown as DemandCompType);
|
||||
@@ -175,7 +183,7 @@ export default function SdmInsertForm({selectSidoData, selectSigunData, dataList
|
||||
type="submit"
|
||||
className="w-32 bg-blue-600 hover:bg-blue-700 text-white font-semibold py-2 px-4 rounded-md transition-colors duration-200"
|
||||
>
|
||||
수요처등록
|
||||
{updateList ?'수정' :'등록'}
|
||||
</Button>
|
||||
}
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ type SearchBaseType = {
|
||||
leftClassName?: string;
|
||||
leftSelectClassName?: string;
|
||||
buttonOrder?: ("query" | "init" | "excel")[];
|
||||
initSidoValue?: string | '';
|
||||
}
|
||||
export type ReturnType = {
|
||||
partValue: string;
|
||||
@@ -57,10 +58,11 @@ function SearchBaseForm ({
|
||||
rightClassName,
|
||||
leftClassName,
|
||||
leftSelectClassName,
|
||||
buttonOrder
|
||||
buttonOrder,
|
||||
initSidoValue='',
|
||||
}: SearchBaseType) {
|
||||
const [partValue, setPartValue] = useState<string>("A");
|
||||
const [sidoValue, setSidoValue] = useState<string>("0");
|
||||
const [sidoValue, setSidoValue] = useState<string>(initSidoValue?initSidoValue:"0");
|
||||
const [sigunValue, setSigunValue] = useState<string>("0");
|
||||
const [sidoText, setSidoText] = useState<string>("");
|
||||
const [sigunText, setSigunText] = useState<string>("");
|
||||
@@ -94,7 +96,7 @@ function SearchBaseForm ({
|
||||
}
|
||||
};
|
||||
const queryVal = () => {
|
||||
console.log("조회버튼 클릭");
|
||||
console.log("조회버튼 클릭",);
|
||||
queryClick({
|
||||
partValue: partValue,
|
||||
sidoValue: sidoValue,
|
||||
@@ -108,11 +110,18 @@ function SearchBaseForm ({
|
||||
});
|
||||
}
|
||||
const initVal = useCallback(() => {
|
||||
if(initSidoValue){
|
||||
setSidoValue(initSidoValue);
|
||||
}
|
||||
setResetTrigger(true);
|
||||
initClick();
|
||||
}, [setResetTrigger, initClick]);
|
||||
}, [initSidoValue, setResetTrigger, initClick]);
|
||||
useEffect(() => {
|
||||
if (resetTrigger) {
|
||||
if(initSidoValue!=""){
|
||||
setSidoValue(initSidoValue);
|
||||
}
|
||||
|
||||
setResetTrigger(false);
|
||||
}
|
||||
}, [resetTrigger]);
|
||||
@@ -167,6 +176,7 @@ function SearchBaseForm ({
|
||||
isAdmin={isAdmin}
|
||||
leftClassName={leftClassName}
|
||||
leftSelectClassName={leftSelectClassName}
|
||||
initSidoValue={initSidoValue}
|
||||
>
|
||||
{leftChildren}
|
||||
</SearchFormLeft>
|
||||
|
||||
@@ -46,6 +46,7 @@ type SearchFormLeftProps = {
|
||||
isAdmin?: boolean;
|
||||
leftClassName?: string;
|
||||
leftSelectClassName?: string;
|
||||
initSidoValue?: string;
|
||||
}
|
||||
|
||||
export type EnvPartSelectDataType = SelectDataType & {
|
||||
@@ -58,11 +59,11 @@ const selectPartData:SelectDataType[] = [
|
||||
{ text: "환경청별", val: 'G' },
|
||||
];
|
||||
|
||||
function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], selectSigunData = [], selectRegionData = [], selectUnitWaterShedData = [], selectMiddleRegionData = [], selectEnvPartData = [], setRtnPartValue, setRtnSidoValue, setRtnSidoText, setRtnSigunValue, setRtnSigunText, setRtnRegionValue, setRtnUnitWaterShedValue, setRtnMiddleRegionValue, setRtnEnvPartValue, setRtnEnvPartSidoValue, setRtnEnvPartSigunValue, resetTrigger = false, isAdmin = false, leftClassName, leftSelectClassName }: SearchFormLeftProps) {
|
||||
function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], selectSigunData = [], selectRegionData = [], selectUnitWaterShedData = [], selectMiddleRegionData = [], selectEnvPartData = [], setRtnPartValue, setRtnSidoValue, setRtnSidoText, setRtnSigunValue, setRtnSigunText, setRtnRegionValue, setRtnUnitWaterShedValue, setRtnMiddleRegionValue, setRtnEnvPartValue, setRtnEnvPartSidoValue, setRtnEnvPartSigunValue, resetTrigger = false, isAdmin = false, leftClassName, leftSelectClassName, initSidoValue }: SearchFormLeftProps) {
|
||||
/******************선택된 데이터******************/
|
||||
const [partValue, setPartValue] = useState<string>('A');
|
||||
//행정별 시도 시군구
|
||||
const [sidoValue, setSidoValue] = useState<string>('0');
|
||||
const [sidoValue, setSidoValue] = useState<string>(initSidoValue?initSidoValue : '0');
|
||||
const [sigunValue, setSigunValue] = useState<string>('0');
|
||||
const [sidoText, setSidoText] = useState<string>('');
|
||||
const [sigunText, setSigunText] = useState<string>('');
|
||||
@@ -85,6 +86,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
const [filteredEnvPartSidoData, setFilteredEnvPartSidoData] = useState<EnvPartSelectDataType[]>([{ text: "전체", val: '0', adstDliStrCd:'' }]);
|
||||
const [filteredEnvPartSigunData, setFilteredEnvPartSigunData] = useState<SelectDataType[]>([{ text: "전체", val: '0' }]);
|
||||
|
||||
const [initTrigger, setInitTrigger] = useState<boolean>(false);
|
||||
// 시군구 세팅
|
||||
const initializeSigunData = (sidoCd: string) => {
|
||||
if (sidoCd === '0') {
|
||||
@@ -99,7 +101,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
setFilteredSigunData(newFilteredData);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 단위유역 세팅
|
||||
const initializeUnitWaterShedData = (regionCd: string) => {
|
||||
if(regionCd === '0') {
|
||||
@@ -159,6 +161,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
}
|
||||
|
||||
const onSelectValue = (val: string, type: string) => {
|
||||
setInitTrigger(true);
|
||||
let selectedSido;
|
||||
let selectedSigun;
|
||||
let selectedEnvPartSido;
|
||||
@@ -272,7 +275,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
// 리셋 함수
|
||||
const resetAllValues = () => {
|
||||
setPartValue('A');
|
||||
setSidoValue('0');
|
||||
setSidoValue(initSidoValue?initSidoValue:'0');
|
||||
setSigunValue('0');
|
||||
setRegionValue('0');
|
||||
setUnitWaterShedValue('0');
|
||||
@@ -287,7 +290,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
setFilteredEnvPartSigunData([{ text: "전체", val: '0' }]);
|
||||
|
||||
if (setRtnPartValue) setRtnPartValue('A');
|
||||
if (setRtnSidoValue) setRtnSidoValue('0');
|
||||
if (setRtnSidoValue) setRtnSidoValue(initSidoValue?initSidoValue:'0');
|
||||
if (setRtnSigunValue) setRtnSigunValue('0');
|
||||
if (setRtnRegionValue) setRtnRegionValue('0');
|
||||
if (setRtnUnitWaterShedValue) setRtnUnitWaterShedValue('0');
|
||||
@@ -304,6 +307,7 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
// 리셋 후 트리거를 false로 설정
|
||||
if (setRtnPartValue) {
|
||||
setRtnPartValue('A');
|
||||
setInitTrigger(false);
|
||||
}
|
||||
}
|
||||
}, [resetTrigger]);
|
||||
@@ -327,7 +331,12 @@ function SearchFormLeft({ isShowPart = false, children, selectSidoData = [], sel
|
||||
) : (
|
||||
<>
|
||||
<SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시도'} selectArray={selectSidoData} onSelectValue={(val) => onSelectValue(val.toString(), 'sido')} value={sidoValue} selectClass={undefined}/>
|
||||
<SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시군구'} selectArray={filteredSigunData} onSelectValue={(val) => onSelectValue(val.toString(), 'sigun')} value={sigunValue} selectClass={undefined}/>
|
||||
<SelectBox className={leftSelectClassName?leftSelectClassName:`col-span-3`} label={'시군구'} selectArray={initSidoValue&&!initTrigger?[
|
||||
{ text: '전체', val: '0' },
|
||||
...selectSigunData.filter(
|
||||
(item) => String(item.val).slice(0, 2) === String(initSidoValue)
|
||||
),
|
||||
]:filteredSigunData} onSelectValue={(val) => onSelectValue(val.toString(), 'sigun')} value={sigunValue} selectClass={undefined}/>
|
||||
</>
|
||||
)}
|
||||
{children}
|
||||
|
||||
Reference in New Issue
Block a user