shish před 4 roky
rodič
revize
48f5c59744

+ 1 - 21
ghsApp/src/admin/home/workbench.vue

@@ -181,8 +181,6 @@ export default {
 	methods: {
 		...mapActions(['setUserShopAll']),
 
-
-
 		loginFun(mobile,password){
 
 			//有几个地方涉及登陆,需要统一方法,请搜索关键词 uni_login
@@ -234,32 +232,14 @@ export default {
 			})
 		},
 		skKd(){
-			// console.log(66666)
-			// console.log(this.myShopInfo)
-			// console.log(this.myShopInfo.skCustomId)
-			// console.log(this.skCustomId)
-			// console.log(777777)
 			if((this.myShopInfo.skCustomId && this.myShopInfo.skCustomId > 0) || this.skCustomId > 0){
-
 				let currentId = 0;
 				if(this.skCustomId > 0){
 					currentId = this.skCustomId
 				}else{
 					currentId = this.myShopInfo.skCustomId
 				}
-				let self = this
-				let levelList = ['PDA开单', '选材开单']
-				uni.showActionSheet({
-					itemList: levelList,
-					success: function (respond) {
-						let currentIndex = respond.tapIndex
-						if(currentIndex == 0){
-							self.$util.pageTo({url: "/admin/billing/affirm",query: {customId: currentId,kdType:'SCAN'}})
-						}else{
-							self.$util.pageTo({url: "/admin/billing/index",query: {customId: currentId}})
-						}
-					}
-				})
+				this.$util.pageTo({url: "/admin/billing/index",query: {customId: currentId}})
 			}else{
 				let that = this
 				uni.showModal({

+ 70 - 34
ghsApp/src/mixins/globalMixins.js

@@ -33,7 +33,7 @@ export default {
 		}
 	},
 	computed: {
-		...mapGetters(["getLoginInfo"]),
+		...mapGetters(["getLoginInfo","getSelectInfo"]),
 	},
 	// 页面生命周期才触发
 	onLoad: function (option) {
@@ -112,8 +112,6 @@ export default {
       // #endif 
 
 		}
-
-
 	},
 	onShow(){
 		if (isLogin()&&!this.$util.isEmpty(this.getLoginInfo)) {
@@ -144,6 +142,7 @@ export default {
           //PDA扫码开单前准备好所有花材
           allProduct().then(res=>{
             this.allProduct = res.data.list
+            console.log('................载入最新花材和库存................')
           })
 
           this.checkStock = true
@@ -162,11 +161,11 @@ export default {
                 that.globalPDAKd(productIdCode)
               }
             })
-            console.log('!!!!!!!!!!!!!!!!!!!!!!!商米收银台发起监听!!!!!!!!!!!!!!!!!!!!!')
+            console.log('!!!!!!!!!!!!!!!!!!!!!!!!商米收银台发起监听!!!!!!!!!!!!!!!!!!!!!!!')
           }
 
           //新大陆PDA
-          if(plus.device.vendor == 'Newland' && plus.device.model == 'NLS-MT90'){
+          if(plus.device.vendor == 'Newland'){
             //PDA
             var main = plus.android.runtimeMainActivity(); //获取activity
             var receiver = plus.android.implements('io.dcloud.feature.internal.reflect.BroadcastReceiver', {
@@ -176,7 +175,7 @@ export default {
             var filter = new IntentFilter();
             filter.addAction("nlscan.action.SCANNER_RESULT"); //监听扫描
             main.registerReceiver(receiver, filter); //注册监听
-            console.log('!!!!!!!!!!!!!!!!!!!!!!!PDA发起监听!!!!!!!!!!!!!!!!!!!!!!')
+            console.log('!!!!!!!!!!!!!!!!!!!!!!!!PDA发起监听!!!!!!!!!!!!!!!!!!!!!!!!!')
           }
 
     },
@@ -189,37 +188,74 @@ export default {
 		},
     globalPDAKd(productIdCode){
 			let that = this
-			this.allProduct.forEach(function(product,index,array){
-				if(Number(product.id) == Number(productIdCode)){
-					that.kdType = 'SCAN'
-					product.userPrice = product.bigPrice
-
-          //已经选择过的花材,先从storage取出,跳转到下一页/admin/billing/affirm 时selectList才有数据
-          if(uni.getStorageSync('selectList_'+that.pageType+'_custom_'+that.option.customId)){
-            let currentInfo = uni.getStorageSync('selectList_'+that.pageType+'_custom_'+that.option.customId)
-            if(!that.$util.isEmpty(currentInfo)){
-              currentInfo.forEach((currentItem,currentIndex,currentArray)=>{
-                let currentId = currentItem.id
-                that.allProduct.forEach(function(product,index,array){
-                  if(product.id == currentId){
-                    currentArray[currentIndex].bigPrice = product.bigPrice
-                    currentArray[currentIndex].smallPrice = product.smallPrice
-                  }
-                })
-              })
-              that.setSelectInfoByType({ type: that.pageType, info: currentInfo })
-            }
-          }
+      that.kdType = 'SCAN'
+      let pageType = "bill"
 
-          that.option.customId = that.skCustomId
-					that.addEvent(product)
-				}
-			})
-			var pages = getCurrentPages()
+      var pages = getCurrentPages()
 			let currentRoute  = pages[pages.length-1].route;
-			if(currentRoute != 'admin/billing/affirm'){
-				that.$util.pageTo({url: "/admin/billing/affirm",query:{customId:that.skCustomId,kdType:'SCAN'}})
+
+      let currentCustomId = that.skCustomId || 0
+      if(!this.$util.isEmpty(this.option.customId) && currentRoute == 'admin/billing/affirm'){
+        currentCustomId = this.option.customId
+      }
+      if(currentCustomId == 0){
+        this.$util.noStockRemind()
+        this.$msg('没有客户信息')
+      }
+
+      //涉及记住花材的代码和流程,请全项目搜索关键词remember_item
+			if(uni.getStorageSync('selectList_'+pageType+'_custom_'+currentCustomId)){
+				this.setSelectInfoByType({ type: pageType, info: uni.getStorageSync('selectList_'+pageType+'_custom_'+currentCustomId)})
 			}
+
+      let currentList = this.getSelectInfo[this.pageType] || [];
+
+      let index = this.allProduct.findIndex(ele => ele.id == productIdCode)
+      if(index == -1){
+        this.$util.noStockRemind()
+        this.$msg('没有找到花材')
+      }
+      let currentProduct = this.allProduct[index]
+      
+      let storeIndex = -1
+      if(!this.$util.isEmpty(currentList)){
+        storeIndex = currentList.findIndex(ele=> ele.id == currentProduct.id)
+      }
+      let currentItem = {}
+      if(storeIndex == -1){
+        currentProduct.bigCount = 1
+        currentProduct.smallCount = 0
+        currentProduct.userPrice = currentProduct.bigPrice
+        currentItem = currentProduct
+        if ((Number(currentItem.bigCount) * currentProduct.ratio + Number(currentItem.smallCount)) > (Number(currentProduct.bigNum) * currentProduct.ratio + Number(currentProduct.smallNum))) {
+          this.$util.noStockRemind()
+          uni.showToast({title:"库存不足",icon:"none"})
+          if(currentRoute != 'admin/billing/affirm'){
+            that.$util.pageTo({url: "/admin/billing/affirm",query:{customId:currentCustomId,kdType:that.kdType}})
+          }
+          return
+        }
+        currentList.push(currentProduct)       
+      }else{
+        let currentInfo = currentList[storeIndex]
+        if (((Number(currentInfo.bigCount)+1) * currentProduct.ratio + Number(currentInfo.smallCount)) > (Number(currentProduct.bigNum) * currentProduct.ratio + Number(currentProduct.smallNum))) {
+          this.$util.noStockRemind()
+          uni.showToast({title:"库存不足",icon:"none"})
+          if(currentRoute != 'admin/billing/affirm'){
+            that.$util.pageTo({url: "/admin/billing/affirm",query:{customId:currentCustomId,kdType:that.kdType}})
+          }
+          return
+        }
+        currentList[storeIndex].bigCount = Number(currentList[storeIndex].bigCount) + 1
+        currentItem = currentList[storeIndex]
+      }
+
+      uni.setStorageSync('selectList_'+pageType+'_custom_'+currentCustomId, currentList)
+      that.setSelectInfoByType({ type: pageType, info: currentList })
+
+      if(currentRoute != 'admin/billing/affirm'){
+        that.$util.pageTo({url: "/admin/billing/affirm",query:{customId:currentCustomId,kdType:that.kdType}})
+      }
     },
 		// #endif