<template>
	<el-dialog v-model="state.dialogVisible" width="50%" draggable title="重复性事件详情" append-to-body destroy-on-close>
		<el-form :model="state.ruleForm" label-width="80px" ref="ruleFormRef" class="show-info-form">
			<el-row :gutter="10">
				<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
					<el-form-item label="标题">
						{{ state.ruleForm.title }}
					</el-form-item>
				</el-col>
				<el-col :xs="24" :sm="24" :md="24" :lg="24" :xl="24">
					<el-form-item label="关键词">
						{{ state.ruleForm.keyWords }}
					</el-form-item>
				</el-col>
			</el-row>
		</el-form>
		<el-divider content-position="left">
			<el-text tag="b" size="large"> 重复事件工单 </el-text>
		</el-divider>
		<vxe-table
			border
			:loading="state.loading"
			:data="state.repeatTable"
			:column-config="{ resizable: true }"
			:row-config="{ isCurrent: true, isHover: true, height: 30,useKey:true }"
			show-overflow
			:scrollY="{ enabled: true, gt: 100 }"
			showHeaderOverflow
			max-height="300px"
		>
			<vxe-column field="order.no" title="工单编码" width="140"></vxe-column>
			<vxe-column field="order.isProvinceText" title="省/市工单" width="100"></vxe-column>
			<vxe-column field="order.currentStepName" title="当前节点" width="120"></vxe-column>
			<vxe-column field="order.statusText" title="工单状态" width="100">
				<template #default="{ row }">
					<el-text type="danger" tag="b" v-if="[1, 2, 3, 9, 101, 102, 103, 104, 105, 200].includes(row.order.status)">{{ row.order.statusText }}</el-text>
					<span v-else>{{ row.order.statusText }}</span>
				</template>
			</vxe-column>
			<vxe-column field="order.title" title="工单标题" min-width="200">
				<template #default="{row}">
					<order-detail :order="row.order">{{ row.order?.title }}</order-detail>
				</template>
			</vxe-column>
			<vxe-column field="order.startTime" title="受理时间" width="160">
				<template #default="{ row }">
					{{ formatDate(row.order.startTime, 'YYYY-mm-dd HH:MM:SS') }}
				</template>
			</vxe-column>
			<vxe-column field="order.expiredTime" title="工单期满时间" width="160">
				<template #default="{ row }">
					{{ formatDate(row.order.expiredTime, 'YYYY-mm-dd HH:MM:SS') }}
				</template>
			</vxe-column>
			<vxe-column field="order.actualHandleOrgName" title="接办部门" width="140"></vxe-column>
			<vxe-column field="order.acceptType" title="受理类型" width="140"></vxe-column>
			<vxe-column field="order.hotspotName" title="热点分类" width="150"></vxe-column>
			<vxe-column field="order.sourceChannel" title="来源渠道" width="140"></vxe-column>
			<vxe-column field="order.acceptorName" title="受理人" width="120"></vxe-column>
		</vxe-table>
	</el-dialog>
</template>
<script setup lang="tsx" name="repeatEventDetail">
import { reactive, defineAsyncComponent, ref } from 'vue';
import { formatDate } from '@/utils/formatTime';
import { repeatEventDetail } from '@/api/business/repeatEvent';

const OrderDetail = defineAsyncComponent(() => import('@/components/OrderDetail/index.vue')); // 工单详情

const state = reactive({
	loading: false, // 加载
	dialogVisible: false, // 弹窗
	ruleForm: {},
	repeatTable: [], // 重复事件工单
});
// 创建重复事件
const openDialog = (row: any) => {
	getDetail(row);
};
// 查询详情
const getDetail = async (row: any) => {
	try {
		const { result } = await repeatEventDetail({ id: row.id, Keyword: null });
		state.ruleForm = result;
		state.repeatTable = result.details;
		state.dialogVisible = true;
	} catch (e) {
		console.log(e);
	}
};
defineExpose({
	openDialog,
});
</script>
