shish 2 ماه پیش
والد
کامیت
38270ba801
1فایلهای تغییر یافته به همراه85 افزوده شده و 273 حذف شده
  1. 85 273
      hdApp/src/admin/tools/calculator.vue

+ 85 - 273
hdApp/src/admin/tools/calculator.vue

@@ -49,7 +49,6 @@
 						<text class="balance-strip-label">余额</text>
 						<text class="balance-strip-val">¥{{ formatMoney(customInfo.balance) }}</text>
 						<text v-if="balanceCoversDue && selHasPay === 4" class="balance-strip-hint balance-strip-hint-ok">余额充足</text>
-						<text v-else-if="balanceCoversDue && selHasPay !== 4" class="balance-strip-hint balance-strip-hint-tip">可选用「余额」收款</text>
 					</view>
 
 					<view class="rcv-pay-block">
@@ -248,34 +247,6 @@
 			</view>
 		</uni-popup>
 
-		<uni-popup ref="cashShortPopup" type="center" background-color="#ffffff" @change="onCashShortPopupChange">
-			<view class="mob-popup-wrap mob-popup-cash-short">
-				<view class="mob-popup-hd">
-					<text class="mob-popup-title">现金不足</text>
-				</view>
-				<text class="cash-short-desc">实收现金不足,还可以再用微信和支付宝付款</text>
-				<view class="cash-short-way-row">
-					<view
-						class="cash-short-way-chip"
-						:class="{ 'cash-short-way-chip-on': cashShortPick === 0 }"
-						@tap.stop="setCashShortPick(0)"
-					>
-						微信
-					</view>
-					<view
-						class="cash-short-way-chip"
-						:class="{ 'cash-short-way-chip-on': cashShortPick === 1 }"
-						@tap.stop="setCashShortPick(1)"
-					>
-						支付宝
-					</view>
-				</view>
-				<view class="cash-short-actions">
-					<view class="cash-short-btn cash-short-btn-cancel" @tap.stop="closeCashShortPopupByCancel">取消</view>
-					<view class="cash-short-btn cash-short-btn-ok" @tap.stop="confirmCashShortWay">确认并提交</view>
-				</view>
-			</view>
-		</uni-popup>
 	</view>
 </template>
 
@@ -292,31 +263,6 @@ const CALCULATOR_PICK_CUSTOMER_KEY = 'hdApp_calculator_pick_customer'
 /** 与 mall 首页「快捷开单」一致:取自 vuex getMyShopInfo.defaultCustomId;名称接口回填前暂显示 */
 const SHORTCUT_CUSTOM_DISPLAY_NAME = '快捷开单'
 
-const SETTLE_FORM_DEFAULTS = {
-	sendType: 1,
-	hasPay: 0,
-	payWay: 0,
-	needPrint: 2,
-	freight: '',
-	groupName: '',
-	remark: '',
-	sendCost: 0,
-	customSendCost: 0,
-	labourCost: 0,
-	modifyPrice: 0,
-	getStaffId: 0,
-	getStaffName: '',
-	shopAdminId: 0,
-	shopAdminName: '',
-	cash: 0,
-	dealPrice: 1,
-	fromType: 1,
-	reductionRule: 0,
-	callErrand: 0,
-	weight: 1,
-	deliveryRemark: '',
-}
-
 export default {
 	name: 'ToolsCalculator',
 	data() {
@@ -352,13 +298,10 @@ export default {
 				{ name: '银行卡', id: 5 },
 			],
 			customInfo: { discount: 1, balance: 0 },
-			cashShortPick: 0,
-			_cashShortPopupCloseByApi: false,
 		}
 	},
 	computed: {
 		...mapGetters({
-			getMerchantInfo: 'getMerchantInfo',
 			myShopInfo: 'getMyShopInfo',
 		}),
 		/** 与 mall.vue 快捷开单一致:myShopInfo.defaultCustomId(goItemKjKd / goHsKjKd) */
@@ -908,33 +851,6 @@ export default {
 		blurCashIfNoColumn() {
 			if (this.keyboardTarget === 'cash' && !this.showCashPayCols) this.focusCalc()
 		},
-		setCashShortPick(v) {
-			this.tapVoice()
-			this.cashShortPick = Number(v) === 1 ? 1 : 0
-		},
-		closeCashShortPopupByCancel() {
-			this.tapVoice()
-			this._cashShortPopupCloseByApi = true
-			this.$refs.cashShortPopup && this.$refs.cashShortPopup.close()
-		},
-		onCashShortPopupChange(e) {
-			if (!e || e.show !== false) return
-			if (this._cashShortPopupCloseByApi) {
-				this._cashShortPopupCloseByApi = false
-				return
-			}
-			this.tapVoice()
-		},
-		confirmCashShortWay() {
-			this.tapVoice()
-			const way = Number(this.cashShortPick) === 1 ? 1 : 0
-			this.applySelPayWay(way)
-			this._cashShortPopupCloseByApi = true
-			this.$refs.cashShortPopup && this.$refs.cashShortPopup.close()
-			this.$nextTick(() => {
-				this._submitCashierPayCore()
-			})
-		},
 		openCalcHistory() {
 			this.tapVoice()
 			this.$refs.calcHistoryPopup && this.$refs.calcHistoryPopup.open()
@@ -1208,21 +1124,12 @@ export default {
 			this.checkType = 0
 		},
 		submitCashierPay() {
-			this._submitCashierPayCore()
-		},
-		_resolveXjPayload() {
-			try {
-				if (Number(this.customId) > 0) {
-					return uni.getStorageSync('xj' + this.customId)
-				}
-			} catch (e) {}
-			try {
-				return uni.getStorageSync('xj')
-			} catch (e2) {}
-			return null
+			this._submitCashierPayCore(false)
 		},
-		_submitCashierPayCore() {
-			this.tapVoice()
+		_submitCashierPayCore(forceBalancePay) {
+			if (!forceBalancePay) {
+				this.tapVoice()
+			}
 			if (this.keyboardTarget === 'calc') {
 				const st = this.stackTotal
 				if (!Number.isFinite(st) || isNaN(st)) {
@@ -1236,15 +1143,11 @@ export default {
 				this.$msg('金额须大于 0')
 				return
 			}
-			if (this.selHasPay === 2 && (!this.customId || Number(this.customId) <= 0)) {
+			if ((this.selHasPay === 4 || this.selHasPay === 2) && (!this.customId || Number(this.customId) <= 0)) {
 				this.$msg('请先选择客户')
 				return
 			}
 			if (this.selHasPay === 4) {
-				if (!this.customId || Number(this.customId) <= 0) {
-					this.$msg('请先选择客户')
-					return
-				}
 				const bal = Number(this.customInfo.balance) || 0
 				if (bal + 1e-6 < p) {
 					this.$msg('客户余额不足')
@@ -1257,115 +1160,104 @@ export default {
 					this.$msg('请输入收到的现金')
 					return
 				}
-				if (Number(this.zl) < 0) {
-					this.cashShortPick = 0
-					this.$refs.cashShortPopup && this.$refs.cashShortPopup.open()
-					return
-				}
 			}
 			const hasCalc =
 				this.tokens.length > 0 ||
 				(this.calcInput != null && !this.$util.isEmpty(this.calcInput))
-			const cashSubmit = this.showCashPayCols ? (Number(this.cash) || 0) : 0
-			const emitHasPay = this.selHasPay
-			const emitPayWay = this.selHasPay === 1 ? this.selPayWay : 0
+			let cashSubmit = this.showCashPayCols ? (Number(this.cash) || 0) : 0
+			/** 现金不足:与 Pad selectPrice / 扫码一致,走后端 pending 再跳转付款 */
+			const cashShortToScan = this.showCashPayCols && Number(this.zl) < 0
+			let emitHasPay = this.selHasPay
+			let emitPayWay = this.selHasPay === 1 ? this.selPayWay : 0
+			if (cashShortToScan) {
+				emitHasPay = 0
+				emitPayWay = 0
+			}
+			if (forceBalancePay) {
+				emitHasPay = 4
+				emitPayWay = 0
+				cashSubmit = 0
+			} else if (
+				!cashShortToScan &&
+				Number(this.customId) > 0 &&
+				Number(this.customInfo.balance) >= Number(p) &&
+				emitHasPay !== 4
+			) {
+				const that = this
+				that.$util.confirmModal({content:'余额充值,可以使用余额支付'},() => {
+					that._submitCashierPayCore(true)
+				})
+				return
+			}
 			this.pushHistorySnapshot(p, {
 				source: 'submit',
 				orderOnly: !hasCalc,
 			})
 			const orderName = (this.name != null ? String(this.name) : '').trim()
-			const formPayload = {
-				...SETTLE_FORM_DEFAULTS,
-				hasPay: emitHasPay,
-				payWay: emitPayWay,
-				modifyPrice: p,
-				cash: cashSubmit,
+			const payload = {
 				orderName,
 				lsGoodsPrice: p,
-			}
-			const xjRaw = this._resolveXjPayload()
-			const payload = {
-				...formPayload,
+				modifyPrice: p,
 				isCashier: 1,
+				cash: cashSubmit,
 				customId: Number(this.customId) || 0,
-				xj: JSON.stringify(xjRaw),
 				version: 3,
 				zjGathering: 1,
 				dealPrice: 1,
+				sendType: 1,
 				getGoods: 1,
-				product: '',
-				orderType: 2,
-				payWay: Number(formPayload.hasPay) === 1 ? (formPayload.payWay != null ? formPayload.payWay : 0) : 0,
+				hasPay: emitHasPay != null ? emitHasPay : 0,
+				payWay: Number(emitHasPay) === 1 ? (emitPayWay != null ? emitPayWay : 0) : 0,
 			}
-			const sendCreate = () => {
-				if (!this.getMerchantInfo || !this.getMerchantInfo.id) {
-					this.$msg('未获取到店铺信息')
-					return
-				}
-				const shopPayload = {
-					...payload,
-					shopId: this.getMerchantInfo.id,
-				}
-				uni.showLoading({ mask: true })
-				createOrder(shopPayload)
-					.then((res) => {
-						uni.hideLoading()
-						if (res.code != 1) {
-							return
-						}
-						if (res.data && res.data.diff && !this.$util.isEmpty(res.data.diff)) {
-							this.$msg('存在价差条目,请到开单页处理')
-							return
-						}
-						let navigatedPay = false
-						if (res.data && res.data.status == 1) {
-							const id = res.data.id
-							const orderSn = res.data.orderSn
-							const actPrice = res.data.actPrice != null ? res.data.actPrice : p
-							if (formPayload.hasPay == 0) {
-								navigatedPay = true
-								this.$util.pageTo({
-									url: '/admin/billing/toPay',
-									type: 2,
-									query: { orderId: id, orderSn: orderSn, actPrice: actPrice },
-								})
-							} else {
-								navigatedPay = true
-								this.$util.pageTo({
-									url: '/admin/billing/result',
-									type: 2,
-									query: { orderId: id, orderSn: orderSn, title: '收款成功' },
-								})
-							}
-						} else if (!navigatedPay) {
-							uni.showToast({ title: '操作成功', icon: 'success' })
+			const finalHasPay = payload.hasPay
+			uni.showLoading({ mask: true })
+			createOrder(payload)
+				.then((res) => {
+					uni.hideLoading()
+					if (res.code != 1) {
+						return
+					}
+					if (res.data && res.data.diff && !this.$util.isEmpty(res.data.diff)) {
+						this.$msg('存在价差条目,请到开单页处理')
+						return
+					}
+					let navigatedPay = false
+					if (res.data && res.data.status == 1) {
+						const id = res.data.id
+						const orderSn = res.data.orderSn
+						const actPrice = res.data.actPrice != null ? res.data.actPrice : p
+						if (finalHasPay == 0) {
+							navigatedPay = true
+							this.$util.pageTo({
+								url: '/admin/billing/toPay',
+								type: 2,
+								query: { orderId: id, orderSn: orderSn, actPrice: actPrice },
+							})
+						} else {
+							navigatedPay = true
+							this.$util.pageTo({
+								url: '/admin/billing/result',
+								type: 2,
+								query: { orderId: id, orderSn: orderSn, title: '收款成功' },
+							})
 						}
-						this.price = 0
-						this.checkType = 3
-						this.keyboardTarget = 'calc'
-						this.cash = 0
-						this.selHasPay = 0
-						this.selPayWay = 0
-						this.tokens = []
-						this.calcInput = ''
-						this.resetActiveDiscountToNone()
-						this.refreshCustomerBalance()
-					})
-					.catch(() => {
-						uni.hideLoading()
-					})
-			}
-			if (!this.getMerchantInfo || !this.getMerchantInfo.id) {
-				this.initMerchantInfo()
-					.then(() => {
-						sendCreate()
-					})
-					.catch(() => {
-						this.$msg('店铺信息加载失败')
-					})
-				return
-			}
-			sendCreate()
+					} else if (!navigatedPay) {
+						uni.showToast({ title: '操作成功', icon: 'success' })
+					}
+					this.price = 0
+					this.checkType = 3
+					this.keyboardTarget = 'calc'
+					this.cash = 0
+					this.selHasPay = 0
+					this.selPayWay = 0
+					this.tokens = []
+					this.calcInput = ''
+					this.resetActiveDiscountToNone()
+					this.refreshCustomerBalance()
+				})
+				.catch(() => {
+					uni.hideLoading()
+				})
 		},
 	},
 }
@@ -1619,10 +1511,6 @@ export default {
 	color: #09c567;
 }
 
-.balance-strip-hint-tip {
-	color: #876500;
-}
-
 .rcv-pay-block {
 	margin-top: 12upx;
 	padding: 22upx 20upx;
@@ -2023,82 +1911,6 @@ export default {
 	padding: 0 12upx 12upx;
 }
 
-.mob-popup-cash-short {
-	max-height: none;
-}
-
-.cash-short-desc {
-	display: block;
-	font-size: 26upx;
-	color: #3d4654;
-	line-height: 1.45;
-	padding: 12upx 28upx 8upx;
-	box-sizing: border-box;
-}
-
-.cash-short-way-row {
-	display: flex;
-	flex-direction: row;
-	align-items: center;
-	padding: 12upx 28upx 8upx;
-	box-sizing: border-box;
-}
-
-.cash-short-way-chip {
-	flex: 1;
-	text-align: center;
-	font-size: 28upx;
-	padding: 20upx 12upx;
-	border-radius: 12upx;
-	border: 2upx solid #e8edf3;
-	background: #fafbfc;
-	color: #3d4654;
-	box-sizing: border-box;
-	margin-right: 16upx;
-	font-weight: 500;
-}
-
-.cash-short-way-chip:last-child {
-	margin-right: 0;
-}
-
-.cash-short-way-chip-on {
-	border-color: #09c567;
-	background: #effff4;
-	color: #09c567;
-}
-
-.cash-short-actions {
-	display: flex;
-	flex-direction: row;
-	align-items: center;
-	padding: 22upx 28upx 26upx;
-	border-top: 2upx solid #eef1f6;
-	box-sizing: border-box;
-	margin-top: 8upx;
-}
-
-.cash-short-btn {
-	flex: 1;
-	text-align: center;
-	font-size: 30upx;
-	padding: 22upx 12upx;
-	border-radius: 12upx;
-	box-sizing: border-box;
-	font-weight: 600;
-}
-
-.cash-short-btn-cancel {
-	margin-right: 16upx;
-	background: #f2f4f7;
-	color: #3d4654;
-}
-
-.cash-short-btn-ok {
-	background: #09c567;
-	color: #fff;
-}
-
 .discount-toolbar {
 	flex-shrink: 0;
 	padding: 20upx 24upx 22upx;