| | |
| | | ]" |
| | | > |
| | | <el-select v-model="formState.type" placeholder="请选择库存类型" @change="handleTypeChange"> |
| | | <el-option label="合格库存" value="qualified" :disabled="props.record.qualifiedUnLockedQuantity <= 0" /> |
| | | <el-option label="不合格库存" value="unqualified" :disabled="props.record.unQualifiedUnLockedQuantity <= 0" /> |
| | | <el-option label="合格库存" value="qualified" :disabled="(props.record.qualifiedUnLockedQuantity || 0) + (props.record.qualifiedPendingOutQuantity || 0) <= 0" /> |
| | | <el-option label="不合格库存" value="unqualified" :disabled="(props.record.unQualifiedUnLockedQuantity || 0) + (props.record.unQualifiedPendingOutQuantity || 0) <= 0" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | |
| | | <script setup> |
| | | import {ref, computed, getCurrentInstance} from "vue"; |
| | | import ProductSelectDialog from "@/views/basicData/product/ProductSelectDialog.vue"; |
| | | import {subtractStockInventory} from "@/api/inventoryManagement/stockInventory.js"; |
| | | import {subtractStockUnInventory} from "@/api/inventoryManagement/stockUninventory.js"; |
| | | import {addStockOutRecordOnly} from "@/api/inventoryManagement/stockInventory.js"; |
| | | import {addUnqualifiedStockOutRecordOnly} from "@/api/inventoryManagement/stockUninventory.js"; |
| | | |
| | | const props = defineProps({ |
| | | visible: { |
| | |
| | | }) |
| | | |
| | | const maxQuality = computed(() => { |
| | | let max = 0; |
| | | if (formState.value.type === 'qualified') { |
| | | max = props.record.qualifiedUnLockedQuantity ? props.record.qualifiedUnLockedQuantity : 0; |
| | | // 合格可出 = 未冻结量 + 待审核出库量(即已申请但尚未审批的数量) |
| | | return Math.max(1, Number(props.record.qualifiedUnLockedQuantity || 0) + Number(props.record.qualifiedPendingOutQuantity || 0)); |
| | | } else { |
| | | max = props.record.unQualifiedUnLockedQuantity ? props.record.unQualifiedUnLockedQuantity : 0; |
| | | return Math.max(1, Number(props.record.unQualifiedUnLockedQuantity || 0) + Number(props.record.unQualifiedPendingOutQuantity || 0)); |
| | | } |
| | | // 确保 max 至少为 1,避免 min > max 的错误 |
| | | return Math.max(max, 1); |
| | | }) |
| | | |
| | | const handleTypeChange = () => { |
| | |
| | | return; |
| | | } |
| | | if (formState.value.type === 'qualified') { |
| | | subtractStockInventory(formState.value).then(res => { |
| | | addStockOutRecordOnly(formState.value).then(res => { |
| | | // 关闭模态框 |
| | | isShow.value = false; |
| | | // 告知父组件已完成 |
| | |
| | | proxy.$modal.msgSuccess("提交成功"); |
| | | }) |
| | | } else { |
| | | subtractStockUnInventory(formState.value).then(res => { |
| | | addUnqualifiedStockOutRecordOnly(formState.value).then(res => { |
| | | // 关闭模态框 |
| | | isShow.value = false; |
| | | // 告知父组件已完成 |