invoiceTent.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650
  1. <template name="invoice">
  2. <view class="invoice-template">
  3. <!-- 发票信息 -->
  4. <view class="invoice-title" @tap.stop="hanldOperationConfim">
  5. <text class="text">发票信息:</text>
  6. <text class="iconfont icon-xiayibu"></text>
  7. </view>
  8. <view class="invoice-text">
  9. <text>{{invoiceText}}</text>
  10. </view>
  11. <!--底部选择模态层弹窗组件 -->
  12. <view class="popup spec" :class="specClass" @touchmove.stop.prevent="discard" @tap="choiceaInvoiceConfim">
  13. <!-- 遮罩层 -->
  14. <view class="mask"></view>
  15. <view class="layer" @tap.stop="discard">
  16. <view class="content clearfix">
  17. <view class="invoice-ltitle">发票类型</view>
  18. <view class="invoice-radio">
  19. <radio-group class="row-group" @change="radioChange">
  20. <label class="row-input" v-for="(item, index) in invoiceTypeList" :key="item.value">
  21. <radio class="row-radio" :value="item.value" :checked="index === current" color="#E15616"/>
  22. <view class="row-text">{{item.name}}</view>
  23. </label>
  24. </radio-group>
  25. </view>
  26. <view class="invoice-main from" v-if="invoiceType == '1'">
  27. <view class="invoice-from">
  28. <view class="label">单位名称:</view>
  29. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写单位信息(必填)" maxlength="20">
  30. </view>
  31. <view class="invoice-from">
  32. <view class="label">纳税人识别号:</view>
  33. <input class="form-input" type="text" v-model="invoiceData.corporationTaxNum" placeholder="请填写纳税人识别号(必填)" maxlength="20">
  34. </view>
  35. <view class="invoice-from">
  36. <view class="label">注册地址:</view>
  37. <input class="form-input" type="text" v-model="invoiceData.registeredAddress" placeholder="请填写单位注册地址(必填)" maxlength="30">
  38. </view>
  39. <view class="invoice-from">
  40. <view class="label">注册电话:</view>
  41. <input class="form-input" type="text" v-model="invoiceData.registeredPhone" placeholder="请填写注册电话(必填)" maxlength="15">
  42. </view>
  43. <view class="invoice-from">
  44. <view class="label">开户银行:</view>
  45. <input class="form-input" type="text" v-model="invoiceData.openBank" placeholder="请填写开户银行(必填)" maxlength="10">
  46. </view>
  47. <view class="invoice-from">
  48. <view class="label">银行账号:</view>
  49. <input class="form-input"
  50. type="text"
  51. v-model="invoiceData.bankAccountNo"
  52. placeholder="请填写银行账号(必填)"
  53. maxlength="25">
  54. </view>
  55. </view>
  56. <view class="invoice-main" v-if="invoiceType == '2'">
  57. <view class="invoice-ltitle">发票内容</view>
  58. <view class="invoice-group tit">
  59. <checkbox-group class="row-group" @change="checkboxChange">
  60. <view class="text">商品明细</view>
  61. <checkbox class="row-radio" value="明细" :checked="inventoryChecked ? true : false" color="#E15616"></checkbox>
  62. </checkbox-group>
  63. </view>
  64. <view class="invoice-ltitle">发票抬头</view>
  65. <view class="invoice-group tit">
  66. <radio-group class="row-group radio" @change="radioChangeTitle">
  67. <label class="row-input" v-for="(item, index) in invoiceTitleList" :key="item.value">
  68. <radio class="row-radio" :value="item.value" :checked="index === titleCurrent" color="#E15616"/>
  69. <view class="row-text">{{item.name}}</view>
  70. </label>
  71. </radio-group>
  72. </view>
  73. <view class="invoice-group from">
  74. <view class="group-from" v-if="invoiceData.invoiceTitleType == '0'">
  75. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写个人抬头" maxlength="20">
  76. </view>
  77. <view class="group-from" v-if="invoiceData.invoiceTitleType == '1'">
  78. <input class="form-input" type="text" v-model="invoiceData.invoiceTitle" placeholder="请填写公司抬头" maxlength="20">
  79. </view>
  80. <view class="group-from" v-if="invoiceData.invoiceTitleType == '1'">
  81. <input class="form-input" type="text" v-model="invoiceData.corporationTaxNum" placeholder="请填写纳税人识别号" maxlength="20">
  82. </view>
  83. </view>
  84. </view>
  85. <view class="invoice-main" v-if="invoiceType == '3'">
  86. <view class="invoice-none">不开具发票信息</view>
  87. </view>
  88. </view>
  89. <view class="btn">
  90. <view class="button add" @click="choiceaInvoiceConfim">完成</view>
  91. </view>
  92. </view>
  93. </view>
  94. </view>
  95. </template>
  96. <script>
  97. export default{
  98. name:"invoice",
  99. props:{
  100. invoiceDatas:{
  101. type:Object
  102. }
  103. },
  104. data() {
  105. return{
  106. invoiceText:'',
  107. specClass: '',//规格弹窗css类,控制开关动画
  108. invoiceType:'1',//发票类型
  109. current:0,
  110. titleCurrent:0,
  111. inventoryChecked:false,
  112. invoiceTypeList:[
  113. {value:'1',name:'增值税发票'},
  114. {value:'2',name:'普通发票'},
  115. {value:'3',name:'不开发票'},
  116. ],
  117. invoiceTitleList:[
  118. {value:'0',name:'个人'},
  119. {value:'1',name:'公司'},
  120. ],
  121. invoiceData:{
  122. invoiceContent:'', //商品明细
  123. invoiceTitle:'', //单位名称
  124. corporationTaxNum:'',//纳税人识别号
  125. registeredAddress: '',//单位地址
  126. registeredPhone:'', //注册电话
  127. openBank:'', //开户银行
  128. bankAccountNo: '' ,//银行账号
  129. invoiceTitleType:'0',//发票抬头类型 1企业 0个人
  130. },
  131. }
  132. },
  133. created(){
  134. this.initData(this.invoiceDatas)
  135. },
  136. computed: {
  137. },
  138. methods:{
  139. initData(res) {
  140. if(res){
  141. this.invoiceText = '无发票信息'
  142. }else{
  143. this.invoiceData = res
  144. this.invoiceText = res.invoiceTitle
  145. this.invoiceData.bankAccountNo = this.$reg.bankRegex(res.bankAccountNo)
  146. }
  147. },
  148. choiceaInvoiceConfim(){
  149. switch(this.invoiceType){
  150. case '1':
  151. this.choiceaInvoiceFirst()
  152. this.invoiceText = this.invoiceData.invoiceTitle
  153. break;
  154. case '2':
  155. this.choiceaInvoiceTwo()
  156. this.invoiceText = this.invoiceData.invoiceTitle
  157. break;
  158. case '3':
  159. this.choiceaInvoiceThree()
  160. this.invoiceText = '不开发票'
  161. break;
  162. }
  163. },
  164. choiceaInvoiceFirst(){//增值税发票
  165. if(this.invoiceData.invoiceTitle == ""){
  166. this.$util.msg('请输入单位名称',2000)
  167. return
  168. }
  169. if(this.invoiceData.corporationTaxNum == ""){
  170. this.$util.msg('请输入纳税人识别号',2000)
  171. return
  172. }
  173. if(this.invoiceData.registeredAddress == ""){
  174. this.$util.msg('请输入单位地址',2000)
  175. return
  176. }
  177. if(this.invoiceData.registeredPhone == ""){
  178. this.$util.msg('请输入注册电话',2000)
  179. return
  180. }
  181. if(this.invoiceData.openBank == ""){
  182. this.$util.msg('请输入开户银行',2000)
  183. return
  184. }
  185. if(this.invoiceData.bankAccountNo == ""){
  186. this.$util.msg('请输入银行账号',2000)
  187. return
  188. }
  189. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:2}))
  190. this.hideSpec()
  191. },
  192. choiceaInvoiceTwo(){//普通发票
  193. if(this.invoiceData.invoiceContent == ''){
  194. this.$util.msg('请选择商品明细',2000)
  195. return
  196. }
  197. switch(this.invoiceData.invoiceTitleType){
  198. case '0':
  199. if(this.invoiceData.invoiceTitle == ""){
  200. this.$util.msg('请输入个人抬头',2000)
  201. return
  202. }
  203. break;
  204. case '1':
  205. if(this.invoiceData.invoiceTitle == ""){
  206. this.$util.msg('请输入公司抬头',2000)
  207. return
  208. }
  209. if(this.invoiceData.corporationTaxNum == ""){
  210. this.$util.msg('请输入纳税人识别号',2000)
  211. return
  212. }
  213. break;
  214. }
  215. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:1}))
  216. this.hideSpec()
  217. },
  218. choiceaInvoiceThree(){//不开发票
  219. this.$emit('handleChoiceaInvoice',Object.assign(this.invoiceData,'',{type:0}))
  220. this.hideSpec()
  221. },
  222. hideSpec() {//关闭弹窗
  223. this.specClass = 'hide';
  224. setTimeout(() => {
  225. this.specClass = 'none';
  226. }, 200);
  227. },
  228. hanldOperationConfim(){//显示发票弹窗
  229. this.specClass = 'show';
  230. },
  231. radioChange(e) {
  232. this.invoiceType = e.target.value;
  233. for (let i = 0; i < this.invoiceTypeList.length; i++) {
  234. if (this.invoiceTypeList[i].value === this.invoiceType) {
  235. this.current = i;
  236. break;
  237. }
  238. }
  239. },
  240. radioChangeTitle(e) {
  241. this.invoiceData.invoiceTitleType = e.target.value;
  242. for (let i = 0; i < this.invoiceTitleList.length; i++) {
  243. if (this.invoiceTitleList[i].value === this.invoiceData.invoiceTitleType) {
  244. this.titleCurrent = i;
  245. break;
  246. }
  247. }
  248. },
  249. checkboxChange(e){
  250. this.invoiceData.invoiceContent = e.detail.value[0]
  251. },
  252. inputBankNum(val) {
  253. if (/\S{5}/.test(val)) {
  254. this.invoiceData.bankAccountNo = val.replace(/\s/g, '').replace(/(.{4})/g, "$1 ");
  255. }
  256. },
  257. discard(){
  258. //丢弃
  259. }
  260. }
  261. }
  262. </script>
  263. <style lang="scss">
  264. .invoice-template{
  265. width: 100%;
  266. height: auto;
  267. background: #FFFFFF;
  268. float: left;
  269. margin-top: 24rpx;
  270. .invoice-title{
  271. width: 702rpx;
  272. padding: 0 24rpx;
  273. height: 88rpx;
  274. line-height: 88rpx;
  275. position: relative;
  276. border-bottom: 1px solid #EBEBEB;
  277. .text{
  278. font-size: $font-size-28;
  279. color: $text-color;
  280. }
  281. .iconfont{
  282. width: 50rpx;
  283. height: 88rpx;
  284. line-height: 88rpx;
  285. color: #999999;
  286. display: block;
  287. position: absolute;
  288. right: 0;
  289. top: 0;
  290. }
  291. }
  292. .invoice-text{
  293. width: 702rpx;
  294. padding: 0 24rpx;
  295. font-size: $font-size-24;
  296. color: #666666;
  297. line-height: 60rpx;
  298. }
  299. .invoice-ltitle{
  300. width: 100%;
  301. line-height: 60rpx;
  302. height: 60rpx;
  303. font-size: $font-size-28;
  304. color: #333333;
  305. }
  306. .invoice-radio{
  307. width: 100%;
  308. height: 88rpx;
  309. line-height: 88rpx;
  310. display: flex;
  311. border-bottom: 1px solid #EBEBEB;
  312. .row-group{
  313. flex:1;
  314. display: flex;
  315. }
  316. .row-input{
  317. flex: 1;
  318. height: 88rpx;
  319. line-height: 88rpx;
  320. }
  321. .row-radio{
  322. float: left;
  323. transform: scale(0.6);
  324. }
  325. .row-text{
  326. font-size: $font-size-24;
  327. color: $text-color;
  328. }
  329. }
  330. .invoice-main{
  331. width: 100%;
  332. height: auto;
  333. margin-top: 30rpx;
  334. &.from{
  335. padding-bottom: 40rpx;
  336. }
  337. .invoice-none{
  338. line-height: 60rpx;
  339. height: 60rpx;
  340. font-size: $font-size-24;
  341. color: #666666;
  342. text-align: center;
  343. }
  344. .invoice-from{
  345. width: 662rpx;
  346. height: 40rpx;
  347. padding: 20rpx;
  348. line-height: 40rpx;
  349. align-items: flex-start;
  350. font-size: $font-size-28;
  351. color: $text-color;
  352. background: #F7F7F7;
  353. border-radius: 14rpx;
  354. margin-bottom: 20rpx;
  355. .label{
  356. height: 40rpx;
  357. line-height: 40rpx;
  358. float: left;
  359. }
  360. .form-input{
  361. height: 40rpx;
  362. line-height: 40rpx;
  363. flex-grow: 1;
  364. padding-left: 20rpx;
  365. }
  366. }
  367. .invoice-group{
  368. width: 100%;
  369. height: 88rpx;
  370. display: flex;
  371. border-bottom: 1px solid #EBEBEB;
  372. &.tit{
  373. margin-bottom: 30rpx;
  374. }
  375. &.from{
  376. margin-bottom: 30rpx;
  377. border-bottom: 1px solid #FFFFFF;
  378. flex-direction: row;
  379. display: block;
  380. .group-from{
  381. flex: 1;
  382. height: 40rpx;
  383. padding: 20rpx;
  384. line-height: 40rpx;
  385. align-items: flex-start;
  386. font-size: $font-size-24;
  387. color: $text-color;
  388. background: #F7F7F7;
  389. border-radius: 14rpx;
  390. margin-bottom: 20rpx;
  391. .form-input{
  392. height: 40rpx;
  393. line-height: 40rpx;
  394. flex-grow: 1;
  395. }
  396. }
  397. }
  398. .row-group{
  399. line-height: 88rpx;
  400. flex: 1;
  401. .text{
  402. font-size: $font-size-24;
  403. color: $text-color;
  404. line-height: 88rpx;
  405. float: left;
  406. }
  407. .row-radio{
  408. float: right;
  409. transform: scale(0.8);
  410. border-radius: 50%;
  411. }
  412. &.radio{
  413. display: flex;
  414. .row-input{
  415. flex: 1;
  416. height: 88rpx;
  417. line-height: 88rpx;
  418. }
  419. .row-radio{
  420. float: left;
  421. transform: scale(0.6);
  422. }
  423. .row-text{
  424. font-size: $font-size-24;
  425. color: $text-color;
  426. }
  427. }
  428. }
  429. }
  430. }
  431. }
  432. /* 加入购物模态层*/
  433. @keyframes showPopup {
  434. 0% {
  435. opacity: 0;
  436. }
  437. 100% {
  438. opacity: 1;
  439. }
  440. }
  441. @keyframes hidePopup {
  442. 0% {
  443. opacity: 1;
  444. }
  445. 100% {
  446. opacity: 0;
  447. }
  448. }
  449. @keyframes showLayer {
  450. 0% {
  451. transform: translateY(0);
  452. }
  453. 100% {
  454. transform: translateY(-100%);
  455. }
  456. }
  457. @keyframes hideLayer {
  458. 0% {
  459. transform: translateY(-100%);
  460. }
  461. 100% {
  462. transform: translateY(0);
  463. }
  464. }
  465. @keyframes showAmnation {
  466. 0% {
  467. top: -12rpx;
  468. opacity: 0;
  469. }
  470. 50% {
  471. top: -60rpx;
  472. opacity: 1;
  473. }
  474. 100% {
  475. top: -100rpx;
  476. opacity: 0;
  477. }
  478. }
  479. @keyframes hideAmnation {
  480. 0% {
  481. top: -100rpx;
  482. opacity: 0;
  483. }
  484. 100% {
  485. top: -12rpx;
  486. opacity: 0;
  487. }
  488. }
  489. .popup {
  490. position: fixed;
  491. top: 0;
  492. width: 100%;
  493. height: 100%;
  494. z-index: 999;
  495. display: none;
  496. .mask{
  497. position: fixed;
  498. top: 0;
  499. width: 100%;
  500. height: 100%;
  501. z-index: 21;
  502. background-color: rgba(0, 0, 0, 0.6);
  503. }
  504. .layer {
  505. position: absolute;
  506. z-index: 22;
  507. bottom: -1010rpx;
  508. width: 702rpx;
  509. padding: 24rpx 24rpx 65rpx 24rpx;
  510. height: 920rpx;
  511. border-radius: 40rpx 40rpx 0 0;
  512. background-color: #fff;
  513. display: flex;
  514. flex-wrap: wrap;
  515. align-content: space-between;
  516. .content {
  517. width: 100%;
  518. }
  519. .btn {
  520. width: 100%;
  521. height: 88rpx;
  522. display: flex;
  523. .button {
  524. width: 702rpx;
  525. height: 88rpx;
  526. color: #fff;
  527. display: flex;
  528. align-items: center;
  529. justify-content: center;
  530. font-size: $font-size-28;
  531. border-radius: 14rpx;
  532. background: $btn-confirm;
  533. }
  534. }
  535. }
  536. &.show {
  537. display: block;
  538. .mask{
  539. animation: showPopup 0.2s linear both;
  540. }
  541. .layer {
  542. animation: showLayer 0.2s linear both;
  543. }
  544. }
  545. &.hide {
  546. display: block;
  547. .mask{
  548. animation: hidePopup 0.2s linear both;
  549. }
  550. .layer {
  551. animation: hideLayer 0.2s linear both;
  552. }
  553. }
  554. &.none {
  555. display: none;
  556. }
  557. &.service {
  558. .row {
  559. margin: 30upx 0;
  560. .title {
  561. font-size: 30upx;
  562. margin: 10upx 0;
  563. }
  564. .description {
  565. font-size: 28upx;
  566. color: #999;
  567. }
  568. }
  569. }
  570. .layer-smimg{
  571. width: 114rpx;
  572. height: 114rpx;
  573. float: left;
  574. border-radius: 10rpx;
  575. margin-right: 24rpx;
  576. image{
  577. width: 114rpx;
  578. height: 114rpx;
  579. border-radius: 10rpx;
  580. }
  581. }
  582. .layer-nunbox{
  583. justify-content: space-between;
  584. align-items: center;
  585. width: 536rpx;
  586. height: 88rpx;
  587. padding: 13rpx 0 0 0;
  588. float: left;
  589. .layer-nunbox-t{
  590. width: 100%;
  591. height:44rpx;
  592. position:relative;
  593. display: flex;
  594. .layer-nunbox-text{
  595. line-height: 44rpx;
  596. font-size: $font-size-28;
  597. }
  598. .number-box{
  599. display: flex;
  600. justify-content: center;
  601. align-items: center;
  602. .iconfont{
  603. font-size: $font-size-32;
  604. padding:0 20rpx;
  605. font-size: $text-color;
  606. }
  607. .btn-input{
  608. width: 62rpx;
  609. height: 48rpx;
  610. line-height: 48rpx;
  611. background: #F8F8F8;
  612. border-radius: 4rpx;
  613. text-align: center;
  614. font-size: $font-size-28;
  615. }
  616. }
  617. .product-step{
  618. position: absolute;
  619. left: 45rpx;
  620. bottom: 0;
  621. height: 44rpx;
  622. background: #FFFFFF;
  623. }
  624. }
  625. .layer-nunbox-b{
  626. width: 100%;
  627. height:44rpx;
  628. margin-top: 13rpx;
  629. }
  630. .text{
  631. line-height: 44rpx;
  632. font-size: $font-size-28;
  633. .p{
  634. color: #FF2A2A;
  635. }
  636. .p:first-child{
  637. margin-left: 30rpx;
  638. }
  639. .p.sm{
  640. font-size: $font-size-24;
  641. }
  642. }
  643. }
  644. }
  645. </style>