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