index.vue 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. <template>
  2. <view class="main">
  3. <view class="tab">
  4. <u-tabs :list="tab" :current="current" @click="click"></u-tabs>
  5. </view>
  6. <view class="list">
  7. <view class="item" v-for="(item, index) in list" :key="index">
  8. <view class="it">
  9. <view class="lable">项目名称</view>
  10. <view class="desc">{{ item.projectName }}</view>
  11. </view>
  12. <view class="it">
  13. <view class="lable">发包公司</view>
  14. <view class="desc">{{ item.companyName }}</view>
  15. </view>
  16. <view class="it">
  17. <view class="lable">项目周期</view>
  18. <view class="desc">{{ item.startDate }} 至 {{ item.finishDate }}</view>
  19. </view>
  20. <view class="it">
  21. <view class="lable">结算日期</view>
  22. <view class="desc">{{ item.balanceDate }}</view>
  23. </view>
  24. <view class="op">
  25. <text>{{ item.createTime }}</text>
  26. <text class="add" @click="add(item)" v-if="current == 0">接任务</text>
  27. <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 0">上传凭证</text>
  28. <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 1">已上传凭证</text>
  29. <text class="add" @click="voucher(item)" v-if="current == 1 && item.audit == 3" style="background-color: #f44336">凭证驳回,请重新上传</text>
  30. <text v-if="current == 2" class="state">已完成</text>
  31. </view>
  32. </view>
  33. <view class="loading" v-if="loadMore"><u-loadmore :status="loadMore ? 'loading' : 'nomore'" /></view>
  34. <u-empty v-if="!loadMore && list.length == 0"></u-empty>
  35. </view>
  36. <voucher ref="voucher" @success="success()"></voucher>
  37. </view>
  38. </template>
  39. <script>
  40. export default {
  41. data() {
  42. return {
  43. show: false,
  44. current: 0,
  45. tab: [{ name: '待接任务' }, { name: '已接任务' }, { name: '完成任务' }],
  46. list: [],
  47. param: { pageNum: 1, pageSize: 10, state: 0 },
  48. loadMore: true
  49. };
  50. },
  51. onLoad() {
  52. this.getData();
  53. },
  54. methods: {
  55. getData() {
  56. this.http.request({
  57. url: this.current === 0 ? '/app/project/list' : '/app/packages/list',
  58. data: this.param,
  59. loading: 'false',
  60. success: (res) => {
  61. this.loadMore = res.data.pages > this.param.pageNum ? true : false;
  62. res.data.rows.forEach((item) => {
  63. item.createTime = uni.$u.timeFrom(Date.parse(item.createTime));
  64. this.list.push(item);
  65. });
  66. }
  67. });
  68. },
  69. click(e) {
  70. this.current = e.index;
  71. this.param.state = e.index === 1 ? 0 : 1;
  72. this.refresh();
  73. },
  74. add(item) {
  75. uni.showModal({
  76. title: '提示',
  77. content: '确定接包?',
  78. success: (res) => {
  79. if (res.confirm) {
  80. this.http.request({
  81. url: '/app/packages/add',
  82. data: { projectId: item.id, companyId: item.companyId },
  83. method: 'POST',
  84. success: (res) => {
  85. if (res.data.code == 7777) {
  86. uni.showModal({
  87. title: '提示',
  88. content: res.data.msg,
  89. showCancel: false,
  90. success: (res) => {
  91. uni.navigateTo({ url: '/pages/statement/user/info' });
  92. }
  93. });
  94. } else {
  95. uni.showModal({
  96. title: '提示',
  97. content: '接包成功',
  98. showCancel: false,
  99. success: (res) => {
  100. this.refresh();
  101. }
  102. });
  103. }
  104. }
  105. });
  106. }
  107. }
  108. });
  109. },
  110. //上传凭证
  111. voucher(item) {
  112. this.$refs.voucher.init(JSON.parse(JSON.stringify(item)));
  113. },
  114. success() {
  115. this.refresh();
  116. },
  117. //刷新数据
  118. refresh() {
  119. this.loadMore = true;
  120. this.param.pageNum = 1;
  121. this.list = [];
  122. this.getData();
  123. }
  124. },
  125. //下拉刷新
  126. onPullDownRefresh() {
  127. setTimeout(() => {
  128. this.refresh();
  129. uni.stopPullDownRefresh();
  130. }, 1000);
  131. },
  132. //上拉加载
  133. onReachBottom() {
  134. if (this.loadMore) {
  135. this.param.pageNum++;
  136. this.getData();
  137. }
  138. }
  139. };
  140. </script>
  141. <style lang="scss">
  142. .main {
  143. padding: 0px 15px 10px 15px;
  144. }
  145. .tab {
  146. background-color: white;
  147. border-radius: 7px;
  148. padding-bottom: 10px;
  149. }
  150. .list {
  151. padding-top: 13px;
  152. .item {
  153. background-color: white;
  154. padding: 15px;
  155. border-radius: 5px;
  156. margin-bottom: 10px;
  157. .it {
  158. overflow: hidden;
  159. padding: 7px 0px 7px 0px;
  160. .lable {
  161. float: left;
  162. font-size: 14px;
  163. color: #787878;
  164. }
  165. .desc {
  166. float: right;
  167. font-size: 14px;
  168. width: 60%;
  169. text-align: right;
  170. }
  171. }
  172. .op {
  173. border-top: 1px solid $line;
  174. padding-top: 10px;
  175. color: #676767;
  176. font-size: 14px;
  177. .add {
  178. float: right;
  179. color: white;
  180. background-color: $main-color;
  181. padding: 3px 20px;
  182. border-radius: 20px;
  183. }
  184. .state {
  185. float: right;
  186. }
  187. }
  188. .cz {
  189. float: right;
  190. }
  191. }
  192. }
  193. </style>