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. debugger
  244. uni.showModal({
  245. confirmText:`撤回`,
  246. content: `确认是否要撤回当前发票申请`,
  247. title: "提示",
  248. success:res=> {
  249. if(res.confirm){
  250. this.switchBtnApiMethod(item);
  251. }
  252. }
  253. })
  254. },
  255. switchBtnApiMethod(node){
  256. uni.showLoading({
  257. title: "加载中",
  258. mask: true,
  259. })
  260. API.deleteInvoice({
  261. id:node.id,
  262. }).then((res) => {
  263. uni.hideLoading();
  264. this.init()
  265. }).catch(error => {
  266. uni.showToast({
  267. title: error,
  268. icon: "none"
  269. })
  270. })
  271. },
  272. ifOrSelectAll(){
  273. for(var i in this.list1){
  274. var item =this.list1[i]
  275. if(!item.checked){
  276. return false
  277. }
  278. }
  279. return true
  280. },
  281. checkeditem(item){
  282. this.$set(item,'checked',!item.checked)
  283. if(!item.checked&&this.checkedAll){
  284. this.checkedAll=false
  285. this.$forceUpdate()
  286. }
  287. if(item.checked&&!this.checkedAll){
  288. this.checkedAll=this.ifOrSelectAll()
  289. this.$forceUpdate()
  290. }
  291. },
  292. myLoadmore() {
  293. this.pageIndex+=1;
  294. this.getInvoiceList2()
  295. },
  296. submit(){
  297. // var sz=[];
  298. // this.list1.forEach(item=>{
  299. // //item.checked=()
  300. // if(item.checked){
  301. // sz.push(item.id)
  302. // }
  303. // })
  304. if(this.sumCollection.length==0){
  305. uni.showToast({
  306. icon: "none",
  307. title: "请勾选所需的开票项目",
  308. })
  309. return
  310. }
  311. uni.navigateTo({
  312. url:"/pages/invoiceManagement/issueInvoice?ids="+this.sumCollection.join(),
  313. events: {
  314. refreshData: () => {
  315. this.init()
  316. }
  317. }
  318. })
  319. // uni.showLoading({
  320. // mask:true,title:'加载中...'
  321. // })
  322. // API.openInvoiceByRecordIds({
  323. // recordIds:this.sumCollection.join()
  324. // }).then((response) => {
  325. // uni.hideLoading();
  326. // //this.list=response.data.data;
  327. // this.companyTypes=response.data.companyTypes;
  328. // this.personTypes=response.data.personTypes;
  329. // }).catch(error => {
  330. // uni.hideLoading();
  331. // })
  332. },
  333. selectOne(e){
  334. console.log(e)
  335. if(e.length==0&&this.checkedAll){
  336. this.checkedAll=false
  337. this.$forceUpdate()
  338. }
  339. if(e.length>0&&!this.checkedAll){
  340. this.checkedAll=this.ifOrSelectAll()
  341. this.$forceUpdate()
  342. }
  343. },
  344. selectAll(e){
  345. var sz=e
  346. for(var i in this.list1){
  347. var item =this.list1[i]
  348. this.$set(item,'checked',sz.length>0)
  349. }
  350. // this.$forceUpdate()
  351. },
  352. thisparseUnixTime(time){
  353. return parseUnixTime(time,'{y}年{m}月{d}日')
  354. },
  355. init(){
  356. this.pageIndex=1;
  357. this.current=0;
  358. this.getInvoiceList1()
  359. },
  360. change(index) {
  361. this.current = index;
  362. if(this.current==0){
  363. this.getInvoiceList1()
  364. }else{
  365. this.getInvoiceList2()
  366. }
  367. },
  368. addInfo(url) {
  369. var url = url;
  370. uni.navigateTo({
  371. url: url,
  372. events: {
  373. refreshData: () => {
  374. this.init()
  375. }
  376. }
  377. })
  378. },
  379. getInvoiceList1(){
  380. uni.showLoading({
  381. mask:true,title:'加载中...'
  382. })
  383. API.invoiceList({
  384. status:0,
  385. pageIndex:1,
  386. pageSize:9999
  387. }).then((response) => {
  388. uni.hideLoading();
  389. this.list1=response.data.recordMap;
  390. if(JSON.stringify(this.list1)=='{}'){
  391. this.list1=[]
  392. }else{
  393. }
  394. }).catch(error => {
  395. uni.hideLoading();
  396. uni.showToast({
  397. icon: "none",
  398. title: error
  399. })
  400. })
  401. },
  402. getInvoiceList2(){
  403. uni.showLoading({
  404. mask:true,title:'加载中...'
  405. })
  406. API.invoiceList({
  407. status:1,
  408. pageIndex: this.pageIndex,
  409. pageSize: 20,
  410. }).then((res) => {
  411. uni.hideLoading();
  412. //this.list2=response.data.data;
  413. var list=[]
  414. if (this.pageIndex == 1) {
  415. list = res.data.data;
  416. } else {
  417. list = [
  418. ...this.list2,
  419. ...res.data.data
  420. ];
  421. }
  422. this.list2=list;
  423. this.recordsTotal2=res.data.recordsTotal;
  424. }).catch(error => {
  425. uni.hideLoading();
  426. uni.showToast({
  427. icon: "none",
  428. title: error
  429. })
  430. })
  431. },
  432. }
  433. }
  434. </script>
  435. <style lang="scss" scoped>
  436. .table1{
  437. .text{
  438. color: rgba(51,51,51,1);
  439. font-size: 36rpx;
  440. }
  441. .money{
  442. color: rgba(255,61,0,1);
  443. white-space: pre;
  444. }
  445. margin: 16rpx 0;
  446. width: 100%;
  447. border-collapse: collapse;
  448. td{
  449. border: 1px solid #e7e7e7;
  450. text-align: end;
  451. padding: 2px 8px;
  452. }
  453. .td1{
  454. text-align: start;
  455. min-width: 20%;
  456. max-width: 30%;
  457. }
  458. .td3{
  459. white-space: pre;
  460. }
  461. tr{
  462. background-color:#f5f5f6
  463. }
  464. .tr1{
  465. text-align: end;
  466. font-weight: bold;
  467. }
  468. .tr2{
  469. text-align: start;
  470. }
  471. tr:nth-child(even) {
  472. background-color: #fff;
  473. }
  474. }
  475. .slot{
  476. color: rgba(16,16,16,1);
  477. font-size: 32rpx;
  478. margin-right: 32rpx;
  479. }
  480. // 标签
  481. .tabs{
  482. position: fixed;
  483. background-color: #fff;
  484. width: 100%;
  485. /deep/.u-tabs{
  486. width: 400rpx;
  487. margin: 0 auto;
  488. }
  489. }
  490. .invoiced,.not-invioced{
  491. margin-top: 100rpx;
  492. }
  493. .not-invioced{
  494. padding-bottom: 160rpx;
  495. }
  496. .not-invioced{
  497. .invoice-item{
  498. padding: 16rpx;
  499. width: 100%;
  500. }
  501. }
  502. // 发票
  503. .invoice-item{
  504. margin: 24rpx;
  505. padding: 32rpx;
  506. background-color: #fff;
  507. display: flex;
  508. align-items: center;
  509. .infos{
  510. margin-left: 32rpx;
  511. flex: 1;
  512. .title{
  513. display: flex;
  514. justify-content: space-between;
  515. align-items: center;
  516. font-size: 36rpx;
  517. font-weight: 600;
  518. .text{
  519. color: rgba(51,51,51,1);
  520. }
  521. .money{
  522. color: rgba(255,61,0,1);
  523. white-space: pre;
  524. }
  525. .state{
  526. color: rgba(255,61,0,1);
  527. font-size: 36rpx;
  528. white-space: pre;
  529. }
  530. .state2{
  531. color: rgba(0,185,98,1);
  532. font-size: 36rpx;
  533. }
  534. }
  535. .item{
  536. display: flex;
  537. align-items: center;
  538. margin-top: 24rpx;
  539. .name{
  540. color: rgba(119,119,119,1);
  541. }
  542. .value{
  543. color: rgba(51,51,51,1);
  544. margin-left: 24rpx;
  545. }
  546. }
  547. }
  548. }
  549. // 底部
  550. .bottom{
  551. background-color: #fff;
  552. padding: 28rpx 32rpx;
  553. display: flex;
  554. align-items: center;
  555. position: fixed;
  556. bottom: 0;
  557. left: 0;
  558. right: 0;
  559. .total{
  560. margin-left: 110rpx;
  561. .money{
  562. color: rgba(22,119,255,1);
  563. font-size: 36rpx;
  564. }
  565. .amount{
  566. color: #111111;
  567. text-align: right;
  568. }
  569. }
  570. .btn-box{
  571. margin-left: auto;
  572. .btn{
  573. width: 260rpx;
  574. border-radius: 50px;
  575. background: linear-gradient(-88.46deg, rgba(34,109,198,1) 2.59%,rgba(9,158,237,1) 97.02%);
  576. color: rgba(255,255,255,1);
  577. font-size: 36rpx;
  578. line-height: 80rpx;
  579. }
  580. }
  581. }
  582. </style>