<%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.release_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">
                <% if(selectedCompilation.name.includes('公路造价')) { %>
                <li role="presentation" class="active"><a href="#suggestion" aria-controls="suggestion" role="tab" data-toggle="tab">建议估算</a></li>
                <li role="presentation"><a href="#feasibility" aria-controls="feasibility" role="tab" data-toggle="tab">可行性估算</a></li>
                <li role="presentation"><a href="#rough" aria-controls="rough" role="tab" data-toggle="tab">概算</a></li>
                <% } %>
                <li role="presentation" class=<%= selectedCompilation.name.includes('公路造价') ? '' : 'active' %>><a href="#bill" aria-controls="bill" role="tab" data-toggle="tab">
                    <% if(title === '公路2.0') { %>    
                    清单计价
                    <% } else { %>
                        预算
                    <% } %>
                </a></li>
                <li role="presentation"><a href="#ration" aria-controls="ration" role="tab" data-toggle="tab">工程量清单</a></li>
                <li role="presentation"><a href="#estimation" aria-controls="estimation" role="tab" data-toggle="tab">估算</a></li>
                
            </ul>
        </div>
        <div class="c-body tab-content">
            <% if(selectedCompilation.name.includes('公路造价')) { %>
            <div class="tab-pane active" role="tabpanel" id="suggestion">
                <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.suggestion_valuation && selectedCompilation.suggestion_valuation.length > 0) { %>
                    <% selectedCompilation.suggestion_valuation.forEach(function(suggestion) { %>
                    <tr>
                        <td><%= suggestion.name %></td>
                        <td>
                            <% if (suggestion.enable) { %>
                            <div class="btn-group enable" data-id="<%= suggestion.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="<%= suggestion.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/suggestion/<%= suggestion.id %>" class="btn btn-sm">编辑</a>
                            <a onclick="$('#del').attr('selectedId', '<%= suggestion.id %>')" href="#" data-id="<%= suggestion.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
                        </td>
                    </tr>
                    <% }) %>
                    <% } %>
                    </tbody>
                </table>
            </div>
            <div class="tab-pane" role="tabpanel" id="feasibility">
                <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.feasibility_valuation && selectedCompilation.feasibility_valuation.length > 0) { %>
                    <% selectedCompilation.feasibility_valuation.forEach(function(feasibility) { %>
                    <tr>
                        <td><%= feasibility.name %></td>
                        <td>
                            <% if (feasibility.enable) { %>
                            <div class="btn-group enable" data-id="<%= feasibility.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="<%= feasibility.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/feasibility/<%= feasibility.id %>" class="btn btn-sm">编辑</a>
                            <a onclick="$('#del').attr('selectedId', '<%= feasibility.id %>')" href="#" data-id="<%= feasibility.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
                        </td>
                    </tr>
                    <% }) %>
                    <% } %>
                    </tbody>
                </table>
            </div>
            <div class="tab-pane" role="tabpanel" id="rough">
                <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.rough_valuation && selectedCompilation.rough_valuation.length > 0) { %>
                    <% selectedCompilation.rough_valuation.forEach(function(rough) { %>
                    <tr>
                        <td><%= rough.name %></td>
                        <td>
                            <% if (rough.enable) { %>
                            <div class="btn-group enable" data-id="<%= rough.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="<%= rough.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/rough/<%= rough.id %>" class="btn btn-sm">编辑</a>
                            <a onclick="$('#del').attr('selectedId', '<%= rough.id %>')" href="#" data-id="<%= rough.id %>" data-toggle="modal" data-target="#del" class="btn btn-sm text-danger">删除</a>
                        </td>
                    </tr>
                    <% }) %>
                    <% } %>
                    </tbody>
                </table>
            </div>
            <% } %>

            <div class="<%= selectedCompilation.name.includes('公路造价') ? 'tab-pane' : '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>
                        <% if(title === '公路2.0') { %>
                            <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>
                        <% if(title === '公路2.0') { %>
                        <td>
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_suggest_gusuan" <% if (bill.fileTypes && bill.fileTypes.includes(16)) { %> checked <% } %> /> 建议估算  
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_gusuan" <% if (bill.fileTypes && bill.fileTypes.includes(15)) { %> checked <% } %> /> 可行性估算  
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_estimate"  <% if (bill.fileTypes && bill.fileTypes.includes(5)) { %> checked <% } %>  /> 概算    
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_submission" <% if (bill.fileTypes && bill.fileTypes.includes(1)) { %> checked <% } %>  /> 预算      
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_three_bill_budget" <% if (bill.fileTypes && bill.fileTypes.includes(18)) { %> checked <% } %>  /> 三级清单预算   
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_bill_budget" <% if (bill.fileTypes && bill.fileTypes.includes(19)) { %> checked <% } %>  /> 清单预算
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_changeBudget" <% if (bill.fileTypes && bill.fileTypes.includes(4)) { %> checked <% } %>  /> 变更预算
                             <input type="checkbox" data-id="<%= bill.id %>" class="fileType" id="<%= bill.id %>_settlement" <% if (bill.fileTypes && bill.fileTypes.includes(10)) { %> checked <% } %>  /> 结算
                         </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>
            <div class="tab-pane" role="tabpanel" id="estimation">
                <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.estimation_valuation && selectedCompilation.estimation_valuation.length > 0) { %>
                    <% selectedCompilation.estimation_valuation.forEach(function(estimation) { %>
                    <tr>
                        <td><%= estimation.name %></td>
                        <td>
                            <% if (estimation.enable) { %>
                            <div class="btn-group enable" data-id="<%= estimation.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="<%= estimation.id %>">
                                <button class="btn btn-default" title="开启">开启</button>
                                <button class="btn btn-danger disabled" disabled="disabled">已禁用</button>
                            </div>
                            <% } %>
                        </td>
                        <td>
                            <a href="/compilation/valuation/estimation/<%= estimation.id %>" class="btn btn-sm">编辑</a>
                            <a href="/compilation/valuation/estimation/delete/<%= estimation.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>
                <tr><td><p>默认工程所在地</p>
                    <select class="form-control" style="width:200px" id="location-select">
                        <option value=""></option>
                        <% locationList.forEach(function(location) { %>
                            <option value="<%= location %>" <% if (selectedCompilation.defaultLocation !== undefined && location === selectedCompilation.defaultLocation) { %>selected="selected"<% } %> ><%= location %></option>
                            <% }) %>
                    </select>
                </td></tr>
                <tr><td><p>编办类型</p>
                    <select class="form-control" style="width:200px" id="type-select">
                        <option value=""></option>
                        <% typeList.forEach(function(type) { %>
                            <option value="<%= type.value %>" <% if (selectedCompilation.type !== undefined && type.value === selectedCompilation.type) { %>selected="selected"<% } %> ><%= type.label %></option>
                            <% }) %>
                    </select>
                </td></tr>
                <tr>
                    <td>
                        <p>
                            <span> 提供免费版:</span> <input type="checkbox" id="freeUse"  <% if (selectedCompilation.freeUse) { %> checked <% } %>>
                            <span style="margin-left: 60px;"> 定制编办:</span> <input type="checkbox" id="customMade"  <% if (selectedCompilation.customMade) { %> checked <% } %>>
                        </p>       
                    </td>
                </tr>
                <tr><td><span>版本号：</span><input class="form-control" type="text" id="edition" value="<%= selectedCompilation.edition%>"></td></tr>
                <tr>
                    <td><span>序号：</span><input class="form-control" type="number" id="serialNumber"
                            value="<%= selectedCompilation.serialNumber%>">
                    </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 %>