#
whycq
2023-11-29 c478bc1b36e38774cf01c02fd5e23858bd70a4a3
pages/business/goBusiness/goBusiness.vue
@@ -14,6 +14,11 @@
            </view>
         </block>
      </uni-nav-bar>
      <!-- 搜索框 -->
      <view class="search-bg">
         <u-search placeholder="输入" v-model="keyword" :clearabled="true" @custom="search()" @search="search()"></u-search>
      </view>
      <view class="main-box">
         <view class="box" v-for="item in list" @click="goDetl(item)">
@@ -29,6 +34,11 @@
            </view>
         </view>
      </view>
      <u-empty v-if="true" icon="../../../static/image/emptyList.png" v-show="list.length <= 0" />
      <view class="fxbtn">
         <uni-icons type="plusempty" color="#fff" @click="add()" ></uni-icons>
      </view>
      <!-- 垫底 -->
      <view style="height: 120rpx;"></view>
@@ -36,14 +46,17 @@
</template>
<script>
   import user from '@/pages/api/user/user.js'
   export default {
      data() {
         return {
            keyword: '',
            user: {
               username: '杨成强',
               username: '',
               id: 0,
               type: ''
               type: 'user_id'
            },
            falg: true,
            list: [{
                  businessTripReasons: '沟通立库事宜',
                  businessTransportation$: '交通工具',
@@ -64,32 +77,50 @@
                  createTime$: '2023-11-06 08:51:24',
                  bgcolor: 'color:#24ab59'
               },
            ]
            ],
            curr: 2,
            reload: false,
            status: 'more',
         }
      },
      onShow() {
         let that = this
         uni.$on('isRefresh',function(data){
            that.user.username = data.title
            that.user.id = data.id
            that.user.type = data.key
            that.falg = false
         })
         if (this.falg) {
            this.getDetail()
         }
         setTimeout(()=> {
            this.getBusinessTrip1()
         },50)
      },
      onReachBottom() {
         this.status = 'more';
         this.getBusinessTrip()
      },
      methods: {
         goDetl(e) {
            console.log(e);
            uni.navigateTo({
               url: '/pages/business/goBusiness/goBusinessDetil',
               success: function(res) {
                  res.eventChannel.emit('busunessDetl', {
                     data: e
                  })
               }
            })
         },
         getBusinessTrip() {
         getBusinessTrip1() {
            let _this = this
            _this.list = []
            uni.showLoading({})
            let param = {curr:1,limit:8,dept_id: 0,user_id: 67}
            if (_this.user.type == 'user_id') {
               param = {curr:1,limit:8,user_id: _this.user.id}
            } else if(_this.user.type == 'dept_id') {
               param = {curr:1,limit:8,dept_id: _this.user.id}
            } else {
               param = {curr:1,limit:8}
            }
            uni.request({
               url: `${_this.baseUrl}/businessTrip/list/auth`,
               header: {
                  'token': uni.getStorageSync('token')
               },
               data: param,
               success(res) {
                  res = res.data
                  if (res.code === 200) {
@@ -100,9 +131,101 @@
                           k['bgcolor'] = 'color: #ffbd67'
                        }
                     }
                     _this.list = res.data.records
                     let list = res.data.records
                     _this.list = _this.reload ? list : _this.list.concat(list);
                     if (res.data.records.length == 0) {
                        _this.status = 'noMore'
                     }
                  }
                  // _this.list =
               },
               fail(result) {
                  uni.showToast({title: '请求失败'})
                  setTimeout(() => {
                     uni.reLaunch({
                        url: '../../login/login'
                     });
                  }, 1000);
               },
               complete() {
                  uni.hideLoading()
               }
            })
         },
         getBusinessTrip() {
            let _this = this
            uni.showLoading({})
            let param = {curr:_this.curr,limit:8,dept_id: 0,user_id: 67}
            if (this.user.type == 'user_id') {
               param = {curr:_this.curr,limit:8,user_id: _this.user.id}
            } else if(this.user.type == 'dept_id') {
               param = {curr:_this.curr,limit:8,dept_id: _this.user.id}
            } else {
               param = {curr:_this.curr,limit:8}
            }
            uni.request({
               url: `${_this.baseUrl}/businessTrip/list/auth`,
               header: {
                  'token': uni.getStorageSync('token')
               },
               data: param,
               success(res) {
                  res = res.data
                  if (res.code === 200) {
                     for (let k of res.data.records) {
                        if (k.settle == 2) {
                           k['bgcolor'] = 'color: #12d489'
                        } else if (k.settle == 1) {
                           k['bgcolor'] = 'color: #ffbd67'
                        }
                     }
                     let list = res.data.records
                     _this.list = _this.reload ? list : _this.list.concat(list);
                     _this.curr = _this.curr + 1
                     if (res.data.records.length == 0) {
                        _this.status = 'noMore'
                     }
                  }
               },
               fail(result) {
                  uni.showToast({title: '请求失败'})
                  setTimeout(() => {
                     uni.reLaunch({
                        url: '../../login/login'
                     });
                  }, 1000);
               },
               complete() {
                  uni.hideLoading()
               }
            })
         },
         async getDetail() {
            let res = await user.getDetail()
            if (res.code === 200) {
               this.user.username = res.data.username
               this.user.id = res.data.id
            } else if (res.code === 403) {
               this.backLogin(res)
            }
         },
         goDetl(e) {
            uni.navigateTo({
               url: '/pages/business/goBusiness/goBusinessDetil',
               success: function(res) {
                  res.eventChannel.emit('busunessDetl', {
                     data: e
                  })
               }
            })
         },
         // 出差申请
         add() {
            uni.navigateTo({
               url: '/pages/business/goBusiness/addgoBusiness',
               success: function(res) {
                  res.eventChannel.emit('goBusinessDel', {
                     data: 'add'
                  })
               }
            })
         },