up修复数量问题

This commit is contained in:
2026-04-27 13:04:42 +08:00
parent 93359a1bd3
commit 1d1a4f3670
6 changed files with 184 additions and 15 deletions
+49 -1
View File
@@ -17,6 +17,19 @@
<input class="form-input" v-model="form.serialNumber" placeholder="请输入物品编号(选填)" />
</view>
<view class="form-item">
<text class="form-label">数量</text>
<view class="quantity-row">
<view class="qty-btn" @click="form.quantity > 1 && form.quantity--">
<text class="qty-btn-text"></text>
</view>
<input class="qty-input" type="number" v-model.number="form.quantity" />
<view class="qty-btn" @click="form.quantity++">
<text class="qty-btn-text">+</text>
</view>
</view>
</view>
<view class="form-item">
<text class="form-label">备注</text>
<textarea class="form-textarea" v-model="form.remark" placeholder="请输入备注(选填)" />
@@ -68,6 +81,7 @@ const form = ref({
name: '',
serialNumber: '',
remark: '',
quantity: 1,
photos: []
})
@@ -129,6 +143,7 @@ async function submitForm() {
name: form.value.name,
serial_number: form.value.serialNumber,
remark: form.value.remark,
quantity: form.value.quantity > 0 ? form.value.quantity : 1,
container_id: containerId.value || null,
photos: form.value.photos
}
@@ -154,7 +169,6 @@ async function submitForm() {
// 获取页面参数
import { onLoad } from '@dcloudio/uni-app'
onLoad((options) => {
console.log('add-item onLoad options:', options)
if (options && options.container_id) {
containerId.value = parseInt(options.container_id)
}
@@ -311,4 +325,38 @@ onLoad((options) => {
border-radius: 12rpx;
font-size: 32rpx;
}
/* 数量选择器 */
.quantity-row {
display: flex;
align-items: center;
gap: 0;
}
.qty-btn {
width: 72rpx;
height: 72rpx;
background-color: #f0f0f0;
border-radius: 10rpx;
display: flex;
align-items: center;
justify-content: center;
}
.qty-btn-text {
font-size: 36rpx;
color: #333;
line-height: 1;
}
.qty-input {
width: 100rpx;
height: 72rpx;
text-align: center;
background-color: #f5f5f5;
font-size: 30rpx;
border-radius: 10rpx;
margin: 0 16rpx;
box-sizing: border-box;
}
</style>