<template>
    <div class="app-container">
        <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="68px">
            <el-form-item label="任务名称" prop="taskName">
                <el-input 
                    v-model="queryParams.taskName"
                    placeholder="请输入任务名称"
                    clearable
                    @keyup.enter.native="handleQuery"
                />
            </el-form-item>

            <el-form-item label="来源系统" prop="baseId">
                <el-input 
                    v-model="queryParams.baseId"
                    placeholder="请输入来源系统名称"
                    clearable
                    @keyup.enter.native="handleQuery"
                />
            </el-form-item>

            <el-form-item>
                <el-button type="primary" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
                <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
            </el-form-item>
            
        </el-form>

        <el-table v-loading="loading" :data="serviceList">
            <el-table-column label="任务名称" min-width="120" align="center" prop="taskName" />
            <el-table-column label="任务路径" min-width="120" align="center" prop="taskUrl" :show-overflow-tooltip="true"/>
            <el-table-column label="来源系统" min-width="80" align="center" prop="baseId" />
            <el-table-column label="任务信息" min-width="120" align="center" prop="taskMessage" :show-overflow-tooltip="true"/>
            <el-table-column label="任务时间" min-width="60" align="center" prop="taskTime" :show-overflow-tooltip="true" :formatter="rounding"/>
            <el-table-column label="任务返回信息" min-width="150" align="center" prop="taskResult" :show-overflow-tooltip="true"/>
            <el-table-column label="异常信息" min-width="120" align="center" prop="taskAlarmSend" :show-overflow-tooltip="true"/>
            <el-table-column label="请求超时时间" align="center" prop="timeOutSecs" :show-overflow-tooltip="true"/>
            <el-table-column label="创建时间" min-width="120" align="center" prop="insertDate" :show-overflow-tooltip="true"/>
            <el-table-column label="修改时间" min-width="120" align="center" prop="modifyDate" :show-overflow-tooltip="true"/>
        </el-table>

        <pagination
        v-show="total>0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
        />
    </div>
</template>

<script>
import { listService } from "@/api/monitor/service";

export default {
    data() {
        return {
            //遮罩层
            loading: true,
            //服务数据表
            serviceList: [],
            //显示搜索条件
            showSearch: true,
            //总条数
            total: 0,
            //查询参数
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                taskName: undefined,
                baseId: undefined
            }
        }
    },
    updated() {},
    mounted() {

    },
    created() {
        this.getList()
    },
    methods: {
        //保留两位小数点
        rounding(row,column) {
            return parseFloat(row[column.property]).toFixed(2);
        },
        //获取数据列表
        getList(){
            this.loading = true;
            listService(this.queryParams).then(response => {
                // console.log(response,'response')
                this.serviceList = response.rows;
                this.total = response.total;
                this.loading = false;
            });
        },
        //查询
        handleQuery(){
            this.queryParams.pageNum = 1;
            this.getList();
        },
        //重置
        resetQuery(){
            this.resetForm("queryForm");
            this.handleQuery();
        }
    }
}
</script>

<style>

</style>