<template>
	<el-dialog v-model="state.dialogVisible" draggable title="重复工单" ref="dialogRef" width="60%" append-to-body>
		<el-table :data="state.tableData" ref="multipleTableRef">
			<el-table-column prop="phoneNo" label="工单标题" show-overflow-tooltip>
				<template #default="{ row }">
					<span class="color-primary">{{ row.title }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="hotspotName" label="热点分类" show-overflow-tooltip> </el-table-column>
			<el-table-column prop="no" label="工单编码" show-overflow-tooltip> </el-table-column>
			<el-table-column prop="actualHandleStepName" label="当前环节" show-overflow-tooltip></el-table-column>
			<el-table-column label="工单状态" show-overflow-tooltip width="100" prop="statusText"></el-table-column>
			<template #empty>
				<Empty />
			</template>
		</el-table>
    <pagination
      @pagination="queryList"
      :total="state.total"
      v-model:current-page="state.queryParams.PageIndex"
      v-model:page-size="state.queryParams.PageSize"
    />
	</el-dialog>
</template>

<script setup lang="ts" name="orderRepeat">
import { reactive, ref,defineAsyncComponent } from 'vue';
import { duplicateOrder } from '@/api/business/order';

const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
// 定义变量内容
const state = reactive<any>({
	dialogVisible: false, // 弹窗显示隐藏
	queryParams: {
		PageIndex: 1, // 当前页
		PageSize: 10, // 每页条数
	},
	tableData: [], // 表格数据
	total: 0, // 总条数
	loading: false, // 加载状态
	ruleForm: {}, // 表单数据
});
const ruleFormRef = ref<RefType>(); // 表单ref
// 打开弹窗
const openDialog = (row: any) => {
	state.ruleForm = row;
	queryList();
	state.dialogVisible = true;
};
const dialogRef = ref<RefType>();
// 关闭弹窗
const closeDialog = () => {
	state.dialogVisible = false;
};
/** 获取历史工单 */
const queryList = () => {
	if (!state.ruleForm.duplicateIds) return;
	state.loading = true;
	let req = {
		...state.queryParams,
		OrderIds: state.ruleForm.duplicateIds,
	};
	duplicateOrder(req)
		.then((response: any) => {
			state.tableData = response?.result.items ?? [];
			state.total = response?.result.total;
			state.loading = false;
		})
		.catch(() => {
			state.loading = false;
		});
};
// 暴露变量
defineExpose({
	openDialog,
	closeDialog,
});
</script>
