견적서 첨부파일
This commit is contained in:
parent
69d11336d5
commit
56aef1c001
@ -61,7 +61,7 @@ export default function Estimate({ params }) {
|
|||||||
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
||||||
|
|
||||||
//견적서 상세데이터
|
//견적서 상세데이터
|
||||||
const { estimateContextState, setEstimateContextState, addItem } = useEstimateController(params.pid)
|
const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid)
|
||||||
|
|
||||||
//견적특이사항 List
|
//견적특이사항 List
|
||||||
const [specialNoteList, setSpecialNoteList] = useState([])
|
const [specialNoteList, setSpecialNoteList] = useState([])
|
||||||
@ -1153,7 +1153,10 @@ export default function Estimate({ params }) {
|
|||||||
return (
|
return (
|
||||||
<li className="file-item" key={uuidv4()}>
|
<li className="file-item" key={uuidv4()}>
|
||||||
<div className="file-item-wrap">
|
<div className="file-item-wrap">
|
||||||
<span style={{ display: originFile.delFlg === '0' ? '' : 'none' }}>
|
<span
|
||||||
|
style={{ display: originFile.delFlg === '0' ? '' : 'none' }}
|
||||||
|
onClick={() => handleEstimateFileDownload(originFile)}
|
||||||
|
>
|
||||||
{originFile.faileName}
|
{originFile.faileName}
|
||||||
<button
|
<button
|
||||||
type="button"
|
type="button"
|
||||||
|
|||||||
@ -42,6 +42,12 @@ export const useEstimateController = (planNo) => {
|
|||||||
}
|
}
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (fileList.length > 0) {
|
||||||
|
realSave(fileList)
|
||||||
|
}
|
||||||
|
}, [fileList])
|
||||||
|
|
||||||
// 상세 조회
|
// 상세 조회
|
||||||
const fetchSetting = async (objectNo, planNo) => {
|
const fetchSetting = async (objectNo, planNo) => {
|
||||||
try {
|
try {
|
||||||
@ -154,14 +160,17 @@ export const useEstimateController = (planNo) => {
|
|||||||
// console.log('새로추가첨부파일:::', estimateData.newFileList)
|
// console.log('새로추가첨부파일:::', estimateData.newFileList)
|
||||||
// console.log('기존첨부파일:::', estimateData.originFiles)
|
// console.log('기존첨부파일:::', estimateData.originFiles)
|
||||||
|
|
||||||
// return
|
// console.log('estimateData::', estimateData)
|
||||||
|
|
||||||
|
//기존에 첨부된 파일이 있으면 파일첨부관련 통과
|
||||||
if (estimateData?.originFiles?.length > 0) {
|
if (estimateData?.originFiles?.length > 0) {
|
||||||
originFileFlg = true
|
originFileFlg = true
|
||||||
}
|
}
|
||||||
if (flag) {
|
if (flag) {
|
||||||
if (!originFileFlg) {
|
if (!originFileFlg) {
|
||||||
|
//기존에 첨부된 파일이 없으면
|
||||||
if (estimateData.newFileList?.length < 1) {
|
if (estimateData.newFileList?.length < 1) {
|
||||||
|
//새로 첨부한 파일이 있으면
|
||||||
if (estimateData.itemList.length > 1) {
|
if (estimateData.itemList.length > 1) {
|
||||||
estimateData.itemList.map((row) => {
|
estimateData.itemList.map((row) => {
|
||||||
if (row.delFlg === '0') {
|
if (row.delFlg === '0') {
|
||||||
@ -217,26 +226,7 @@ export const useEstimateController = (planNo) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
|
||||||
|
|
||||||
if (flag && fileFlg && itemFlg) {
|
|
||||||
//1. 첨부파일 저장시작
|
|
||||||
const formData = new FormData()
|
|
||||||
if (estimateData?.newFileList?.length > 0) {
|
|
||||||
estimateData.newFileList.forEach((file) => {
|
|
||||||
formData.append('files', file)
|
|
||||||
})
|
|
||||||
formData.append('objectNo', estimateData.objectNo)
|
|
||||||
formData.append('planNo', estimateData.planNo)
|
|
||||||
formData.append('category', '10')
|
|
||||||
formData.append('userId', estimateData.userId)
|
|
||||||
|
|
||||||
await post({ url: '/api/file/fileUpload', data: formData }).then((res) => {
|
|
||||||
console.log('리턴::::::::::::', res)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
//첨부파일저장끝
|
|
||||||
estimateData.itemList = estimateData.itemList.filter((item) => item.delFlg === '0' || !item.addFlg)
|
estimateData.itemList = estimateData.itemList.filter((item) => item.delFlg === '0' || !item.addFlg)
|
||||||
|
|
||||||
let delCnt = 0
|
let delCnt = 0
|
||||||
@ -248,6 +238,32 @@ export const useEstimateController = (planNo) => {
|
|||||||
if (delCnt === estimateData.itemList.length) {
|
if (delCnt === estimateData.itemList.length) {
|
||||||
return alert(getMessage('estimate.detail.save.requiredItem'))
|
return alert(getMessage('estimate.detail.save.requiredItem'))
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag && fileFlg && itemFlg) {
|
||||||
|
//1. 첨부파일 저장시작
|
||||||
|
const formData = new FormData()
|
||||||
|
if (estimateData?.newFileList?.length > 0) {
|
||||||
|
console.log('새로추가한 첨부파일있음:::', estimateData?.newFileList)
|
||||||
|
estimateData.newFileList.forEach((file) => {
|
||||||
|
formData.append('files', file)
|
||||||
|
})
|
||||||
|
formData.append('objectNo', estimateData.objectNo)
|
||||||
|
formData.append('planNo', estimateData.planNo)
|
||||||
|
formData.append('category', '10')
|
||||||
|
formData.append('userId', estimateData.userId)
|
||||||
|
|
||||||
|
await post({ url: '/api/file/fileUpload', data: formData }).then((res) => {
|
||||||
|
setFileList(res)
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
realSave()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const realSave = async (fileList) => {
|
||||||
|
//첨부파일저장끝
|
||||||
|
|
||||||
let option = []
|
let option = []
|
||||||
estimateData.itemList.forEach((item) => {
|
estimateData.itemList.forEach((item) => {
|
||||||
@ -289,8 +305,17 @@ export const useEstimateController = (planNo) => {
|
|||||||
estimateOptions = estimateOptionsArray.join('、')
|
estimateOptions = estimateOptionsArray.join('、')
|
||||||
|
|
||||||
estimateData.estimateOption = estimateOptions
|
estimateData.estimateOption = estimateOptions
|
||||||
// console.log('첨부파일::::::::', fileList)
|
|
||||||
// console.log('최종아이템:::', estimateData.itemList)
|
// console.log('최종아이템:::', estimateData.itemList)
|
||||||
|
if (fileList?.length > 0) {
|
||||||
|
estimateData.fileList = fileList
|
||||||
|
} else {
|
||||||
|
estimateData.fileList = []
|
||||||
|
}
|
||||||
|
if (estimateData.originFiles?.length > 0) {
|
||||||
|
estimateData.deleteFileList = estimateData.originFiles?.filter((item) => item.delFlg === '1')
|
||||||
|
} else {
|
||||||
|
estimateData.deleteFileList = []
|
||||||
|
}
|
||||||
console.log('최종저장::', estimateData)
|
console.log('최종저장::', estimateData)
|
||||||
//2. 상세데이터 저장
|
//2. 상세데이터 저장
|
||||||
// return
|
// return
|
||||||
@ -306,7 +331,6 @@ export const useEstimateController = (planNo) => {
|
|||||||
console.log('error::::::::::::', e.response.data.message)
|
console.log('error::::::::::::', e.response.data.message)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 견적서 복사버튼
|
* 견적서 복사버튼
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user