diff --git a/web-admin/src/components/business/ProjectSelect.vue b/web-admin/src/components/business/ProjectSelect.vue index 4ae714f8..fe680c22 100644 --- a/web-admin/src/components/business/ProjectSelect.vue +++ b/web-admin/src/components/business/ProjectSelect.vue @@ -20,7 +20,13 @@ v-for="option in displayOptions" :key="option.id" :value="option.id" - :label="team ? option.teamName : `${option.projectName} · ${option.teamName}`" + :label=" + team + ? option.teamName + : teamId + ? option.projectName + : `${option.projectName} · ${option.teamName}` + " :disabled="!filter && option.disabled" /> @@ -43,6 +49,8 @@ const props = defineProps<{ filter?: boolean team?: boolean + /** When selecting projects, keep options under this team. */ + teamId?: string modelValue?: string bizType?: BizType disabled?: boolean @@ -54,15 +62,18 @@ ready: [value: boolean] }>() const options = ref([]) - const displayOptions = computed(() => - props.team - ? [ - ...new Map( - options.value.map((option) => [option.teamId, { ...option, id: option.teamId }]) - ).values() - ] + const displayOptions = computed(() => { + if (props.team) { + return [ + ...new Map( + options.value.map((option) => [option.teamId, { ...option, id: option.teamId }]) + ).values() + ] + } + return props.teamId + ? options.value.filter((option) => option.teamId === props.teamId) : options.value - ) + }) const loading = ref(false) const error = ref(false), retry = ref(0) diff --git a/web-admin/src/views/project-management/RecordList.vue b/web-admin/src/views/project-management/RecordList.vue index 08048a4c..78b4c6f4 100644 --- a/web-admin/src/views/project-management/RecordList.vue +++ b/web-admin/src/views/project-management/RecordList.vue @@ -143,57 +143,58 @@ - + + + + + + + + - - - - ({}), - previewRows = ref([]), historyVisible = ref(false), historyRows = ref([]) const visibleColumns = computed(() => @@ -361,47 +362,54 @@ } function open(row: ProjectRecord) { selected.value = row + targetTeamId.value = '' target.value = '' reason.value = '' - previewRows.value = [] visible.value = true } - async function preview() { + function onTargetTeamChange() { + target.value = '' + } + async function commit() { + if (!targetTeamId.value) { + ElMessage.warning('请选择新项目组') + return + } if (!target.value) { - ElMessage.warning('请选择目标项目') + ElMessage.warning('请选择新项目') + return + } + if (!reason.value.trim()) { + ElMessage.warning('请填写调整原因') return } busy.value = true - const previewTarget = target.value - const previewRecord = selected.value + const commitTarget = target.value + const commitRecord = selected.value try { - const result = await previewAssignment({ + const preview = await previewAssignment({ bizType: selected.value.bizType, id: selected.value.id, projectId: target.value }) - if (selected.value === previewRecord && target.value === previewTarget && visible.value) { - previewRows.value = result.records + if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) { + return } - } finally { - busy.value = false - } - } - async function commit() { - busy.value = true - try { await saveAssignment({ bizType: selected.value.bizType, id: selected.value.id, projectId: target.value, reason: reason.value.trim(), - expectedAssignments: assignmentSnapshot(previewRows.value) + expectedAssignments: assignmentSnapshot(preview.records) }) + if (selected.value !== commitRecord || target.value !== commitTarget || !visible.value) { + return + } visible.value = false ElMessage.success('归属已调整') await load() } catch { - previewRows.value = [] + // API layer already surfaces the conflict / validation message. } finally { busy.value = false }