InvoiceList.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <member-base :show="false" ><view class="div container">
  3. <view class="div common-header-wrap">
  4. <view :style="'height:'+navHeight+'px'"></view>
  5. <view class="common-header-holder"></view>
  6. <view class="common-header-fixed">
  7. <title-header />
  8. <uni-nav-bar title="发票管理" class="common-header" left-icon="back" @clickLeft="goBack()">
  9. <view v-if="isFromCheckout" class="div common-btn btn" slot="right" @click="useInvoice(false)">不使用发票</view>
  10. </uni-nav-bar>
  11. </view>
  12. </view>
  13. <view class="div pb-30" v-if="invoice_list.length>0">
  14. <view class="div" v-for="item in invoice_list" :key="item.invoice_id">
  15. <view class="div invoice-item">
  16. <view class="div top-wrapper">
  17. <view class="div" v-if="item.invoice_state == 1">
  18. <view class="div title-wrapper">
  19. <label class="title" style="margin-left:0">普通发票</label>
  20. <label class="title" >{{ item.invoice_title }}</label>
  21. </view>
  22. <view class="div desc address-text">{{item.invoice_code}}</view>
  23. </view>
  24. <view class="div" v-else>
  25. <view class="div title-wrapper">
  26. <label class="title">增值税发票</label>
  27. <label class="title" >{{ item.invoice_company }}</label>
  28. </view>
  29. <view class="div desc address-text">{{item.invoice_company_code}}</view>
  30. </view>
  31. <view class="div bottom-line"></view>
  32. </view>
  33. <view class="div bottom-wrapper">
  34. <view class="div bottom-left-wrapper" v-if="isFromCheckout">
  35. <label class="subtitle" @click="useInvoice(item)">
  36. <text v-if="invoice_id == item.invoice_id" class="i iconfont">&#xe69d;</text><text v-else class="i iconfont">&#xe69e;</text>使用
  37. </label>
  38. </view>
  39. <view class="div bottom-right-wrapper">
  40. <view class="div common-btn btn-2 mr-5" @click="onEdit(item.invoice_id)">编辑</view>
  41. <view class="div common-btn btn-1" @click="onDelete(item.invoice_id)">删除</view>
  42. </view>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <view class="div" v-else>
  48. <empty-record></empty-record>
  49. </view>
  50. <view class='common-add-btn-wrapper'><view class="div common-btn common-add-btn" @click="goAdd">新增</view></view>
  51. </view></member-base>
  52. </template>
  53. <script>
  54. import {getFontSize} from '@/util/common'
  55. import TitleHeader from '../../TitleHeader'
  56. import { urlencode } from '@/util/common'
  57. import MemberBase from '../MemberBase'
  58. import { getInvoiceList, delInvoice } from '../../../api/memberInvoice'
  59. import EmptyRecord from '../../EmptyRecord'
  60. export default {
  61. name: 'InvoiceList',
  62. components:{
  63. TitleHeader,
  64. MemberBase,
  65. EmptyRecord
  66. },
  67. mounted(){
  68. // #ifdef MP-WEIXIN
  69. this.navHeight = uni.getMenuButtonBoundingClientRect().top
  70. // #endif
  71. },
  72. computed:{
  73. fontSize(){
  74. return getFontSize()
  75. },
  76. },
  77. data(){
  78. return {
  79. navHeight: 0,
  80. params:{},
  81. vat_deny: false,
  82. isFromCheckout: false,
  83. invoice_id: 0,
  84. invoice_list: []
  85. }
  86. },
  87. onLoad: function (option) {
  88. this.params=option.params
  89. this.vat_deny=option.vat_deny ? option.vat_deny : false
  90. this.isFromCheckout=option.isFromCheckout ? option.isFromCheckout : false
  91. this.invoice_id=option.invoice_id ? option.invoice_id : 0
  92. },
  93. onShow: function (option) {
  94. this.getInvoiceList()
  95. },
  96. methods:{
  97. goBack(){uni.navigateBack({delta:1})},
  98. goAdd () {
  99. uni.navigateTo({ url: '/pages/member/invoice/InvoiceForm'+'?'+urlencode( { action: 'add' } )})
  100. },
  101. useInvoice (item) {
  102. let query = JSON.parse(this.params)
  103. if (item == false) {
  104. query.invoice_id = 0
  105. query.invoice_content = '不需要发票'
  106. } else {
  107. let content = ''
  108. if (this.vat_deny) {
  109. if (item.invoice_state == 2) {
  110. uni.showToast({icon:'none',title: '订单商品不支持增值税发票'})
  111. return
  112. }
  113. }
  114. if (item.invoice_state == 2) {
  115. // content = '增值税发票 ' + item.invoice_company + ' ' + item.invoice_company_code + ' ' + item.invoice_reg_addr
  116. content = item.invoice_company
  117. } else {
  118. // content = '普通发票 ' + item.invoice_title + ' ' + item.invoice_code + ' ' + item.invoice_content
  119. content = item.invoice_title
  120. }
  121. query.invoice_id = item.invoice_id
  122. query.invoice_content = content
  123. }
  124. uni.navigateTo({ url: '/pages/member/buy/step1'+'?'+urlencode( query )})
  125. },
  126. onEdit (invoiceId) {
  127. uni.navigateTo({ url: '/pages/member/invoice/InvoiceForm'+'?'+urlencode( { invoice_id: invoiceId } )})
  128. },
  129. onDelete (invoiceId) {
  130. uni.showLoading({ title: '加载中' })
  131. delInvoice(invoiceId).then(
  132. (response) => {
  133. this.getInvoiceList()
  134. uni.hideLoading()
  135. }, (error) => {
  136. uni.hideLoading()
  137. uni.showToast({icon:'none',title: error.message})
  138. })
  139. },
  140. getInvoiceList () {
  141. getInvoiceList().then(res => {
  142. this.invoice_list = res.result.invoice_list
  143. }).catch(function (error) {
  144. uni.showToast({icon:'none',title: error.message})
  145. })
  146. }
  147. }
  148. }
  149. </script>
  150. <style scoped lang="scss">
  151. .container{}
  152. .common-header{
  153. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  154. }
  155. .invoice-item{background: #fff;padding:0 $pageSpace;margin-bottom:$modelSpace}
  156. .btn-1{border:1px solid $primaryColor;color:$primaryColor;min-width: 2rem}
  157. .btn-2{border:1px solid #333;color:#333;min-width: 2rem}
  158. .bottom{position:absolute;padding:.5rem $pageSpace;bottom:0;left:0;width:100%;box-sizing: border-box;background: #fff}
  159. .bottom-holder{height: 3rem;}
  160. .top-wrapper {
  161. position: relative;
  162. flex: 1;
  163. display: flex;
  164. flex-direction: column;
  165. justify-content: flex-start;
  166. align-items: stretch;
  167. }
  168. .title-wrapper {
  169. height: 1rem;
  170. display: flex;
  171. flex-direction: row;
  172. justify-content: flex-start;
  173. align-items: center;
  174. margin-top: 1rem;
  175. }
  176. .title {
  177. font-size:$h3;
  178. color: #333;
  179. margin-left: 0.5rem;
  180. font-weight: 700;
  181. }
  182. .desc {
  183. color: $descTextColor;
  184. font-size:$subFontSize;
  185. }
  186. .address-text {
  187. margin-top: 0.5rem;
  188. margin-bottom: 1rem;
  189. }
  190. .bottom-line {
  191. position: absolute;
  192. left: 0;
  193. bottom: 0;
  194. right: 0;
  195. border-bottom:1px dashed #eee
  196. }
  197. .bottom-wrapper {
  198. height: 2.5rem;
  199. display: flex;
  200. flex-direction: row;
  201. justify-content: space-around;
  202. align-items: stretch;
  203. align-items: center;
  204. }
  205. .bottom-left-wrapper {
  206. display: flex;
  207. flex-direction: row;
  208. justify-content: flex-start;
  209. align-items: center;
  210. }
  211. .bottom-right-wrapper {
  212. flex: 1;
  213. display: flex;
  214. flex-direction: row;
  215. justify-content: flex-end;
  216. align-items: stretch;
  217. }
  218. .edit-wrapper {
  219. display: flex;
  220. flex-direction: row;
  221. justify-content: flex-start;
  222. align-items: center;
  223. }
  224. .delete-wrapper {
  225. margin-right: 0.5rem;
  226. }
  227. .subtitle {
  228. font-size:$subFontSize;
  229. color: $descTextColor;
  230. }
  231. .subtitle .i{font-size:$h2;margin-right:.5rem;}
  232. </style>