invoiceManagement.vue 8.9 KB

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