fix : 파일 삭제 api 오류 발생중, 백엔드 확인 요청

This commit is contained in:
Yesol Choi
2025-06-08 07:36:45 +09:00
parent 094d9ade0f
commit 12cd757357
2 changed files with 49 additions and 32 deletions

View File

@@ -5,6 +5,7 @@ import {delContAttachFile, getContractDetail, saveContract, updateContract} from
import type {iPbAtt} from "/@src/utils/types.ts";
import {useRouter} from "vue-router";
import {signStart} from "/@src/service/signDocApi.ts";
import {deletePrcsFile} from "/@src/service/priceApi.ts";
const registerFormOpen = ref(false)
@@ -114,6 +115,10 @@ function getDetailList(arg){
params.contStatCd = arg.contStatCd
params.contNo = arg.contNo
params.contAtts = arg.contAtts
// params.contAtts = arg.contAtts.map((item: any, index: any) => ({
// ...item,
// description: fileInputs.value[index]?.description || '',
// })
}
function formatMonthDate(dateStr) {
@@ -314,13 +319,35 @@ const onFileChange = (e, idx) => {
reader.readAsDataURL(file)
}
function removeFile(idx) {
pbAtts.value[idx] = null
params.contAtts[idx] = null
// function removeFile(idx, input) {
// console.log("input",input)
// pbAtts.value[idx] = null
// params.contAtts[idx] = null
// }
const removeFile = async (contNo: string, index: number, fileOrd: number) => {
notyf.dismissAll()
const confirmed = confirm('삭제하시겠습니까?')
if (!contNo) {
if (confirmed){
pbAtts.value.splice(index, 1)
console.log("index",index)
console.log("fileOrd",fileOrd)
}
} else {
if (confirmed) {
await delContAttachFile(contNo, fileOrd).then((res: string) => {
notyf.success(res)
pbAtts.value.splice(index, 1)
}).catch((err) => {
notyf.error('삭제 중 오류가 발생했습니다.')
console.error(err)
})
}
}
}
function downloadFile(file) {
console.log(file)
file.path = `https://svcm.hmsn.ink/api/cont/${file.contNo}/${file.fileOrd}`
window.open(file.path, '_blank')
return
@@ -676,29 +703,29 @@ const onChangeSign = async() => {
<td colspan="7">
<div class="file-upload-list" style="margin-top:10px;">
<div
v-for="(input, idx) in fileInputs"
:key="idx"
v-for="f in params.contAtts"
:key="f.fileOrd"
style="display: flex; align-items: center; margin-bottom: 8px;"
>
<label class="file-label" style="margin-right: 10px;">
<input
type="file"
class="file-input"
@change="(e) => onFileChange(e, idx)"
@change="(e) => onFileChange(e, f.fileOrd)"
/>
<span class="file-cta">파일선택</span>
</label>
<span style="flex:0.8; margin-right: 10px;">
{{ pbAtts[idx]?.logiFnm || params.contAtts?.[idx]?.logiFnm || '' }}
{{ pbAtts[f.fileOrd]?.logiFnm || params.contAtts?.[f.fileOrd]?.logiFnm || '' }}
</span>
<div style="flex:0.5;">
<template v-if="pbAtts[idx] || params.contAtts?.[idx]">
<template v-if="pbAtts[f.fileOrd] || params.contAtts?.[f.fileOrd]">
<VButton
v-if="params.contAtts?.[idx]"
v-if="params.contAtts?.[f.fileOrd]"
color="primary"
size="big"
style="margin-right:8px; width: 30%"
@click="downloadFile(params.contAtts[idx])"
@click="downloadFile(params.contAtts[f.fileOrd])"
>
다운로드
</VButton>
@@ -706,20 +733,20 @@ const onChangeSign = async() => {
color="danger"
size="big"
style="width: 10%"
@click="removeFile(idx)"
@click="removeFile(f.contNo, i, f.fileOrd)"
>
삭제
</VButton>
</template>
</div>
<!-- 설명/인지세 안내는 등록폼과 동일하게 -->
<span v-if="input.description != '인지세 납부확인서'" style="flex:2; color: #666;">
{{ input.description }}
</span>
<span v-if="input.description == '인지세 납부확인서'" style="flex:2; color: #666;">
{{ input.description }}
<span style="color:red">(계약금액이 1,000만원 이상일 경우 인지세 납부확인서 첨부가 필수입니다.)</span>
</span>
<!-- <span v-if="input.description != '인지세 납부확인서'" style="flex:2; color: #666;">-->
<!-- {{ input.description }}-->
<!-- </span>-->
<!-- <span v-if="input.description == '인지세 납부확인서'" style="flex:2; color: #666;">-->
<!-- {{ input.description }}-->
<!-- <span style="color:red">(계약금액이 1,000만원 이상일 경우 인지세 납부확인서 첨부가 필수입니다.)</span>-->
<!-- </span>-->
</div>
</div>
</td>

View File

@@ -90,22 +90,12 @@ export async function getContractDetail(contNo) {
* 계약관리 삭제
* @param {object} params
* @property {string} params.contNo -
* @property {string} params.bizNo -
* @property {string} params.prcsNo -
* @property {string} params.title -
* @property {string} params.compNm -
* @property {string} params.signDt -
* @property {string} params.contSdat -
* @property {string} params.contEdat -
* @property {string} params.amt -
* @property {string} params.excYn -
* @property {string} params.reason -
* @property {string} params.contAtts{fileOrd,logiFnm,data} -
* @property {string} params.fileOrd -
* @returns
*/
export async function delContAttachFile(params = {}) {
export async function delContAttachFile(contNo: string,fileOrd: number ) {
try {
const result = await axios.delete(`/api/cont/${params.contNo}/${params.fileOrd}`)
const result = await axios.delete(`/api/cont/${contNo}/${fileOrd}`)
return result
} catch (e) {
const serverError = e.response?.data;