Mr.Shi
2023-09-07 17e1ae4795b1be3d4bfd7005fb1bb559d5e30115
minipro_standard/pages_adjust/components/user.vue
@@ -5,11 +5,11 @@
      </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>
         <div class="content_total">共{{form.total}}条数据</div>
         <scroll-view class="content_list" scroll-y>
            <div class="content_list_item" v-for="(item, index) in indexList" :key="index" @click="getVal(item)">
            <div class="content_list_item" v-for="(item, index) in list" :key="index" @click="jump(item)">
               <div class="content_list_item_name">
                  <span>{{item.name}}</span>
               </div>
@@ -20,35 +20,60 @@
</template>
<script>
   import { allUser } from '@/util/api/PlanningAPI'
   export default {
      props: {
         show: Boolean
      },
      data() {
         return {
            keyword: '',
            total: 0,
            indexList: []
            list: [],
            loading: false,
            finished: false,
            refreshing: false,
            form: {
               capacity: 50,
               page: 0,
               total: 0,
               name: ''
            }
         };
      },
      methods: {
         getVal(item) {
         // 搜索框
         searchInput(data) {
            this.form.page = 0
            this.finished = false
            this.list = []
            this.loadmore()
         },
         jump(item) {
            this.$emit('value', item)
         },
         open() {
            this.indexList = []
            this.loadmore()
         },
         scrolltolower() {
            this.list = []
            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}`
            allUser({ name: this.form.name })
               .then(res => {
                  if (res.code === 200 && res.data && res.data.length !== 0) {
                     this.form.total = res.data.length
                     this.list = res.data
                  } else {
                     this.finished = true;
                  }
               }).catch(err => {
                  this.loading = false;
                  this.finished = true;
                  if (this.refreshing) {
                     this.list = []
                     this.refreshing = false;
                  }
               })
            }
         },
         close() {
            this.$emit('close')