invoiceAdmin.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. <template>
  2. <view class="curpage">
  3. <view class="list" v-for="item,index in list" :key="index">
  4. <view class="title">
  5. <view class="">
  6. {{item.name}}
  7. </view>
  8. <view class="" style="margin: 10rpx 0;">
  9. <text style="color: #666666;">类型:</text>
  10. {{item.type}}
  11. </view>
  12. <view class="" v-if="item.type=='企业'">
  13. <text style="color: #666666;">税号:</text>
  14. {{item.tax_no}}
  15. </view>
  16. </view>
  17. <view class="icon">
  18. <text @click="goendit(item)">
  19. 编辑
  20. </text>
  21. <text class="line"></text>
  22. <text class="dele" @click="dele(item.id)">
  23. 删除
  24. </text>
  25. </view>
  26. </view>
  27. <view class="" style="height: 1rpx;margin-bottom: 144rpx;"></view>
  28. <view class="navbar" @click="add">
  29. + 新增常用发票
  30. </view>
  31. </view>
  32. </template>
  33. <script>
  34. export default {
  35. data() {
  36. return {
  37. showSex: false,
  38. id: 1,
  39. list: []
  40. }
  41. },
  42. onLoad() {
  43. this.init()
  44. },
  45. onShow() {
  46. let token = uni.getStorageSync("token")
  47. if (!token) {
  48. //未登录
  49. uni.showToast({
  50. title: "请先登录",
  51. icon: 'none'
  52. })
  53. setTimeout(() => {
  54. uni.navigateBack({
  55. delta: 1
  56. })
  57. }, 1500)
  58. return false
  59. }
  60. this.init()
  61. },
  62. methods: {
  63. init() {
  64. uni.$u.http.post('/api/invoice/list', {
  65. custom: {
  66. auth: true
  67. }
  68. }).then((res) => {
  69. console.log(res)
  70. res.forEach(item => {
  71. if (item.type == 1) {
  72. item.type = "个人"
  73. } else if (item.type == 2) {
  74. item.type = "企业"
  75. }
  76. })
  77. this.list = res
  78. }).catch((err) => {
  79. console.log(err)
  80. })
  81. },
  82. // 编辑发票
  83. goendit(item) {
  84. uni.navigateTo({
  85. url: `/pages/invoice/invoiceEndit?state=0&info=${JSON.stringify(item)}`
  86. })
  87. },
  88. // 增加发票
  89. add() {
  90. uni.navigateTo({
  91. url: "/pages/invoice/invoiceEndit?state=1"
  92. })
  93. },
  94. // 删除发票
  95. dele(id) {
  96. uni.showModal({
  97. title: "提示",
  98. content: "确认删除吗?",
  99. success: (res) => {
  100. if (res.confirm) {
  101. this.$showLoadding("删除中")
  102. uni.$u.http.post('/api/invoice/delete', {
  103. id
  104. }, {
  105. custom: {
  106. auth: true
  107. }
  108. }).then((res) => {
  109. uni.hideLoading()
  110. this.$toast("删除成功")
  111. this.init()
  112. }).catch((err) => {
  113. console.log(err)
  114. uni.showToast({
  115. icon: "error",
  116. title: err.message,
  117. })
  118. })
  119. }
  120. }
  121. })
  122. }
  123. }
  124. }
  125. </script>
  126. <style lang="less">
  127. page {
  128. background-color: #F4F4F4;
  129. font-size: 28rpx;
  130. }
  131. .curpage {
  132. .list {
  133. background: #FFFFFF;
  134. box-shadow: 0px 2rpx 4rpx 0px rgba(0, 0, 0, 0.02);
  135. border-radius: 16rpx 16rpx 16rpx 32rpx;
  136. margin: 30rpx;
  137. .title {
  138. padding: 30rpx;
  139. border-bottom: 1rpx solid #E3E3E3;
  140. }
  141. .dele {
  142. // border-left: 1rpx solid #1E9F6A;
  143. // padding-left: 40rpx;
  144. margin-right: 40rpx;
  145. }
  146. .icon {
  147. text-align: right;
  148. padding: 40rpx 0rpx;
  149. color: #1E9F6A;
  150. .line {
  151. display: inline-block;
  152. width: 1px;
  153. height: 30rpx;
  154. background-color: #1E9F6A;
  155. margin: 0 40rpx -4rpx;
  156. }
  157. }
  158. }
  159. }
  160. .navbar {
  161. padding: 30rpx 0;
  162. text-align: center;
  163. background: #fff;
  164. color: #1E9F6A;
  165. bottom: 0;
  166. margin: 0 auto;
  167. left: 0;
  168. position: fixed;
  169. width: 100%;
  170. // margin-top: 144rpx;
  171. }
  172. </style>