Browse Source

默认客户

shish 2 months ago
parent
commit
cbb0e0343c
1 changed files with 29 additions and 1 deletions
  1. 29 1
      ghsApp/src/admin/tools/calculator.vue

+ 29 - 1
ghsApp/src/admin/tools/calculator.vue

@@ -236,12 +236,15 @@
 
 
 <script>
 <script>
 import { createOrder } from '@/api/order/index'
 import { createOrder } from '@/api/order/index'
+import { mapGetters } from 'vuex'
 
 
 const CALC_HISTORY_STORAGE_KEY = 'ghsApp_calculator_calcHistory'
 const CALC_HISTORY_STORAGE_KEY = 'ghsApp_calculator_calcHistory'
 const DISCOUNT_CUSTOM_STORAGE_KEY = 'ghsApp_calculator_customDiscountZhe'
 const DISCOUNT_CUSTOM_STORAGE_KEY = 'ghsApp_calculator_customDiscountZhe'
 const DISCOUNT_SELECTED_STORAGE_KEY = 'ghsApp_calculator_discountZhe'
 const DISCOUNT_SELECTED_STORAGE_KEY = 'ghsApp_calculator_discountZhe'
 /** 计算器选客回填:对应 selectCustom style=3 */
 /** 计算器选客回填:对应 selectCustom style=3 */
 const CALCULATOR_PICK_CUSTOMER_KEY = 'ghsApp_calculator_pick_customer'
 const CALCULATOR_PICK_CUSTOMER_KEY = 'ghsApp_calculator_pick_customer'
+/** 与首页「快捷开单」一致:取自 loginInfo.skCustomId,界面展示名固定 */
+const SHORTCUT_CUSTOM_DISPLAY_NAME = '快捷开单'
 
 
 const SETTLE_FORM_DEFAULTS = {
 const SETTLE_FORM_DEFAULTS = {
 	sendType: 1,
 	sendType: 1,
@@ -303,9 +306,21 @@ export default {
 		}
 		}
 	},
 	},
 	computed: {
 	computed: {
+		...mapGetters({ loginInfo: 'getLoginInfo' }),
+		/** 工作台「快捷开单」客户 id,与 workbench skKd 使用的 loginInfo.skCustomId 一致 */
+		shortcutCustomerId() {
+			const login = this.loginInfo || {}
+			const sid = login.skCustomId
+			if (this.$util.isEmpty(sid) || Number(sid) <= 0) return 0
+			return Number(sid)
+		},
 		customerDisplayName() {
 		customerDisplayName() {
 			const n = (this.customName || '').trim()
 			const n = (this.customName || '').trim()
 			if (n) return n
 			if (n) return n
+			const skid = this.shortcutCustomerId
+			if (Number(this.customId) > 0 && skid > 0 && Number(this.customId) === skid) {
+				return SHORTCUT_CUSTOM_DISPLAY_NAME
+			}
 			if (Number(this.customId) > 0) return '—'
 			if (Number(this.customId) > 0) return '—'
 			return '未选择'
 			return '未选择'
 		},
 		},
@@ -345,6 +360,9 @@ export default {
 		},
 		},
 	},
 	},
 	watch: {
 	watch: {
+		shortcutCustomerId(n) {
+			if (n > 0 && Number(this.customId) <= 0) this.applyDefaultShortcutCustomer()
+		},
 		stackDiscountedAmount: {
 		stackDiscountedAmount: {
 			handler(v) {
 			handler(v) {
 				if (this.keyboardTarget === 'calc') {
 				if (this.keyboardTarget === 'calc') {
@@ -363,9 +381,11 @@ export default {
 		if (options && options.customName) {
 		if (options && options.customName) {
 			this.customName = decodeURIComponent(String(options.customName))
 			this.customName = decodeURIComponent(String(options.customName))
 		}
 		}
+		this.applyDefaultShortcutCustomer()
 	},
 	},
 	onShow() {
 	onShow() {
 		this.applyPickCustomerFromStorage()
 		this.applyPickCustomerFromStorage()
+		this.applyDefaultShortcutCustomer()
 	},
 	},
 	mounted() {
 	mounted() {
 		this.loadCalcHistoryFromStorage()
 		this.loadCalcHistoryFromStorage()
@@ -391,6 +411,14 @@ export default {
 				uni.removeStorageSync(CALCULATOR_PICK_CUSTOMER_KEY)
 				uni.removeStorageSync(CALCULATOR_PICK_CUSTOMER_KEY)
 			} catch (e) {}
 			} catch (e) {}
 		},
 		},
+		/** 未选客且无路由参数带入时,默认工作台设置的快捷客户 */
+		applyDefaultShortcutCustomer() {
+			if (Number(this.customId) > 0) return
+			const skid = this.shortcutCustomerId
+			if (!skid || skid <= 0) return
+			this.customId = skid
+			this.customName = SHORTCUT_CUSTOM_DISPLAY_NAME
+		},
 		loadCalcHistoryFromStorage() {
 		loadCalcHistoryFromStorage() {
 			try {
 			try {
 				const raw = uni.getStorageSync(CALC_HISTORY_STORAGE_KEY)
 				const raw = uni.getStorageSync(CALC_HISTORY_STORAGE_KEY)
@@ -1117,7 +1145,7 @@ export default {
 				zjGathering: 1,
 				zjGathering: 1,
 				dealPrice: 1,
 				dealPrice: 1,
 				getGoods: 1,
 				getGoods: 1,
-				product: JSON.stringify([]),
+				product: '',
 				payWay: Number(formPayload.hasPay) === 1 ? (formPayload.payWay != null ? formPayload.payWay : 0) : 0,
 				payWay: Number(formPayload.hasPay) === 1 ? (formPayload.payWay != null ? formPayload.payWay : 0) : 0,
 			}
 			}
 			uni.showLoading({ mask: true })
 			uni.showLoading({ mask: true })