invoiceManagement.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view>
  3. <u-navbar title="发票管理" title-color="#101010" >
  4. <view class="slot" slot="right" @click="gotoUrl('/pages/invoiceManagement/InvoiceTitleManagement')">
  5. 抬头管理
  6. </view>
  7. </u-navbar>
  8. <!-- 标签 -->
  9. <view class="tabs">
  10. <u-tabs :list="list" :is-scroll="false" bar-width="100" :current="current" @change="change"></u-tabs>
  11. </view>
  12. <!-- 未开发票 -->
  13. <view class="not-invioced" v-if="current==0">
  14. <u-checkbox-group @change="selectOne" style="width: 100%;" >
  15. <view class="invoice-item" v-for="(item,i) in list1" :key="item" >
  16. <view class="radio">
  17. <label class="radio">
  18. <u-checkbox v-model="item.checked" :value="item.id" /><text></text>
  19. </label>
  20. </view>
  21. <view class="infos">
  22. <view class="title">
  23. <view class="text">
  24. {{thisparseUnixTime(item.createTime)}}{{item.remark}}扣费
  25. </view>
  26. <view class="money">
  27. {{item.amountABS}}元
  28. </view>
  29. </view>
  30. </view>
  31. </view>
  32. </u-checkbox-group>
  33. <u-divider :isnone="list1.length==0" nonetext="没有找到相关内容"
  34. border-color="#CFD2D5">已经到底了</u-divider>
  35. </view>
  36. <!-- 已开发票 -->
  37. <view class="invoiced" v-if="current==1">
  38. <view class="invoice-item" v-for="(item,i) in list2"
  39. @click="gotoUrl('/pages/invoiceManagement/invoiceDetails?id='+item.id)"
  40. :key="i" >
  41. <view class="infos">
  42. <view class="title">
  43. <view class="text">
  44. {{item.title}}
  45. </view>
  46. <view :class="{
  47. state:!item.image,
  48. state2:item.image,
  49. }" >
  50. {{item.image?'已开票':'开票中'}}
  51. </view>
  52. </view>
  53. <view class="item">
  54. <view class="name">
  55. 发票金额
  56. </view>
  57. <view class="value">
  58. {{item.amount}}元
  59. </view>
  60. </view>
  61. <view class="item">
  62. <view class="name">
  63. 抬头类型
  64. </view>
  65. <view class="value">
  66. {{item.headerType=='1'?'企业单位':''}}{{item.headerType=='2'?'个人/非企业单位':''}}
  67. </view>
  68. </view>
  69. <view class="item" v-if="item.headerType=='1'" >
  70. <view class="name">
  71. 发票类型
  72. </view>
  73. <view class="value">
  74. {{item.type=='1'?'增值税专票':''}}{{item.type=='2'?'增值税普票':''}}
  75. </view>
  76. </view>
  77. <view class="item">
  78. <view class="name">
  79. 申请时间
  80. </view>
  81. <view class="value">
  82. {{item.createTime}}
  83. </view>
  84. </view>
  85. </view>
  86. </view>
  87. <!-- <view class="invoice-item" >
  88. <view class="infos">
  89. <view class="title">
  90. <view class="text">
  91. 2024年1月扣费发票
  92. </view>
  93. <view class="state2">
  94. 已开票
  95. </view>
  96. </view>
  97. <view class="item">
  98. <view class="name">
  99. 发票金额
  100. </view>
  101. <view class="value">
  102. 1000.00元
  103. </view>
  104. </view>
  105. <view class="item">
  106. <view class="name">
  107. 发票抬头
  108. </view>
  109. <view class="value">
  110. 联通公司
  111. </view>
  112. </view>
  113. <view class="item">
  114. <view class="name">
  115. 申请时间
  116. </view>
  117. <view class="value">
  118. 2024-02-07 16:00:00
  119. </view>
  120. </view>
  121. </view>
  122. </view> -->
  123. <u-divider :isnone="list2.length==0" v-if="list2.length==recordsTotal2" nonetext="没有找到相关内容"
  124. border-color="#CFD2D5">已经到底了</u-divider>
  125. </view>
  126. <!-- 底部 -->
  127. <view class="bottom" v-if="current==0">
  128. <view class="all">
  129. <label class="radio">
  130. <u-checkbox-group @change="selectAll">
  131. <u-checkbox v-model="checkedAll" value="1" /><text></text>
  132. </u-checkbox-group>
  133. </label>
  134. </view>
  135. <view class="total">
  136. <view class="money">
  137. 共{{sumCollectionMoney}}元
  138. </view>
  139. <view class="amount">
  140. {{sumCollection.length}}张发票
  141. </view>
  142. </view>
  143. <view class="btn-box">
  144. <button class="btn" @click="submit" >去开票</button>
  145. </view>
  146. </view>
  147. </view>
  148. </template>
  149. <script>
  150. import * as API from '@/apis/pagejs/invoiceApi.js'
  151. import {
  152. parseUnixTime
  153. } from '@/apis/utils'
  154. export default {
  155. data() {
  156. return {
  157. list: [{
  158. id:0,
  159. name: '未开发票'
  160. }, {
  161. id:1,
  162. name: '已开发票'
  163. }],
  164. current: 0,
  165. checkedAll:false,
  166. checkboxList:[],
  167. list1:[],
  168. recordsTotal1:0,
  169. list2:[],
  170. recordsTotal2:0,
  171. pageIndex:1,
  172. }
  173. },
  174. onLoad() {
  175. this.getInvoiceList1()
  176. },
  177. onReachBottom() {
  178. if(this.current==1){
  179. var list=this.list2;
  180. var recordsTotal=this.recordsTotal2;
  181. if (list.length < recordsTotal) {
  182. this.myLoadmore();
  183. }
  184. }
  185. },
  186. computed:{
  187. sumCollectionMoney(){
  188. var amounts=[];
  189. let totalAmount =0
  190. this.list1.forEach(item=>{
  191. //item.checked=()
  192. if(item.checked){
  193. amounts.push(item.amountABS)
  194. }
  195. })
  196. totalAmount = amounts.reduce((accumulator, currentValue) => {
  197. return accumulator + currentValue;
  198. }, 0);
  199. return totalAmount.toFixed(2)
  200. },
  201. sumCollection(){
  202. var sz=[];
  203. this.list1.forEach(item=>{
  204. //item.checked=()
  205. if(item.checked){
  206. sz.push(item.id)
  207. }
  208. })
  209. return sz
  210. }
  211. },
  212. methods: {
  213. myLoadmore() {
  214. this.pageIndex+=1;
  215. this.getInvoiceList2()
  216. },
  217. submit(){
  218. // var sz=[];
  219. // this.list1.forEach(item=>{
  220. // //item.checked=()
  221. // if(item.checked){
  222. // sz.push(item.id)
  223. // }
  224. // })
  225. if(this.sumCollection.length==0){
  226. uni.showToast({
  227. icon: "none",
  228. title: "请勾选所需的开票项目",
  229. })
  230. return
  231. }
  232. uni.navigateTo({
  233. url:"/pages/invoiceManagement/issueInvoice?ids="+this.sumCollection.join(),
  234. events: {
  235. refreshData: () => {
  236. this.init()
  237. }
  238. }
  239. })
  240. // uni.showLoading({
  241. // mask:true,title:'加载中...'
  242. // })
  243. // API.openInvoiceByRecordIds({
  244. // recordIds:this.sumCollection.join()
  245. // }).then((response) => {
  246. // uni.hideLoading();
  247. // //this.list=response.data.data;
  248. // this.companyTypes=response.data.companyTypes;
  249. // this.personTypes=response.data.personTypes;
  250. // }).catch(error => {
  251. // uni.hideLoading();
  252. // })
  253. },
  254. selectOne(e){
  255. this.checkedAll=false
  256. this.$forceUpdate()
  257. },
  258. selectAll(e){
  259. console.log(e)
  260. var sz=e
  261. this.list1.forEach(item=>{
  262. //item.checked=()
  263. this.$set(item,'checked',sz.length>0)
  264. })
  265. // this.$forceUpdate()
  266. },
  267. thisparseUnixTime(time){
  268. return parseUnixTime(time,'{y}年{m}月{d}日')
  269. },
  270. init(){
  271. this.pageIndex=1;
  272. this.current=0;
  273. this.getInvoiceList1()
  274. },
  275. change(index) {
  276. this.current = index;
  277. if(this.current==0){
  278. this.getInvoiceList1()
  279. }else{
  280. this.getInvoiceList2()
  281. }
  282. },
  283. addInfo(url) {
  284. var url = url;
  285. uni.navigateTo({
  286. url: url,
  287. events: {
  288. refreshData: () => {
  289. this.init()
  290. }
  291. }
  292. })
  293. },
  294. getInvoiceList1(){
  295. uni.showLoading({
  296. mask:true,title:'加载中...'
  297. })
  298. API.invoiceList({
  299. status:0,
  300. pageIndex:1,
  301. pageSize:9999
  302. }).then((response) => {
  303. uni.hideLoading();
  304. this.list1=response.data.data;
  305. }).catch(error => {
  306. uni.hideLoading();
  307. uni.showToast({
  308. icon: "none",
  309. title: error
  310. })
  311. })
  312. },
  313. getInvoiceList2(){
  314. uni.showLoading({
  315. mask:true,title:'加载中...'
  316. })
  317. API.invoiceList({
  318. status:1,
  319. pageIndex: this.pageIndex,
  320. pageSize: 20,
  321. }).then((res) => {
  322. uni.hideLoading();
  323. //this.list2=response.data.data;
  324. var list=[]
  325. if (this.pageIndex == 1) {
  326. list = res.data.data;
  327. } else {
  328. list = [
  329. ...this.list2,
  330. ...res.data.data
  331. ];
  332. }
  333. this.list2=list;
  334. this.recordsTotal2=res.data.recordsTotal;
  335. }).catch(error => {
  336. uni.hideLoading();
  337. uni.showToast({
  338. icon: "none",
  339. title: error
  340. })
  341. })
  342. },
  343. }
  344. }
  345. </script>
  346. <style lang="scss" scoped>
  347. .slot{
  348. color: rgba(16,16,16,1);
  349. font-size: 32rpx;
  350. margin-right: 32rpx;
  351. }
  352. // 标签
  353. .tabs{
  354. position: fixed;
  355. background-color: #fff;
  356. width: 100%;
  357. /deep/.u-tabs{
  358. width: 400rpx;
  359. margin: 0 auto;
  360. }
  361. }
  362. .invoiced,.not-invioced{
  363. margin-top: 100rpx;
  364. }
  365. .not-invioced{
  366. padding-bottom: 160rpx;
  367. }
  368. .not-invioced{
  369. .invoice-item{
  370. width: 100%;
  371. }
  372. }
  373. // 发票
  374. .invoice-item{
  375. margin: 24rpx;
  376. padding: 32rpx;
  377. background-color: #fff;
  378. display: flex;
  379. align-items: center;
  380. .infos{
  381. margin-left: 32rpx;
  382. flex: 1;
  383. .title{
  384. display: flex;
  385. justify-content: space-between;
  386. align-items: center;
  387. font-size: 36rpx;
  388. font-weight: 600;
  389. .text{
  390. color: rgba(51,51,51,1);
  391. }
  392. .money{
  393. color: rgba(255,61,0,1);
  394. white-space: pre;
  395. }
  396. .state{
  397. color: rgba(255,61,0,1);
  398. font-size: 36rpx;
  399. }
  400. .state2{
  401. color: rgba(0,185,98,1);
  402. font-size: 36rpx;
  403. }
  404. }
  405. .item{
  406. display: flex;
  407. align-items: center;
  408. margin-top: 24rpx;
  409. .name{
  410. color: rgba(119,119,119,1);
  411. }
  412. .value{
  413. color: rgba(51,51,51,1);
  414. margin-left: 24rpx;
  415. }
  416. }
  417. }
  418. }
  419. // 底部
  420. .bottom{
  421. background-color: #fff;
  422. padding: 28rpx 32rpx;
  423. display: flex;
  424. align-items: center;
  425. position: fixed;
  426. bottom: 0;
  427. left: 0;
  428. right: 0;
  429. .total{
  430. margin-left: 110rpx;
  431. .money{
  432. color: rgba(22,119,255,1);
  433. font-size: 36rpx;
  434. }
  435. .amount{
  436. color: #111111;
  437. text-align: right;
  438. }
  439. }
  440. .btn-box{
  441. margin-left: auto;
  442. .btn{
  443. width: 260rpx;
  444. border-radius: 50px;
  445. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  446. color: rgba(255,255,255,1);
  447. font-size: 36rpx;
  448. line-height: 80rpx;
  449. }
  450. }
  451. }
  452. </style>