<template>
|
<view class="subtract-stock-page">
|
<PageHeader title="出库" @back="goBack" />
|
|
<scroll-view scroll-y class="content-scroll">
|
<view class="form-section">
|
<view class="section-title">库存信息</view>
|
<view class="info-row">
|
<text class="label">产品大类</text>
|
<text class="value">{{ stockRecord.productName }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">规格型号</text>
|
<text class="value">{{ stockRecord.model }}</text>
|
</view>
|
<view class="info-row">
|
<text class="label">可用库存</text>
|
<text class="value highlight">{{ stockRecord.unLockedQuantity }}</text>
|
</view>
|
</view>
|
|
<view class="form-section">
|
<view class="section-title">出库信息</view>
|
<view class="form-row">
|
<text class="form-label required">出库数量</text>
|
<up-input v-model="form.stockOutNum" type="number" :placeholder="'最大' + stockRecord.unLockedQuantity" />
|
</view>
|
<view class="form-row">
|
<text class="form-label">备注</text>
|
<up-input v-model="form.remark" type="textarea" placeholder="选填" />
|
</view>
|
</view>
|
</scroll-view>
|
|
<view class="bottom-bar">
|
<view class="btn-submit" @click="handleSubmit">提交</view>
|
</view>
|
</view>
|
</template>
|
|
<script setup>
|
import { computed, reactive, ref } from "vue";
|
import { onLoad } from "@dcloudio/uni-app";
|
import PageHeader from "@/components/PageHeader.vue";
|
import { subtractConsumablesIn } from "@/api/consumablesLogistics/consumablesIn.js";
|
|
const type = ref("0");
|
const isQualified = computed(() => true);
|
|
const stockRecord = reactive({});
|
|
const form = reactive({
|
stockOutNum: "",
|
remark: "",
|
});
|
|
onLoad((options) => {
|
type.value = "0";
|
const cached = uni.getStorageSync("stockSubtractRecord");
|
if (cached) {
|
try {
|
const payload = typeof cached === "string" ? JSON.parse(cached) : cached;
|
const item = payload && payload.item != null ? payload.item : payload;
|
Object.assign(stockRecord, item || {});
|
uni.removeStorageSync("stockSubtractRecord");
|
} catch (e) {
|
uni.removeStorageSync("stockSubtractRecord");
|
}
|
}
|
});
|
|
const handleSubmit = () => {
|
const outNum = Number(form.stockOutNum);
|
if (!outNum || outNum <= 0 || outNum > Number(stockRecord.unLockedQuantity)) {
|
uni.showToast({ title: `请输入 1~${stockRecord.unLockedQuantity} 之间的数量`, icon: "none" });
|
return;
|
}
|
subtractConsumablesIn({
|
...stockRecord,
|
id: stockRecord.id,
|
qualitity: outNum,
|
remark: form.remark,
|
})
|
.then(() => {
|
uni.showToast({ title: "出库成功", icon: "success" });
|
setTimeout(() => uni.navigateBack(), 400);
|
})
|
.catch(() => {
|
uni.showToast({ title: "出库失败", icon: "none" });
|
});
|
};
|
|
const goBack = () => uni.navigateBack();
|
</script>
|
|
<style lang="scss" scoped>
|
.subtract-stock-page { min-height: 100vh; background: #f5f5f5; padding-bottom: 100rpx; }
|
.content-scroll { height: calc(100vh - 100rpx); }
|
.form-section { background: #fff; margin: 24rpx; padding: 24rpx; border-radius: 16rpx; }
|
.section-title { font-size: 28rpx; font-weight: 500; color: #333; margin-bottom: 12rpx; }
|
.info-row { display: flex; justify-content: space-between; padding: 12rpx 0; font-size: 26rpx; }
|
.info-row .label { color: #666; }
|
.info-row .value { color: #333; }
|
.info-row .value.highlight { color: #2979ff; font-weight: 500; }
|
.form-row { margin-bottom: 24rpx; }
|
.form-label { display: block; font-size: 26rpx; color: #666; margin-bottom: 12rpx; }
|
.form-label.required:before { content: "*"; color: #f56c6c; margin-right: 6rpx; }
|
.selector-trigger { display: flex; align-items: center; justify-content: space-between; padding: 20rpx 24rpx; background: #f5f5f5; border-radius: 12rpx; }
|
.selector-text { font-size: 28rpx; color: #333; }
|
.selector-text.placeholder { color: #999; }
|
.bottom-bar { position: fixed; left: 0; right: 0; bottom: 0; padding: 16rpx 24rpx calc(16rpx + env(safe-area-inset-bottom)); background: #fff; box-shadow: 0 -4rpx 16rpx rgba(0, 0, 0, 0.04); }
|
.btn-submit { height: 88rpx; border-radius: 999rpx; background: #2979ff; color: #fff; font-size: 30rpx; display: flex; align-items: center; justify-content: center; }
|
</style>
|