mirror of
https://git.hmsn.ink/kospo/svcm/oa.git
synced 2026-03-19 21:15:11 +09:00
fix: 수정기능 로직 변경
func: 첨부파일 삭제기능 추가 - 테스트필요 issue: 예외사유 여부와 관계없이 에러발생 -> 500 Error
This commit is contained in:
@@ -1,7 +1,7 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
|
|
||||||
import axios from 'axios'
|
import axios from 'axios'
|
||||||
import {getContractDetail, saveContract} from "/@src/service/contractApi.ts";
|
import {delContAttachFile, getContractDetail, saveContract, updateContract} from "/@src/service/contractApi.ts";
|
||||||
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";
|
||||||
@@ -76,9 +76,7 @@ params.modalColumn = [
|
|||||||
{ key: 'regNm', label: '선택' },
|
{ key: 'regNm', label: '선택' },
|
||||||
]
|
]
|
||||||
|
|
||||||
params.contAtts = [
|
params.contAtts = []
|
||||||
{ prcsNo : '', bizNo : '' ,fileOrd : 0 ,logiFnm : '' ,physFnm : '',size : 0 ,data : '' ,path : '' },
|
|
||||||
]
|
|
||||||
|
|
||||||
const data = reactive({
|
const data = reactive({
|
||||||
contractData: [],
|
contractData: [],
|
||||||
@@ -209,14 +207,49 @@ const fileInputs = ref([
|
|||||||
{ file: null, description: '인지세 납부확인서' },
|
{ file: null, description: '인지세 납부확인서' },
|
||||||
])
|
])
|
||||||
|
|
||||||
const saveContOne = async () => {
|
const updateContOne = async () => {
|
||||||
let res = null
|
let res = null
|
||||||
try{
|
try{
|
||||||
loading.value = true
|
loading.value = true
|
||||||
|
|
||||||
|
const changeFileOrd = []
|
||||||
|
const conAtts = fileInputs.value.map((input, idx) => {
|
||||||
|
// console.log(fileInputs)
|
||||||
|
if(pbAtts.value[idx]) {
|
||||||
|
// console.log('pbAtts.value[idx]', pbAtts.value[idx])
|
||||||
|
changeFileOrd.push(idx)
|
||||||
|
return pbAtts.value[idx]
|
||||||
|
} else if(params.contAtts[idx]) {
|
||||||
|
// console.log('params.contAtts[idx]', params.contAtts[idx])
|
||||||
|
return params.contAtts[idx]
|
||||||
|
} else {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
})
|
||||||
|
console.log('conAtts', conAtts)
|
||||||
|
|
||||||
|
const paramsCont ={
|
||||||
|
contNo: params.contNo || '',
|
||||||
|
bizNo: completedPriceDataParams.bizNo,
|
||||||
|
prcsNo: completedPriceDataParams.prcsNo || '',
|
||||||
|
compNm: completedPriceDataParams.compNm,
|
||||||
|
contAmt: completedPriceDataParams.contAmt,
|
||||||
|
cateCd: priceSearchCheckBoxStatus.value ? selectedCode.value : completedPriceDataParams.cateCd,
|
||||||
|
title: completedPriceDataParams.title,
|
||||||
|
signDt: formatMonthDate(completedPriceDataParams.signDt),
|
||||||
|
contSdat: formatMonthDate(completedPriceDataParams.contSdat),
|
||||||
|
contEdat: formatMonthDate(completedPriceDataParams.contEdat),
|
||||||
|
reason: completedPriceDataParams.reason || '',
|
||||||
|
excYn: priceSearchCheckBoxStatus.value, // 가격조사 예외여부 확인필요
|
||||||
|
contAtts: conAtts,
|
||||||
|
}
|
||||||
|
console.log(pbAtts)
|
||||||
|
console.log(paramsCont.contAtts)
|
||||||
|
|
||||||
const amt = Number(String(completedPriceDataParams.contAmt).replace(/[^0-9]/g, ''))
|
const amt = Number(String(completedPriceDataParams.contAmt).replace(/[^0-9]/g, ''))
|
||||||
if (amt >= 10000000) {
|
if (amt >= 10000000) {
|
||||||
const injiFile = pbAtts.value[6]
|
const injiIdx = fileInputs.value.findIndex(input => input.description === '인지세 납부확인서');
|
||||||
|
const injiFile = injiIdx !== -1 ? paramsCont.contAtts[injiIdx] : null;
|
||||||
if (!injiFile || !injiFile.logiFnm) {
|
if (!injiFile || !injiFile.logiFnm) {
|
||||||
notyf.error('계약금액이 1,000만원 이상일 경우 인지세 납부확인서 첨부가 필수입니다.')
|
notyf.error('계약금액이 1,000만원 이상일 경우 인지세 납부확인서 첨부가 필수입니다.')
|
||||||
loading.value = false
|
loading.value = false
|
||||||
@@ -224,22 +257,30 @@ const saveContOne = async () => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const paramsCont ={
|
console.log('changeFileOrd', changeFileOrd)
|
||||||
prcsNo: completedPriceDataParams.prcsNo,
|
|
||||||
bizNo: completedPriceDataParams.bizNo,
|
// 첨부파일 삭제
|
||||||
cateCd: priceSearchCheckBoxStatus.value ? selectedCode.value : completedPriceDataParams.cateCd,
|
for(const idx of changeFileOrd) {
|
||||||
compNm: completedPriceDataParams.compNm,
|
const file = params.contAtts[idx]
|
||||||
title: completedPriceDataParams.title,
|
if(file){
|
||||||
contSdat: formatMonthDate(completedPriceDataParams.contSdat),
|
const delParam = [{
|
||||||
contEdat: formatMonthDate(completedPriceDataParams.contEdat),
|
contNo: file.contNo,
|
||||||
contAmt: completedPriceDataParams.contAmt,
|
fileOrd: file.fileOrd,
|
||||||
signDt: formatMonthDate(completedPriceDataParams.signDt),
|
}]
|
||||||
reason: completedPriceDataParams.reason,
|
console.log('delParam',delParam)
|
||||||
excYn: priceSearchCheckBoxStatus.value, // 가격조사 예외여부 확인필요
|
// await delContAttachFile(file)
|
||||||
contAtts: params.contAtts,
|
}
|
||||||
}
|
}
|
||||||
console.log(pbAtts)
|
|
||||||
res = await saveContract(paramsCont)
|
// 기존 첨부파일 전체 삭제
|
||||||
|
// for (const file of params.contAtts) {
|
||||||
|
// if (file && file.fileOrd !== undefined) {
|
||||||
|
// await delContAttachFile(file) // 서버 파일 삭제 API 호출
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
res = await updateContract(paramsCont)
|
||||||
|
|
||||||
if(res.request.status == '200'){
|
if(res.request.status == '200'){
|
||||||
notyf.primary('등록 되었습니다.')
|
notyf.primary('등록 되었습니다.')
|
||||||
@@ -254,13 +295,6 @@ const saveContOne = async () => {
|
|||||||
|
|
||||||
const pbAtts = ref<iPbAtt[]>(params.contAtts)
|
const pbAtts = ref<iPbAtt[]>(params.contAtts)
|
||||||
|
|
||||||
watch(
|
|
||||||
() => params.contAtts,
|
|
||||||
(newContAtts) => {
|
|
||||||
pbAtts.value = newContAtts.map(() => null)
|
|
||||||
},
|
|
||||||
{ immediate: true, deep: true }
|
|
||||||
)
|
|
||||||
const onFileChange = (e, idx) => {
|
const onFileChange = (e, idx) => {
|
||||||
const file = e.target.files[0]
|
const file = e.target.files[0]
|
||||||
if (!file) return
|
if (!file) return
|
||||||
@@ -268,15 +302,14 @@ const onFileChange = (e, idx) => {
|
|||||||
reader.onload = () => {
|
reader.onload = () => {
|
||||||
const result = reader.result
|
const result = reader.result
|
||||||
const pbAtt = {
|
const pbAtt = {
|
||||||
prcsNo: completedPriceDataParams.prcsNo,
|
contNo: completedPriceDataParams.contNo,
|
||||||
|
fileOrd: idx + 1,
|
||||||
logiFnm: file.name,
|
logiFnm: file.name,
|
||||||
size: file.size,
|
size: file.size,
|
||||||
data: result.split(',')[1],
|
data: result.split(',')[1],
|
||||||
}
|
}
|
||||||
// 인덱스별로 파일 저장
|
// 인덱스별로 파일 저장
|
||||||
pbAtts.value[idx] = pbAtt
|
pbAtts.value[idx] = pbAtt
|
||||||
console.log(pbAtts)
|
|
||||||
console.log(pbAtts.value[idx].logiFnm)
|
|
||||||
}
|
}
|
||||||
reader.readAsDataURL(file)
|
reader.readAsDataURL(file)
|
||||||
}
|
}
|
||||||
@@ -695,7 +728,7 @@ const onChangeSign = async() => {
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div class="bottom-button">
|
<div class="bottom-button">
|
||||||
<VButton @click="saveContOne">수 정</VButton>
|
<VButton @click="updateContOne">수 정</VButton>
|
||||||
<VButton v-if="params.contStatCd == '0000'" @click="onChangeSign">전자 결재(등록)</VButton>
|
<VButton v-if="params.contStatCd == '0000'" @click="onChangeSign">전자 결재(등록)</VButton>
|
||||||
<!-- todo 전자결재 url 태우기-->
|
<!-- todo 전자결재 url 태우기-->
|
||||||
<VButton @click="routerMove">취 소</VButton>
|
<VButton @click="routerMove">취 소</VButton>
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ export async function updateContract(params = {}) {
|
|||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
export async function saveContract(params = {}) {
|
export async function saveContract(params = {}) {
|
||||||
console.log(params)
|
|
||||||
try {
|
try {
|
||||||
const result = await axios.post(`/api/cont`,params)
|
const result = await axios.post(`/api/cont`,params)
|
||||||
return result
|
return result
|
||||||
@@ -87,6 +86,41 @@ 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} -
|
||||||
|
* @returns
|
||||||
|
*/
|
||||||
|
export async function delContAttachFile(params = {}) {
|
||||||
|
try {
|
||||||
|
const result = await axios.delete(`/api/cont/${params.contNo}/${params.fileOrd}`)
|
||||||
|
return result
|
||||||
|
} catch (e) {
|
||||||
|
const serverError = e.response?.data;
|
||||||
|
|
||||||
|
const message = typeof serverError?.body === 'string'
|
||||||
|
? serverError.body
|
||||||
|
: 'Unknown error occurred';
|
||||||
|
|
||||||
|
const error = new Error(message); // ✅ 반드시 string만 넣기! 아니면 객체가 문자열로 나옴
|
||||||
|
error.code = serverError?.code;
|
||||||
|
error.errTime = serverError?.errTime;
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 계약관리 조회(페이징)
|
* 계약관리 조회(페이징)
|
||||||
* @property {string} params.page - 페이지
|
* @property {string} params.page - 페이지
|
||||||
|
|||||||
Reference in New Issue
Block a user