잠재수요처 엑셀 등록 전화번호 추가

This commit is contained in:
jyha00
2025-06-30 20:13:28 +09:00
parent b6e847a55a
commit 19621c17b4
@@ -1,12 +1,12 @@
import { useWrStore } from "@/app/store";
import { coRegExcel } from "@/app/store/matDmd/coSttn/headList";
import type { customLdrmnt } from "@/app/store/matDmd/ldrmntCoSttn";
import { excelToLdrmntData, names } from "@/app/store/matDmd/ldrmntCoSttn/excel";
import { names } from "@/app/store/matDmd/ldrmntCoSttn/excel";
import { filePicked, FileUpload, FormUi, Title } from "@common/business_components/ui";
import { Form, FormField } from "@common/business_components/ui/form";
import { Button, Input } from "@common/components/ui";
import { Button } from "@common/components/ui";
import { zodResolver } from "@hookform/resolvers/zod";
import { useEffect, useState } from "react";
import { useState } from "react";
import { useForm } from "react-hook-form";
import type { z } from "zod";
@@ -26,34 +26,41 @@ export default function CoRegExcel() {
ldrmntDelete();
if (file) {
filePicked(file, 0).then((res) => {
//TODO:loading
try {
console.log("res", res)
let array: { [key: string]: string | number }[] = []
if (Array.isArray(res))
res.forEach((item, index) => {
let isError = false;
if (Array.isArray(res)){
res.some((item, index) => {
let object: { [key: string]: string | number } = {}
Object.keys(names).forEach((key) => {
Object.keys(names).some((key) => {
if (item && names[key] !== undefined) {
if (key === "공장관리번호")
if (key === "공장관리번호") {
item[key] = String(item[key])
object[names[key] as string] = item[key];
} else {
object[names[key] as string] = item[key];
}
}
return false;
})
if(isError === true)
return true;
array.push(object)
if (index != 0 && index % 5000 == 0) {
ldrmntRegData(array);
console.log("array", array)
array = []
array.length = 0;
// throw new Error("error")
}
return false;
})
}
if(isError === false)
ldrmntRegData(array);
console.log("array끝", array)
} catch (e) {
console.log(e)
alert(e)
return true;
}
});
@@ -61,47 +68,46 @@ export default function CoRegExcel() {
}
return (
<>
<div>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<div>
<Title title={"잠재수요처 등록"}></Title>
</div>
<div className="flex justify-between">
<h3 className="text-2xl font-bold text-gray-900 mt-1 ml-7">
{"잠재수요처 파일"}
</h3>
return (
<>
<div>
<Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)}>
<div>
<Title title={"잠재수요처 등록"}></Title>
</div>
<div className="flex justify-between">
<h3 className="text-2xl font-bold text-gray-900 mt-1 ml-7">
{"잠재수요처 파일"}
</h3>
<Button className="" type="submit" size={"sm"}>
저장
</Button>
</div>
<Button className="" type="submit" size={"sm"}>
저장
</Button>
</div>
<div>
<div>
<FormField
control={form.control}
name="file"
render={({ field }) => (
<FormUi label="">
<FileUpload
files={file ? [file] : []}
setFiles={(files: File[] | null) => {
console.log("files", files)
if (files && files?.length === 1) setFiles(files[0]);
}}
fileTypes=""
maxFiles={1}
></FileUpload>
</FormUi>
)}
/>
</div>
</form>
</Form>
</div>
</>
);
}
<FormField
control={form.control}
name="file"
render={({ field }) => (
<FormUi label="">
<FileUpload
files={file ? [file] : []}
setFiles={(files: File[] | null) => {
if (files && files?.length === 1) setFiles(files[0]);
}}
fileTypes=""
maxFiles={1}
></FileUpload>
</FormUi>
)}
/>
</div>
</form>
</Form>
</div>
</>
);
}