invoiceManagement.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653
  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" @click="checkeditem(item)">
  22. <!-- <view class="title">
  23. <view class="text">
  24. {{i}}
  25. </view>
  26. <view class="money">
  27. {{item.totalAmount}}元
  28. </view>
  29. </view> -->
  30. <table class="table1" >
  31. <template >
  32. <tr :key="i" >
  33. <td colspan="2" class="tr2 text" >{{item.name}}</td>
  34. </tr>
  35. <tr v-for="(it,j) in item" :key="i+'_'+j" v-if="!(['yearMonth','tenantContractId','name','totalAmount','checked'].indexOf(j)>=0)&&it!=0" >
  36. <td class="tr2" >{{j}}</td>
  37. <td>{{it}}元</td>
  38. </tr>
  39. <tr v-for="(it,j) in item" :key="i+'_'+j" v-if="'totalAmount'==j" >
  40. <td class="tr2" >合计</td>
  41. <td class="money">{{it}}元</td>
  42. </tr>
  43. </template>
  44. </table>
  45. </view>
  46. </view>
  47. </u-checkbox-group>
  48. <u-divider :isnone="list1.length==0" nonetext="没有找到相关内容"
  49. border-color="#CFD2D5">已经到底了</u-divider>
  50. </view>
  51. <!-- 已开发票 -->
  52. <view class="invoiced" v-if="current==1">
  53. <view class="invoice-item" v-for="(item,i) in list2"
  54. @click="btn1(item,0)"
  55. :key="i" >
  56. <view class="infos">
  57. <view class="title">
  58. <view class="text">
  59. {{item.title}}
  60. </view>
  61. <view :class="{
  62. state:!item.image,
  63. state2:item.image,
  64. }" >
  65. {{item.image?'已开票':'开票中'}}
  66. </view>
  67. </view>
  68. <view class="item">
  69. <view class="name">
  70. 发票金额
  71. </view>
  72. <view class="value">
  73. {{item.amount}}元
  74. </view>
  75. </view>
  76. <view class="item">
  77. <view class="name">
  78. 抬头类型
  79. </view>
  80. <view class="value">
  81. {{item.headerType=='1'?'企业单位':''}}{{item.headerType=='2'?'个人/非企业单位':''}}
  82. </view>
  83. </view>
  84. <view class="item" v-if="item.headerType=='1'" >
  85. <view class="name">
  86. 发票类型
  87. </view>
  88. <view class="value">
  89. {{item.type=='1'?'增值税专票':''}}{{item.type=='2'?'增值税普票':''}}
  90. </view>
  91. </view>
  92. <view class="item">
  93. <view class="name">
  94. 申请时间
  95. </view>
  96. <view class="value">
  97. {{item.createTime}}
  98. </view>
  99. </view>
  100. <view class="item" v-if="!item.image"
  101. style=" justify-content: space-around;">
  102. <view class="btn" >
  103. <u-button @tap.stop="btn1(item,1)" type="primary">查看</u-button>
  104. </view>
  105. <view class="btn btn2" >
  106. <u-button @tap.stop="btn2(item)" >撤回</u-button>
  107. </view>
  108. </view>
  109. </view>
  110. </view>
  111. <!-- <view class="invoice-item" >
  112. <view class="infos">
  113. <view class="title">
  114. <view class="text">
  115. 2024年1月扣费发票
  116. </view>
  117. <view class="state2">
  118. 已开票
  119. </view>
  120. </view>
  121. <view class="item">
  122. <view class="name">
  123. 发票金额
  124. </view>
  125. <view class="value">
  126. 1000.00元
  127. </view>
  128. </view>
  129. <view class="item">
  130. <view class="name">
  131. 发票抬头
  132. </view>
  133. <view class="value">
  134. 联通公司
  135. </view>
  136. </view>
  137. <view class="item">
  138. <view class="name">
  139. 申请时间
  140. </view>
  141. <view class="value">
  142. 2024-02-07 16:00:00
  143. </view>
  144. </view>
  145. </view>
  146. </view> -->
  147. <u-divider :isnone="list2.length==0" v-if="list2.length==recordsTotal2" nonetext="没有找到相关内容"
  148. border-color="#CFD2D5">已经到底了</u-divider>
  149. </view>
  150. <!-- 底部 -->
  151. <view class="bottom" v-if="current==0">
  152. <view class="all">
  153. <label class="radio">
  154. <u-checkbox-group @change="selectAll">
  155. <u-checkbox v-model="checkedAll" value="1" /><text></text>
  156. </u-checkbox-group>
  157. </label>
  158. </view>
  159. <view class="total">
  160. <view class="money">
  161. 共{{sumCollectionMoney}}元
  162. </view>
  163. <view class="amount">
  164. {{sumCollection.length}}张发票
  165. </view>
  166. </view>
  167. <view class="btn-box">
  168. <button class="btn" @click="submit" >去开票</button>
  169. </view>
  170. </view>
  171. </view>
  172. </template>
  173. <script>
  174. import * as API from '@/apis/pagejs/invoiceApi.js'
  175. import {
  176. parseUnixTime
  177. } from '@/apis/utils'
  178. export default {
  179. data() {
  180. return {
  181. list: [{
  182. id:0,
  183. name: '未开发票'
  184. }, {
  185. id:1,
  186. name: '已开发票'
  187. }],
  188. current: 0,
  189. checkedAll:false,
  190. checkboxList:[],
  191. list1:[],
  192. recordsTotal1:0,
  193. list2:[],
  194. recordsTotal2:0,
  195. pageIndex:1,
  196. }
  197. },
  198. onLoad() {
  199. this.getInvoiceList1()
  200. },
  201. onReachBottom() {
  202. if(this.current==1){
  203. var list=this.list2;
  204. var recordsTotal=this.recordsTotal2;
  205. if (list.length < recordsTotal) {
  206. this.myLoadmore();
  207. }
  208. }
  209. },
  210. computed:{
  211. sumCollectionMoney(){
  212. var amounts=[];
  213. let totalAmount =0
  214. for(var i in this.list1){
  215. var item =this.list1[i]
  216. if(item.checked){
  217. amounts.push(item.totalAmount)
  218. }
  219. }
  220. totalAmount = amounts.reduce((accumulator, currentValue) => {
  221. return accumulator + currentValue;
  222. }, 0);
  223. return totalAmount.toFixed(2)
  224. },
  225. sumCollection(){
  226. var sz=[];
  227. for(var i in this.list1){
  228. var item =this.list1[i]
  229. if(item.checked){
  230. sz.push(item.tenantContractId+"#"+item.yearMonth)
  231. }
  232. }
  233. return sz
  234. }
  235. },
  236. methods: {
  237. btn1(item,bl){
  238. if(bl||item.image){
  239. this.gotoUrl('/pages/invoiceManagement/invoiceDetails?id='+item.id)
  240. }
  241. },
  242. btn2(item){
  243. uni.showModal({
  244. confirmText:`撤回`,
  245. content: `确认是否要撤回当前发票申请`,
  246. title: "提示",
  247. success:res=> {
  248. if(res.confirm){
  249. this.switchBtnApiMethod(item);
  250. }
  251. }
  252. })
  253. },
  254. switchBtnApiMethod(node){
  255. uni.showLoading({
  256. title: "加载中",
  257. mask: true,
  258. })
  259. API.deleteInvoice({
  260. id:node.id,
  261. }).then((res) => {
  262. uni.hideLoading();
  263. this.init()
  264. }).catch(error => {
  265. uni.showToast({
  266. title: error,
  267. icon: "none"
  268. })
  269. })
  270. },
  271. ifOrSelectAll(){
  272. for(var i in this.list1){
  273. var item =this.list1[i]
  274. if(!item.checked){
  275. return false
  276. }
  277. }
  278. return true
  279. },
  280. checkeditem(item){
  281. this.$set(item,'checked',!item.checked)
  282. if(!item.checked&&this.checkedAll){
  283. this.checkedAll=false
  284. this.$forceUpdate()
  285. }
  286. if(item.checked&&!this.checkedAll){
  287. this.checkedAll=this.ifOrSelectAll()
  288. this.$forceUpdate()
  289. }
  290. },
  291. myLoadmore() {
  292. this.pageIndex+=1;
  293. this.getInvoiceList2()
  294. },
  295. submit(){
  296. // var sz=[];
  297. // this.list1.forEach(item=>{
  298. // //item.checked=()
  299. // if(item.checked){
  300. // sz.push(item.id)
  301. // }
  302. // })
  303. if(this.sumCollection.length==0){
  304. uni.showToast({
  305. icon: "none",
  306. title: "请勾选所需的开票项目",
  307. })
  308. return
  309. }
  310. uni.navigateTo({
  311. url:"/pages/invoiceManagement/issueInvoice?ids="+this.sumCollection.join(),
  312. events: {
  313. refreshData: () => {
  314. this.init()
  315. }
  316. }
  317. })
  318. // uni.showLoading({
  319. // mask:true,title:'加载中...'
  320. // })
  321. // API.openInvoiceByRecordIds({
  322. // recordIds:this.sumCollection.join()
  323. // }).then((response) => {
  324. // uni.hideLoading();
  325. // //this.list=response.data.data;
  326. // this.companyTypes=response.data.companyTypes;
  327. // this.personTypes=response.data.personTypes;
  328. // }).catch(error => {
  329. // uni.hideLoading();
  330. // })
  331. },
  332. selectOne(e){
  333. console.log(e)
  334. if(e.length==0&&this.checkedAll){
  335. this.checkedAll=false
  336. this.$forceUpdate()
  337. }
  338. if(e.length>0&&!this.checkedAll){
  339. this.checkedAll=this.ifOrSelectAll()
  340. this.$forceUpdate()
  341. }
  342. },
  343. selectAll(e){
  344. var sz=e
  345. for(var i in this.list1){
  346. var item =this.list1[i]
  347. this.$set(item,'checked',sz.length>0)
  348. }
  349. // this.$forceUpdate()
  350. },
  351. thisparseUnixTime(time){
  352. return parseUnixTime(time,'{y}年{m}月{d}日')
  353. },
  354. init(){
  355. this.pageIndex=1;
  356. this.current=0;
  357. this.getInvoiceList1()
  358. },
  359. change(index) {
  360. this.current = index;
  361. if(this.current==0){
  362. this.getInvoiceList1()
  363. }else{
  364. this.getInvoiceList2()
  365. }
  366. },
  367. addInfo(url) {
  368. var url = url;
  369. uni.navigateTo({
  370. url: url,
  371. events: {
  372. refreshData: () => {
  373. this.init()
  374. }
  375. }
  376. })
  377. },
  378. getInvoiceList1(){
  379. uni.showLoading({
  380. mask:true,title:'加载中...'
  381. })
  382. API.invoiceList({
  383. status:0,
  384. pageIndex:1,
  385. pageSize:9999
  386. }).then((response) => {
  387. uni.hideLoading();
  388. this.list1=response.data.recordMap;
  389. if(JSON.stringify(this.list1)=='{}'){
  390. this.list1=[]
  391. }else{
  392. }
  393. }).catch(error => {
  394. uni.hideLoading();
  395. uni.showToast({
  396. icon: "none",
  397. title: error
  398. })
  399. })
  400. },
  401. getInvoiceList2(){
  402. uni.showLoading({
  403. mask:true,title:'加载中...'
  404. })
  405. API.invoiceList({
  406. status:1,
  407. pageIndex: this.pageIndex,
  408. pageSize: 20,
  409. }).then((res) => {
  410. uni.hideLoading();
  411. //this.list2=response.data.data;
  412. var list=[]
  413. if (this.pageIndex == 1) {
  414. list = res.data.data;
  415. } else {
  416. list = [
  417. ...this.list2,
  418. ...res.data.data
  419. ];
  420. }
  421. this.list2=list;
  422. this.recordsTotal2=res.data.recordsTotal;
  423. }).catch(error => {
  424. uni.hideLoading();
  425. uni.showToast({
  426. icon: "none",
  427. title: error
  428. })
  429. })
  430. },
  431. }
  432. }
  433. </script>
  434. <style lang="scss" scoped>
  435. .table1{
  436. .text{
  437. color: rgba(51,51,51,1);
  438. font-size: 36rpx;
  439. }
  440. .money{
  441. color: rgba(255,61,0,1);
  442. white-space: pre;
  443. }
  444. margin: 16rpx 0;
  445. width: 100%;
  446. border-collapse: collapse;
  447. td{
  448. border: 1px solid #e7e7e7;
  449. text-align: end;
  450. padding: 2px 8px;
  451. }
  452. .td1{
  453. text-align: start;
  454. min-width: 20%;
  455. max-width: 30%;
  456. }
  457. .td3{
  458. white-space: pre;
  459. }
  460. tr{
  461. background-color:#f5f5f6
  462. }
  463. .tr1{
  464. text-align: end;
  465. font-weight: bold;
  466. }
  467. .tr2{
  468. text-align: start;
  469. }
  470. tr:nth-child(even) {
  471. background-color: #fff;
  472. }
  473. }
  474. .slot{
  475. color: rgba(16,16,16,1);
  476. font-size: 32rpx;
  477. margin-right: 32rpx;
  478. }
  479. // 标签
  480. .tabs{
  481. position: fixed;
  482. background-color: #fff;
  483. width: 100%;
  484. ::v-deep.u-tabs{
  485. width: 400rpx;
  486. margin: 0 auto;
  487. }
  488. }
  489. .invoiced,.not-invioced{
  490. margin-top: 100rpx;
  491. }
  492. .not-invioced{
  493. padding-bottom: 160rpx;
  494. }
  495. .not-invioced{
  496. .invoice-item{
  497. padding: 16rpx;
  498. width: 100%;
  499. }
  500. }
  501. // 发票
  502. .invoice-item{
  503. margin: 24rpx;
  504. padding: 32rpx;
  505. background-color: #fff;
  506. display: flex;
  507. align-items: center;
  508. .infos{
  509. margin-left: 32rpx;
  510. flex: 1;
  511. .title{
  512. display: flex;
  513. justify-content: space-between;
  514. align-items: center;
  515. font-size: 36rpx;
  516. font-weight: 600;
  517. .text{
  518. color: rgba(51,51,51,1);
  519. }
  520. .money{
  521. color: rgba(255,61,0,1);
  522. white-space: pre;
  523. }
  524. .state{
  525. color: rgba(255,61,0,1);
  526. font-size: 36rpx;
  527. white-space: pre;
  528. }
  529. .state2{
  530. color: rgba(0,185,98,1);
  531. font-size: 36rpx;
  532. }
  533. }
  534. .item{
  535. display: flex;
  536. align-items: center;
  537. margin-top: 24rpx;
  538. .name{
  539. color: rgba(119,119,119,1);
  540. }
  541. .value{
  542. color: rgba(51,51,51,1);
  543. margin-left: 24rpx;
  544. }
  545. }
  546. }
  547. }
  548. // 底部
  549. .bottom{
  550. background-color: #fff;
  551. padding: 28rpx 32rpx;
  552. display: flex;
  553. align-items: center;
  554. position: fixed;
  555. bottom: 0;
  556. left: 0;
  557. right: 0;
  558. .total{
  559. margin-left: 110rpx;
  560. .money{
  561. color: rgba(22,119,255,1);
  562. font-size: 36rpx;
  563. }
  564. .amount{
  565. color: #111111;
  566. text-align: right;
  567. }
  568. }
  569. .btn-box{
  570. margin-left: auto;
  571. .btn{
  572. width: 260rpx;
  573. border-radius: 50px;
  574. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  575. color: rgba(255,255,255,1);
  576. font-size: 36rpx;
  577. line-height: 80rpx;
  578. }
  579. }
  580. }
  581. </style>