瀏覽代碼

bug 修复

lilei 2 年之前
父節點
當前提交
340ebae88c
共有 4 個文件被更改,包括 46 次插入35 次删除
  1. 37 31
      pages/soldOut/chooseProduct.vue
  2. 3 0
      pages/soldOut/creatOrder.vue
  3. 1 1
      pages/soldOut/productList.vue
  4. 5 3
      pages/soldOut/shelfList.vue

+ 37 - 31
pages/soldOut/chooseProduct.vue

@@ -137,37 +137,35 @@
 		},
 		},
 		methods: {
 		methods: {
 			checkboxGroupChange(e) {
 			checkboxGroupChange(e) {
-				console.log(e);
 				this.stockStateList = e
 				this.stockStateList = e
 			},
 			},
-			// 全选
+			// 单击全选
 			allCheckeChange(e){
 			allCheckeChange(e){
 				this.$refs.productList.allSelect(e.value)
 				this.$refs.productList.allSelect(e.value)
-				this.chooseList = this.$refs.productList.getAllChecked()
-			},
-			allCheckedCallback(val){
-				this.allChecked = val
-				this.chooseList = this.$refs.productList.getAllChecked()
-			},
-			// 创建补货单
-			creatOrder(data){
-				uni.showLoading({
-					title:"正在保存.."
-				})
-				stockCheckSave({
-					 shelfSn: this.nowData.shelfSn,
-					 totalCategory: this.nowData.totalCategory,
-					 totalStockQty: this.nowData.totalStockQty,
-					 totalFreezeQty: this.nowData.totalFreezeQty
-				}).then(res => {
-					 if(res.status == 200){
-						 this.detail = res.data || null
-						 this.stockCheckSn = res.data.stockCheckSn
-					 }else{
-						 uni.hideLoading()
-					 }
+				const list = this.$refs.productList.getAllData()
+				list.map(item => {
+					this.allCheckedCallback(true,item)
 				})
 				})
 			},
 			},
+			// 选中事件
+			allCheckedCallback(isAllChecked,row){
+				console.log(isAllChecked,row)
+				const has = this.chooseList.findIndex(k => k.id == row.id)
+				// 在已选列表中
+				if(has>=0){
+					// 取消选中
+					if(!row.checked){
+						this.chooseList.splice(has,1)
+					}
+				}else{
+					// 不在已选列表中,添加
+					if(row.checked){
+						this.chooseList.push(row)
+					}
+				}
+				// 是否全选
+				this.allChecked = isAllChecked
+			},
 			// 清空已选数据
 			// 清空已选数据
 			clearChoose(){
 			clearChoose(){
 				this.chooseList = []
 				this.chooseList = []
@@ -201,10 +199,6 @@
 					queryWord: this.queryWord,
 					queryWord: this.queryWord,
 					stockStateList: this.stockStateList
 					stockStateList: this.stockStateList
 				}
 				}
-				_this.clearChoose()
-				_this.partList = []
-				_this.$refs.productList && _this.$refs.productList.setData(_this.partList)
-				_this.status = 'loading'
 				uni.showLoading({
 				uni.showLoading({
 					mask:true,
 					mask:true,
 					title:"正在加载..."
 					title:"正在加载..."
@@ -228,6 +222,11 @@
 							return !(row>=0)
 							return !(row>=0)
 						})
 						})
 					}
 					}
+					// 已选
+					_this.partList.map(item => {
+						const row = _this.chooseList.find(k => k.id == item.id)
+						item.checked = !!row
+					})
 					this.$refs.productList.setData(_this.partList)
 					this.$refs.productList.setData(_this.partList)
 					setTimeout(()=>{
 					setTimeout(()=>{
 						uni.hideLoading()
 						uni.hideLoading()
@@ -237,8 +236,15 @@
 			// 提交
 			// 提交
 			submitOrder(){
 			submitOrder(){
 				if(this.totalCategory){
 				if(this.totalCategory){
-					uni.$emit("chooseDbhProduct",this.chooseList)
-					uni.navigateBack()
+					if(this.nowData.chooseKey.length){
+						uni.$emit("chooseDbhProduct",this.chooseList)
+						uni.navigateBack()
+					}else{
+						this.$store.state.vuex_tempData = this.chooseList
+						uni.redirectTo({
+							url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.nowData))
+						})
+					}
 				}else{
 				}else{
 					uni.showToast({
 					uni.showToast({
 						icon: 'none',
 						icon: 'none',

+ 3 - 0
pages/soldOut/creatOrder.vue

@@ -132,6 +132,9 @@
 		onLoad(opts) {
 		onLoad(opts) {
 			const _this = this
 			const _this = this
 			this.nowData = JSON.parse(decodeURIComponent(opts.data));
 			this.nowData = JSON.parse(decodeURIComponent(opts.data));
+			// 首次选中产品
+			this.chooseList = this.$store.state.vuex_tempData || []
+			
 			uni.$on("chooseDbhProduct",function(data){
 			uni.$on("chooseDbhProduct",function(data){
 				_this.chooseList = _this.chooseList.concat(data).sort(function(a,b){
 				_this.chooseList = _this.chooseList.concat(data).sort(function(a,b){
 					return (a.shelfPlaceCode+'').localeCompare(b.shelfPlaceCode+'');
 					return (a.shelfPlaceCode+'').localeCompare(b.shelfPlaceCode+'');

+ 1 - 1
pages/soldOut/productList.vue

@@ -116,7 +116,7 @@
 				}
 				}
 				// 判断是否全选
 				// 判断是否全选
 				const isAllNoChecked = this.partList.filter(item => !item.checked)
 				const isAllNoChecked = this.partList.filter(item => !item.checked)
-				this.$emit('allChecked',isAllNoChecked.length == 0)
+				this.$emit('allChecked',isAllNoChecked.length == 0,row)
 			},
 			},
 			// 获取所有选择的
 			// 获取所有选择的
 			getAllChecked(){
 			getAllChecked(){

+ 5 - 3
pages/soldOut/shelfList.vue

@@ -201,9 +201,11 @@
 			viewDetail (row) {
 			viewDetail (row) {
 			  if (row.productCategory&&row.productQty) {
 			  if (row.productCategory&&row.productQty) {
 			    this.tempData = row
 			    this.tempData = row
-			    uni.navigateTo({
-			    	url: "/pages/soldOut/creatOrder?data="+encodeURIComponent(JSON.stringify(this.tempData))
-			    })
+				this.tempData.chooseKey = []
+				this.$store.state.vuex_tempData = null
+				uni.navigateTo({
+					url: "/pages/soldOut/chooseProduct?data="+encodeURIComponent(JSON.stringify(this.tempData))
+				})
 			  } else {
 			  } else {
 			    this.toashMsg('此货架没有待补货产品')
 			    this.toashMsg('此货架没有待补货产品')
 			  }
 			  }