invoiceAdmin.vue 4.7 KB

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