폼 합계 readonly / 자동계산 완료
This commit is contained in:
@@ -43,6 +43,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
const [ppiYn, setPpiYn] = useState("Y");
|
||||
const [isFcOrgwts, setIsFcOrgwts] = useState<boolean>(false);
|
||||
const [modalData, setModalData] = useState<fcOrgwtType | null>(null);
|
||||
const [sumCpct, setSumCpct] = useState<number>(0);
|
||||
|
||||
const form = useForm<fcBizType>({
|
||||
resolver: zodResolver(fcBizSchema),
|
||||
@@ -50,7 +51,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
|
||||
// 2. Define a submit handler.
|
||||
function onSubmit(values: fcBizType) {
|
||||
console.log(values);
|
||||
// console.log(values);
|
||||
}
|
||||
|
||||
const { fields: fcOrgwtFiled } = useFieldArray({
|
||||
@@ -128,7 +129,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
}
|
||||
|
||||
}, [getBizCycle,pbnst.pbnstResObj]);
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
const ppl = [];
|
||||
if (code.pplLenght) {
|
||||
@@ -253,7 +254,7 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
<Label className="text-right">합계</Label>
|
||||
<Input
|
||||
type="text"
|
||||
value={""}
|
||||
value={sumCpct}
|
||||
readOnly={true}
|
||||
className="w-32 border-gray-300 rounded pr-8 "
|
||||
/>
|
||||
@@ -281,6 +282,14 @@ export function PbnstBuseForm({ data }: { data: fcBizType[] }) {
|
||||
code={ppiSelectList ?? []}
|
||||
ref={ref}
|
||||
upHeadList={[]}
|
||||
onTableSet={(val) => {
|
||||
if (!ref.current) return;
|
||||
let sum = 0;
|
||||
ref.current.forEach(item => {
|
||||
sum += Number(item.cpct) || 0;
|
||||
});
|
||||
setSumCpct(sum);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ type RuseMngTableProps = {
|
||||
headList: TableUpperProps[];
|
||||
upHeadList: chHeadType[];
|
||||
code?: { name: string, val: SelectDataType[] }[];
|
||||
onTableSet?:(item:any)=> void;
|
||||
};
|
||||
|
||||
const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
|
||||
@@ -28,14 +29,20 @@ const RuseMngTable = React.forwardRef<any, RuseMngTableProps>(
|
||||
tableData,
|
||||
headList,
|
||||
upHeadList,
|
||||
code
|
||||
code,
|
||||
onTableSet
|
||||
}, ref) => {
|
||||
const [tableState, setTableState] = useState([...tableData]);
|
||||
useEffect(() => {
|
||||
if (ref && typeof ref === "object" && "current" in ref) {
|
||||
ref.current = tableState;
|
||||
}
|
||||
}, [tableState]);
|
||||
if(onTableSet)
|
||||
onTableSet (tableState)
|
||||
}, [tableState,onTableSet]);
|
||||
|
||||
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
if(tableData)
|
||||
|
||||
Reference in New Issue
Block a user