<template>
	<lay-table class="empty-small2 empty-small3" style="margin:30px 0;" height="200px" :columns="dataColumn" id="FID"
		:dataSource="dataList">
		<template v-slot:toolbar>
			<p style="float:right;">操作日志</p>
			<lay-button size="sm" @click="_getPageList()">刷新</lay-button>
		</template>
	</lay-table>
</template>
<script>
	import {
		ref
	} from 'vue';
	import {
		getPageList
	} from "/src/api/api/common";

	export default {
		setup() {
			let dataColumn = [{
					title: "序号",
					key: "RowIndex",
					width: "80px"
				},
				{
					title: "操作时间",
					key: "FAddDate",
					width: "200px"
				},
				{
					title: "操作人",
					key: "FOptUser",
					width: "180px",
					align: 'center'
				},
				{
					title: "说明",
					key: "FDesc"
				}
			];
			dataColumn.forEach((item) => {
				item.align = "center";
			});
			const dataList = ref([]);
			return {
				dataColumn,
				dataList
			}
		},
		props: {
			dataInfoObj: {
				type: Object,
				default: () => {},
			}
		},
		mounted() {
			setTimeout((item) => {
				this._getPageList();
			}, 100);
		},
		methods: {
			cancelClick(isRefresh) {
				this.$emit('cancelClick', isRefresh !== undefined ? isRefresh : false);
			},
			//日期处理
			dateFormat(dataStr) {
				return dataStr.replace('T', ' ').split('.')[0];
			},
			async _getPageList() {
				if (this.dataInfoObj.FTeamID) {
					let postObj = {
						FTeamID: this.dataInfoObj.FTeamID,
						FType: this.dataInfoObj.FType,
						FPageSize: 99999
					};
					let result = await getPageList(postObj, 'OperateLog');
					this.dataList = result.Data.List || [];
					this.dataList.forEach(item => {
						item.FAddDate = item.FAddDate == null ? "" : this.dateFormat(item.FAddDate);
					});
				}
			}
		}
	}
</script>
