diff --git a/src/views/assets/operation/count/component/editInventoryCount.vue b/src/views/assets/operation/count/component/editInventoryCount.vue index 0736bba..ed351bd 100644 --- a/src/views/assets/operation/count/component/editInventoryCount.vue +++ b/src/views/assets/operation/count/component/editInventoryCount.vue @@ -22,23 +22,59 @@ - + + + + + + + + + + + +
-
- {{ getScopeLabel(form.scope) }} - {{ name }} - {{ name }} - {{ name }} +
+ {{ name }}
- - - {{ scopeDisplayText ? '修改' : '选择盘点范围' }} + + + {{ form.warehouseIds.length > 0 ? '继续选择' : '选择仓库' }}
- - + + +
+
+ {{ name }} +
+ + + {{ form.zoneIds.length > 0 ? '继续选择' : '选择库区' }} + + 请先选择仓库 +
+
+ + + +
+
+ {{ name }} +
+ + + {{ form.locationIds.length > 0 ? '继续选择' : '选择库位' }} + + 请先选择库区 +
+
+ + + @@ -66,14 +102,14 @@ import { ref, reactive, computed } from 'vue'; import { ElMessage } from 'element-plus'; import type { FormInstance, FormRules } from 'element-plus'; import { createInventoryCount, updateInventoryCount, getInventoryCount } from '/@/api/assets/operation/count'; -import ScopeSelectDrawer from './scopeSelectDrawer.vue'; +import ScopeSelectDialog from './scopeSelectDialog.vue'; const emit = defineEmits(['refresh']); const visible = ref(false); const loading = ref(false); const formRef = ref(); -const scopeDrawerRef = ref(); +const scopeSelectDialogRef = ref(); // 表单数据 const form = reactive({ @@ -98,15 +134,53 @@ const selectedLocationNames = ref([]); // 参与人员输入框 const participantsInput = ref(''); -// 盘点范围显示文本 -const scopeDisplayText = computed(() => { - return form.warehouseIds.length > 0; -}); +// 当前选择的类型(1-仓库 2-库区 3-库位) +const currentSelectType = ref(1); -// 获取盘点范围标签 -const getScopeLabel = (scope: number) => { - const labels: Record = { 1: '按仓库盘点', 2: '按库区盘点', 3: '按库位盘点', 4: '按SKU盘点', 5: '按资产盘点' }; - return labels[scope] || ''; +// 移除仓库 +const removeWarehouse = (name: string) => { + const idx = selectedWarehouseNames.value.indexOf(name); + if (idx > -1) { + selectedWarehouseNames.value.splice(idx, 1); + form.warehouseIds.splice(idx, 1); + // 清空下级选择 + form.zoneIds = []; + form.locationIds = []; + selectedZoneNames.value = []; + selectedLocationNames.value = []; + } +}; + +// 移除库区 +const removeZone = (name: string) => { + const idx = selectedZoneNames.value.indexOf(name); + if (idx > -1) { + selectedZoneNames.value.splice(idx, 1); + form.zoneIds.splice(idx, 1); + // 清空下级选择 + form.locationIds = []; + selectedLocationNames.value = []; + } +}; + +// 移除库位 +const removeLocation = (name: string) => { + const idx = selectedLocationNames.value.indexOf(name); + if (idx > -1) { + selectedLocationNames.value.splice(idx, 1); + form.locationIds.splice(idx, 1); + } +}; + +// 盘点范围类型变化 +const onScopeTypeChange = () => { + // 清空已选项 + form.warehouseIds = []; + form.zoneIds = []; + form.locationIds = []; + selectedWarehouseNames.value = []; + selectedZoneNames.value = []; + selectedLocationNames.value = []; }; // 表单校验规则 @@ -186,25 +260,52 @@ const resetForm = () => { formRef.value?.resetFields(); }; -// 打开盘点范围选择抽屉 -const openScopeDrawer = () => { - scopeDrawerRef.value?.openDrawer({ - scope: form.scope, +// 打开选择弹窗 +const openSelectDialog = (type: number) => { + currentSelectType.value = type; + let selectedIds: string[] = []; + let selectedNames: string[] = []; + + if (type === 1) { + selectedIds = form.warehouseIds; + selectedNames = selectedWarehouseNames.value; + } else if (type === 2) { + selectedIds = form.zoneIds; + selectedNames = selectedZoneNames.value; + } else if (type === 3) { + selectedIds = form.locationIds; + selectedNames = selectedLocationNames.value; + } + + scopeSelectDialogRef.value?.open({ + scope: type, + selectedIds, + selectedNames, warehouseIds: form.warehouseIds, zoneIds: form.zoneIds, - locationIds: form.locationIds, }); }; -// 盘点范围选择确认 -const onScopeConfirm = (data: any) => { - form.scope = data.scope; - form.warehouseIds = data.warehouseIds; - form.zoneIds = data.zoneIds; - form.locationIds = data.locationIds; - selectedWarehouseNames.value = data.warehouseNames; - selectedZoneNames.value = data.zoneNames; - selectedLocationNames.value = data.locationNames; +// 选择确认 +const onSelectConfirm = (data: any) => { + if (currentSelectType.value === 1) { + form.warehouseIds = data.selectedIds; + selectedWarehouseNames.value = data.selectedNames; + // 清空下级选择 + form.zoneIds = []; + form.locationIds = []; + selectedZoneNames.value = []; + selectedLocationNames.value = []; + } else if (currentSelectType.value === 2) { + form.zoneIds = data.selectedIds; + selectedZoneNames.value = data.selectedNames; + // 清空下级选择 + form.locationIds = []; + selectedLocationNames.value = []; + } else if (currentSelectType.value === 3) { + form.locationIds = data.selectedIds; + selectedLocationNames.value = data.selectedNames; + } }; // 关闭弹窗 @@ -269,7 +370,7 @@ defineExpose({ diff --git a/src/views/assets/operation/count/component/scopeSelectDialog.vue b/src/views/assets/operation/count/component/scopeSelectDialog.vue new file mode 100644 index 0000000..90d9858 --- /dev/null +++ b/src/views/assets/operation/count/component/scopeSelectDialog.vue @@ -0,0 +1,313 @@ + + + + +