yuan
2026-04-25 17e77741270ac0efcade87b37d63bfcb41295ec2
src/views/inventoryManagement/stockManagement/Subtract.vue
@@ -49,8 +49,8 @@
            ]"
        >
          <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>
@@ -85,8 +85,8 @@
<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: {
@@ -106,14 +106,12 @@
})
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 = () => {
@@ -192,7 +190,7 @@
        return;
      }
      if (formState.value.type === 'qualified') {
        subtractStockInventory(formState.value).then(res => {
        addStockOutRecordOnly(formState.value).then(res => {
          // 关闭模态框
          isShow.value = false;
          // 告知父组件已完成
@@ -200,7 +198,7 @@
          proxy.$modal.msgSuccess("提交成功");
        })
      } else {
        subtractStockUnInventory(formState.value).then(res => {
        addUnqualifiedStockOutRecordOnly(formState.value).then(res => {
          // 关闭模态框
          isShow.value = false;
          // 告知父组件已完成