zhengkaixin преди 3 години
родител
ревизия
ee19e0b3ec

+ 19 - 1
apis/invoiceApi.js

@@ -62,4 +62,22 @@ export function saveInvoiceType(data) {
 		 		data: data,
 		url: '/mobile/invoiceApi/saveInvoiceType'
 	})
-}
+}
+
+export function invoiceTypeDefalutByStation(data) {
+	return request({
+		method: 'post',
+		data: data,
+		url: '/mobile/invoiceApi/invoiceTypeDefalutByStation'
+	})
+}
+
+
+
+export function saveInvoiceByStation(data) {
+	return request({
+		method: 'post',
+		data: data,
+		url: '/mobile/invoiceApi/saveInvoiceByStation'
+	})
+}

+ 7 - 1
pages/MyInvoice/editInvoiceTitle.vue

@@ -1,7 +1,7 @@
 <template>
 	<view>
 		<u-navbar title="编辑发票抬头">
-			<text class="delete" @click="delBtn()" v-if="obj.id">删除</text>
+			<text class="delete" @click="delBtn()" v-if="obj.id&&!invoice">删除</text>
 		</u-navbar>
 
 		<u-cell-group>
@@ -65,6 +65,7 @@ export default {
 				},
 				
 			],
+			invoice:false,
 			checked:false,
 			// u-radio-group的v-model绑定的值如果设置为某个radio的name,就会被默认选中
 			value: '企业单位',
@@ -75,6 +76,11 @@ export default {
 			this.id=op.id;
 			this.getInfo();
 		}
+		if(op.invoice){
+			this.invoice=true;
+		
+		}
+		
 	},
 	methods: {
 		delBtn(){

+ 22 - 3
pages/MyInvoice/invioceResult.vue

@@ -18,7 +18,7 @@
 					发票抬头
 				</view>
 				<view class="info-content">
-					刘德华
+					{{selectObj.title}}
 				</view>
 			</view>
 			<view class="info-item">
@@ -26,20 +26,39 @@
 					发票金额
 				</view>
 				<view class="info-content">
-					200.00
+					{{selectObj.totalPrice}}
 				</view>
 			</view>
 				
 			</view>
 		</view>
 		
-		<u-button type="success" shape="circle">查看电子发票</u-button>
+		<u-button type="success" shape="circle" @click="back" >返回</u-button>
 	</view>
 </template>
 
 <script>
 	import * as API from '@/apis/invoiceApi.js'
 	
+	export default {
+		data() {
+			return {
+				selectObj:{}
+			};
+		},
+		onLoad() {
+			
+			var obj=this.carhelp.get("issueInvoice");
+			this.selectObj=obj.selectObj;
+		},
+		methods: {
+			back(){
+				uni.navigateBack({
+					
+				})
+			}
+		}
+	};
 </script>
 
 <style lang="scss" scoped> 

+ 55 - 41
pages/MyInvoice/invoiceManagement.vue

@@ -8,7 +8,7 @@
 			<u-tabs  inactive-color="#888888" active-color="#101010" :list="list" :is-scroll="true"
 					:current="current" @change="change"></u-tabs>
 	
-		<view class="carNone" v-if="list[current].length == 0">
+		<view class="carNone" v-if="list[current].list.length == 0">
 				<img src="static/img/暂无数据-缺省页.png" alt="">
 				<p class="oldTextjp2" oldstyle="font-size: 18px;">暂无记录</p>
 			</view>
@@ -20,43 +20,20 @@
 			<view class="radio">
 				<u-checkbox v-model="item.ck" @change="changeitem($event,item)" ></u-checkbox>
 			</view>
-			<view class="content"  @click="submit(item.id)">
+			<view class="content"  @click="submit(item.stationId)">
 				<view class="title">
-					荆鹏软件园充电站 <text class="price">50.00元</text>
+					{{item.stationName}} <text class="price">{{item.totalActualFee}}元</text>
 				</view>
-				<p><text class="text-1">充电电量</text> <text class="text-2">50.00度</text></p>
-				<p><text class="text-1">充电笔数</text> <text class="text-2">10笔</text></p>
-				<!-- <p><text class="text-1">车牌号码</text> <text class="text-2">鄂D9GX23</text></p> -->
-				<!-- <p><text class="text-1">充电电流</text> <text class="text-2">50.00</text></p> -->
-			<!-- <p><text class="text-1">支付号码</text> <text class="text-2">2022-06-07 16:00:00</text></p> -->
-				<!-- <p class=order-box>
-					<view class="order">
-						订单号
-					</view>
-					<view class="order-num">
-						2022060715035348150312
-					</view>
-				</p> -->
+				<p><text class="text-1">充电电量</text> <text class="text-2">{{item.totalElectricQuantity/10000}}度</text></p>
+				<p><text class="text-1">充电笔数</text> <text class="text-2">{{item.recordNum}}笔</text></p>
+				 
 			</view>
 			
         	
         </view>
        <p class="tips" v-if="list[current].list.length == list[current].recordsTotal && list[current].recordsTotal != 0" > 已经到底了</p>
        
-		<view class="not-invoiced-item flex">
-			<view class="radio">
-				<radio></radio>
-			</view>
-			<view class="content">
-				<view class="title">
-					玉桥公园充电站 <text class="price">15.00元</text>
-				</view>
-				<p><text class="text-1">充电电量</text> <text class="text-2">50.00度</text></p>
-				<p><text class="text-1">充电笔数</text> <text class="text-2">10笔</text></p>
-				
-			</view>
-			
-		</view>
+		
       	
 		<view class="bottom">
 			<view class="radio">
@@ -74,17 +51,20 @@
       </view>
 	  <!-- 已开票 -->
 	  <view class="invoiced" v-show="current==1">
-	  	<view class="invoiced-item">
+	  	<view class="invoiced-item" v-for="(item,index) in list[current].list" :key="index">
 	  		<view class="content">
 	  			<view class="title">
-	  				荆鹏软件园充电站 <text class="invoice">开票中</text>
+	  				{{item.stationName}} <text :class="{
+						invoice:item.status==1,
+						'have-invoiced':item.status==2
+					}">{{item.statusText}}</text>
 	  			</view>
-	  			<p><text class="text-1">发票金额</text> <text class="text-2">50.00元</text></p>
-	  			<p><text class="text-1">发票抬头</text><text class="text-2">刘德华</text></p>
-	  			<p><text class="text-1">申请时间</text> <text class="text-2">2022-06-23 16:00:00</text></p>
+	  			<p><text class="text-1">发票金额</text> <text class="text-2">{{item.amount}}元</text></p>
+	  			<p><text class="text-1">发票抬头</text><text class="text-2">{{item.title}}</text></p>
+	  			<p><text class="text-1">申请时间</text> <text class="text-2">{{item.createTime}}</text></p>
 	  		</view>
 	  	</view>
-		<view class="invoiced-item">
+	<!-- 	<view class="invoiced-item">
 			<view class="content">
 				<view class="title">
 					玉桥公园充电站 <text class="have-invoiced">开票成功</text>
@@ -93,7 +73,7 @@
 				<p><text class="text-1">发票抬头</text> <text class="text-2">刘德华</text></p>
 				<p><text class="text-1">申请时间</text> <text class="text-2">2022-06-23 16:00:00</text></p>
 			</view>
-		</view>
+		</view> -->
 		<p class="tips"> 仅展示最近12个月的发票信息</p>
 	  </view>
 	</view>
@@ -145,12 +125,24 @@
 					var obj=list[i];
 					if(obj.ck){
 					 
-						sum+=obj.actualFee*100
+						sum+=obj.totalActualFee*100
 					}
 				}
 			 
 				return sum/100
 			},
+			selectIds(){
+				var list=this.list[0].list;
+				var sz=[]
+				for(var i in list ){
+					var obj=list[i];
+					if(obj.ck){
+						sz.push(obj.stationId);
+					}
+				}
+							
+				return sz.join();
+			},
 			selectcount(){
 				var list=this.list[0].list;		 
 				var count=0
@@ -207,14 +199,22 @@
 				
 				}).then((res) => {
 					uni.hideLoading();
-					var datalist=res.data.data;
+					
+					var datalist=[]
+					if(current==0){
+						datalist=res.data.station;
+					}
+					if(current==1){
+						datalist=res.data.data;
+					}
+					
 					for(var i in datalist){
 						var obj=datalist[i]
 						obj.ck=false;
 					}
 					this.list[current].list = [
 						...list,
-						...res.data.data
+						...datalist
 					];
 					this.list[current].recordsTotal = res.data.recordsTotal;
 				}).catch(error => {
@@ -232,10 +232,24 @@
 			},
 			change(index) {
 				this.current = index;
+				var list =this.list[this.current].list
+				if(list.length==0){
+					this.getlist(true);
+				}
 			},
 			submit(id){
+				if(!id){
+					id=this.selectIds
+				}
+				if(!id){
+					uni.showToast({
+						title:"请至少勾选一条记录"
+					})
+					return
+				}
+				
 				uni.navigateTo({
-					url:'/pages/MyInvoice/issueInvoice'
+					url:'/pages/MyInvoice/issueInvoice?ids='+id
 				})
 			}
 				

+ 10 - 2
pages/MyInvoice/invoiceTitleManagement.vue

@@ -13,7 +13,7 @@
 					
 					<p class="num">{{item.companyTaxNo}}</p>
 				</view>
-				<view class="edit" @click="gotoUrl('pages/MyInvoice/editInvoiceTitle?id='+item.id)" >
+				<view class="edit" @click="editBtn(item)" >
 					<img src="../../static/img/riFill-edit-2-fill@1x.png" alt="">
 				</view>
 			</view>
@@ -36,7 +36,7 @@
 				<view class="itemlist" @click="ckBtn(item)">
 					<p class="name">{{item.title}}<text v-if="item.defaultHeader=='1'" class="default">默认</text></p>
 				</view>
-				<view class="edit"  @click="gotoUrl('pages/MyInvoice/editInvoiceTitle?id='+item.id)" >
+				<view class="edit"  @click="editBtn(item)" >
 					<img src="../../static/img/riFill-edit-2-fill@1x.png" alt="">
 				</view>
 			</view>
@@ -81,6 +81,13 @@
 			this.getlist();
 		},
 		methods: {
+			editBtn(item){
+				var url='pages/MyInvoice/editInvoiceTitle?id='+item.id;
+				if(this.invoice){
+					url+="&invoice=1"
+				}
+				this.gotoUrl(url)
+			},
 			ckBtn(item){
 				if(this.invoice){
 					
@@ -95,6 +102,7 @@
 					
 					
 				}else{
+					
 					this.gotoUrl('pages/MyInvoice/editInvoiceTitle?id='+item.id)
 				}
 			},

+ 101 - 19
pages/MyInvoice/issueInvoice.vue

@@ -6,14 +6,11 @@
 		<view class="invioice-info">
 			<p class="title">发票信息</p>
 			<u-cell-group>
-				<u-cell-item title="发票金额" :arrow="false"> <text style="color:#ff3d00;">50.00元</text></u-cell-item>
+				<u-cell-item title="发票金额" :arrow="false"> <text style="color:#ff3d00;">{{obj.totalPrice}}元</text></u-cell-item>
 				<u-cell-item title="抬头类型" :arrow="false">
-					<u-radio-group v-model="value" @change="radioGroupChange">
-						<u-radio @change="radioChange" v-for="(item, index) in list" :key="index" :name="item.name"
-							:disabled="item.disabled" active-color="#00b962">
-							{{item.name}}
-						</u-radio>
-					</u-radio-group>
+					<view v-if="!selectObj.title">请选择发票</view>
+					<view v-else-if="selectObj.headerType==1">企业单位</view>
+					<view v-else-if="selectObj.headerType==2">个人/非企业单位</view>
 				</u-cell-item>
 				<u-cell-item title="发票抬头" @click="gotoUrl('pages/MyInvoice/invoiceTitleManagement?invoice=1&uuid='+uuid)" :value="selectObj.title?selectObj.title:'请选择发票抬头'"></u-cell-item>
 				<u-cell-item title="公司税号" :value="selectObj.companyTaxNo?selectObj.companyTaxNo:'自动读取对应抬头的公司税号'"  :arrow="false"></u-cell-item>
@@ -22,7 +19,7 @@
 		<!-- 弹窗 -->
 		<view class="modal">
 
-			<u-modal v-model="show"  :show-title="false" 
+			<u-modal v-model="show"  :show-title="false"  @confirm="confirm"
 				:show-cancel-button="true" confirm-text="确认开具" cancel-text="返回修改">
 				<view class="title">
 					发票开具成功后不可撤销
@@ -47,10 +44,18 @@
 					</view>
 					<view class="item">
 						<view class="name">
-							发票金额
+							公司税号
 						</view>
 						<view class="content">
-							5000.00
+							{{selectObj.companyTaxNo}}
+						</view>
+					</view>
+					<view class="item">
+						<view class="name">
+							发票抬头
+						</view>
+						<view class="content">
+							{{obj.totalPrice}}元
 						</view>
 					</view>
 					<view class="hint">
@@ -73,6 +78,7 @@
 	export default {
 		data() {
 			return {
+				ids:"",
 				uuid:"",
 				list: [{
 						name: '企业单位',
@@ -87,21 +93,90 @@
 				value: '企业单位',
 				show: false,
 				selectObj:{},
+				obj:{},
 				
 			};
 		},
 		onShow() {
-			var obj=this.carhelp.get("issueInvoice");
-			if(obj){
-				if(obj.uuid==this.uuid){
-					this.selectObj=obj.selectObj;
-				}
-			}
+			this.getInfo()
+			
 		},
-		onLoad() {
-			this.uuid=new Date().getTime();
+		onLoad(op) {
+			
+			if(op.ids){
+				this.ids=op.ids;
+				//this.getInfo()
+			}
 		},
+		
 		methods: {
+			confirm(){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				
+				API.saveInvoiceByStation({
+					stationIds:this.ids,
+					invoiceTypeId:this.selectObj.id
+				}).then((res) => {
+					
+					
+				
+					uni.hideLoading()
+					uni.redirectTo({
+						url:"/pages/MyInvoice/invioceResult"
+					})
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
+			getInfo(){
+				uni.showLoading({
+					title: "加载中",
+					mask: true,
+				})
+				
+				API.invoiceTypeDefalutByStation({
+					stationIds:this.ids
+				}).then((res) => {
+					uni.hideLoading()
+					this.selectObj=res.data.invoiceType
+					if(!res.data.invoiceType){
+						this.selectObj={}
+						this.uuid=new Date().getTime();
+					}else{
+						
+						var obj=this.carhelp.get("issueInvoice");
+						if(obj){
+							if(obj.uuid==this.uuid){
+								if(obj.selectObj.id){
+									this.selectObj=obj.selectObj;
+								}
+								
+							}
+						}
+					}
+					this.selectObj.totalPrice=res.data.totalPrice;
+					this.obj=res.data
+					
+					
+					this.uuid=new Date().getTime();
+					this.carhelp.set("issueInvoice",{
+						uuid:this.uuid,
+						selectObj:this.selectObj
+					})
+					
+				}).catch(error => {
+					uni.showToast({
+						title: error,
+						icon: "none"
+					})
+				})
+			},
 			// 选中某个单选框时,由radio时触发
 			radioChange(e) {
 				// console.log(e);
@@ -120,7 +195,14 @@
 				// 	],
 				// 	longPressActions:true
 				// })
-				this.show = true;
+				if(this.selectObj.id){
+					this.show = true;
+				}
+				else{
+					uni.showToast({
+						title:"请选择发票"
+					})
+				}
 			}
 		}
 	};