<%include ./common.html %>
<div class="panel-content">
    <% if(Object.keys(selectedCompilation).length > 0) {%>
    <div class="panel-title">
        <div class="title-main">
            <h2>
                <%= selectedCompilation.name %>
                <% if(selectedCompilation.is_release) {%>
                <span class="text-muted" style="margin-left: 5px;">已发布 <%= moment(selectedCompilation.update_time).format('YYYY-MM-DD')%></span>
                <% } %>
                <a href="javascript:void(0);" data-id="<%= selectedCompilation._id %>" data-status="<%= selectedCompilation.is_release ? 0 : 1 %>" class="btn btn-primary btn-sm pull-right" id="release"><% if(selectedCompilation.is_release) {%>取消<% }else{ %>发布<% } %>编办</a>
            </h2>
        </div>
    </div>
    <!--养护中计价方式为项目类别-->
    <div class="content-wrap">
        <div class="c-header" style="padding:0">
            <ul class="nav nav-tabs">
                <li role="presentation" class="active"><a href="#bill" aria-controls="bill" role="tab" data-toggle="tab">预算</a></li>
                <li role="presentation"><a href="#ration" aria-controls="ration" role="tab" data-toggle="tab">工程量清单</a></li>
            </ul>
        </div>
        <div class="c-body tab-content">
            <div class="tab-pane active" role="tabpanel" id="bill">
                <a class="btn btn-default btn-sm" href="#" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
                <table class="table">
                    <thead>
                    <tr>
                        <th>计价规则</th>
                        <th>启用/禁用</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <% if (selectedCompilation.bill_valuation.length > 0) { %>
                    <% selectedCompilation.bill_valuation.forEach(function(bill) { %>
                    <tr>
                        <td><%= bill.name %></td>
                        <td>
                            <% if (bill.enable) { %>
                            <div class="btn-group enable" data-id="<%= bill.id %>">
                                <button class="btn btn-success  disabled" disabled="disabled">已开启</button>
                                <button class="btn btn-default" title="禁用">禁用</button>
                            </div>
                            <% }else { %>
                            <div class="btn-group enable" data-id="<%= bill.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/bill/<%= bill.id %>" class="btn btn-sm">编辑</a>
                            <a onclick="$('#del').attr('selectedId', '<%= bill.id %>')" href="#" data-id="<%= bill.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
                            <!--<a href="/compilation/valuation/bill/delete/<%= bill.id %>" class="btn btn-sm text-danger">删除</a>-->
                        </td>
                    </tr>
                    <% }) %>
                    <% } %>
                    </tbody>
                </table>
            </div>
            <div class="tab-pane" role="tabpanel" id="ration">
                <a class="btn btn-default btn-sm" href="javascript:void(0)" data-toggle="modal" data-target="#valuation-dialog"><span class="glyphicon glyphicon-plus"></span> 添加计价规则</a>
                <table class="table">
                    <thead>
                    <tr>
                        <th>计价规则</th>
                        <th>启用/禁用</th>
                        <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <% if (selectedCompilation.ration_valuation.length > 0) { %>
                    <% selectedCompilation.ration_valuation.forEach(function(ration) { %>
                    <tr>
                        <td><%= ration.name %></td>
                        <td>
                            <% if (ration.enable) { %>
                            <div class="btn-group enable" data-id="<%= ration.id %>">
                                <button class="btn btn-success  disabled" disabled="disabled">已开启</button>
                                <button class="btn btn-default" title="禁用">禁用</button>
                            </div>
                            <% }else { %>
                            <div class="btn-group enable" data-id="<%= ration.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/ration/<%= ration.id %>" class="btn btn-sm">编辑</a>
                            <a href="/compilation/valuation/ration/delete/<%= ration.id %>" class="btn btn-sm text-danger">删除</a>
                        </td>
                    </tr>
                    <% }) %>
                    <% } %>
                    </tbody>
                </table>
            </div>
            <table class="table">
                <tr><td><p>软件版本介绍</p><textarea id="description" class="form-control" placeholder="请简要描述改版本"><%= selectedCompilation.description%></textarea></td></tr>
                <tr><td><span>重写路径:</span><input class="form-control" type="text" id="overWriteUrl" value="<%= selectedCompilation.overWriteUrl%>"></td></tr>
                <tr><td><span>例题建设项目ID:</span><input class="form-control" type="text" id="example" value="<%= selectedCompilation.example%>"></td></tr>
                <tr><td><p>显示办事处销售信息</p>
                    <select class="form-control" style="width:200px" id="category-select">
                        <% categoryList.forEach(function(category) { %>
                        <option value="<%= category.id %>" <% if (selectedCompilation.categoryID !== undefined && category.id === selectedCompilation.categoryID) { %>selected="selected"<% } %> ><%= category.name %></option>
                        <% }) %>
                    </select>
                </td></tr>
            </table>
        </div>
        <input type="hidden" name="id" value="<%= selectedCompilation._id %>" id="compilation-id">
        <% } %>
	</div>
</div>
<script type="text/javascript" src="/web/users/js/compilation.js"></script>
<%include ../compilation/modal.html %>