<% include ./stage_sub_menu.ejs %>
<div class="panel-content">
    <div class="panel-title">
        <div class="title-main d-flex">
            <div>
                <div class="d-inline-block">
                    <div class="dropdown">
                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                            <i class="fa fa-list-ol"></i> 显示层级
                        </button>
                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
                            <a class="dropdown-item" name="showLevel" tag="1" href="javascirpt: void(0);">第一层</a>
                            <a class="dropdown-item" name="showLevel" tag="2" href="javascirpt: void(0);">第二层</a>
                            <a class="dropdown-item" name="showLevel" tag="3" href="javascirpt: void(0);">第三层</a>
                            <a class="dropdown-item" name="showLevel" tag="4" href="javascirpt: void(0);">第四层</a>
                            <a class="dropdown-item" name="showLevel" tag="5" href="javascirpt: void(0);">第五层</a>
                            <a class="dropdown-item" name="showLevel" tag="last" href="javascirpt: void(0);">最底层</a>
                            <a class="dropdown-item" name="showLevel" tag="leafXmj" href="javascirpt: void(0);">只显示项目节</a>
                            <a class="dropdown-item" name="showLevel" tag="curMeasure" href="javascirpt: void(0);">只显示本期计量</a>
                        </div>
                    </div>
                </div>
                <div class="d-inline-block">
                    <button href="#row-view" class="btn btn-sm btn-light" data-toggle="modal" data-target="#row-view"><i class="fa fa-table"></i> 列显示</button>
                </div>
                <div class="d-inline-block">
                    <div class="input-group input-group-sm mt-2">
                        <div class="input-group-prepend">
                            <span class="input-group-text" id="basic-addon1">表达式</span>
                        </div>
                        <input type="text" class="form-control m-0" <% if (stage.readOnly) { %> readonly="" <% } %>>
                    </div>
                </div>
            </div>
            <div class="ml-auto">
                <!--完成中间计量-->
                <% if (!ctx.stage.check_detail) { %>
                <span class="text-success" id="locked-hint">已完成，请继续完成「上报审批」 <a href="/tender/<%- ctx.tender.id %>/measure/stage/<%- ctx.stage.order %>/detail/unlock">解锁编辑</a></span>
                <% } %>
            </div>
        </div>
    </div>
    <div class="content-wrap pr-46">
        <div class="c-header p-0">
        </div>
        <div class="row w-100 sub-content">
            <div id="main-view" class="c-body" style="width: 100%">
                <!--上部分-->
                <div class="sjs-height-1" id="stage-ledger">
                </div>
                <!--下部分-->
                <div class="bcontent-wrap" id="main-bottom">
                    <div id="main-resize" class="resize-y" r-Type="height" div1="#stage-ledger" div2="#main-bottom" store-id="stage-main" store-version="1.0.0" min="100"></div>
                    <div class="bc-bar mb-1">
                        <ul class="nav nav-tabs">
                            <li class="nav-item">
                                <a class="nav-link active" href="#">部位明细</a>
                            </li>
                            <!--工程量清单模式操作-->
                            <% if (ctx.tender.data.measure_type === measureType.gcl) { %>
                            <li class="nav-item">
                                <div class="mt-1 ml-3">
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="插入"><i class="fa fa-sign-in" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="复制"><i class="fa fa-files-o" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="剪切"><i class="fa fa-scissors" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="粘贴"><i class="fa fa-clipboard" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="删除"><i class="fa fa-remove" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="下移"><i class="fa fa-arrow-down" aria-hidden="true"></i></a>
                                    <a href="" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="上移"><i class="fa fa-arrow-up" aria-hidden="true"></i></a>
                                </div>
                            </li>
                            <% } %>
                        </ul>
                    </div>
                    <div class="sp-wrap" id="stage-pos">
                    </div>
                </div>
            </div>
            <div id="tools-view" class="c-body" style="display: none; width: 33%;">
                <div class="resize-x" id="right-spr" r-Type="width" div1="#main-view" div2="#tools-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>
                <div class="tab-content">
                    <!--查找定位-->
                    <div id="search" class="tab-pane tab-select-show">
                        <div class="sjs-bar-1">
                            <div class="input-group input-group-sm">
                                <div class="input-group-prepend">
                                    <div class="input-group-text">
                                        <input type="radio" name="searchType" id="over"> 超计
                                    </div>
                                    <div class="input-group-text">
                                        <input type="radio" name="searchType" id="empty"> 漏计
                                    </div>
                                </div>
                                <input type="text" class="form-control" placeholder="可查找 项目节编号 / 清单编号 /名称" id="keyword">
                                <div class="input-group-append">
                                    <button class="btn btn-outline-secondary" type="button" id="searchLedger">搜索</button>
                                </div>
                            </div>
                        </div>
                        <div id="search-result" class="sjs-sh-1">
                        </div>
                    </div>
                    <!--附件-->
                    <div id="fujian" class="tab-pane tab-select-show">
                        <div class="sjs-bar">
                            <ul class="nav nav-tabs">
                                <li class="nav-item">
                                    <a class="nav-link active" data-toggle="tab" href="#dqjiedian" role="tab" fujian-content="dqjiedian">当前节点</a>
                                </li>
                                <li class="nav-item">
                                    <a class="nav-link" data-toggle="tab" href="#syfujian" role="tab" fujian-content="syfujian">所有附件</a>
                                </li>
                                <li class="nav-item ml-auto">
                                    <!--所有附件 翻页-->
                                    <span id="showPage" style="display: none"><a href="javascript:void(0);" class="page-select" content="pre"><i class="fa fa-chevron-left"></i></a> <span id="currentPage">1</span>/<span id="totalPage">10</span> <a href="javascript:void(0);" class="page-select" content="next"><i class="fa fa-chevron-right"></i></a></span>
                                    <a href="#upload" data-toggle="modal" data-target="#upload"  class="btn btn-sm btn-outline-primary ml-3">上传</a>
                                </li>
                            </ul>
                        </div>
                        <div class="tab-content">
                            <div class="tab-pane active" id="dqjiedian">
                                <div class="sjs-height-3" style="overflow:auto; overflow-x:hidden;">
                                    <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
                                        <tr><th>文件名</th><th width="80">上传</th></tr>
                                        <tbody id="nodelist-table" class="list-table">
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="tab-pane" id="syfujian">
                                <div class="sjs-height-3" style="overflow:auto; overflow-x:hidden;">
                                    <table class="table table-sm table-bordered table-hover" style="word-break:break-all; table-layout: fixed">
                                        <tr><th>文件名</th><th width="80">上传</th></tr>
                                        <tbody id="alllist-table" class="list-table">
                                        </tbody>
                                    </table>
                                </div>
                            </div>
                            <div class="sjs-bottom">
                                <br>
                                <div class="tab-content" id="showAttachment" style="display: none" file-id="">
                                    <div class="sjs-bottom-2">
                                        <div class="d-flex justify-content-end mb-1" id="btn-att">
                                            <!--默认 有删除权限-->
                                            <a href="javascript:void(0);" content="del" class="btn btn-sm text-danger" style="display: none">删除</a>
                                            <!--默认 有编辑权限-->
                                            <a href="javascript:void(0);" content="edit" class="btn btn-sm btn-outline-primary" style="display: none">编辑</a>
                                            <!--编辑模式-->
                                            <a href="javascript:void(0);" content="save" class="btn btn-sm btn-outline-success mr-1" style="display: none">保存</a>
                                            <a href="javascript:void(0);" content="cancel" class="btn btn-sm btn-outline-secondary" style="display: none">取消</a>
                                        </div>
                                        <!--显示信息-->
                                        <table class="table table-sm table-bordered" id="show-att" style="word-break:break-all; table-layout: fixed">
                                            <tbody>
                                            <tr><th>文件名</th><td colspan="3">asdasd.jpg</td></tr>
                                            <tr><th>所在节点</th><td colspan="3">1 第一部分 建筑安装工程非</td></tr>
                                            <tr><td colspan="4"><a href="javascript:void(0);">下载附件</a></td></tr>
                                            <tr><th>上传者</th><td>张三</td><th>上传时间</th><td>2018-10-20</td></tr>
                                            <tr><th>备注</th><td colspan="3"></td></tr>
                                            </tbody>
                                        </table>
                                        <div id="edit-att" style="display: none">
                                        <!--编辑模式-->
                                            <div class="form-group">
                                                <div class="input-group input-group-sm">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text">文件名</span>
                                                    </div>
                                                    <input type="text" class="form-control" value="asdasd">
                                                    <div class="input-group-append">
                                                        <span class="input-group-text">.jpg</span>
                                                    </div>
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="input-group input-group-sm">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text">所在节点</span>
                                                    </div>
                                                    <input type="text" class="form-control" value="1 第一部分 建筑安装工程非" readonly="">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="input-group input-group-sm">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text">上传时间</span>
                                                    </div>
                                                    <input type="text" class="form-control" value="2018-10-20" readonly="">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <div class="input-group input-group-sm">
                                                    <div class="input-group-prepend">
                                                        <span class="input-group-text">备注</span>
                                                    </div>
                                                    <input type="text" class="form-control" value="">
                                                </div>
                                            </div>
                                            <div class="form-group">
                                                <label>替换文件</label>
                                                <div class="custom-file">
                                                    <input type="file" class="custom-file-input" id="change-att-btn">
                                                    <label class="custom-file-label" for="customFile">Choose file</label>
                                                </div>
                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="side-menu">
            <!--右侧菜单-->
            <ul class="nav flex-column right-nav">
                <li class="nav-item">
                    <a class="nav-link" content="#search" href="javascript: void(0);">查找定位</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" content="#fujian" href="javascript: void(0);">附件</a>
                </li>
            </ul>
        </div>
    </div>
    <div style="display: none">
        <img src="/public/images/ellipsis_horizontal.png" id="ellipsis-icon" />
        <img src="/public/images/icon-ok.png" id="icon-ok" />
    </div>
</div>
<script>
    String.prototype.replaceAll = function (FindText, RepText) {
        regExp = new RegExp(FindText, 'g');
        return this.replace(regExp, RepText);
    }
    const readOnly = <%- stage.readOnly %>;
    const ledgerSpreadSetting = JSON.parse('<%- JSON.stringify(ledgerSpread) %>');
    const posSpreadSetting = JSON.parse('<%- JSON.stringify(posSpread) %>');
    const tender = JSON.parse('<%- JSON.stringify(tender) %>');
    const tenderInfo = JSON.parse('<%- JSON.stringify(ctx.tender.info) %>');
    const measureType = JSON.parse('<%- JSON.stringify(measureType) %>');
    const stage = JSON.parse('<%- JSON.stringify(ctx.stage) %>');
    const ledgerData = JSON.parse('<%- JSON.stringify(ledgerData) %>');
    const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
    let attData = JSON.parse('<%- JSON.stringify(attData) %>');
    const userID = '<%- ctx.session.sessionUser.accountId %>';
</script>
<% if (ctx.stage.status === auditConst.status.uncheck && ctx.session.sessionUser.accountId === ctx.stage.user_id) {%>
<script>
    const accountList = JSON.parse('<%- JSON.stringify(accountList) %>');
</script>
<% } %>
