물건현황 리스트 사양확정일 필드명 수정 & 임시저장 & 상세화면 ...

This commit is contained in:
basssy 2024-10-22 17:55:47 +09:00
parent 4d859d1530
commit cc9eee731b
4 changed files with 350 additions and 125 deletions

View File

@ -123,8 +123,8 @@ export default function Stuff() {
{ field: 'dispCompanyName', headerName: getMessage('stuff.gridHeader.dispCompanyName'), cellStyle: { textAlign: 'left' } },
{ field: 'receiveUser', headerName: getMessage('stuff.gridHeader.receiveUser'), cellStyle: { textAlign: 'left' } },
{
field: 'specDate',
headerName: getMessage('stuff.gridHeader.specDate'),
field: 'specificationConfirmDate',
headerName: getMessage('stuff.gridHeader.specificationConfirmDate'),
valueFormatter: function (params) {
if (params.value) {
return dayjs(params?.value).format('YYYY.MM.DD')

View File

@ -31,7 +31,7 @@ export default function StuffDetail() {
const { getMessage } = useMessage()
const globalLocaleState = useRecoilValue(globalLocaleStore)
const ref = useRef()
const { get, del, promisePost } = useAxios(globalLocaleState)
const { get, del, promisePost, promisePut } = useAxios(globalLocaleState)
//form
const formInitValue = {
// T...() R...()
@ -71,6 +71,8 @@ export default function StuffDetail() {
const [honorificCodeList, setHonorificCodeList] = useState([]) //
const [selHonorificCode, setSelHonorificCode] = useState('') //
const [objectStatusList, setObjectStatusList] = useState([]) //
const [selectObjectStatusId, setSelectObjectStatusId] = useState('0') //
const [windSpeedList, setWindSpeedList] = useState([]) //
const [prefCodeList, setPrefCodeList] = useState([]) //
const [prefValue, setPrefValue] = useState('')
@ -93,7 +95,6 @@ export default function StuffDetail() {
// console.log('objectNo::', objectNo)
if (objectNo) {
console.log('수정화면')
setEditMode('EDIT')
if (objectNo.substring(0, 1) === 'R') {
@ -116,7 +117,6 @@ export default function StuffDetail() {
//1 : X167 T01
//2 : 10X22, 201X112
// get({ url: `/api/object/saleStore/T100/list` }).then((res) => {
get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => {
if (!isEmptyArray(res)) {
const firstList = res.filter((row) => row.saleStoreLevel === '1')
@ -171,11 +171,8 @@ export default function StuffDetail() {
}
})
// 1 ??
// 1 saleStoreId=201TES01
// T01
//1 : X167
// get({ url: `/api/object/saleStore/T01/list` }).then((res) => {
//1 : X167 T01
//2 : 10X22, 201X112
get({ url: `/api/object/saleStore/${sessionState?.storeId}/list` }).then((res) => {
if (!isEmptyArray(res)) {
const firstList = res.filter((row) => row.saleStoreLevel === '1')
@ -186,11 +183,44 @@ export default function StuffDetail() {
setOriginOtherSaleStoreList(otherList)
setOtherSaleStoreList(otherList)
}
})
console.log('상세데이타::세팅:::::', detailData)
//No.
form.setValue('planReqNo', detailData.planReqNo)
//
form.setValue('dispCompanyName', detailData.dispCompanyName)
//objectStatusId
setSelectObjectStatusId(detailData.objectStatusId)
form.setValue('objectStatusId', detailData.objectStatusId)
//
form.setValue('objectName', detailData.objectName)
//
setSelHonorificCode(detailData.objectNameOmit)
form.setValue('objectNameOmit', detailData.objectNameOmit)
//
form.setValue('objectNameKana', detailData.objectNameKana)
// console.log('1::', firstList)
// console.log('2::', otherList)
setSelOptions(detailData.saleStoreId)
form.setValue('saleStoreId', detailData.saleStoreId)
form.setValue('saleStoreLevel', sessionState?.storeLvl)
//2
console.log('2차점까지 고른경우 확인필요')
// setOtherSelOptions(sessionState?.storeId)
// form.setValue('saleStoreId', firstList[0].saleStoreId)
// form.setValue('otherSaleStoreId', sessionState?.storeId)
// form.setValue('otherSaleStoreLevel', sessionState?.storeLvl)
form.setValue('zipNo', detailData.zipNo)
})
}
}, [detailData])
}, [detailData, sessionState])
//
const onChangeHonorificCode = (key) => {
@ -212,8 +242,26 @@ export default function StuffDetail() {
}
}
//
const onRadioChange = (key) => {
setSelectObjectStatusId(key.target.value)
}
//1
const onSelectionChange = (key) => {
const planReqNo = form.watch('planReqNo')
let delFlg = false
if (planReqNo !== '') {
if (confirm('stuff.detail.confirm.message1')) {
delFlg = true
} else {
delFlg = false
}
}
if (planReqNo !== '') {
if (delFlg) {
form.setValue('planReqNo', '')
if (isObjectNotEmpty(key)) {
setOtherSaleStoreList(otherSaleStoreList)
form.setValue('saleStoreId', key.saleStoreId)
@ -233,14 +281,54 @@ export default function StuffDetail() {
form.setValue('otherSaleStoreId', '')
form.setValue('otherSaleStoreName', '')
form.setValue('otherSaleStoreLevel', '')
setOtherSaleStoreList(originOtherSaleStoreList)
//1 2
setOtherSaleStoreList(originOtherSaleStoreList)
handleClear()
}
}
} else {
if (isObjectNotEmpty(key)) {
setOtherSaleStoreList(otherSaleStoreList)
form.setValue('saleStoreId', key.saleStoreId)
form.setValue('saleStoreName', key.saleStoreName)
form.setValue('saleStoreLevel', key.saleStoreLevel)
setSelOptions(key.saleStoreId)
// 1 2 list
// 
let newOtherSaleStoreList = originOtherSaleStoreList.filter((row) => row.firstAgentId === key.saleStoreId)
setOtherSaleStoreList(newOtherSaleStoreList)
} else {
//X
setSelOptions('')
form.setValue('saleStoreId', '')
form.setValue('saleStoreName', '')
form.setValue('saleStoreLevel', '')
form.setValue('otherSaleStoreId', '')
form.setValue('otherSaleStoreName', '')
form.setValue('otherSaleStoreLevel', '')
//1 2
setOtherSaleStoreList(originOtherSaleStoreList)
handleClear()
}
}
}
//2
const onSelectionChange2 = (key) => {
const planReqNo = form.watch('planReqNo')
let delFlg = false
if (planReqNo !== '') {
if (confirm('stuff.detail.confirm.message1')) {
delFlg = true
} else {
delFlg = false
}
}
if (planReqNo !== '') {
if (delFlg) {
form.setValue('planReqNo', '')
if (isObjectNotEmpty(key)) {
setOtherSelOptions(key.saleStoreId)
form.setValue('otherSaleStoreId', key.saleStoreId)
@ -253,6 +341,20 @@ export default function StuffDetail() {
form.setValue('otherSaleStoreLevel', '')
}
}
} else {
if (isObjectNotEmpty(key)) {
setOtherSelOptions(key.saleStoreId)
form.setValue('otherSaleStoreId', key.saleStoreId)
form.setValue('otherSaleStoreName', key.saleStoreName)
form.setValue('otherSaleStoreLevel', key.saleStoreLevel)
} else {
setOtherSelOptions('')
form.setValue('otherSaleStoreId', '')
form.setValue('otherSaleStoreName', '')
form.setValue('otherSaleStoreLevel', '')
}
}
}
//1 2
const handleClear = () => {
@ -295,8 +397,8 @@ export default function StuffDetail() {
if (info.saleStoreLevel === '1') {
setSelOptions(info.saleStoreId)
form.setValue('saleStoreId', info.saleStoreId)
form.setValue('saleStoreName', key.saleStoreName)
form.setValue('saleStoreLevel', key.saleStoreLevel)
form.setValue('saleStoreName', info.saleStoreName)
form.setValue('saleStoreLevel', info.saleStoreLevel)
} else {
setOtherSelOptions(info.saleStoreId)
form.setValue('otherSaleStoreId', info.saleStoreId)
@ -310,40 +412,32 @@ export default function StuffDetail() {
form.setValue('windSpeed', info.windSpeed)
}
//
//dispCompanyName: '', //
// objectName: '', //
// objectNameOmit: '', //
// saleStoreId: '', //ID
// zipNo: '', //
// prefId: '', //
// address: '', //
// areaId: '', //new
// windSpeed: '', //
// verticalSnowCover: '', //
// coldRegionFlg: false, //
// surfaceType: '', //( / )
// saltAreaFlg: false, //
// installHeight: '', //
// conType : '0' //( / )
// remarks: '', //
// tempFlag: 'T', //(1) (0)
const _dispCompanyName = watch('dispCompanyName')
//objectName: '', //
const _objectName = watch('objectName')
// objectNameOmit: '', //
const _objectNameOmit = watch('objectNameOmit')
// saleStoreId: '', //1 ID
const _saleStoreId = watch('saleStoreId')
const _saleStoreLevel = watch('saleStoreLevel')
// zipNo: '', //
const _zipNo = watch('zipNo')
// prefId: '', //
const _prefId = watch('prefId')
// address: '', //
const _address = watch('address')
const _areaId = watch('areaId') //new
// areaId: '', //
const _areaId = watch('areaId')
// windSpeed: '', //
const _windSpeed = watch('windSpeed')
// verticalSnowCover: '', //
const _verticalSnowCover = watch('verticalSnowCover')
// installHeight: '', //
const _installHeight = watch('installHeight')
useEffect(() => {
if (editMode === 'NEW') {
const formData = form.getValues()
// console.log('error::::::::::::', formData)
let errors = {}
if (!formData.dispCompanyName || formData.dispCompanyName.trim().length === 0) {
errors.dispCompanyName = true
@ -358,6 +452,10 @@ export default function StuffDetail() {
errors.saleStoreId = true
}
if (!formData.zipNo) {
errors.zipNo = true
}
if (!formData.prefId) {
errors.prefId = true
}
@ -378,19 +476,57 @@ export default function StuffDetail() {
errors.installHeight = true
}
// console.log('::', errors)
setIsFormValid(Object.keys(errors).length === 0 ? true : false)
} else {
console.log('상세일때 폼체크')
const formData = form.getValues()
let errors = {}
if (!formData.dispCompanyName || formData.dispCompanyName.trim().length === 0) {
errors.dispCompanyName = true
}
if (!formData.objectName || formData.objectName.trim().length === 0) {
errors.objectName = true
}
if (!formData.objectNameOmit) {
errors.objectNameOmit = true
}
if (!formData.saleStoreId) {
errors.saleStoreId = true
}
if (!formData.zipNo) {
errors.zipNo = true
}
if (!formData.prefId) {
errors.prefId = true
}
if (!formData.areaId) {
errors.areaId = true
}
if (!formData.windSpeed) {
errors.windSpeed = true
}
if (!formData.verticalSnowCover) {
errors.verticalSnowCover = true
}
if (!formData.installHeight) {
errors.installHeight = true
}
console.log('상세 저장용 에러결과?????::', errors)
setIsFormValid(Object.keys(errors).length === 0 ? true : false)
}
}, [
_dispCompanyName,
_objectName,
_objectNameOmit,
_saleStoreId,
_saleStoreLevel,
// _otherSaleStoreId,
// _otherSaleStoreLevel,
_zipNo,
_prefId,
_address,
_areaId,
@ -424,8 +560,6 @@ export default function StuffDetail() {
//
get({ url: `/api/object/prefecture/${prefValue}/list` }).then((res) => {
if (!isEmptyArray(res)) {
// form.setValue('areaId', res[0].areaId)
// form.setValue('areaName', res[0].prefName)
setAreaIdList(res)
}
})
@ -439,29 +573,52 @@ export default function StuffDetail() {
}
//
const onValid = (data, e) => {
const onValid = async () => {
const formData = form.getValues()
console.log('필수값 통과:::', data, formData)
// console.log(' formData:::', formData)
console.log('필수값 통과:::', formData)
const apiUrl = '/api/object/save-object'
const params = {
saleStoreId: formData.otherSaleStoreId ? formData.otherSaleStoreId : formData.saleStoreId,
saleStoreName: formData.otherSaleStoreName ? formData.otherSaleStoreName : formData.saleStoreName,
saleStoreLevel: formData.otherSaleStoreLevel ? formData.otherSaleStoreLevel : formData.saleStoreLevel,
objectStatusId: formData.objectStatusId,
objectName: formData.objectName,
objectNameOmit: formData.objectNameOmit,
objectNameKana: formData.objectNameKana,
zipNo: formData.zipNo,
prefId: formData.prefId,
prefName: formData.prefName,
address: formData.address,
areaId: formData.areaId,
receiveUser: formData.dispCompanyName,
installHeight: formData.installHeight,
windSpeed: formData.windSpeed,
verticalSnowCover: formData.verticalSnowCover,
surfaceType: formData.surfaceType,
conType: formData.conType,
coldRegionFlg: formData.coldRegionFlg,
saltAreaFlg: formData.saltAreaFlg,
tempFlg: '0',
workNo: null,
workName: null,
}
console.log('params::', params)
alert('작업중')
return
if (editMode === 'NEW') {
await promisePost({ url: apiUrl, data: params }).then((res) => {
console.log('진짜저장결과::::', pathname, res)
//
//router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`)
})
} else {
// PUT
// console.log(' ')
// console.log('data::::::', data)
// console.log('formData::::', formData)
// const _dispCompanyName = watch('dispCompanyName')
// const _objectStatusId = watch('objectStatusId')
// const _objectNameOmit = watch('objectNameOmit')
// const _zipNo = watch('zipNo')
// const _prefId = watch('prefId')
// const _address = watch('address')
// const _coldRegionFlg = watch('coldRegionFlg')
// console.log(_dispCompanyName)
// console.log(_objectStatusId)
// console.log(_objectNameOmit)
// console.log(_zipNo)
// console.log(_prefId)
// console.log('prefValue::', prefValue)
// console.log(_address)
// console.log('_coldRegionFlg::', _coldRegionFlg)
await promisePut({ url: apiUrl, data: params }).then((res) => {
console.log('진짜데이터 수정 결과::::::::::', pathname, res)
//???
})
}
}
// form required
@ -474,8 +631,6 @@ export default function StuffDetail() {
//
const onTempSave = async () => {
const formData = form.getValues()
console.log('임시저장누름:::::', formData)
return
const params = {
saleStoreId: formData.otherSaleStoreId ? formData.otherSaleStoreId : formData.saleStoreId,
saleStoreName: formData.otherSaleStoreName ? formData.otherSaleStoreName : formData.saleStoreName,
@ -501,15 +656,17 @@ export default function StuffDetail() {
workNo: null,
workName: null,
}
//1 or 2
if (params.saleStoreId == '') {
params.saleStoreId = sessionState.storeId
params.saleStoreLevel = sessionState.storeLvl
}
alert('작업중')
return
await promisePost({ url: '/api/object/save-object', data: params }).then((res) => {
if (res.status === 201) {
alert('임시저장 되었습니다. 물건번호를 획득하려면 필수 항목을 모두 입력해 주십시오.')
getMessage('stuff.detail.tempSave.message1')
router.push(`${pathname}?objectNo=${res.data.objectNo.toString()}`)
}
})
@ -576,7 +733,7 @@ export default function StuffDetail() {
<td>
<div className="flx-box">
{/* 라디오시작 */}
{objectStatusList.map((row, index) => {
{objectStatusList.map((row) => {
return (
<div className="d-check-radio light mr10" key={`objectStatusId_${row.clCode}`}>
<input
@ -585,6 +742,8 @@ export default function StuffDetail() {
value={row.clCode}
id={`objectStatus${row.clCode}`}
{...register('objectStatusId')}
onChange={onRadioChange}
checked={row.clCode === selectObjectStatusId}
/>
<label htmlFor={`objectStatus${row.clCode}`}>{row.clCodeNm}</label>
</div>
@ -597,7 +756,7 @@ export default function StuffDetail() {
<div className="select-wrap" style={{ width: '120px' }}>
<Select
{...register('objectNameOmit')}
id="ng-value-select0"
id="long-value-select0"
instanceId="long-value-select0"
className="react-select-custom"
classNamePrefix="custom"
@ -782,9 +941,6 @@ export default function StuffDetail() {
</th>
<td>
<div className="flx-box">
{/* <div className="input-wrap mr10">
<input type="text" className="input-light" readOnly value={form.watch('windSpeed')} {...register('windSpeed')} />
</div> */}
{/* 기준풍속sel시작 */}
<div className="select-wrap mr10" style={{ width: '200px' }}>
<Select
@ -819,13 +975,6 @@ export default function StuffDetail() {
</th>
<td>
<div className="flx-box">
{/* <div className="select-wrap mr10" style={{ width: '200px' }}>
<select className="select-light" name="verticalSnowCover" {...register('verticalSnowCover')}>
<option value="">수직적설량 인풋</option>
<option value="30">30</option>
<option value="40">40</option>
</select>
</div> */}
<div className="input-wrap mr10" style={{ width: '200px' }}>
<input type="text" className="input-light" value={form.watch('verticalSnowCover')} {...register('verticalSnowCover')} />
</div>
@ -935,11 +1084,15 @@ export default function StuffDetail() {
<td>
<div className="flx-box">
<div className="input-wrap mr5" style={{ width: '200px' }}>
<input type="text" className="input-light" readOnly />
<input type="text" className="input-light" readOnly value={form.watch('planReqNo')} />
</div>
{objectNo.substring(0, 1) === 'T' ? (
<>
<Button className="btn-origin grey" onClick={onSearchDesignRequestPopOpen}>
{getMessage('stuff.planReqPopup.title')}
</Button>
</>
) : null}
</div>
</td>
</tr>
@ -969,6 +1122,8 @@ export default function StuffDetail() {
value={row.clCode}
id={`objectStatus${row.clCode}`}
{...register('objectStatusId')}
onChange={onRadioChange}
checked={row.clCode === selectObjectStatusId}
/>
<label htmlFor={`objectStatus${row.clCode}`}>{row.clCodeNm}</label>
</div>
@ -981,7 +1136,7 @@ export default function StuffDetail() {
<div className="select-wrap" style={{ width: '120px' }}>
<Select
{...register('objectNameOmit')}
id="ng-value-select0"
id="long-value-select0"
instanceId="long-value-select0"
className="react-select-custom"
classNamePrefix="custom"
@ -993,6 +1148,8 @@ export default function StuffDetail() {
isClearable={true}
isSearchable={false}
value={honorificCodeList.filter(function (option) {
console.log('상세 경칭코드결과:::::::::::::::', option.clCode)
console.log('상세 셋팅된 경칭코드값:::::::::::::::', selHonorificCode)
return option.clCode === selHonorificCode
})}
></Select>
@ -1021,15 +1178,21 @@ export default function StuffDetail() {
<td>
<div className="flx-box">
<div className="select-wrap mr5" style={{ width: '567px' }}>
{/* <Select
<Select
id="long-value-select1"
instanceId="long-value-select1"
className="react-select-custom"
classNamePrefix="custom"
placeholder="Select"
options={saleStoreList}
value={form.watch('saleStoreId')}
onChange={onSelectionChange}
labelField="saleStoreName"
valueField="saleStoreId"
searchBy="saleStoreName"
clearable={true}
></Select> */}
getOptionLabel={(x) => x.saleStoreName}
getOptionValue={(x) => x.saleStoreId}
isClearable={sessionState?.storeLvl === '1' ? true : false}
value={saleStoreList.filter(function (option) {
return option.saleStoreId === selOptions
})}
/>
</div>
<div className="input-wrap" style={{ width: '216px' }}>
<input type="text" className="input-light" value={form.watch('saleStoreId')} {...form.register('saleStoreId')} readOnly />
@ -1037,6 +1200,64 @@ export default function StuffDetail() {
</div>
</td>
</tr>
<tr>
<th>
<div className="flx-box">
<div className="title">{getMessage('stuff.detail.otherSaleStoreId')}</div>
<div className="tooltips">
<span>{getMessage('stuff.detail.tooltip.saleStoreId')}</span>
</div>
</div>
</th>
<td>
<div className="flx-box">
<div className="select-wrap mr5" style={{ width: '567px' }}>
<Select
id="long-value-select2"
instanceId="long-value-select2"
className="react-select-custom"
classNamePrefix="custom"
placeholder="Select"
ref={ref}
options={otherSaleStoreList}
onChange={onSelectionChange2}
getOptionLabel={(x) => x.saleStoreName}
getOptionValue={(x) => x.saleStoreId}
isDisabled={sessionState?.storeLvl === '1' && form.watch('saleStoreId') != '' ? false : true}
isClearable={sessionState?.storeLvl === '1' ? true : false}
value={otherSaleStoreList.filter(function (option) {
return option.saleStoreId === otherSelOptions
})}
/>
</div>
<div className="input-wrap" style={{ width: '216px' }}>
<input
type="text"
className="input-light"
value={form.watch('otherSaleStoreId')}
{...form.register('otherSaleStoreId')}
readOnly
/>
</div>
</div>
</td>
</tr>
<tr>
<th>
{getMessage('stuff.detail.zipNo')} <span className="important">*</span>
</th>
<td>
<div className="flx-box">
<div className="input-wrap mr5" style={{ width: '200px' }}>
<input type="text" className="input-light" disabled value={form.watch('zipNo')} />
</div>
<Button className="btn-origin grey" onClick={onSearchPostNumberPopOpen}>
{getMessage('stuff.detail.btn.addressPop')}
</Button>
<div className="guide">{getMessage('stuff.detail.btn.addressPop.guide')}</div>
</div>
</td>
</tr>
</tbody>
</table>
</div>

View File

@ -454,7 +454,7 @@
"stuff.gridHeader.address": "商品アドレス",
"stuff.gridHeader.dispCompanyName": "見積もり",
"stuff.gridHeader.receiveUser": "担当者",
"stuff.gridHeader.specDate": "仕様確認日",
"stuff.gridHeader.specificationConfirmDate": "仕様確認日",
"stuff.gridHeader.createDatetime": "登録日",
"stuff.message.periodError": "最大1年間閲覧可能.",
"stuff.addressPopup.title": "郵便番号",
@ -495,6 +495,8 @@
"stuff.detail.conType1": "全量",
"stuff.detail.remarks": "メモ",
"stuff.detail.tooltip.saleStoreId": "販売代理店または販売代理店IDを1文字以上入力してください",
"stuff.detail.tempSave.message1": "一時保存されました。商品番号を取得するには、必須項目をすべて入力してください。",
"stuff.detail.confirm.message1": "販売店情報を変更すると、設計依頼文書番号が削除されます。変更しますか?",
"stuff.planReqPopup.popTitle": "設計依頼検索",
"stuff.planReqPopup.btn1": "検索",
"stuff.planReqPopup.btn2": "初期化",

View File

@ -459,7 +459,7 @@
"stuff.gridHeader.address": "물건주소",
"stuff.gridHeader.dispCompanyName": "견적처",
"stuff.gridHeader.receiveUser": "담당자",
"stuff.gridHeader.specDate": "사양확인일",
"stuff.gridHeader.specificationConfirmDate": "사양확인일",
"stuff.gridHeader.createDatetime": "등록일",
"stuff.message.periodError": "최대1년 조회 가능합니다.",
"stuff.addressPopup.title": "우편번호",
@ -500,6 +500,8 @@
"stuff.detail.conType1": "전량",
"stuff.detail.remarks": "메모",
"stuff.detail.tooltip.saleStoreId": "판매대리점 또는 판매대리점ID를 1자 이상 입력하세요",
"stuff.detail.tempSave.message1": "임시저장 되었습니다. 물건번호를 획득하려면 필수 항목을 모두 입력해 주십시오.",
"stuff.detail.confirm.message1": "판매점 정보를 변경하면, 설계의뢰 문서번호가 삭제됩니다. 변경하시겠습니까?",
"stuff.planReqPopup.popTitle": "설계 요청 검색",
"stuff.planReqPopup.btn1": "검색",
"stuff.planReqPopup.btn2": "초기화",