<template>
	<view class="content">
		<Nav :title="title" isBack isRight @goBack="handelBack" @change="change" />
		<view id="luckysheet"
			style="margin:0px;padding:0px;position:absolute;width:100%;height:95%;left: 0px;top: 80rpx;">
		</view>
		<u-empty mode="data" icon="../../../static/data.png" v-if="!option">
		</u-empty>
	</view>
</template>


<script>
	export default {
		data() {
			return {
				id: null,
				title: null,
				option: null
			}
		},
		onLoad(options) {
			this.id = options.id
		},
		onReady() {
			if (this.id) {
				this.getReportDetail()
			}
		},
		methods: {
			//返回按钮
			handelBack() {
				uni.switchTab({
					url: '/pages/reportForm/index'
				});
				let diaLog = document.getElementById('luckysheet-icon-morebtn-div')
				let more = document.getElementById('luckysheet-tooltip-up')
				if (diaLog) {
					diaLog.style.display = "none"
				}
				if (more) {
					more.style.display = "none"
				}
			},
			//表格详情接口
			getReportDetail() {
				uni.$http.get('/reportTable/getReportTableById/' + this.id).then(res => {
					const data = res.data
					if (data.code === 200) {
						this.title = data.data.reportTableName
						const tableData = JSON.parse(data.data.reportTableData)
						this.option = tableData.option
						if (this.option) {
							tableData.option.allowEdit = false
							luckysheet.create(this.option)
							this.showToolbar(tableData)
						}
					}
				})
			},
			showToolbar(tableData) {
				tableData.showtoolbar = false
				let data = tableData.option.showtoolbarConfig
				for (let item in data) {
					data[item] = false
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	::v-deep .luckysheet_info_detail_back {
		display: none !important;
	}
</style>
