물건 화면 복사 기능 관련 콘솔제거 & 버튼 추가

This commit is contained in:
basssy 2025-01-06 13:00:04 +09:00
parent db7a055e22
commit 66ea82b9a3
3 changed files with 63 additions and 14 deletions

View File

@ -50,17 +50,15 @@ export default function Stuff() {
// } // }
// Navigator clipboard api needs a secure context (https) // Navigator clipboard api needs a secure context (https)
if (navigator.clipboard && window.isSecureContext) { if (navigator.clipboard && window.isSecureContext) {
console.log('확인11', value)
await navigator.clipboard await navigator.clipboard
.writeText(value) .writeText(value)
.then(() => { .then(() => {
alert(getMessage('stuff.detail.header.successCopy')) alert(getMessage('stuff.detail.header.successCopy'))
}) })
.catch((err) => { .catch(() => {
alert(getMessage('stuff.detail.header.failCopy')) alert(getMessage('stuff.detail.header.failCopy'))
}) })
} else { } else {
console.log('확인22', value)
// Use the 'out of viewport hidden text area' trick // Use the 'out of viewport hidden text area' trick
const textArea = document.createElement('textArea') const textArea = document.createElement('textArea')
textArea.value = value textArea.value = value
@ -73,7 +71,6 @@ export default function Stuff() {
textArea.select() textArea.select()
try { try {
console.log('deprecated::document.execCommand(`copy`)', document.execCommand('copy'))
document.execCommand('copy') document.execCommand('copy')
alert(getMessage('stuff.detail.header.successCopy')) alert(getMessage('stuff.detail.header.successCopy'))
} catch (err) { } catch (err) {

View File

@ -1449,15 +1449,32 @@ export default function StuffDetail() {
</components.NoOptionsMessage> </components.NoOptionsMessage>
) )
} }
return ( return (
<> <>
{(editMode === 'NEW' && ( {(editMode === 'NEW' && (
<form onSubmit={handleSubmit(onValid)}> <form onSubmit={handleSubmit(onValid)}>
<div className="sub-table-box"> <div className="sub-table-box">
<div className="promise-gudie"> <div className="promise-title-wrap">
<span className="important">*</span> <div className="promise-gudie">
{getMessage('stuff.detail.required')} <span className="important">*</span>
{getMessage('stuff.detail.required')}
</div>
<div className="left-unit-box">
{!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}>
{getMessage('stuff.detail.btn.tempSave')}
</Button>
) : (
<Button type="submit" className="btn-origin navy mr5">
{getMessage('stuff.detail.btn.save')}
</Button>
)}
<Link href="/management/stuff" scroll={false}>
<button type="button" className="btn-origin grey">
{getMessage('stuff.detail.btn.moveList')}
</button>
</Link>
</div>
</div> </div>
<div className="infomation-table"> <div className="infomation-table">
<table> <table>
@ -1952,8 +1969,46 @@ export default function StuffDetail() {
<> <>
<form onSubmit={handleSubmit(onValid)}> <form onSubmit={handleSubmit(onValid)}>
<div className="sub-table-box"> <div className="sub-table-box">
<div className="promise-gudie"> <div className="promise-title-wrap">
<span className="important">*</span> {getMessage('stuff.detail.required')} <div className="promise-gudie">
<span className="important">*</span> {getMessage('stuff.detail.required')}
</div>
{managementState?.tempFlg === '0' ? (
<>
<div className="left-unit-box">
<Link href="/management/stuff" scroll={false}>
<button type="button" className="btn-origin grey mr5">
{getMessage('stuff.detail.btn.moveList')}
</button>
</Link>
<Button type="submit" className="btn-origin navy mr5">
{getMessage('stuff.detail.btn.save')}
</Button>
<Button type="button" className="btn-origin grey" onPress={onDelete}>
{getMessage('stuff.detail.btn.delete')}
</Button>
</div>
</>
) : (
<>
<div className="left-unit-box">
{!isFormValid ? (
<Button className="btn-origin grey mr5" onPress={onTempSave}>
{getMessage('stuff.detail.btn.tempSave')}
</Button>
) : (
<Button type="submit" className="btn-origin navy mr5">
{getMessage('stuff.detail.btn.save')}
</Button>
)}
<Link href="/management/stuff" scroll={false}>
<button type="button" className="btn-origin grey">
{getMessage('stuff.detail.btn.moveList')}
</button>
</Link>
</div>
</>
)}
</div> </div>
<div className="infomation-wrap"> <div className="infomation-wrap">
<div className="infomation-table"> <div className="infomation-table">

View File

@ -22,17 +22,15 @@ export default function StuffHeader() {
const copyObjectNo = async (objectNo) => { const copyObjectNo = async (objectNo) => {
if (navigator.clipboard && window.isSecureContext) { if (navigator.clipboard && window.isSecureContext) {
console.log('확인11', objectNo)
await navigator.clipboard await navigator.clipboard
.writeText(objectNo) .writeText(objectNo)
.then(() => { .then(() => {
alert(getMessage('stuff.detail.header.successCopy')) alert(getMessage('stuff.detail.header.successCopy'))
}) })
.catch((err) => { .catch(() => {
alert(getMessage('stuff.detail.header.failCopy')) alert(getMessage('stuff.detail.header.failCopy'))
}) })
} else { } else {
console.log('확인22', objectNo)
// Use the 'out of viewport hidden text area' trick // Use the 'out of viewport hidden text area' trick
const textArea = document.createElement('textArea') const textArea = document.createElement('textArea')
textArea.value = objectNo textArea.value = objectNo
@ -45,7 +43,6 @@ export default function StuffHeader() {
textArea.select() textArea.select()
try { try {
console.log('deprecated::document.execCommand(`copy`)', document.execCommand('copy'))
document.execCommand('copy') document.execCommand('copy')
alert(getMessage('stuff.detail.header.successCopy')) alert(getMessage('stuff.detail.header.successCopy'))
} catch (err) { } catch (err) {