shish пре 4 година
родитељ
комит
c1c069b6b8

+ 114 - 0
ghsPad/src/admin/home/components/leftItem.vue

@@ -0,0 +1,114 @@
+<template>
+    <view class="itemList-box">
+        <view class="title">花材列表</view>
+        <view class="itemList-item_box">
+            <view v-for="item in itemList" :key="item.id" @click="selectCurrentActive(item)" class="show-item_box">
+                <view :class="[ 'item-body_box', selectCurrentActiveItem.id===item.id?'active':'not-active']">
+                    <view class="flower-name_box">
+                        <view class="current-item-title"><text class="name">{{item.name}}</text><text @click.stop="delSelectItem" class="del">删除</text></view>
+                    </view>
+                    <view class="item-price-num">
+                        <view>{{parseFloat(item.currentUnitPrice)}}元/{{item.currentUnit}}</view>
+                        <view>{{item.currentNum}} {{item.currentUnit}}</view>
+                        <view>¥{{item.currentNum * item.currentUnitPrice}}</view>
+                    </view>
+                </view>
+            </view>
+        </view>
+        <view class="itemList-footer_box">
+            <view> 数量
+                <text style="margin-left:5upx;">
+                    <text v-if="Number(totalShop.bigUnit)>0">{{totalShop.bigUnit}}扎</text>
+                    <text v-if="Number(totalShop.smallUnit)>0">{{totalShop.smallUnit}}支</text>
+                </text>
+            </view>
+            <view> 合计 <text style="margin-left:5upx;">¥{{totalShop.totalPrice}}</text> </view>
+        </view>
+    </view>
+</template>
+<script>
+export default {
+    name:'leftItem',
+    mixins:{},
+    components:{},
+	props: {
+    },
+    data(){
+        return {
+            totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
+            itemList:[]
+        }
+    },
+    methods:{
+    }
+}
+</script>
+<style lang="scss" scoped>
+.itemList-box {
+    height: 100%;
+    display: flex;
+    flex-direction: column;
+    & .title {
+        padding: 3upx;
+        font-size: 12upx;
+        background-color: rgba(72, 91, 107, 1);
+        color: #FFFFFF;
+    }
+    & .itemList-item_box {
+        overflow-y: auto;
+        flex: 1;
+        border: 1px solid #eee;
+        & .show-item_box {
+            padding: 2upx;
+            & .item-body_box {
+                border-radius: 2upx;
+                padding: 2upx;
+                font-size: 14upx;
+                color:#666666;
+                &.active {
+                    background-color: #d4d6d6;
+                }
+                &.not-active {
+                    background-color: #e7e9e9;
+                }
+                .item-price-num{
+                    color:#afaeae;
+                    font-size:10upx;
+                }
+                & .flower-name_box {
+                    padding: 0 5upx;
+                    .current-item-title {
+                        .name{
+                            color: #333333;
+                            font-weight: bold;
+                            overflow: hidden;
+                            text-overflow:ellipsis;
+                            white-space: nowrap;
+                            width:50upx;
+                        }
+                        .del{
+                            color:orange;
+                            font-size:12upx;
+                            float:right;
+                        }
+                    }
+                }
+                & > view:nth-child(2) {
+                    display: flex;
+                    align-items: center;
+                    justify-content: space-between;
+                    padding-top: 15upx;
+                }
+            }
+        }
+    }
+    & .itemList-footer_box {
+        height: 20upx;
+        border: 1px solid #eee;
+        font-size: 10upx;
+        display: flex;
+        align-items: center;
+        justify-content: space-around;
+    }
+}
+</style>

+ 48 - 2
ghsPad/src/admin/home/components/middleButton.vue

@@ -36,10 +36,10 @@
 import settlePop from './settle-pop.vue'
 import selectUser from './select-user.vue'
 import selectPayWay from '@/components/select-pay-way.vue'
-import productMins from "@/mixins/product";
+import { createCreateOrder, wastageCreateOrder } from '@/api/home/index'
 export default {
     name:'middleButton',
-    mixins:{productMins},
+    mixins:{},
     components:{ settlePop,selectUser,selectPayWay },
 	props: {
     },
@@ -55,6 +55,52 @@ export default {
 
 	},
     methods:{
+		//结算创建订单
+		async setCreateOrder(){
+			try {
+				let arr = this.itemList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum, property: i.property, unitPrice: i.currentUnitPrice }))
+				const {settleId,payId,payUserId,isPrint,proceeds,freight} = this.$refs.settlePop
+				await createCreateOrder({
+					customId: this.selectItemUser.id,
+					product: JSON.stringify(arr),
+					modifyPrice: proceeds,
+					sendType: 1,
+					hasPay: settleId,
+					payWay: payId,
+					getUserId: payUserId,
+					needPrint: isPrint,
+					sendCost: freight,
+					remark:''
+				})
+				this.$refs.settlePopRef.close()
+				this.$refs.selectPayWayRef.open('center')
+				this.$msg('订单创建成功')
+			}catch(err) {
+				console.log(err)
+			}
+		},
+		cancelPay(){
+			this.$refs.selectPayWayRef.close()
+		},
+		async settleReturn(){
+			this.setCreateOrder()
+		},
+		selectCurrentActive(item){
+				this.selectCurrentActiveItem = item
+		},
+		selectUserReturn(val){
+			this.selectItemUser = val
+			this.$refs.selectUserRef.close()
+		},
+		cancelSelectUser(){
+			this.$refs.selectUserRef.close()
+		},
+		selectUser(){
+			this.$refs.selectUserRef.open('center')
+		},
+		selectPayWayBack(price){
+			console.log(price)
+		},
 		breakage(){
 			if(this.$util.isEmpty(this.itemList)) {
 				this.$msg('请选择报损花材')

+ 0 - 85
ghsPad/src/admin/home/components/rightItem.vue

@@ -1,85 +0,0 @@
-<template>
-<view class="item-detail" @click="showAddModelFn(info)">
-    <image class="img" :src="info.cover" mode="scaleToFill" ></image>
-    <view class="shop-info_price">
-        <view>
-            <view>{{info.name}}</view>
-            <view>¥{{parseFloat(info.price)}}</view>
-        </view>
-    </view>
-</view>
-</template>
-<script>
-export default {
-    name:'rightItem',
-    components:{  },
-	props: {
-		info: {
-			required: true,
-			type: Object,
-			default() {
-				return {};
-			}
-		}
-    },
-    data(){
-        return {
-			bigCount:0,
-			smallCount:0,
-			userPrice:0
-        }
-    },
-    created(){
-
-    },
-	watch:{
-		info:{
-			handler(){
-				this.bigCount = this.info.bigCount
-				this.smallCount = this.info.smallCount
-				this.userPrice = this.info.userPrice
-			},
-			deep:true
-		}
-	},
-    methods:{
-		showAddModelFn() {
-			this.$emit("showAddModelFn", { ...this.info, bigCount: this.bigCount, smallCount: this.smallCount, userPrice: this.userPrice})
-		}
-    }
-}
-</script>
-<style lang="scss" scoped>
-.item-detail{
-    position: relative;
-    margin-right: 9upx;
-    margin-bottom: 6upx;
-    width: 82upx;
-    height: 82upx;
-    & .img {
-        width: 82upx;
-        height: 82upx;
-    }
-    .shop-info_price {
-        position: absolute;
-        background-color: rgba(0, 0, 0, 0.5);
-        bottom: 0;
-        width: 100%;
-        font-size: 12upx;
-        color: #ffffff;
-        height:25upx;
-        & > view {
-            font-size: 10upx;
-            & > view:nth-child(1) {
-                overflow: hidden;
-                text-overflow:ellipsis;
-                white-space: nowrap;
-                width:90%;
-            }
-            & > view:nth-child(2) {
-                font-size:8upx;
-            }
-        }
-    }
-}
-</style>

+ 57 - 16
ghsPad/src/admin/home/components/rightItemArea.vue

@@ -1,30 +1,39 @@
 <template>
     <view class="shop-listType_box">
         <view class="shop-type_box">
-            <view v-for="item in shopListType" :key="item.id" :class="[categoryId===item.id?'active':'']" @click="changeType(item)" > {{item.name}} </view>
+            <view v-for="item in shopListType" :key="item.id" :class="[categoryId===item.id?'active':'']" @click="changeCategory(item)" > {{item.name}} </view>
         </view>
         <view class="shop-show_box">
             <view v-for="item in currenTypeShopList" :key="item.id" class="show-shop_box">
-                <rightItemComponent @showAddModelFn="showAddModelFn" :info="item"></rightItemComponent>
+                <view class="item-detail" @click="popAddModelFn(item)">
+                    <image class="img" :src="item.cover" mode="scaleToFill" ></image>
+                    <view class="shop-info_price">
+                        <view>
+                            <view>{{item.name}}</view>
+                            <view>¥{{parseFloat(item.price)}}</view>
+                        </view>
+                    </view>
+                </view>
             </view>
         </view>
         <slot name="footer"></slot>
 
         <!-- 开单选花材输入数量和金额 -->
         <uni-popup ref="kdSelectNumPriceRef" background-color="#fff" type="center" :animation="false">
-            <kdSelectNumPrice @enterNum="confirmAddItemModel" :selectItem.sync="selectItem" @cancelKdSelectNumPrice="addItemModelHidden"></kdSelectNumPrice>
+            <kdSelectNumPrice @enterNum="confirmAddItemModel" :customData.sync="customData" @cancelKdSelectNumPrice="addItemModelHidden"></kdSelectNumPrice>
         </uni-popup>
 
     </view>
 </template>
 <script>
 import settlePop from './settle-pop.vue'
-import rightItemComponent from './rightItem.vue'
 import { showClass,showList } from '@/api/home/index'
+import productMins from "@/mixins/product";
 import kdSelectNumPrice from '@/components/app-kd-select-num-price.vue'
 export default {
     name:'rightItemArea',
-    components:{ settlePop,rightItemComponent,kdSelectNumPrice },
+    components:{ settlePop,kdSelectNumPrice },
+	mixins: [productMins],
     data(){
         return {
             shopListType:[],
@@ -32,7 +41,7 @@ export default {
             arrShop:[],
             currenTypeShopList:[],
             isShowSettle: false,
-            selectItem:{}
+            selectJobType:'bill'
         }
     },
     created(){
@@ -42,9 +51,8 @@ export default {
 
     },
     methods:{
-		showAddModelFn(item) {
-            this.$refs.kdSelectNumPriceRef.open('center')
-			//this.$emit("showAddModelFn", { ...item, bigCount: 1, smallCount: '', userPrice: item.price})
+		popAddModelFn(info) {
+			this.showAddModelFn({ ...info, buyNum: 1, unitPrice: info.price,unitType:0})
 		},
         async init(){
             let { data } =  await showClass()
@@ -53,17 +61,14 @@ export default {
             this.getShowList()
         },
         async getShowList(){
-            try {
-                let { data:{list} } =  await showList({})
-                this.arrShop = list
-                this.updateCurrentShop()
-            }catch(err){
-            }
+            let { data:{list} } =  await showList({})
+            this.arrShop = list
+            this.updateCurrentShop()
         },
         updateCurrentShop(){
             this.currenTypeShopList = this.arrShop[this.categoryId]
         },
-        changeType(item){
+        changeCategory(item){
             if(item.id === this.categoryId){
                 return false
             }
@@ -83,6 +88,42 @@ export default {
     display: flex;
     flex-direction: column;
     box-sizing: border-box;
+    & .shop-show_box{
+        & .show-shop_box{
+            & .item-detail{
+                position: relative;
+                margin-right: 9upx;
+                margin-bottom: 6upx;
+                width: 82upx;
+                height: 82upx;
+                & .img {
+                    width: 82upx;
+                    height: 82upx;
+                }
+                .shop-info_price {
+                    position: absolute;
+                    background-color: rgba(0, 0, 0, 0.5);
+                    bottom: 0;
+                    width: 100%;
+                    font-size: 12upx;
+                    color: #ffffff;
+                    height:25upx;
+                    & > view {
+                        font-size: 10upx;
+                        & > view:nth-child(1) {
+                            overflow: hidden;
+                            text-overflow:ellipsis;
+                            white-space: nowrap;
+                            width:90%;
+                        }
+                        & > view:nth-child(2) {
+                            font-size:8upx;
+                        }
+                    }
+                }
+            }
+        }
+    }
     & .shop-type_box {
         max-height: 300upx;
         display: flex;

+ 11 - 161
ghsPad/src/admin/home/workbench.vue

@@ -8,31 +8,9 @@
 			<view class="nav-left">
 				<view class="item-list"> 收银 </view>
 			</view>
+			<!-- 已选花材列表 -->
 			<view class="itemList-box">
-				<view class="title">花材列表</view>
-				<view class="itemList-item_box">
-					<view v-for="item in itemList" :key="item.id" @click="selectCurrentActive(item)" class="show-item_box">
-						<view :class="[ 'item-body_box', selectCurrentActiveItem.id===item.id?'active':'not-active']">
-							<view class="flower-name_box">
-								<view class="current-item-title"><text class="name">{{item.name}}</text><text @click.stop="delSelectItem" class="del">删除</text></view>
-							</view>
-							<view class="item-price-num">
-								<view>{{parseFloat(item.currentUnitPrice)}}元/{{item.currentUnit}}</view>
-								<view>{{item.currentNum}} {{item.currentUnit}}</view>
-								<view>¥{{item.currentNum * item.currentUnitPrice}}</view>
-							</view>
-						</view>
-					</view>
-				</view>
-				<view class="itemList-footer_box">
-					<view> 数量
-						<text style="margin-left:5upx;">
-							<text v-if="Number(totalShop.bigUnit)>0">{{totalShop.bigUnit}}扎</text>
-							<text v-if="Number(totalShop.smallUnit)>0">{{totalShop.smallUnit}}支</text>
-						</text>
-					</view>
-					<view> 合计 <text style="margin-left:5upx;">¥{{totalShop.totalPrice}}</text> </view>
-				</view>
+				<leftItemComponent></leftItemComponent>
 			</view>
 			<!-- 按钮操作 -->
 			<view class="open-box">
@@ -40,43 +18,39 @@
 			</view>
 			<!-- 分类和花材图片 -->
 			<view class="all-item-area">
-				<rightItemArea @showAddModelFn="showAddModelFn"> </rightItemArea>
+				<rightItemArea> </rightItemArea>
 			</view>
 		</view>
 	</view>
 </view>
 </template>
 <script>
-import { mapGetters,mapActions } from "vuex";
-import autoUpdateMixins from "@/mixins/autoUpdate";
+import { mapGetters } from "vuex";
+import autoUpdateApp from "@/mixins/autoUpdate";
 import rightItemArea from './components/rightItemArea.vue'
 import middleButton from './components/middleButton.vue'
+import leftItemComponent from './components/leftItem.vue'
 import loginComponent from './login.vue'
-import { createCreateOrder, wastageCreateOrder } from '@/api/home/index'
 export default {
 	name: "workbench",
-	components: { rightItemArea,middleButton,  loginComponent },
-	mixins: [autoUpdateMixins],
+	components: { rightItemArea,middleButton,  loginComponent, leftItemComponent },
+	mixins: [autoUpdateApp],
 	data() {
 		return {
 			itemList:[],
 			currenSelectShop:{},
 			selectItem: {},
 			selectCurrentActiveItem:{},
-			totalShop:{ bigUnit: 0, smallUnit:0, totalPrice: 0 },
 			selectItemUser:{},
 			isLogin:false
 		};
 	},
 	computed: {
-		...mapGetters(["getLoginInfo"]),
-		...mapGetters({ myShopInfo: "getMyShopInfo" }),
+		...mapGetters(["getLoginInfo"])
 	},
-	onLoad(option) {
+	onLoad() {
 	},
 	onPullDownRefresh() {
-		this.init();
-		uni.stopPullDownRefresh();
 	},
 	onShow() {
 	},
@@ -92,71 +66,11 @@ export default {
 					this.isLogin = true
 				}				
 			}
-		},
-		itemList(){
-			if(this.$util.isEmpty(this.itemList)) {
-				this.totalShop = { bigUnit: 0, smallUnit:0, totalPrice: 0 }
-			}
-			this.totalShop =	this.itemList.reduce((total,val)=>{
-				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: {
-		//结算创建订单
-		async setCreateOrder(){
-			try {
-				let arr = this.itemList.map(i=>({ productId:i.id, unitType: i.unitType, num: i.currentNum, property: i.property, unitPrice: i.currentUnitPrice }))
-				const {settleId,payId,payUserId,isPrint,proceeds,freight} = this.$refs.settlePop
-				await createCreateOrder({
-					customId: this.selectItemUser.id,
-					product: JSON.stringify(arr),
-					modifyPrice: proceeds,
-					sendType: 1,
-					hasPay: settleId,
-					payWay: payId,
-					getUserId: payUserId,
-					needPrint: isPrint,
-					sendCost: freight,
-					remark:''
-				})
-				this.$refs.settlePopRef.close()
-				this.$refs.selectPayWayRef.open('center')
-				this.$msg('订单创建成功')
-			}catch(err) {
-				console.log(err)
-			}
-		},
-		cancelPay(){
-			this.$refs.selectPayWayRef.close()
-		},
-		async settleReturn(){
-			this.setCreateOrder()
-		},
-		selectCurrentActive(item){
-				this.selectCurrentActiveItem = item
-		},
-		selectUserReturn(val){
-			this.selectItemUser = val
-			this.$refs.selectUserRef.close()
-		},
-		cancelSelectUser(){
-			this.$refs.selectUserRef.close()
-		},
-		selectUser(){
-			this.$refs.selectUserRef.open('center')
-		},
 		init() {
 		},
-		selectPayWayBack(price){
-			console.log(price)
-		}
 	}
 };
 </script>
@@ -173,7 +87,7 @@ export default {
 		flex: 5;
 		background-color: rgba(72, 91, 107, 1);
 		& .item-list {
-			margin-top: 30upx;
+			margin-top: 20upx;
 			font-size: 16upx;
 			text-align: center;
 			padding: 15upx 0;
@@ -184,70 +98,6 @@ export default {
 	& .itemList-box {
 		flex: 25;
 		height: 100%;
-		display: flex;
-		flex-direction: column;
-		& .title {
-			padding: 3upx;
-			font-size: 12upx;
-			background-color: rgba(72, 91, 107, 1);
-			color: #FFFFFF;
-		}
-		& .itemList-item_box {
-			overflow-y: auto;
-			flex: 1;
-			border: 1px solid #eee;
-			& .show-item_box {
-				padding: 2upx;
-				& .item-body_box {
-					border-radius: 2upx;
-					padding: 2upx;
-					font-size: 14upx;
-					color:#666666;
-					&.active {
-						background-color: #d4d6d6;
-					}
-					&.not-active {
-						background-color: #e7e9e9;
-					}
-					.item-price-num{
-						color:#afaeae;
-						font-size:10upx;
-					}
-					& .flower-name_box {
-						padding: 0 5upx;
-						.current-item-title {
-							.name{
-								color: #333333;
-								font-weight: bold;
-								overflow: hidden;
-								text-overflow:ellipsis;
-								white-space: nowrap;
-								width:50upx;
-							}
-							.del{
-								color:orange;
-								font-size:12upx;
-								float:right;
-							}
-						}
-					}
-					& > view:nth-child(2) {
-						display: flex;
-						align-items: center;
-						justify-content: space-between;
-						padding-top: 15upx;
-					}
-				}
-			}
-		}
-		& .itemList-footer_box {
-			height: 20upx;
-			border: 1px solid #eee;
-			font-size: 10upx;
-			display: flex;
-			align-items: center;
-			justify-content: space-around;
-		}
 	}
 	& .open-box {
 		flex: 8;

+ 71 - 22
ghsPad/src/components/app-kd-select-num-price.vue

@@ -1,22 +1,22 @@
 <template>
     <view class="boardset-flowert">
         <view class="flower-input_box">
-            <view class="flower-title">{{selectItem.name}}</view>
+            <view class="flower-title">{{customData.name}}</view>
             <view class="flower-open_box">
                 <view>
-                    <view class="desc">{{selectItem.currentUnit}}数</view>
-                    <div class="flower-unit_box">
-                        <text>121</text>
+                    <view class="desc">{{Number(customData.unitType) == 0 ? customData.bigUnit : customData.smallUnit}}数</view>
+                    <div class="flower-unit_box" @tap="checkCurrent(0)">
+                        <text :class="{selected:hasCheck == 0}">{{buyNum}}</text>
                     </div>
                 </view>
                 <view>
                     <view class="desc">单价</view>
-                    <div class="flower-unit_box">
-                        <text>121</text>
+                    <div class="flower-unit_box" @tap="checkCurrent(1)">
+                        <text :class="{selected:hasCheck == 1}">{{unitPrice}}</text>
                     </div>
                 </view>
             </view>
-            <view class="set-residue_box">还剩{{parseFloat(selectItem.stock)||0}}{{selectItem.bigUnit}}</view>
+            <view class="set-residue_box">还剩{{parseFloat(customData.stock)}}{{customData.bigUnit}}</view>
             <view class="switch-button">
                 <image @tap="changeUnit" class="change-unit" :src="`${constant.imgUrl}/icon/switch/switch128.png`"></image>
             </view>
@@ -32,18 +32,38 @@ export default {
     name:'keyboardSetFlower',
     components:{ VKeyboard },
     props:{
-        selectItem:{ type:Object, default:()=>{} }
+        customData:{ type:Object, default:()=>{} }
     },
     data() {
         return {
             keyShow: false,
             enterType:'currentNum',
+            //输入类型 0 数值 1价格
+            fillType:0,
+            buyNum:'',
+            unitPrice:'',
+            //全选类型 0 数值全选 1 价格全选 2 没有任何全选
+            hasCheck:0
         };
     },
     mounted(){
         this.activeKeyboard()
     },
+	watch:{
+		customData:{
+			handler(){
+                console.log(this.customData,'this.customData')
+				this.buyNum = this.customData.buyNum||1
+				this.unitPrice = this.customData.bigPrice||0
+			},
+			deep:true
+		}
+	},
     methods: {
+        checkCurrent(n){
+            this.hasCheck = n
+            this.fillType = n
+        },
         cancel(){
             this.$emit('cancelKdSelectNumPrice')
         },
@@ -60,30 +80,56 @@ export default {
         },
         typing(e) {
             if (e.backspace) {
-                if (this.selectItem[this.enterType].length > 0) {
-                    this.selectItem[this.enterType] = this.selectItem[this.enterType].substring(0, this.selectItem[this.enterType].length - 1);
+                if(this.fillType == 0){
+                    if(this.hasCheck == 0){
+                        this.buyNum = ''
+                     }else{
+                        if (this.buyNum.length > 0) {
+                            this.buyNum = this.buyNum.substring(0, this.buyNum.length - 1)   
+                        }
+                    }
+                }else{
+                    if(this.hasCheck == 1){
+                        this.unitPrice = ''
+                    }else{
+                        if (this.unitPrice.length > 0) {
+                            this.unitPrice = this.unitPrice.substring(0, this.unitPrice.length - 1)
+                        }
+                    }
                 }
             }else {
-                if(this.selectItem[this.enterType] == 0|| this.$util.isEmpty(this.selectItem[this.enterType])) {
-                    this.selectItem[this.enterType] = e.char
-                }else {
-                    this.selectItem[this.enterType] += e.char;
+                if(this.fillType == 0){
+                    if(this.$util.isEmpty(this.buyNum) || this.hasCheck == 0) {
+                        this.buyNum = e.char
+                    }else {
+                        this.buyNum += e.char;
+                    }
+                }else{
+                    if(this.$util.isEmpty(this.unitPrice) || this.hasCheck == 1) {
+                        this.unitPrice = e.char
+                    }else {
+                        this.unitPrice += e.char;
+                    }
                 }
             }
-            this.$emit('update:selectItem', this.selectItem)
+            this.hasCheck = 2
         },
         enter() {
-            if(this.selectItem.currentNum  <= 0) {
-                this.$msg('数量不能为空')
+            if(Number(this.buyNum)  <= 0) {
+                this.$msg('请填写数量')
+                return
+            }
+            if(Number(this.unitPrice)  <= 0) {
+                this.$msg('请填写价格')
                 return
             }
-            this.$emit('enterNum', this.selectItem)
+            this.customData.buyNum = this.buyNum
+            this.customData.unitPrice = this.unitPrice
+            this.$emit('enterNum', this.customData)
         },
         changeUnit(){
-            this.selectItem.unitType = this.selectItem.unitType === 0?1:0
-            this.selectItem.currentUnit = this.selectItem.unitType ===0?this.selectItem.bigUnit:this.selectItem.smallUnit
-            this.selectItem.currentUnitPrice = this.selectItem.unitType ===0?this.selectItem.bigPrice:this.selectItem.smallPrice
-            this.$emit('update:selectItem', this.selectItem)
+            this.customData.unitType = this.customData.unitType == 0 ? 1 : 0
+            this.$forceUpdate()
         }
     }
 }
@@ -132,6 +178,9 @@ export default {
                 align-items: center;
                 justify-content:center;
                 border-bottom: 1px solid #eee;
+                & > text{
+                    height:25upx;
+                }
                 .selected{
                     background:blue;
                     color:white;

+ 29 - 30
ghsPad/src/mixins/product.js

@@ -22,7 +22,7 @@ export default {
 			checkStock:true,// 考虑库存,盘点不需要考虑库存
 			isAddModel:false,
 			isAddInputFocus:false,
-			customData: { bigCount: 0, smallCount: 0, userPrice: 0 },
+			customData: { buyNum: 0, unitPrice: 0,unitType:0 },
 			globalItemList:[]
 		};
 	},
@@ -342,44 +342,50 @@ export default {
 			let item = copyObject(product)
 			if(multiple == 0){
 				if(calc == 'add'){
-					item.bigCount++
+					item.buyNum++
 				}
 				if(calc == 'sub'){
-					if(Number(item.bigCount) <= 0){
-						if(Number(item.smallCount) > 0){
-							item.smallCount = 0
+					if(Number(item.buyNum) <= 0){
+						if(Number(item.buyNum) > 0){
+							item.buyNum = 0
 						}else{
 							this.$msg('不能再小了')
 						}
 					}else{
-						item.bigCount--
+						item.buyNum--
 					}
 				}
 			}
-			console.log('........replace_item......')
-			console.log(item)
 			const list = this.selectList
 			if(this.checkStock){
-				if ((Number(item.bigCount) * item.ratio + Number(item.smallCount)) > (Number(item.bigNum) * item.ratio + Number(item.smallNum))) {
-					this.$util.noStockRemind()
-					this.$msg("库存不足哦")
-					return
+				if(item.unitType == 0){
+					if(Number(item.buyNum)>Number(item.stock)){
+						this.$util.noStockRemind()
+						this.$msg("库存不足哦")
+						return
+					}
+				}else{
+					let currentNum = item.buyNum/item.ratio
+					currentNum = currentNum.toFixed(2)
+					if(Number(currentNum)>Number(item.stock)){
+						this.$util.noStockRemind()
+						this.$msg("库存不足哦")
+						return
+					}
 				}
 			}
 			let index = list.findIndex(element => element.id == item.id)
 			if(index == -1){
-				if(this.$util.isEmpty(item.userPrice) || Number(item.userPrice) == 0){
-					item.userPrice = item.bigPrice
+				if(this.$util.isEmpty(item.unitPrice) || Number(item.unitPrice) == 0){
+					item.unitPrice = item.bigPrice
 				}
 				list.push(item)			
 			}else{
-				if(item.bigCount <= 0 && item.smallCount <= 0){
-					//删除花材
+				if(item.buyNum <= 0){
 					list.splice(index,1)
 				}else{
-					list[index].bigCount = item.bigCount
-					list[index].smallCount = item.smallCount
-					list[index].userPrice = item.userPrice
+					list[index].buyNum = item.buyNum
+					list[index].unitPrice = item.unitPrice
 				}
 			}
 
@@ -424,32 +430,25 @@ export default {
 				return false
 			}
 
-			//二个都不是数值
-			if(/(^[1-9]\d*$)/.test(this.customData.bigCount) == false && /(^[1-9]\d*$)/.test(this.customData.smallCount) == false){
+			if(/(^[1-9]\d*$)/.test(this.customData.buyNUm) == false){
 				uni.showToast({title:"请填写数值",icon:"none"})
 				return;
 			}
 
-			if(/(^[1-9]\d*$)/.test(this.customData.bigCount)){
+			if(/(^[1-9]\d*$)/.test(this.customData.buyNUm)){
 				if(this.customData.bigCount<=0){
 					uni.showToast({title:"数量要大于0",icon:"none"})
 					return;
 				}
 			}
 
-			if(/(^[1-9]\d*$)/.test(this.customData.smallCount)){
-				if(this.customData.smallCount<=0){
-					uni.showToast({title:"数量要大于0",icon:"none"})
-					return;
-				}
-			}
 			//只有开单和采购需要使用价格
 			if(this.selectJobType == 'bill' || this.selectJobType == 'purchase'){
-				if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.userPrice) == false){
+				if(/(^[1-9]([0-9]+)?(\.[0-9]{1,2})?$)|(^(0){1}$)|(^[0-9]\.[0-9]([0-9])?$)/.test(this.customData.unitPrice) == false){
 					uni.showToast({title:"金额错误",icon:"none"})
 					return;
 				}
-				if(this.customData.userPrice <=0){
+				if(this.customData.unitPrice <=0){
 					uni.showToast({title:"金额要大于0",icon:"none"})
 					return;
 				}