fix : type 에러 제거 , 가격조사 등록과 수정 VUser 컴포넌트 분리하여 사용

등록 결재선 삭제 이슈 -> 변화감지를 위해서는 key 값이 꼭 있어야 됨.(이동, 삭제)
This commit is contained in:
Yesol Choi
2025-06-06 17:40:00 +09:00
parent acf86a83be
commit d1b65d85fa
5 changed files with 89 additions and 110 deletions

View File

@@ -8,19 +8,6 @@ const dataUser = reactive({
userSession: null, userSession: null,
}) })
// onBeforeMount(() => {
// dataUser.userSession = userSession.user.data
// const sessioinData = [{
// gubunCd: '0000', //구분
// gubunNm: '입안',
// deptNm: dataUser.userSession.dept.deptNm,
// sabun: dataUser.userSession.sabun,
// name: dataUser.userSession.name,
// attendCd: '', // 비고
//
// }]
// model.value = sessioinData
// })
const initiator = ref<Person | null>(null) const initiator = ref<Person | null>(null)
const approvers = ref<Person[]>([]) const approvers = ref<Person[]>([])
@@ -69,27 +56,6 @@ const onKeyup = async (e: any) => {
const res = await getUserList({params:{name : e.target.value}}) const res = await getUserList({params:{name : e.target.value}})
if (res.length > 0) { if (res.length > 0) {
// res.forEach(u => { 2명으로 제한 로직 풀기 25.05.29
// if (model.value?.length > 0) {
// const ignore = model.value.reduce((a: Person, b: Person) => {
// console.log("aaaaa",a.sabun)
// console.log("bbbbbb",b.sabun)
// return a.sabun + '|' + b.sabun
// })
//
// if (typeof ignore !== 'object') {
// if (ignore.includes(u.sabun)) {
// console.log("ignore 처리",u.sabun)
// u['disabled'] = true
// }
// } else {
// if (ignore.sabun.includes(u.sabun)) {
// console.log("ignore 처리222",u.sabun)
// u['disabled'] = true
// }
// }
// }
// })
tagsOptions.value = res tagsOptions.value = res
} }
} catch (e) { } catch (e) {

View File

@@ -1,40 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { type Person } from '/@src/utils/types' import { type Person } from '/@src/utils/types'
import { getUserList } from '/src/service/UserApi' import { getUserList } from '/@src/service/UserApi'
const model = defineModel<Person[]>()
const userSession = useUserSession()
const dataUser = reactive({
userSession: null,
})
// onBeforeMount(() => {
// dataUser.userSession = userSession.user.data
// const sessioinData = [{
// gubunCd: '0000', //구분
// gubunNm: '입안',
// deptNm: dataUser.userSession.dept.deptNm,
// sabun: dataUser.userSession.sabun,
// name: dataUser.userSession.name,
// attendCd: '', // 비고
//
// }]
// model.value = sessioinData
// })
const initiator = ref<Person | null>(null)
onBeforeMount(() => {
dataUser.userSession = userSession.user.data
initiator.value = {
gubunCd: '0000',
gubunNm: '입안',
deptNm: dataUser.userSession.dept.deptNm,
sabun: dataUser.userSession.sabun,
name: dataUser.userSession.name,
attendCd: '',
}
})
const props = defineProps({ const props = defineProps({
label: { label: {
@@ -58,8 +24,7 @@ export interface VUserEmits {
} }
const emits = defineEmits<VUserEmits>() const emits = defineEmits<VUserEmits>()
const tagsOptions = ref([]) const tagsOptions = ref([])
const approvers = ref<Person[]>([])
const approvers = ref()
watch(() => props.modelValue, (newVal) => { watch(() => props.modelValue, (newVal) => {
if (newVal.length > 0) { if (newVal.length > 0) {

View File

@@ -6,7 +6,7 @@ import {formatBizNum,formatDatefromString} from "/@src/utils/common/comfunc.ts";
const notyf = useNotyf() const notyf = useNotyf()
const showTable = ref(false) const showTable = ref(false)
const detailActionsOpen = ref(false) const detailActionsOpen = ref(false)
const apprLine = defineModel<Person[]>() const apprLine = ref<Person[]>([])
const today = new Date() const today = new Date()
const loading = ref(false) const loading = ref(false)
//포커스 설정 변수 정리 //포커스 설정 변수 정리
@@ -38,7 +38,7 @@ const params = reactive({
{ key: 'deptNm', label: '부서' }, { key: 'deptNm', label: '부서' },
{ key: 'sabun', label: '사번' }, { key: 'sabun', label: '사번' },
{ key: 'name', label: '이름' }, { key: 'name', label: '이름' },
{ key: 'attendCd', label: '비고' }, { key: 'attendCd', label: '근태' },
{ key: 'actions', label: '동작'} { key: 'actions', label: '동작'}
], ],
priceData:[], priceData:[],
@@ -82,26 +82,38 @@ const validation = () => {
return false return false
} }
if(params.prcsBizs==[]){ const resultGu = apprLine.value.filter((item,index)=> index != 0 && !item.gubunCd)
notyf.error("견적요청을 입력해주세요")
prcsBizsRef.value.focus() if(resultGu.length > 0){
notyf.error("결재선 구분값을 입력해주세요")
return false return false
} }
if(apprLine.value.length < 2){ if(apprLine.value.length <= 2){
notyf.error("결재선은 두 명이상 입력해주세요.") console.log("여기서 2명이상인지 체크")
notyf.error("결재선은 본인 외 2명이상 필수입니다.")
return false
}
const result = apprLine.value.filter((item)=> item.gubunCd === '0200' )
if(result.length > 1){
notyf.error("결재는 한 명입니다.")
return false
}
const resultLastItem = apprLine.value[apprLine.value.length-1].gubunCd
if(resultLastItem != '0200'){
notyf.error("결재선의 마지막은 결재자이어야 함")
return false return false
} }
return true return true
} }
const savePriceOne = async () => { const savePriceOne = async () => {
let res = null let res = null
try{ try{
loading.value = true loading.value = true
// if (!validation()) { if (validation()){
// return;
// }
const paramsPrice ={ const paramsPrice ={
cateCd : params.cateSelect, cateCd : params.cateSelect,
title: generalParams.title, title: generalParams.title,
@@ -124,6 +136,7 @@ const savePriceOne = async () => {
notyf.primary('등록 되었습니다.') notyf.primary('등록 되었습니다.')
router.push({path: '/app/priceManagement'}) router.push({path: '/app/priceManagement'})
} }
}
}catch(e){ }catch(e){
notyf.error(e.message) notyf.error(e.message)
}finally { }finally {
@@ -223,6 +236,29 @@ function onInput(row, column){
row[column.key] = formatBizNum(raw) // 실시간 포맷 적용 row[column.key] = formatBizNum(raw) // 실시간 포맷 적용
} }
} }
const moveUp = (index: number) => {
if (index <= 0) return
let temp = apprLine.value[index]
apprLine.value[index] = apprLine.value[index - 1]
apprLine.value[index - 1] = temp
}
const moveDown = (index: number) => {
if (index >= apprLine.value.length - 1) return
let temp = apprLine.value[index]
apprLine.value[index] = apprLine.value[index + 1]
apprLine.value[index + 1] = temp
}
const onPriceDelete = (index: number) => {
if(apprLine.value.length-1 !== params.felxColumn.length
|| (params.felxColumn.length == 6 && apprLine.value.length-1 == params.felxColumn.length))
{
apprLine.value.splice(index, 1)
}
}
</script> </script>
<template> <template>
@@ -513,6 +549,7 @@ function onInput(row, column){
</VLabel> </VLabel>
</VField> </VField>
<ComVFlexTable <ComVFlexTable
:key="apprLine.map(item => item.sabun).join(',')"
:data="apprLine" :data="apprLine"
:columns="params.felxColumn" :columns="params.felxColumn"
:separators="true" :separators="true"
@@ -521,16 +558,21 @@ function onInput(row, column){
<template #body-cell="{ row, column, index, value }"> <template #body-cell="{ row, column, index, value }">
<!-- : 특정 컬럼이면 input, 아니면 그냥 출력 --> <!-- : 특정 컬럼이면 input, 아니면 그냥 출력 -->
<div> <div>
<!-- <span v-if="column.key=='gubunCd' && index == 0" class="column">--> <span v-if="(index==0 && column.key != 'gubunCd' && column.key != 'attendCd')" class="column">
<!-- {{row.gubunNm}}--> {{value}}
<!-- </span>--> </span>
<span v-if="column.key=='gubunCd'" class="column"> <span v-else-if="(index==0 && column.key == 'gubunCd')" class="column">
{{"입안"}}
</span>
<span v-else-if="(index==0 && column.key == 'attendCd')" class="column">
{{"재중"}}
</span>
<span v-else-if="column.key=='gubunCd'" class="column">
<VField class="pr-1"> <VField class="pr-1">
<VCodeSelect <VCodeSelect
cd_grp=7 cd_grp=7
v-model="row.gubunCd" v-model="row.gubunCd"
/> />
<!-- :disabled="index === 0"-->
</VField> </VField>
</span> </span>
<span v-else-if="column.key=='attendCd' && index != 0" class="column"> <span v-else-if="column.key=='attendCd' && index != 0" class="column">
@@ -541,8 +583,11 @@ function onInput(row, column){
v-model="row.attendCd"/> v-model="row.attendCd"/>
</VField> </VField>
</span> </span>
<span v-else-if="column.key=='actions'" class="lnil lnil-close" <span v-else-if="column.key === 'actions'" class="flex gap-1">
@click="onPayDelete(index)"/> <VCustomButton v-if="index != 1" @click="moveUp(index)" icon="lucide:arrow-up" />
<VCustomButton @click="moveDown(index)" icon="lucide:arrow-down" />
<VCustomButton @click="onPriceDelete(index)">{{"삭제"}}</VCustomButton>
</span>
<span v-else>{{value}}</span> <span v-else>{{value}}</span>
</div> </div>
</template> </template>

View File

@@ -114,12 +114,11 @@ const validation = () => {
const resultGu = apprLine.value.filter((item,index)=> index != 0 && !item.gubunCd) const resultGu = apprLine.value.filter((item,index)=> index != 0 && !item.gubunCd)
if(resultGu.length > 0){ if(resultGu.length > 0){
console.log("resultGu",resultGu)
notyf.error("결재선 구분값을 입력해주세요") notyf.error("결재선 구분값을 입력해주세요")
return false return false
} }
if(apprLine.value.length < 2){ if(apprLine.value.length <= 2){
notyf.error("결재선은 본인 외 2명이상 필수입니다.") notyf.error("결재선은 본인 외 2명이상 필수입니다.")
return false return false
} }
@@ -210,6 +209,7 @@ const onDelete = (index: number) => {
if(params.prcsBizs.length-1 !== params.prcsBizsColumn.length if(params.prcsBizs.length-1 !== params.prcsBizsColumn.length
|| (params.prcsBizsColumn.length == 4 && params.prcsBizs.length-1 == params.prcsBizsColumn.length)) || (params.prcsBizsColumn.length == 4 && params.prcsBizs.length-1 == params.prcsBizsColumn.length))
{ {
params.prcsBizs.splice(index, 1) params.prcsBizs.splice(index, 1)
} }
} }
@@ -239,6 +239,9 @@ const onPriceDelete = (index: number) => {
if(apprLine.value.length-1 !== params.felxColumn.length if(apprLine.value.length-1 !== params.felxColumn.length
|| (params.felxColumn.length == 8 && apprLine.value.length-1 == params.felxColumn.length)) || (params.felxColumn.length == 8 && apprLine.value.length-1 == params.felxColumn.length))
{ {
console.log("index 삭제",index)
console.log("params.felxColumn.length",params.felxColumn.length)
console.log("params.felxColumn.length",apprLine.value.length)
apprLine.value.splice(index, 1) apprLine.value.splice(index, 1)
} }
} }

View File

@@ -13,7 +13,7 @@ export type Person = {
attend_nm: string attend_nm: string
attend_sta_ymd: string attend_sta_ymd: string
attend_end_ymd: string attend_end_ymd: string
gubun_cd: string gubunCd: string
} }
export type SapPerson = { export type SapPerson = {