<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>定额库编辑器</title>
    <link rel="stylesheet" href="/lib/bootstrap/css/bootstrap.min.css">
    <!-- <link rel="stylesheet" href="css/bootstrap/themes.css">-->
    <link rel="stylesheet" href="/web/maintain/ration_repository/css/main.css">
    <link rel="stylesheet" href="/lib/font-awesome/font-awesome.min.css">
    <!--zTree-->
    <link rel="stylesheet" href="/lib/ztree/css/zTreeStyle.css" type="text/css">
</head>

<body>
<div class="header">
    <nav class="navbar navbar-toggleable-lg navbar-light bg-faded p-0 ">
        <span class="header-logo px-2">Smartcost</span>
        <div class="navbar-text"></div>
    </nav>
    <nav class="navbar navbar-toggleable-lg justify-content-between navbar-light p-0">
        <ul class="nav navbar-nav px-1">
            <li class="nav-item">
                <a class="nav-link" href="javacript:void(0);" aria-haspopup="true" aria-expanded="false" data-toggle="modal" data-target="#add">新建定额库</a>
            </li>
        </ul>
    </nav>
</div>
<div class="main">
    <div class="content">
        <div id="exportSpread" style="display: none"></div>
        <div class="container-fluid">
            <div class="row">
                <div class="col-md-2">
                    <div class="list-group mt-3">
                        <% for (let compilation of compilationList) { %>
                        <% if (compilation._id === 'all') { %>
                        <a href="/rationRepository/main" class="list-group-item list-group-item-action <%= compilation.active %>">
                            所有
                        </a>
                        <% } else { %>
                        <a id="<%= compilation._id %>" href="/rationRepository/main/?filter=<%= compilation._id %>" class="list-group-item list-group-item-action <%= compilation.active %>">
                            <%= compilation.name %>
                        </a>
                        <% }} %>
                    </div>
                </div>
                <div class="col-md-8">
                    <div class="warp-p2 mt-3">
                        <table class="table table-hover table-bordered">
                            <thead>
                                <tr>
                                    <th>定额库名称</th>
                                    <th width="160">费用定额</th>
                                    <th width="160">添加时间</th>
                                    <th width="90">操作</th>
                                    <th width="90">原始数据</th>
                                    <th width="150">内部数据</th>
                                    <th width="90">补充模板</th>
                                </tr>
                            </thead>
                            <tbody id="showArea">
                            <% for(let lib of rationLibs){ %>
                            <tr id="<%= lib.ID %>">
                                <td><a href="/rationRepository/ration?repository=<%= lib.ID%>&locked=true"><%= lib.dispName%></a></td>
                                <td><%= lib.compilationName%></td>
                                <td><%= moment(lib.createDate).format('YYYY-MM-DD')%></td>
                                <td>
                                    <a class="lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-target="#edit" title="编辑"><i class="fa fa-pencil-square-o"></i></a>
                                    <a class="text-danger lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-target="#del" title="删除"><i class="fa fa-remove"></i></a>
                                    <a class="lock-btn-control disabled" data-toggle="modal" data-target="#reCalcAll" href="javascript:void(0);" title="全部计算"><i class="fa fa-calculator"></i></a>
                                    <a class="lock" data-locked="true" href="javascript:void(0);" title="解锁"><i class="fa fa-unlock-alt"></i></a>
                                </td>
                                <td>
                                    <a class="btn btn-secondary btn-sm import-source lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入原始数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                                </td>
                                <td>
                                    <a class="btn btn-success btn-sm export lock-btn-control disabled" href="javacript:void(0);" data-toggle="modal" data-id="<%= lib.ID %>" data-target="#emport" title="导出内部数据"><i class="fa fa-sign-out fa-rotate-270"></i>导出</a>
                                    <a class="btn btn-secondary btn-sm import-data lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="导入内部数据"><i class="fa fa-sign-in fa-rotate-90"></i>导入</a>
                                </td>
                                <td>
                                    <a class="btn btn-secondary btn-sm set-comple lock-btn-control disabled" href="javacript:void(0);" data-id="<%= lib.ID %>" title="将章节树设为补充模板数据"><i class="fa fa-sign-in fa-rotate-90"></i>设置</a>
                                </td>
                            </tr>
                            <% } %>
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<!--弹出添加-->
<!--<div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
              <h5 class="modal-title">添加定额库</h5>
              <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                <span aria-hidden="true">×</span>
              </button>
            </div>
            <div class="modal-body">
              <form>
                <div class="form-group">
                  <label>定额库名称</label>
                  <input class="form-control" id="addInput" placeholder="输入定额库名称" type="text">
                </div>
              </form>
            </div>
            <div class="modal-footer">
                <button type="button" id="rationAdd" class="btn btn-secondary" data-dismiss="modal">新建</button>
                <a href="" id="addCancel" class="btn btn-primary">取消</a>
            </div>
        </div>
    </div>
</div>-->
<div class="modal fade" id="add" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">添加定额库</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label>定额库名称</label>
                        <input id="libNameTxt" class="form-control" placeholder="输入定额库名称" type="text">
                    </div>
                    <div class="form-group">
                        <label>费用定额名称</label>
                        <select id="compilationSels" class="form-control"></select>
                    </div>
                    <div class="form-group">
                        <label>人材机库</label>
                        <select id="gljLibSels" class="form-control"></select>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a id="addBtn" href="javascript: void(0);" class="btn btn-primary">确定</a>
                <button type="button" id="cancelBtn" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--弹出编辑-->
<div class="modal fade" id="edit" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">编辑定额库</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <form>
                    <div class="form-group">
                        <label>定额库名称</label>
                        <input class="form-control" id="renameText" placeholder="输入定额库名称" type="text" value="">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <!--<button type="button" id="edtCancel" class="btn btn-secondary" data-dismiss="modal">取消</button>
                <button type="button"  id="edtOK" class="btn btn-secondary" data-dismiss="modal">确定</button>-->
                <a href="javascript: void(0);"  id="renameA" class="btn btn-primary">确定</a>
                <button id="editCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>

            </div>
        </div>
    </div>
</div>
<!--弹出删除-->
<div class="modal fade" id="del" data-backdrop="static" style="display: none;" aria-hidden="true">
    <!--<input type="hidden" id="did" value="123">-->
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">删除确认</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <h5 class="text-danger">删除后无法恢复，确认是否删除？</h5>
            </div>
            <div class="modal-footer">
                <a id="deleteA" href="javascript: void(0);" class="btn btn-danger">确认</a>
                <button id="delCancelBtn" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--全部计算-->
<div class="modal fade" id="reCalcAll" data-backdrop="static" style="display: none;" aria-hidden="true">
    <!--<input type="hidden" id="did" value="123">-->
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">全部计算</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <h5>确认重算所有定额数据？</h5>
            </div>
            <div class="modal-footer">
                <a id="reCalcConfirm" href="javascript: void(0);" class="btn btn-primary">确认</a>
                <button id="reCalcCancel" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--弹出导入原始数据-->
<div class="modal fade" id="import" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">导入原始数据</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="alert alert-warning" role="alert">
                    导入操作会覆盖数据，请谨慎操作！！
                </div>
                <form>
                    <div class="form-group">
                        <label>请选择Excel格式文件</label>
                        <input class="form-control-file" type="file" name="source_file" accept=".xlsx,.xls">
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="source-import">确定导入</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>

<!--弹出导入内部数据-->
<div class="modal fade" id="import2" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">导入内部数据</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <div class="alert alert-warning" role="alert">
                    导入操作会覆盖数据，请谨慎操作！！
                </div>
                <form>
                    <div class="form-group">
                        <label>请选择Excel格式文件</label>
                        <input class="form-control-file" type="file" accept=".xlsx,.xls" name="import_data"/>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-primary" id="data-import">确定导入</button>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--转换Excel-->
<div class="modal fade" id="transfer" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">转换Excel</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <!--<div class="alert alert-warning" role="alert">
                    导入操作会覆盖数据，请谨慎操作！！
                </div>-->
                <form>
                    <div class="form-group">
                        <label>请选择Excel格式文件</label>
                        <input id="transfer-file" class="form-control-file" type="file" accept=".xlsx,.xls"/>
                    </div>
                </form>
            </div>
            <div class="modal-footer">
                <a href="javascript:void(0);" class="btn btn-primary" id="transferConfirm">确定转换</a>
                <button type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!--弹出设置模板-->
<div class="modal fade" id="template" data-backdrop="static" style="display: none;" aria-hidden="true">
    <div class="modal-dialog" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">设置确认</h5>
                <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                    <span aria-hidden="true">×</span>
                </button>
            </div>
            <div class="modal-body">
                <h5 id="templateText">确认是否将此库的章节树设置成该费用定额下补充定额章节树模板？</h5>
                <div class="form-group">
                    <label>费用定额名称</label>
                    <select id="compilations" class="form-control"></select>
                </div>
            </div>
            <div class="modal-footer">
                <a id="templateA" href="javascript: void(0);" class="btn btn-primary">确认</a>
                <button id="templateCancel" type="button" class="btn btn-secondary" data-dismiss="modal">取消</button>
            </div>
        </div>
    </div>
</div>
<!-- JS. -->
<script type="text/javascript">
    let allNames = '<%= allNames %>'.split(',');
    let userAccount = '<%=userAccount %>';
</script>
<script src="/lib/jquery/jquery.min.js"></script>
<script src="/lib/tether/tether.min.js"></script>
<script src="/lib/bootstrap/bootstrap.min.js"></script>
<script src="/public/web/PerfectLoad.js"></script>
<script src="/web/maintain/ration_repository/js/global.js"></script>
<script src="/public/web/common_ajax.js"></script>
<script src="/public/web/lock_util.js"></script>
<script src="/lib/spreadjs/sheets/gc.spread.sheets.all.11.1.2.min.js"></script>
<script src="/lib/spreadjs/sheets/interop/gc.spread.excelio.11.1.2.min.js"></script>
<script>GC.Spread.Sheets.LicenseKey =  '<%- LicenseKey %>';</script>
<script src="/lib/fileSaver/FileSaver.min.js"></script>
<!-- zTree -->
<script type="text/javascript" src="/public/web/date_util.js"></script>
<script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
<script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
<script type="text/javascript" src="/web/maintain/ration_repository/js/main.js"></script>
<script type="text/javascript" src="/public/web/storageUtil.js"></script>
</body>

</html>