<link rel="stylesheet" type="text/css" href="/public/css/datatable/dataTables.bootstrap4.min.css">
<link rel="stylesheet" type="text/css" href="/public/css/datatable/fixedColumns.bootstrap4.min.css">
<style type="text/css" class="init">
    .qd-table .input-sm{
        height:30px;
        padding:2px;
    }
    .qd-table>tbody>tr>td, .qd-table>tbody>tr>th, .qd-table>tfoot>tr>td, .qd-table>tfoot>tr>th, .qd-table>thead>tr>td, .qd-table>thead>tr>th {
        padding:5px 2px
    }

    #list td input{
        width: 100%;
        font-size: 0.9rem;
    }
    #list td select{
        width: 100%;
        font-size: 0.9rem;
        vertical-align: middle;
        line-height: 30px;
    }
    #list td a {
        cursor: pointer;
    }
    .allwidth1{

    }
    .allwidth2{

    }
    .allwidth3{
        text-align:right;
    }
    .allwidth3 input{
        text-align:right;
    }
    .allwidth5{
        text-align:center;
    }
    .allwidth4{
        text-align:center;
    }
    div.DTFC_LeftFootWrapper table, div.DTFC_RightFootWrapper table{
        border-top: 1px solid #ddd;
    }
    div.dataTables_scrollFootInner table{
        margin-top: 1px !important;
    }
    table.dataTable{
        border-collapse: collapse !important;
    }
    table.table-bordered.dataTable tbody th, table.table-bordered.dataTable tbody td{
        border-bottom-width: 1px;
    }
    div.dataTables_scrollFootInner table{
        margin-top: 0 !important;
    }
    .bg-con-warp:nth-child(2) th{
        text-align: center !important;
    }
    .change-title {
        font-size: 16px;
        margin: 0;
        height: 50px;
        line-height: 50px;
        display: block;
    }
</style>
<div class="panel-sidebar">
    <div class="panel-title">
        <div class="title-bar">
            <h2><%- tender.name %></h2>
        </div>
    </div>
    <div class="scrollbar-auto">
        <div class="nav-box">
            <ul class="nav-list list-unstyled">
                <li class=""><a href="/tender/<%- tender.id %>/change"><i class="fa fa-chevron-left "></i> <span>返回</span></a></li>
            </ul>
        </div>
        <div class="nav-box">
            <ul class="nav nav-tab nav-list list-unstyled" role="tablist" id="tablist" style="display: block">
                <li style="margin-bottom: 1rem;"><a href="#info" class="active" aria-controls="info" data-toggle="tab"><span class="ml-3">变更信息</span></a></li>
                <li style="margin-bottom: 1rem;"><a href="#bills" aria-controls="bills" data-toggle="tab"><span class="ml-3">变更清单</span></a></li>
                <li><a href="#files" aria-controls="files" data-toggle="tab"><span class="ml-3">附件</span></a></li>
            </ul>
        </div>
    </div>
</div>
<div class="panel-content">
    <div class="panel-title">
        <div class="title-main d-flex justify-content-between">
            <h2 id="info_title" class="show_title">变更信息</h2>
            <div id="bills_title" class="show_title" style="display: none">
                <div>
                    <% if (auditStatus === 1 || auditStatus === 2) { %>
                    <div class="d-inline-block">
                        <a href="#addlist" data-toggle="modal" class="btn btn-sm" id="open-list-modal" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="添加清单"><i class="fa fa-plus" aria-hidden="true"></i> 添加清单</a>
                    </div>
                    <% } else { %>
                    <div class="d-inline-block">
                        <h2 class="change-title">变更清单</h2>
                    </div>
                    <% } %>
                    <div class="d-inline-block ml-3">
                        <div class="custom-control custom-checkbox" style="line-height: normal;">
                            <input type="checkbox" class="custom-control-input change-detail-checkbox" id="customCheck1" checked>
                            <label class="custom-control-label" for="customCheck1">变更详情</label>
                        </div>
                    </div>
                    <% if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
                    <div class="d-inline-block ml-3">
                        <div class="custom-control custom-checkbox" style="line-height: normal;">
                            <input type="checkbox" class="custom-control-input" id="show-table-detail">
                            <label class="custom-control-label" for="show-table-detail">审批过程</label>
                        </div>
                    </div>
                    <% } %>
                </div>
            </div>
            <div id="files_title" class="show_title" style="display: none">
                <% if (auditStatus === 1 || auditStatus === 2 || auditStatus === 6) { %>
                <a href="#addfujian" data-toggle="modal" class="btn btn-sm" data-toggle="tooltip" data-placement="bottom" title="" data-original-title="添加清单">
                    <i class="fa fa-cloud-upload" aria-hidden="true"></i> 上传附件
                </a>
                <% } else { %>
                <h2 class="change-title">附件</h2>
                <% } %>
            </div>
            <input id="tenderId" value="<%= tender.id %>" type="hidden">
            <input id="changeId" value="<%= change.cid %>" type="hidden">
            <!--info状态区分-->
            <% if (auditStatus === 1) { %>
            <div>
                <a href="#sub-ap" data-category="save_change" data-toggle="modal" data-target="#sub-ap" class="btn btn-sm btn-success pull-right">保存修改</a>
                <a href="#sub-ap" data-category="up_change" data-toggle="modal" data-target="#sub-ap" class="btn btn-primary btn-sm pull-right">上报审批</a>
                <!--<a href="#" class="btn btn-outline-danger btn-sm pull-right text-truncate" style="max-width: 100px;" title="删除 <%- change.code %>">删除 <%- change.code %></a>-->
            </div>
            <% } else if (auditStatus === 2) { %>
            <div>
                <a href="#sub-ap" data-category="save_change" data-toggle="modal" data-target="#sub-ap" class="btn btn-sm btn-success pull-right">保存修改</a>
                <a href="#sub-ap" data-category="up_change" data-toggle="modal" data-target="#sub-ap" class="btn btn-primary btn-sm pull-right">重新上报</a>
                <!--<a href="#" class="btn btn-outline-danger btn-sm pull-right text-truncate" style="max-width: 100px;" title="删除 <%- change.code %>">删除 <%- change.code %></a>-->
            </div>
            <% } else if (auditStatus === 3) { %>
            <div>
                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-warning btn-sm pull-right text-muted">审批退回</a>
            </div>
            <% } else if (auditStatus === 4) { %>
            <div>
                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-success btn-sm pull-right">审批完成</a>
            </div>
            <% } else if (auditStatus === 5) { %>
            <div>
                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-danger btn-sm pull-right">审批终止</a>
            </div>
            <% } else if (auditStatus === 6) { %>
            <div>
                <a href="#sp-done" data-toggle="modal" data-target="#sp-done" class="btn btn-success btn-sm pull-right">审批通过</a>
                <a href="#sp-back" data-toggle="modal" data-target="#sp-back" class="btn btn-warning btn-sm pull-right">审批退回</a>
            </div>
            <% } else if (auditStatus === 7) { %>
            <div>
                <a href="#sp-list" data-toggle="modal" data-target="#sp-list" class="btn btn-outline-secondary btn-sm pull-right">审批中</a>
            </div>
            <% } %>
        </div>
    </div>
    <div class="content-wrap tab-content">
        <div class="c-body tab-pane active" role="tabpanel" id="info">
            <!--变更信息-->
            <% if (auditStatus === 1 || auditStatus === 2) { %>
            <form action="/change/save?_csrf=<%= ctx.csrf %>" method="post" id="change_form">
                <div class="row">
                    <div class="col-md-4">
                        <div class="form-group">
                            <label><b class="text-danger">*&nbsp;</b>申请编号</label>
                            <a href="javascript:void(0);" class="pull-right reduction-code" data-toggle="tooltip" data-placement="bottom" title="" data-code="<%- change.code %>" data-original-title="自动编号"><i class="fa fa-repeat"></i></a>
                            <input class="form-control" name="code" value="<%- change.code %>" type="text">
                        </div>
                        <div class="form-group">
                            <label><b class="text-danger">*&nbsp;</b>工程名称</label>
                            <input class="form-control" name="name" value="<%- change.name %>" type="text">
                        </div>
                        <div class="form-group">
                            <label>桩号</label>
                            <input class="form-control" name="peg" value="<%- change.peg %>" type="text">
                        </div>
                        <div class="form-group">
                            <label>原设计图名称</label>
                            <input class="form-control" name="org_name" placeholder="" type="text" value="<%- change.org_name %>">
                        </div>
                        <div class="form-group">
                            <label>原图号</label>
                            <input class="form-control" name="org_code" placeholder="" type="text" value="<%- change.org_code %>">
                        </div>
                        <div class="form-group">
                            <label>变更设计图名称</label>
                            <input class="form-control" name="new_name" placeholder="" type="text" value="<%- change.new_name %>">
                        </div>
                        <div class="form-group">
                            <label>变更图号</label>
                            <input class="form-control" name="new_code" placeholder="" type="text" value="<%- change.new_code %>">
                        </div>
                    </div>
                    <div class="col-md-4" style="z-index:999">
                        <div class="form-group">
                            <label><b class="text-danger">*&nbsp;</b>工程变更理由及内容</label>
                            <textarea class="form-control" name="content" rows="6"><%- change.content %></textarea>
                        </div>
                        <div class="form-group">
                            <label>工程变更合同依据</label>
                            <textarea class="form-control" name="basis" rows="6"><%- change.basis %></textarea>
                        </div>
                        <div class="form-group">
                            <label>备注</label>
                            <textarea class="form-control" name="memo" rows="3"><%- change.memo %></textarea>
                        </div>
                    </div>
                    <div class="col-md-4">
                        <div class="form-group">
                            <label>变更类型</label>
                            <div class="checkbox">
                                <% const changeType = change.type !== null && change.type !== '' ? change.type.split(',') : '' %>
                                <% for (const t in changeConst.type) { %>
                                <% const cType = changeConst.type[t] %>
                                <label class="checkbox-inline">
                                    <input value="<%- cType.value %>" name="type[]"
                                           type="checkbox"<% if (changeType.indexOf(cType.value.toString()) !== -1) { %> checked<% } %>><%- cType.name %>
                                </label>
                                <% } %>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>变更类别 </label>
                            <select class="form-control" name="class">
                                <% for (const c in changeConst.class) { %>
                                <% const cClass = changeConst.class[c] %>
                                <option value="<%- cClass.value %>"<% if (cClass.value === change.class) { %> selected<% } %>><%- cClass.name %></option>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>变更性质 </label>
                            <select class="form-control" name="quality">
                                <% for (const q in changeConst.quality) { %>
                                <% const cQuality = changeConst.quality[q] %>
                                <option value="<%- cQuality.value %>"<% if (cQuality.value === change.quality) { %> selected<% } %>><%- cQuality.name %></option>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>变更提出单位</label>
                            <a href="#editcompany" style="float:right;" class="" data-toggle="modal">编辑</a>
                            <select class="form-control" id="company" name="company">
                                <% for (const company of companyList) { %>
                                <option <% if (company.name === change.company) { %>selected<% } %>><%- company.name %></option>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>费用承担方</label>
                            <div class="radio">
                                <% for (const c in changeConst.charge) { %>
                                <% const cCharge = changeConst.charge[c] %>
                                <label class="radio-inline">
                                    <input value="<%- cCharge.value %>" name="charge" type="radio"<% if (cCharge.value === change.charge) { %> checked<% } %>> <%- cCharge.name %>
                                </label>
                                <% } %>
                            </div>
                        </div>
                    </div>
                </div>
                <!--清单、附件、审批人上传数据-->
                <input type="hidden" name="changelist" id="change-list" value="<%= changeListData %>">
                <input type="hidden" name="changewhitelist" id="change-whitelist" value="<%= changeWhiteListData %>">
                <input type="hidden" name="changeaudit" id="changeaudit" value="">
                <input type="hidden" name="changestatus" id="changeStatus">
                <input type="hidden" name="cid" value="<%= change.cid %>">
            </form>
            <% } else { %>
            <div class="row">
                <div class="col-md-4">
                    <form>
                        <div class="form-group">
                            <label>申请编号</label>
                            <input class="form-control" value="<%- change.code %>" type="text" readonly>
                        </div>
                        <% if (auditStatus === 4) { %>
                        <div class="form-group">
                            <label>批复编号</label>
                            <input class="form-control" value="<%- change.p_code %>" type="text" readonly>
                        </div>
                        <% } %>
                        <div class="form-group">
                            <label>工程名称</label>
                            <input class="form-control" value="<%- change.name %>" type="text" readonly>
                        </div>
                        <div class="form-group">
                            <label>桩号</label>
                            <input class="form-control" value="<%- change.peg %>" type="text" readonly>
                        </div>
                        <div class="form-group">
                            <label>原设计图名称</label>
                            <input class="form-control" placeholder="" type="text" value="<%- change.org_name %>" readonly>
                        </div>
                        <div class="form-group">
                            <label>原图号</label>
                            <input class="form-control" placeholder="" type="text" value="<%- change.org_code %>" readonly>
                        </div>
                        <div class="form-group">
                            <label>变更设计图名称</label>
                            <input class="form-control" placeholder="" type="text" value="<%- change.new_name %>" readonly>
                        </div>
                        <div class="form-group">
                            <label>变更图号</label>
                            <input class="form-control" placeholder="" type="text" value="<%- change.new_code %>" readonly>
                        </div>
                    </form>
                </div>
                <div class="col-md-4" style="z-index:999">
                    <form>
                        <div class="form-group">
                            <label>工程变更理由及内容</label>
                            <textarea class="form-control" rows="6" readonly><%- change.content %></textarea>
                        </div>
                        <div class="form-group">
                            <label>工程变更合同依据</label>
                            <textarea class="form-control" rows="6" readonly><%- change.basis %></textarea>
                        </div>
                        <div class="form-group">
                            <label>备注</label>
                            <textarea class="form-control" rows="3" readonly><%- change.memo %></textarea>
                        </div>
                    </form>
                </div>
                <div class="col-md-4">
                    <form>
                        <div class="form-group">
                            <label>变更类型</label>
                            <div class="checkbox">
                                <% const changeType = change.type !== null && change.type !== '' ? change.type.split(',') : '' %>
                                <% for (const t in changeConst.type) { %>
                                <% const cType = changeConst.type[t] %>
                                <label class="checkbox-inline">
                                    <% if (changeType.indexOf(cType.value.toString()) !== -1) { %>
                                    <input value="<%- cType.value %>" type="checkbox" disabled checked><%- cType.name %>
                                    <% } %>
                                </label>
                                <% } %>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>变更类别 </label>
                            <select class="form-control" disabled>
                                <% for (const c in changeConst.class) { %>
                                <% const cClass = changeConst.class[c] %>
                                <% if (cClass.value === change.class) { %>
                                <option value="<%- cClass.value %>"><%- cClass.name %></option>
                                <% } %>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>变更性质 </label>
                            <select class="form-control" disabled>
                                <% for (const q in changeConst.quality) { %>
                                <% const cQuality = changeConst.quality[q] %>
                                <% if (cQuality.value === change.quality) { %>
                                <option value="<%- cQuality.value %>"><%- cQuality.name %></option>
                                <% } %>
                                <% } %>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>变更提出单位</label>
                            <select class="form-control" disabled>
                                <option><%- change.company %></option>
                            </select>
                        </div>
                        <div class="form-group">
                            <label>费用承担方</label>
                            <div class="radio">
                                <% for (const c in changeConst.charge) { %>
                                <% const cCharge = changeConst.charge[c] %>
                                <label class="radio-inline">
                                    <% if (cCharge.value === change.charge) { %>
                                    <input value="<%- cCharge.value %>" type="radio" disabled checked> <%- cCharge.name %>
                                    <% } %>
                                </label>
                                <% } %>
                            </div>
                        </div>
                        <div class="form-group">
                            <label>批复文号</label>
                            <input class="form-control" id="w_code" placeholder="" type="text" value="<%- change.w_code %>" <% if (auditStatus !== 6) { %>readonly<% } %>>
                        </div>
                    </form>
                </div>
            </div>
            <% } %>
        </div>

        <div class="c-body tab-pane first-bill-pane" role="tabpanel" id="bills">
            <!--变更清单-->
            <% if (auditStatus === 1 || auditStatus === 2) { %>
            <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist" cellspacing="0" style="width:100%">
                <thead>
                <tr>
                    <th rowspan="2" class="text-center">清单编号</th>
                    <th rowspan="2" class="text-center">名称</th>
                    <th rowspan="2" class="text-center">变更详情</th>
                    <th rowspan="2" class="text-center">单位</th>
                    <th rowspan="2" class="text-center">单价</th>
                    <th colspan="2" class="text-center">原设计</th>
                    <th colspan="2" class="text-center">申报变更</th>
                    <th rowspan="2" class="text-center">操作</th>
                </tr>
                <tr>
                    <th class="text-center">数量</th>
                    <th class="text-center">金额</th>
                    <th class="text-center">数量</th>
                    <th class="text-center">金额</th>
                </tr>
                </thead>
                <tbody id="list">
                <% let windex = 0; %>
                <% for (const [index,cl] of changeList.entries()) { %>
                    <% if (cl.lid !== 0) { %>
                    <tr class="clist clid" data-lid="<%= cl.lid %>_<%= index %>" data-index="<%= index %>">
                        <td data-site="0"><%= cl.code %></td>
                        <td data-site="1"><%= cl.name %></td>
                        <td data-site="2"><input class="form-control form-control-sm" placeholder="变更详情" type="text" value="<%= cl.detail %>"></td>
                        <td data-site="3"><%= cl.unit %></td>
                        <td data-site="4"><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
                        <td data-site="5"><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                        <td data-site="6"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                        <td data-site="7"><input class="form-control form-control-sm" placeholder="变更数量" type="text" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)"  value="<%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %>"></td>
                        <td data-site="8"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
                        <td><a class="text-danger">移除</a>
                        </td>
                    </tr>
                    <% } else { %>
                    <tr class="clist" data-lid="<%= windex %>" data-index="<%= windex %>">
                        <td data-site="0"><input class="form-control form-control-sm" placeholder="清单编号" type="text" value="<%= cl.code %>"></td>
                        <td data-site="1"><input class="form-control form-control-sm" placeholder="名称" type="text" value="<%= cl.name %>"></td>
                        <td data-site="2"><input class="form-control form-control-sm" placeholder="变更详情" type="text" value="<%= cl.detail %>"></td>
                        <td data-site="3">
                            <select class="form-control input-sm">
                                <% for (const j in changeUnits) { %>
                                    <% if (changeUnits[j].unit !== undefined && changeUnits[j].unit === cl.unit) { %>
                                <option selected="selected"><%= changeUnits[j].unit %></option>
                                    <% } else if(changeUnits[j].unit !== undefined) { %>
                                <option><%= changeUnits[j].unit %></option>
                                    <% } %>
                                <% } %>
                            </select>
                        </td>
                        <td data-site="4"><input class="form-control form-control-sm" placeholder="单价" onkeyup="RegNum(this,event,tpUnit)" type="text" value="<%= ctx.helper.roundNum(cl.unit_price, tpUnit) %>"></td>
                        <td data-site="5"><input class="form-control form-control-sm" placeholder="数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %>"></td>
                        <td data-site="6"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                        <td data-site="7"><input class="form-control form-control-sm" placeholder="变更数量" onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)" type="text" value="<%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %>"></td>
                        <td data-site="8"><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
                        <td><a class="text-danger">移除</a>
                        </td>
                    </tr>
                        <% windex++ %>
                    <% } %>
                <% } %>
                </tbody>
                <tfoot>
                <tr class="info">
                    <td>合计</td><td></td><td></td><td></td><td></td><td></td>
                    <td class="otatalamount"><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
                    <td class="ctatalamount"><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td><td></td>
                </tr>
                </tfoot>
            </table>
            <% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
                <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist" cellspacing="0" style="width:100%">
                    <thead>
                    <tr>
                        <th rowspan="2" class="text-center">清单编号</th>
                        <th rowspan="2" class="text-center">名称</th>
                        <th rowspan="2" class="text-center">变更详情</th>
                        <th rowspan="2" class="text-center">单位</th>
                        <th rowspan="2" class="text-center">单价</th>
                        <th colspan="2" class="text-center">原设计</th>
                        <th colspan="2" class="text-center">申报变更</th>
                        <th colspan="2" class="text-center">审批后变更</th>
                    </tr>
                    <tr>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                    </tr>
                    </thead>
                    <tbody id="list">
                    <% for (const cl of changeList.sort()) { %>
                        <tr>
                            <td><%= cl.code %></td>
                            <td><%= cl.name %></td>
                            <td><%= cl.detail %></td>
                            <td><%= cl.unit %></td>
                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
                            <td><%= cl.samount !== '' ? ctx.helper.roundNum(cl.samount, ctx.helper.findDecimal(cl.unit)) : '' %></td>
                            <td><%= cl.samount !== '' ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.samount), tpUnit) : '' %></td>
                            </td>
                        </tr>
                    <% } %>
                    </tbody>
                    <tfoot>
                    <tr class="info">
                        <td>合计</td><td></td><td></td><td></td><td></td><td></td>
                        <td><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
                        <td><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td><td></td>
                        <td><%= stotalCost !== 0 ? ctx.helper.roundNum(stotalCost, tpUnit) : '' %></td>
                    </tr>
                    </tfoot>
                </table>

                <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist2" cellspacing="0" style="width:100%;display: none;">
                    <thead>
                    <tr>
                        <th rowspan="2" class="text-center">清单编号</th>
                        <th rowspan="2" class="text-center">名称</th>
                        <th rowspan="2" class="text-center">变更详情</th>
                        <th rowspan="2" class="text-center">单位</th>
                        <th rowspan="2" class="text-center">单价</th>
                        <th colspan="2" class="text-center">原设计</th>
                        <th colspan="2" class="text-center">申报变更</th>
                        <% for (const audit of auditList2) { %>
                        <% if (audit.usite !== 0) { %>
                        <th colspan="2" class="text-center"><%= audit.name %> 审批</th>
                        <% } %>
                        <% } %>
                    </tr>
                    <tr>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <% for (const audit of auditList2) { %>
                            <% if (audit.usite !== 0) { %>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                            <% } %>
                        <% } %>
                    </tr>
                    </thead>
                    <tbody id="list">
                    <% const audittotalCost = []; %>
                    <% for (const [cindex,cl] of changeList.sort().entries()) { %>
                        <tr>
                            <td><%= cl.code %></td>
                            <td><%= cl.name %></td>
                            <td><%= cl.detail %></td>
                            <td><%= cl.unit %></td>
                            <td><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
                            <% for (const audit of auditList2) { %>
                                <% if (audit.usite !== 0) { %>
                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %></td>
                                <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, audit.list_amount[cindex]), tpUnit) : '' %></td>
                                <% } %>
                            <% } %>
                            </td>
                        </tr>
                    <% } %>
                    </tbody>
                    <tfoot>
                    <tr class="info">
                        <td>合计</td><td></td><td></td><td></td><td></td><td></td>
                        <td><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
                        <td><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td>
                        <% for (const audit of auditList2) { %>
                            <% if (audit.usite !== 0) { %>
                        <td></td><td><%=audit.totalCost !== 0 ? ctx.helper.roundNum(audit.totalCost, tpUnit) : '' %></td>
                            <% } %>
                        <% } %>
                    </tr>
                    </tfoot>
                </table>
            <% } else if (auditStatus === 6) { %>
                <table class="table table-striped table-bordered nowrap qd-table table-list" id="tablelist" cellspacing="0" style="width:100%;">
                    <thead>
                    <tr>
                        <th rowspan="2" class="text-center">清单编号</th>
                        <th rowspan="2" class="text-center">名称</th>
                        <th rowspan="2" class="text-center">变更详情</th>
                        <th rowspan="2" class="text-center">单位</th>
                        <th rowspan="2" class="text-center">单价</th>
                        <th colspan="2" class="text-center">原设计</th>
                        <th colspan="2" class="text-center">申报变更</th>
                        <% for (const audit of auditList) { %>
                            <% if (audit.usite !== 0) { %>
                                <th colspan="2" class="text-center"><%= audit.name %> 审批</th>
                            <% } %>
                        <% } %>
                    </tr>
                    <tr>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <th class="text-center">数量</th>
                        <th class="text-center">金额</th>
                        <% for (const audit of auditList) { %>
                            <% if (audit.usite !== 0) { %>
                                <th class="text-center">数量</th>
                                <th class="text-center">金额</th>
                            <% } %>
                        <% } %>
                    </tr>
                    </thead>
                    <tbody id="list">
                    <% const audittotalCost = []; %>
                    <% for (const [cindex,cl] of changeList.entries()) { %>
                        <tr class="clist" data-lid="<%= cl.id %>">
                            <td><%= cl.code %></td>
                            <td><%= cl.name %></td>
                            <td><%= cl.detail %></td>
                            <td><%= cl.unit %></td>
                            <td data-site="4"><%= ctx.helper.roundNum(cl.unit_price, tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.oamount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.oamount), tpUnit) %></td>
                            <td><%= ctx.helper.roundNum(cl.camount, ctx.helper.findDecimal(cl.unit)) %></td>
                            <td><%= ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, cl.camount), tpUnit) %></td>
                            <% for (const audit of auditList) { %>
                                <% if (audit.usite !== 0) { %>
                                    <% if (uid === audit.uid) { %>
                                    <td>
                                        <input class="form-control form-control-sm"  style="min-width:80px" placeholder="变更数量" type="text"
                                               onkeyup="RegNum(this,event,<%= ctx.helper.findDecimal(cl.unit) %>)"
                                               value="<%= audit.list_amount[cindex] !== undefined ?
                                                       ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %>">
                                    </td>
                                    <% } else { %>
                                    <td><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(audit.list_amount[cindex], ctx.helper.findDecimal(cl.unit)) : '' %></td>
                                    <% } %>
                                    <td<% if (uid === audit.uid) { %> class="amount_cost"<% } %>><%= audit.list_amount[cindex] !== undefined ? ctx.helper.roundNum(ctx.helper.accMul(cl.unit_price, audit.list_amount[cindex]), tpUnit) : '' %></td>
                                <% } %>
                            <% } %>
                            </td>
                        </tr>
                    <% } %>
                    </tbody>
                    <tfoot>
                    <tr class="info">
                        <td>合计</td><td></td><td></td><td></td><td></td><td></td>
                        <td><%= ctx.helper.roundNum(ototalCost, tpUnit) %></td><td></td>
                        <td><%= ctx.helper.roundNum(ctotalCost, tpUnit) %></td>
                        <% for (const audit of auditList) { %>
                            <% if (audit.usite !== 0) { %>
                            <td></td><td <% if (uid === audit.uid) { %>class="amount_totalcost"<% } %>><%=audit.totalCost !== 0 ? ctx.helper.roundNum(audit.totalCost, tpUnit) : '' %></td>
                            <% } %>
                        <% } %>
                    </tr>
                    </tfoot>
                </table>
            <% } %>
        </div>

        <div class="c-body tab-pane" role="tabpanel" id="files">
            <table class="table table-bordered">
                <thead>
                <tr>
                    <th width="50">序号</th>
                    <th>名称</th>
                    <th width="90">大小</th>
                    <th width="100">上传时间</th>
                    <th width="100">操作</th>
                </tr>
                </thead>
                <tbody id="attList">
                <% if (attList !== undefined && attList !== '') { %>
                <% for (const [index,att] of attList.entries()) { %>
                <tr>
                    <td><%- index+1 %></td>
                    <td><a href="/change/download/file/<%- att.id %>"><%- att.filename %><%- att.fileext %></a></td>
                    <td><%- ctx.helper.bytesToSize(att.filesize) %></td>
                    <td><%- moment(att.in_time * 1000).format('YYYY-MM-DD') %></td>
                    <td>
                        <% if (att.uid === uid && (auditStatus === 1 || auditStatus === 2 || auditStatus === 6)) { %>
                        <a class="btn btn-light btn-sm delete-file" data-attid="<%- att.id %>" title="删除附件"><span class="fa fa-trash text-danger"></span></a>
                        <% } %>
                    </td>
                </tr>
                <% } %>
                <% } %>
                </tbody>
            </table>
        </div>
    </div>
</div>
<link href="/public/css/toastr.css" rel="stylesheet">
<script src="/public/js/toastr.min.js"></script>
<script>
    $(document).ready(() => {
        toastr.options = {
            "closeButton": false,
            "debug": false,
            "newestOnTop": false,
            "progressBar": false,
            "positionClass": "toast-top-right",
            "preventDuplicates": false,
            "onclick": null,
            "showDuration": "300",
            "hideDuration": "1000",
            "timeOut": "5000",
            "extendedTimeOut": "1000",
            "showEasing": "swing",
            "hideEasing": "linear",
            "showMethod": "fadeIn",
            "hideMethod": "fadeOut"
        };
    })
    let table = '';
    const totalPriceUnit = '<%- tpUnit %>';
</script>
<script src="/public/js/datatable/jquery.dataTables.min.js"></script>
<script src="/public/js/datatable/dataTables.bootstrap4.min.js"></script>
<script src="/public/js/datatable/dataTables.fixedColumns.min.js"></script>
<script src="/public/js/datatable/jlzf-change-table.js"></script>
<script src="/public/js/change_calculation.js"></script>
<% if (auditStatus === 1 || auditStatus === 2) { %>
<script>
    const whiteList = JSON.parse('<%- JSON.stringify(whiteList) %>');
    const changeUnits = JSON.parse('<%- JSON.stringify(changeUnits) %>');
    const billsTable = {
        columnDefs: [
            { className: 'allwidth1', width: 100, targets: 0 },
            { className: 'allwidth2', width: 150, targets: [1,2] },
            { className: 'allwidth4', width: 40, targets: 9 },
            { className: 'allwidth5', width: 60, targets: 3 },
            { className: 'allwidth3',width: 80, targets: '_all' }
        ],
        fixedColumns: {
            leftColumns: 5
        }
    }
    const ledger = JSON.parse('<%- JSON.stringify(ledger) %>');
    const pos = JSON.parse('<%- JSON.stringify(pos) %>');
    const dealBillList = JSON.parse('<%- JSON.stringify(dealBillList) %>');
</script>
<script src="/public/js/path_tree.js"></script>
<script src="/public/js/gcl_gather.js"></script>
<script src="/public/js/change_set.js"></script>
<% } else if (auditStatus === 3 || auditStatus === 4 || auditStatus === 5 || auditStatus === 7) { %>
<script>
    const billsTable = {
        columnDefs: [
            { className: 'allwidth1', width: 100, targets: 0 },
            { className: 'allwidth2', width: 150, targets: [1,2] },
            { className: 'allwidth5', width: 60, targets: 3 },
            { className: 'allwidth3',width: 80, targets: '_all' }
        ],
        fixedColumns: {
            leftColumns: 5
        }
    }
</script>
<script src="/public/js/change_show.js"></script>
<% } else if (auditStatus === 6) { %>
<script>
    const billsTable = {
        columnDefs: [
            { className: 'allwidth1', width: 100, targets: 0 },
            { className: 'allwidth2', width: 150, targets: [1,2] },
            { className: 'allwidth5', width: 60, targets: 3 },
            { className: 'allwidth3',width: 80, targets: '_all' }
        ],
        fixedColumns: {
            leftColumns: 5
        }
    }
</script>
<script src="/public/js/change_approval.js"></script>
<% } %>
<script src="/public/js/change_detail.js"></script>
