availableOrder.vue 4.0 KB

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