<template>
	<view class="invoice-detail">
		<view class="hui-detail">
			<view class="detail-box">
				<view class="title-box">
					<view class="title">{{detail.name}}</view>
					<view class="date">{{detail.createTime}}</view>
					<view class="title-icon">
						<uni-icons type="icon-hetongwendang" custom-prefix="iconfont" color="#fff" size="18">
						</uni-icons>
					</view>
				</view>
				<view class="other">
					<view class="item">
						<view class="label">订单编号</view>
						<view class="value"> {{detail.orderNo}}</view>
					</view>
					<view class="item">
						<view class="label">纳税人识别号</view>
						<view class="value">{{detail.taxpayerIdentificationNumber}}</view>
					</view>
					<view class="item">
						<view class="label">注册电话</view>
						<view class="value"> {{detail.phone}}</view>
					</view>
					<view class="item">
						<view class="label">开户银行</view>
						<view class="value">{{detail.bankAccount}}</view>
					</view>
					<view class="item">
						<view class="label">银行账号</view>
						<view class="value"> {{detail.bankAccountNumber}}</view>
					</view>
					<view class="item" v-if="detail.state === 1">
						<view class="label">发票内容</view>
						<view class="value">{{detail.content}}</view>
					</view>
					<view class="item">
						<view class="label">发票金额</view>
						<view class="value color-error"> {{detail.amount || '-'}}</view>
					</view>
					<view class="item">
						<view class="label">注册地址</view>
						<view class="value">{{detail.address}}</view>
					</view>
					<view class="item">
						<view class="label">订单编号</view>
						<view class="value"> {{detail.orderNo}}</view>
					</view>
					<view class="item" v-if="detail.state === 1">
						<view class="label">发票文件</view>
						<view class="value">
							<upload :list="detail.file ? JSON.parse(detail.file) : []" type="preview">
							</upload>
						</view>
					</view>
				</view>
				<view class="state">
					<view class="tag">
						<view class="status-tag info" v-if="!detail.state">开具中</view>
						<view class="status-tag success" v-else>已开具</view>
					</view>
					<view class="tag">
						<view class="status-tag primary"
							@tap.stop="$navigateTo('/subPages/indexPage/orderDetail/orderDetail?orderNo='+detail.orderNo)">
							查看订单
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		getInvoiceDetailById
	} from '@/request/api/workark.js'
	import upload from '@/components/common/upload.vue';
	export default {
		data() {
			return {
				invoiceId: '',
				detail: {}
			}
		},
		onLoad(body) {
			this.invoiceId = body.invoiceId;
			if (this.invoiceId) this.init();
		},
		methods: {
			async init() {
				let invoiceData = await getInvoiceDetailById(this.invoiceId);
				if (invoiceData.state) this.detail = invoiceData.data;
			}
		},
		components: {
			upload
		}
	}
</script>

<style lang="scss" scoped>

</style>