<template>
	<div class="tels-callLog-connect-container">
		<el-dialog v-model="state.dialogVisible" draggable title="审核记录" destroy-on-close>
			<vxe-table
				border
				:loading="loading"
				:data="state.tableData"
				:column-config="{ resizable: true }"
				:row-config="{ isCurrent: true, isHover: true, height: 30,useKey:true }"
				ref="tableRef"
				show-overflow
				:scrollY="{ enabled: true, gt: 100 }"
				max-height="400"
			>
				<vxe-column field="workflow.actualHandlerName" title="审核人">
				</vxe-column>
				<vxe-column field="workFlowApplyStatusText" title="审核状态">
				</vxe-column>
				<vxe-column field="workflow.actualHandlerName" title="审核人">
				</vxe-column>
				<vxe-column field="handleTime" title="审核时间" width="160">
					<template #default="{ row }">
						{{ formatDate(row.handleTime, 'YYYY-mm-dd HH:MM:SS') }}
					</template>
				</vxe-column>
				<vxe-column field="actualOpinion" title="备注">
				</vxe-column>
			</vxe-table>
			<pagination
				@pagination="queryList"
				:total="state.total"
				v-model:current-page="state.queryParams.PageIndex"
				v-model:page-size="state.queryParams.PageSize"
				:disabled="state.loading"
			/>
			<template #footer>
				<span class="dialog-footer">
					<el-button @click="closeDialog" class="default-button">关 闭</el-button>
				</span>
			</template>
		</el-dialog>
	</div>
</template>

<script lang="tsx" setup>
import { ref, reactive, defineAsyncComponent } from 'vue';
import { formatDate } from '@/utils/formatTime';
import { knowledgeApproval } from '@/api/knowledge';


const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页

// 定义变量内容
const state = reactive<any>({
	queryParams: {
		// 查询参数
		PageIndex: 1,
		PageSize: 10,
		id: null, // 标签
	},
	tableData: [],
	total: 0,
	dialogVisible: false, // 弹窗显示隐藏
});
const loading = ref<Boolean>(false);
// 打开弹窗
const openDialog = (id: string) => {
	state.queryParams.id = id;
	state.dialogVisible = true;
	queryList();
};
const queryList = () => {
	loading.value = true;
	knowledgeApproval(state.queryParams)
		.then((res: any) => {
			state.tableData = res.result?.items ?? [];
			state.total = res.result?.total ?? 0;
			loading.value = false;
		})
		.catch(() => {
			state.tableData = [];
			state.total = 0;
			loading.value = false;
		});
};
// 关闭弹窗
const closeDialog = () => {
	state.dialogVisible = false;
};
//暴漏变量和方法
defineExpose({ closeDialog, openDialog });
</script>
