견적서

This commit is contained in:
basssy 2024-12-03 17:43:15 +09:00
parent 3b72acce81
commit e6e600602d
4 changed files with 97 additions and 46 deletions

View File

@ -191,9 +191,9 @@ export default function Estimate({ params }) {
}, [specialNoteList])
// remark
const settingShowContent = (code, event) => {
const settingShowContent = (code) => {
setShowContentCode(code)
event.stopPropagation()
// event.stopPropagation()
}
// estimateContextState
@ -227,7 +227,15 @@ export default function Estimate({ params }) {
}, [estimateContextState?.fileList])
// ( ?)
const deleteOriginFile = async (objectNo, no) => {
const deleteOriginFile = (objectNo, no) => {
originFiles.map((file) => {
if (file.no === no) {
file.delFlg = '1'
}
})
// console.log('originFiles::', originFiles)
setOriginFiles(originFiles)
const delParams = {
userId: session.userId,
objectNo: objectNo,
@ -407,25 +415,43 @@ export default function Estimate({ params }) {
if (isNotEmptyArray(data.data2)) {
estimateContextState.itemList.map((item) => {
// console.log('::', item)
let checkYn = false
data.data2.map((item2) => {
if (item2) {
if (item2.itemId === item.itemId) {
for (let i = 0; i < data.data2.length; i++) {
// console.log(':::', data.data2[i])
if (data.data2[i]) {
if (data.data2[i].itemId === item.itemId) {
updateList.push({
...item,
openFlg: item2.unitPrice === '0.0' ? '1' : '0',
salePrice: item2.unitPrice === null ? '0' : item2.unitPrice,
saleTotPrice: (item.amount * item2.unitPrice).toString(),
openFlg: data.data2[i].unitPrice === '0.0' ? '1' : '0',
salePrice: data.data2[i].unitPrice === null ? '0' : data.data2[i].unitPrice,
saleTotPrice: (item.amount * data.data2[i].unitPrice).toString(),
})
checkYn = true
break
}
}
})
}
// data.data2.map((item2) => {
// if (item2) {
// // console.log('::::', item2)
// if (item2.itemId === item.itemId) {
// updateList.push({
// ...item,
// openFlg: item2.unitPrice === '0.0' ? '1' : '0',
// salePrice: item2.unitPrice === null ? '0' : item2.unitPrice,
// saleTotPrice: (item.amount * item2.unitPrice).toString(),
// })
// checkYn = true
// }
// }
// })
if (!checkYn) {
updateList.push({ ...item, salePrice: '0', saleTotPrice: '0' })
}
})
setEstimateContextState({
priceCd: showPriceCd,
itemList: updateList,
@ -472,7 +498,7 @@ export default function Estimate({ params }) {
//PKG input
const onChangePkgAsp = (value) => {
if (estimateContextState.estimateType === 'YJSS') {
let pkgAsp = Number(value.replace(/[^0-9]/g, '').replaceAll(',', ''))
let pkgAsp = Number(value.replace(/[^-\.0-9]/g, '').replaceAll(',', ''))
if (isNaN(pkgAsp)) {
pkgAsp = 0
} else {
@ -725,6 +751,7 @@ export default function Estimate({ params }) {
makeUniqueSpecialNoteCd(itemList)
itemList.forEach((item) => {
// console.log('YJOD::::::', item)
delete item.showSalePrice
delete item.showSaleTotPrice
if (item.delFlg === '0') {
@ -753,10 +780,10 @@ export default function Estimate({ params }) {
itemList.sort((a, b) => a.dispOrder - b.dispOrder)
makeUniqueSpecialNoteCd(itemList)
itemList.forEach((item) => {
// console.log('YJSSS::', item)
if (item.delFlg === '0') {
let amount = Number(item.amount?.replace(/[^0-9]/g, '').replaceAll(',', '')) || 0
let salePrice = Number(item.salePrice?.replaceAll(',', '')) || 0
if (item.moduleFlg === '1') {
const volKw = (item.pnowW * amount) / 1000
totals.totVolKw += volKw
@ -1111,17 +1138,26 @@ export default function Estimate({ params }) {
{originFiles.map((originFile) => {
return (
<li className="file-item" key={uuidv4()}>
<span onClick={() => handleEstimateFileDownload(originFile)}>
{originFile.faileName}
<button
type="button"
className="delete"
onClick={(e) => {
deleteOriginFile(originFile.objectNo, originFile.no)
e.stopPropagation()
}}
></button>
</span>
<div className="file-item-wrap">
<span>
{originFile.faileName}
<button
type="button"
className="delete"
onClick={(e) => {
deleteOriginFile(originFile.objectNo, originFile.no)
e.stopPropagation()
}}
></button>
</span>
{/* <div className="return-wrap">
<span className="return">{originFile.faileName}</span>
<button type="button" className="return-btn">
<i className="return-ico"></i>
{getMessage('estimate.detail.fileList2.btn.return')}
</button>
</div> */}
</div>
</li>
)
})}
@ -1155,21 +1191,29 @@ export default function Estimate({ params }) {
specialNoteList.map((row) => {
return (
<div key={uuidv4()} className="special-note-check-item">
<div className="d-check-box light">
<input
type="checkbox"
id={row.code}
checked={!!row.check}
disabled={row.code === 'ATTR001' ? true : false}
onChange={(event) => {
setSpecialNoteList((specialNote) =>
specialNote.map((temp) => (temp.code === row.code ? { ...temp, check: !temp.check } : temp)),
)
settingShowContent(row.code, event)
<div className="special-note-check-box">
<div className="d-check-box light">
<input
type="checkbox"
id={row.code}
checked={!!row.check}
disabled={row.code === 'ATTR001' || row.pkgYn === '1' ? true : false}
onClick={(event) => {
setSpecialNoteList((specialNote) =>
specialNote.map((temp) => (temp.code === row.code ? { ...temp, check: !temp.check } : temp)),
)
}}
/>
<label htmlFor={row.code}></label>
</div>
<span
className="check-name"
onClick={() => {
settingShowContent(row.code)
}}
/>
<label htmlFor={row.code}>{row.codeNm}</label>
>
{row.codeNm}
</span>
</div>
</div>
)
@ -1501,7 +1545,9 @@ export default function Estimate({ params }) {
</div>
</td>
<td className="al-r">
{convertNumberToPriceDecimal(item?.showSaleTotPrice === '0' ? null : item?.saleTotPrice?.replaceAll(',', ''))}
{convertNumberToPriceDecimal(
item?.showSaleTotPrice === '0' ? null : item?.saleTotPrice === '0' ? null : item?.saleTotPrice?.replaceAll(',', ''),
)}
</td>
</tr>
)

View File

@ -18,6 +18,9 @@ const updateItemInList = (itemList, dispOrder, updates) => {
}
export const useEstimateController = (planNo) => {
const [fileList, setFileList] = useState([])
const [deleteFileList, setDeleteFileList] = useState([])
const router = useRouter()
const { session } = useContext(SessionContext)
const globalLocaleState = useRecoilValue(globalLocaleStore)
@ -148,8 +151,8 @@ export const useEstimateController = (planNo) => {
//첨부파일을 첨부안했는데
//아이템 fileUploadFlg가1(첨부파일 필수)이 1개라도 있는데 후일 자료 제출(fileFlg) 체크안했으면(0) alert 저장안돼
console.log('새로추가첨부파일:::', estimateData.newFileList)
console.log('기존첨부파일:::', estimateData.originFiles)
// console.log('새로추가첨부파일:::', estimateData.newFileList)
// console.log('기존첨부파일:::', estimateData.originFiles)
// return
@ -228,13 +231,12 @@ export const useEstimateController = (planNo) => {
formData.append('category', '10')
formData.append('userId', estimateData.userId)
await post({ url: '/api/file/fileUpload', data: formData })
await post({ url: '/api/file/fileUpload', data: formData }).then((res) => {
console.log('리턴::::::::::::', res)
})
}
//첨부파일저장끝
//제품라인 추가했는데 아이템 안고르고 저장하면itemId=''은 날리고 나머지 저장하기
// estimateData.itemList = estimateData.itemList.filter((item) => item.itemId !== '')
estimateData.itemList = estimateData.itemList.filter((item) => item.delFlg === '0' || !item.addFlg)
let delCnt = 0
@ -287,10 +289,11 @@ export const useEstimateController = (planNo) => {
estimateOptions = estimateOptionsArray.join('、')
estimateData.estimateOption = estimateOptions
console.log('최종아이템:::', estimateData.itemList)
// console.log('첨부파일::::::::', fileList)
// console.log('최종아이템:::', estimateData.itemList)
console.log('최종저장::', estimateData)
//2. 상세데이터 저장
// return
return
try {
await promisePost({ url: `${ESTIMATE_API_ENDPOINT}/save-estimate`, data: estimateData }).then((res) => {
if (res.status === 201) {

View File

@ -841,6 +841,7 @@
"estimate.detail.fileList.btn": "ファイル選択",
"estimate.detail.fileList.extCheck": "そのファイルはイメージファイルではありません",
"estimate.detail.header.fileList2": "添付ファイル一覧",
"estimate.detail.fileList2.btn.return": "復元",
"estimate.detail.header.specialEstimate": "見積もりの具体的な",
"estimate.detail.header.specialEstimateProductInfo": "製品情報",
"estimate.detail.sepcialEstimateProductInfo.totAmount": "数量 (PCS)",

View File

@ -851,6 +851,7 @@
"estimate.detail.fileList.btn": "파일선택",
"estimate.detail.fileList.extCheck": "해당 파일은 이미지 파일이 아닙니다",
"estimate.detail.header.fileList2": "첨부파일 목록",
"estimate.detail.fileList2.btn.return": "복원",
"estimate.detail.header.specialEstimate": "견적특이사항",
"estimate.detail.header.specialEstimateProductInfo": "제품정보",
"estimate.detail.sepcialEstimateProductInfo.totAmount": "수량 (PCS)",