diff --git a/src/components/UserSelector/index.vue b/src/components/UserSelector/index.vue index c7f19f6..d1675d6 100644 --- a/src/components/UserSelector/index.vue +++ b/src/components/UserSelector/index.vue @@ -2,65 +2,94 @@ - - - - - - - - - - - - - - @@ -69,7 +98,7 @@ diff --git a/src/views/marketing/UserVoucher.vue b/src/views/marketing/UserVoucher.vue index 06f7cc6..2ed71fe 100644 --- a/src/views/marketing/UserVoucher.vue +++ b/src/views/marketing/UserVoucher.vue @@ -177,30 +177,36 @@ - +
-
- - {{ getSelectedUserName() }} - -
- - - {{ addForm.user_id ? '重新选择用户' : '选择用户' }} + + + + 清除
- + { ElMessage.warning('请选择一个用户') return } - addForm.user_id = user.UserId + addForm.user_id = user.user_id // 将选中的用户添加到 userOptions 中(如果不存在) - if (!userOptions.value.find(u => u.UserId === user.UserId)) { + if (!userOptions.value.find(u => u.user_id === user.user_id)) { userOptions.value.push(user) } userSelectorVisible.value = false @@ -668,8 +674,9 @@ const clearSelectedUser = () => { // 获取选中用户的显示名称 const getSelectedUserName = () => { - const user = userOptions.value.find(u => u.UserId === addForm.user_id) - return user ? `${user.UserName} (ID: ${user.UserId})` : `用户ID: ${addForm.user_id}` + if (!addForm.user_id) return '' + const user = userOptions.value.find(u => u.user_id === addForm.user_id) + return user ? `${user.user_name} (ID: ${user.user_id})` : `用户ID: ${addForm.user_id}` } // 添加用户代金券 @@ -940,5 +947,21 @@ onMounted(() => { margin-top: 24px; justify-content: flex-end; } + +/* 用户选择器样式 */ +.user-selector-wrapper { + display: flex; + align-items: center; + gap: 8px; + width: 100%; +} + +.user-selector-wrapper .el-input { + flex: 1; +} + +.user-selector-wrapper .clear-btn { + flex-shrink: 0; +}