<!-- 行政资产 -->
<template>
	<view class="travel-expense" v-show="isShow">
		<view class="travel-top">
			
			<h4>{{ExpenseBill.DEPT_NAME}}</h4>
			<h3>{{ExpenseBill.ACCEPT_NAME}}</h3>
			<div class="detail-top-base">
				<view class="span24">
					<text class="text-title">{{ExpenseBill.ExpenseBill.DEPARTMENT_NAME}}：</text>
					<text >{{ExpenseBill.STAFF_NAME}}</text>
				</view>
				<text>{{$util.cutDate(ExpenseBill.FINANCEPROINST_CREATEDATE)}}</text>
			</div>
			<view class="detail-top-box">
				<view class="detail-top-bottom ">
					<view class="uni-flex" style="align-items:flex-start;">
						<div class="detail-title">
							<i class="ico ico-fy"></i>
							商品名称：
						</div>
						<text class="span24">{{ExpenseBill.ExpenseBill.COMMODITY_NAME+ExpenseBill.ExpenseBill.COMMODITY_RULE}}</text>
					</view>
					<view class="uni-flex span24 mt8"  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.BUDGET_PRICE,2)}}</text>
					</view>
					<view class="line-block between-circle"></view>
					<view class="uni-flex " style="align-items:flex-start;" v-if="ExpenseBill.ExpenseBill.APPLY_INFO">
						<div class="detail-title">
							<i class="ico ico-ly"></i>
							申请理由：
						</div>
						<text class="span24">{{ExpenseBill.ExpenseBill.APPLY_INFO}}</text>
					</view>
					
					
					<view class="uni-flex mt8" style="align-items:center;" v-if="ExpenseBill.ExpenseBill.APPLY_OTHER">
						<div class="detail-title">
							<i class="ico ico-bz"></i>
							其他要求：
						</div>
						<text class="span24">{{ExpenseBill.ExpenseBill.APPLY_OTHER}}</text>
					</view>
					<view class="uni-flex mt8" style="align-items:flex-start;" v-if="ExpenseBill.ExpenseBill.SUBSCRIBEFEE_DESC">
						<div class="detail-title">
							<i class="ico ico-bz"></i>
							备注说明：
						</div>
						<text class="span24">{{ExpenseBill.ExpenseBill.SUBSCRIBEFEE_DESC}}</text>
					</view>
					
				</view>
				<view class="detail-middle-box" v-if=" ExpenseBill.FileList || ExpenseBill.ImageList">
					
					<view 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>
					</view>
					<view class="attachment" v-if="ExpenseBill.ImageList && ExpenseBill.ImageList.length>0">
						<div  class="detail-title">
							<i class="ico ico-tp"></i>
							<text>图 片</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>
					</view>
				</view>
			
			</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="cardShow ? ' uni-navigate-bottom' : 'uni-navigate-right'" @tap="cardShow =!cardShow">
					<b>审批流程</b>
				</div>
				<div class="process-box uni-collapse-content" :class="cardShow ? 'uni-active' : ''" v-show="cardShow">
					<processUnit v-for="item in ExpenseBill.ApprovedList" :item="item" :key="item.APPROVED_DATE" :approveType='1' />
				</div>
			</div>
		</view>
		
	</view>
</template>

<script>
	import {mapGetters} from 'vuex'
	import filesUnit from '@/components/filesComponent/fileUnit.vue'
	import processUnit from '@/components/auditingProcess/item.vue'
  
	
	export default {
		
		data() {
		
			return {
				imageUrls:[],
				
				isShow:false,
				ExpenseBill:{},
				showPopupMiddle: false,
				popType: 'middle',
				cardShow: true, // 控制折叠面板
				
				isExamine: false, // 按钮显示隐藏
			};
		},
		components: {
			filesUnit,
			processUnit
	
		},
		computed: {
			...mapGetters({'users':'getUser'}),
	
		},
		methods: {
			// 图片预览
			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.BUDGET_PRICE =_data.ExpenseBill.BUDGET_PRICE
					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
				
					_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)
					
				}
			});
		},
		onShow() {
			
			
		},
		onUnload() {
			this.$util.addUserBehavior()
			uni.$off('3000');
		},
		onHide() {
			
		}
	}
</script>

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