<!-- 审核表格 -->
<template>
	<div class='approvalTable'>
		<!--@row-click="rowClick"-->
		<el-table
						:data="tableList"
						class="tables"
						border
						@row-click="rowClick"
						style="width: 100%">
			<el-table-column
							prop="status"
							class="firstTable"
							label=""
							width="15">
				<template slot-scope="scope">
					<span class="statusBg" :style="{background: $common.colorNum(scope.row.status)}"></span>
				</template>
			</el-table-column>
			<el-table-column
							prop="userName"
							label="申请人"
							align="center">
			</el-table-column>
			<!--width="100"-->
			<el-table-column
							prop="approvalType"
							label="类型"
							align="center">
			</el-table-column>
			<!--width="200"-->
			<el-table-column
							prop="applyTime"
							label="申请时间"
							align="center">
			</el-table-column>
			<el-table-column
							prop="status"
							label="状态"
							align="center">
				<template slot-scope="scope">
					<span :style="{color: $common.colorNum(scope.row.status)}">{{$common.approvalStatusName(scope.row.status)}}</span>
				</template>
			</el-table-column>
			<el-table-column
							label="操作"
							v-if="showEdit === true"
							align="center">
				<template slot-scope="scope">
					<!--<el-button @click="rowClick(scope.row)" type="text" size="small">查看<i class="el-icon-view"></i></el-button>-->
					<el-button :disabled="scope.row.status !== '0'" slot="reference" style="background: #EE4B4C" @click.stop="deleteApproval(scope.row)" type="text" size="small">删除<i class="el-icon-delete"></i></el-button>
				</template>
			</el-table-column>
		</el-table>
	</div>
</template>

<script>
	//这里可以导入其他文件（比如：组件，工具js，第三方插件js，json文件，图片文件等等）
	//例如：import 《组件名称》 from '《组件路径》';

	export default {
		name: "approvalTable",
//import引入的组件需要注入到对象中才能使用
		components: {},
		props: ['tableList', 'user'],
		data () {
//这里存放数据
			return {
				table: [],
				visible: false,
				userDetail: '',
				showEdit: false,
			};
		},
//监听属性 类似于data概念
		computed: {},
//监控data中的数据变化
		watch: {
			user: {
				immediate: true,
				handler(val) {
					console.log(val)
					console.log(val.roles)
					if (val.roles !== undefined && val.roles.length > 0 && val.roles[0].authorities.findIndex(item => item.name === '审批管理') > -1) {
						this.showEdit = false;
					} else {
						this.showEdit = true;
					}
				}
			}
		},
//方法集合
		methods: {
			rowClick(val) {
				console.log(val)
				this.$emit('trData', val);
			},
			deleteApproval(val) {
				console.log(val)
				this.$emit('delete', val);
			}
		},
//生命周期 - 创建完成（可以访问当前this实例）
		created () {

		},
//生命周期 - 挂载完成（可以访问DOM元素）
		mounted () {
			// this.userDetail = JSON.parse(this.$Base64.decode(localStorage.getItem('login')));
			// if (this.userDetail.roles !== undefined && this.userDetail.roles.length > 0 && this.userDetail.roles[0].authorities.findIndex(item => item.name === '审批管理') === -1) {
			// 	this.showEdit = true;
			// }
		},
		beforeCreate () {
		}, //生命周期 - 创建之前
		beforeMount () {
		}, //生命周期 - 挂载之前
		beforeUpdate () {
		}, //生命周期 - 更新之前
		updated () {
		}, //生命周期 - 更新之后
		beforeDestroy () {
		}, //生命周期 - 销毁之前
		destroyed () {
		}, //生命周期 - 销毁完成
		activated () {
		}, //如果页面有keep-alive缓存功能，这个函数会触发
	}
</script>
<style scoped>
	.approvalTable{
		margin-bottom: 60px; /*no*/
	}
	.approvalTable /deep/ .el-table td{
		padding: 0 0 !important;
		height: 70px !important;
		min-width: 0;
		-webkit-box-sizing: border-box;
		box-sizing: border-box;
		text-overflow: ellipsis;
		vertical-align: middle;
		position: relative;
		text-align: center;
		border-right: 0 !important;
		border-left: 0 !important;
		border-bottom: 3px solid #F5F5F5;
	}

	/deep/ .el-table--border, .el-table--group {
		border: 0px solid #EBEEF5;
	}

	.statusBg{
		display: block;
		width: 10px;
		height: 80px;
		margin-left: -11px;
	}

	/deep/ .el-button.is-disabled, .el-button.is-disabled:focus, .el-button.is-disabled:hover {
		color: #FFF;
		cursor: not-allowed;
		background-image: none;
		background-color: #d1d1d1 !important;
		border-color: #d1d1d1;
	}
</style>
