|
|
@@ -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>
|