invoice.vue 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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. }
  53. },
  54. onLoad(body) {
  55. this.type = parseInt(body.type) || 1;
  56. this.menu = this.title();
  57. uni.setNavigationBarTitle({
  58. title: this.menu.title
  59. });
  60. uni.$on('reloadContract', () => {
  61. this.mescroll.resetUpScroll(false);
  62. })
  63. },
  64. methods: {
  65. title() {
  66. let str = {
  67. title: '',
  68. iconClass: 'icon-app-hetongguanli-hetongfapiao'
  69. };
  70. switch (this.type) {
  71. case 1:
  72. str = {
  73. title: '合同发票',
  74. iconClass: 'icon-app-hetongguanli-hetongfapiao'
  75. };
  76. break;
  77. case 2:
  78. str = {
  79. title: '常规发票',
  80. iconClass: 'icon-integralrecord'
  81. };
  82. break;
  83. default:
  84. break;
  85. }
  86. return str;
  87. },
  88. /*上拉加载的回调: 其中page.num:当前页 从1开始, page.size:每页数据条数,默认10 */
  89. upCallback(page) {
  90. let postData = {
  91. currPage: page.num,
  92. pageSize: 10,
  93. projectId: this.$store.getters.project.id,
  94. type: this.type
  95. }
  96. if (this.$store.getters.identity.id === 3 || this.$store.getters.identity.id === 6) {
  97. postData['organizationId'] = this.$store.getters.organization.id;
  98. this.getBillList(postData);
  99. } else if (this.$store.getters.identity.id === 4) {
  100. if (this.payMerchantId) {
  101. postData['payMerchantId'] = this.payMerchantId;
  102. this.getBillList(postData);
  103. return;
  104. }
  105. bindProjectDetail({
  106. bindOrganizationId: this.$store.getters.organization.id,
  107. projectId: this.$store.getters.project.id,
  108. identityId: 4
  109. }).then(res => {
  110. if (res.code === 200) {
  111. if (res.data.length == 0) return this.mescroll.endBySize(0, 0);
  112. this.payMerchantId = res.data[0].merchantId;
  113. postData['payMerchantId'] = this.payMerchantId;
  114. this.getBillList(postData);
  115. } else {
  116. this.mescroll.endErr();
  117. }
  118. }).catch(() => {
  119. //联网失败, 结束加载
  120. this.mescroll.endErr();
  121. })
  122. } else if (this.$store.getters.identity.id === 1) {
  123. if (this.payClientId) {
  124. postData['payClientId'] = this.payClientId;
  125. this.getBillList(postData);
  126. return;
  127. }
  128. bindProjectDetail({
  129. userId: this.$store.getters.user.userId,
  130. projectId: this.$store.getters.project.id,
  131. identityId: 1
  132. }).then(res => {
  133. if (res.code === 200) {
  134. if (res.data.length == 0) return this.mescroll.endBySize(0, 0);
  135. this.payClientId = res.data[0].clientId;
  136. postData['payClientId'] = this.payClientId;
  137. this.getBillList(postData);
  138. } else {
  139. this.mescroll.endErr();
  140. }
  141. }).catch(() => {
  142. //联网失败, 结束加载
  143. this.mescroll.endErr();
  144. })
  145. }
  146. },
  147. getBillList(postData) {
  148. getInvoiceListByPage(postData).then(res => {
  149. if (res.code === 200) {
  150. this.mescroll.endBySize(res.data.dataList.length, res.data.totalCount);
  151. if (postData.currPage == 1) this.list = []; //如果是第一页需手动制空列表
  152. let data = res.data.dataList;
  153. this.list = this.list.concat(data); //追加新数据
  154. } else {
  155. this.mescroll.endErr();
  156. }
  157. }).catch(() => {
  158. //联网失败, 结束加载
  159. this.mescroll.endErr();
  160. })
  161. }
  162. }
  163. }
  164. </script>
  165. <style>
  166. </style>