invoiceHeaderList.vue 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. <!-- 发票抬头列表 -->
  2. <template>
  3. <view class="invoice-header">
  4. <z-paging ref="paging" v-model="invoiceHeaderList" @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="invoice-header-list">
  16. <!-- <u-swipe-action
  17. v-for="(item, index) in invoiceHeaderList"
  18. :key="index"
  19. :index="index"
  20. :show="item.show"
  21. :options="options"
  22. btn-width="120"
  23. @click="invoiceHeaderClick"
  24. bg-color="#fff"
  25. >
  26. <view class="invoice-header-list-item" @click="addInvoiceHeader(item)">
  27. <view class="left">
  28. <view class="left-item">{{ item.invoName }}</view>
  29. <view class="left-item">{{ item.invoCode }}</view>
  30. </view>
  31. <view class="center">
  32. {{ formatType(item.invoHeadType) }}
  33. </view>
  34. <view class="right">
  35. <u-icon name="arrow-right" color="#909399" size="30"></u-icon>
  36. </view>
  37. </view>
  38. </u-swipe-action> -->
  39. <view class="invoice-header-list-item" v-for="(item, index) in invoiceHeaderList" :key="index">
  40. <view class="left">
  41. <view class="left-item">{{ item.invoName }}</view>
  42. <view class="left-item">{{ item.invoCode }}</view>
  43. </view>
  44. <view class="center">
  45. {{ formatType(item.invoHeadType) }}
  46. </view>
  47. <view class="right">
  48. <u-image width="28rpx" height="28rpx" src="/static/img/edit-icon.png" @click="addInvoiceHeader(item)" />
  49. <!--
  50. <u-icon name="edit-pen" color="#909399" size="40" @click="addInvoiceHeader(item)"></u-icon>
  51. <u-icon name="trash-fill" color="#fa3534" size="40" @click="deleteInvoiceHeader(item)"></u-icon> -->
  52. </view>
  53. </view>
  54. </view>
  55. <view class="invoice-header-bottom" slot="bottom">
  56. <u-button type="primary" @click="addInvoiceHeader">新增抬头</u-button>
  57. </view>
  58. </z-paging>
  59. <u-toast ref="uToast" />
  60. </view>
  61. </template>
  62. <script>
  63. export default {
  64. data() {
  65. return {
  66. invoiceHeaderList: [],
  67. queryParams: {
  68. pageNum: 1,
  69. pageSize: 10
  70. },
  71. options: [
  72. {
  73. text: '删除',
  74. style: {
  75. backgroundColor: '#dd524d'
  76. }
  77. }
  78. ]
  79. };
  80. },
  81. methods: {
  82. /**
  83. * @description: 分页组件触发
  84. * @param {*} pageNo
  85. * @param {*} pageSize
  86. * @return {*}
  87. */
  88. queryList(pageNo, pageSize) {
  89. this.queryParams.pageNum = pageNo;
  90. this.queryParams.pageSize = pageSize;
  91. this.getList();
  92. },
  93. customBack() {
  94. this.$u.route({
  95. url: '/pages/invoiceModule/addInvoice/addInvoice'
  96. });
  97. },
  98. /**
  99. * @description: 获取列表
  100. * @return {*}
  101. */
  102. async getList() {
  103. const { code, data } = await this.$u.api.invoiceModuleApi.getInvoiceHeadListApi({ ...this.queryParams });
  104. if (code === 200) {
  105. this.$refs.paging.complete(data?.pageInfo?.rows || []);
  106. }
  107. },
  108. /**
  109. * @description: 滑动按钮点击
  110. * @param {*} index
  111. * @param {*} btnIndex
  112. * @return {*}
  113. */
  114. invoiceHeaderClick(index, btnIndex) {
  115. this.invoiceHeaderList[index].show = true;
  116. if (btnIndex === 0) {
  117. uni.showModal({
  118. title: '提示',
  119. content: '你确认删除该条发票抬头信息吗?',
  120. success: async (res) => {
  121. if (res.confirm) {
  122. const { id } = this.invoiceHeaderList[index];
  123. const { code } = await this.$u.api.invoiceModuleApi.deleteInvoiceHeaderApi({ id });
  124. if (code === 200) {
  125. this.$refs.uToast.show({
  126. title: '删除成功!',
  127. type: 'success'
  128. });
  129. this.getList();
  130. this.invoiceHeaderList[index].show = false;
  131. }
  132. }
  133. if (res.cancel) {
  134. this.invoiceHeaderList[index].show = false;
  135. console.log('取消删除');
  136. }
  137. }
  138. });
  139. }
  140. },
  141. /**
  142. * @description: 新增抬头
  143. * @return {*}
  144. */
  145. addInvoiceHeader(item) {
  146. this.$u.route({
  147. url: '/pages/invoiceModule/addInvoiceHeader/addInvoiceHeader',
  148. params: {
  149. id: item.id
  150. }
  151. });
  152. },
  153. // 删除抬头
  154. async deleteInvoiceHeader(item) {
  155. const { id } = item;
  156. const { code } = await this.$u.api.invoiceModuleApi.deleteInvoiceHeaderApi({ id });
  157. if (code === 200) {
  158. this.$refs.uToast.show({
  159. title: '删除成功!',
  160. type: 'success'
  161. });
  162. this.getList();
  163. }
  164. },
  165. /**
  166. * @description: 初始化类型
  167. * @param {*} val
  168. * @return {*}
  169. */
  170. formatType(val) {
  171. const typeObj = {
  172. 1: '企业',
  173. 2: '个人'
  174. };
  175. return typeObj[val];
  176. }
  177. }
  178. };
  179. </script>
  180. <style lang="scss" scoped>
  181. @import './invoiceHeaderList.scss';
  182. </style>