index.vue 4.7 KB

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