-
+
@@ -22,11 +30,20 @@
-
+ class="w-full flex focus:outline-none"
+ ref="inputRef" />
+
{{ label.labelName }}
+
+ {{ editValue.labelName.length }}/10
+
@@ -41,7 +47,10 @@ import CommonIcons from '../common/CommonIcons.vue'
const dePartments = ref
([])
const dropdownOpen = ref(false)
const emit = defineEmits(['update:modelValue'])
-const { modelValue, isInvalidate } = defineProps<{ modelValue: number; isInvalidate: string }>()
+const { modelValue, isInvalidate } = defineProps<{
+ modelValue: DepartmentType | null
+ isInvalidate: string
+}>()
const isInvalidateState = computed(() => isInvalidate)
const toggleDropdown = () => {
@@ -49,11 +58,14 @@ const toggleDropdown = () => {
}
const selectOption = (option: DepartmentType) => {
- emit('update:modelValue', option.departmentId)
+ emit('update:modelValue', option)
dropdownOpen.value = false
}
onMounted(async () => {
dePartments.value = await getDepartmentsAdmin()
+ if (dePartments.value.length > 0) {
+ emit('update:modelValue', dePartments.value[0])
+ }
})
diff --git a/src/components/user-manage/UserRegistration.vue b/src/components/user-manage/UserRegistration.vue
index 008b579..f6c3f8a 100644
--- a/src/components/user-manage/UserRegistration.vue
+++ b/src/components/user-manage/UserRegistration.vue
@@ -1,16 +1,13 @@
-
- 새로운 회원이 추가되었습니다
-
-
+
+
+
+
+ 새로운 회원이 추가되었습니다
+
@@ -71,6 +74,9 @@ import DepartmentDropDown from './DepartmentDropDown.vue'
const router = useRouter()
+const usernameRegex = /^[a-z]{3,10}\.[a-z]{1,5}$/
+const emailRegex = /^@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/
+
const isModalVisible = ref(false)
const userRegistrationForm = ref(INITIAL_USER_REGISTRATION)
const isInvalidate = ref('')
@@ -86,8 +92,21 @@ const handleCancel = () => {
router.back()
}
-const usernameRegex = /^[a-z]{3,10}\.[a-z]{1,5}$/
-const emailRegex = /^@[a-zA-Z0-9-]+(?:\.[a-zA-Z0-9-]+)+$/
+const filteredRoleKeys = computed(() => {
+ if (userRegistrationForm.value.department?.isManager) {
+ return RoleKeys
+ }
+ return RoleKeys.filter(role => role !== '담당자')
+})
+
+watch(
+ () => userRegistrationForm.value.department?.isManager,
+ newValue => {
+ if (!newValue && userRegistrationForm.value.role === '담당자') {
+ userRegistrationForm.value.role = '사용자'
+ }
+ }
+)
const handleSubmit = async () => {
try {
@@ -103,12 +122,19 @@ const handleSubmit = async () => {
isInvalidate.value = 'wrongEmail'
return
}
+ if (!userRegistrationForm.value.department?.departmentId) {
+ isInvalidate.value = 'depertmentEmpty'
+ return
+ }
+ const { department, ...restForm } = userRegistrationForm.value
const formData = {
- ...userRegistrationForm.value,
+ ...restForm,
+ departmentId: department?.departmentId,
isReviewer: isManager.value ? userRegistrationForm.value.isReviewer : false,
role: RoleTypeMapping[userRegistrationForm.value.role],
email: userRegistrationForm.value.nickname + userRegistrationForm.value.email
}
+
await addMemberAdmin(formData)
isModalVisible.value = true
} catch (error) {
diff --git a/src/components/user-manage/UserUpdate.vue b/src/components/user-manage/UserUpdate.vue
index db997b5..9dcc803 100644
--- a/src/components/user-manage/UserUpdate.vue
+++ b/src/components/user-manage/UserUpdate.vue
@@ -1,16 +1,13 @@
-
- 회원정보가 수정되었습니다
-
-
+
+
+
+
+ 회원정보가 수정되었습니다
+
+ (isModalVisible = '')">
+ 수정이 실패하였습니다
+ 잔여 작업이 남아있어 수정이 불가합니다
+