src/pages/inventoryManagement/stockManagement/subtract.vue
@@ -87,7 +87,7 @@
</template>
<script setup>
import { ref, reactive, watch } from 'vue'
import { ref, reactive, watch, computed } from 'vue'
import { onLoad } from '@dcloudio/uni-app'
import dayjs from 'dayjs'
import PageHeader from '@/components/PageHeader.vue'
@@ -127,6 +127,12 @@
const type = ref('0') // 0 合格库存,1 不合格库存
const showWeighingDatePicker = ref(false)
const weighingDateValue = ref(Date.now())
const maxAllowedNetWeight = computed(() => {
  const v = form.unLockedQuantity ?? form.qualitity
  const n = Number(v)
  return !isNaN(n) ? n : 0
})
onLoad((options) => {
  if (options && options.type != null) {
@@ -183,6 +189,11 @@
    uni.showToast({ title: '记录信息缺失,无法出库', icon: 'none' })
    return
  }
  const net = Number(form.netWeight)
  if (!isNaN(net) && net > 0 && maxAllowedNetWeight.value > 0 && net > maxAllowedNetWeight.value) {
    uni.showToast({ title: `净重不能大于可用库存 ${maxAllowedNetWeight.value}`, icon: 'none' })
    return
  }
  const payload = { ...form }
  const api = type.value === '0' ? subtractStockInventory : subtractStockUnInventory
  api(payload)