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

View File

@@ -90,22 +90,12 @@ export async function getContractDetail(contNo) {
* 계약관리 삭제 * 계약관리 삭제
* @param {object} params * @param {object} params
* @property {string} params.contNo - * @property {string} params.contNo -
* @property {string} params.bizNo - * @property {string} params.fileOrd -
* @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} -
* @returns * @returns
*/ */
export async function delContAttachFile(params = {}) { export async function delContAttachFile(contNo: string,fileOrd: number ) {
try { try {
const result = await axios.delete(`/api/cont/${params.contNo}/${params.fileOrd}`) const result = await axios.delete(`/api/cont/${contNo}/${fileOrd}`)
return result return result
} catch (e) { } catch (e) {
const serverError = e.response?.data; const serverError = e.response?.data;