index.vue 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286
  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" 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. </div>
  24. <div class="search-content mi-search-content">
  25. <input type="text" v-model="filterParams.keyword" @keyup.13="onFilter" placeholder="订单号/发票抬头/收票人/联系电话">
  26. <span @click="onFilter"><i class="iconfont icon-sousuo"></i></span>
  27. </div>
  28. <div class="mi-list-content">
  29. <div class="mi-lc-filters clearfix">
  30. <div class="com-select-wrap fr" @click.stop="showFilterInvoiceType = !showFilterInvoiceType">{{filterParams.invoicetype === 1206 ? '普票' : filterParams.invoicetype === 1205 ? '专票' : '类型'}}
  31. <ul class="select-list" v-show="showFilterInvoiceType">
  32. <li @click.stop="setInvoiceType(1206)">普票</li>
  33. <li @click.stop="setInvoiceType(1205)">专票</li>
  34. </ul>
  35. </div>
  36. </div>
  37. <ul class="mi-list" v-if="invoiceList.length">
  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">
  47. <i class="inv" :class="{'spec-inv' : inv.invoicetype === 1205}">{{inv.invoicetype === 1206 ? '普票' : '专票'}}</i>
  48. </span>
  49. </div>
  50. <div class="line">
  51. <span class="inline-block title">
  52. 申请时间:
  53. </span>
  54. <span class="inline-block content">{{inv.createTime | date}}</span>
  55. </div>
  56. <div class="line">
  57. <span class="inline-block title">
  58. 订单号:
  59. </span>
  60. <span class="inline-block content">
  61. <template v-for="id in inv.orderids.split(',')">
  62. <a class="link">
  63. {{id}}
  64. </a>
  65. <br/>
  66. </template>
  67. </span>
  68. </div>
  69. <div class="line">
  70. <span class="inline-block title">
  71. 可开票金额(¥):
  72. </span>
  73. <span class="inline-block content">{{inv.price}}</span>
  74. </div>
  75. <div class="line">
  76. <span class="inline-block title">
  77. 发票抬头:
  78. </span>
  79. <span class="inline-block content">{{inv.invoicetitle}}</span>
  80. </div>
  81. <div class="line">
  82. <span class="inline-block title">
  83. 收票人:
  84. </span>
  85. <span class="inline-block content">{{inv.receiverName}}</span>
  86. </div>
  87. <div class="line">
  88. <span class="inline-block title">
  89. 联系电话:
  90. </span>
  91. <span class="inline-block content">{{inv.recTel}}</span>
  92. </div>
  93. <div class="line">
  94. <span class="inline-block title">
  95. 收票地址:
  96. </span>
  97. <span class="inline-block content">{{inv.invoiceAddress}}</span>
  98. </div>
  99. </li>
  100. </ul>
  101. <empty-status
  102. :text="'暂无开票信息'"
  103. :showLink="false"
  104. v-else></empty-status>
  105. </div>
  106. <div class="mi-fix-result" v-if="invoiceList.length">
  107. <label class="bottom-modal-check mobile-cart-check" :class="{active: allChecked}">
  108. <input type="checkbox" @change="setActive()">
  109. <span>全选</span>
  110. </label>
  111. <button @click="submit">确认开票</button>
  112. </div>
  113. <remind-box :title="remindText" :timeoutCount="timeoutCount"></remind-box>
  114. <pull-up :searchMore="fetching" :allPage="invoices.data.totalPages" :page="page" @pullUpAction="onPullUp"></pull-up>
  115. <remind-ope-modal :text="'点击【确认】系统将通知买家发票已寄出,否则请点击【取消】'"
  116. :show="Boolean(operateIds)"
  117. @closeAction="closeRemindOpe"
  118. ></remind-ope-modal>
  119. </div>
  120. </template>
  121. <script>
  122. import { RemindBox, PullUp, EmptyStatus } from '~components/mobile/common'
  123. import { RemindOpeModal } from '~components/mobile/base'
  124. export default {
  125. layout: 'mobile',
  126. middleware: 'authenticated',
  127. data () {
  128. return {
  129. remindText: '',
  130. timeoutCount: '',
  131. invoiceList: [],
  132. isChange: false,
  133. page: 1,
  134. count: 10,
  135. filterParams: {
  136. invoicetype: '',
  137. keyword: ''
  138. },
  139. showFilterInvoiceType: false,
  140. operateIds: null,
  141. switchType: 'apply'
  142. }
  143. },
  144. components: {
  145. RemindBox,
  146. PullUp,
  147. RemindOpeModal,
  148. EmptyStatus
  149. },
  150. fetch ({store}) {
  151. return Promise.all([
  152. store.dispatch('invoice/getInvoices', {count: 10, page: 1, role: 'SELLER', sorting: {'createTime': 'DESC'}, status: 101})
  153. ])
  154. },
  155. watch: {
  156. '$store.state.invoice.data.invoices.data': {
  157. handler: function (val) {
  158. if (val && val.content) {
  159. if (this.isChange) {
  160. this.invoiceList = []
  161. this.isChange = false
  162. }
  163. let arr = this.baseUtils.deepCopy(val.content)
  164. arr.forEach(item => {
  165. // item.orderidArr = item.orderids.split(',')
  166. item.$active = false
  167. })
  168. this.invoiceList = [...this.invoiceList, ...arr]
  169. }
  170. },
  171. immediate: true
  172. }
  173. },
  174. computed: {
  175. invoices () {
  176. return this.$store.state.invoice.data.invoices
  177. },
  178. fetching () {
  179. return this.invoices.fetching
  180. },
  181. listActiveFlag () {
  182. let allChecked = true
  183. for (let i = 0; i < this.invoiceList.length; i++) {
  184. if (!this.invoiceList[i].$active) {
  185. allChecked = false
  186. break
  187. }
  188. }
  189. return allChecked
  190. },
  191. allChecked () {
  192. return this.invoiceList.length && this.listActiveFlag
  193. }
  194. },
  195. methods: {
  196. setRemindText: function (str) {
  197. this.remindText = str
  198. this.timeoutCount++
  199. },
  200. initParams () {
  201. this.page = 1
  202. this.filterParams.invoicetype = null
  203. this.filterParams.keyword = null
  204. this.operateIds = null
  205. },
  206. setActive (inv) {
  207. if (inv) {
  208. inv.$active = !inv.$active
  209. } else {
  210. // 先存储 否则会重新计算
  211. let flag = !this.allChecked
  212. this.invoiceList.forEach(item => {
  213. item.$active = flag
  214. })
  215. }
  216. },
  217. reloadList () {
  218. 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})
  219. },
  220. onPullUp () {
  221. this.page++
  222. this.reloadList()
  223. },
  224. onFilter () {
  225. this.isChange = true
  226. this.page = 1
  227. return this.reloadList()
  228. },
  229. setInvoiceType (type) {
  230. this.filterParams.invoicetype = type
  231. this.showFilterInvoiceType = false
  232. this.onFilter()
  233. },
  234. submit () {
  235. let arr = []
  236. this.invoiceList.forEach(item => {
  237. if (item.$active) {
  238. arr.push(item.id)
  239. }
  240. })
  241. if (arr.length) {
  242. this.operateIds = arr.join(',')
  243. } else {
  244. this.setRemindText('请先勾选开票申请')
  245. }
  246. },
  247. doSubmit () {
  248. return this.$http.put(`/trade/billSubmit/${this.operateIds}`).then(res => {
  249. if (res.data.length) {
  250. this.setRemindText('开票成功')
  251. this.initParams()
  252. this.onFilter()
  253. } else {
  254. this.setRemindText('开票失败,请重试')
  255. }
  256. }, err => {
  257. this.setRemindText(err.response.data || '开票失败,请重试')
  258. })
  259. },
  260. closeRemindOpe (flag) {
  261. if (flag) {
  262. this.doSubmit()
  263. } else {
  264. this.operateIds = null
  265. }
  266. },
  267. setSwitchType (type) {
  268. this.initParams()
  269. this.switchType = type
  270. this.onFilter()
  271. // .then(() => {
  272. // this.switchType = type
  273. // })
  274. }
  275. }
  276. }
  277. </script>
  278. <style lang="scss" scoped>
  279. @import '~assets/scss/mobileInvoice';
  280. .vendor-invoice {
  281. margin-bottom: 2.3rem;
  282. &.invoice-record {
  283. margin-bottom: .98rem;
  284. }
  285. }
  286. </style>