#
whycq
2023-11-22 3913b3c5c8cde03f8c92d1c738d28c4a9bae7e55
pages/business/goBusiness/goBusiness.vue
@@ -3,9 +3,8 @@
      <view class="status_bar">
         <!-- 这里是状态栏 -->
      </view>
      <uni-nav-bar left-icon="left" title="出差" @clickLeft="back" @clickRight="scan" :fixed="true"
         :border="false" rightWidth="160rpx" leftWidth="160rpx"
         >
      <uni-nav-bar left-icon="left" title="出差" @clickLeft="back" @clickRight="scan" :fixed="true" :border="false"
         rightWidth="160rpx" leftWidth="160rpx">
         <block slot="right">
            <view class="city">
               <view>
@@ -15,27 +14,20 @@
            </view>
         </block>
      </uni-nav-bar>
      <!-- <view class="main-box">
         <view class="box" v-for="item in list">
            <view class="box-single-row flex-row" v-for="rule in listRule">
               <view style="flex: 1;">{{rule.label}}</view>
               <view style="flex: 4;">{{item[rule.attribute]}}</view>
            </view>
         </view>
      </view> -->
      
      <!-- 搜索框 -->
      <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">
            <!-- <view class="box-flag" >{{item.settle$}}</view> -->
         <view class="box" v-for="item in list" @click="goDetl(item)">
            <view style="display: flex;">
               <view class="box-title" style="flex: 1;">{{item.userId$}}提交的出差申请</view>
               <view class="box-time">{{item.createTime$.substring(0,10)}}</view>
            </view>
            <view class="box-item">出差事由:{{item.businessTripReasons}}</view>
            <view class="box-item">出差天数:{{item.businessTripDays$}}</view>
            <!-- <view class="box-item">同行人:{{item.businessPeers}}</view> -->
            <view style="display: flex;">
               <view class="box-item" style="flex: 1;">同行人:{{item.businessPeers}}</view>
               <view class="box-settle" :style="item.bgcolor">{{item.settle$}}</view>
@@ -43,48 +35,29 @@
         </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>
   </view>
</template>
<script>
   import user from '@/pages/api/user/user.js'
   export default {
      data() {
         return {
            keyword: '',
            user: {
               username: '杨成强',
               username: '',
               id: 0,
               type: ''
            },
            listRule: [
               {
                  label: "出发日期",
                  attribute: "businessStartTimeDay$",
               },
               {
                  label: "结束日期",
                  attribute: "businessEndTimeDay$",
               },
               {
                  label: "申请人",
                  attribute: "userId$",
               },
               {
                  label: "进度",
                  attribute: "settle$",
               },
               {
                  label: "出差备注",
                  attribute: "businessNotes",
               },
               {
                  label: "出差事由",
                  attribute: "businessTripReasons",
               },
            ],
            list: [
               {
            falg: true,
            list: [{
                  businessTripReasons: '沟通立库事宜',
                  businessTransportation$: '交通工具',
                  businessStartAddr$: '出发地',
@@ -104,23 +77,64 @@
                  createTime$: '2023-11-06 08:51:24',
                  bgcolor: 'color:#24ab59'
               },
            ]
         }
      },
      onShow() {
         this.getBusinessTrip()
         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
         })
         setTimeout(()=> {
            this.getBusinessTrip()
         },50)
         if (this.falg) {
            this.getDetail()
         }
      },
      methods: {
         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
                  })
               }
            })
         },
         getBusinessTrip() {
            let _this = this
            let param = {curr:1,limit:16,dept_id: 0,user_id: 67}
            if (_this.user.type == 'user_id') {
               param = {curr:1,limit:16,user_id: _this.user.id}
            } else if(_this.user.type == 'dept_id') {
               param = {curr:1,limit:16,dept_id: _this.user.id}
            } else {
               param = {curr:1,limit:16}
            }
            uni.request({
               url: `${_this.baseUrl}/businessTrip/list/auth`,
               header: {'token' : uni.getStorageSync('token')},
               header: {
                  'token': uni.getStorageSync('token')
               },
               data: param,
               success(res) {
                  res = res.data
                  if (res.code === 200) {
                     for(let k of res.data.records) {
                     for (let k of res.data.records) {
                        if (k.settle == 2) {
                           k['bgcolor'] = 'color: #12d489'
                        } else if (k.settle == 1) {
@@ -133,9 +147,19 @@
               }
            })
         },
         back() {
            uni.navigateBack({
         // 出差申请
         add() {
            uni.navigateTo({
               url: '/pages/business/goBusiness/addgoBusiness',
               success: function(res) {
                  res.eventChannel.emit('goBusinessDel', {
                     data: 'add'
                  })
               }
            })
         },
         back() {
            uni.navigateBack({})
         },
         scan() {
            uni.navigateTo({
@@ -150,16 +174,19 @@
   .flex-row {
      display: flex;
   }
   .flex-col {
      display: flex;
      flex-direction: column;
   }
   .main-box {
      /* margin: 16rpx; */
      /* background-color: #FFF; */
      border-radius: 20rpx;
      padding: 8rpx;
   }
   .box {
      margin: 16rpx 8rpx;
      /* height: 200px; */
@@ -171,51 +198,54 @@
      font-size: 24rpx;
      color: #bdbdbd;
   }
   .box-flag {
      position: absolute;
      right: 0;
      top:10rpx;
      top: 10rpx;
      background-color: #74B9E9;
      padding: 6rpx;
      font-size: 10rpx;
      color: #FFF;
   }
   .box-time {
      color: #bdbdbd;
   }
   .box-settle{
   .box-settle {
      font-size: 26rpx;
      /* font-weight: bold; */
   }
   .box-title {
      font-size: 28rpx;
      font-weight: bold;
      color: #000;
   }
   .box-single-row {
   }
   .box-single-row {}
</style>
list: [
   {
      businessTripReasons: '沟通立库事宜',
      businessTransportation$: '交通工具',
      businessStartAddr$: '出发地',
      businessEndAddr$: '目的地',
      businessStartTimeDay$: '出发日期',
      businessEndTimeDay$: '结束日期',
      businessDuration$: '出差时长',
      businessTripDays$: '出差天数',
      businessPeers: '同行人',
      userId$: '申请人',
      orderId: '跟踪项目',
      updateTime$: '更新时间',
      updateId$: '更新人员',
      settle$: '进度',
      businessNotes: '出差备注',
   },
{
businessTripReasons: '沟通立库事宜',
businessTransportation$: '交通工具',
businessStartAddr$: '出发地',
businessEndAddr$: '目的地',
businessStartTimeDay$: '出发日期',
businessEndTimeDay$: '结束日期',
businessDuration$: '出差时长',
businessTripDays$: '出差天数',
businessPeers: '同行人',
userId$: '申请人',
orderId: '跟踪项目',
updateTime$: '更新时间',
updateId$: '更新人员',
settle$: '进度',
businessNotes: '出差备注',
},
]