<template>
    <div class="mesMaterial-container">
        <el-dialog v-model="isShowDialog" width="80%" draggable="" :before-close="closeDialog" destroy-on-close>
            <template #header>
                <div style="color: #fff">
                    <!--<el-icon size="16" style="margin-right: 3px; display: inline; vertical-align: middle"> <ele-Edit /> </el-icon>-->
                    <span>查询同步信息</span>
                </div>
            </template>
            <el-button-group>
                <el-button type="primary" icon="ele-Refresh" @click="handleQuery"> 刷新 </el-button>
            </el-button-group>
            <el-table :data="tableData" style="width: 100%;margin-top: 10px;" v-loading="loading" ref="tableRef"
                tooltip-effect="light" row-key="id" border>
                <el-table-column type="index" label="序号" width="55" align="center" />
                <el-table-column prop="title" label="标题" show-overflow-tooltip="" />
                <el-table-column prop="ctx" label="内容" show-overflow-tooltip="" />
                <el-table-column prop="res" label="结果" show-overflow-tooltip="" />
                <el-table-column prop="isSuccess" label="是否成功" width="140" show-overflow-tooltip="">
                    <template #default="scope">
                        <el-tag v-if="scope.row.isSuccess == 0">同步中</el-tag>
                        <el-tag v-if="scope.row.isSuccess == 1" type="success">同步完成</el-tag>
                        <el-tag v-if="scope.row.isSuccess == 2" type="danger">同步失败</el-tag>
                    </template>
                </el-table-column>
                <el-table-column prop="ext" label="额外数据" width="140" show-overflow-tooltip="" />
                <el-table-column prop="createTime" label="开始时间" width="140" show-overflow-tooltip="" />
            </el-table>
            <el-pagination v-model:currentPage="tableParams.page" v-model:page-size="tableParams.pageSize"
                :total="tableParams.total" :page-sizes="[10, 20, 50, 100, 200, 500]" small="" background=""
                @size-change="handleSizeChange" @current-change="handleCurrentChange"
                layout="total, sizes, prev, pager, next, jumper" />
        </el-dialog>
    </div>
</template>
  
<script lang="ts" setup="" name="mesMaterial">
import { pageComOptLog } from '/@/api/mes/comOptLog';
import { ref } from "vue";
import { ElMessageBox, ElMessage } from "element-plus";
import { formatDate } from '/@/utils/formatTime';
import { nextTick } from "vue";

var props = defineProps({
    /**
     * 标题
     */
    title: {
        type: String,
        default: "",
    },
});

const showAdvanceQueryUI = ref(true);
const loading = ref(false);
const tableData = ref<any>([]);

const tableRef = ref<any>();
const isShowDialog = ref(false);
const options = ref<any>({});
const queryParams = ref<any>({});
const tableParams = ref({
    page: 1,
    pageSize: 10,
    total: 0,
});

// 打开弹窗
const openDialog = async () => {
    handleQuery();
    isShowDialog.value = true;
};

// 关闭弹窗
const closeDialog = () => {
    isShowDialog.value = false;
};

// 取消
const cancel = () => {
    isShowDialog.value = false;
};

// 查询操作
const handleQuery = async () => {
    loading.value = true;
    var res = await pageComOptLog(Object.assign(queryParams.value, tableParams.value));
    tableData.value = res.data.result?.items ?? [];
    tableParams.value.total = res.data.result?.total;
    loading.value = false;
};
// 改变页面容量
const handleSizeChange = (val: number) => {
    tableParams.value.pageSize = val;
    handleQuery();
};

// 改变页码序号
const handleCurrentChange = (val: number) => {
    tableParams.value.page = val;
    handleQuery();
};

//将属性或者函数暴露给父组件
defineExpose({ openDialog });
</script>
<style scoped>
:deep(.el-ipnut),
:deep(.el-select),
:deep(.el-input-number) {
    width: 100%;
}
</style>
  
  