myInvoice.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. <!-- 我的发票 -->
  2. <template>
  3. <view class="invoice">
  4. <z-paging ref="paging" v-model="invoiceList" empty-view-text="暂无开票记录" @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">
  23. <view class="left"></view>
  24. <view class="right">
  25. <text class="money">¥{{ item.amount }}</text>
  26. </view>
  27. </view>
  28. <view class="invoice-list-item-left-item">
  29. <view class="left"></view>
  30. <view class="right">
  31. <text>{{ formatInvoiceType(item.invoType) }}</text>
  32. </view>
  33. </view>
  34. <view class="invoice-list-item-left-item">
  35. <view class="left">申请时间:</view>
  36. <view class="right">
  37. <text class="time">{{ $u.timeFormat(new Date(item.askTime), 'yyyy-mm-dd hh:MM:ss') }}</text>
  38. </view>
  39. </view>
  40. </view>
  41. <view class="invoice-list-item-right">
  42. <view class="arrow-right">
  43. <u-icon name="arrow-right" color="#909399" size="28" />
  44. </view>
  45. <view>
  46. <text :class="formatStatusType(item['status'])">{{ formatStatus(item['status']) }}</text>
  47. </view>
  48. </view>
  49. </view>
  50. </view>
  51. </z-paging>
  52. <!-- 选择开票类型 -->
  53. <u-select v-model="chooseRecords.show" :list="chooseRecords.list" value-name="dictValue" label-name="dictLabel" @confirm="chooseRecordsConfirm" />
  54. </view>
  55. </template>
  56. <script>
  57. export default {
  58. data() {
  59. return {
  60. invoiceList: [],
  61. queryParams: {
  62. pageNum: 1,
  63. pageSize: 10
  64. },
  65. chooseRecords: {
  66. show: false,
  67. list: []
  68. },
  69. invoiceStatusList: []
  70. };
  71. },
  72. onLoad(options) {
  73. this.getDict();
  74. },
  75. onShow() {
  76. this.$nextTick(() => {
  77. this.$refs.paging.reload();
  78. })
  79. },
  80. methods: {
  81. /**
  82. * @description: 获取字典
  83. * @return {*}
  84. */
  85. async getDict() {
  86. // 发票类型
  87. const typeRes = await this.$u.api.getDictApi({ type: 'invoice_type' });
  88. if (typeRes.code === 200) {
  89. this.chooseRecords.list = typeRes.data;
  90. }
  91. // 开票状态
  92. const statusRes = await this.$u.api.getDictApi({ type: 'invoice_status' });
  93. if (statusRes.code === 200) {
  94. this.invoiceStatusList = statusRes.data;
  95. }
  96. },
  97. /**
  98. * @description: 指定返回上一页
  99. * @return {*}
  100. */
  101. customBack() {
  102. this.$u.route({
  103. type: 'switchTab',
  104. url: 'pages/center/index'
  105. });
  106. },
  107. /**
  108. * @description: 开发票
  109. * @return {*}
  110. */
  111. addInvoice() {
  112. this.chooseRecords.show = true;
  113. },
  114. /**
  115. * @description: 开发票选择确认
  116. * @param {*} val
  117. * @return {*}
  118. */
  119. chooseRecordsConfirm(list) {
  120. this.$u.route({
  121. url: '/pages/invoiceModule/addInvoice/addInvoice',
  122. params: {
  123. invoType: list[0].value
  124. }
  125. });
  126. },
  127. /**
  128. * @description: 分页触发
  129. * @param {*} pageNo
  130. * @param {*} pageSize
  131. * @return {*}
  132. */
  133. queryList(pageNo, pageSize) {
  134. this.queryParams.pageNum = pageNo;
  135. this.queryParams.pageSize = pageSize;
  136. this.getInvoiceList();
  137. },
  138. /**
  139. * @description: 获取发票列表
  140. * @return {*}
  141. */
  142. async getInvoiceList() {
  143. const { code, data } = await this.$u.api.invoiceModuleApi.getInvoiceListApi({ ...this.queryParams });
  144. if (code === 200) {
  145. this.$refs.paging.complete(data?.pageInfo?.rows || []);
  146. }
  147. },
  148. /**
  149. * @description: 单条发票点击
  150. * @param {*} item
  151. * @return {*}
  152. */
  153. invoiceItemClick(item) {
  154. this.$u.route({
  155. url: '/pages/invoiceModule/invoiceDetails/invoiceDetails',
  156. params: {
  157. id: item.id,
  158. invoType: item.invoType
  159. }
  160. });
  161. },
  162. /**
  163. * @description: 初始化状态
  164. * @param {*} val
  165. * @return {*}
  166. */
  167. formatStatus(val) {
  168. if (!val && val !== 0) return;
  169. if (this.invoiceStatusList.length) return this.invoiceStatusList.find((v) => Number(v.dictValue) === Number(val)).dictLabel;
  170. },
  171. /**
  172. * @description: 初始化状态按钮样式
  173. * @param {*} val
  174. * @return {*}
  175. */
  176. formatStatusType(val) {
  177. const statusTypeObj = {
  178. 0: 'info',
  179. 1: 'primary',
  180. 2: 'error'
  181. };
  182. return statusTypeObj[val];
  183. },
  184. /**
  185. * @description: 初始化发票类型
  186. * @param {*} val
  187. * @return {*}
  188. */
  189. formatInvoiceType(val) {
  190. if (!val) return;
  191. if (this.chooseRecords.list.length) return this.chooseRecords.list.find((item) => Number(item.dictValue) === Number(val)).dictLabel;
  192. }
  193. }
  194. };
  195. </script>
  196. <style lang="scss" scoped>
  197. @import './myInvoice.scss';
  198. </style>