<template>
  <div class="dataShare-taskDetail-container layout-padding">
    <div class="layout-padding-auto layout-padding-view pd20">
			<vxe-toolbar
				ref="toolbarRef"
				:loading="state.loading"
				custom
				:refresh="{
					queryMethod: queryList,
				}"
			>
			</vxe-toolbar>
			<div style="overflow: hidden; width: 100%; height: 100%; flex: 1">
				<vxe-table
					border
					:loading="state.loading"
					:data="state.tableData"
					:column-config="{ resizable: true }"
					:row-config="{ isCurrent: true, isHover: true, height: 30, useKey: true }"
					ref="tableRef"
					height="auto"
					auto-resize
					show-overflow
					:scrollY="{ enabled: true, gt: 100 }"
					id="dataShareTaskDetail"
					:custom-config="{ storage: true }"
				>
					<vxe-column field="provinceNo" title="推送状态" width="100">
						<template #default="{ row }">
							{{ row.isSuccess ? '成功' : '失败' }}
						</template>
					</vxe-column>
					<vxe-column field="result" title="返回数据" min-width="200"></vxe-column>
					<vxe-column field="resultErrorData" title="错误数据" min-width="200"></vxe-column>
					<vxe-column field="processingServices" title="推送平台" width="140"></vxe-column>
					<vxe-column field="创建时间" title="推送平台" width="160">
						<template #default="{ row }">
							{{ formatDate(row.creationTime, 'YYYY-mm-dd HH:MM:SS') }}
						</template>
					</vxe-column>
				</vxe-table>
			</div>
			<pagination
				@pagination="queryList"
				:total="state.total"
				v-model:current-page="state.queryParams.PageIndex"
				v-model:page-size="state.queryParams.PageSize"
				:disabled="state.loading"
			/>
    </div>
  </div>
</template>
<script setup lang="tsx" name="dataShareTaskDetail">
import { defineAsyncComponent, onMounted, reactive, ref } from 'vue';
import { getPushTaskDetailNew } from "@/api/dataShare";
import { useRoute } from "vue-router";
import { formatDate } from "@/utils/formatTime";

const pagination = defineAsyncComponent(() => import('@/components/ProTable/components/Pagination.vue')); // 分页
// 定义变量内容
const state = reactive({
  queryParams: {
    // 查询条件
    PageIndex: 1,
    PageSize: 20,
  },
  tableData: [], //表单
  loading: false, // 加载
  total: 0, // 总数
});
/** 获取列表 */
const route = useRoute();
const queryList = () => {
  state.loading = true;
  const request = {
    PageIndex: state.queryParams.PageIndex,
    PageSize: state.queryParams.PageSize,
    Id: route.params.id
  }
  getPushTaskDetailNew(request)
    .then((res: any) => {
      state.tableData = res.result?.items ?? [];
      state.total = res.result?.total ?? 0;
      state.loading = false;
    })
    .catch(() => {
      state.loading = false;
    });
};
const toolbarRef = ref<RefType>();
const tableRef = ref<RefType>();
onMounted(() => {
  queryList();
	if (tableRef.value && toolbarRef.value) {
		tableRef.value.connect(toolbarRef.value);
	}
});
</script>
