<!DOCTYPE html>
<html lang="zh">
<#include "/include/header.html">
<body>
<div class="lyear-layout-web">
    <div class="lyear-layout-container">
        <!--左侧导航-->
        <#include "/include/left.html">
        <!--End 左侧导航-->
        <!--头部信息-->
        <#include "/include/topbar.html">
        <!--End 头部信息-->
        <!--页面主要内容-->
        <main class="lyear-layout-content">

            <div class="container-fluid">

                <div class="row">
                    <div class="col-lg-12">
                        <div class="card">
                            <div class="panel" style="margin-bottom: auto">
                                <div class="panel-heading">
                                    <h3 class="panel-title">
                                        组合条件筛选
                                    </h3>
                                </div>
                                <!--组合条件组件-->
                                <#include "/include/table/table-query.html">
                            </div>
                            <div class="card-toolbar clearfix" style="padding: 0px 24px 0px 24px">
                                <div class="toolbar-btn-action" id="toolBar">
                                    <#include "/include/table/table-batch.html">
                                </div>
                            </div>
                            <!--快速搜索框-->
                            <div class="card-body" style="padding: 10px 15px">
                                <div class="pull-right" id="id_search_column"
                                     style="position: absolute;right: 295px;margin-top: 10px;">
                                    <input type="hidden" name="search_field" id="search-field" value="">
                                    <button class="btn btn-default dropdown-toggle" id="search-btn"
                                            data-toggle="dropdown" type="button" aria-haspopup="true"
                                            aria-expanded="false">
                                        全部 <span class="caret"></span>
                                    </button>
                                    <ul class="dropdown-menu" style="min-width: auto">
                                        <li><a tabindex="-1" href="javascript:void(0)" data-field="">全部</a></li>
                                        <#list pageTemplate.tableSearch as search>
                                            <li><a tabindex="-1" href="javascript:void(0)" data-field="${search.key!}">${search.name}</a></li>
                                        </#list>
                                    </ul>
                                </div>
                                <!--Bootstarp Table插入-->
                                <#include "/include/table/table-data.html">
                                <input type="file" class="selected-btn" id ="upload_file" name="file" onchange="" style="display: none" accept=".apk,.wgt">

                            </div>
                        </div>

                    </div>

                </div>
            </div>

        </main>
        <!--End 页面主要内容-->
    </div>
</div>
<div class="modal fade" id="appInfoModel" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="exampleModalLabel">版本信息</h4>
            </div>
            <div class="modal-body">
                <form id="id_update_from">
                    <input type="text" class="form-control" name="id" readonly="readonly" style="display: none">
                    <input type="text" class="form-control" name="logo" readonly="readonly" style="display: none">
                    <input type="text" class="form-control" name="clicks" readonly="readonly" style="display: none">
                    <div class="form-group">
                        <label class="control-label">APP名称：</label>
                        <input type="text" id class="form-control" name="name" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">更新识别KEY：</label>
                        <input type="text" id class="form-control" name="appKey" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">版本号：</label>
                        <input type="text" class="form-control" name="version" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">大版本号：</label>
                        <input type="text" class="form-control" name="versionCode" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">更新方式：</label>
                        <input type="text" class="form-control" name="type" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">更新平台：</label>
                        <input type="text" class="form-control" name="system" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">包地址：</label>
                        <input type="text" class="form-control" name="url" readonly="readonly">
                    </div>
                    <div class="form-group">
                        <label class="control-label">更新说明：</label>
                        <textarea class="form-control" name="text" rows="4" maxlength="200" placeholder="请在此填写更新说明...(最大200字)"></textarea>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" onclick="update()">确认更新</button>
            </div>
        </div>
    </div>
</div>
<#include "/include/footer.html">
<#include "/include/table/table-event.html">
<#include "/include/table/table-model.html">
<!--以下为业务流程处理-->
<script>
    /**
     * 上传更新包
     * @param key
     */
    let key;
    function uploadApp(a){
        key=a;
        $("#upload_file").trigger("click");
    };
    $("#upload_file").change(function (e){
        document.getElementById("js_load").style.display = "inline";
        let formData = new FormData();
        formData.append("file",$("#upload_file")[0].files[0]);
        formData.append("role",key);
        $.ajax({
            url:"${ctx}/admin/app/upload",
            type:"POST",
            data:formData,
            cache: false,
            processData: false,
            contentType: false,
            success:function (res){
                document.getElementById("js_load").style.display = "none"
                if(res.status!==200){
                    lightyear.notify(res.message, 'danger');
                    return;
                }
                console.log(res);
                $("#id_update_from").setForm(res.body);
                $("#appInfoModel").modal('show');
            }
        });
    });

    /**
     * 确认更新
     */
    function update(){
        sendAjax("${ctx}/admin/app/update","POST",$("#id_update_from").serializeFormToJson());
        $("#appInfoModel").modal('hide');
    }
</script>
</body>
</html>