Bladeren bron

1. 点击商品名称与价格能快捷添加至列表
2. 优化列表:2.1-高亮选中的商品、2.2-跟踪当前高亮商品;这样无论最新商品在底部,还是重新选择顶部已有商品,列表都会自动滚到对应项

shizhongqi 3 maanden geleden
bovenliggende
commit
e679770c52

+ 22 - 5
ghsPad/src/pages/home/cash.vue

@@ -10,14 +10,23 @@
 				</view>
 
 				<view class="itemList-box">
-					<leftArea v-if="!$util.isEmpty(selectList)" :changeCurrentJobType.sync="currentJobType"
-						:changeCurrentJobId.sync="currentJobId"></leftArea>
+					<leftArea
+						v-if="!$util.isEmpty(selectList)"
+						:changeCurrentJobType.sync="currentJobType"
+						:changeCurrentJobId.sync="currentJobId"
+						:activeItemMark="activeItemMark"
+					></leftArea>
 					<leftGroup v-else :customId.sync="customId" :custom.sync="custom"></leftGroup>
 				</view>
 
 				<view class="all-item-area">
-					<rightItem ref="rightItemRef" :customId.sync="customId" :changeCurrentJobType.sync="currentJobType"
-						:changeCurrentJobId.sync="currentJobId"> </rightItem>
+					<rightItem
+						ref="rightItemRef"
+						:customId.sync="customId"
+						:changeCurrentJobType.sync="currentJobType"
+						:changeCurrentJobId.sync="currentJobId"
+						@operateItem="setActiveItemMark"
+					> </rightItem>
 				</view>
 
 				<view class="open-box">
@@ -84,7 +93,8 @@ export default {
 			T: null,
 			customList: [],
 			myCustomList: [],
-			mustUpdate: false
+			mustUpdate: false,
+			activeItemMark: { key: '', time: 0 }
 		}
 	},
 	computed: {
@@ -241,6 +251,13 @@ export default {
 		},
 		changeProperty(property) {
 			this.currentProperty = property
+		},
+		setActiveItemMark(item) {
+			const property = item.property !== undefined ? item.property : 1
+			this.activeItemMark = {
+				key: `${item.id}_${property}`,
+				time: Date.now()
+			}
 		}
 	}
 };

+ 140 - 17
ghsPad/src/pages/home/components/leftArea.vue

@@ -4,26 +4,38 @@
             列表
             <text style="float:right;">{{ getMyShopInfo.shopName=='首店'? getMyShopInfo.merchantName: getMyShopInfo.merchantName+' '+getMyShopInfo.shopName}}</text>
         </view>
-        <view class="itemList-item_box">
+        <scroll-view
+            class="itemList-item_box"
+            scroll-y
+            scroll-with-animation
+            :scroll-into-view="activeScrollIntoView"
+        >
             <view
                 v-for="item in selectList"
-                :key="item.id"
+                :key="getItemKey(item)"
+                :id="getItemScrollId(item)"
+                :data-item-key="getItemKey(item)"
                 class="show-item_box"
-                @touchstart="onItemTouchStart(item, $event)"
-                @touchmove="onItemTouchMove(item, $event)"
-                @touchend="onItemTouchEnd(item)"
-                @touchcancel="onItemTouchEnd(item)"
+                @touchstart="onItemTouchStartByEvent"
+                @touchmove="onItemTouchMoveByEvent"
+                @touchend="onItemTouchEndByEvent"
+                @touchcancel="onItemTouchEndByEvent"
             >
-                <view class="delete-btn" @click.stop="delItem(item)">删除</view>
-                <view class="item-body_box not-active" :class="{'is-swiped': swipeItemId === item.id}" @click="handleItemClick(item)">
+                <view class="delete-btn" :data-item-key="getItemKey(item)" @click.stop="delItemByEvent">删除</view>
+                <view
+                    class="item-body_box not-active"
+                    :data-item-key="getItemKey(item)"
+                    :class="{'is-swiped': swipeItemId === item.id, 'is-operated': activeItemKey === getItemKey(item)}"
+                    @click="handleItemClickByEvent"
+                >
                     <view class="flower-name_box">
                         <view class="current-item-title">
                             <text class="name">{{item.name}}</text>
                             <view class="num-action_box">
-                                <view class="num-btn" @click.stop="changeItemNum(item, -1)">
+                                <view class="num-btn" :data-item-key="getItemKey(item)" @click.stop="changeItemNumByEvent($event, -1)">
                                     <zui-svg-icon icon="general-sub" :width="28" :height="28" color="#8abf8a" />
                                 </view>
-                                <view class="num-btn" @click.stop="changeItemNum(item, 1)">
+                                <view class="num-btn" :data-item-key="getItemKey(item)" @click.stop="changeItemNumByEvent($event, 1)">
                                     <zui-svg-icon icon="general-plus" :width="28" :height="28" color="#8abf8a" />
                                 </view>
                             </view>
@@ -42,7 +54,7 @@
                     </view>
                 </view>
             </view>
-        </view>
+        </scroll-view>
         <view class="itemList-footer_box">
             <view> 数量
                 <text style="margin-left:5upx;">
@@ -81,6 +93,12 @@ export default {
         changeCurrentJobId:{
 			type: Number,
 			default: 0
+        },
+        activeItemMark:{
+            type: Object,
+            default(){
+                return { key:'', time:0 }
+            }
         }
     },
     data(){
@@ -88,6 +106,8 @@ export default {
             totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
             itemList:[],
             swipeItemId: '',
+            activeItemKey: '',
+            activeScrollIntoView: '',
             touchStartX: 0,
             touchStartY: 0,
             isHorizontalSwipe: false,
@@ -109,6 +129,23 @@ export default {
                 this.currentJobId = id
             },
             immediate:true
+        },
+        activeItemMark:{
+            handler(mark){
+                if(mark && mark.key){
+                    this.activeItemKey = mark.key
+                    this.scrollToActiveItemByKey(mark.key)
+                }
+            },
+            immediate:true
+        },
+        selectList:{
+            handler(){
+                if(this.activeItemKey){
+                    this.scrollToActiveItemByKey(this.activeItemKey)
+                }
+            },
+            deep:true
         }
     },
     methods:{
@@ -116,14 +153,64 @@ export default {
             const touches = event.changedTouches || event.touches || []
             return touches[0]
         },
+        getItemKey(item) {
+            const property = item.property !== undefined ? item.property : 1
+            return `${item.id}_${property}`
+        },
+        getScrollIdByKey(key) {
+            return `select-item-${key}`
+        },
+        getItemScrollId(item) {
+            return this.getScrollIdByKey(this.getItemKey(item))
+        },
+        getEventItem(event) {
+            const dataset = event && event.currentTarget && event.currentTarget.dataset
+            const key = dataset && dataset.itemKey
+            if (!key) return null
+            return this.selectList.find(item => this.getItemKey(item) === key)
+        },
+        scrollToActiveItemByKey(key) {
+            this.activeScrollIntoView = ''
+            this.$nextTick(() => {
+                this.activeScrollIntoView = this.getScrollIdByKey(key)
+            })
+        },
+        setActiveItem(item) {
+            const key = this.getItemKey(item)
+            this.activeItemKey = key
+            this.scrollToActiveItemByKey(key)
+        },
+        clearActiveItem(item) {
+            if (this.activeItemKey === this.getItemKey(item)) {
+                this.activeItemKey = ''
+                this.activeScrollIntoView = ''
+            }
+        },
+        hasEnoughStock(item, num) {
+            if (!this.checkStock || num <= 0) return true
+            if (item.unitType == 0) {
+                return Number(num) <= Number(item.stock)
+            }
+            const stockNum = (Number(num) / Number(item.ratio)).toFixed(2)
+            return Number(stockNum) <= Number(item.stock)
+        },
+        showNoStockTip(item) {
+            this.$util.noStockRemind()
+            this.$msg(item.unitType == 0 ? "库存不足呢" : "库存不足哦")
+        },
         onItemTouchStart(item, event) {
+            if (!item) return
             const touch = this.getTouchPoint(event)
             if (!touch) return
             this.touchStartX = touch.clientX
             this.touchStartY = touch.clientY
             this.isHorizontalSwipe = false
         },
+        onItemTouchStartByEvent(event) {
+            this.onItemTouchStart(this.getEventItem(event), event)
+        },
         onItemTouchMove(item, event) {
+            if (!item) return
             const touch = this.getTouchPoint(event)
             if (!touch) return
             const moveX = touch.clientX - this.touchStartX
@@ -132,7 +219,11 @@ export default {
             this.isHorizontalSwipe = true
             this.swipeItemId = moveX < 0 ? item.id : ''
         },
-        onItemTouchEnd() {
+        onItemTouchMoveByEvent(event) {
+            this.onItemTouchMove(this.getEventItem(event), event)
+        },
+        onItemTouchEnd(item) {
+            if (!item) return
             if (this.isHorizontalSwipe) {
                 this.lastSwipeTime = Date.now()
             }
@@ -140,15 +231,23 @@ export default {
             this.touchStartY = 0
             this.isHorizontalSwipe = false
         },
+        onItemTouchEndByEvent(event) {
+            this.onItemTouchEnd(this.getEventItem(event))
+        },
         handleItemClick(item) {
+            if (!item) return
             if (this.swipeItemId === item.id) {
                 if (Date.now() - this.lastSwipeTime < 300) return
                 this.swipeItemId = ''
                 return
             }
             this.popAddModelFn(item)
+        },
+        handleItemClickByEvent(event) {
+            this.handleItemClick(this.getEventItem(event))
         },
 		popAddModelFn(info) {
+            this.setActiveItem(info)
             let currentNum = info.currentNum
             let unitPrice = info.unitPrice
             let unitType = info.unitType
@@ -156,17 +255,36 @@ export default {
 			this.showAddModelFn({ ...info, currentNum: currentNum, unitPrice: unitPrice,unitType:unitType,action:'update'})
 		},
         delItem(item){
+            if (!item) return
             this.$util.hitVoice()
             this.swipeItemId = ''
+            this.clearActiveItem(item)
             item.currentNum = 0
             this.replaceItemFn(item)
         },
+        delItemByEvent(event) {
+            this.delItem(this.getEventItem(event))
+        },
         changeItemNum(item, step) {
+            if (!item) return
             this.$util.hitVoice()
             this.swipeItemId = ''
             const currentNum = Number(item.currentNum) || 0
-            item.currentNum = Math.max(0, currentNum + step)
+            const nextNum = Math.max(0, currentNum + step)
+            if (!this.hasEnoughStock(item, nextNum)) {
+                this.showNoStockTip(item)
+                return
+            }
+            item.currentNum = nextNum
+            if (nextNum > 0) {
+                this.setActiveItem(item)
+            } else {
+                this.clearActiveItem(item)
+            }
             this.replaceItemFn(item)
+        },
+        changeItemNumByEvent(event, step) {
+            this.changeItemNum(this.getEventItem(event), step)
         }
     }
 }
@@ -186,6 +304,7 @@ export default {
         margin-bottom:72upx;
         overflow-y: auto;
         flex: 1;
+        height: 0;
         border: 1px solid #eee;
         & .show-item_box {
             padding: 2upx;
@@ -193,9 +312,9 @@ export default {
             overflow: hidden;
             .delete-btn {
                 position: absolute;
-                top: 2upx;
-                right: 2upx;
-                bottom: 2upx;
+                top: 3upx;
+                right: 3upx;
+                bottom: 3upx;
                 width: 40upx;
                 display: flex;
                 align-items: center;
@@ -207,15 +326,19 @@ export default {
             }
             & .item-body_box {
                 position: relative;
-                border-radius: 2upx;
+                border-radius: 4upx;
                 padding: 2upx;
                 font-size: 14upx;
                 color:#666666;
+                border-bottom: 3upx solid transparent;
                 transition: transform 0.2s;
                 z-index: 1;
                 &.is-swiped {
                     transform: translateX(-42upx);
                 }
+                &.is-operated {
+                    border-bottom-color: #3385FF;
+                }
                 &.active {
                     background-color: #d4d6d6;
                 }

+ 3 - 2
ghsPad/src/pages/home/components/rightGoods.vue

@@ -16,7 +16,8 @@
                         <view>
                             <view>{{item.name}}</view>
                             <view style="display:flex;justify-content: space-between;padding-right:2upx;">
-                                <text>¥{{parseFloat(item.price)}}</text><text>剩{{parseFloat(item.stock)}}</text>
+                                <text>¥{{parseFloat(item.price)}}</text>
+                                <text>剩{{parseFloat(item.stock)}}</text>
                             </view>
                         </view>
                     </view>
@@ -36,7 +37,7 @@
     </view>
 </template>
 <script>
-import { getClass } from '@/api/category/index'
+//import { getClass } from '@/api/category/index'
 import { getGoodsList } from '@/api/goods/index'
 import productMins from "@/mixins/product";
 import list from "@/mixins/list";

+ 29 - 3
ghsPad/src/pages/home/components/rightItem.vue

@@ -32,9 +32,9 @@
                     <view v-if="item.variety == 1" class="variety-badge"></view>
                     <view class="shop-info_price">
                         <view>
-                            <view>{{item.name}}</view>
+                            <view @click.stop="quickAddItem(item)">{{item.name}}</view>
                             <view style="display:flex;justify-content: space-between;padding-right:2upx;">
-                                <text>¥{{parseFloat(item.price)}}</text>
+                                <text @click.stop="quickAddItem(item)">¥{{parseFloat(item.price)}}</text>
                                 <text v-if="Number(item.reachNumDiscount)>0 && Number(item.reachNum)>0" style="color:#FFEB3B;">{{ item.reachNum }}↓{{ item.reachNumDiscount?parseFloat(item.reachNumDiscount):0 }}</text>
                                 <text>剩{{parseFloat(item.stock)}}</text>
                             </view>
@@ -185,9 +185,35 @@ export default {
             this.searchKeyword = ''
         },
 		popAddModelFn(info) {
+            const property = info.property !== undefined ? info.property : 1
+            this.notifyOperateItem({ ...info, property })
             this.$util.hitVoice()
-			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
+			this.showAddModelFn({ ...info, property, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
+        quickAddItem(info){
+            const property = info.property !== undefined ? info.property : 1
+            this.notifyOperateItem({ ...info, property })
+            const hasItem = this.selectList.find(item => Number(item.id) == Number(info.id) && Number(item.property) == Number(property))
+            this.$util.hitVoice()
+            if(hasItem){
+                return
+            }
+            const unitName = property == 1 ? (info.bigUnit || info.unitName || '扎') : '份'
+            const unitPrice = property == 1 ? (info.bigPrice || info.price || info.unitPrice) : (info.price || info.unitPrice)
+            this.replaceItemFn({ ...info, property, currentNum: 1, unitPrice, unitType: 0, unitName})
+        },
+        notifyOperateItem(item){
+            this.$emit('operateItem', item)
+        },
+        addItemModelHidden() {
+            if(this.customData && this.customData.id){
+                this.notifyOperateItem(this.customData)
+            }
+            if(this.$refs.selectNumPriceRef){
+                this.$refs.selectNumPriceRef.close()
+            }
+            this.customData = {};
+        },
         refreshMyRightItem(customId){
 			this.globalRightItemCustomId = customId
 			this.itemRefresh()

+ 23 - 3
hdPad/src/pages/home/cash.vue

@@ -12,13 +12,25 @@
 			</view>
 			<!-- 已选花材列表 -->
 			<view class="itemList-box">
-				<leftArea v-if="!$util.isEmpty(selectList)" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"></leftArea>
+				<leftArea
+					v-if="!$util.isEmpty(selectList)"
+					:changeCurrentJobType.sync="currentJobType"
+					:changeCurrentJobId.sync="currentJobId"
+					:activeItemMark="activeItemMark"
+				></leftArea>
 				<leftGroup v-else :customId.sync="customId"></leftGroup>
 			</view>
 			<!-- 分类和花材图片 -->
 			<view class="all-item-area">
 				<rightGoods v-if="currentProperty == 0" ref="rightItemRef" :customId.sync="customId" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"> </rightGoods>
-				<rightItem v-else ref="rightItemRef" :customId.sync="customId" :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"> </rightItem>
+				<rightItem
+					v-else
+					ref="rightItemRef"
+					:customId.sync="customId"
+					:changeCurrentJobType.sync="currentJobType"
+					:changeCurrentJobId.sync="currentJobId"
+					@operateItem="setActiveItemMark"
+				> </rightItem>
 			</view>
 			<!-- 按钮操作 -->
 			<view class="open-box">
@@ -84,7 +96,8 @@ export default {
 			myCustomList:[],
 			mustUpdate:false,
 			reduceOrderId:0,
-			reduceStock:0
+			reduceStock:0,
+			activeItemMark:{ key:'', time:0 }
 		}
 	},
 	computed: {
@@ -240,6 +253,13 @@ export default {
 		},
 		changeProperty(property){
 			this.currentProperty = property
+		},
+		setActiveItemMark(item){
+			const property = item.property !== undefined ? item.property : 1
+			this.activeItemMark = {
+				key: `${item.id}_${property}`,
+				time: Date.now()
+			}
 		}
 	}
 };

+ 140 - 17
hdPad/src/pages/home/components/leftArea.vue

@@ -4,26 +4,38 @@
             列表
             <text style="float:right;">{{ getMyShopInfo.shop.shopName=='首店'? getMyShopInfo.shop.merchantName: getMyShopInfo.shop.merchantName+' '+getMyShopInfo.shop.shopName}}</text>
         </view>
-        <view class="itemList-item_box">
+        <scroll-view
+            class="itemList-item_box"
+            scroll-y
+            scroll-with-animation
+            :scroll-into-view="activeScrollIntoView"
+        >
             <view
                 v-for="item in selectList"
-                :key="item.id"
+                :key="getItemKey(item)"
+                :id="getItemScrollId(item)"
+                :data-item-key="getItemKey(item)"
                 class="show-item_box"
-                @touchstart="onItemTouchStart(item, $event)"
-                @touchmove="onItemTouchMove(item, $event)"
-                @touchend="onItemTouchEnd(item)"
-                @touchcancel="onItemTouchEnd(item)"
+                @touchstart="onItemTouchStartByEvent"
+                @touchmove="onItemTouchMoveByEvent"
+                @touchend="onItemTouchEndByEvent"
+                @touchcancel="onItemTouchEndByEvent"
             >
-                <view class="delete-btn" @click.stop="delItem(item)">删除</view>
-                <view class="item-body_box not-active" :class="{'is-swiped': swipeItemId === item.id}" @click="handleItemClick(item)">
+                <view class="delete-btn" :data-item-key="getItemKey(item)" @click.stop="delItemByEvent">删除</view>
+                <view
+                    class="item-body_box not-active"
+                    :data-item-key="getItemKey(item)"
+                    :class="{'is-swiped': swipeItemId === item.id, 'is-operated': activeItemKey === getItemKey(item)}"
+                    @click="handleItemClickByEvent"
+                >
                     <view class="flower-name_box">
                         <view class="current-item-title">
                             <text class="name">{{item.name}}</text>
                             <view class="num-action_box">
-                                <view class="num-btn" @click.stop="changeItemNum(item, -1)">
+                                <view class="num-btn" :data-item-key="getItemKey(item)" @click.stop="changeItemNumByEvent($event, -1)">
                                     <zui-svg-icon icon="general-sub" :width="28" :height="28" color="#8abf8a" />
                                 </view>
-                                <view class="num-btn" @click.stop="changeItemNum(item, 1)">
+                                <view class="num-btn" :data-item-key="getItemKey(item)" @click.stop="changeItemNumByEvent($event, 1)">
                                     <zui-svg-icon icon="general-plus" :width="28" :height="28" color="#8abf8a" />
                                 </view>
                             </view>
@@ -42,7 +54,7 @@
                     </view>
                 </view>
             </view>
-        </view>
+        </scroll-view>
         <view class="itemList-footer_box">
             <view> 数量
                 <text style="margin-left:5upx;">
@@ -75,6 +87,12 @@ export default {
         changeCurrentJobId:{
 			type: Number,
 			default: 0
+        },
+        activeItemMark:{
+            type: Object,
+            default(){
+                return { key:'', time:0 }
+            }
         }
     },
     data(){
@@ -82,6 +100,8 @@ export default {
             totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
             itemList:[],
             swipeItemId: '',
+            activeItemKey: '',
+            activeScrollIntoView: '',
             touchStartX: 0,
             touchStartY: 0,
             isHorizontalSwipe: false,
@@ -100,6 +120,23 @@ export default {
                 this.currentJobId = id
             },
             immediate:true
+        },
+        activeItemMark:{
+            handler(mark){
+                if(mark && mark.key){
+                    this.activeItemKey = mark.key
+                    this.scrollToActiveItemByKey(mark.key)
+                }
+            },
+            immediate:true
+        },
+        selectList:{
+            handler(){
+                if(this.activeItemKey){
+                    this.scrollToActiveItemByKey(this.activeItemKey)
+                }
+            },
+            deep:true
         }
     },
 	computed:{
@@ -110,14 +147,64 @@ export default {
             const touches = event.changedTouches || event.touches || []
             return touches[0]
         },
+        getItemKey(item) {
+            const property = item.property !== undefined ? item.property : 1
+            return `${item.id}_${property}`
+        },
+        getScrollIdByKey(key) {
+            return `select-item-${key}`
+        },
+        getItemScrollId(item) {
+            return this.getScrollIdByKey(this.getItemKey(item))
+        },
+        getEventItem(event) {
+            const dataset = event && event.currentTarget && event.currentTarget.dataset
+            const key = dataset && dataset.itemKey
+            if (!key) return null
+            return this.selectList.find(item => this.getItemKey(item) === key)
+        },
+        scrollToActiveItemByKey(key) {
+            this.activeScrollIntoView = ''
+            this.$nextTick(() => {
+                this.activeScrollIntoView = this.getScrollIdByKey(key)
+            })
+        },
+        setActiveItem(item) {
+            const key = this.getItemKey(item)
+            this.activeItemKey = key
+            this.scrollToActiveItemByKey(key)
+        },
+        clearActiveItem(item) {
+            if (this.activeItemKey === this.getItemKey(item)) {
+                this.activeItemKey = ''
+                this.activeScrollIntoView = ''
+            }
+        },
+        hasEnoughStock(item, num) {
+            if (!this.checkStock || num <= 0) return true
+            if (item.unitType == 0) {
+                return Number(num) <= Number(item.stock)
+            }
+            const stockNum = (Number(num) / Number(item.ratio)).toFixed(2)
+            return Number(stockNum) <= Number(item.stock)
+        },
+        showNoStockTip(item) {
+            this.$util.noStockRemind()
+            this.$msg(item.unitType == 0 ? "库存不足" : "库存不足哦")
+        },
         onItemTouchStart(item, event) {
+            if (!item) return
             const touch = this.getTouchPoint(event)
             if (!touch) return
             this.touchStartX = touch.clientX
             this.touchStartY = touch.clientY
             this.isHorizontalSwipe = false
         },
+        onItemTouchStartByEvent(event) {
+            this.onItemTouchStart(this.getEventItem(event), event)
+        },
         onItemTouchMove(item, event) {
+            if (!item) return
             const touch = this.getTouchPoint(event)
             if (!touch) return
             const moveX = touch.clientX - this.touchStartX
@@ -126,7 +213,11 @@ export default {
             this.isHorizontalSwipe = true
             this.swipeItemId = moveX < 0 ? item.id : ''
         },
-        onItemTouchEnd() {
+        onItemTouchMoveByEvent(event) {
+            this.onItemTouchMove(this.getEventItem(event), event)
+        },
+        onItemTouchEnd(item) {
+            if (!item) return
             if (this.isHorizontalSwipe) {
                 this.lastSwipeTime = Date.now()
             }
@@ -134,15 +225,23 @@ export default {
             this.touchStartY = 0
             this.isHorizontalSwipe = false
         },
+        onItemTouchEndByEvent(event) {
+            this.onItemTouchEnd(this.getEventItem(event))
+        },
         handleItemClick(item) {
+            if (!item) return
             if (this.swipeItemId === item.id) {
                 if (Date.now() - this.lastSwipeTime < 300) return
                 this.swipeItemId = ''
                 return
             }
             this.popAddModelFn(item)
+        },
+        handleItemClickByEvent(event) {
+            this.handleItemClick(this.getEventItem(event))
         },
 		popAddModelFn(info) {
+            this.setActiveItem(info)
             let currentNum = info.currentNum
             let unitPrice = info.unitPrice
             let unitType = info.unitType
@@ -150,17 +249,36 @@ export default {
 			this.showAddModelFn({ ...info, currentNum: currentNum, unitPrice: unitPrice,unitType:unitType,action:'update'})
 		},
         delItem(item){
+            if (!item) return
             this.$util.hitVoice()
             this.swipeItemId = ''
+            this.clearActiveItem(item)
             item.currentNum = 0
             this.replaceItemFn(item)
         },
+        delItemByEvent(event) {
+            this.delItem(this.getEventItem(event))
+        },
         changeItemNum(item, step) {
+            if (!item) return
             this.$util.hitVoice()
             this.swipeItemId = ''
             const currentNum = Number(item.currentNum) || 0
-            item.currentNum = Math.max(0, currentNum + step)
+            const nextNum = Math.max(0, currentNum + step)
+            if (!this.hasEnoughStock(item, nextNum)) {
+                this.showNoStockTip(item)
+                return
+            }
+            item.currentNum = nextNum
+            if (nextNum > 0) {
+                this.setActiveItem(item)
+            } else {
+                this.clearActiveItem(item)
+            }
             this.replaceItemFn(item)
+        },
+        changeItemNumByEvent(event, step) {
+            this.changeItemNum(this.getEventItem(event), step)
         }
     }
 }
@@ -180,6 +298,7 @@ export default {
         margin-bottom:72upx;
         overflow-y: auto;
         flex: 1;
+        height: 0;
         border: 1px solid #eee;
         & .show-item_box {
             padding: 2upx;
@@ -187,9 +306,9 @@ export default {
             overflow: hidden;
             .delete-btn {
                 position: absolute;
-                top: 2upx;
-                right: 2upx;
-                bottom: 2upx;
+                top: 3upx;
+                right: 3upx;
+                bottom: 3upx;
                 width: 40upx;
                 display: flex;
                 align-items: center;
@@ -201,15 +320,19 @@ export default {
             }
             & .item-body_box {
                 position: relative;
-                border-radius: 2upx;
+                border-radius: 4upx;
                 padding: 2upx;
                 font-size: 14upx;
                 color:#666666;
+                border-bottom: 3upx solid transparent;
                 transition: transform 0.2s;
                 z-index: 1;
                 &.is-swiped {
                     transform: translateX(-42upx);
                 }
+                &.is-operated {
+                    border-bottom-color: #8abf8a;
+                }
                 &.active {
                     background-color: #d4d6d6;
                 }

+ 2 - 1
hdPad/src/pages/home/components/rightGoods.vue

@@ -19,7 +19,8 @@
                             <view>
                                 <view>{{item.name}}</view>
                                 <view style="display:flex;justify-content: space-between;padding-right:2upx;">
-                                    <text>¥{{parseFloat(item.price)}}</text><text>剩{{parseFloat(item.stock)}}</text>
+                                    <text>¥{{parseFloat(item.price)}}</text>
+                                    <text>剩{{parseFloat(item.stock)}}</text>
                                 </view>
                             </view>
                         </view>

+ 30 - 3
hdPad/src/pages/home/components/rightItem.vue

@@ -30,9 +30,10 @@
                     <image class="img" :src="item.cover" lazy-load="true" :lazy-load-margin="0" mode="scaleToFill" ></image>
                     <view class="shop-info_price">
                         <view>
-                            <view>{{item.name}}</view>
+                            <view @click.stop="quickAddItem(item)">{{item.name}}</view>
                             <view style="display:flex;justify-content: space-between;padding-right:2upx;">
-                                <text>¥{{parseFloat(item.price)}}</text><text>剩{{parseFloat(item.stock)}}</text>
+                                <text @click.stop="quickAddItem(item)">¥{{parseFloat(item.price)}}</text>
+                                <text>剩{{parseFloat(item.stock)}}</text>
                             </view>
                         </view>
                     </view>
@@ -179,9 +180,35 @@ export default {
             this.searchKeyword = ''
         },
 		popAddModelFn(info) {
+            const property = info.property !== undefined ? info.property : 1
+            this.notifyOperateItem({ ...info, property })
             this.$util.hitVoice()
-			this.showAddModelFn({ ...info, currentNum: 1, unitPrice: info.price,unitType:0})
+			this.showAddModelFn({ ...info, property, currentNum: 1, unitPrice: info.price,unitType:0})
 		},
+        quickAddItem(info){
+            const property = info.property !== undefined ? info.property : 1
+            this.notifyOperateItem({ ...info, property })
+            const hasItem = this.selectList.find(item => Number(item.id) == Number(info.id) && Number(item.property) == Number(property))
+            this.$util.hitVoice()
+            if(hasItem){
+                return
+            }
+            const unitName = property == 1 ? (info.bigUnit || info.unitName || '扎') : '份'
+            const unitPrice = property == 1 ? (info.bigPrice || info.price || info.unitPrice) : (info.price || info.unitPrice)
+            this.replaceItemFn({ ...info, property, currentNum: 1, unitPrice, unitType: 0, unitName})
+        },
+        notifyOperateItem(item){
+            this.$emit('operateItem', item)
+        },
+        addItemModelHidden() {
+            if(this.customData && this.customData.id){
+                this.notifyOperateItem(this.customData)
+            }
+            if(this.$refs.selectNumPriceRef){
+                this.$refs.selectNumPriceRef.close()
+            }
+            this.customData = {};
+        },
         renewMyRightItem(customId){
             this.globalRightItemCustomId = customId
             this.globalItemRefresh(customId)