This commit is contained in:
@@ -22,7 +22,14 @@
|
||||
<view class="section">
|
||||
<view class="section-header">
|
||||
<text class="section-title">商品明细</text>
|
||||
<text class="add-btn" @click="addProduct">+ 添加商品</text>
|
||||
<picker
|
||||
mode="selector"
|
||||
:range="productList"
|
||||
range-key="name"
|
||||
@change="onProductSelect"
|
||||
>
|
||||
<text class="add-btn">+ 添加商品</text>
|
||||
</picker>
|
||||
</view>
|
||||
|
||||
<view v-for="(item, index) in orderItems" :key="index" class="order-item">
|
||||
@@ -136,30 +143,6 @@
|
||||
</view>
|
||||
<button class="submit-btn" @click="createOrder">创建订单</button>
|
||||
</view>
|
||||
|
||||
<!-- 商品选择弹窗 -->
|
||||
<uni-popup ref="productPopup" type="bottom">
|
||||
<view class="product-popup">
|
||||
<view class="popup-header">
|
||||
<text>选择商品</text>
|
||||
<text @click="$refs.productPopup.close()">关闭</text>
|
||||
</view>
|
||||
<view class="popup-search">
|
||||
<input v-model="searchKeyword" placeholder="搜索商品" />
|
||||
</view>
|
||||
<scroll-view class="popup-list" scroll-y>
|
||||
<view
|
||||
v-for="p in productList"
|
||||
:key="p.productId"
|
||||
class="popup-item"
|
||||
@click="selectProduct(p)"
|
||||
>
|
||||
<text>{{ p.name }}</text>
|
||||
<text>¥{{ p.price }}</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</uni-popup>
|
||||
</view>
|
||||
</template>
|
||||
|
||||
@@ -205,10 +188,8 @@ export default {
|
||||
selectCustomer(e) {
|
||||
this.selectedCustomer = this.customers[e.detail.value]
|
||||
},
|
||||
addProduct() {
|
||||
this.$refs.productPopup.open()
|
||||
},
|
||||
selectProduct(product) {
|
||||
onProductSelect(e) {
|
||||
const product = this.productList[e.detail.value]
|
||||
// 检查是否已添加
|
||||
const exists = this.orderItems.find(item => item.productId === product.productId)
|
||||
if (exists) {
|
||||
@@ -218,6 +199,12 @@ export default {
|
||||
|
||||
this.orderItems.push({
|
||||
productId: product.productId,
|
||||
productName: product.name,
|
||||
price: product.price,
|
||||
quantity: 1
|
||||
})
|
||||
this.calcAmount()
|
||||
},
|
||||
productName: product.name,
|
||||
spec: product.spec,
|
||||
unit: product.unit,
|
||||
@@ -226,7 +213,6 @@ export default {
|
||||
})
|
||||
|
||||
this.calcAmount()
|
||||
this.$refs.productPopup.close()
|
||||
},
|
||||
removeItem(index) {
|
||||
this.orderItems.splice(index, 1)
|
||||
@@ -499,39 +485,4 @@ export default {
|
||||
border-radius: 40rpx;
|
||||
font-size: 28rpx;
|
||||
}
|
||||
|
||||
.product-popup {
|
||||
background: #fff;
|
||||
height: 60vh;
|
||||
border-radius: 24rpx 24rpx 0 0;
|
||||
}
|
||||
|
||||
.popup-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx;
|
||||
border-bottom: 1rpx solid #eee;
|
||||
}
|
||||
|
||||
.popup-search {
|
||||
padding: 20rpx;
|
||||
}
|
||||
|
||||
.popup-search input {
|
||||
height: 60rpx;
|
||||
background: #f5f5f5;
|
||||
border-radius: 8rpx;
|
||||
padding: 0 20rpx;
|
||||
}
|
||||
|
||||
.popup-list {
|
||||
height: calc(60vh - 140rpx);
|
||||
}
|
||||
|
||||
.popup-item {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
padding: 24rpx;
|
||||
border-bottom: 1rpx solid #f5f5f5;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user