<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>设备授权管理</title>
    <link rel="stylesheet" href="/static/layui/css/layui.css">
    <link rel="stylesheet" href="/static/css/style.css">
</head>
<body>
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-header">
                <span>设备授权管理</span>
            </div>
            <div class="layui-card-body">
                <!-- 搜索表单 -->
                <form class="layui-form layui-form-pane" action="">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">设备UID</label>
                            <div class="layui-input-inline">
                                <input type="text" name="uid" autocomplete="off" class="layui-input">
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">设备型号</label>
                            <div class="layui-input-inline">
                                <select name="device_model" lay-search>
                                    <option value="">全部</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">授权状态</label>
                            <div class="layui-input-inline">
                                <select name="status">
                                    <option value="">全部</option>
                                    <option value="active">正常</option>
                                    <option value="expired">已过期</option>
                                    <option value="inactive">未激活</option>
                                </select>
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn" lay-submit lay-filter="search">
                                <i class="layui-icon">&#xe615;</i> 搜索
                            </button>
                            <button type="button" class="layui-btn layui-btn-primary" id="export-devices">
                                <i class="layui-icon">&#xe67d;</i> 导出
                            </button>
                        </div>
                    </div>
                </form>

                <!-- 数据表格 -->
                <table id="device-table" lay-filter="device-table"></table>
            </div>
        </div>
    </div>

    <!-- 表格工具栏模板 -->
    <script type="text/html" id="tableToolbar">
        <div class="layui-btn-container">
            <button class="layui-btn layui-btn-sm" lay-event="refresh">
                <i class="layui-icon">&#xe669;</i> 刷新
            </button>
        </div>
    </script>

    <!-- 行工具栏模板 -->
    <script type="text/html" id="tableRowBar">
        <a class="layui-btn layui-btn-xs" lay-event="view">查看</a>
        <a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="bind">绑定授权</a>
        <a class="layui-btn layui-btn-xs layui-btn-warm" lay-event="logs">日志</a>
        {{# if(d.status !== 'expired'){ }}
        <a class="layui-btn layui-btn-xs layui-btn-danger" lay-event="revoke">撤销</a>
        {{# } }}
    </script>

    <!-- 设备详情模板 -->
    <script type="text/html" id="deviceDetailTpl">
        <div style="padding: 20px;">
            <table class="layui-table" lay-skin="line">
                <colgroup>
                    <col width="150">
                    <col>
                </colgroup>
                <tbody>
                    <tr>
                        <td>设备UID</td>
                        <td>{{ d.uid }}</td>
                    </tr>
                    <tr>
                        <td>设备型号</td>
                        <td>{{ d.device_model }}</td>
                    </tr>
                    <tr>
                        <td>授权码</td>
                        <td>{{ d.license_code || '-' }}</td>
                    </tr>
                    <tr>
                        <td>授权类型</td>
                        <td>{{ d.license_type || '-' }}</td>
                    </tr>
                    <tr>
                        <td>过期时间</td>
                        <td>{{ d.expire_time ? new Date(d.expire_time).toLocaleString() : '-' }}</td>
                    </tr>
                    <tr>
                        <td>启动次数</td>
                        <td>{{ d.start_count }}</td>
                    </tr>
                    <tr>
                        <td>最后活跃</td>
                        <td>{{ d.last_active_at ? new Date(d.last_active_at).toLocaleString() : '-' }}</td>
                    </tr>
                    <tr>
                        <td>注册时间</td>
                        <td>{{ new Date(d.register_time).toLocaleString() }}</td>
                    </tr>
                </tbody>
            </table>
        </div>
    </script>

    <script src="/static/layui/layui.js"></script>
    <script src="/static/js/device-license.js"></script>
</body>
</html> 