| | |
| | | > |
| | | <el-form label-width="140px" :model="formState" ref="formRef"> |
| | | <el-form-item |
| | | label="库存类型" |
| | | prop="type" |
| | | :rules="[ |
| | | { |
| | | required: true, |
| | | message: '请选择库存类型', |
| | | trigger: 'change', |
| | | } |
| | | ]" |
| | | > |
| | | <el-select v-model="formState.type" placeholder="请选择库存类型" @change="handleChangeType"> |
| | | <el-option label="合格库存" value="qualified" :disabled="(operationType === 'frozen' && props.record.qualifiedUnLockedQuantity <= 0) || (operationType === 'thaw' && props.record.qualifiedLockedQuantity <= 0)" /> |
| | | <el-option label="不合格库存" value="unqualified" :disabled="(operationType === 'frozen' && props.record.unQualifiedUnLockedQuantity <= 0) || (operationType === 'thaw' && props.record.unQualifiedLockedQuantity <= 0)" /> |
| | | </el-select> |
| | | </el-form-item> |
| | | |
| | | <el-form-item |
| | | :label="operationType === 'frozen' ? '冻结数量:' : '解冻数量:'" |
| | | prop="lockedQuantity" |
| | | > |
| | | <el-input-number v-model="formState.lockedQuantity" :step="1" :min="1" precision="0" style="width: 100%" :max="maxCount" /> |
| | | <el-input-number v-model="formState.lockedQuantity" :step="1" :min="maxCount > 0 ? 1 : 0" precision="0" style="width: 100%" :max="maxCount" :disabled="maxCount < 1" /> |
| | | </el-form-item> |
| | | </el-form> |
| | | |
| | |
| | | </template> |
| | | |
| | | <script setup> |
| | | import {ref, computed, getCurrentInstance} from "vue"; |
| | | import {ref, computed, getCurrentInstance, onMounted} from "vue"; |
| | | import {frozenStockInventory, thawStockInventory} from "@/api/inventoryManagement/stockInventory.js"; |
| | | import {frozenStockUninventory, thawStockUninventory} from "@/api/inventoryManagement/stockUninventory.js"; |
| | | |
| | |
| | | default: 'frozen', |
| | | }, |
| | | |
| | | type: { |
| | | type: String, |
| | | required: true, |
| | | default: 'qualified', |
| | | }, |
| | | |
| | | record: { |
| | | type: Object, |
| | | default: () => {}, |
| | |
| | | |
| | | // 响应式数据(替代选项式的 data) |
| | | const formState = ref({ |
| | | lockedQuantity: 0, |
| | | type: undefined, |
| | | lockedQuantity: undefined, |
| | | }); |
| | | |
| | | const isShow = computed({ |
| | |
| | | const closeModal = () => { |
| | | // 重置表单数据 |
| | | formState.value = { |
| | | lockedQuantity: undefined |
| | | lockedQuantity: undefined, |
| | | type: undefined, |
| | | }; |
| | | isShow.value = false; |
| | | }; |
| | |
| | | const maxCount = computed(() => { |
| | | // 冻结库存最大数量为未解冻数量 |
| | | if (props.operationType === 'frozen') { |
| | | return props.record.unLockedQuantity |
| | | // 冻结合格库存最大数量为未解冻合格数量 |
| | | if (formState.value.type === 'qualified') { |
| | | return Math.max(0, props.record.qualifiedUnLockedQuantity || 0) |
| | | } |
| | | // 冻结不合格库存最大数量为未解冻不合格数量 |
| | | return Math.max(0, props.record.unQualifiedUnLockedQuantity || 0) |
| | | } |
| | | // 解冻库存最大数量为已冻结数量 |
| | | return props.record.lockedQuantity |
| | | if (formState.value.type === 'qualified') { |
| | | // 解冻合格库存最大数量为已冻结合格数量 |
| | | return Math.max(0, props.record.qualifiedLockedQuantity || 0) |
| | | } |
| | | // 解冻不合格库存最大数量为已冻结不合格数量 |
| | | return Math.max(0, props.record.unQualifiedLockedQuantity || 0) |
| | | }) |
| | | |
| | | const handleChangeType = (type) => { |
| | | formState.value.lockedQuantity = maxCount.value; |
| | | } |
| | | |
| | | const handleSubmit = () => { |
| | | proxy.$refs["formRef"].validate(valid => { |
| | | if (valid) { |
| | | const data = Object.assign({id: props.record.id}, formState.value); |
| | | if (props.type === 'qualified') { |
| | | const data = Object.assign({}, formState.value); |
| | | if (formState.value.type === 'qualified') { |
| | | data.id = props.record.qualifiedId; |
| | | // 冻结 |
| | | if (props.operationType === 'frozen') { |
| | | frozenStockInventory(data).then(res => { |
| | |
| | | }) |
| | | } |
| | | } else { |
| | | data.id = props.record.unQualifiedId; |
| | | if (props.operationType === 'frozen') { |
| | | frozenStockUninventory(data).then(res => { |
| | | if (res.code === 200) { |
| | |
| | | }; |
| | | |
| | | onMounted(() => { |
| | | formState.value.lockedQuantity = maxCount.value; |
| | | }) |
| | | |
| | | defineExpose({ |
| | |
| | | handleSubmit, |
| | | isShow, |
| | | }); |
| | | </script> |
| | | </script> |