<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport"
          content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no"/>
    <title>终端升级日志详情</title>
    <link rel="stylesheet" href="${ctx}/css/plugin/bootstrap/bootstrap.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatimepicker/bootstrap-datetimepicker.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/fontawesome/font-awesome.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/buttons.dataTables.min.css">
    <link rel="stylesheet" href="${ctx}/css/plugin/datatables/datatables.bootstrap.css">
    <link rel="stylesheet" href="${ctx}/css/basic.css">
    <style>
        .form-control {
            height: 22px;
            padding: 1px 5px;
        }

        #deviceTable {
            min-width: 100%;
        }

        .btn {
            padding: 2px 10px;
            font-size: 12px;
        }

        .tr {
            text-align: center;
        }

        .td {
            text-align: center;
            height: 48px;
            line-height: 48px
        }

        .table > tbody > tr > td {
            padding: 5px;
            line-height: 1.42857143;
            vertical-align: middle;
            border-top: 1px solid #ddd;
        }
    </style>
</head>
<body class="container-fluid">
<div class="row">
    <%--页面表格--%>
    <div class="col-md-12 col-lg-12 col-sm-12">
        <div class="width100">
            <table id="deviceTable" class="table table-striped table-bordered dataTable no-footer width100">
                <thead>
                <tr>
                    <th>序号</th>
                    <th>目标版本</th>
                    <th>升级结果</th>
                    <th>升级时间</th>
                    <th>升级人员</th>
                </tr>
                </thead>
            </table>
        </div>
    </div>
</div>

<input type="hidden" id="username" value="${username}">
<script src="${ctx}/js/plugin/jquery/jquery.min.js"></script>
<script src="${ctx}/js/plugin/layui/layer.js"></script>
<script src="${ctx}/js/plugin/bootstrap/bootstrap.min.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.jquery.js"></script>
<script src="${ctx}/js/plugin/datatables/dataTables.buttons.min.js"></script>
<script src="${ctx}/js/plugin/datatables/datatables.bootstrap.js"></script>
<script src="${ctx}/js/plugin/datatables/buttons.html5.min.js"></script>
<script src="${ctx}/jspJS/utils/loading.js"></script>
<script src="${ctx}/jspJS/utils/judgeAjaxStatus.js"></script>
<script src="${ctx}/js/plugin/xss/aes.js"></script>
<script src="${ctx}/jspJS/sm2.js"></script>
<script src="${ctx}/jspJS/sm3.js"></script>
<script src="${ctx}/jspJS/confirmIndentity.js"></script>
<script src="${ctx}/jspJS/utils/common.js"></script>
<script>
    var dataTable;
    var devIndex = getQueryString('devIndex')
    $(function () {
        //初始化设备
        refresh()
    })

    /**
     * 初始化获取后台数据
     */
    function refresh() {
        /*获取各项条件 */
        var indexi;
        $.ajax({
            type: "get",
            url: "/pqs9900/version/getUpdetail",
            dataType: "json",
            data: {
                devIndex: devIndex
            },
            beforeSend: function () {
                indexi = ityzl_SHOW_LOAD_LAYER();
            },
            success: function (data) {
                if (data.code === 200) {
                    //初始化表格
                    initTransactionTable(data.body);
                } else {
                    layer.msg(data.message, {icon: 2, time: 2000})
                    initTransactionTable(null);
                }
                ityzl_CLOSE_LOAD_LAYER(indexi);
            }
        })
    }

    //初始化表格数据
    function initTransactionTable(tableData) {
        dataTable = $('#deviceTable').DataTable({
            order: [3, 'desc'],
            columns: [
                { width: "4%", targets: 1, render: function (data, type, row, meta) {
                        return meta.row+1
                    }
                },
                {width: "7%", data: "edName"},
                {
                    width: "12%", data: "updateresult", render: function (data) {
                        return getWarnInfo(data)
                    }
                },
                {
                    width: "12%", data: "updateTime", render: function (data) {
                        return formatTime(data, 1)
                    }
                },
                {width: "7%", data: "updateUser"},
            ],
            paging: false,
            info: false,
            destroy: true,
            data: tableData,
            lengthChange: true,
            searching: true,
            dom: 'rtip',
            scrollY: true,
            scrollX: true,
            language: {
                url: '/pqs9900/json/chine.json'
            },
        });
    }

    //获取启用状态
    function getWarnInfo(data) {
        var da = Number(data);
        if (da == 1) {
            info = '<font style="color:#20B2AA">升级成功</font>'
        } else {
            info = '<font style="color:#A52a2a">升级失败</font>'
        }
        return info;
    }
</script>
</body>
</html>
