Mr.Shi
2023-09-06 0256141ad70be0d254fd9958e8d28867db1d7531
minipro_standard/pages_adjust/components/Material.vue
@@ -5,25 +5,23 @@
      </view>
      <view class="content">
         <view class="content_search">
            <u-search :showAction="false" placeholder="搜索物料名称" v-model="keyword"></u-search>
            <u-search :showAction="false" placeholder="搜索物料名称" v-model="form.name" @search="searchInput"></u-search>
         </view>
         <div class="content_total">共{{total}}条数据</div>
         <view class="content_list">
            <u-list @scrolltolower="scrolltolower">
               <u-list-item v-for="(item, index) in indexList" :key="index">
                  <div class="content_list_item" @click="getVal(item)">
                     <div class="content_list_item_name">
                        <span>{{item.name}}</span>
                     </div>
                  </div>
               </u-list-item>
            </u-list>
         </view>
         <scroll-view scroll-y class="content_list" @scrolltolower="loadmore">
            <div class="content_list_item" v-for="(item, index) in list" :key="index" @click="getVal(item)">
               <div class="content_list_item_name">
                  <span>{{item.mmodelUnionName}}</span>
               </div>
            </div>
         </scroll-view>
      </view>
   </u-popup>
</template>
<script>
   import { materialDistributeExt } from '@/util/api/ExWarehouse'
   export default {
      props: {
         show: Boolean
@@ -32,25 +30,64 @@
         return {
            keyword: '',
            total: 0,
            indexList: []
            list: [],
            loading: false,
            finished: false,
            refreshing: false,
            form: {
               capacity: 50,
               page: 0,
               total: 0,
               name: ''
            }
         };
      },
      methods: {
         searchInput() {
            this.form.page = 0
            this.finished = false
            this.list = []
            this.loadmore()
         },
         getVal(item) {
            this.$emit('value', item)
         },
         open() {
            this.indexList = []
            this.loadmore()
         },
         scrolltolower() {
            this.form.page = 0
            this.finished = false
            this.list = []
            this.loadmore()
         },
         loadmore() {
            for (let i = 0; i < 20; i++) {
               this.indexList.push({
                  id: i,
                  name: `仓库${i}`
            if (!this.finished) {
               this.loading = true;
               this.form.page = this.form.page += 1
               materialDistributeExt({
                  capacity: this.form.capacity,
                  page: this.form.page,
                  model: {
                     mmodelUnionName: this.form.name,
                     status: 1
                  }
               }).then(res => {
                  if (this.refreshing) {
                     this.list = []
                     this.refreshing = false;
                  }
                  this.loading = false;
                  if (res.code === 200 && res.data.records && res.data.records.length !== 0) {
                     this.form.total = res.data.total
                     this.list.push(...res.data.records)
                  } else {
                     this.finished = true;
                  }
               }).catch(err => {
                  this.loading = false;
                  this.finished = true;
                  if (this.refreshing) {
                     this.list = []
                     this.refreshing = false;
                  }
               })
            }
         },