<% include ../tender/tender_sub_menu.ejs %>
<div class="panel-content">
    <div class="panel-title">
        <div class="title-main d-flex justify-content-between">
            <div>
                <div class="d-inline-block">
                    <select class="form-control form-control-sm" id="status_select">
                        <option value="0">全部</option>
                        <% for (const fs in filter.status) { %>
                        <% const f = filter.status[fs]; %>
                        <option value="<%- f %>" <% if (f === status) { %>selected="selected"<% } %>><%- filter.statusString[f] %>(<%- filter.count[f] %>)</option>
                        <% } %>
                    </select>
                </div>
            </div>
            <div>
                <a href="#add-bj" data-toggle="modal" data-target="#add-bj" class="btn btn-sm btn-primary pull-right">新建变更令</a>
                <a href="#setting" data-toggle="modal" data-target="#setting" class="btn btn-sm btn-outline-primary pull-right"><i class="fa fa-cog"></i></a>
            </div>
        </div>
    </div>
    <div class="content-wrap">
        <div class="c-body">
            <input id="tenderName" value="<%= tender.name %>" type="hidden">
            <input id="tenderId" value="<%= tender.id %>" type="hidden">
            <table class="table">
                <thead>
                <tr>
                    <th width="20%">变更令号</th><th width="30%">工程名称</th>
                    <th width="10%">变更类别</th><th width="10%">变更金额</th>
                    <th width="10%">审批状态</th><th>审批进度</th>
                </tr>
                </thead>
                <tbody id="changeList">
                <% const classArray = []; %>
                <% for (const t in changeConst.class) { %>
                    <% const cClass = changeConst.class[t] %>
                    <% classArray[cClass.value] = cClass.name %>
                <% } %>
                <% for (const c of changes) { %>
                <tr>
                    <td><a href="/tender/<%- tender.id %>/change/<%- c.cid %>/info"><%- c.code %></a></td>
                    <td><%- c.name %></td>
                    <td><%- classArray[c.class] %><% c.class %></td>
                    <td><%- c.total_price %></td>
                    <% if (c.auditStatus) { %>
                    <td>
                        <a href="/tender/<%- tender.id %>/change/<%- c.cid %>/info" class="btn <%- auditConst.statusButtonClass[c.status] %> btn-sm">
                            <%- auditConst.statusButton[c.status] %>
                        </a>
                    </td>
                    <% } else {  %>
                    <td>
                        <span class="<%- auditConst.statusClass[c.status] %>"><%- auditConst.statusString[c.status] %></span>
                    </td>
                    <% } %>
                    <% if (c.status === auditConst.status.uncheck) { %>
                    <td>
                        待上报
                    </td>
                    <% } else { %>
                    <td>
                        <%- c.changeAudit.name %>-<%- c.changeAudit.jobs %>
                        <span class="<%- auditConst.auditStatusClass[c.changeAudit.status] %>"><%- auditConst.auditStatusString[c.changeAudit.status] %></span>
                    </td>
                    <% } %>
                </tr>
                <% } %>
                </tbody>
            </table>
            <!--翻页-->
            <% include ../layout/page.ejs %>
        </div>
    </div>
</div>
<script src="/public/js/change.js"></script>
