#
whycq
2022-04-01 1f953fd7165222a7d460aadd4d3509414924d115
pages/basics/demo.vue
@@ -3,15 +3,19 @@
      <scroll-view>
         <view class="demo-tab">
            <checkbox-group @change="checkbox">
               <label v-for="(item,index) in data" :key="index" class="demo-list" :class="'bg-'+ item.checked">
                  <view class="demo-list-left"><checkbox :value="index+''" :checked="item.checked" />
                  </view>
                  <view class="demo-list-right">
                     <view><text style="width: 90rpx;">订单  | </text>{{item.orderNo}}<text>序号:{{index+1}}</text></view>
                     <view><text >商品编码:</text>{{item.matnr}}</view>
                     <view :class="'bg-'+item.checked"><text>应入数量:</text><view class="text-num">{{item.anfme}}</view><text>商品名称:</text>{{item.maktx}}</view>
                     <view><text>已入数量:</text><view class="text-num">{{item.inQty}}</view><text>订单状态:</text>{{item.state$}}</view>
                  </view>
               <label v-for="(item,index) in data" :key="index"
                     @click="changeClass(index)" class="demo-list bg-false" :class="{'active':add_class==index}" >
                     <view :class="'bg-'+item.checked" class="demo-list">
                        <view class="demo-list-left"><checkbox :value="item.id+''" :checked="item.checked" />
                        </view>
                        <view class="demo-list-right">
                           <view><text style="width: 90rpx;">订单  | </text>{{item.orderNo}}<text>序号:{{index+1}}</text></view>
                           <view><text >商品编码:</text>{{item.matnr}}</view>
                           <view ><text>应入数量:</text><view class="text-num">{{item.anfme}}</view><text>商品名称:</text>{{item.maktx}}</view>
                           <view><text>已入数量:</text><view class="text-num">{{item.inQty}}</view><text>订单状态:</text>{{item.state$}}</view>
                        </view>
                     </view>
               </label>
            </checkbox-group>
         </view>
@@ -29,7 +33,8 @@
         return {
            data: [],
            background:'unCheck',
            color:''
            color:'',
            add_class:''
         }
      },
      mounted() {
@@ -61,28 +66,32 @@
                  var res = res.data
                  if (res.code === 200) {
                     that.data = res.data.records
                     that.setCheck()
                     console.log(that.data)
                     // that.setCheck()
                     
                  }
               }
            })
         },
         setCheck() {
            for (var i = 0; i < this.data.length; i++) {
               var key = 'checked',
                  value = false
               this.data[i][key] = value
            }
         },
         checkbox: function (e) {
            var val = e.detail.value
            for (var i = 0; i < val.length; i++) {
               val[i] = parseInt(val[i])
               this.data[val[i]].checked = true
            var items = this.data,
               values = e.detail.value;
            for (var i = 0, lenI = items.length; i < lenI; ++i) {
               const item = items[i]
               item.id = item.id + ''
               if(values.indexOf(item.id) >= 0){
                  this.$set(item,'checked',true)
               }else{
                  this.$set(item,'checked',false)
               }
            }
            console.log(this.data)
         },
         changeClass(index) {
            console.log(index)
            this.add_class=index
         }
      }
   }
</script>
@@ -92,7 +101,7 @@
      background-color: #FFFFFF;
   }
   .bg-true {
      background-color: #55ffff;
      background-color: #e5e5e5;
   }
   .demo-tab {
   }