diff --git a/src/components/estimate/Estimate.jsx b/src/components/estimate/Estimate.jsx
index 77b9cd43..4861e75c 100644
--- a/src/components/estimate/Estimate.jsx
+++ b/src/components/estimate/Estimate.jsx
@@ -55,7 +55,7 @@ export default function Estimate({ params }) {
const objectRecoil = useRecoilValue(floorPlanObjectState)
//견적서 상세데이터
- const { state, setState, addItem } = useEstimateController(params.pid)
+ const { state, setState, addItem, handleEstimateFileDownload } = useEstimateController(params.pid)
//견적특이사항 List
const [specialNoteList, setSpecialNoteList] = useState([])
@@ -170,7 +170,6 @@ export default function Estimate({ params }) {
objectNo: objectNo,
no: no,
}
-
await promisePost({ url: 'api/file/fileDelete', data: delParams }).then((res) => {
if (res.status === 204) {
setOriginFiles(originFiles.filter((file) => file.objectNo === objectNo && file.no !== no))
@@ -181,13 +180,6 @@ export default function Estimate({ params }) {
})
}
- //아이템 목록
- // useEffect(() => {
- // if (isNotEmptyArray(state.itemList)) {
- // setItemList(state.itemList)
- // }
- // }, [state?.itemList])
-
//가격표시 option 최초세팅
useEffect(() => {
if (state.estimateType !== '') {
@@ -267,7 +259,7 @@ export default function Estimate({ params }) {
setSelection(newSelection)
}
- // 아이템 자동완성 검색시
+ // 아이템 자동완성 검색시 아이템 변경
const onChangeDisplayItem = (itemId, dispOrder) => {
const param = {
itemId: itemId,
@@ -282,7 +274,8 @@ export default function Estimate({ params }) {
updates.itemId = res.itemId
updates.itemNo = '' //예정
updates.itemName = res.itemName
- updates.itemChangeFlg = '1' //무조건1
+ updates.itemChangeFlg = '1' //무조건 1
+ updates.partAdd = '1' //무조건1 NEW
updates.fileUploadFlg = res.fileUploadFlg
updates.unit = res.unit
updates.unitPrice = res.salePrice //unitPrice도 salePrice로
@@ -294,6 +287,7 @@ export default function Estimate({ params }) {
updates.unit = res.unit
updates.specialNoteCd = res.spnAttrCds
updates.itemGroup = res.itemGroup
+ updates.delFlg = '0' // 삭제플래그 0
updateList = state.itemList.map((item) => {
if (item.dispOrder === dispOrder) {
@@ -619,9 +613,16 @@ export default function Estimate({ params }) {
originFiles.map((originFile) => {
return (
-
+ handleEstimateFileDownload(originFile)}>
{originFile.faileName}
-
+
)
@@ -888,7 +889,8 @@ export default function Estimate({ params }) {
})}
/>
- {item?.itemChangeFlg === '1' && (
+ {/* {item?.itemChangeFlg === '1' && ( */}
+ {item?.partAdd === '1' && (
@@ -921,6 +923,7 @@ export default function Estimate({ params }) {
defaultValue={convertNumberToPriceDecimal(item?.amount)}
onChange={(e) => {
//onChangeDisplayItem참고
+ //itemChangeFlg = 1, partAdd = 0 셋팅
console.log('수량변경::::::::', e.target.value)
}}
/>
@@ -936,6 +939,7 @@ export default function Estimate({ params }) {
value={convertNumberToPriceDecimal(item?.salePrice)}
onChange={(e) => {
//onChangeDisplayItem참고
+ //itemChangeFlg, partAdd 받아온 그대로
console.log('단가변경:::::::', e.target.value)
}}
/>
diff --git a/src/components/management/StuffHeader.jsx b/src/components/management/StuffHeader.jsx
index d7e3246d..581163b6 100644
--- a/src/components/management/StuffHeader.jsx
+++ b/src/components/management/StuffHeader.jsx
@@ -22,7 +22,7 @@ export default function StuffHeader() {
if (res != null && res != '') {
setHeaderData(res)
} else {
- alert(getMessage('stuff.detail.header.message1'))
+ alert(getMessage('stuff.detail.header.notExistObjectNo'))
router.push('/management/stuff')
}
})
diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js
index 8d2d8dc9..68252e95 100644
--- a/src/hooks/floorPlan/estimate/useEstimateController.js
+++ b/src/hooks/floorPlan/estimate/useEstimateController.js
@@ -93,6 +93,8 @@ export const useEstimateController = (planNo) => {
salePrice: '0', //단가
saleTotPrice: '0', //금액(부가세별도)
itemChangeFlg: '1', //추가시 체인지플래그 1로
+ partAdd: '1', //NEW 체인지 플래그
+ delFlg: '0', //삭제 플래그 0 삭제하면 1
},
],
})
@@ -102,34 +104,62 @@ export const useEstimateController = (planNo) => {
setEstimateData({ ...state, userId: session.userId, sapSalesStoreCd: session.custCd })
}, [state])
+ // 첨부파일 다운로드
+ const handleEstimateFileDownload = async (originFile) => {
+ const options = { responseType: 'blob' }
+
+ console.log('첨부파일 다운로드 호출:::::::', originFile)
+
+ await promisePost({ url: `/api/file/fileDownload`, data: originFile, option: options })
+ .then((resultData) => {
+ if (resultData) {
+ const blob = new Blob([resultData.data], { type: resultData.headers['content-type'] || 'application/octet-stream' })
+ const fileUrl = window.URL.createObjectURL(blob)
+ const link = document.createElement('a')
+
+ link.href = fileUrl
+ link.download = file.srcFileNm
+ document.body.appendChild(link)
+ link.click()
+ link.remove()
+ window.URL.revokeObjectURL(fileUrl)
+ }
+ })
+ .catch((error) => {
+ alert('File does not exist.')
+ })
+ }
+
//견적서 저장
const handleEstimateSubmit = async () => {
//0. 필수체크
let flag = true
console.log('::담긴 estimateData:::', estimateData)
-
+ // console.log('첨부파일:::::', estimateData.fileList)
+ //첨부파일을 첨부안했는데
//아이템 fileUploadFlg가1(첨부파일 필수)이 1개라도 있는데 후일 자료 제출(fileFlg) 체크안했으면(0) alert 저장안돼
- if (estimateData.itemList.length > 1) {
- estimateData.itemList.map((row) => {
- if (row.fileUploadFlg === '1') {
- if (estimateData.fileFlg === '0') {
- alert(getMessage('estimate.detail.save.requiredMsg'))
- flag = false
+ if (estimateData.fileList.length < 1) {
+ if (estimateData.itemList.length > 1) {
+ estimateData.itemList.map((row) => {
+ if (row.fileUploadFlg === '1') {
+ if (estimateData.fileFlg === '0') {
+ alert(getMessage('estimate.detail.save.requiredMsg'))
+ flag = false
+ }
}
- }
- })
+ })
+ }
}
+
if (flag) {
//1. 첨부파일 저장
const formData = new FormData()
+ console.log('첨부파일:!!!', estimateData.fileList)
formData.append('file', estimateData.fileList)
formData.append('objectNo', estimateData.objectNo)
formData.append('planNo', estimateData.planNo)
formData.append('category', '10')
formData.append('userId', estimateData.userId)
- // for (const value of formData.values()) {
- // console.log('formData::', value)
- // }
await post({ url: '/api/file/fileUpload', data: formData })
@@ -162,5 +192,6 @@ export const useEstimateController = (planNo) => {
addItem,
handleEstimateSubmit,
fetchSetting,
+ handleEstimateFileDownload,
}
}
diff --git a/src/locales/ja.json b/src/locales/ja.json
index 97d3f599..f849816e 100644
--- a/src/locales/ja.json
+++ b/src/locales/ja.json
@@ -616,7 +616,7 @@
"stuff.planReqPopup.title": "設計依頼のインポート",
"stuff.temp.subTitle": "商品情報",
"stuff.temp.subTitle2": "作図",
- "stuff.detail.header.message1": "存在しないものです。",
+ "stuff.detail.header.notExistObjectNo": "存在しないものです。",
"stuff.detail.header.message2": "商品番号がコピーされました。",
"stuff.detail.header.message3": "存在しないものです。",
"stuff.detail.header.objectNo": "商品番号のコピーに失敗しました。",
diff --git a/src/locales/ko.json b/src/locales/ko.json
index 2d42a11c..e22241bc 100644
--- a/src/locales/ko.json
+++ b/src/locales/ko.json
@@ -626,7 +626,7 @@
"stuff.planReqPopup.title": "설계의뢰 불러오기",
"stuff.temp.subTitle": "물건정보",
"stuff.temp.subTitle2": "도면작성",
- "stuff.detail.header.message1": "존재하지 않는 물건입니다.",
+ "stuff.detail.header.notExistObjectNo": "존재하지 않는 물건입니다.",
"stuff.detail.header.message2": "물건번호가 복사되었습니다.",
"stuff.detail.header.message3": "물건번호 복사에 실패했습니다.",
"stuff.detail.header.objectNo": "물건번호",