<template>
	<view>		
		<view style="margin:10px 100px;position: fixed;z-index: 50;opacity:0.7;" v-show="isShow">
			<button type="primary" style="border-radius: 5px;" class="mini-btn" size="mini" @click="modify">修改</button>
		</view>
		<uni-list>
			<uni-list-item v-if="listData.mainEntity">
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">签证编号：</view>
						<view class="column-right">{{listData.mainEntity.viseId}}</view>
					</view>
					<view class="row">
						<view class="column-left">签证名称：</view>
						<view class="column-right">{{listData.mainEntity.viseName}}</view>
					</view>
					<view class="row">
						<view class="column-left">签证类型：</view>
						<view class="column-right">{{listData.mainEntity.viseType}}</view>
					</view>
					<view class="row">
						<view class="column-left">当前状态：</view>
						<view class="column-right">{{listData.mainEntity.stateName}}</view>
					</view>
					<view class="row">
						<view class="column-left">申请单：</view>
						<view class="column-right">{{listData.mainEntity.requisitionName}}</view>
					</view>
					<view class="row">
						<view class="column-left">关联合同：</view>
						<view class="column-right">{{listData.mainEntity.contractName}}</view>
					</view>
					<view class="row">
						<view class="column-left">币种汇率：</view>
						<view class="column-right">{{listData.mainEntity.moneyType}}  {{listData.mainEntity.exchangeRate}}</view>
					</view>
					
					<view class="row">
						<view class="column-left">合作伙伴：</view>
						<view class="column-right">{{listData.mainEntity.supplierName}}</view>
					</view>
					<view class="row">
						<view class="column-left">税率：</view>
						<view class="column-right">{{listData.mainEntity.rate}}%</view>
					</view>
					<view class="row">
						<view class="column-left">是否可抵扣：</view>
						<view class="column-right">{{listData.mainEntity.isDeduct=='1'?'是':'否'}}</view>
					</view>
					<view class="row">
						<view class="column-left">签证日期：</view>
						<view class="column-right">{{listData.mainEntity.viseDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">办理期限：</view>
						<view class="column-right">{{listData.mainEntity.endDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">经办人：</view>
						<view class="column-right">{{listData.mainEntity.personName}}</view>
					</view>
					<view class="row">
						<view class="column-left">经办部门：</view>
						<view class="column-right">{{listData.mainEntity.unitFullName}}</view>
					</view>
					<view class="row">
						<view class="column-left">审核人：</view>
						<view class="column-right">{{listData.mainEntity.checkPerson}}</view>
					</view>
					<view class="row">
						<view class="column-left">审核日期：</view>
						<view class="column-right">{{listData.mainEntity.checkDate}}</view>
					</view>
					<view class="row">
						<view class="column-left">审核意见：</view>
						<view class="column-right">{{listData.mainEntity.checkOpinion}}</view>
					</view>
					<view class="row">
						<view class="column-left">报送金额：</view>
						<view class="column-right">{{listData.mainEntity.reportCash}}</view>
					</view>
					<view class="row">
						<view class="column-left">暂估金额：</view>
						<view class="column-right">{{listData.mainEntity.estimateCash}}</view>
					</view>
					<view class="row">
						<view class="column-left">签证原因：</view>
						<view class="column-right">{{listData.mainEntity.reason}}</view>
					</view>
					<view class="row">
						<view class="column-left">备注：</view>
						<view class="column-right">{{listData.mainEntity.remark}}</view>
					</view>
					<view class="row">
						<view class="column-left">附件：</view>
						<view class="column-right">
							<view v-for="(item,index) in listData.attachments" :key="index">								
								<a :href="'/api/common/ShowImg?code='+item.attachMentCode">{{item.fileName}}</a>
							</view>
						</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
		 
		
		<uni-section title="费用明细"  type="line"></uni-section>
		<uni-list>
			<uni-list-item v-if="listData.subList"  v-for="(item, index) in listData.subList"  :key="index">
				<view slot="body" class="slot-box">
					<view class="row">
						<view class="column-left">费用项：</view>
						<view class="column-right">{{item.costCodeName}}</view>
					</view>
					<view class="row">
						<view class="column-left">含税金额(原币)：</view>
						<view class="column-right">{{item.cash}}</view>
					</view>
					<view class="row">
						<view class="column-left">税额(原币)：</view>
						<view class="column-right">{{item.rateCash}}</view>
					</view>
					<view class="row">
						<view class="column-left">金额(原币)：</view>
						<view class="column-right">{{item.noRateCash}}</view>
					</view>
					<view class="row">
						<view class="column-left">备注：</view>
						<view class="column-right">{{item.remark}}</view>
					</view>
				</view>
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	import {
		 GetVise
	} from "@/common/api/viseApi.js";
	import {
		Decimal
	} from 'decimal.js';
	export default {
		data() {
			return {
				listData: [],
				isShow:false
			}
		},
		onLoad() {
			//console.info("当前登录状态:" + this.$store.state.isLogin);
			//console.info(this);
			this.$util.persistLogin(this);
		},
		created: function() {
			this.getDetail(this.$util.getQuery("id"));
		},
		mounted:function(){
			
		},
		methods: {
			getDetail(id) {
				let that = this;
				GetVise(id).then((res) => {
					console.info('GetVise',res);
					
					if(res.mainEntity.state== "0"){
						that.isShow=true;
					}
					else{
						that.isShow=false;
					}
					res.mainEntity.exchangeRate=new Decimal(res.mainEntity.exchangeRate).toFixed(2);
					res.mainEntity.rate=new Decimal(res.mainEntity.rate).toFixed(2);
					res.mainEntity.reportCash=new Decimal(res.mainEntity.reportCash).toFixed(2);
					res.mainEntity.estimateCash=new Decimal(res.mainEntity.estimateCash).toFixed(2);
					//给数字字段增加小数点后两位
					res.subList.forEach(function(item,index,arr){
						item.cash=new Decimal(item.cash).toFixed(2);
						item.rateCash=new Decimal(item.rateCash).toFixed(2);
						item.noRateCash=new Decimal(item.noRateCash).toFixed(2);
					});
					that.listData=res;
					 
					//console.info(that.listData);
				});
			},
			 
			 modify: function() { //跳转到修改页面
			 	let id = this.$util.getQuery("id");
			 	uni.navigateTo({
			 		url: '/pages/template/viseedit/viseedit?id=' + id
			 	});
			 }
		}
	}
</script>

<style>
  /deep/ .uni-section__content-title{
	  font-size:15px;
	  font-weight: 600;
  }
  
 /deep/ .uni-list-item{
	  background-color: #f8f8f8;
  }
  .slot-box{
	  background-color: #fff;
	  padding: 5px 8px;
  }
</style>
