index.vue 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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: 1,
  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. uni.showModal({
  86. title: '提示',
  87. content: '接包成功',
  88. showCancel: false,
  89. success: (res) => {
  90. this.refresh();
  91. }
  92. });
  93. }
  94. });
  95. }
  96. }
  97. });
  98. },
  99. //上传凭证
  100. voucher(item) {
  101. this.$refs.voucher.init(JSON.parse(JSON.stringify(item)));
  102. },
  103. success() {
  104. this.refresh();
  105. },
  106. //刷新数据
  107. refresh() {
  108. this.loadMore = true;
  109. this.param.pageNum = 1;
  110. this.list = [];
  111. this.getData();
  112. }
  113. },
  114. //下拉刷新
  115. onPullDownRefresh() {
  116. setTimeout(() => {
  117. this.refresh();
  118. uni.stopPullDownRefresh();
  119. }, 1000);
  120. },
  121. //上拉加载
  122. onReachBottom() {
  123. if (this.loadMore) {
  124. this.param.pageNum++;
  125. this.getData();
  126. }
  127. }
  128. };
  129. </script>
  130. <style lang="scss">
  131. .main {
  132. padding: 0px 15px 10px 15px;
  133. }
  134. .tab {
  135. background-color: white;
  136. border-radius: 7px;
  137. padding-bottom: 10px;
  138. }
  139. .list {
  140. padding-top: 13px;
  141. .item {
  142. background-color: white;
  143. padding: 15px;
  144. border-radius: 5px;
  145. margin-bottom: 10px;
  146. .it {
  147. overflow: hidden;
  148. padding: 7px 0px 7px 0px;
  149. .lable {
  150. float: left;
  151. font-size: 14px;
  152. color: #787878;
  153. }
  154. .desc {
  155. float: right;
  156. font-size: 14px;
  157. width: 60%;
  158. text-align: right;
  159. }
  160. }
  161. .op {
  162. border-top: 1px solid $line;
  163. padding-top: 10px;
  164. color: #676767;
  165. font-size: 14px;
  166. .add {
  167. float: right;
  168. color: white;
  169. background-color: $main-color;
  170. padding: 3px 20px;
  171. border-radius: 20px;
  172. }
  173. .state {
  174. float: right;
  175. }
  176. }
  177. .cz {
  178. float: right;
  179. }
  180. }
  181. }
  182. </style>