<template>
	<ciy-header title="开票记录" ref="header"></ciy-header>
	<view v-if="init.code != 1" class="px4 py4">
		<view style="height:4em;width:100%;" class="ciy-skeleton"></view>
		<view style="height:6em;width:100%;" class="ciy-skeleton"></view>
		<view style="height:6em;width:100%;" class="ciy-skeleton"></view>
	</view>
	<view v-else>
		<view class="sti" :style="{top:(header_statusbar_height+header_title_height)+'px'}">
			<ciy-segment lis="20:待开票,100:已开票,90:已拒开" all="全部" @change="segment_change"></ciy-segment>
		</view>
		<view class="ciy-list" v-for="(item,index) in init.list" :key="item.id">
			<view class="rt">
				<text class="kbd" :class="ccode(g.auditstatus, item.auditstatus,'clas')">{{ccode(g.auditstatus,item.auditstatus)}}</text>
			</view>
			<view class="l2 txt-wb">{{ccode(init.ap_invoicedetail,item.invoicedetailid)}}</view>
			<view class="l2">{{item.name}}</view>
			<view class="l3" v-if="item.taxnumber">税号 {{item.taxnumber}}</view>
			<view class="l3" v-if="item.addr">地址 {{item.addr}}</view>
			<view class="l3" v-if="item.phone">电话 {{item.phone}}</view>
			<view class="l3" v-if="item.bankname">银行 {{item.bankname}}</view>
			<view class="l3" v-if="bankaccount">账号 {{item.bankaccount}}</view>
			<view class="lb">{{todatetime(item.addtimes)}}</view>
			<template v-if="item.audittimes>20">
				<view class="ciy-hr"></view>
				<view class="l2" v-if="item.invcode">发票号码 <text class="txt-lgg px2" @tap="copyboard(item.invcode)">{{item.invcode}}</text></view>
				<ciy-showimgs label="发票附件" :src="item.invfile"></ciy-showimgs>
				<view class="l2">操作时间 {{todatetime(item.audittimes)}}</view>
				<view class="l2" v-if="item.auditmsg">拒开原因 {{item.auditmsg}}</view>
			</template>
			<view class="rb">
				<text class="txt-lgg txt-wb px2">{{item.invoicemoney/100}}</text>
				<text class="txt-smm">元</text>
			</view>
		</view>
		<ciy-listend :page="pageno" :listlen="init.list.length" :nodataimg="file_stor('/img/mbnone.png')"></ciy-listend>
	</view>
</template>

<style>
</style>

<script>
	export default {
		data() {
			return {}
		},
		onLoad() {
			this.getlist();
		},
		onReachBottom(b) {
			if (this.init.code != 1)
				return;
			this.getlist();
		},
		onPullDownRefresh(b) {
			this.pageno = 0;
			this._stopPullDown = true;
			this.getlist();
		},
		watch: {},
		computed: {},
		methods: {
			async getlist() {
				if (this.pageno < 0)
					return;
				if (this._loading)
					return;
				this.pagepost.pageno = this.pageno + 1;
				this._loading = true;
				var retjson = await this.callfunc({
					func: 'me.invoice_lst_list',
					data: this.pagepost
				});
				this._loading = false;
				if (retjson.code != 1)
					return this.alert(retjson.errmsg);
				this.pageno++;
				if (this.pageno == 1)
					this.init.list = [];
				this.init = this.objdeepmerge(this.init, retjson);
				if (retjson.list.length < retjson.pagecount)
					this.pageno = -1;
			},
			segment_change(e) {
				this.pagepost.liid = e.value.id;
				this.pageno = 0;
				this.getlist();
				uni.pageScrollTo({
					scrollTop: 0,
					duration: 800
				});
			}
		}
	}
</script>