shish 2 ماه پیش
والد
کامیت
cd8aa70ca2
2فایلهای تغییر یافته به همراه250 افزوده شده و 39 حذف شده
  1. 17 5
      hdPad/src/pages/home/components/console.vue
  2. 233 34
      hdPad/src/pages/home/components/selectPrice.vue

+ 17 - 5
hdPad/src/pages/home/components/console.vue

@@ -84,7 +84,7 @@
 
 	<!-- 直接收款 -->
 	<uni-popup ref="gatheringRef" background-color="#fff" type="center" :animation="false">
-		<selectPrice @zjGathering="zjGathering" @cancelSelectPrice="cancelSelectPrice"></selectPrice>
+		<selectPrice :balance="balance" :custom-id="customId" :custom-name="customName" @zjGathering="zjGathering" @cancelSelectPrice="cancelSelectPrice"></selectPrice>
 	</uni-popup>
 
 	<!-- 开单选花材输入数量和金额 -->
@@ -326,10 +326,22 @@ export default {
 		//直接收款
 		zjGathering(params){
 			uni.showLoading()
-			//isCashier=1时收银台播放 总金额139元,请扫码付款
-			//zjGathering 1 表示直接收款,dealPrice 1 表示有改价格也直接提交
-			//senType==1到店自取 getGoods==1自动确认取货
-			createOrder({orderName:params.name,lsGoodsPrice:params.price,modifyPrice:params.price,isCashier:1,cash:params.cash,customId:this.customId,version:3,zjGathering:1,dealPrice:1,sendType:1,getGoods:1}).then(res=>{
+			const payload = {
+				orderName: params.name,
+				lsGoodsPrice: params.price,
+				modifyPrice: params.price,
+				isCashier: 1,
+				cash: params.cash,
+				customId: this.customId,
+				version: 3,
+				zjGathering: 1,
+				dealPrice: 1,
+				sendType: 1,
+				getGoods: 1,
+				hasPay: params.hasPay != null ? params.hasPay : 0,
+				payWay: Number(params.hasPay) === 1 ? (params.payWay != null ? params.payWay : 0) : 0
+			}
+			createOrder(payload).then(res=>{
 				uni.hideLoading()
 				if(res.code == 1){
 					if(res.data.status == 1){

+ 233 - 34
hdPad/src/pages/home/components/selectPrice.vue

@@ -30,29 +30,55 @@
                             </view>
                         </view>
                         <view class="calc-total-row">
-                            <text class="calc-total-label">合计</text>
-                            <text class="calc-total-val">{{ formatMoney(stackTotal) }}</text>
+                            <text class="calc-total-label">订单金额</text>
+                            <text class="calc-total-val">{{ formatMoney(stackDiscountedAmount) }}</text>
                         </view>
                         <view v-if="isDiscountActive" class="calc-discount-row">
                             <text class="calc-discount-label">{{ formatDiscountZheLabel(discountZhe) }}后</text>
                             <text class="calc-discount-val">{{ formatMoney(stackDiscountedAmount) }}</text>
                         </view>
-                    </view>
+                        </view>
 
-                    <view class="pay-amount-row">
-                        <view class="flower-open_box pay-amount-col">
-                            <view @tap="checkCurrent(1)">
-                                <view class="desc">订单金额</view>
-                                <view class="flower-unit_box">
-                                    <text :class="{ selected: checkType == 1 }">{{ formatMoney(price) }}</text>
+                    <view class="rcv-pay-block">
+                        <view class="rcv-pay-title">收款方式</view>
+                        <view class="rcv-item-list_box">
+                            <view
+                                v-for="item in optHasPayList"
+                                :key="'hp-' + item.id"
+                                class="rcv-item-chip"
+                                :data-hpid="String(item.id)"
+                                :class="{ active: selHasPay === item.id }"
+                                @tap.stop="onHasPayChipTap"
+                            >
+                                {{ item.name }}
+                            </view>
+                        </view>
+                        <view v-if="Number(balance) > 0" class="rcv-customer-line">
+                            {{ rcvCustomerBalanceLabel }} ¥{{ formatMoney(balance) }}
+                        </view>
+                        <view v-if="selHasPay === 1" class="rcv-sub-block">
+                            <view class="rcv-pay-title rcv-pay-title-sub">请选择线下收款方式</view>
+                            <view class="rcv-item-list_box">
+                                <view
+                                    v-for="item in optPayWayList"
+                                    :key="'pw-' + item.id"
+                                    class="rcv-item-chip"
+                                    :data-pwid="String(item.id)"
+                                    :class="{ active: selPayWay === item.id }"
+                                    @tap.stop="onPayWayChipTap"
+                                >
+                                    {{ item.name }}
                                 </view>
                             </view>
                         </view>
+                    </view>
+
+                    <view class="pay-amount-row" v-if="showCashPayCols">
                         <view class="flower-open_box pay-amount-col">
                             <view @tap="checkCurrent(2)">
                                 <view class="desc">收现金</view>
                                 <view class="flower-unit_box">
-                                    <text :class="{ selected: checkType == 2 }">{{ formatMoney(cash) }}</text>
+                                    <text :class="{ selected: keyboardTarget !== 'calc' && checkType == 2 }">{{ formatMoney(cash) }}</text>
                                 </view>
                             </view>
                         </view>
@@ -71,11 +97,9 @@
                             </view>
                         </view>
                     </view>
-                    <view class="pay-submit-column">
-                        <view class="pay-submit-btn" @tap.stop="submitGathering">提交</view>
-                        <view class="pay-submit-row2">
-                            <view class="pay-submit-btn pay-submit-btn-stash" @tap.stop="stashCurrent">暂存</view>
-                        </view>
+                    <view class="pay-submit-row">
+                        <view class="pay-submit-btn pay-submit-btn-stash" @tap.stop="stashCurrent">暂存</view>
+                        <view class="pay-submit-btn" @tap.stop="submitCashierPay">提交</view>
                     </view>
                     </view>
                 </view>
@@ -206,6 +230,20 @@ const DISCOUNT_CUSTOM_STORAGE_KEY = 'hdPad_selectPrice_customDiscountZhe'
 const DISCOUNT_SELECTED_STORAGE_KEY = 'hdPad_selectPrice_discountZhe'
 export default {
     name: 'selectPrice',
+    props: {
+        balance: {
+            type: Number,
+            default: 0
+        },
+        customId: {
+            type: Number,
+            default: 0
+        },
+        customName: {
+            type: String,
+            default: ''
+        }
+    },
     data() {
         return {
             price: 0,
@@ -225,9 +263,27 @@ export default {
             customDiscountZheList: [],
             customZheInput: '',
             _discountPopupCloseByApi: false,
+            selHasPay: 0,
+            selPayWay: 0,
+            optHasPayList: [
+                { name: '扫码', id: 0 },
+                { name: '余额', id: 4 },
+                { name: '赊账', id: 2 },
+                { name: '线下', id: 1 }
+            ],
+            optPayWayList: [
+                { name: '线下微信', id: 0 },
+                { name: '线下支付宝', id: 1 },
+                { name: '现金', id: 4 },
+                { name: '银行卡', id: 5 }
+            ]
         }
     },
     computed: {
+        rcvCustomerBalanceLabel() {
+            const n = (this.customName || '').trim()
+            return n || '客户余额'
+        },
         isEmptyCalcInput() {
             return this.$util.isEmpty(this.calcInput)
         },
@@ -257,6 +313,9 @@ export default {
             return Number(this.discountZhe) < 10 - 1e-6
         },
         zl() {
+            if (!(this.selHasPay === 1 && this.selPayWay === 4)) {
+                return 0
+            }
             let amount = 0
             if (Number(this.cash) > 0 && Number(this.price) > 0) {
                 amount = Number(this.cash) - Number(this.price)
@@ -264,6 +323,9 @@ export default {
             }
             return Number(amount)
         },
+        showCashPayCols() {
+            return this.selHasPay === 1 && this.selPayWay === 4
+        },
     },
     watch: {
         stackDiscountedAmount: {
@@ -693,6 +755,54 @@ export default {
             this.checkType = n
             this.keyboardTarget = n === 1 ? 'order' : 'cash'
         },
+        onHasPayChipTap(e) {
+            const ds = e.currentTarget.dataset || {}
+            const v = ds.hpid
+            if (v === undefined || v === '') {
+                return
+            }
+            const val = Number(v)
+            if (isNaN(val)) {
+                return
+            }
+            this.applySelHasPay(val)
+        },
+        onPayWayChipTap(e) {
+            const ds = e.currentTarget.dataset || {}
+            const v = ds.pwid
+            if (v === undefined || v === '') {
+                return
+            }
+            const val = Number(v)
+            if (isNaN(val)) {
+                return
+            }
+            this.applySelPayWay(val)
+        },
+        applySelHasPay(val) {
+            this.tapVoice()
+            this.selHasPay = val
+            this.cash = 0
+            if (Number(val) !== 1) {
+                this.selPayWay = 0
+            }
+            this.blurCashIfNoColumn()
+        },
+        applySelPayWay(val) {
+            this.tapVoice()
+            this.selPayWay = val
+            if (Number(val) !== 4) {
+                this.cash = 0
+            } else {
+                this.checkCurrent(2)
+            }
+            this.blurCashIfNoColumn()
+        },
+        blurCashIfNoColumn() {
+            if (this.keyboardTarget === 'cash' && !this.showCashPayCols) {
+                this.focusCalc()
+            }
+        },
         openCalcHistory() {
             this.tapVoice()
             this.$refs.calcHistoryPopup && this.$refs.calcHistoryPopup.open()
@@ -937,6 +1047,9 @@ export default {
                         this.price = String(this.price).substring(0, String(this.price).length - 1)
                     }
                 } else if (field === 'cash') {
+                    if (!this.showCashPayCols) {
+                        return
+                    }
                     if (this.checkType === 2) {
                         this.cash = ''
                     } else if (String(this.cash).length > 0) {
@@ -964,6 +1077,9 @@ export default {
                         this.price += ch
                     }
                 } else if (field === 'cash') {
+                    if (!this.showCashPayCols) {
+                        return
+                    }
                     if (this.$util.isEmpty(this.cash) || this.checkType === 2) {
                         this.cash = ch
                     } else {
@@ -976,7 +1092,7 @@ export default {
             }
             this.checkType = 0
         },
-        submitGathering() {
+        submitCashierPay() {
             this.tapVoice()
             if (this.keyboardTarget === 'calc') {
                 const st = this.stackTotal
@@ -991,18 +1107,46 @@ export default {
                 this.$msg('订单金额须大于 0')
                 return
             }
+            if ((this.selHasPay === 4 || this.selHasPay === 2) && (!this.customId || Number(this.customId) <= 0)) {
+                this.$msg('请先选择客户')
+                return
+            }
+            if (this.selHasPay === 4 && Number(this.balance) < Number(p)) {
+                this.$msg('客户余额不足')
+                return
+            }
+            if (this.showCashPayCols) {
+                const cx = Number(this.cash) || 0
+                if (cx <= 0) {
+                    this.$msg('请输入收到的现金金额')
+                    return
+                }
+                if (Number(this.zl) < 0) {
+                    this.$msg('收现金不足,还差 ' + this.formatChangeAmount(-Number(this.zl)))
+                    return
+                }
+            }
             const hasCalc =
                 this.tokens.length > 0 ||
                 (this.calcInput != null && !this.$util.isEmpty(this.calcInput))
+            const cashSubmit = this.showCashPayCols ? (Number(this.cash) || 0) : 0
             this.pushHistorySnapshot(p, {
                 source: 'submit',
                 orderOnly: !hasCalc,
             })
-            this.$emit('zjGathering', { price: p, name: this.name, cash: Number(this.cash) || 0 })
+            this.$emit('zjGathering', {
+                price: p,
+                name: this.name,
+                cash: cashSubmit,
+                hasPay: this.selHasPay,
+                payWay: this.selHasPay === 1 ? this.selPayWay : 0
+            })
             this.price = 0
             this.checkType = 3
             this.keyboardTarget = 'calc'
             this.cash = 0
+            this.selHasPay = 0
+            this.selPayWay = 0
             this.tokens = []
             this.calcInput = ''
             this.resetActiveDiscountToNone()
@@ -1033,10 +1177,9 @@ export default {
     color: #d1cfcf;
 }
 .boardset-flowert {
-    width: 88vw;
-    max-width: 900upx;
-    height: 86vh;
-    max-height: 900px;
+    width: 91vw;
+    height: 99vh;
+    max-height: 960px;
     background-color: #ffffff;
     margin: 0 auto;
     border-radius: 5upx;
@@ -1054,7 +1197,7 @@ export default {
         min-height: 0;
     }
     .register-left-scroll {
-        flex: 1;
+        flex: 6;
         min-width: 0;
         width: 0;
         height: 100%;
@@ -1062,9 +1205,9 @@ export default {
         padding-right: 10upx;
     }
     .register-right {
-        width: 52%;
-        flex-shrink: 0;
-        min-width: 260upx;
+        flex: 5;
+        min-width: 0;
+        width: 0;
         height: 100%;
         display: flex;
         flex-direction: column;
@@ -1133,6 +1276,66 @@ export default {
         color: #09c567;
         line-height: 1;
     }
+    .rcv-pay-block {
+        margin-top: 10upx;
+        padding: 10upx 8upx 8upx;
+        border: 1upx solid #eeeeee;
+        border-radius: 6upx;
+        box-sizing: border-box;
+    }
+    .rcv-pay-title {
+        font-size: 12upx;
+        color: #333333;
+        text-align: left;
+        margin-bottom: 6upx;
+    }
+    .rcv-pay-title-sub {
+        margin-top: 8upx;
+    }
+    .rcv-sub-block {
+        margin-top: 4upx;
+    }
+    .rcv-item-list_box {
+        display: flex;
+        align-items: center;
+        justify-content: flex-start;
+        flex-wrap: wrap;
+        padding-bottom: 2upx;
+    }
+    .rcv-item-chip {
+        min-width: 78upx;
+        padding-left: 6upx;
+        padding-right: 6upx;
+        height: 26upx;
+        text-align: center;
+        line-height: 26upx;
+        font-size: 10upx;
+        border: 1upx solid #eeeeee;
+        margin-right: 6upx;
+        margin-bottom: 6upx;
+        margin-top: 0;
+        color: #333333;
+        border-radius: 3upx;
+        display: flex;
+        align-items: center;
+        justify-content: center;
+        box-sizing: border-box;
+    }
+    .rcv-item-chip:first-child {
+        margin-left: 0;
+    }
+    .rcv-item-chip.active {
+        background-color: #09c567;
+        color: #ffffff;
+        border-color: #09c567;
+    }
+    .rcv-customer-line {
+        color: #3385ff;
+        font-size: 13upx;
+        font-weight: bold;
+        margin-bottom: 4upx;
+        margin-top: 2upx;
+    }
     .pay-amount-row {
         display: flex;
         flex-direction: row;
@@ -1180,20 +1383,16 @@ export default {
     .flower-unit_box-change {
         min-height: 25upx;
     }
-    .pay-submit-column {
-        display: flex;
-        flex-direction: column;
-        margin-top: 12upx;
-    }
-    .pay-submit-row2 {
+    .pay-submit-row {
         display: flex;
         flex-direction: row;
-        margin-top: 8upx;
+        margin-top: 12upx;
+        align-items: stretch;
     }
-    .pay-submit-row2 .pay-submit-btn {
+    .pay-submit-row .pay-submit-btn {
         flex: 1;
     }
-    .pay-submit-row2 .pay-submit-btn + .pay-submit-btn {
+    .pay-submit-row .pay-submit-btn + .pay-submit-btn {
         margin-left: 8upx;
     }
     .pay-submit-btn {