<!-- 费用报销 -->
<template>
	<view class="travel-expense" >
		<view v-if="isShow">
			<view class="travel-top">
				<h4>{{ExpenseBill.DEPT_NAME}}</h4>
				<h3>{{ExpenseBill.ACCEPT_NAME}}</h3>
				<view class="detail-top-base">
					<view class="span24"><text class="text-title uni-ellipsis">{{ExpenseBill.ExpenseBill.DEPARTMENT_NAME}}：</text><text >{{ExpenseBill.STAFF_NAME}}</text></view>
					<text>{{$util.cutDate(ExpenseBill.FINANCEPROINST_CREATEDATE)}}</text>
				</view>
				<view class="detail-top-box">
					<view class="detail-top-bottom ">
						<view class="uni-flex " style="align-items: center;justify-content: space-between;">
							<view class="uni-flex span24" style="align-items: center;" >
								<view class="detail-title">
									<i class="ico ico-ndbz"></i><text class="text-title">报销总额： </text>
									
								</view>
								<text style="color:#ec8538;">￥{{ $util.fmoney(ExpenseBill.PAYMENT_LOWER,2)}}</text>
							</view>
							<view class="uni-flex span24" style="align-items: center;"> 
								<view class="detail-title">
									<i class="ico ico-rzlx"></i><text class="text-title">入账类型：</text> 
									
								</view>
								<text v-if="ExpenseBill.EXPENDBILL_TYPE == 1000">公务卡</text>
								<text v-if="ExpenseBill.EXPENDBILL_TYPE == 3000">现金</text>
								<text v-if="ExpenseBill.EXPENDBILL_TYPE == 4000">公对公转账</text>
								<text v-else>工资卡</text>
							</view>
						</view>
						<view class="line-block between-circle"></view>
						<view>
							<view class="cost-unit-card" v-for="(item,index) in ExpenseBill.ExpenseDetail" :key="index">
								<view style="line-height: 1.2;">
									<text class="span24 widthAuto">{{item.EXPENSE_ITEM}}：</text>
									<text class="span24 text-title" >{{item.EXPENSE_DETAIL}}</text>
								</view>
								<view class="uni-flex span24 mt20" style="align-items: center;">
									<view class="uni-flex span24" style="align-items: center;">
										
										<i class="ico ico-ndbz"></i>
										<text class="text-title">报销金额：</text>
										<text style="color:#ec8538;">
											￥{{$util.fmoney(item.EXPENSEDETAIL_AMOUNT)}}
										</text>
									</view>
							
									<view class="uni-flex span24 ml36" style="align-items: center;">
										<i class="ico ico-pj"></i>
										<!-- <text class="text-title">
											票据：
										</text> -->
										<text>
											{{item.EXPENSEDETAIL_COUNT}}张
										</text>
									</view>
								</view>
								<view class="uni-flex span24 mt20" style="align-items: center;" v-if="preSubscribefeeMap && preSubscribefeeMap[item.EXPENSEDETAIL_DESC]">
									<i class="ico ico-xmgl"></i>
									<text class="text-title">项目关联：</text>
									<text class="linkText" @tap="clickGetSubscribefee(item.EXPENSEDETAIL_DESC)">{{preSubscribefeeMap[item.EXPENSEDETAIL_DESC].ACCEPT_NAME}}</text>
								</view>
							</view>
						</view>
					</view>
		
					<ul class="detail-middle-box" v-if="ExpenseBill.FileList || ExpenseBill.ImageList">
						
						<li class="attachment" v-if="ExpenseBill.FileList && ExpenseBill.FileList.length>0">
							<p class="detail-title">
								<i class="ico ico-fj"></i>
								<span>附 件</span>
							</p>
							<div class="imgBox">
								<filesUnit v-for="(file,i) in ExpenseBill.FileList" :fileItem="file" :key="i"></filesUnit>
								
							</div>
						</li>
						<li class="attachment" v-if="ExpenseBill.ImageList && ExpenseBill.ImageList.length>0">
							<div class="detail-title">
								<i class="ico ico-tp"></i>
								<text class="text-title">图 片</text>
							</div>
							<div class="imgBox">
								<image v-for="(arr,i) in ExpenseBill.ImageList" :key="i" :src="arr.IMAGE_URL" @tap="showImg(arr,i)" mode="aspectFill" lazy-load/>
							</div>
						</li>
					
					</ul>
				</view>
				<view class="button-box"  v-if="ExpenseBill.NOWSTAFF_ID == users.UserId">
					<span @tap="showPop(4000)"><image src="../../static/images/yj-btn.png" mode="aspectFit"></image> 移交 </span>
					<span @tap="showPop(2000)"><image src="../../static/images/sh-btn.png" mode="aspectFit"></image> 审核 </span>
					<span @tap="showPop(3000)" v-if="ExpenseBill.CAN_REJECT===1"><image src="../../static/images/bh-btn.png" mode="aspectFit"></image> 驳回</span>
				</view>
			
			
			</view>


			<!-- 审批流程 -->
			<view class="base-info" v-if="ExpenseBill.RejectApproved && ExpenseBill.RejectApproved.length>0">
				<div class="uni-list-cell uni-collapse">
					<div class="cat-box uni-list-cell-navigate" >
						<b>驳回意见</b>
					</div>
					<div class="process-box uni-collapse-content uni-active">
						<processUnit :item="ExpenseBill.RejectApproved[0]"  :approveType='0' />
					</div>
				</div>
			</view>
			<view class="base-info" v-if="ExpenseBill.ApprovedList && ExpenseBill.ApprovedList.length > 0">
				<div class="uni-list-cell uni-collapse">
					<div class="cat-box uni-list-cell-navigate" :class="cardShow3 ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow3 =!cardShow3">
						<b>审批流程</b>
					</div>
					<div class="process-box uni-collapse-content" :class="cardShow3 ? 'uni-active' : ''" v-show="cardShow3">
						<processUnit v-for="item in ExpenseBill.ApprovedList" :item="item" :key="item.APPROVED_DATE" :approveType='1' />
					</div>
				</div>
				
			</view>
			<popUp :show="showPopupMiddle" :msg="preSubscribefeeMap[showId].ACCEPT_TYPE == '401101'?'行政资产申购':'公务接待'" @hidePopup="closePop" type="middle">
				
				<div style="width: 600upx;margin-top: 40upx;" v-if="preSubscribefeeMap[showId].ACCEPT_TYPE=='401101'">
			
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;">申请部门：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].DEPARTMENT_NAME}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">申&nbsp;&nbsp;请&nbsp;人：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_PERSON}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">申请日期：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_DATE}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">申请理由：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_INFO}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">品&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].COMMODITY_NAME}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">规&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;格：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].COMMODITY_RULE}}</text>
							
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">预计费用：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].BUDGET_PRICE}}</text>
						
						</div>
						<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
							<text style="color:#888;min-width:120upx;">其它要求：</text>
							<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_OTHER}}</text>
							
						</div>
					
				</div>
				<div style="width: 600upx;margin-top: 40upx;" v-else>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;">来宾单位：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].DEPARTMENT_NAME}}</text>
					
					</div>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;">来宾时间：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].VISITOR_DATE}}</text>
					
					</div>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;">来宾人数：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].VISITOR_PERSONS}}</text>
					
					</div>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;">经办人：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].APPLY_STAFF}}</text>
					
					</div>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;">陪同人数：</text>
						<text class="lie_right">{{preSubscribefeeMap[showId].ACCOMPANY_PERSON}}</text>
				
					</div>
					<div class="span24 uni-flex" style="aligin-items:flex-start; margin-bottom: 12upx;">
						<text style="color:#888;min-width:120upx;" >拟定饭店及标准：</text>
						<text class="lie_right" style="width:60%">{{preSubscribefeeMap[showId].HOTEL_INFO}}</text>
					
					</div>
					
				</div>
			</popUp>
		</view>
		<view v-else-if="isLoading==false">
			<noFound :nodata="baseData.HIGHWAYPROINST_ID ? false : true"/>
		</view>
	</view>
</template>

<script>
	import { mapGetters } from 'vuex';
	import processUnit from '@/components/auditingProcess/item.vue'
	import filesUnit from '@/components/filesComponent/fileUnit.vue'
	import popUp from '@/components/uni-popup.vue'
	export default {
		data() {
		
			return {
		
				doUser: false,
				ExpenseBill: {},
				preSubscribefeeMap:{},
				isShow: false,
				isLoading: true,
				cardShow: true, // 控制折叠面板
				imageUrls:[],
				cardShow3: true,
				cardShow4: true,
				showPopupMiddle:false,
				showId:''
			};
		},
		components: {
	
			processUnit,
			filesUnit,
			popUp
		},
		computed: {
			...mapGetters({'users':'getUser'}),
		
		},
		
		methods: {
			clickGetSubscribefee(id) {
				this.showId = id
				this.showPopupMiddle = true
			
			},
			closePop(){
				this.showPopupMiddle = false
			},
			// 图片预览
			showImg(src,index) {
		
				uni.previewImage({
					urls: this.imageUrls,
					current: index,
					loop: true,
					indicator: 'number'
				});
			},
			showPop(type) {
				let _this = this
				let url = ''
				switch (type) {
					case 4000: 
							url = '/pages/auditingPop/transfer?businessType=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS
						break;
					case 2000:
							url = '/pages/auditingPop/toExamine?businessType=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS+'&ApproName='+_this.ExpenseBill.ApproName+'&ACCEPT_TYPE='+_this.ExpenseBill.ACCEPT_TYPE+'&NeedApproved='+_this.ExpenseBill.NeedApproved
						
						break;
					case 3000:
							url = '/pages/auditingPop/reject?businessType=3000&PROINST_ID='+_this.ExpenseBill.FINANCEPROINST_ID+'&NOWACTINST_ID='+_this.ExpenseBill.NOWACTDEF_IDS+'&ACCEPT_TYPE='+_this.ExpenseBill.ACCEPT_TYPE
						
						break;
				}
				this.$util.toNextRoute('navigateTo', url)
			},

			// 获取页面数据
			getData(_id) {
				let _this = this
			
				this.$request.$get('GetFinanceFlowDetail',{
					
					FINANCEPROINST_ID: _id, //业务内码
	
				}).then(res => {
					if(!res.ResultCode ||res.ResultCode!='100'){
						_this.isShow = false
					}
					
					let _data = res.Data
					_this.ExpenseBill = _data || {};
					_data.PAYMENT_LOWER =_data.ExpenseBill.PAYMENT_LOWER
					if(_data.FileList){
						
						_data.FileList.map(v => {
							let name= v.ATTACHMENT_NAME.split('.')
							v.type = name[name.length-1]
							v.name = v.ATTACHMENT_NAME
							v.path = v.ATTACHMENT_URL
						})
					}
					let arr = []
					if(_data.ImageList){
						
						_data.ImageList.map(v => {
							arr.push(v.IMAGE_URL)
						})
					}
					_this.imageUrls = arr
					let  preSubscribefeeMap = {}
				
					if(_data.PreSubscribefeeList) {
						
						_data.PreSubscribefeeList.map(u=>{
							preSubscribefeeMap[u.FINANCEPROINST_ID] = u
						})
						_this.preSubscribefeeMap = preSubscribefeeMap
					}
					// if (_data.NOWSTAFF_ID == _this.users.UserId) { // 该用户是当前详情处理人
					
					// 	_this.doUser = true
					// }
					_this.$forceUpdate()
					
					uni.hideLoading()
					setTimeout(function(){
						
						_this.isShow  = true
						_this.isLoading  = false
					},500)
					
				})
			},
		},
		onLoad(option) {
			uni.showLoading({
				title:'正在加载'
			})
			
			this.isLoading =true
			this.getData(option.id)
			let _this = this
			uni.$on('3000', function (data){
				if(data) {
					uni.showLoading({
						title:'正在加载'
					})
					_this.isLoading =true
					_this.getData(_this.ExpenseBill.FINANCEPROINST_ID)
					// _this.$eventHub.$emit('3000',false)
				}
			});
		},
		onShow() {
			
		},
		onUnload() {
			this.$util.addUserBehavior()
			uni.$off('3000');
		},
		onHide() {
			
		}
	
	}
</script>

<style scoped>
	@import url("../../common/css/expensesTop.css");

	.mt20 {
		margin-top: 20upx;
	}
	.cost-unit-card {
		border-top: none;
		display: flex;
		flex-direction: column;
		/* padding: 0 8upx 0 8upx; */
	}
	.cost-unit-card+.cost-unit-card {
		border-top: 2upx dashed #eee ;
		padding-top: 24upx;
		margin-top: 24upx;
	}
	.linkText {
		margin-left: 16upx;
		text-decoration: underline;
		color: #72aaea;
	}
</style>
