ysy 2 years ago
parent
commit
88018ca31d
1 changed files with 61 additions and 10 deletions
  1. 61 10
      pages/pda/workOrder/search/index.vue

+ 61 - 10
pages/pda/workOrder/search/index.vue

@@ -15,7 +15,7 @@
 				<input v-model="keyWord" placeholder="请输入关键字搜索" class="searchInput" />
 
 				<view>
-					<u-button @click="getList" type="success" class="u-reset-button" text="搜索">
+					<u-button @click="getList" type="success" size="small" class="u-reset-button" text="搜索">
 					</u-button>
 				</view>
 
@@ -105,13 +105,15 @@
 				list: [],
 
 				seletedAll: false, //全选状态
-				checkListLen: 0,
+				memoList: []
 			}
 		},
 
 		//选择的列表长度
 		computed: {
-
+			checkListLen() {
+				return this.memoList.length
+			}
 
 		},
 
@@ -123,7 +125,32 @@
 
 		methods: {
 			_seletedAll() {
-				this.seletedAll = !this.seletedAll
+
+				if (!this.seletedAll) {
+					this.seletedAll = true
+
+					this.list.map(item => {
+						this.$set(item, 'checked', true)
+						const idx = this.memoList.findIndex(itm => itm.id === item.id)
+						if (idx === -1) {
+							this.memoList.push(item)
+						}
+					})
+
+
+
+				} else {
+					this.seletedAll = false
+					this.list.map(item => {
+						this.$set(item, 'checked', false)
+
+						const idx = this.memoList.findIndex(itm => itm.id === item.id)
+						if (idx > -1) {
+							this.memoList.splice(idx, 1)
+						}
+
+					})
+				}
 			},
 
 			openTreePicker() {
@@ -161,16 +188,40 @@
 				pageeLedgerMain(param).then(res => {
 					this.list.push(
 						...res.list.map(i => {
+							const checked =
+							  this.memoList.findIndex(itm => itm.id === i.id) > -1
+							  
 							return {
-								checked: false,
+								 checked,
 								...i
 							}
 						})
 					)
 				})
 			},
-			
-			
+
+			//勾选
+			selectVal(e, val, index) {
+				this.list[index].checked = !this.list[index].checked
+
+				this.seletedAll = !this.list.some(item => !item.checked)
+				
+				const idx = this.memoList.findIndex(
+				  item => item.id === this.list[index].id
+				)
+				
+				if (this.list[index].checked) {
+				  if (idx === -1) {
+				    this.memoList.push(this.list[index])
+				  }
+				} else {
+				  if (idx > -1) {
+				    this.memoList.splice(idx, 1)
+				  }
+				}
+				
+				
+			}
 		}
 	}
 </script>
@@ -186,11 +237,11 @@
 
 	.searchBox {
 		background-color: #dedede;
-		height: 100rpx;
+		height: 90rpx;
 		padding: 0 20rpx;
 
 		input {
-			height: 80rpx;
+			height: 70rpx;
 			width: 540rpx;
 			background: #f9f9f9 !important;
 			padding-left: 10rpx;
@@ -252,7 +303,7 @@
 
 			.items {
 				width: 50%;
-			margin-top: 6rpx;
+				margin-top: 6rpx;
 			}
 		}
 	}