availableOrder.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!-- 可开发票订单 -->
  2. <template>
  3. <view class="order-box">
  4. <z-paging ref="paging" v-model="orderList" @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. slot="top"
  14. />
  15. <view class="order-box-list">
  16. <view class="order-box-list-item" v-for="(item, index) in orderList" :key="index" @click="radioClick(item)">
  17. <view class="left">
  18. <view class="left-radio small-radio">
  19. <radio value="true" :checked="currentIds.includes(item.id)" />
  20. </view>
  21. <view class="left-content">
  22. <view class="left-content-item money">¥{{ item.amount }}</view>
  23. <view class="left-content-item">{{ item.name }}</view>
  24. <view class="left-content-item time">{{ item.payTime }}</view>
  25. </view>
  26. </view>
  27. <view class="right">{{ item.vehicleNo }}</view>
  28. </view>
  29. </view>
  30. <view class="order-box-bottom" slot="bottom">
  31. <view class="order-box-bottom-radio small-radio"> <radio value="true" :checked="checkedAll" @click="checkedChange" />本页全选 </view>
  32. <view class="order-box-bottom-next">
  33. <u-button type="primary" size="medium" :disabled="!currentIds.length" @click="nextStep">下一步</u-button>
  34. </view>
  35. </view>
  36. </z-paging>
  37. <u-toast ref="uToast" />
  38. </view>
  39. </template>
  40. <script>
  41. export default {
  42. data() {
  43. return {
  44. orderList: [],
  45. currentIds: [],
  46. currentList: [],
  47. checkedAll: false,
  48. queryParams: {
  49. pageNum: 1,
  50. pageSize: 10,
  51. invoType: 1
  52. }
  53. };
  54. },
  55. watch: {
  56. currentIds(val) {
  57. this.checkedAll = val.length === this.orderList.length;
  58. }
  59. },
  60. onLoad(options) {
  61. const { orderType } = options;
  62. if (orderType) {
  63. this.queryParams.invoType = orderType;
  64. }
  65. },
  66. methods: {
  67. /**
  68. * @description: 分页触发
  69. * @param {*} pageNo
  70. * @param {*} pageSize
  71. * @return {*}
  72. */
  73. queryList(pageNo, pageSize) {
  74. this.queryParams.pageNum = pageNo;
  75. this.queryParams.pageSize = pageSize;
  76. this.getList();
  77. },
  78. customBack() {
  79. this.$u.route({
  80. url: '/pages/invoiceModule/myInvoice/myInvoice'
  81. });
  82. },
  83. /**
  84. * @description: 获取列表
  85. * @return {*}
  86. */
  87. async getList() {
  88. const { code, data } = await this.$u.api.invoiceModuleApi.getInvoiceOrderListApi({ ...this.queryParams });
  89. if (code === 200) {
  90. this.$refs.paging.complete(data?.pageInfo?.rows || []);
  91. }
  92. },
  93. /**
  94. * @description: 单项条目点击
  95. * @param {*} item
  96. * @return {*}
  97. */
  98. radioClick(item) {
  99. if (this.currentIds.includes(item.id)) {
  100. const index = this.currentIds.indexOf(item.id);
  101. this.currentIds.splice(index, 1);
  102. this.currentList.splice(index, 1);
  103. } else {
  104. this.currentIds.push(item.id);
  105. this.currentList.push(item);
  106. }
  107. },
  108. /**
  109. * @description: 全选
  110. * @return {*}
  111. */
  112. checkedChange(item) {
  113. this.checkedAll = !this.checkedAll;
  114. this.currentIds = this.checkedAll ? this.orderList.map((item) => item.id) : [];
  115. this.currentList = this.checkedAll
  116. ? this.orderList.map((item) => {
  117. return { ...item };
  118. })
  119. : [];
  120. },
  121. /**
  122. * @description: 下一步
  123. * @return {*}
  124. */
  125. nextStep() {
  126. if (this.currentIds.length) {
  127. const storageObj = {
  128. total: this.currentList.reduce((prev, curr) => {
  129. return prev + curr.amount;
  130. }, 0),
  131. ids: this.currentIds,
  132. invoType: this.queryParams.invoType
  133. };
  134. uni.setStorage({
  135. key: 'availableOrderKey',
  136. data: JSON.stringify(storageObj),
  137. success: () => {
  138. this.$u.route({
  139. url: '/pages/invoiceModule/addInvoice/addInvoice',
  140. params: {
  141. invoType: this.queryParams.invoType
  142. }
  143. });
  144. }
  145. });
  146. } else {
  147. this.$refs.uToast.show({
  148. title: '请先选择订单',
  149. type: 'warning'
  150. });
  151. }
  152. }
  153. }
  154. };
  155. </script>
  156. <style lang="scss" scoped>
  157. @import './availableOrder.scss';
  158. </style>