견적서 상세
This commit is contained in:
parent
7dac85cf39
commit
173f26a1fc
@ -17,7 +17,6 @@ import { SessionContext } from '@/app/SessionProvider'
|
|||||||
import Select, { components } from 'react-select'
|
import Select, { components } from 'react-select'
|
||||||
import { convertNumberToPriceDecimal } from '@/util/common-utils'
|
import { convertNumberToPriceDecimal } from '@/util/common-utils'
|
||||||
import ProductFeaturesPop from './popup/ProductFeaturesPop'
|
import ProductFeaturesPop from './popup/ProductFeaturesPop'
|
||||||
|
|
||||||
export default function Estimate({ params }) {
|
export default function Estimate({ params }) {
|
||||||
const { session } = useContext(SessionContext)
|
const { session } = useContext(SessionContext)
|
||||||
const [objectNo, setObjectNo] = useState('') //물건번호
|
const [objectNo, setObjectNo] = useState('') //물건번호
|
||||||
@ -31,6 +30,7 @@ export default function Estimate({ params }) {
|
|||||||
const [productFeaturesPopupOpen, setProductFeaturesPopupOpen] = useState(false) //견적특이사항 팝업
|
const [productFeaturesPopupOpen, setProductFeaturesPopupOpen] = useState(false) //견적특이사항 팝업
|
||||||
const [showProductFeatureData, setShowProductFeatureData] = useState([]) //팝업에 보여줄 견적특이사항 데이터
|
const [showProductFeatureData, setShowProductFeatureData] = useState([]) //팝업에 보여줄 견적특이사항 데이터
|
||||||
|
|
||||||
|
const [selection, setSelection] = useState(new Set())
|
||||||
//견적특이사항 접고 펼치기
|
//견적특이사항 접고 펼치기
|
||||||
const [hidden, setHidden] = useState(false)
|
const [hidden, setHidden] = useState(false)
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ export default function Estimate({ params }) {
|
|||||||
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
const objectRecoil = useRecoilValue(floorPlanObjectState)
|
||||||
|
|
||||||
//견적서 상세데이터
|
//견적서 상세데이터
|
||||||
const { state, setState } = useEstimateController(params.pid)
|
const { state, setState, addItem } = useEstimateController(params.pid)
|
||||||
|
|
||||||
const [itemList, setItemList] = useState([]) //기존 아이템 리스트
|
const [itemList, setItemList] = useState([]) //기존 아이템 리스트
|
||||||
|
|
||||||
@ -191,25 +191,27 @@ export default function Estimate({ params }) {
|
|||||||
|
|
||||||
//가격표시 option 최초세팅
|
//가격표시 option 최초세팅
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const param = {
|
if (state.estimateType !== '') {
|
||||||
saleStoreId: session.storeId,
|
const param = {
|
||||||
sapSalesStoreCd: session.custCd,
|
saleStoreId: session.storeId,
|
||||||
docTpCd: state?.estimateType,
|
sapSalesStoreCd: session.custCd,
|
||||||
}
|
docTpCd: state?.estimateType,
|
||||||
|
|
||||||
const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}`
|
|
||||||
get({ url: apiUrl }).then((res) => {
|
|
||||||
if (isNotEmptyArray(res?.data)) {
|
|
||||||
setStorePriceList(res.data)
|
|
||||||
}
|
}
|
||||||
})
|
|
||||||
|
const apiUrl = `/api/estimate/price/store-price-list?${queryStringFormatter(param)}`
|
||||||
|
get({ url: apiUrl }).then((res) => {
|
||||||
|
if (isNotEmptyArray(res?.data)) {
|
||||||
|
setStorePriceList(res.data)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
}, [state?.estimateType])
|
}, [state?.estimateType])
|
||||||
|
|
||||||
useEffect(() => {
|
// useEffect(() => {
|
||||||
if (state.priceCd) {
|
// if (state.priceCd) {
|
||||||
setTempPriceCd(state.priceCd)
|
// setTempPriceCd(state.priceCd)
|
||||||
}
|
// }
|
||||||
}, [state?.priceCd])
|
// }, [state?.priceCd])
|
||||||
|
|
||||||
//가격표시 option 변경시
|
//가격표시 option 변경시
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -260,10 +262,37 @@ export default function Estimate({ params }) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
// 제품 추가 테스트
|
//row 체크박스 컨트롤
|
||||||
const addItemTest = () => {
|
const onChangeSelect = (dispOrder) => {
|
||||||
const newItemDispOrder = (Math.max(...state.itemList.map((item) => item.dispOrder)) + 1) * 100
|
const newSelection = new Set(selection)
|
||||||
console.log('newItemDispOrder::', newItemDispOrder)
|
if (newSelection.has(dispOrder)) {
|
||||||
|
newSelection.delete(dispOrder)
|
||||||
|
} else {
|
||||||
|
newSelection.add(dispOrder)
|
||||||
|
}
|
||||||
|
|
||||||
|
setSelection(newSelection)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 아이템 자동완성 검색시
|
||||||
|
const onChangeDisplayItem = (itemId, dispOrder) => {
|
||||||
|
console.log('아이템 자동완성:::::::', dispOrder)
|
||||||
|
const param = {
|
||||||
|
itemId: itemId,
|
||||||
|
}
|
||||||
|
const apiUrl = `/api/display-item/item-detail?${queryStringFormatter(param)}`
|
||||||
|
get({ url: apiUrl }).then((res) => {
|
||||||
|
console.log('제품상세 결과::::::::', res)
|
||||||
|
})
|
||||||
|
// setState({
|
||||||
|
// itemList: [{ itemNo: '123123123123' }],
|
||||||
|
// })
|
||||||
|
}
|
||||||
|
|
||||||
|
//제품 삭제
|
||||||
|
const removeItem = () => {
|
||||||
|
const array = [...selection]
|
||||||
|
console.log(array)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -731,11 +760,11 @@ export default function Estimate({ params }) {
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
<div className="product-edit-btn">
|
<div className="product-edit-btn">
|
||||||
<button className="btn-origin navy mr5" type="button" onClick={() => addItemTest()}>
|
<button className="btn-origin navy mr5" type="button" onClick={addItem}>
|
||||||
<span className="plus"></span>
|
<span className="plus"></span>
|
||||||
{getMessage('estimate.detail.showPrice.addItem')}
|
{getMessage('estimate.detail.showPrice.addItem')}
|
||||||
</button>
|
</button>
|
||||||
<button className="btn-origin grey">
|
<button className="btn-origin grey" type="button" onClick={removeItem}>
|
||||||
<span className="minus"></span>
|
<span className="minus"></span>
|
||||||
{getMessage('estimate.detail.showPrice.delItem')}
|
{getMessage('estimate.detail.showPrice.delItem')}
|
||||||
</button>
|
</button>
|
||||||
@ -774,14 +803,14 @@ export default function Estimate({ params }) {
|
|||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{itemList.length > 0 &&
|
{state?.itemList.length > 0 &&
|
||||||
itemList.map((item, index) => {
|
state.itemList.map((item, index) => {
|
||||||
return (
|
return (
|
||||||
<tr key={index}>
|
<tr key={index}>
|
||||||
<td className="al-c">
|
<td className="al-c">
|
||||||
<div className="d-check-box light no-text">
|
<div className="d-check-box light no-text">
|
||||||
<input type="checkbox" id={item?.dispOrder * 100} />
|
<input type="checkbox" id={item?.dispOrder} onChange={() => onChangeSelect(item.dispOrder)} />
|
||||||
<label htmlFor={item?.dispOrder * 100}></label>
|
<label htmlFor={item?.dispOrder}></label>
|
||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
<td className="al-r">{item?.dispOrder * 100}</td>
|
<td className="al-r">{item?.dispOrder * 100}</td>
|
||||||
@ -795,11 +824,14 @@ export default function Estimate({ params }) {
|
|||||||
classNamePrefix="custom"
|
classNamePrefix="custom"
|
||||||
placeholder="Select"
|
placeholder="Select"
|
||||||
options={displayItemList}
|
options={displayItemList}
|
||||||
|
onChange={(e) => onChangeDisplayItem(e.itemId, item.dispOrder)}
|
||||||
getOptionLabel={(x) => x.itemName}
|
getOptionLabel={(x) => x.itemName}
|
||||||
getOptionValue={(x) => x.itemId}
|
getOptionValue={(x) => x.itemId}
|
||||||
isClearable={true}
|
isClearable={true}
|
||||||
isDisabled={false}
|
isDisabled={false}
|
||||||
value={displayItemList.filter(function (option) {
|
value={displayItemList.filter(function (option) {
|
||||||
|
// console.log('옵션값???', option.itemId)
|
||||||
|
// console.log('골랐을때 여기오지???', item.itemId)
|
||||||
return option.itemId === item.itemId
|
return option.itemId === item.itemId
|
||||||
})}
|
})}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -19,7 +19,7 @@ const defaultEstimateData = {
|
|||||||
charger: '', //담당자
|
charger: '', //담당자
|
||||||
objectName: '', //안건명
|
objectName: '', //안건명
|
||||||
objectNameOmit: '', //경칭코드
|
objectNameOmit: '', //경칭코드
|
||||||
estimateType: 'YJOD', //주문분류
|
estimateType: '', //주문분류
|
||||||
remarks: '', //비고
|
remarks: '', //비고
|
||||||
estimateOption: '', //견적특이사항
|
estimateOption: '', //견적특이사항
|
||||||
itemList: [],
|
itemList: [],
|
||||||
@ -76,12 +76,14 @@ export const useEstimateController = (planNo) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const addItem = () => {
|
const addItem = () => {
|
||||||
const newItemDispOrder = (Math.max(...state.itemList.map((item) => item.dispOrder)) + 1) * 100
|
const newItemDispOrder = Math.max(...state.itemList.map((item) => item.dispOrder)) + 1
|
||||||
setState({
|
setState({
|
||||||
itemList: [
|
itemList: [
|
||||||
...state.itemList,
|
...state.itemList,
|
||||||
{
|
{
|
||||||
dispOrder: newItemDispOrder,
|
objectNo: objectRecoil.floorPlanObjectNo,
|
||||||
|
planNo: planNo,
|
||||||
|
dispOrder: newItemDispOrder.toString(),
|
||||||
itemId: '', //제품번호
|
itemId: '', //제품번호
|
||||||
itemNo: '', //형명
|
itemNo: '', //형명
|
||||||
itemName: '',
|
itemName: '',
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user