fuwei 4 лет назад
Родитель
Сommit
d83f1847cf

+ 2 - 3
ghsPad/src/admin/home/components/select-user.vue

@@ -71,8 +71,8 @@ export default {
 	 async init() {
 		 try {
 		let { data:{list} } = await customList({
-																								name: this.searchUser
-																							})
+															name: this.searchUser
+														})
 			this.list = list
 		 }catch(err) {
 
@@ -88,7 +88,6 @@ export default {
       } else {
         this.searchUser += e.char;
       }
-
     },
     enter() {
 					 this.init()

+ 25 - 24
ghsPad/src/admin/home/components/shopTypeSelect.vue

@@ -30,29 +30,29 @@
             </view>
         </view>
         <view class="shop-footer_box">
-            <view class="btn-breakage">
+										<slot name="footer"></slot>
+            <!-- <view class="btn-breakage">
                 报损
             </view>
             <view
                 @click="settle"
                 class="btn-account">
                 结算
-            </view>
+            </view> -->
         </view>
-        <uniPopup
+        <!-- <uniPopup
             :show.sync="isShowFllowNum"
             type="top"
-            maxHeight="90vh"
-		>
-			<keyboardSetFlower :selectItem.sync="selectItem"></keyboardSetFlower>
-		</uniPopup>
-		<uniPopup
-            :show.sync="isShowSettle"
-            type="top"
-            maxHeight="90vh"
-            >
-			<selectSettle></selectSettle>
-		</uniPopup>
+            maxHeight="90vh">
+								<keyboardSetFlower :selectItem.sync="selectItem"></keyboardSetFlower>
+							</uniPopup> -->
+							<uniPopup
+																:show.sync="isShowSettle"
+																type="top"
+																maxHeight="90vh"
+																>
+							<selectSettle></selectSettle>
+						</uniPopup>
     </view>
 </template>
 
@@ -74,7 +74,7 @@
                 selectTypeId: '',
                 arrShop:[],
                 currenTypeShopList:[],
-                isShowFllowNum: false,
+                // isShowFllowNum: false,
                 isShowSettle: false,
                 selectItem:{}
             }
@@ -114,15 +114,16 @@
                 this.updateCurrentShop()
             },
             selectItemChange(item){
-                this.selectItem = {
-                    ...item,
-                    currentUnit:item.bigUnit,
-                    currentUnitPrice:item.property==1?item.bigPrice:item.price,
-                    currentNum: 0,
-																				unitType: 0
-                }
-																console.log(33333,this.selectItem)
-                this.isShowFllowNum = true
+															this.$emit('selectItemChange',item)
+                // this.selectItem = {
+                //     ...item,
+                //     currentUnit:item.bigUnit,
+                //     currentUnitPrice:item.property==1?item.bigPrice:item.price,
+                //     currentNum: 0,
+																// 				unitType: 0
+                // }
+																// console.log(33333,this.selectItem)
+                // this.isShowFllowNum = true
             },
             settle(){
                 this.isShowSettle = true

+ 93 - 23
ghsPad/src/admin/home/workbench.vue

@@ -8,21 +8,27 @@
 		<view class="shopList-box">
 			<view class="title">商品列表</view>
 			<view class="shopList-item_box">
-				<view class="shop-item_box">
-					<view class="shop-body_box">
+				<view
+				v-for="item in shopList"
+				:key="item.id"
+				@click="selectCurrentActive(item)"
+				class="shop-item_box">
+					<view :class="[
+						'shop-body_box',
+					selectCurrentActiveItem.id===item.id?'active':'']">
 						<view class="flower-name_box">
 							<view class="name">
-								小菊
+								{{item.name}}
 							</view>
 						</view>
 						<view>
-							<view>25元/支</view>
-							<view>5支</view>
-							<view>¥108</view>
+							<view>{{item.currentUnitPrice}}元/{{item.currentUnit}}</view>
+							<view>{{item.currentNum}} {{item.currentUnit}}</view>
+							<view>¥{{item.currentNum * item.currentUnitPrice}}</view>
 						</view>
 					</view>
 				</view>
-				<view class="shop-item_box">
+				<!-- <view class="shop-item_box">
 					<view class="shop-body_box">
 						<view class="flower-name_box">
 							<view class="name">
@@ -35,18 +41,19 @@
 							<view>¥108</view>
 						</view>
 					</view>
-				</view>
+				</view> -->
 			</view>
 			<view class="shopList-footer_box">
 				<view>
 					数量:
 					<text style="fontWeight:bold">
-						8扎5支
+						<!-- 8扎5支 -->
+						{{totalShop.bigUnit}}扎 {{totalShop.smallUnit}}支
 					</text>
 				</view>
 				<view>
 					合计:
-					<text style="color:red">¥123</text>
+					<text style="color:red">¥{{totalShop.totalPrice}}</text>
 				</view>
 			</view>
 		</view>
@@ -54,9 +61,9 @@
 			<view @click="selectUser">
 				客户
 			</view>
-			<view class="active">
+			<!-- <view class="active">
-			</view>
+			</view> -->
 			<view @click="deleteShop">
 				删除商品
 			</view>
@@ -65,14 +72,21 @@
 			</view>
 		</view>
 		<view class="shop-list">
-			<shopTypeSelect></shopTypeSelect>
+			<shopTypeSelect @selectItemChange="selectItemChange"></shopTypeSelect>
 		</view>
 		<uniPopup
 		:show.sync="isShowUser"
 		type="top"
 		maxHeight="90vh"
 		>
-			<selectUser @selectUser="selectUserReturn"></selectUser>
+			<selectUser @selectUser="selectUserReturn">
+			</selectUser>
+		</uniPopup>
+		<uniPopup
+		     :show.sync="isShowFllowNum"
+		     type="top"
+		     maxHeight="90vh">
+			<keyboardSetFlower @enterNum="enterReturn" :selectItem.sync="selectItem"></keyboardSetFlower>
 		</uniPopup>
 		<NotLogin></NotLogin>
 	</view>
@@ -83,13 +97,13 @@ import NotLogin from "@/components/not-login";
 import productMins from "@/mixins/product";
 import autoUpdateMixins from "@/mixins/autoUpdate";
 import uniPopup from '@/components/uni-popup'
-// import keyboardSetFlower from '@/components/app-boardSet-flower.vue'
+import keyboardSetFlower from '@/components/app-boardSet-flower.vue'
 // import selectSettle from './components/select-settle.vue'
 import selectUser from './components/select-user.vue'
 import shopTypeSelect from './components/shopTypeSelect.vue'
 export default {
 	name: "workbench",
-	components: { NotLogin,uniPopup,selectUser,shopTypeSelect },
+	components: { NotLogin,uniPopup,selectUser,shopTypeSelect,keyboardSetFlower },
 	mixins: [productMins,autoUpdateMixins],
 	data() {
 		return {
@@ -97,7 +111,14 @@ export default {
 			isShowUser: false,
 			isShowSettle: false,
 			shopList:[],
-			currenSelectShop:{}
+			currenSelectShop:{},
+			selectItem: {},
+			selectCurrentActiveItem:{},
+			totalShop:{
+					bigUnit: 0,
+					smallUnit:0,
+					totalPrice: 0
+			}
 		};
 	},
 	computed: {
@@ -112,15 +133,43 @@ export default {
 	},
 	onShow() {
 	},
+	watch:{
+			shopList(){
+							if(this.$util.isEmpty(this.shopList)) {
+									this.totalShop = {
+											bigUnit: 0,
+											smallUnit:0,
+											totalPrice: 0
+										}
+							}
+						this.totalShop =	this.shopList.reduce((total,val)=>{
+									// 0 大单位 1小单位
+									if(val.unitType === 0) {
+										total.bigUnit = total.bigUnit + (val.currentNum *1)
+									}else {
+										total.smallUnit = total.smallUnit +(1*val.currentNum)
+									}
+										total.totalPrice = total.totalPrice +  (1*val.currentNum) * (val.currentUnitPrice*1)
+									return total
+							},{
+								bigUnit: 0,
+								smallUnit:0,
+								totalPrice: 0
+							})
+			}
+	},
 	methods: {
+		selectCurrentActive(item){
+				this.selectCurrentActiveItem = item
+		},
 		selectUserReturn(val){
 					this.isShowUser = false
 		},
 		init() {
 		},
-		selectItem(){
-			this.isShowFllowNum = true
-		},
+		// selectItem(){
+		// 	this.isShowFllowNum = true
+		// },
 		selectUser(){
 			this.isShowUser = true
 		},
@@ -131,7 +180,26 @@ export default {
 			this.shopList = []
 		},
 		deleteShop(){
-			
+			if(this.$util.isEmpty(this.selectCurrentActiveItem)) {
+					this.$msg('请选择要删除的商品')
+			}
+		let index =	this.shopList.findIndex(i=>this.selectCurrentActiveItem.id === i.id)
+		this.shopList = this.shopList.filter(i=>this.selectCurrentActiveItem.id !== i.id)
+		// this.selectCurrentActiveItem
+		},
+		selectItemChange(item){
+		    this.selectItem = {
+		        ...item,
+		        currentUnit:item.bigUnit,
+		        currentUnitPrice:item.property==1?item.bigPrice:item.price,
+		        currentNum: 0,
+										unitType: 0
+		    }
+		    this.isShowFllowNum = true
+		},
+		enterReturn(item){
+			this.isShowFllowNum = false
+			this.shopList.push(item)
 		}
 	}
 };
@@ -172,13 +240,15 @@ export default {
 			}
 			& .shopList-item_box {
 				flex: 1;
-			    border: 1px solid #eee;
+			 border: 1px solid #eee;
 				& .shop-item_box {
 					padding: 5rpx;
 					& .shop-body_box {
-						background-color: #f2f8f8;
 						padding: 5rpx;
 						font-size: 14rpx;
+						&.active {
+							background-color: #f2f8f8;
+						}
 						& .flower-name_box {
 							padding: 0 5rpx;
 							& .name {

+ 7 - 7
ghsPad/src/components/app-boardSet-flower.vue

@@ -68,12 +68,7 @@
 							};
 		},
 		mounted(){
-
 					this.activeKeyboard()
-					this.currentUnit = 	this.selectItem.currentUnit
-					this.currentPrice = this.selectItem.currentUnitPrice
-
-
 
 		},
 		methods: {
@@ -100,13 +95,18 @@
 			},
 			enter() {
 				//this.$refs.keyboard.deactivate();
+				if(this.selectItem.currentNum  <= 0) {
+							this.$msg('数量不能为空')
+				}
+				this.$emit('enterNum', this.selectItem)
+
 			},
 			changeUnit(){
-							
+
 
 								this.selectItem.unitType = this.selectItem.unitType === 0?1:0
 								this.selectItem.currentUnit = this.selectItem.unitType ===0?this.selectItem.bigUnit:this.selectItem.smallUnit
-									this.$emit('update:selectItem', this.selectItem)
+								this.$emit('update:selectItem', this.selectItem)
 
 
 			}