index.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  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. <div class="line">
  84. <span class="inline-block title">
  85. 收票人:
  86. </span>
  87. <span class="inline-block content">{{inv.receiverName}}</span>
  88. </div>
  89. <div class="line">
  90. <span class="inline-block title">
  91. 联系电话:
  92. </span>
  93. <span class="inline-block content">{{inv.recTel}}</span>
  94. </div>
  95. <div class="line">
  96. <span class="inline-block title">
  97. 收票地址:
  98. </span>
  99. <span class="inline-block content">{{inv.invoiceAddress}}</span>
  100. </div>
  101. </li>
  102. </ul>
  103. <empty-status
  104. :text="'暂无开票信息'"
  105. :showLink="false"
  106. v-else></empty-status>
  107. </div>
  108. <div class="mi-fix-result" v-if="invoiceList.length">
  109. <label class="bottom-modal-check mobile-cart-check" :class="{active: allChecked}">
  110. <input type="checkbox" @change="setActive()">
  111. <span>全选</span>
  112. </label>
  113. <button @click="submit">确认开票</button>
  114. </div>
  115. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  116. <pull-up :searchMore="fetching" :allPage="invoices.data.totalPages" :page="page" @pullUpAction="onPullUp"></pull-up>
  117. <remind-ope-modal :text="'点击【确认】系统将通知买家发票已寄出,否则请点击【取消】'"
  118. :show="Boolean(operateIds)"
  119. @closeAction="closeRemindOpe"
  120. ></remind-ope-modal>
  121. </div>
  122. </template>
  123. <script>
  124. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  125. import { RemindOpeModal } from '~components/mobile/base'
  126. export default {
  127. layout: 'mobile',
  128. middleware: 'authenticated',
  129. data () {
  130. return {
  131. remindText: '',
  132. timeoutCount: '',
  133. invoiceList: [],
  134. isChange: false,
  135. page: 1,
  136. count: 10,
  137. filterParams: {
  138. invoicetype: '',
  139. keyword: ''
  140. },
  141. showFilterInvoiceType: false,
  142. operateIds: null,
  143. switchType: 'apply',
  144. showMoreRemind: false
  145. }
  146. },
  147. components: {
  148. RemindBox,
  149. PullUp,
  150. RemindOpeModal,
  151. EmptyStatus
  152. },
  153. fetch ({store}) {
  154. return Promise.all([
  155. store.dispatch('invoice/getInvoices', {count: 10, page: 1, role: 'SELLER', sorting: {'createTime': 'DESC'}, status: 101})
  156. ])
  157. },
  158. watch: {
  159. '$store.state.invoice.data.invoices.data': {
  160. handler: function (val) {
  161. if (val && val.content) {
  162. if (this.isChange) {
  163. this.invoiceList = []
  164. this.isChange = false
  165. }
  166. let arr = this.baseUtils.deepCopy(val.content)
  167. arr.forEach(item => {
  168. // item.orderidArr = item.orderids.split(',')
  169. // item.purchaseidArr = item.purchaseids ? item.purchaseids.split(',') : null
  170. item.$active = false
  171. })
  172. this.invoiceList = [...this.invoiceList, ...arr]
  173. }
  174. },
  175. immediate: true
  176. }
  177. },
  178. computed: {
  179. invoices () {
  180. return this.$store.state.invoice.data.invoices
  181. },
  182. fetching () {
  183. return this.invoices.fetching
  184. },
  185. listActiveFlag () {
  186. let allChecked = true
  187. for (let i = 0; i < this.invoiceList.length; i++) {
  188. if (!this.invoiceList[i].$active) {
  189. allChecked = false
  190. break
  191. }
  192. }
  193. return allChecked
  194. },
  195. allChecked () {
  196. return this.invoiceList.length && this.listActiveFlag
  197. }
  198. },
  199. methods: {
  200. setRemindText: function (str) {
  201. this.remindText = str
  202. this.timeoutCount++
  203. },
  204. initParams () {
  205. this.page = 1
  206. this.filterParams.invoicetype = null
  207. this.filterParams.keyword = null
  208. this.operateIds = null
  209. },
  210. setActive (inv) {
  211. if (inv) {
  212. inv.$active = !inv.$active
  213. } else {
  214. // 先存储 否则会重新计算
  215. let flag = !this.allChecked
  216. this.invoiceList.forEach(item => {
  217. item.$active = flag
  218. })
  219. }
  220. },
  221. reloadList () {
  222. 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})
  223. },
  224. onPullUp () {
  225. this.page++
  226. this.reloadList()
  227. },
  228. onFilter () {
  229. this.isChange = true
  230. this.page = 1
  231. return this.reloadList()
  232. },
  233. setInvoiceType (type) {
  234. this.filterParams.invoicetype = type
  235. this.showFilterInvoiceType = false
  236. this.onFilter()
  237. },
  238. submit () {
  239. let arr = []
  240. this.invoiceList.forEach(item => {
  241. if (item.$active) {
  242. arr.push(item.id)
  243. }
  244. })
  245. if (arr.length) {
  246. this.operateIds = arr.join(',')
  247. } else {
  248. this.setRemindText('请先勾选开票申请')
  249. }
  250. },
  251. doSubmit () {
  252. return this.$http.put(`/trade/billSubmit/${this.operateIds}`).then(res => {
  253. if (res.data.length) {
  254. this.setRemindText('开票成功')
  255. this.initParams()
  256. this.onFilter()
  257. } else {
  258. this.setRemindText('开票失败,请重试')
  259. }
  260. }, err => {
  261. this.setRemindText(err.response.data || '开票失败,请重试')
  262. })
  263. },
  264. closeRemindOpe (flag) {
  265. if (flag) {
  266. this.doSubmit()
  267. } else {
  268. this.operateIds = null
  269. }
  270. },
  271. setSwitchType (type) {
  272. this.initParams()
  273. this.switchType = type
  274. this.onFilter()
  275. // .then(() => {
  276. // this.switchType = type
  277. // })
  278. },
  279. goOrderDetail (inv, index) {
  280. if (inv.purchaseids) {
  281. this.$router.push(`/mobile/order/details?uuid=${this.baseUtils.enidfilter(inv.purchaseids.split(',')[index])}&type=saler`)
  282. } else {
  283. this.setRemindText('获取订单号失败')
  284. }
  285. }
  286. }
  287. }
  288. </script>
  289. <style lang="scss" scoped>
  290. @import '~assets/scss/mobileInvoice';
  291. .vendor-invoice {
  292. margin-bottom: 2.3rem;
  293. &.invoice-record {
  294. margin-bottom: .98rem;
  295. }
  296. }
  297. </style>