invoice.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <template>
  2. <view>
  3. <mescroll-body top="30" bottom="40" @init="mescrollInit" @down="downCallback" @up="upCallback" :option="{}">
  4. <view class="common-list">
  5. <view class="common-item" v-for="(item,index) in list" :key="item.id"
  6. @click="$navigateTo('/pages/invoiceDetail/invoiceDetail?invoiceId='+item.id+'&type='+type)">
  7. <view class="title">{{item.name}}</view>
  8. <view class="date">{{$field.findTypeName('invoiceType',item.invoiceType)}}</view>
  9. <view class="other">
  10. <view class="item">
  11. <view class="label">收款方</view>
  12. <view class="value">{{item.organizationName}}</view>
  13. </view>
  14. <view class="item">
  15. <view class="label">付款方</view>
  16. <view class="value">{{item.payMerchantName || item.payClientName}}</view>
  17. </view>
  18. </view>
  19. <view class="state">
  20. <view></view>
  21. <view class="tag">
  22. <div class="status-tag success" v-if="!item.status">正常</div>
  23. <div class="status-tag error" v-else-if="item.status === 1">作废</div>
  24. </view>
  25. </view>
  26. <view class="icon">
  27. <uni-icons custom-prefix="iconfont" :type="menu.iconClass" color="#08979c" size="30">
  28. </uni-icons>
  29. </view>
  30. </view>
  31. </view>
  32. </mescroll-body>
  33. </view>
  34. </template>
  35. <script>
  36. import {
  37. getInvoiceListByPage
  38. } from '@/request/api/invouce.js'
  39. import {
  40. bindProjectDetail
  41. } from '@/request/api/organization.js'
  42. import MescrollMixin from "@/uni_modules/mescroll-uni/components/mescroll-uni/mescroll-mixins.js";
  43. export default {
  44. mixins: [MescrollMixin], // 使用mixin
  45. data() {
  46. return {
  47. list: [],
  48. type: '',
  49. menu: {},
  50. payClientId: '',
  51. payMerchantId: '',
  52. paymentIds: ''
  53. }
  54. },
  55. onLoad(body) {
  56. this.type = parseInt(body.type);
  57. this.menu = this.title();
  58. this.paymentIds = body.paymentIds;
  59. uni.setNavigationBarTitle({
  60. title: this.menu.title
  61. });
  62. uni.$on('reloadContract', () => {
  63. this.mescroll.resetUpScroll(false);
  64. })
  65. },
  66. methods: {
  67. title() {
  68. let str = {
  69. title: '',
  70. iconClass: 'icon-app-hetongguanli-hetongfapiao'
  71. };
  72. switch (this.type) {
  73. case 1:
  74. str = {
  75. title: '合同发票',
  76. iconClass: 'icon-app-hetongguanli-hetongfapiao'
  77. };
  78. break;
  79. case 2:
  80. str = {
  81. title: '常规发票',
  82. iconClass: 'icon-integralrecord'
  83. };
  84. break;
  85. default:
  86. break;
  87. }
  88. return str;
  89. },
  90. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  91. upCallback(page) {
  92. let postData = {
  93. currPage: page.num,
  94. pageSize: 10,
  95. projectId: this.$store.getters.project.id,
  96. type: this.type
  97. }
  98. if (this.paymentIds) {
  99. postData['paymentIds'] = this.paymentIds.split(',');
  100. return this.getBillList(postData);
  101. }
  102. if (this.$store.getters.identity.id === 3 || this.$store.getters.identity.id === 6) {
  103. postData['organizationId'] = this.$store.getters.organization.id;
  104. this.getBillList(postData);
  105. } else if (this.$store.getters.identity.id === 4) {
  106. if (this.payMerchantId) {
  107. postData['payMerchantId'] = this.payMerchantId;
  108. this.getBillList(postData);
  109. return;
  110. }
  111. bindProjectDetail({
  112. bindOrganizationId: this.$store.getters.organization.id,
  113. projectId: this.$store.getters.project.id,
  114. identityId: 4
  115. }).then(res => {
  116. if (res.code === 200) {
  117. if (res.data.length == 0) return this.mescroll.endBySize(0, 0);
  118. this.payMerchantId = res.data[0].merchantId;
  119. postData['payMerchantId'] = this.payMerchantId;
  120. this.getBillList(postData);
  121. } else {
  122. this.mescroll.endErr();
  123. }
  124. }).catch(() => {
  125. //联网失败, 结束加载
  126. this.mescroll.endErr();
  127. })
  128. } else if (this.$store.getters.identity.id === 1) {
  129. if (this.payClientId) {
  130. postData['payClientId'] = this.payClientId;
  131. this.getBillList(postData);
  132. return;
  133. }
  134. bindProjectDetail({
  135. userId: this.$store.getters.user.userId,
  136. projectId: this.$store.getters.project.id,
  137. identityId: 1
  138. }).then(res => {
  139. if (res.code === 200) {
  140. if (res.data.length == 0) return this.mescroll.endBySize(0, 0);
  141. this.payClientId = res.data[0].clientId;
  142. postData['payClientId'] = this.payClientId;
  143. this.getBillList(postData);
  144. } else {
  145. this.mescroll.endErr();
  146. }
  147. }).catch(() => {
  148. //联网失败, 结束加载
  149. this.mescroll.endErr();
  150. })
  151. }
  152. },
  153. getBillList(postData) {
  154. getInvoiceListByPage(postData).then(res => {
  155. if (res.code === 200) {
  156. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  157. if (postData.currPage == 1) this.list = []; //如果是第一页需手动制空列表
  158. let data = res.data.dataList;
  159. this.list = this.list.concat(data); //追加新数据
  160. } else {
  161. this.mescroll.endErr();
  162. }
  163. }).catch(() => {
  164. //联网失败, 结束加载
  165. this.mescroll.endErr();
  166. })
  167. }
  168. }
  169. }
  170. </script>
  171. <style>
  172. </style>