waitinvoice.vue 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607
  1. <template>
  2. <div class="invoice-wrapper">
  3. <div class="order-nav">
  4. <nuxt-link to="/mobile/center/user/invoice" tag="div"><span>开票信息</span></nuxt-link>
  5. <div class="active"><span>待开票信息</span></div>
  6. <nuxt-link to="/mobile/center/user/invoice/invoiceRecord" tag=div><span>开票记录</span></nuxt-link>
  7. </div>
  8. <div class="mobile-invoice">
  9. <div class="mi-remind-area" :class="{less: !showMoreRemind}">
  10. <p class="title">温馨提示</p>
  11. <p class="content">
  12. <span class="inline-block">1、</span>
  13. <span class="inline-block">申请发票时默认将同一店铺的订单合并开一张发票,如需分开开票,请分别申请;</span>
  14. </p>
  15. <p class="content">
  16. <span class="inline-block">2、</span>
  17. <span class="inline-block">您只能对订单状态为<b>“交易完成”</b>,且已不能再发起售后的人民币交易订单进行补开发票;</span>
  18. </p>
  19. <p class="content">
  20. <span class="inline-block">3、</span>
  21. <span class="inline-block">发票金额为产品总金额且不含运费、积分、优惠卷、促销折扣等金额;</span>
  22. </p>
  23. <p class="content">
  24. <span class="inline-block">4、</span>
  25. <span class="inline-block">发票邮寄费用将由卖家承担。</span>
  26. </p>
  27. <p class="more" @click="showMoreRemind = !showMoreRemind">{{showMoreRemind ? '收起' : '查看更多'}}
  28. <i v-show="showMoreRemind" class="iconfont icon-shangshuangjiantou"></i>
  29. <i v-show="!showMoreRemind" class="iconfont icon-xiashuangjiantou"></i>
  30. </p>
  31. </div>
  32. <div class="search-content mi-search-content">
  33. <input type="text" placeholder="商家名称/订单号" v-model="keyword">
  34. <span @click="searchMore()"><i class="iconfont icon-sousuo"></i></span>
  35. </div>
  36. <div class="mi-list-content">
  37. <ul class="mi-list">
  38. <li v-for="inv in invoiceList" @click.stop="setActive(inv)" :class="{active: inv.$active}">
  39. <div class="line">
  40. <span class="inline-block title">
  41. <label class="bottom-modal-check mobile-cart-check" :class="{active: inv.$active}">
  42. <input type="checkbox">
  43. </label>
  44. 商家名称:
  45. </span>
  46. <span class="inline-block content" @click.stop="toShopdetails(inv)">{{inv.sellername}}</span>
  47. </div>
  48. <div class="line">
  49. <span class="inline-block title">
  50. 订单号:
  51. </span>
  52. <span class="inline-block content" @click.stop="lookOrderDetail(inv)">
  53. {{inv.orderid}}
  54. </span>
  55. </div>
  56. <div class="line">
  57. <span class="inline-block title">
  58. 可开票金额(¥):
  59. </span>
  60. <span class="inline-block content pri">{{inv.price}}</span>
  61. </div>
  62. </li>
  63. </ul>
  64. </div>
  65. <div class="mi-fix-result">
  66. <label class="bottom-modal-check mobile-cart-check" :class="{active: allChecked}">
  67. <input type="checkbox" @change="setActive()">
  68. <span>全选</span>
  69. </label>
  70. <button @click="applyInvoice()">申请开票</button>
  71. </div>
  72. </div>
  73. <remind-box :title="collectResult" :timeoutCount="timeoutCount"></remind-box>
  74. <addinvoice
  75. :chooseItem="addItem"
  76. @addinvoiceBtn="addinvoiceFn"
  77. v-if="showAddinvoice"
  78. :joinType="joinType"
  79. ></addinvoice>
  80. <pull-up :searchMore="fetching" :allPage="invoices.data.totalPages" :page="page" @pullUpAction="onPullUp"></pull-up>
  81. <!-- 申请发票弹窗 -->
  82. <div class="mobile-modal" @touchmove="preventTouchMove($event)" v-if="showSend">
  83. <div class="applyinvoice_Alert" >
  84. <div class="applyinvoice_title">申请开票<span><i class="iconfont icon-guanbi1" @click="showSend = false"></i></span></div>
  85. <div ref="applyinvoiceAlert" class="scrollContent" >
  86. <div>
  87. <div class="applyinvoice-ul" v-if="invoiceArr.length > 0">
  88. <div class="addinvoice-focus clearfix">
  89. <div class="pull-left addinvoice-focus-name">发票类型:</div>
  90. <div class="pull-left clearfix">
  91. <div class="normal pull-left" style="margin-right: 0.2rem;" @click="chooseVoice('speci', 1205)" v-if="showSpeciBtn">
  92. <div class="icon" :class="waitinvoiceType === 'speci' ? 'active' : ''">
  93. <div class="icon-next"></div>
  94. </div>
  95. 增值税专票
  96. </div>
  97. <div class="normal pull-left" @click="chooseVoice('normal', 1206)" v-if="showNormalBtn">
  98. <div class="icon" :class="waitinvoiceType === 'normal' ? 'active' : ''">
  99. <div class="icon-next"></div>
  100. </div>
  101. 增值税普票
  102. </div>
  103. </div>
  104. </div>
  105. <div class="addinvoice-focus clearfix">
  106. <div class="pull-left addinvoice-focus-name">发票抬头:</div>
  107. <div class="pull-left clearfix">
  108. {{chooseItem.head}}
  109. </div>
  110. </div>
  111. <div class="addinvoice-focus clearfix" v-if="chooseItem.kind === 1205">
  112. <div class="pull-left addinvoice-focus-name">单位地址:</div>
  113. <div class="pull-left clearfix">
  114. {{chooseItem.companyAddress}}
  115. </div>
  116. </div>
  117. <div class="addinvoice-focus clearfix" v-if="chooseItem.kind === 1205">
  118. <div class="pull-left addinvoice-focus-name">单位电话:</div>
  119. <div class="pull-left clearfix">
  120. {{chooseItem.companyPhone}}
  121. </div>
  122. </div>
  123. <div class="addinvoice-focus clearfix" v-if="chooseItem.kind === 1205">
  124. <div class="pull-left addinvoice-focus-name">税务登记号:</div>
  125. <div class="pull-left clearfix">
  126. {{chooseItem.companyTaxNumber}}
  127. </div>
  128. </div>
  129. <div class="addinvoice-focus clearfix" v-if="chooseItem.kind === 1205">
  130. <div class="pull-left addinvoice-focus-name">开户银行:</div>
  131. <div class="pull-left clearfix">
  132. {{chooseItem.bankName}}
  133. </div>
  134. </div>
  135. <div class="addinvoice-focus clearfix" v-if="chooseItem.kind === 1205">
  136. <div class="pull-left addinvoice-focus-name">开户银行账号:</div>
  137. <div class="pull-left clearfix">
  138. {{chooseItem.bankAccount}}
  139. </div>
  140. </div>
  141. <div class="addinvoice-focus clearfix" >
  142. <div class="pull-left addinvoice-focus-name">收票人:</div>
  143. <div class="pull-left clearfix">
  144. {{chooseItem.name}}
  145. </div>
  146. </div>
  147. <div class="addinvoice-focus clearfix" >
  148. <div class="pull-left addinvoice-focus-name">联系电话:</div>
  149. <div class="pull-left clearfix">
  150. {{chooseItem.telephone}}
  151. </div>
  152. </div>
  153. <div class="addinvoice-focus clearfix" >
  154. <div class="pull-left addinvoice-focus-name">收票地址:</div>
  155. <div class="pull-left clearfix">
  156. <p style="line-height:0.4rem">{{chooseItem.area}}</p>
  157. <p style="line-height:0.4rem">{{chooseItem.detailAddress}}</p>
  158. </div>
  159. </div>
  160. </div>
  161. <div class="applyinvoice-ul">
  162. <div class="addinvoice-focus clearfix">
  163. <div class="pull-left addinvoice-focus-name">暂无发票信息:</div>
  164. <div class="pull-left clearfix" @click="addInvoiceNew()">
  165. <img src="/images/mobile/center/user/icon-rm-invoice.png"/>新增发票
  166. </div>
  167. </div>
  168. </div>
  169. <div class="applyinvoive_infotitle">共<a class="blue">{{applyObj.sellNum.length}}</a>个商家,<a class="blue">{{applyObj.orderNum}}</a>个订单,发票金额总计:<a class="red">¥{{applyObj.allPrice}}</a>元</div>
  170. <div class="applyinvoive_detailinfo">
  171. <div class="clearfix" v-for="info in applyObj.sellNum">
  172. <div class="pull-left">{{info.sellername}}</div>
  173. <div class="pull-right">金额:¥{{info.orderAllPrice}}</div>
  174. </div>
  175. </div>
  176. <div class="applyinvoice_controll clearfix">
  177. <div @click="showSend = false" class="pull-left">取消</div>
  178. <div class="pull-right" @click="applyInvoiceFn()">确认</div>
  179. </div>
  180. </div>
  181. </div>
  182. </div>
  183. </div>
  184. </div>
  185. </template>
  186. <script>
  187. import { EncryptionFilter } from '~utils/tools.js'
  188. import axios from '~plugins/axios'
  189. import { RemindBox, PullUp } from '~components/mobile/common'
  190. import { addinvoice } from '~components/mobile/center'
  191. import BScroll from 'better-scroll'
  192. export default {
  193. name: 'invoice-view',
  194. layout: 'mobile',
  195. middleware: 'authenticated',
  196. data () {
  197. return {
  198. showMoreRemind: false
  199. }
  200. },
  201. computed: {
  202. invoices () {
  203. return this.$store.state.invoice.data.Buyerinvoices
  204. },
  205. fetching () {
  206. return this.invoices.fetching
  207. },
  208. listActiveFlag () {
  209. let allChecked = true
  210. for (let i = 0; i < this.invoiceList.length; i++) {
  211. if (!this.invoiceList[i].$active) {
  212. allChecked = false
  213. break
  214. }
  215. }
  216. return allChecked
  217. },
  218. allChecked () {
  219. return this.invoiceList.length && this.listActiveFlag
  220. }
  221. },
  222. fetch ({store}) {
  223. return Promise.all([
  224. store.dispatch('invoice/getBuyerInvoices', {count: 10, keyword: '', page: 1, sorting: {'creattime': 'DESC'}, status: 520})
  225. ])
  226. },
  227. watch: {
  228. '$store.state.invoice.data.Buyerinvoices.data': {
  229. handler: function (val) {
  230. if (val && val.content) {
  231. if (this.isChange) {
  232. this.invoiceList = []
  233. this.isChange = false
  234. }
  235. let arr = this.baseUtils.deepCopy(val.content)
  236. arr.forEach(item => {
  237. item.$active = false
  238. })
  239. this.invoiceList = [...this.invoiceList, ...arr]
  240. }
  241. },
  242. immediate: true
  243. }
  244. },
  245. data() {
  246. return {
  247. waitinvoiceType: 'speci',
  248. showNormalBtn: true, // 是否显示普票按钮
  249. showSpeciBtn: true, // 是否显示专票按钮
  250. activeType: '',
  251. invoiceList: [],
  252. invoiceArr: [],
  253. collectResult: '',
  254. timeoutCount: 0,
  255. chooseItem: {},
  256. showAddinvoice: false,
  257. joinType: 'add',
  258. keyword: '',
  259. page: 1,
  260. showSend: false,
  261. applyObj: {
  262. sellNum: []
  263. },
  264. addItem: {}
  265. }
  266. },
  267. async asyncData() {
  268. let { data } = await axios.get('/trade/bill/list/personal')
  269. let showNormalBtn = data.find(item => {
  270. return item.kind === 1206
  271. })
  272. let showSpeciBtn = data.find(item => {
  273. return item.kind === 1205
  274. })
  275. let chooseItem = showSpeciBtn ? showSpeciBtn : showNormalBtn
  276. return {
  277. invoiceArr: data,
  278. showNormalBtn: showNormalBtn ? true: false,
  279. showSpeciBtn: showSpeciBtn ? true : false,
  280. chooseItem: chooseItem
  281. }
  282. },
  283. methods: {
  284. setActive (inv) {
  285. if (inv) {
  286. inv.$active = !inv.$active
  287. } else {
  288. // 先存储 否则会重新计算
  289. let flag = !this.allChecked
  290. this.invoiceList.forEach(item => {
  291. item.$active = flag
  292. })
  293. }
  294. },
  295. chooseVoice(str, num) {
  296. this.waitinvoiceType = str
  297. this.chooseItem = this.invoiceArr.find(obj => {
  298. return obj.kind === num
  299. })
  300. this._initScroll()
  301. },
  302. async addinvoiceFn(ty, item) {
  303. this.showAddinvoice = false
  304. if (ty) {
  305. let { data } = await axios.get('/trade/bill/list/personal')
  306. let showNormalBtn = data.find(item => {
  307. return item.kind === 1206
  308. })
  309. let showSpeciBtn = data.find(item => {
  310. return item.kind === 1205
  311. })
  312. let chooseItem = showSpeciBtn ? showSpeciBtn : showNormalBtn
  313. this.invoiceArr = data
  314. this.showNormalBtn = showNormalBtn ? true: false
  315. this.showSpeciBtn = showSpeciBtn ? true : false
  316. this.chooseItem = chooseItem
  317. }
  318. this.showSend = true
  319. },
  320. setRemindText(str) {
  321. this.collectResult = str
  322. this.timeoutCount++
  323. },
  324. // 店铺详情页
  325. toShopdetails(item) {
  326. this.$router.push(`/mobile/shop/${item.storeid}`)
  327. },
  328. // 查看订单详情
  329. lookOrderDetail(item) {
  330. let id = EncryptionFilter(item.orderid)
  331. this.$router.push(`/mobile/order/details?uuid=${id}&type=buyer&paytype=${item.paytype}`)
  332. },
  333. // 申请开票
  334. applyInvoice() {
  335. let _arr = []
  336. let _orderNum = 0
  337. let _AllPice = 0
  338. this.invoiceList.forEach(obj => {
  339. if (obj.$active === true) {
  340. _AllPice += obj.price
  341. _orderNum++
  342. let _find = _arr.find($it => {
  343. return $it.storeid === obj.storeid
  344. })
  345. if (_find) {
  346. _find.orderAllPrice += obj.price
  347. } else {
  348. obj.orderAllPrice = obj.price
  349. _arr.push(obj)
  350. }
  351. }
  352. })
  353. if (_arr.length === 0) {
  354. this.setRemindText('请勾选未开票订单')
  355. return
  356. }
  357. this.applyObj = {
  358. sellNum: _arr,
  359. orderNum: _orderNum,
  360. allPrice: _AllPice
  361. }
  362. this.showSend = true
  363. this._initScroll()
  364. },
  365. // 申请开票最后阶段
  366. applyInvoiceFn() {
  367. if (this.invoiceArr.length === 0) {
  368. this.setRemindText('请选择发票类型')
  369. return
  370. }
  371. let str = ''
  372. this.applyObj.sellNum.forEach(obj => {
  373. str === '' ? str += obj.orderid : str += ',' + obj.orderid
  374. })
  375. let json = {
  376. invoiceid: 3034,
  377. orderids: str
  378. }
  379. this.$http.post('/trade/billSubmit', json).then(res => {
  380. if (res.data instanceof Array) {
  381. this.setRemindText('申请成功')
  382. this.searchMore()
  383. this.showSend = false
  384. }
  385. })
  386. },
  387. reloadList () {
  388. this.isChange = true
  389. this.$store.dispatch('invoice/getBuyerInvoices', {count: 10, page: this.page, keyword: this.keyword, sorting: {'creattime': 'DESC'}, status: 520})
  390. },
  391. searchMore() {
  392. this.page = 1
  393. this.reloadList()
  394. },
  395. onPullUp () {
  396. this.page++
  397. this.reloadList()
  398. },
  399. _initScroll() {
  400. this.$nextTick(res => {
  401. if (!this.scroll) {
  402. this.scroll = new BScroll(this.$refs.applyinvoiceAlert, {click: true})
  403. } else {
  404. this.scroll.refresh()
  405. }
  406. })
  407. },
  408. addInvoiceNew() {
  409. this.showSend = false
  410. this.addItem = {}
  411. this.showAddinvoice = true
  412. }
  413. },
  414. components: {
  415. RemindBox,
  416. addinvoice,
  417. PullUp
  418. }
  419. }
  420. </script>
  421. <style lang="scss" scoped>
  422. @import '~assets/scss/mobileInvoice';
  423. @mixin overFlowHidden {
  424. overflow: hidden;
  425. text-overflow: ellipsis;
  426. white-space: nowrap;
  427. }
  428. @mixin lineHeight($value) {
  429. height: $value;
  430. line-height: $value;
  431. }
  432. .invoice-wrapper {
  433. background: #f1f3f6;
  434. margin: 1.26rem 0 0 0;
  435. padding: 0.82rem 0 2.04rem;
  436. height: calc(100vh - 1.26rem);
  437. overflow-y: scroll;
  438. .order-nav {
  439. background: #fff;
  440. position: fixed;
  441. width: 100%;
  442. top: 1.26rem;
  443. div {
  444. height: 0.82rem;
  445. line-height: 0.82rem;
  446. display: inline-block;
  447. width: 33.3%;
  448. text-align: center;
  449. font-size: .28rem;
  450. color: #666;
  451. &.active span{
  452. color: #3f84f6;
  453. border-bottom: 0.04rem solid #3f84f6;
  454. padding-bottom: 0.2rem;
  455. }
  456. }
  457. }
  458. .mi-remind-area {
  459. margin-top: 0.24rem;
  460. background: #fff;
  461. }
  462. .mi-list-content .mi-list li {
  463. background: #fff;
  464. &:nth-child(1) {
  465. margin-top: 0;
  466. }
  467. }
  468. .mi-search-content input {
  469. width: 7rem;
  470. margin: 0;
  471. }
  472. .mobile-invoice .mi-list-content .mi-list li .line .content {
  473. padding: 0;
  474. color: #3976f4;
  475. width: 67%;
  476. &.pri {
  477. color: #ee1111
  478. }
  479. }
  480. .mobile-invoice .mi-list-content .mi-list li .line .title {
  481. width: 33%;
  482. }
  483. .applyinvoice_Alert {
  484. background: #fff;
  485. position: fixed;
  486. bottom: 0.98rem;
  487. left: 0;
  488. width: 100%;
  489. border-top-left-radius: 5px;
  490. border-top-right-radius: 5px;
  491. padding-bottom: 0.2rem;
  492. .scrollContent {
  493. max-height: 6rem;
  494. overflow: hidden;
  495. }
  496. .applyinvoice_title {
  497. color: #333;
  498. font-size: 0.42rem;
  499. text-align: center;
  500. line-height: 1rem;
  501. font-weight: 600;
  502. position: relative;
  503. i {
  504. position: absolute;
  505. font-size: 16px;
  506. right: 0.2rem;
  507. }
  508. }
  509. .applyinvoice-ul {
  510. .addinvoice-focus {
  511. font-size: 0.28rem;
  512. color: #666;
  513. line-height: 0.6rem;
  514. margin: 0 0.2rem;
  515. img {
  516. width: 0.29rem;
  517. vertical-align: top;
  518. height: 0.33rem;
  519. margin-top: 0.12rem;
  520. margin-right: 0.04rem;
  521. }
  522. .addinvoice-focus-name {
  523. width: 2.1rem;
  524. }
  525. .normal {
  526. .icon {
  527. font-size: 0.28rem;
  528. color: #333;
  529. width: 0.5rem;
  530. height: 0.5rem;
  531. border-radius: 50%;
  532. border: 1px solid #dcdcdc;
  533. position: relative;
  534. display: inline-block;
  535. vertical-align: top;
  536. &.active .icon-next {
  537. background: #226ce7;
  538. width: 0.3rem;
  539. height: 0.3rem;
  540. border-radius: 50%;
  541. position: absolute;
  542. left: 50%;
  543. top: 50%;
  544. transform: translate3d(-50%, -50%, 0);
  545. }
  546. }
  547. }
  548. }
  549. }
  550. .applyinvoive_infotitle {
  551. color: #333;
  552. font-size: 0.28rem;
  553. @include lineHeight(0.6rem);
  554. background: #e5e5e5;
  555. padding: 0 0.2rem;
  556. .blue {
  557. color: #3e82f5;
  558. }
  559. .red{
  560. max-width: 1.6rem;
  561. @include overFlowHidden();
  562. vertical-align: middle;
  563. display: inline-block;
  564. color: #f43938
  565. }
  566. }
  567. .applyinvoive_detailinfo {
  568. color: #333;
  569. font-size: 0.28rem;
  570. padding: 0.2rem;
  571. .clearfix {
  572. @include lineHeight(0.5rem);
  573. }
  574. .pull-left {
  575. max-width: 4rem;
  576. @include overFlowHidden()
  577. }
  578. .pull-right {
  579. max-width: 3rem;
  580. @include overFlowHidden()
  581. }
  582. }
  583. .applyinvoice_controll {
  584. padding: 0 0.3rem;
  585. div {
  586. width: 3.29rem;
  587. @include lineHeight(0.77rem);
  588. color: #fff;
  589. font-size: 0.32rem;
  590. text-align: center;
  591. border-radius: 0.07rem;
  592. background: #bfbfbf;
  593. &:last-child {
  594. background: #3e82f5;
  595. }
  596. }
  597. }
  598. }
  599. }
  600. </style>