<template>
<div>
    <header class="mui-bar mui-bar-nav">
			<h1 class="mui-title">扫码放行</h1>
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		</header>
		<div class="mui-content vongi-fklist">
			<div class="vongi-clasadmin">
				<h4>{{info.companyName}}</h4>
				<div class="vongi-clasadmin-list">
					<div class="vongi-clasadmin-ma mui-col-xs-12">
						<p class="mui-ellipsis">{{queryDate}}</p>
						<span class="color999"><span class="colorFF7100">{{info.appointmentNum}}</span> / <span class="colorFF7100">{{info.passNum}}</span></span>
						<p class="mui-ellipsis color999">今日预约  / 已核验放行</p>
					</div>
				</div>
				<div class="vongi-btn">
					<button class="mui-btn mui-btn-primary" @click="scan">
						扫码核验<span class="iconfont icon-saoyisao"></span>
					</button>
				</div>
			</div>
			<div class="vongi-smhy-list">
				<div class="vongi-smhy-tit">放行记录</div>
				<ul class="mui-table-view mui-content-padded">
					<template v-if="info.map&&info.map.data">
						
						<li class="mui-table-view-cell mui-media" v-for="item,i in info.map.data" @click="gotoItem(item.id)">
							<a href="javascript:;" class="mui-navigate-right">
								申请人：{{item.personName}}
							</a>
							<p class="mui-ellipsis flew-sp">
								出厂时间：{{showtime(item.releaseTime)}}
								<span>核验人：{{item.releasePerson}} {{item.releaseCompany}}</span>
							</p>
						</li>
					</template>
				
					<li class="mui-table-view-cell mui-media">
						<a @click="gotoUrl" class="vongi-smhy-more" >查看全部记录</a>
					</li>
				</ul>				
			</div>			
		</div>
			<loading :visible="isLoading"></loading>
</div>
</template>


<script>
 	
	import * as API from '@/apis-xsy/scan'
  import * as WxJsApi from '$project/utils/wxJsApi'
  
	import  Common from '$project/components/Common.vue'
 	import Loading from '$project/components/Loading.vue'
	import TopHeader from '$project/components/TopHeader.vue'
 import {
 	currentTimeStamp,
 	parseUnixTime
 } from '$project/utils'
 import wx from "weixin-js-sdk";

	export default {
		name: '',
		components: {
			Common,
			Loading,
			TopHeader 
		},
		data() {
			return {
			 
				pageTitle: '申请调班',
				info:{},
				isLoading: false,
				 queryDate:'',
			}
		},
		created() {
			this.queryDate = parseUnixTime(currentTimeStamp(), '{y}-{m}-{d}');
 
		},
		methods: {
			scan(){
				var _this= this;
				wx.scanQRCode({
					needResult: 1,
					scanType: ["qrCode"],
					success: function (res) {
						var url = res.resultStr;
						_this.checkForm(url)
					},faile: function(res) {
						mui.toast("扫码失败");
					},
					complete() {
			
					}
				})
				
			},
			showtime(time){
				if(time){
					time=time.substring(5)
				}
				return time;
			},
			checkForm(url) {
				
				 window.location.href=url+"&scan=scan"
			},
			 gotoUrl(){
				this.$router.push({
				    name: "XsyScanList",
				})
			 },
			  gotoItem(id){
				  this.$router.push({
				      name: "XsyScanInfo",
						query:{id:id,
						scan:'scan'
						}
				  })
			  },
			getRemainingAmount(){
				this.isLoading = true;
					 
				API.indexData().then(response => {
					this.info=response;
				 
					this.isLoading = false;
				}).catch(error => {
					this.isLoading = false;
					mui.toast(error);
				})
			},
			asynCallBack() {

			},
		
		},
		mounted() {
				WxJsApi.getWxConfig();
			this.getRemainingAmount();
			
		},
		destroyed() {},
	
	}
</script>

<style src="$project/assets/css/iconfont.css"></style>
<style scoped src="$project/assets/css/xpwyfyy.css"></style>
<style src="$project/assets/css/xsy.css"></style>
<style>
</style>
