Parcourir la source

开始增加一个数量选择框

shish il y a 4 ans
Parent
commit
21c0c8e6ad

+ 12 - 1
hdPad/src/pages/home/components/rightGoodsArea.vue

@@ -24,7 +24,7 @@
 
         <slot name="footer"></slot>
 
-        <!-- 开单花材输入数量金额 -->
+        <!-- 选数量金额 -->
         <uni-popup ref="selectNumPriceRef" background-color="#fff" type="center" :animation="false">
             <selectNumPrice @confirmAddItemModel="confirmAddItemModel" :customData.sync="customData" @cancelKdSelectNumPrice="addItemModelHidden"></selectNumPrice>
         </uni-popup>
@@ -49,6 +49,7 @@ export default {
             currentJobType:'bill',
             currentJobId:0,
             flowerNum:0,
+            checkStock:true,
             flowerNumList:[{num:0,name:'支数'},{num:6,name:6},{num:9,name:9},{num:11,name:11},{num:19,name:19},{num:33,name:33},{num:52,name:52},{num:66,name:66},{num:99,name:99}]
         }
     },
@@ -64,6 +65,10 @@ export default {
         changeCurrentJobId:{
             type:Number,
             default:0
+        },
+        changeCheckStock:{
+            type:Boolean,
+            default:true
         }
     },
     created(){
@@ -87,6 +92,12 @@ export default {
                 this.currentJobId = Number(id)
             },
             immediate:true
+        },
+        changeCheckStock:{
+            handler(bool){
+                this.checkStock = bool
+            },
+            immediate:true
         }
     },
     methods:{

+ 243 - 0
hdPad/src/pages/home/components/selectNum.vue

@@ -0,0 +1,243 @@
+<template>
+    <view class="boardset-flowert">
+        <view class="flower-input_box">
+            <view class="flower-title">{{customData.name}}</view>
+            <view class="flower-ratio" v-if="customData.property && customData.property==1">{{customData.ratio}}{{customData.smallUnit}}/{{customData.bigUnit}}</view>
+
+            <view class="flower-open_box">
+                <view @tap="checkCurrent(0)">
+                    <view class="desc" v-if="customData.property && customData.property==1">{{Number(unitType) == 0 ? customData.bigUnit : customData.smallUnit}}数</view>
+                    <view class="desc" v-else>数量</view>
+                    <div class="flower-unit_box">
+                        <text :class="{selected:checkType == 0}">{{buyNum}}</text>
+                    </div>
+                </view>
+                <view @tap="checkCurrent(1)">
+                    <view class="desc">单价</view>
+                    <div class="flower-unit_box">
+                        <text :class="{selected:checkType == 1}">{{unitPrice}}</text>
+                    </div>
+                </view>
+            </view>
+
+            <view class="set-residue_box" v-if="customData.property && customData.property==1">
+                还剩
+                <text v-if="bigStockNum>0">{{bigStockNum}}{{customData.bigUnit}}</text>
+                <text v-if="smallStockNum>0">{{smallStockNum}}{{customData.smallUnit}}</text>
+            </view>
+            <view class="set-residue_box" v-else> 还剩 <text>{{customData.stock}}</text> </view>
+
+            <view class="switch-button" v-if="customData.property && customData.property==1">
+                <image @tap="changeUnitType" class="change-unit" :src="`${constant.imgUrl}/icon/switch/switch128.png`"></image>
+            </view>
+
+        </view>
+        <view class="keyboard-body_box">
+         <VKeyboard ref="keyboard" :pointIsShow="true" :digital="true" :disorderly="false" @typing="typing" @enter="enter" @cancel="cancel"> </VKeyboard>
+        </view>
+    </view>
+</template>
+<script>
+import VKeyboard from '@/components/plugin/vKeyboard/VKeyboard.vue'
+export default {
+    name:'keyboardSetFlower',
+    components:{ VKeyboard },
+    props:{
+        customData:{ type:Object, default:()=>{} }
+    },
+    data() {
+        return {
+            //输入类型 0 数值 1价格
+            fillType:0,
+            buyNum:'',
+            unitPrice:'',
+            unitType:0,
+            unitName:'',
+            //全选类型 0 数值全选 1 价格全选 2 没有任何全选
+            checkType:0,
+            bigStockNum:0,
+            smallStockNum:0
+        };
+    },
+    mounted(){
+        this.activeKeyboard()
+    },
+	watch:{
+		customData:{
+			handler(newData){
+				this.buyNum = newData.buyNum ? parseFloat(newData.buyNum) : 1
+                if(newData.property && newData.property == 1){
+                    this.bigStockNum = Math.floor(newData.stock)
+                    let smallCount = newData.stock - this.bigStockNum
+                    let smallStockNum = smallCount*newData.ratio
+                    this.smallStockNum = smallStockNum.toFixed(2)
+                    this.smallStockNum = parseFloat(this.smallStockNum)
+                    this.unitPrice = newData.bigPrice ? parseFloat(newData.bigPrice) : 0
+                    this.unitName = newData.bigUnit
+                }else{
+                    this.unitPrice = newData.price ? parseFloat(newData.price) : 0
+                    this.unitName = '份';
+                }
+			},
+			deep:true,
+            immediate:true
+		}
+	},
+    methods: {
+        checkCurrent(n){
+            this.checkType = n
+            this.fillType = n
+        },
+        cancel(){
+            this.$emit('cancelKdSelectNumPrice')
+        },
+        focus() {
+        },
+        focusSelect(event){
+            event.currentTarget.select();
+        },
+        activeKeyboard() {
+            this.$refs.keyboard.activate();
+        },
+        typing(e) {
+            if (e.backspace) {
+                if(this.fillType == 0){
+                    if(this.checkType == 0){
+                        this.buyNum = ''
+                     }else{
+                        if (this.buyNum.length > 0) {
+                            this.buyNum = this.buyNum.substring(0, this.buyNum.length - 1)   
+                        }
+                    }
+                }else{
+                    if(this.checkType == 1){
+                        this.unitPrice = ''
+                    }else{
+                        if (this.unitPrice.length > 0) {
+                            this.unitPrice = this.unitPrice.substring(0, this.unitPrice.length - 1)
+                        }
+                    }
+                }
+            }else {
+                if(this.fillType == 0){
+                    if(this.$util.isEmpty(this.buyNum) || this.checkType == 0) {
+                        this.buyNum = e.char
+                    }else {
+                        this.buyNum += e.char;
+                    }
+                }else{
+                    if(this.$util.isEmpty(this.unitPrice) || this.checkType == 1) {
+                        this.unitPrice = e.char
+                    }else {
+                        this.unitPrice += e.char;
+                    }
+                }
+            }
+            this.checkType = 2
+        },
+        enter() {
+            if(Number(this.buyNum)  <= 0) {
+                this.$msg('请填写数量')
+                return
+            }
+            if(Number(this.unitPrice)  <= 0) {
+                this.$msg('请填写价格')
+                return
+            }
+            this.customData.buyNum = this.buyNum
+            this.customData.unitPrice = this.unitPrice
+            this.customData.unitType = this.unitType
+            this.customData.unitName = this.unitName
+            this.$emit('confirmAddItemModel', this.customData)
+            this.checkType = 0
+            this.fillType = 0
+        },
+        changeUnitType(){
+            this.unitType = this.unitType == 0 ? 1 : 0
+            this.unitPrice = this.unitType == 0 ? this.customData.bigPrice : this.customData.smallPrice
+            this.unitName = this.unitType == 0 ? this.customData.bigUnit : this.customData.smallUnit
+            this.unitPrice = parseFloat(this.unitPrice)
+        }
+    }
+}
+</script>
+<style lang="scss" scoped>
+.boardset-flowert {
+    width:34vw;
+    height: 80vh;
+    background-color: #ffffff;
+    margin: 0 auto;
+    border-radius: 5upx;
+    padding: 10upx;
+    overflow-y: auto;
+    display: flex;
+    flex-direction: column;
+    box-sizing: border-box;
+    & .flower-input_box {
+        flex: 1;
+        & .flower-title {
+            text-align: center;
+            color: #333333;
+            font-size: 14upx;
+        }
+        & .flower-ratio{
+            text-align: center;
+            color: #CCCCCC;
+            font-size: 9upx;
+            margin-bottom:10upx;
+            margin-top:6upx;
+        }
+        & .set-residue_box {
+            font-size: 12upx;
+            color: #CCCCCC;
+            margin-top: 10upx;
+            text-align: left;
+        }
+    }
+    & .flower-open_box {
+        display: flex;
+        align-items: center;
+        justify-content: space-between;
+        & > view {
+            width:90upx;
+            & .desc {
+                text-align: center;
+                font-size: 13upx;
+                margin-bottom: 5upx;
+                color:#CCCCCC;
+            }
+            & .flower-unit_box {
+                display: flex;
+                font-size:15upx;
+                align-items: center;
+                justify-content:center;
+                border-bottom: 1px solid #eee;
+                & > text{
+                    height:25upx;
+                }
+                .selected{
+                    background:blue;
+                    color:white;
+                }
+            }
+        }
+    }
+    .switch-button{
+        display: flex;
+        justify-content: center;
+        width: 35upx;
+        height: 35upx;
+        position: absolute;
+        top:70upx;
+        left:14vw;
+        .change-unit {
+            width: 35upx;
+            height: 35upx;
+        }
+    }
+    & .keyboard-body_box {
+        flex: 1;
+        overflow: hidden;
+    }
+}
+</style>

+ 4 - 4
hdPad/src/pages/home/components/selectNumPrice.vue

@@ -5,16 +5,16 @@
             <view class="flower-ratio" v-if="customData.property && customData.property==1">{{customData.ratio}}{{customData.smallUnit}}/{{customData.bigUnit}}</view>
 
             <view class="flower-open_box">
-                <view>
+                <view @tap="checkCurrent(0)">
                     <view class="desc" v-if="customData.property && customData.property==1">{{Number(unitType) == 0 ? customData.bigUnit : customData.smallUnit}}数</view>
                     <view class="desc" v-else>数量</view>
-                    <div class="flower-unit_box" @tap="checkCurrent(0)">
+                    <div class="flower-unit_box">
                         <text :class="{selected:checkType == 0}">{{buyNum}}</text>
                     </div>
                 </view>
-                <view>
+                <view @tap="checkCurrent(1)">
                     <view class="desc">单价</view>
-                    <div class="flower-unit_box" @tap="checkCurrent(1)">
+                    <div class="flower-unit_box">
                         <text :class="{selected:checkType == 1}">{{unitPrice}}</text>
                     </div>
                 </view>

+ 3 - 2
hdPad/src/pages/home/selectMake.vue

@@ -10,7 +10,7 @@
             </view>
             <!-- 成品 -->
             <view class="all-item-area">
-                <rightGoodsArea :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId"></rightGoodsArea>
+                <rightGoodsArea :changeCurrentJobType.sync="currentJobType" :changeCurrentJobId.sync="currentJobId" :changeCheckStock="checkStock"></rightGoodsArea>
             </view>
             <!-- 按钮操作 -->
             <view class="open-box">
@@ -45,7 +45,8 @@ export default {
 			customId:0,
             currentJobType:'selectMake',
             currentJobId:0,
-			chooseCustomer:false
+			chooseCustomer:false,
+			checkStock:false
 		}
 	},
 	computed: {