Mr.Zhang
2023-09-05 64a7f738aadbf552bfb1ce24c46b1924767bf526
minipro_standard/components/SelectMultipleMaterial.vue
@@ -6,12 +6,12 @@
         </v-Search>
         <div class="content_total">共{{pages.total}}条数据</div>
         <view class="scroll-content">
            <u-list @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower">
               <u-list-item v-for="(item1, index) in list" :key="index">
                  <view class="flex mb20" @click="selectMaterialAction(index)">
            <scroll-view scroll-y="true" refresher-enabled="true" :refresher-triggered="refreshing" @scrolltolower="loadMore"
               @refresherrefresh="onRefresh">
               <view v-for="(item1, index) in list" :key="index" class="flex mb20" @click="selectMaterialAction(index)">
                     <view class="img36 mr20 pt10">
                        <u-checkbox-group style="display: block;" name="" @change="selectMaterialAction(index)">
                           <u-checkbox :checked="item1.isActive"></u-checkbox>
                        <u-checkbox :checked="selectIndex.includes(index)"></u-checkbox>
                        </u-checkbox-group>
                     </view>
                     <view class="fx1">
@@ -47,8 +47,12 @@
                        </div>
                     </view>
                  </view>
            </scroll-view>
            <!-- <u-list @scrolltoupper="scrolltoupper" @scrolltolower="scrolltolower">
               <u-list-item v-for="(item1, index) in list" :key="index">
               </u-list-item>
            </u-list>
            </u-list> -->
         </view>
            <view style="height: 98rpx;"></view>
         <!-- <view class="">
@@ -60,7 +64,7 @@
                  <u-checkbox :checked="isAll" label="全选"></u-checkbox>
               </u-checkbox-group>
            </view>
            <view class="submit sbtn_green bbox tc">提交()</view>
            <view class="submit sbtn_green bbox tc" @click="submitAction">{{ `提交(${selectIndex.length})`}}</view>
         </view>
      </view>
   </u-popup>
@@ -68,6 +72,10 @@
<script>
   import vSearch from '@/components/Search.vue'
   import {
      choiceStockListPage,
      choiceStockPageForStandard
   } from '@/util/api/agencyAPI'
   export default {
      name: "selectMaterial",
      components: {
@@ -78,118 +86,85 @@
            show: false,
            splite:'&nbsp;|&nbsp;',
            isAll: false,
            refreshing: false,
            pages: {
               size: 10,
               index: 1,
               capacity: 10,
               page: 1,
               total: 0
            },
            list: []
            list: [],
            selectIndex: []
         };
      },
      methods: {
         open(target) {
            this.show = true
            this.refreshing = false
            this.workorderId = target.workorderId
            this.deviceId = target.deviceId
            this.list = []
            this.selectIndex = []
            // console.log(this.selectIndex);
            this.pages = {
               size: 10,
               index: 1,
               capacity: 10,
               page: 1,
               total: 0
            }
            this.loadData()
         },
         loadData() {
            this.list = [{
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            },
            {
               batch: '1',
               materialName: 'dsadas',
               materialCode: '1m0001',
               locationName: 'a仓2号位',
               num: '1',
               unitName: '块',
               qualityType: 0,
               procedureName: '压制',
               isActive: false
            choiceStockPageForStandard({
               ...this.pages,
               model: {
                  workorderId: this.workorderId,
                  deviceId: this.deviceId
            }
            ]
            }).then(res => {
               let {data} = res
               if (data.page == 1) {
                  this.list = [];
               }
               this.pages.page = data.page
               this.pages.total = data.total
               this.list.push(...data.records)
            }).catch((err) => {
            })
            .finally(() => {
               this.refreshing = false;
            })
         },
         scrolltoupper() {
         loadMore() {
            this.pages.page += 1
            this.loadData()
         },
         scrolltolower() {
         onRefresh() {
            if (this.refreshing) return
            this.refreshing = true;
            this.pages.page = 1
            this.loadData()
         },
         selectMaterialAction(index) {
            // console.log('12');
            this.list[index].isActive = !this.list[index].isActive
            let i = this.selectIndex.findIndex(item => item==index)
            if (i == -1 ) {
               this.selectIndex.push(index)
            } else {
               this.selectIndex.splice(i)
            }
         },
         selectAll() {}
         selectAll() {
            this.selectIndex = []
            this.selectIndex = [...new Array(this.list.length).keys()]
         },
         submitAction () {
            this.show = false
            let selectValue = []
            this.selectIndex.forEach(item => {
               selectValue.push(this.list[item])
            })
            this.$emit('selectes', { materials: selectValue })
         }
      }
   }
   /* 
@@ -202,6 +177,7 @@
      flex-direction: column;
      height: 1200rpx;
      box-sizing: border-box;
      .scroll-content {
         height: calc(1100rpx - env(safe-area-inset-bottom));
         overflow: scroll;
@@ -263,8 +239,10 @@
   }
   .bottom {
      height: 98rpx;
      .submit {
         width: 272rpx;
         height: 98rpx;