물건저장 업데이트
This commit is contained in:
parent
70477b12f1
commit
e10bc8ba45
@ -15,12 +15,12 @@ import KO from '@/locales/ko.json'
|
||||
import JA from '@/locales/ja.json'
|
||||
import QPagination from '../common/pagination/QPagination'
|
||||
import { SessionContext } from '@/app/SessionProvider'
|
||||
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
import { QcastContext } from '@/app/QcastProvider'
|
||||
|
||||
export default function Stuff() {
|
||||
const { setIsGlobalLoading } = useContext(QcastContext)
|
||||
|
||||
const { swalFire } = useSwal()
|
||||
const resetStuffRecoil = useResetRecoilState(stuffSearchState)
|
||||
const { session } = useContext(SessionContext)
|
||||
const setAppMessageState = useSetRecoilState(appMessageStore)
|
||||
@ -41,20 +41,18 @@ export default function Stuff() {
|
||||
|
||||
//그리드 내부 복사버튼
|
||||
const copyNo = async (value) => {
|
||||
// try {
|
||||
// await navigator.clipboard.writeText(value)
|
||||
// alert(getMessage('stuff.detail.header.successCopy'))
|
||||
// } catch (error) {
|
||||
// alert(getMessage('stuff.detail.header.failCopy'))
|
||||
// }
|
||||
// Navigator clipboard api needs a secure context (https)
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
console.log('trttt')
|
||||
await navigator.clipboard
|
||||
.writeText(value)
|
||||
.then(() => {
|
||||
alert(getMessage('stuff.detail.header.successCopy'))
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.successCopy'),
|
||||
type: 'alert',
|
||||
})
|
||||
.catch(() => {
|
||||
})
|
||||
.catch((e) => {
|
||||
console.log(e)
|
||||
alert(getMessage('stuff.detail.header.failCopy'))
|
||||
})
|
||||
} else {
|
||||
@ -71,7 +69,10 @@ export default function Stuff() {
|
||||
|
||||
try {
|
||||
document.execCommand('copy')
|
||||
alert(getMessage('stuff.detail.header.successCopy'))
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.successCopy'),
|
||||
type: 'alert',
|
||||
})
|
||||
} catch (err) {
|
||||
alert(getMessage('stuff.detail.header.failCopy'))
|
||||
} finally {
|
||||
@ -122,7 +123,7 @@ export default function Stuff() {
|
||||
type="button"
|
||||
className="copy_ico"
|
||||
onClick={() => {
|
||||
copyNo(params.value)
|
||||
copyNo(params?.value)
|
||||
}}
|
||||
></button>
|
||||
</>
|
||||
|
||||
@ -1405,7 +1405,6 @@ export default function StuffDetail() {
|
||||
.then((res) => {
|
||||
setIsGlobalLoading(true)
|
||||
|
||||
// console.log('수정했어!!', managementState)
|
||||
if (res.status === 201) {
|
||||
setIsGlobalLoading(false)
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: res.data.objectNo })
|
||||
@ -1413,8 +1412,9 @@ export default function StuffDetail() {
|
||||
text: getMessage('stuff.detail.save'),
|
||||
type: 'alert',
|
||||
confirmFn: () => {
|
||||
callDetailApi(objectNo)
|
||||
// setManagementState({ ...managementState, params })
|
||||
router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
// router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`, { scroll: false })
|
||||
},
|
||||
})
|
||||
}
|
||||
@ -1426,6 +1426,51 @@ export default function StuffDetail() {
|
||||
}
|
||||
}
|
||||
|
||||
const callDetailApi = (objectNo) => {
|
||||
promiseGet({ url: `/api/object/${objectNo}/detail` }).then((res) => {
|
||||
if (res.status === 200) {
|
||||
if (res?.data?.createUser === 'T01' && session?.userId !== 'T01') {
|
||||
//createUser가 T01인데 로그인사용자가 T01이 아니면 버튼숨기기
|
||||
setShowButton('none')
|
||||
}
|
||||
if (isObjectNotEmpty(res.data)) {
|
||||
let surfaceTypeValue
|
||||
if (res.data.surfaceType === 'Ⅲ・Ⅳ') {
|
||||
surfaceTypeValue = '3'
|
||||
} else if (res.data.surfaceType === 'Ⅱ') {
|
||||
surfaceTypeValue = '2'
|
||||
}
|
||||
setManagementState({ ...res.data, surfaceTypeValue: surfaceTypeValue })
|
||||
} else {
|
||||
setManagementState({})
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.notExistObjectNo'),
|
||||
type: 'alert',
|
||||
confirmFn: () => {
|
||||
router.push('/management/stuff', { scroll: false })
|
||||
},
|
||||
})
|
||||
}
|
||||
if (isNotEmptyArray(res.data.planList)) {
|
||||
setPlanGridProps({ ...planGridProps, planGridData: res.data.planList })
|
||||
} else {
|
||||
setPlanGridProps({ ...planGridProps, planGridData: [] })
|
||||
}
|
||||
} else {
|
||||
setManagementState({})
|
||||
setPlanGridProps({ ...planGridProps, planGridData: [] })
|
||||
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.notExistObjectNo'),
|
||||
type: 'alert',
|
||||
confirmFn: () => {
|
||||
router.push('/management/stuff', { scroll: false })
|
||||
},
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// 임시저장
|
||||
const onTempSave = async () => {
|
||||
const formData = form.getValues()
|
||||
|
||||
@ -1,31 +1,26 @@
|
||||
'use client'
|
||||
|
||||
import { useContext } from 'react'
|
||||
import { useContext, useEffect } from 'react'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import dayjs from 'dayjs'
|
||||
import { GlobalDataContext } from '@/app/GlobalDataProvider'
|
||||
// import { ManagementContext } from '@/app/management/ManagementProvider'
|
||||
import { useSwal } from '@/hooks/useSwal'
|
||||
export default function StuffHeader() {
|
||||
const { getMessage } = useMessage()
|
||||
|
||||
const { swalFire } = useSwal()
|
||||
const { managementState } = useContext(GlobalDataContext)
|
||||
|
||||
//물건번호 복사
|
||||
// const copyObjectNo = async (objectNo) => {
|
||||
// await navigator.clipboard.writeText(objectNo)
|
||||
// alert(getMessage('stuff.detail.header.successCopy'))
|
||||
// try {
|
||||
// } catch (error) {
|
||||
// alert(getMessage('stuff.detail.header.failCopy'))
|
||||
// }
|
||||
// }
|
||||
|
||||
const copyObjectNo = async (objectNo) => {
|
||||
if (navigator.clipboard && window.isSecureContext) {
|
||||
await navigator.clipboard
|
||||
.writeText(objectNo)
|
||||
.then(() => {
|
||||
alert(getMessage('stuff.detail.header.successCopy'))
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.successCopy'),
|
||||
type: 'alert',
|
||||
})
|
||||
})
|
||||
.catch(() => {
|
||||
alert(getMessage('stuff.detail.header.failCopy'))
|
||||
@ -44,7 +39,10 @@ export default function StuffHeader() {
|
||||
|
||||
try {
|
||||
document.execCommand('copy')
|
||||
alert(getMessage('stuff.detail.header.successCopy'))
|
||||
swalFire({
|
||||
text: getMessage('stuff.detail.header.successCopy'),
|
||||
type: 'alert',
|
||||
})
|
||||
} catch (err) {
|
||||
alert(getMessage('stuff.detail.header.failCopy'))
|
||||
} finally {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user