index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337
  1. <template>
  2. <div class="mobile-invoice mobile-content mobile-content-long vendor-invoice" :class="{'invoice-record': switchType == 'record'}" @click="showFilterInvoiceType = false">
  3. <div class="switch-head">
  4. <div class="com-switch-head">
  5. <span class="com-switch-item inline-block" :class="{active: switchType == 'apply'}" @click="setSwitchType('apply')">买家开票申请</span>
  6. <span class="com-switch-item inline-block" :class="{active: switchType == 'record'}" @click="setSwitchType('record')">开票记录</span>
  7. </div>
  8. </div>
  9. <div class="mi-remind-area" :class="{less: !showMoreRemind}" v-if="switchType == 'apply'">
  10. <p class="title">温馨提示</p>
  11. <p class="content">
  12. <span class="inline-block">1、</span>
  13. <span class="inline-block">买家只能对订单状态为<b>“交易成功”</b>,且已不能再发起售后的人民币交易订单进行补开发票。</span>
  14. </p>
  15. <p class="content">
  16. <span class="inline-block">2、</span>
  17. <span class="inline-block">发票金额为产品总金额且不含运费、积分、优惠券、促销折扣等金额。</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="more" @click="showMoreRemind = !showMoreRemind">{{showMoreRemind ? '收起' : '查看更多'}}
  24. <i v-show="showMoreRemind" class="iconfont icon-shangshuangjiantou"></i>
  25. <i v-show="!showMoreRemind" class="iconfont icon-xiashuangjiantou"></i>
  26. </p>
  27. </div>
  28. <div class="search-content mi-search-content">
  29. <input type="text" v-model="filterParams.keyword" @keyup.13="onFilter" placeholder="订单号/发票抬头/收票人/联系电话">
  30. <span @click="onFilter"><i class="iconfont icon-sousuo"></i></span>
  31. </div>
  32. <div class="mi-list-content">
  33. <div class="mi-lc-filters clearfix">
  34. <div class="com-select-wrap fr" @click.stop="showFilterInvoiceType = !showFilterInvoiceType">{{filterParams.invoicetype === 1206 ? '普票' : filterParams.invoicetype === 1205 ? '专票' : '全部'}}
  35. <ul class="select-list" v-show="showFilterInvoiceType">
  36. <li @click.stop="setInvoiceType(null)" v-if="filterParams.invoicetype">全部</li>
  37. <li @click.stop="setInvoiceType(1206)" v-if="filterParams.invoicetype != 1206">普票</li>
  38. <li @click.stop="setInvoiceType(1205)" v-if="filterParams.invoicetype != 1205">专票</li>
  39. </ul>
  40. </div>
  41. </div>
  42. <ul class="mi-list" v-if="invoiceList.length">
  43. <li v-for="inv in invoiceList" @click="setActive(inv)" :class="{active: inv.$active && switchType == 'apply'}">
  44. <div class="line">
  45. <span class="inline-block title">
  46. <label class="bottom-modal-check mobile-cart-check" :class="{active: inv.$active}">
  47. <!--<input type="checkbox">-->
  48. </label>
  49. 类型:
  50. </span>
  51. <span class="inline-block content">
  52. <i class="inv" :class="{'spec-inv' : inv.invoicetype === 1205}">{{inv.invoicetype === 1206 ? '普票' : '专票'}}</i>
  53. </span>
  54. </div>
  55. <div class="line">
  56. <span class="inline-block title">
  57. 申请时间:
  58. </span>
  59. <span class="inline-block content">{{inv.createTime | date}}</span>
  60. </div>
  61. <div class="line">
  62. <span class="inline-block title">
  63. 订单号:
  64. </span>
  65. <span class="inline-block content">
  66. <span @click.stop="goOrderDetail(inv, index)" class="block link" :key="id" v-for="(id, index) in inv.orderids.split(',')">
  67. {{id}}
  68. </span>
  69. </span>
  70. </div>
  71. <div class="line">
  72. <span class="inline-block title">
  73. 可开票金额:
  74. </span>
  75. <span class="inline-block content price">¥{{inv.price || 0}}</span>
  76. </div>
  77. <div class="line">
  78. <span class="inline-block title">
  79. 发票抬头:
  80. </span>
  81. <span class="inline-block content">{{inv.invoicetitle}}</span>
  82. </div>
  83. <template v-if="inv.invoicetype == 1205">
  84. <div class="line">
  85. <span class="inline-block title">
  86. 单位地址:
  87. </span>
  88. <span class="inline-block content">{{inv.billInfo.companyAddress || '-'}}</span>
  89. </div>
  90. <div class="line">
  91. <span class="inline-block title">
  92. 单位电话:
  93. </span>
  94. <span class="inline-block content">{{inv.billInfo.companyPhone || '-'}}</span>
  95. </div>
  96. <div class="line">
  97. <span class="inline-block title">
  98. 税务登记号:
  99. </span>
  100. <span class="inline-block content">{{inv.billInfo.companyTaxNumber || '-'}}</span>
  101. </div>
  102. <div class="line">
  103. <span class="inline-block title">
  104. 开户银行:
  105. </span>
  106. <span class="inline-block content">{{inv.billInfo.bankName || '-'}}</span>
  107. </div>
  108. <div class="line">
  109. <span class="inline-block title">
  110. 开户银行账户:
  111. </span>
  112. <span class="inline-block content">{{inv.billInfo.bankAccount || '-'}}</span>
  113. </div>
  114. </template>
  115. <div class="line">
  116. <span class="inline-block title">
  117. 收票人:
  118. </span>
  119. <span class="inline-block content">{{inv.receiverName}}</span>
  120. </div>
  121. <div class="line">
  122. <span class="inline-block title">
  123. 联系电话:
  124. </span>
  125. <span class="inline-block content">{{inv.recTel}}</span>
  126. </div>
  127. <div class="line">
  128. <span class="inline-block title">
  129. 收票地址:
  130. </span>
  131. <span class="inline-block content">{{inv.invoiceAddress}}</span>
  132. </div>
  133. </li>
  134. </ul>
  135. <empty-status
  136. :text="'暂无开票信息'"
  137. :showLink="false"
  138. v-else></empty-status>
  139. </div>
  140. <div class="mi-fix-result" v-if="invoiceList.length">
  141. <label class="bottom-modal-check mobile-cart-check" :class="{active: allChecked}">
  142. <input type="checkbox" @change="setActive()">
  143. <span>全选</span>
  144. </label>
  145. <button @click="submit">确认开票</button>
  146. </div>
  147. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  148. <pull-up :searchMore="fetching" :allPage="invoices.data.totalPages" :page="page" @pullUpAction="onPullUp"></pull-up>
  149. <remind-ope-modal :text="'点击【确认】系统将通知买家发票已寄出,否则请点击【取消】'"
  150. :show="Boolean(operateIds)"
  151. @closeAction="closeRemindOpe"
  152. ></remind-ope-modal>
  153. </div>
  154. </template>
  155. <script>
  156. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  157. import { RemindOpeModal } from '~components/mobile/base'
  158. export default {
  159. layout: 'mobile',
  160. middleware: 'authenticated',
  161. data () {
  162. return {
  163. remindText: '',
  164. timeoutCount: '',
  165. invoiceList: [],
  166. isChange: false,
  167. page: 1,
  168. count: 10,
  169. filterParams: {
  170. invoicetype: '',
  171. keyword: ''
  172. },
  173. showFilterInvoiceType: false,
  174. operateIds: null,
  175. switchType: 'apply',
  176. showMoreRemind: false
  177. }
  178. },
  179. components: {
  180. RemindBox,
  181. PullUp,
  182. RemindOpeModal,
  183. EmptyStatus
  184. },
  185. fetch ({store}) {
  186. return Promise.all([
  187. store.dispatch('invoice/getInvoices', {count: 10, page: 1, role: 'SELLER', sorting: {'createTime': 'DESC'}, status: 101})
  188. ])
  189. },
  190. watch: {
  191. '$store.state.invoice.data.invoices.data': {
  192. handler: function (val) {
  193. if (val && val.content) {
  194. if (this.isChange) {
  195. this.invoiceList = []
  196. this.isChange = false
  197. }
  198. let arr = this.baseUtils.deepCopy(val.content)
  199. arr.forEach(item => {
  200. // item.orderidArr = item.orderids.split(',')
  201. // item.purchaseidArr = item.purchaseids ? item.purchaseids.split(',') : null
  202. item.billInfo = item.billInfo ? JSON.parse(item.billInfo) : {}
  203. item.$active = false
  204. })
  205. this.invoiceList = [...this.invoiceList, ...arr]
  206. }
  207. },
  208. immediate: true
  209. }
  210. },
  211. computed: {
  212. invoices () {
  213. return this.$store.state.invoice.data.invoices
  214. },
  215. fetching () {
  216. return this.invoices.fetching
  217. },
  218. listActiveFlag () {
  219. let allChecked = true
  220. for (let i = 0; i < this.invoiceList.length; i++) {
  221. if (!this.invoiceList[i].$active) {
  222. allChecked = false
  223. break
  224. }
  225. }
  226. return allChecked
  227. },
  228. allChecked () {
  229. return this.invoiceList.length && this.listActiveFlag
  230. }
  231. },
  232. methods: {
  233. setRemindText: function (str) {
  234. this.remindText = str
  235. this.timeoutCount++
  236. },
  237. initParams () {
  238. this.page = 1
  239. this.filterParams.invoicetype = null
  240. this.filterParams.keyword = null
  241. this.operateIds = null
  242. },
  243. setActive (inv) {
  244. if (inv) {
  245. inv.$active = !inv.$active
  246. } else {
  247. // 先存储 否则会重新计算
  248. let flag = !this.allChecked
  249. this.invoiceList.forEach(item => {
  250. item.$active = flag
  251. })
  252. }
  253. },
  254. reloadList () {
  255. return this.$store.dispatch('invoice/getInvoices', {count: this.count, page: this.page, role: 'SELLER', sorting: {'createTime': 'DESC'}, status: this.switchType === 'record' ? 102 : 101, invoicetype: this.filterParams.invoicetype, keyword: this.filterParams.keyword})
  256. },
  257. onPullUp () {
  258. this.page++
  259. this.reloadList()
  260. },
  261. onFilter () {
  262. this.isChange = true
  263. this.page = 1
  264. return this.reloadList()
  265. },
  266. setInvoiceType (type) {
  267. this.filterParams.invoicetype = type
  268. this.showFilterInvoiceType = false
  269. this.onFilter()
  270. },
  271. submit () {
  272. let arr = []
  273. this.invoiceList.forEach(item => {
  274. if (item.$active) {
  275. arr.push(item.id)
  276. }
  277. })
  278. if (arr.length) {
  279. this.operateIds = arr.join(',')
  280. } else {
  281. this.setRemindText('请先勾选开票申请')
  282. }
  283. },
  284. doSubmit () {
  285. return this.$http.put(`/trade/billSubmit/${this.operateIds}`).then(res => {
  286. if (res.data.length) {
  287. this.setRemindText('开票成功')
  288. this.initParams()
  289. this.onFilter()
  290. } else {
  291. this.setRemindText('开票失败,请重试')
  292. }
  293. }, err => {
  294. this.setRemindText(err.response.data || '开票失败,请重试')
  295. })
  296. },
  297. closeRemindOpe (flag) {
  298. if (flag) {
  299. this.doSubmit()
  300. } else {
  301. this.operateIds = null
  302. }
  303. },
  304. setSwitchType (type) {
  305. this.initParams()
  306. this.switchType = type
  307. this.onFilter()
  308. // .then(() => {
  309. // this.switchType = type
  310. // })
  311. },
  312. goOrderDetail (inv, index) {
  313. if (inv.purchaseids) {
  314. this.$router.push(`/mobile/order/details?uuid=${this.baseUtils.enidfilter(inv.purchaseids.split(',')[index])}&type=saler`)
  315. } else {
  316. this.setRemindText('获取订单号失败')
  317. }
  318. }
  319. }
  320. }
  321. </script>
  322. <style lang="scss" scoped>
  323. @import '~assets/scss/mobileInvoice';
  324. .com-switch-head .com-switch-item.active {
  325. border-bottom: 0.04rem solid #3f84f6;
  326. }
  327. .vendor-invoice {
  328. .mi-list {
  329. padding-bottom: 2rem !important;
  330. }
  331. &.invoice-record {
  332. .mi-list {
  333. padding-bottom: .68rem !important;
  334. }
  335. }
  336. }
  337. </style>