<template>
	<el-container>
		<el-main class="nopadding">
			<scTable
				ref="table"
				:data="list"
				row-key="id"
				stripe
				highlightCurrentRow
				hidePagination
			>
				<el-table-column label="ID" prop="id"></el-table-column>
				<el-table-column label="工单标题" prop="title"></el-table-column>
				<el-table-column label="流水号" prop="sn"></el-table-column>
				<el-table-column label="当前状态">
					<template #default="scope">
						{{ scope.row.state_.name }}
					</template>
				</el-table-column>
				<el-table-column label="进行状态" prop="sort">
					<template #default="scope">
						{{ actstate_[scope.row.act_state] }}
					</template>
				</el-table-column>
				<el-table-column label="关联工作流" prop="title">
					<template #default="scope">
						{{ scope.row.workflow_.name }}
					</template>
				</el-table-column>
				<el-table-column label="处理人类型">
					<template #default="scope">
						{{ participant_[scope.row.participant_type] }}
					</template>
				</el-table-column>
				<el-table-column label="创建时间" prop="create_time"></el-table-column>
				<el-table-column label="操作" fixed="right" align="right" width="120">
					<template #default="scope">
						<el-button type="text" size="small" @click="handleShow(scope.row)">查看详情</el-button>
					</template>
				</el-table-column>
			</scTable>
		</el-main>
	</el-container>
</template>

<script>
	export default {
		name: "state",
		data() {
			return {
				list: [],

				actstate_: {
					0: "草稿中",
					1: "进行中",
					2: "被退回",
					3: "被撤回",
					4: "已完成",
					5: "已关闭",
				},
				participant_: {
					0: "无处理人",
					1: "个人",
					2: "多人",
				},
			};
		},
		mounted() {
			this.getList();
		},
		methods: {
			async getList() {
				let res = await this.$API.wf.ticket.list.req({category: "worked", page: 0});
				console.log(res);
				this.list = res;
			},
			handleShow(row) {
				var catetype = row.workflow_.key;
				switch (catetype) {
					case 'visit':
						this.$router.push({
							name: "visitdetail",
							query: {
								id: row.id,
								type: 'show',
								visitID: row.ticket_data.visit
							},
						});
						break;
				}
			},
		},
	};
</script>

<style scoped>
</style>
