| | |
| | | ]" |
| | | > |
| | | <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> |
| | | |
| | |
| | | prop="qualitity" |
| | | > |
| | | <el-input-number v-model="formState.qualitity" :step="1" :min="1" :max="maxQuality" style="width: 100%" /> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="出库批次" prop="outboundBatches"> |
| | | <el-input |
| | | v-model="formState.outboundBatches" |
| | | placeholder="留空自动生成" |
| | | maxlength="100" |
| | | show-word-limit |
| | | /> |
| | | <div class="form-tip">不填则自动生成,格式:CK年月日-序号</div> |
| | | </el-form-item> |
| | | |
| | | <el-form-item label="备注" prop="remark"> |
| | |
| | | <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 = () => { |
| | |
| | | model: "", |
| | | unit: "", |
| | | qualitity: 0, |
| | | outboundBatches: "", |
| | | remark: '', |
| | | }); |
| | | |
| | |
| | | productModelId: undefined, |
| | | productName: "", |
| | | productModelName: "", |
| | | outboundBatches: "", |
| | | description: '', |
| | | }; |
| | | isShow.value = false; |
| | |
| | | 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; |
| | | // 告知父组件已完成 |
| | |
| | | handleSubmit, |
| | | isShow, |
| | | }); |
| | | </script> |
| | | </script> |
| | | |
| | | <style scoped> |
| | | .form-tip { |
| | | font-size: 12px; |
| | | color: #909399; |
| | | margin-top: 4px; |
| | | } |
| | | </style> |