diff --git a/frontend/src/components/BatchDisposalDialog.vue b/frontend/src/components/BatchDisposalDialog.vue index 7cc30a1..185f7f1 100644 --- a/frontend/src/components/BatchDisposalDialog.vue +++ b/frontend/src/components/BatchDisposalDialog.vue @@ -59,18 +59,8 @@
-
- -
+
+

不可申请 {{ blockedCandidates.length }} 项

-
- - -
+ 全选 +
@@ -279,7 +277,7 @@ const selectedIds = ref([]) const expandedCodes = ref(new Set()) const previewScope = ref<'eligible' | 'blocked'>('eligible') const previewPage = ref(1) -const previewPageSize = 8 +const previewPageSize = 12 const reason = ref('') const method = ref('报废') const notes = ref('') @@ -307,10 +305,6 @@ const autoReturnCandidates = computed(() => (preview.value?.candidates || []).fi )) const eligibleCandidates = computed(() => (preview.value?.candidates || []).filter(canApply)) const blockedCandidates = computed(() => (preview.value?.candidates || []).filter((candidate) => !canApply(candidate))) -const standaloneCandidates = computed(() => eligibleCandidates.value.filter((candidate) => - candidate.items.length === 1 && !candidate.auto_return_token -)) -const showBulkActions = computed(() => previewScope.value === 'eligible' && eligibleCandidates.value.length > previewPageSize) const visibleCandidates = computed(() => previewScope.value === 'eligible' ? eligibleCandidates.value : blockedCandidates.value) const previewPageCount = computed(() => Math.max(1, Math.ceil(visibleCandidates.value.length / previewPageSize))) const pageCandidates = computed(() => { @@ -323,6 +317,8 @@ const selectedCandidates = computed(() => { .filter((candidate) => selected.has(candidate.equipment_id)) .map((candidate) => [candidate.equipment_id, candidate])).values()) }) +const allEligibleSelected = computed(() => eligibleCandidates.value.length > 0 && + selectedCandidates.value.length === eligibleCandidates.value.length) const selectedQuantity = computed(() => { const quantities = selectedCandidates.value.flatMap((candidate) => candidate.items.map((item) => item.total_quantity)) return quantities.every((quantity) => quantity !== undefined) @@ -348,6 +344,13 @@ const changeAutoReturn = (event: Event) => { previewPage.value = 1 } +const changeAllEligible = (event: Event) => { + if (busy.value) return + selectedIds.value = (event.currentTarget as HTMLInputElement).checked + ? eligibleCandidates.value.map((candidate) => candidate.equipment_id) + : [] +} + const changePreviewPage = (page: number) => { previewPage.value = page void nextTick(() => { @@ -370,13 +373,6 @@ const resetPreview = () => { previewScope.value = 'eligible' } -const selectStandalone = () => { - selectedIds.value = Array.from(new Set([ - ...selectedIds.value, - ...standaloneCandidates.value.map((candidate) => candidate.equipment_id) - ])) -} - const close = () => { if (submitting.value) return dialogElement.value?.close() @@ -395,7 +391,9 @@ const loadPreview = async (params: BatchDisposalPreviewParams) => { if (!response.data) throw new Error('没有读取到报废预览,请重新预览') preview.value = response.data if (!eligibleCandidates.value.length && blockedCandidates.value.length) previewScope.value = 'blocked' - selectStandalone() + selectedIds.value = eligibleCandidates.value + .filter((candidate) => candidate.items.length === 1) + .map((candidate) => candidate.equipment_id) void nextTick(() => dialogTitle.value?.focus({ preventScroll: true })) } catch (error) { errorMessage.value = error instanceof Error ? error.message : '预览失败,请重试' @@ -583,16 +581,27 @@ onMounted(() => { display: flex; flex-wrap: wrap; align-items: center; - justify-content: space-between; gap: var(--space-2); } +.disposal-toolbar-choice { + display: inline-flex; + flex-shrink: 0; + min-height: 44px; + align-items: center; + gap: 6px; + color: var(--text-primary); + font-size: 14px; + white-space: nowrap; + cursor: pointer; +} + .disposal-scope { gap: var(--space-1); } .disposal-scope .segmented-toggle__item { - padding-inline: var(--space-3); + padding-inline: var(--space-2); } .disposal-scope .segmented-toggle__item.is-active {