ysy 2 年 前
コミット
b07f5a5e4b
2 ファイル変更45 行追加8 行削除
  1. 32 8
      pages/pda/picking/details.vue
  2. 13 0
      pages/pda/workOrder/search/index.vue

+ 32 - 8
pages/pda/picking/details.vue

@@ -15,8 +15,8 @@
 
 						<view class="right_box rx-ec">
 
-							<u-button type="success" size="small" class="u-reset-button" @click="addPicking(item.id)"
-								text="添加物料"></u-button>
+							<u-button type="success" size="small" class="u-reset-button"
+								@click="addPicking(item.id, item.instanceList)" text="添加物料"></u-button>
 
 						</view>
 
@@ -70,8 +70,8 @@
 						</view>
 					</view>
 
-					<view >
-					   <instanceBom :list='item.instanceList'></instanceBom>
+					<view>
+						<instanceBom :list='item.instanceList'></instanceBom>
 					</view>
 
 				</view>
@@ -96,7 +96,7 @@
 	} from '@/api/pda/workOrder.js'
 
 	export default {
-        components: {
+		components: {
 			instanceBom
 		},
 		data() {
@@ -121,9 +121,31 @@
 			uni.$off("setSelectList");
 
 			uni.$on("setSelectList", (selectList, id) => {
+				console.log(selectList)
 				this.List.forEach(m => {
 					if (m.id == id) {
-						this.$set(m, 'instanceList', selectList)
+						console.log(m.hasOwnProperty('instanceList'))
+						if (!m.hasOwnProperty('instanceList') || m.instanceList.length == 0) {
+							console.log(222)
+							this.$set(m, 'instanceList', selectList)
+							console.log(m)
+						} else {
+							let data = [...m.instanceList]
+
+							selectList.map(item => {
+								const obj = m.instanceList.find(value => value.id == item
+									.id); //分别判断arr1里面是否含           有arr的元素
+								if (!obj) {
+									data.push(item);
+								};
+							});
+
+							console.log(data)
+						}
+
+
+
+
 					}
 				})
 
@@ -151,9 +173,11 @@
 				console.log(e)
 			},
 
-			addPicking(id) {
+			addPicking(id, list) {
+				const storageKey = Date.now() + "";
+				uni.setStorageSync(storageKey, list|| []);
 				uni.navigateTo({
-					url: '/pages/pda/workOrder/search/index?id=' + id
+					url: `/pages/pda/workOrder/search/index?id=${id}&storageKey=${storageKey}`
 				})
 			},
 

+ 13 - 0
pages/pda/workOrder/search/index.vue

@@ -114,6 +114,7 @@
 				memoList: [],
 				
 				pid: null, // 上个页面id
+				storageKey: null
 			}
 		},
 
@@ -127,8 +128,20 @@
 
 		onLoad(option) {
 			this.pid =  option.id
+			if(option.storageKey) {
+				this.storageKey = option.storageKey
+				  this.memoList = (this.storageKey  && uni.getStorageSync(this.storageKey )) || []
+			}
+			
 			this.getTreeList()
 		},
+		
+		onUnload() {
+			if(this.storageKey) {
+					uni.removeStorage(this.storageKey)
+			}
+		
+		},