| | |
| | | <el-col :span="12"> |
| | | <el-form-item label="是否生产:" |
| | | prop="isProduction"> |
| | | <div style="display: flex; align-items: center; width: 100%;"> |
| | | <el-radio-group v-model="productForm.isProduction"> |
| | | <el-radio label="是" |
| | | :value="true" /> |
| | | <el-radio label="否" |
| | | :value="false" /> |
| | | </el-radio-group> |
| | | <div |
| | | v-if="currentStock !== null" |
| | | :style="{ |
| | | marginLeft: '20px', |
| | | padding: '0 12px', |
| | | height: '28px', |
| | | lineHeight: '28px', |
| | | borderRadius: '4px', |
| | | fontSize: '13px', |
| | | fontWeight: '500', |
| | | display: 'inline-block', |
| | | whiteSpace: 'nowrap', |
| | | backgroundColor: (productForm.quantity || 0) > currentStock ? '#fff0f0' : '#f0f9eb', |
| | | border: (productForm.quantity || 0) > currentStock ? '1px solid #ffcccc' : '1px solid #e1f3d8', |
| | | color: (productForm.quantity || 0) > currentStock ? '#f56c6c' : '#67c23a' |
| | | }" |
| | | > |
| | | <span>当前库存:{{ currentStock }} {{ productForm.unit || '' }}</span> |
| | | </div> |
| | | </div> |
| | | </el-form-item> |
| | | </el-col> |
| | | </el-row> |
| | |
| | | item?.stockQuantity; |
| | | return quantity ?? 0; |
| | | }; |
| | | const currentStock = ref(null); |
| | | const fetchCurrentStock = async (productModelId) => { |
| | | if (!productModelId) { |
| | | currentStock.value = null; |
| | | return; |
| | | } |
| | | try { |
| | | const res = await getStockInventoryByModelId(productModelId); |
| | | const rawList = Array.isArray(res?.data) |
| | | ? res.data |
| | | : res?.data?.records || res?.data?.rows || []; |
| | | let total = 0; |
| | | rawList.forEach(item => { |
| | | total += Number(getDeliveryBatchQuantity(item) || 0); |
| | | }); |
| | | currentStock.value = total; |
| | | } catch (e) { |
| | | console.error(e); |
| | | currentStock.value = 0; |
| | | } |
| | | }; |
| | | const getCurrentDeliveryRowQuantity = () => { |
| | | return Number(currentDeliveryRow.value?.noQuantity || 0); |
| | | }; |
| | |
| | | // 获取tree子数据 |
| | | const getModels = value => { |
| | | productForm.value.productCategory = findNodeById(productOptions.value, value); |
| | | currentStock.value = null; |
| | | modelList({ id: value }).then(res => { |
| | | modelOptions.value = res; |
| | | }); |
| | |
| | | if (index !== -1) { |
| | | productForm.value.specificationModel = modelOptions.value[index].model; |
| | | productForm.value.unit = modelOptions.value[index].unit; |
| | | fetchCurrentStock(value); |
| | | } else { |
| | | productForm.value.specificationModel = null; |
| | | productForm.value.unit = null; |
| | | currentStock.value = null; |
| | | } |
| | | }; |
| | | const findNodeById = (nodes, productId) => { |
| | |
| | | |
| | | productOperationType.value = type; |
| | | productForm.value = {}; |
| | | currentStock.value = null; |
| | | if (type === "add") { |
| | | productForm.value.isProduction = false; |
| | | } |
| | |
| | | ); |
| | | if (currentModel) { |
| | | productForm.value.productModelId = currentModel.id; |
| | | fetchCurrentStock(currentModel.id); |
| | | } |
| | | } |
| | | } catch (e) { |