myInvoice.vue 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <!-- 我的发票 -->
  2. <template>
  3. <view class="invoice">
  4. <z-paging ref="paging" v-model="invoiceList" @query="queryList">
  5. <!-- 导航栏 -->
  6. <u-navbar
  7. title-color="#fff"
  8. :custom-back="customBack"
  9. :border-bottom="false"
  10. back-icon-color="#CCE8FF"
  11. :background="{ background: '#008CFF' }"
  12. title="我的发票"
  13. class="invoice-navbar"
  14. slot="top"
  15. >
  16. <view slot="right" class="invoice-navbar-right" @click="addInvoice">申请开票</view>
  17. </u-navbar>
  18. <!-- 列表 -->
  19. <view class="invoice-list">
  20. <view class="invoice-list-item" v-for="(item, index) in invoiceList" :key="index" @click="invoiceItemClick(item)">
  21. <view class="invoice-list-item-left">
  22. <view class="invoice-list-item-left-item" v-for="(child, childIndex) in invoiceObjectList" :key="childIndex">
  23. <view class="left">{{ child.label }}</view>
  24. <view class="right">
  25. <template v-if="child.type === 'money'">
  26. <text class="money">¥{{ item[child.key] }}</text>
  27. </template>
  28. <template v-else-if="child.type === 'time'">
  29. <text class="time">{{ item[child.key] }}</text>
  30. </template>
  31. <template v-else>
  32. <text>{{ item[child.key] }}</text>
  33. </template>
  34. </view>
  35. </view>
  36. </view>
  37. <view class="invoice-list-item-right">
  38. <view class="arrow-right">
  39. <u-icon name="arrow-right" color="#909399" size="28" />
  40. </view>
  41. <view>
  42. <text :class="formatStatusType(item['status'])">{{ formatStatus(item['status']) }}</text>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. </z-paging>
  48. <!-- 选择开票类型 -->
  49. <u-select v-model="chooseRecords.show" :list="chooseRecords.list" @confirm="chooseRecordsConfirm" />
  50. </view>
  51. </template>
  52. <script>
  53. export default {
  54. data() {
  55. return {
  56. invoiceList: [],
  57. invoiceObjectList: [
  58. { label: '', key: 'price', type: 'money' },
  59. { label: '', key: 'title', type: 'status' },
  60. { label: '申请时间:', key: 'applyTime', type: 'time' }
  61. ],
  62. queryParams: {
  63. pageNum: 1,
  64. pageSize: 10
  65. },
  66. chooseRecords: {
  67. show: false,
  68. list: [
  69. {
  70. value: 'parkingRecords',
  71. label: '停车记录'
  72. },
  73. {
  74. value: 'monthlyRecords',
  75. label: '包月记录'
  76. }
  77. ]
  78. }
  79. };
  80. },
  81. methods: {
  82. /**
  83. * @description: 指定返回上一页
  84. * @return {*}
  85. */
  86. customBack() {
  87. this.$u.route({
  88. type: 'switchTab',
  89. url: 'pages/center/index'
  90. });
  91. },
  92. /**
  93. * @description: 开发票
  94. * @return {*}
  95. */
  96. addInvoice() {
  97. this.chooseRecords.show = true;
  98. },
  99. /**
  100. * @description: 开发票选择确认
  101. * @param {*} val
  102. * @return {*}
  103. */
  104. chooseRecordsConfirm(list) {
  105. this.$u.route({
  106. url: '/pages/invoiceModule/availableOrder/availableOrder',
  107. params: {
  108. type: list[0].value
  109. }
  110. });
  111. },
  112. /**
  113. * @description: 分页触发
  114. * @param {*} pageNo
  115. * @param {*} pageSize
  116. * @return {*}
  117. */
  118. queryList(pageNo, pageSize) {
  119. this.queryParams.pageNum = pageNo;
  120. this.queryParams.pageSize = pageSize;
  121. // this.getInvoiceList();
  122. this.$refs.paging.complete([
  123. { id: 1, title: '停车服务', price: 0.03, applyTime: '2023-06-12 11:21:30', status: 0 },
  124. { id: 2, title: '停车服务', price: 0.03, applyTime: '2023-06-12 11:21:30', status: 1 },
  125. { id: 3, title: '停车服务', price: 0.03, applyTime: '2023-06-12 11:21:30', status: 2 },
  126. { id: 4, title: '停车服务', price: 0.03, applyTime: '2023-06-12 11:21:30', status: 1 }
  127. ]);
  128. },
  129. /**
  130. * @description: 获取发票列表
  131. * @return {*}
  132. */
  133. async getInvoiceList() {
  134. const { code, data } = await this.$u.api.invoiceModuleApi.getInvoiceListApi({ ...this.queryParams });
  135. if (code === 200) {
  136. this.$refs.paging.complete(data?.rows || []);
  137. }
  138. },
  139. /**
  140. * @description: 单条发票点击
  141. * @param {*} item
  142. * @return {*}
  143. */
  144. invoiceItemClick(item) {
  145. this.$u.route({
  146. url: '/pages/invoiceModule/invoiceDetails/invoiceDetails',
  147. params: {
  148. id: item.id
  149. }
  150. });
  151. },
  152. /**
  153. * @description: 初始化状态
  154. * @param {*} val
  155. * @return {*}
  156. */
  157. formatStatus(val) {
  158. const statusObj = {
  159. 0: '申请中',
  160. 1: '已开票',
  161. 2: '开票失败'
  162. };
  163. return statusObj[val];
  164. },
  165. /**
  166. * @description: 初始化状态按钮样式
  167. * @param {*} val
  168. * @return {*}
  169. */
  170. formatStatusType(val) {
  171. const statusTypeObj = {
  172. 0: 'info',
  173. 1: 'primary',
  174. 2: 'error'
  175. };
  176. return statusTypeObj[val];
  177. }
  178. }
  179. };
  180. </script>
  181. <style lang="scss" scoped>
  182. @import './myInvoice.scss';
  183. </style>