<%include ./common.html %>
<div class="panel-content">
    <div class="panel-title">
        <div class="title-main">
            <h2>
                <span><%= selectedCompilation.name%></span>
                <a href="javascript:void(0);" id="save-valuation" class="btn btn-primary btn-sm pull-right">保存</a>
                <a href="/compilation" class="btn btn-default btn-sm pull-right">返回</a>
            </h2>
        </div>
    </div>
    <div class="content-wrap">
        <div class="c-header" style="padding:0">
            <ul class="nav nav-tabs">
                <% valuationList.forEach(function(valuation) { %>
                <li role="presentation" <% if (valuation.id.toString() === valuationId) { %>class="active"<% } %>><a href="/compilation/valuation/<%= section %>/<%= valuation.id %>"><%= valuation.name %></a></li>
                <% }) %>
            </ul>
        </div>
        <div class="c-body">
            <form id="saveValuation" action="/compilation/save-valuation" method="post" enctype="application/x-www-form-urlencoded">
                <div class=" row">
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>名称</label>
                            <input type="text" class="form-control" name="valuationName" value="<%= valuationData.name %>">
                        </div>
                    </div>
                    <div class="col-md-12">
                        <legend style="margin-bottom: 0px;">
                            工程专业
                        </legend>
                        <a class="btn btn-link btn-sm"  data-toggle="modal" data-target="#addEngineer">添加</a>
                        <table class="table engineer_table">
                            <thead>
                            <tr>
                                <th>工程专业</th>
                                <th>费用标准</th>
                                <th>定额取费专业</th>
                                <th>单位工程取费专业</th>
                                <th>标准清单</th>
                                <th>定额库</th>
                                <th>人材机库</th>
                                <th>前台显示</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                                <% engineeringList.forEach(function(engineering) {%>
                                <tr >
                                    <td>
                                        <div><span><%= engineering.name %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                            <input class="form-control" name="name">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
                                                    <span class="glyphicon glyphicon-ok"></span></button>
                                            </div>
                                        </div>
                                    </td>
                                    <td>
                                        <div><span><%= engineering.feeName %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                            <input class="form-control" name="feeName">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
                                                    <span class="glyphicon glyphicon-ok"></span></button>
                                            </div>
                                        </div></td>
                                    <td>
                                        <div><span><%= engineering.engineering %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                            <input onkeypress="intChecking(event,this)" class="form-control engineeringInput" type="number" name="engineering">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
                                                    <span class="glyphicon glyphicon-ok"></span></button>
                                            </div>
                                        </div>
                                    </td>
                                    <td><div><span><%= engineering.projectEngineering %></span> <a onclick='editEngineer(this)'><i class="glyphicon glyphicon-pencil"></i></a></div>
                                        <div class="input-group input-group-sm input_group_div" style="width:200px;display: none">
                                            <input onkeypress="intChecking(event,this)" class="form-control engineeringInput" type="number" name="projectEngineering">
                                            <div class="input-group-btn">
                                                <button type="button" class="btn btn-success" onclick='confirmUpdate(this,"<%= engineering._id.toString()%>")'>
                                                    <span class="glyphicon glyphicon-ok"></span></button>
                                            </div>
                                        </div>
                                    </td>
                                    <td><%= engineering.bill_lib.length %></td>
                                    <td><%= engineering.ration_lib.length %></td>
                                    <td><%= engineering.glj_lib.length %></td>
                                    <td><label><input type="checkbox"  <% if (engineering.visible) { %>checked<% } %>  onclick='engineerVisibleChange(this,"<%= engineering._id.toString()%>")'> 显示</label></td>
                                    <td><a class="btn-link" href="/compilation/<%= section %>/<%= valuationId %>/<%= engineering._id.toString()%>">编辑</a>/<a onclick="deleteEngineerClick('<%= engineering._id.toString()%>',this)" class='btn btn-link btn-sm' style="padding: 0px">删除</a></td>
                                </tr>
                                <% }) %>
                            </tbody>
                        </table>
                    </div>
                </div>
                <input type="hidden" name="section" value="<%= section %>" id="section">
                <input type="hidden" name="id" value="<%= valuationId %>">
            </form>
        </div>
    </div>
</div>

<!--添加工程专业窗口-->
<div class="modal fade in" id="addEngineer"  role="dialog" tabindex="-1">
    <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">×</span></button>
                <h4 class="modal-title">添加新的工程专业</h4>
            </div>
            <div class="modal-body">
                <form id="addEngineerForm" method="post" action="/compilation/addEngineer" enctype="application/x-www-form-urlencoded21">
                    <div class="form-group">
                        <label>工程专业</label>
                        <input class="form-control" type="text" name ="name" id="name" placeholder="请输入工程专业名称">
                        <small class="form-text text-danger" id="nameError" style="display: none">请输入工程专业名称。</small>
                    </div>
                    <div class="form-group">
                        <label>费用标准</label>
                        <input class="form-control" type="text" name ="feeName" id="feeName" placeholder="请输入费用标准">
                        <small class="form-text text-danger" id="feeNameError" style="display: none">请输入费用标准。</small>
                    </div>
                    <div class="form-group">
                        <label>定额取费专业</label>
                        <input onkeypress="intChecking(event,this)" class="form-control engineeringInput" type="number"  name ="engineering" id="engineeringInput" placeholder="请输入定额取费专业">
                        <small class="form-text text-danger" id="engineeringError" style="display: none">请输入定额取费专业。</small>
                    </div>
                    <div class="form-group">
                        <label>单位工程取费专业</label>
                        <input onkeypress="intChecking(event,this)"  class="form-control engineeringInput" type="number" name ="projectEngineering" id="projectEngineering" placeholder="请输入单位工程取费专业">
                        <small class="form-text text-danger" id="projectError" style="display: none">请输入单位工程取费专业。</small>
                    </div>
                    <input type="hidden" name="valuationID" value="<%= valuationId %>">
                    <input type="hidden" name="compilationId" value="<%= selectedCompilation._id.toString() %>" >
                </form>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                <button type="button" class="btn btn-primary" id="addEngineerConfirm">确定添加</button>
            </div>
        </div>
    </div>
</div>
<script src="/public/web/commonAlert.js"></script>
<script type="text/javascript" src="/public/web/common_ajax.js"></script>
<script type="text/javascript" src="/web/users/js/compilation.js"></script>
<%include ../compilation/modal.html %>