invoice.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. <template>
  2. <view class="pages">
  3. <view class="" :style="{height: navHeight+'px' }"></view>
  4. <view class="navbar-box">
  5. <u-navbar title="开具发票" :safeAreaInsetTop="true" @leftClick="leftClick" :titleStyle="{color:'#fff'}" leftIconColor="#fff" bgColor="#EF1818"></u-navbar>
  6. </view>
  7. <view class="page-wrap">
  8. <u-tabs
  9. :list="tabsList"
  10. lineColor="#EE0D0D"
  11. :current="tabsCurrent"
  12. :activeStyle="{color:'#EE0D0D','font-weight': '600','font-size':'30rpx'}"
  13. :inactiveStyle="{color:'#7F7F7F'}"
  14. itemStyle="width:50%;box-sizing:border-box;padding:24rpx;"
  15. @click="tabsClick"></u-tabs>
  16. <view class="block-wrap" style="margin-top: 32rpx;">
  17. <view class="form-item" v-if="tabsCurrent===0" @click="showInvoiceLine=true">
  18. <view class="til">
  19. <text>*</text>申请类型
  20. </view>
  21. <u--input placeholder="请选择申请类型" readonly border="surround" v-model="invoiceLineName" ></u--input>
  22. <!-- <view class="item-value">
  23. <text>{{formData.invoiceLine}}</text>
  24. </view> -->
  25. </view>
  26. <u-picker :show="showInvoiceLine" :columns="invoiceLineList" keyName="label" @cancel="cancelInvoiceLine" @confirm="confirmInvoiceLine" ></u-picker>
  27. <view class="form-item">
  28. <view class="til">
  29. <text>*</text>抬头名称
  30. </view>
  31. <u--input placeholder="请输入名称" border="surround" v-model="formData.name" ></u--input>
  32. </view>
  33. <view class="form-item" v-if="tabsCurrent===0">
  34. <view class="til">
  35. <text>*</text>税号
  36. </view>
  37. <u--input placeholder="请输入税号 " border="surround" v-model="formData.creditCode" ></u--input>
  38. </view>
  39. </view>
  40. <view class="block-wrap amount u-flex u-row-between">
  41. <view class="til">发票金额</view>
  42. <view class="con">¥{{invoiceInfo.invoiceAmount}}</view>
  43. </view>
  44. <view class="block-wrap">
  45. <view class="form-item">
  46. <view class="til">
  47. <text>*</text>电子邮箱
  48. </view>
  49. <u--input placeholder="请输入电子邮箱" border="surround" v-model="formData.email" ></u--input>
  50. </view>
  51. </view>
  52. </view>
  53. <view class="page-bottom">
  54. <view class="inner">
  55. <view class="btn active" v-if="cansubmit" @click="submitorder">提交</view>
  56. <view class="btn" @click="$u.toast('请完整填写表单')" v-else>提交</view>
  57. </view>
  58. </view>
  59. </view>
  60. </template>
  61. <script>
  62. import { systemInfo } from "@/mixin.js";
  63. export default {
  64. mixins: [systemInfo], // 使用mixin
  65. data() {
  66. return {
  67. staticUrl:this.$commonConfig.staticUrl,
  68. orderId:'',
  69. tabsCurrent:0,
  70. tabsList:[
  71. {name:'企业',status:'0'},
  72. {name:'个人',status:'1'}
  73. ],
  74. invoiceInfo:{},
  75. handlerList:[],
  76. formData:{
  77. name:'',
  78. creditCode :'',
  79. email:''
  80. },
  81. invoiceLine:'',
  82. showInvoiceLine:false,
  83. invoiceLineName:'',
  84. invoiceLineList:[[{label:'数电专票',id:'bs'},{label:'数电普票',id:'pc'}]]
  85. }
  86. },
  87. onShow() {
  88. },
  89. onLoad(page) {
  90. this.orderId = page.id;
  91. this.invoiceLine = page.invoiceLine;
  92. this.getSystemInfo();
  93. this.getInvoiceInfo();
  94. },
  95. computed: {
  96. // 是否全选
  97. cansubmit() {
  98. if(this.tabsCurrent===0){
  99. return this.formData.name && this.formData.creditCode && uni.$u.test.email(this.formData.email)&& this.invoiceLineName;
  100. }else{
  101. return this.formData.name && uni.$u.test.email(this.formData.email);
  102. }
  103. },
  104. },
  105. methods: {
  106. leftClick(e){
  107. let pages = getCurrentPages();
  108. if(pages.length==1){
  109. uni.$u.route('/pages/index/index')
  110. }else{
  111. uni.navigateBack()
  112. };
  113. },
  114. tabsClick(item){
  115. this.tabsCurrent = item.index;
  116. // console.log('item',item);
  117. this.setDefault();
  118. },
  119. getInvoiceInfo(){
  120. this.$u.api.getInvoiceInfo({orderId:this.orderId}).then(res=>{
  121. // console.log('res',res);
  122. this.invoiceInfo = res.data;
  123. this.handlerList = res.data.handlerList||[];
  124. this.setDefault();
  125. }).catch(err=>{
  126. console.log('getInvoiceInfo',err);
  127. })
  128. },
  129. setDefault(){
  130. if(this.handlerList.length>0){
  131. let handlerType1 = this.handlerList.find(handler => handler.handlerType === 1) || {};//个人
  132. let handlerType2 = this.handlerList.find(handler => handler.handlerType === 2) || {};//企业
  133. if(this.tabsCurrent===0){//企业
  134. this.formData.name = handlerType2.name||null;
  135. this.formData.creditCode = handlerType2.creditCode||null;
  136. this.formData.email = handlerType2.email||null;
  137. this.formData.invoiceLine = this.invoiceLine||null;
  138. if(this.formData.invoiceLine=='bs'){
  139. this.invoiceLineName = '数电专票'
  140. }else if(this.formData.invoiceLine=='pc'){
  141. this.invoiceLineName = '数电普票'
  142. }
  143. }else{
  144. this.formData.name = handlerType1.name||null;
  145. this.formData.email = handlerType1.email||null;
  146. }
  147. }
  148. },
  149. submitorder(){
  150. let params = {
  151. orderId:this.orderId,
  152. invoiceAmount:this.invoiceInfo.invoiceAmount,
  153. invoiceHandler:{
  154. handlerType:this.tabsCurrent===0?2:1,
  155. name:this.formData.name,
  156. email:this.formData.email,
  157. // mobile:this.formData.mobile
  158. }
  159. };
  160. if(this.tabsCurrent===0){//企业
  161. params.invoiceHandler.creditCode = this.formData.creditCode;
  162. params.invoiceLine = this.formData.invoiceLine;
  163. }
  164. this.$u.api.submitInvoice(params).then(res=>{
  165. uni.$u.toast(res.msg)
  166. // uni.navigateBack()
  167. setTimeout(()=>{
  168. uni.redirectTo({
  169. url: `/center/orderdetails?id=${this.orderId}`
  170. })
  171. },1500)
  172. }).catch(err=>{
  173. console.log('submitorder',err);
  174. })
  175. }
  176. }
  177. }
  178. </script>
  179. <style>
  180. page{background-color: #F7F7F9;}
  181. </style>
  182. <style lang="scss" scoped>
  183. .block-wrap{
  184. background-color: #fff;
  185. border-radius: 16rpx;
  186. padding: 22rpx 32rpx 30rpx;
  187. margin-bottom: 24rpx;
  188. .form-item{
  189. margin-bottom: 22rpx;
  190. .til{
  191. font-size: 28rpx;
  192. font-family: PingFangSC, PingFang SC;
  193. font-weight: 400;
  194. color: #333;
  195. margin-bottom: 12rpx;
  196. text{
  197. color: #EF0E0E;
  198. }
  199. }
  200. }
  201. &.amount{
  202. padding: 26rpx 32rpx;
  203. .til{
  204. margin-bottom: 0;
  205. }
  206. .con{
  207. font-size: 28rpx;
  208. font-family: SourceHanSansCN, SourceHanSansCN;
  209. font-weight: bold;
  210. color: #EF0E0E;
  211. }
  212. }
  213. }
  214. .page-bottom{
  215. $height:98rpx;
  216. position: relative;
  217. z-index: 1001;
  218. height: $height;
  219. padding: 24rpx 20rpx;
  220. .inner{
  221. position: fixed;
  222. background-color: transparent;
  223. height: $height;
  224. left: 0;
  225. right: 0;
  226. bottom: 0;
  227. padding: 24rpx 20rpx;
  228. // box-shadow: 0rpx -4rpx 12rpx 0rpx rgba(215,215,215,0.5);
  229. .btn{
  230. font-size: 28rpx;
  231. height: 100%;
  232. line-height: $height;
  233. border-radius: 50rpx;
  234. padding: 0 50rpx;
  235. background-color: #eee;
  236. color: #333;
  237. text-align: center;
  238. &.active{
  239. background: linear-gradient(90deg, #FF7979 0%, #ED0000 100%);
  240. color: #fff;
  241. }
  242. }
  243. }
  244. }
  245. </style>