<template>
	<el-dialog v-model="state.dialogVisible" draggable title="会签明细" ref="dialogRef" width="50%" append-to-body destroy-on-close>
		<el-form :model="state.queryParams" ref="ruleFormRef" @submit.native.prevent inline>
			<el-form-item label="关键词" prop="Keyword">
				<el-input v-model="state.queryParams.Keyword" placeholder="工单编码/标题" clearable @keyup.enter="queryList" />
			</el-form-item>
			<el-form-item label=" ">
				<el-button type="primary" @click="queryList" :loading="state.loading"> <SvgIcon name="ele-Search" class="mr5" />查询 </el-button>
				<el-button @click="resetQuery(ruleFormRef)" v-waves class="default-button" :loading="state.loading">
					<SvgIcon name="ele-Refresh" class="mr5" />重置
				</el-button>
			</el-form-item>
		</el-form>
		<!-- 表格 -->
		<el-table :data="state.tableData" v-loading="state.loading" row-key="id" ref="multipleTableRef">
			<el-table-column prop="no" label="会签编码" show-overflow-tooltip></el-table-column>
      <el-table-column prop="order.no" label="工单编码" show-overflow-tooltip width="150"></el-table-column>
      <el-table-column prop="sourceChannel" label="来源方式" show-overflow-tooltip></el-table-column>
			<el-table-column width="100" label="省/市工单" prop="isProvince" >
        <template #default="{ row }">
          <span>{{ row.order?.isProvince ? '省工单' : '市工单' }}</span>
        </template>
      </el-table-column>
			<el-table-column prop="expiredTime" label="节点期满时间" show-overflow-tooltip width="170">
				<template #default="{ row }">
					<span>{{ formatDate(row.expiredTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="expiredTime" label="工单期满时间" show-overflow-tooltip width="170">
				<template #default="{ row }">
					<span>{{ formatDate(row.expiredTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="startTime" label="受理时间" show-overflow-tooltip width="170">
				<template #default="{ row }">
					<span>{{ formatDate(row.startTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
				</template>
			</el-table-column>
      <el-table-column prop="acceptType" label="受理类型" show-overflow-tooltip width="150"></el-table-column>
      <el-table-column label="工单状态" show-overflow-tooltip width="100" prop="statusText"></el-table-column>
      <el-table-column label="工单编码" prop="no" show-overflow-tooltip width="150">
        <template #default="{ row }">
          <span>{{ row.no }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="actualHandleOrgName" label="接办部门" show-overflow-tooltip width="170"></el-table-column>
      <el-table-column prop="actualHandleTime" label="接办时间" show-overflow-tooltip width="170">
        <template #default="{ row }">
          <span>{{ formatDate(row.actualHandleTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
        </template>
      </el-table-column>
      <el-table-column prop="order.hotspotName" label="热点分类" show-overflow-tooltip width="120"></el-table-column>
			<el-table-column prop="acceptTypeText" label="会签发起部门" show-overflow-tooltip></el-table-column>
			<el-table-column prop="acceptTypeText" label="会签发起人" show-overflow-tooltip></el-table-column>
			<el-table-column prop="expiredTime" label="会签发起时间" show-overflow-tooltip width="170">
				<template #default="{ row }">
					<span>{{ formatDate(row.expiredTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
				</template>
			</el-table-column>
			<el-table-column prop="acceptTypeText" label="被会签部门" show-overflow-tooltip></el-table-column>
			<el-table-column prop="acceptTypeText" label="会签处理人" show-overflow-tooltip></el-table-column>
			<el-table-column prop="expiredTime" label="会签处理时间" show-overflow-tooltip width="170">
				<template #default="{ row }">
					<span>{{ formatDate(row.expiredTime, 'YYYY-mm-dd HH:MM:SS') }}</span>
				</template>
			</el-table-column>
			<template #empty>
				<Empty />
			</template>
		</el-table>
		<!-- 分页 -->
		<pagination :total="state.total" v-model:page="state.queryParams.PageIndex" v-model:limit="state.queryParams.PageSize" @pagination="queryList" />
		<template #footer>
			<span class="dialog-footer">
				<el-button @click="closeDialog" class="default-button">关 闭</el-button>
			</span>
		</template>
	</el-dialog>
</template>
<script setup lang="ts" name="orderCountersignDetail">
import { reactive, ref } from 'vue';
import { ElButton, ElMessage, FormInstance } from 'element-plus';
import { auth } from '/@/utils/authFunction';
import { throttle } from '/@/utils/tools';
import { formatDate } from '/@/utils/formatTime';
import { useRouter } from 'vue-router';
// 引入组件

// 定义变量内容
const ruleFormRef = ref<RefType>(); // 表单ref
const router = useRouter(); // 路由
const state = reactive(<any>{
	queryParams: {
		// 查询条件
		PageIndex: 1,
		PageSize: 10,
		Keyword: '', // 关键字
	},
	dialogVisible: false, // 是否显示弹窗
	tableData: [{}], //表单
	loading: false, // 加载
	total: 0, // 总数
	countersignId: '', // 会签ID
});
/** 获取列表 */
const queryList = throttle(() => {
	if (!auth('business:countersign:detail')) ElMessage.error('抱歉，您没有权限查看会签明细列表！');
	else {
	}
}, 300);
/** 重置按钮操作 */
const resetQuery = throttle((formEl: FormInstance | undefined) => {
	if (!formEl) return;
	formEl.resetFields();
	queryList();
}, 300);
// 打开弹窗
const openDialog = (val: any) => {
	state.countersignId = val.id;
	queryList();
	state.dialogVisible = true;
};
// 关闭弹窗
const closeDialog = () => {
	state.dialogVisible = false;
};
defineExpose({
	openDialog,
	closeDialog,
});
</script>

<style scoped lang="scss">
.business-countersignDetail-container {
}
</style>
