<template>
	<view class="reporttable">
		<scroll-view scroll-x class="reporttable-scroll">
			<view class="reporttable-ul" >
				<view class="reporttable-li" :style="{width: item.width + 'px'}" v-for="(item, index) in widgetModel.columns" :key="index">
					<view class="reporttable-li-title" :style="{color: colors[index]}">{{item.name}}</view>
					<view class="reporttable-cont" v-if="widgetModel.rows.length > 0">
						<view class="reporttable-cont-li" :style="{color: colors[index]}" v-for="(rowItem, rowIndex) in widgetModel.rows" :key="rowIndex">
							<view v-if="item.prop === 'city'" :style="{width: item.width + 'px'}" class="reporttable-cont-city">
								<text class="reporttable-cont-city-text">修改</text>
								<text class="reporttable-cont-city-text">删除</text>
							</view>
							<view v-else>
								<uni-easyinput v-model="rowItem[item.prop]"></uni-easyinput>
							</view>
						</view>
					</view>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	import tableJson from './table.json'
	export default {
		props: {
			dataModel: {}
		},
		data() {
			return {
				colorList: ['#c23531', '#2f4554', '#61a0a8', '#d48265', '#91c7ae', '#749f83', '#ca8622', '#bda29a', '#6e7074', '#546570', '#c4ccd3'],
				colors: [],
				tableApi: 'Api/Report/GetCountTable',
				viewList: [],
				widgetModel: tableJson
			}
		},
		created() {
			this.init()
		},
		methods: {
			init() {
				// this.viewList = JSON.parse(JSON.stringify(this.viewModel))
				// this.colors = []
				// this.viewModel.columns.forEach(item => {
				// 	let round = Math.round(Math.random() * (this.colorList.length - 1))
				// 	this.colors.push(this.colorList[round])
				// })
			},
			addTable() {
				let para = {}
				this.widgetModel.columns.forEach(item => {
					para[item.prop] = this.dataModel[item.prop]
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.reporttable {
		padding: 0 20rpx;
		margin-bottom: 20rpx;
		&-scroll{
			width: 710rpx;
		}
		&-ul {
			flex-direction: row;
		}
		&-li{
			width: 236rpx;
			&-title{
				height: 80rpx;
				text-align: center;
				line-height: 80rpx;
				@include styleFont(#343434, 28rpx, 1);
				&:last-child {
					border-right-width: 0;
				}
			}
		}
		&-cont{
			&-li{
				height: 80rpx;
				padding: 0 10rpx;
				box-sizing: border-box;
				line-height: 80rpx;
				text-align: center;
				@include styleFont(#343434, 28rpx, 1);
			}
			&-city{
				flex-direction: row;
				justify-content: flex-end;
				&-text{
					@include styleFont(#3981f7, 28rpx);
					margin-left: 15rpx;
				}
			}
		}
		&-pagination{
			padding: 0 20rpx;
			margin: 30rpx 0;
		}
	}
</style>
