<template> <view class="main"> <view class="tab"> <u-tabs :list="tab" :current="current" @click="click"></u-tabs> </view> <view class="list"> <view class="item" v-for="(item, index) in list" :key="index"> <view class="it"> <view class="lable">项目名称</view> <view class="desc">{{ item.projectName }}</view> </view> <view class="it"> <view class="lable">发包公司</view> <view class="desc">{{ item.companyName }}</view> </view> <view class="it"> <view class="lable">项目周期</view> <view class="desc">{{ item.startDate }} 至 {{ item.finishDate }}</view> </view> <view class="it"> <view class="lable">结算日期</view> <view class="desc">{{ item.balanceDate }}</view> </view> <view class="op"> <text>{{ item.createTime }}</text> <text class="add" @click="add(item)" v-if="current == 0">接任务</text> <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 0">上传凭证</text> <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 1">已上传凭证</text> <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 3" style="background-color: #f44336">凭证驳回,请重新上传</text> <text v-if="current == 2" class="state">已完成</text> </view> </view> <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view> <u-empty v-if="!loadMore && list.length == 0"></u-empty> </view> <voucher ref="voucher" @success="success()"></voucher> </view> </template> <script> export default { data() { return { show: false, current: 0, tab: [{ name: '待接任务' }, { name: '已接任务' }, { name: '完成任务' }], list: [], param: { pageNum: 1, pageSize: 10, state: 0 }, loadMore: true }; }, onLoad() { this.getData(); }, methods: { getData() { this.http.request({ url: this.current === 0 ? '/app/project/list' : '/app/packages/list', data: this.param, loading: 'false', success: (res) => { this.loadMore = res.data.pages > this.param.pageNum ? true : false; res.data.rows.forEach((item) => { item.createTime = uni.$u.timeFrom(Date.parse(item.createTime)); this.list.push(item); }); } }); }, click(e) { this.current = e.index; this.param.state = e.index === 1 ? 0 : 1; this.refresh(); }, add(item) { uni.showModal({ title: '提示', content: '确定接包?', success: (res) => { if (res.confirm) { this.http.request({ url: '/app/packages/add', data: { projectId: item.id, companyId: item.companyId }, method: 'POST', success: (res) => { uni.showModal({ title: '提示', content: '接包成功', showCancel: false, success: (res) => { this.refresh(); } }); } }); } } }); }, //上传凭证 voucher(item) { this.$refs.voucher.init(JSON.parse(JSON.stringify(item))); }, success() { this.refresh(); }, //刷新数据 refresh() { this.loadMore = true; this.param.pageNum = 1; this.list = []; this.getData(); } }, //下拉刷新 onPullDownRefresh() { setTimeout(() => { this.refresh(); uni.stopPullDownRefresh(); }, 1000); }, //上拉加载 onReachBottom() { if (this.loadMore) { this.param.pageNum++; this.getData(); } } }; </script> <style lang="scss"> .main { padding: 0px 15px 10px 15px; } .tab { background-color: white; border-radius: 7px; padding-bottom: 10px; } .list { padding-top: 13px; .item { background-color: white; padding: 15px; border-radius: 5px; margin-bottom: 10px; .it { overflow: hidden; padding: 7px 0px 7px 0px; .lable { float: left; font-size: 14px; color: #787878; } .desc { float: right; font-size: 14px; width: 60%; text-align: right; } } .op { border-top: 1px solid $line; padding-top: 10px; color: #676767; font-size: 14px; .add { float: right; color: white; background-color: $main-color; padding: 3px 20px; border-radius: 20px; } .state { float: right; } } .cz { float: right; } } } </style>