| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876 | <link href="/public/css/bootstrap/select2.min.css" rel="stylesheet" /><link rel="stylesheet" href="/public/css/bootstrap/select2-bootstrap4.min.css"><script src="/public/js/bootstrap/select2.min.js"></script><% if (stg_id === -1) {%><% include ../tender/tender_sub_menu.ejs %><% } else { %><% include ../stage/stage_sub_menu.ejs %><% } %><div class="panel-content">    <div class="panel-title">        <div class="title-main d-flex">            <% if(stg_id === -1) { %>            <% include ../tender/tender_sub_mini_menu.ejs %>            <% } else { %>            <% include ../stage/stage_sub_mini_menu.ejs %>            <% } %>            <div>                <% if (stg_id === -1) { %>                <div class="d-inline-block">                    <div class="dropdown">                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="bizDropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">                            计量期                        </button>                        <div class="dropdown-menu" aria-labelledby="bizDropdownMenuButton" id="select-item">                            <a class="dropdown-item" href="javascript:void(0);" data-type="stage" style="display: none">计量期</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="change">变更令</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="change_project">变更立项</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="change_apply">变更申请</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="change_plan">变更方案</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="advance">预付款</a>                            <a class="dropdown-item" href="javascript:void(0);" data-type="material">材料调差</a>                        </div>                    </div>                </div>                <% } %>                <div class="d-inline-block">                    <div class="dropdown" id="divSelectableStages">                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentStage" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableStages"></div>                    </div>                </div>                <div class="d-inline-block">                    <style>                        .select2-container {                            display: inline-block!important;                            height: 27px;                        }                        .select2-container--bootstrap4 .select2-selection--single {                            height: calc(.84em + .75rem + 2px) !important;                        }                        .select2-container--bootstrap4 .select2-selection {                            background-color: #f8f9fa;                            /*border-color: #f8f9fa;*/                            border: 1px solid #f8f9fa;                        }                        .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered:focus{                            box-shadow: 0 0 0 0.2rem rgba(216,217,219,.5);                        }                        .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered:hover {                            background-color: #e2e6ea;                            border-color: #dae0e5;                        }                        .select2-container--bootstrap4 .select2-selection--single .select2-selection__rendered {                            line-height: calc(.84em + .75rem);                            color: #007bff!important;                            border-radius: 0.2rem;                            /*background-color: #f8f9fa;*/                            /*border-color: #f8f9fa;*/                        }                        .select2-container--bootstrap4 .select2-selection--single .select2-selection__arrow b {                            border-color: #007bff transparent transparent transparent;                            border-width: 4px 3.7px 0;                        }                        .select2-search--dropdown .select2-search__field {                            padding: 0.175rem 0.5rem;                        }                    </style>                    <div id="divSelectableChanges" class="" style="display: none;min-width: 90px;">                        <select id="optionSelectableChanges" class="form-control form-control-sm"></select>                    </div><!--                    <div class="dropdown" id="divSelectableChanges" style="display: none">--><!--                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentChange" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>--><!--                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableChanges"></div>--><!--                    </div>-->                </div>                <div class="d-inline-block">                    <div class="dropdown" style="display: none" id="divSelectableAdvances">                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentAdvance" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>                        <div class="dropdown-menu" aria-labelledby="allPrepayButton" id="optionSelectableAdvances"></div>                    </div>                </div>                <div class="d-inline-block">                    <div class="dropdown" id="divSelectableAdvancePays" style="display:none;">                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentAdvancePay" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableAdvancePays"></div>                    </div>                </div>                <div class="d-inline-block">                    <div class="dropdown" id="divSelectableMaterials" style="display:none;">                        <button class="btn btn-sm btn-light dropdown-toggle text-primary" type="button" id="btnCurrentMaterial" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>                        <div class="dropdown-menu" aria-labelledby="dropdownMenuButton" id="optionSelectableMaterials"></div>                    </div>                </div>                <% if (ctx.session.sessionUser.accountId === ctx.tender.data.user_id) { %>                <div class="d-inline-block">                    <button id="file-msg" class="btn btn-sm btn-primary" type="button" onclick="sendReportFileMsg();" <% if (!needFileMsg.stage.valid) { %>style="display: none;"<% } %>>同步档案系统</button>                </div>                <% } %>            </div>            <div>            </div>        </div>    </div>    <div class="content-wrap">        <div class="c-header p-0"></div>        <div class="c-body">            <div class="row">                <div class="col-auto pr-0" id="tree-view" style="width: 17%">                    <div class="sjs-height-1" style="overflow: auto">                        <div class="text-center"></div>                        <ul id="rptTplTree" class="ztree"></ul>                    </div>                </div>                <div class="col-auto" id="main-view" style="width: 83%">                    <div class="resize-x" id="right-spr" r-Type="width" div1="#tree-view" div2="#main-view" title="调整大小" a-type="percent"><!--调整左右高度条--></div>                    <div class="toolsbar-f d-flex justify-content-between position-absolute bg-light m-1">                        <div class="print-toolsbar p-0">                            <div class="panel">                                <div class="panel-body" id="print_div">                                    <div class="btn-group" role="group">                                        <button class="btn btn-outline-primary btn-sm" type="button" id="print_file">                                            <i class="fa fa-print"></i><br>                                            打印 <span class="badge badge-primary">0</span>                                        </button>                                    </div>                                </div>                            </div>                            <div class="panel">                                <div class="panel-body" id="export_div">                                    <div class="btn-group" role="group">                                        <button class="btn btn-outline-primary btn-sm" type="button" id="download_file">                                            <i class="fa fa-download"></i><br>                                            下载 <span class="badge badge-primary">0</span>                                        </button>                                    </div>                                </div>                            </div>                            <div class="panel">                                <div class="panel-body">                                    <div class="btn-group" role="group">                                        <div>                                            <button id="currentDrpArchiveSelect" type="button" class="btn btn-outline-primary btn-sm dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"></button>                                            <div class="dropdown-menu" aria-labelledby="btnGroupDrop1" style="min-width:112px" id="drpArchiveSelect">                                                <!--                                                <a class="dropdown-item" href="#">#1 2021-02-01</a>                                                <a class="dropdown-item" href="#">#2 2021-02-27</a>                                                <a class="dropdown-item" href="javascript: void(0);" onclick="zTreeOprObj.changeOrientation(this)">横向</a>                                                -->                                            </div>                                        </div>                                    </div>                                </div>                                <div class="panel-foot text-muted">                                    历史归档                                </div>                            </div>                            <% if(ctx.session.sessionUser.is_admin) { %>                                <div class="panel">                                    <div class="panel-body" id="delete_div">                                        <div class="btn-group mr-1" role="group">                                            <button class="btn btn-outline-danger btn-sm" type="button" data-toggle="modal" data-target="#del-archive" id="delete_archive_btn">                                                <i class="fa fa-remove"></i><br>                                                删除归档                                            </button>                                        </div>                                    </div>                                </div>                            <% } %>                        </div>                    </div>                    <div class="print-view form-view">                        <div class="pageContainer sjs-height-1" id="iframe_made">                            <iframe src="/archive/pdf/show" class="border-0" height="100%" width="100%"></iframe>                        </div>                    </div>                </div>            </div>        </div>    </div></div><script src="/public/js/sub_menu.js"></script><script src="/public/js/div_resizer.js"></script><script>    $.subMenu({        menu: '#sub-menu', miniMenu: '#sub-mini-menu', miniMenuList: '#mini-menu-list',        toMenu: '#to-menu', toMiniMenu: '#to-mini-menu',        key: 'menu.1.0.0',        miniHint: '#sub-mini-hint', hintKey: 'menu.hint.1.0.1',        callback: function (info) {            if (info.mini) {                $('.panel-title').addClass('fluid');                $('#sub-menu').removeClass('panel-sidebar');            } else {                $('.panel-title').removeClass('fluid');                $('#sub-menu').addClass('panel-sidebar');            }            autoFlashHeight();        }    });    $.divResizer({        select: '#right-spr',        callback: function () {            autoFlashHeight();        }    });</script><script type="text/javascript">  autoFlashHeight();</script><script src="/public/js/shares/cs_tools.js"></script><!-- zTree --><script type="text/javascript" src="/public/js/ztree/jquery.ztree.core.js"></script><script type="text/javascript" src="/public/js/ztree/jquery.ztree.excheck.js"></script><script type="text/javascript" src="/public/js/string_util_light.js"></script><!----><script type="text/javascript" src="/public/js/rpt_tpl_def.js"></script><script type="text/javascript" src="/public/js/common_ajax.js"></script><script type="text/javascript" src="/public/js/treeDataHelper.js"></script><script type="text/javascript" src="/public/js/ztree_common.js"></script><script type="text/javascript" src="/public/js/storageUtil.js"></script><script type="text/javascript" src="/public/report/js/rpt_archive.js"></script><script type="text/javascript" src="/public/report/js/rpt_main.js"></script><script type="text/javascript" src="/public/report/js/rpt_cfg_const.js"></script><script type="text/javascript" src="/public/js/datepicker/datepicker.min.js"></script><script type="text/javascript" src="/public/js/datepicker/datepicker.zh.js"></script><!--<script type="text/javascript" src="/public/report/js/rpt_custom.js"></script>--><script type="text/javascript">    const needFileMsg = JSON.parse('<%- JSON.stringify(needFileMsg) %>');    let current_stage_order = -1;    let current_stage_id = -1;    let current_stage_status = -1;    let ARCHIVE_LIST = JSON.parse('<%- JSON.stringify(archiveList) %>');    let ARCHIVE_ENCRYPTION_LIST = JSON.parse('<%- JSON.stringify(archiveEncryptionList) %>');    let TOP_TREE_NODES = <%- rpt_tpl_data %>;    const CUST_TREE_NODES = <%- cust_tpl_data %>;    if (!(CUST_TREE_NODES.customize instanceof Array)) {        CUST_TREE_NODES.customize = [];    }    const ORG_CUST_TREE_NODES = JSON.parse(JSON.stringify(CUST_TREE_NODES));    //    const PROJECT_ID = <%- project_id %>;    const TENDER_ID = <%- tender_id %>;    const STAGE_ID = <%- stg_id %>;    const STAGE_ORDER = <%- stg_order %>;    const STAGE_LIST = <%- stage_list %>;    const can_netcasign = <%- can_netcasign %>;    const oss_path = JSON.parse('<%- JSON.stringify(ossPath) %>');    let business_type = 'stage';    let CHANGE_LIST = [], current_change_id = -1, current_change_code = '';    let CHANGE_ID = -1, BUSINESS_ID = -1;    let current_advance_id = -1;  // 预付款期id    let current_advance_type = -1;// 预付款报表类型    let current_material_id = -1; // 材差期id    let current_material_order = -1; // 材差期order    let ADVANCE_LIST = [];    let MATERIAL_LIST = [];    let CURRENT_SELECTED_BIZ_TYPE = '';    const ADVANCE_TYPECOL = JSON.parse(unescape('<%- escape(JSON.stringify(advanceConst.typeCol)) %>'));    const FOLDER_SEPERATER = '->';    if (STAGE_ORDER > 0) {        current_stage_order = STAGE_ORDER;        current_stage_id = STAGE_ID;//        current_stage_status = STAGE_STATUS;    } else if (STAGE_LIST.length > 0) {        for (let i = STAGE_LIST.length; i > 0; i--) {            if (parseInt(STAGE_LIST[i - 1].status) === 3) {                current_stage_order = STAGE_LIST[i - 1].order;                current_stage_id = STAGE_LIST[i - 1].id;                break;            }        }//        current_stage_order = STAGE_LIST[STAGE_LIST.length - 1].order;//        current_stage_id = STAGE_LIST[STAGE_LIST.length - 1].id;//        current_stage_status = STAGE_LIST[STAGE_LIST.length - 1].status;    }    buildStageSelection();    for (let item of TOP_TREE_NODES) {        if (item.name === '通用报表') {            item.name = '推荐报表';        }    }    const ORG_TOP_TREE_NODES = JSON.parse(JSON.stringify(TOP_TREE_NODES));    for (let item of TOP_TREE_NODES) {        item.items = JSON.parse(item.items);        if (item.items && item.items.length > 0) {            for (let dtlItem of item.items) {                chkAndSetNode(dtlItem);            }        }    }    for (let item of ORG_TOP_TREE_NODES) {        item.items = JSON.parse(item.items);        if (item.items && item.items.length > 0) {            for (let dtlItem of item.items) {                chkAndSetNode(dtlItem);            }        }    }    buildTplTree();    function chkAndSetNode(parentItem) {        if (parentItem.nodeType === 1) {            parentItem.isParent = true;        }        if (parentItem.items) {            for (let dtlItem of parentItem.items) {                chkAndSetNode(dtlItem);            }        }    }    function buildTplTree() {        if (TOP_TREE_NODES.length > 0) {            //1. 整理模板树 (原始状态的TOP_TREE_NODES包含了推荐报表与定制表,需要分割)            const individualNode = {id: 99999, name: '定制报表', pid: -1, rpt_type: 0, items: [], isParent: true};            for (let tnIdx = TOP_TREE_NODES.length - 1; tnIdx >= 0; tnIdx--) {                if (TOP_TREE_NODES[tnIdx].pid !== -1) {                    TOP_TREE_NODES[tnIdx].isParent = true;                    TOP_TREE_NODES[tnIdx].nodeType = 1;                    individualNode.items.unshift(TOP_TREE_NODES[tnIdx]);                    TOP_TREE_NODES.splice(tnIdx, 1);                }            }            // 1.1 移除未被选择的模板            // filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.common);            TOP_TREE_NODES.unshift(individualNode); //定制在前            // filterUnchkTplTreeNode(TOP_TREE_NODES[0], CUST_TREE_NODES.customize);            //2. 原始的模板树(恢复用)            const individualNodeOrg = {id: 99999, name: '定制报表', pid: -1, rpt_type: 0, items: [], isParent: true};            for (let tnIdx = ORG_TOP_TREE_NODES.length - 1; tnIdx >= 0; tnIdx--) {                if (ORG_TOP_TREE_NODES[tnIdx].pid !== -1) {                    ORG_TOP_TREE_NODES[tnIdx].isParent = true;                    ORG_TOP_TREE_NODES[tnIdx].nodeType = 1;                    individualNodeOrg.items.unshift(ORG_TOP_TREE_NODES[tnIdx]);                    ORG_TOP_TREE_NODES.splice(tnIdx, 1);                }            }            //ORG_TOP_TREE_NODES.push(individualNode);            ORG_TOP_TREE_NODES.unshift(individualNodeOrg);        }    }    function buildStageSelection() {        if (STAGE_LIST.length === 0) {            $("#optionSelectableStages")[0].style.display = 'none';        } else {            $("#optionSelectableStages")[0].style.display = '';            $("#btnCurrentStage")[0].innerText = '第' + current_stage_order + '期';            $("#optionSelectableStages").empty();            if (STAGE_LIST.length > 0 && STAGE_ID < 0) {                for (let i = STAGE_LIST.length; i > 0; i--) {                    if (parseInt(STAGE_LIST[i - 1].status) === 3 && parseInt(STAGE_LIST[i - 1].order) !== current_stage_order) {                        const str = '<a class="dropdown-item" style="cursor:pointer" onclick="changeCurrentStage(this)" stg_id = "' + STAGE_LIST[i - 1].id + '" stg_order="' + STAGE_LIST[i - 1].order + '">第' + STAGE_LIST[i - 1].order + '期</a>';                        $("#optionSelectableStages").append(str);                    }                }            }        }        if (STAGE_ID > 0) {            $("#divSelectableStages")[0].style.display = 'none';        }    }    // $('#divSelectableChanges').select2();    function buildChangeSelection() {        if (CHANGE_LIST.length === 0) {            $('#optionSelectableChanges').html('');        } else {            let html = '';            for (let i = 0; i < CHANGE_LIST.length; i++) {                html += '<option value = "' + CHANGE_LIST[i].id + '">'+ CHANGE_LIST[i].code +'</option>';            }            $('#optionSelectableChanges').html(html);        }        $('#optionSelectableChanges').select2({            language: 'zh-CN',            theme: 'bootstrap4',            selectOnClose: true,            // width: '150',        });        $('#optionSelectableChanges').val(current_change_id ? current_change_id : '').trigger("change");        // if (CHANGE_LIST.length === 0) {        //     $("#optionSelectableChanges")[0].style.display = 'none';        //     $("#btnCurrentChange")[0].innerText = '';        // } else {        //     $("#optionSelectableChanges")[0].style.display = '';        //     $("#btnCurrentChange")[0].innerText = current_change_code;        //        //     $("#optionSelectableChanges").empty();        //     if (CHANGE_LIST.length > 0) {        //         for (let i = 0; i < CHANGE_LIST.length; i++) {        //             if (parseInt(CHANGE_LIST[i].status) === 3 && CHANGE_LIST[i].code !== current_change_code) {        //                 const str = '<a class="dropdown-item" style="cursor:pointer" onclick="changeCurrentChange(this)" change_id = "' + CHANGE_LIST[i].id + '" change_code = "' + CHANGE_LIST[i].code + '">' + CHANGE_LIST[i].code + '</a>';        //                 $("#optionSelectableChanges").append(str);        //             }        //         }        //     }        // }        // if (CHANGE_ID > 0) {        //     $("#divSelectableChanges")[0].style.display = 'none';        // }    }    function buildAdvanceSelection() {        $('#optionSelectableAdvances').html('');        $("#btnCurrentAdvance")[0].innerText = '';        const advanceCols = [];        for (const advance of ADVANCE_LIST) {            if (advanceCols.indexOf(advance.type) === -1) {                advanceCols.push(advance.type);            }        }        for (const advanceAdj of ADVANCE_TYPECOL) {            const ad = _.includes(advanceCols, advanceAdj.type);            if (ad) {                let dispStr = '';                if (current_advance_type === -1 || current_advance_type === advanceAdj.type) {                    current_advance_type = advanceAdj.type;                    current_advance_id = -1;                    $("#btnCurrentAdvance")[0].innerText = advanceAdj.name;                    dispStr = ';display:none';                }                const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentAdvance(this)" data-type = "${advanceAdj.type}">${advanceAdj.name}</a>`;                $("#optionSelectableAdvances").append(str);            }        }        buildAdvancePaySelection(current_advance_type, true);    }    function changeCurrentAdvance(ele) {        $('#optionSelectableAdvances a').show();        $(ele).hide();        current_advance_type = +ele.attributes[3].value;        $('#optionSelectableAdvances').siblings('button').text($(ele).text());        // BUSINESS_ID = material_id;        buildAdvanceSelection();    }    function buildAdvancePaySelection(current_advance_type, needClick = false) {        $("#optionSelectableAdvancePays").empty();        $("#btnCurrentAdvancePay")[0].innerText = '';        const adList = _.orderBy(_.filter(ADVANCE_LIST, { type: current_advance_type }), ['order'], ['desc']);        for (const advance of adList) {            let dispStr = '';            if (current_advance_id === -1 || current_advance_id === advance.id) {                current_advance_id = advance.id;                $("#btnCurrentAdvancePay")[0].innerText = `第${advance.order}期`;                dispStr = ';display:none';            }            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentAdvancePays(this)" advance_id = "${advance.id}">第${advance.order}期</a>`;            $("#optionSelectableAdvancePays").append(str);        }        if (needClick) {            changeCurrentAdvancePays($("#optionSelectableAdvancePays a")[0], !needClick);        }    }    function changeCurrentAdvancePays(ele, refresh = true) {        $('#optionSelectableAdvancePays a').show();        $(ele).hide();        current_advance_id = ele ? +ele.attributes[3].value : -1;        $('#optionSelectableAdvancePays').siblings('button').text($(ele).text());        // BUSINESS_ID = material_id;        if (refresh) buildAdvancePaySelection(current_advance_type);        //还有必要触发归档报表刷新!        //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);        const params = {tenderId: TENDER_ID, business_type, bzId: current_advance_id};        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),            function(result){                $.bootstrapLoading.end();                ARCHIVE_LIST = result.data;                ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                buildTplTree();                rptArchiveObj.iniPage();            }, function(err){                $.bootstrapLoading.end();            }, function(ex){                $.bootstrapLoading.end();            }        );    }    function buildMaterialSelection() {        $("#optionSelectableMaterials").empty();        $("#btnCurrentMaterial")[0].innerText = '';        MATERIAL_LIST.forEach((materialAdj, maIndex) => {            let dispStr = '';            if (current_material_id === -1 && maIndex === 0 || current_material_id === materialAdj.id) {                current_material_id = materialAdj.id;                $("#btnCurrentMaterial")[0].innerText = `第${materialAdj.order}期`;                dispStr = ';display:none';            }            const str = `<a class="dropdown-item" style="cursor:pointer${dispStr}" onclick="changeCurrentMaterial(this)" material_id = "${materialAdj.id}">第${materialAdj.order}期</a>`;            $("#optionSelectableMaterials").append(str);        });    }    function changeCurrentStage(ele) {        // alert('you are selecting: ' + ele.innerText);        current_stage_order = parseInt(ele.attributes.stg_order.value);        current_stage_id = parseInt(ele.attributes.stg_id.value);        for (let i = STAGE_LIST.length; i > 0; i--) {            if (parseInt(STAGE_LIST[i - 1].order) === current_stage_order) {                current_stage_status = STAGE_LIST[i - 1].status;                break;            }        }        buildStageSelection();        //还有必要触发归档报表刷新!        //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);        const params = {prjId: PROJECT_ID, stgId: current_stage_id};        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive", params, 10000, true, getCookie('csrfToken_j'),            function(result){                $.bootstrapLoading.end();                // console.log(result);                ARCHIVE_LIST = result.data;                ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));                rptArchiveObj.iniPage();            }, function(err){                $.bootstrapLoading.end();            }, function(ex){                $.bootstrapLoading.end();            }        );    }    $('body').on('select2:select', '#optionSelectableChanges', function (e) {        const change_id = $(this).val();        const change_code = e.params.data.text;        changeCurrentChange(change_id, change_code);    });    function changeCurrentChange(change_id, change_code) {        // alert('you are selecting: ' + ele.innerText);        current_change_id = change_id;        current_change_code = change_code;        CHANGE_ID = change_id;        BUSINESS_ID = change_id;        buildChangeSelection();        //还有必要触发归档报表刷新!        //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);        const params = {tenderId: TENDER_ID, business_type, bzId: current_change_id};        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),            function(result){                $.bootstrapLoading.end();                ARCHIVE_LIST = result.data;                ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                buildTplTree();                rptArchiveObj.iniPage();            }, function(err){                $.bootstrapLoading.end();            }, function(ex){                $.bootstrapLoading.end();            }        );    }    function changeCurrentMaterial(ele) {        $('#optionSelectableMaterials a').show();        $(ele).hide();        current_material_id = +ele.attributes[3].value;        $('#optionSelectableMaterials').siblings('button').text($(ele).text());        // BUSINESS_ID = material_id;        buildMaterialSelection();        //还有必要触发归档报表刷新!        //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);        const params = {tenderId: TENDER_ID, business_type, bzId: current_material_id};        $.bootstrapLoading.start();        CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),            function(result){                $.bootstrapLoading.end();                ARCHIVE_LIST = result.data;                ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                buildTplTree();                rptArchiveObj.iniPage();            }, function(err){                $.bootstrapLoading.end();            }, function(ex){                $.bootstrapLoading.end();            }        );    }    function sendReportFileMsg() {        if (!needFileMsg[business_type] || !needFileMsg[business_type].valid) return;        if (business_type === 'stage') {            postData('sendReportFileMsg', { sid: current_stage_id, sorder: current_stage_order }, function (result, msg) {                toastr.success(msg);            });        } else {            if (CHANGE_LIST.length === 0) {                toastr.warning('暂无任何归档数据');                return;            }            loadChangeSelect(CHANGE_LIST);            $('#change-select').modal('show');        }    }    function loadChangeSelect(changes) {        const html = [];        for (const c of changes) {            html.push('<tr>');            html.push(`<td><input cid="${c.cid || c.id}" type="checkbox" ${(c.selected ? "checked" : '')}></td>`);            html.push(`<td>${c.code}</td>`);            html.push(`<td>${c.name}</td>`);            html.push(`<td>${moment(c.in_time).format('YYYY-MM-DD')}</td>`);            html.push('</tr>');        }        $('#change-select-list').html(html.join(''));    }    $('body').on('change', '#change-select input[type=checkbox]', function() {        if ($('#change-select input:checked').length > 10) {            this.checked = false;            toastr.warning('最多选择10条数据');        }    });    $('body').on('click', '#change-select-ok', function() {        if (!needFileMsg[business_type]) return;        const select = $('#change-select input:checked');        const id = [];        for (const s of select) {            id.push(s.getAttribute('cid'));        }        postData('sendOtherReportFileMsg', { id, msgType: needFileMsg[business_type].key }, function (result, msg) {            toastr.success(msg);            $('change-select').modal('hide');        });    });    $(function () {        //阻止事件冒泡        //不仅仅要stopPropagation,还要preventDefault        function pauseEvent(e){            if(e.stopPropagation) e.stopPropagation();            if(e.preventDefault) e.preventDefault();            e.cancelBubble=true;            e.returnValue=false;            return false;        }        let pe = 0;        $('#right-spr').mousedown(function (ev) {            $('iframe').css('pointerEvents', 'none');            let e = ev||event;            pauseEvent(e);            pe = 1;        });        $(document).mouseup(function (ev) {            if(pe) {                $('iframe').css('pointerEvents', 'auto');                pe = 0;                let e = ev||event;                pauseEvent(e);            }        });        $('#select-item a').on('click', function () {           $('#select-item a').show();           $(this).hide();           $('#select-item').siblings('button').text($(this).text());           const type = $(this).data('type');           business_type = type;           CHANGE_ID = -1;           BUSINESS_ID = -1;           current_advance_type = -1;           CURRENT_SELECTED_BIZ_TYPE = '';           if (type === 'stage') {               $('#divSelectableStages').show();               $('#divSelectableChanges').hide();               $('#divSelectableAdvances').hide();               $('#divSelectableAdvancePays').hide();               $('#divSelectableMaterials').hide();               // const info = _.find(STAGE_LIST, { order: current_stage_order });               for (let i = STAGE_LIST.length; i > 0; i--) {                   if (parseInt(STAGE_LIST[i - 1].status) === 3) {                       current_stage_order = STAGE_LIST[i - 1].order;                       current_stage_id = STAGE_LIST[i - 1].id;                       break;                   }               }               // current_stage_id = info ? info.id : STAGE_LIST[i -1].id;               // current_stage_order = info ? info.order : STAGE_LIST[i - 1].order;               // 下列树结构重新加载               //还有必要触发归档报表刷新!               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);               const params = {prjId: PROJECT_ID, stgId: current_stage_id};               $.bootstrapLoading.start();               ARCHIVE_LIST = [];               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive", params, 10000, true, getCookie('csrfToken_j'),                   function(result){                       $.bootstrapLoading.end();                       // console.log(result);                       ARCHIVE_LIST = result.data;                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                       TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));                       buildStageSelection();                       buildTplTree();                       rptArchiveObj.iniPage();                   }, function(err){                       $.bootstrapLoading.end();                   }, function(ex){                       $.bootstrapLoading.end();                   }               );           } else if (_.includes(type, 'change')) {               $('#divSelectableStages').hide();               $('#divSelectableAdvances').hide();               $('#divSelectableAdvancePays').hide();               $('#divSelectableChanges').show();               $('#divSelectableMaterials').hide();               // 下列树结构重新加载               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);               const params = {tenderId: TENDER_ID, business_type: type};               $.bootstrapLoading.start();               ARCHIVE_LIST = [];               // ARCHIVE_ENCRYPTION_LIST = [];               // TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));               // rptArchiveObj.iniPage();               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),                   function(result){                       $.bootstrapLoading.end();                       // console.log(result);                       ARCHIVE_LIST = result.data;                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                       CHANGE_LIST = result.changes;                       current_change_id = CHANGE_LIST.length > 0 ? CHANGE_LIST[0].id : -1;                       current_change_code = CHANGE_LIST.length > 0 ? CHANGE_LIST[0].code : '';                       TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                       CHANGE_ID = CHANGE_LIST.length > 0 ? CHANGE_LIST[0].id : -1;                       BUSINESS_ID = CHANGE_LIST.length > 0 ? CHANGE_LIST[0].id : -1;                       buildChangeSelection();                       buildTplTree();                       rptArchiveObj.iniPage();                       current_stage_id = result.stgId;                   }, function(err){                       $.bootstrapLoading.end();                   }, function(ex){                       $.bootstrapLoading.end();                   }               );           } else if (type === 'advance') {               CURRENT_SELECTED_BIZ_TYPE = 'change_prepay'               $('#divSelectableStages').hide();               $('#divSelectableChanges').hide();               $('#divSelectableAdvances').show();               $('#divSelectableAdvancePays').show();               $('#divSelectableMaterials').hide();               // 下列树结构重新加载               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);               const params = {tenderId: TENDER_ID, business_type: type};               $.bootstrapLoading.start();               ARCHIVE_LIST = [];               // ARCHIVE_ENCRYPTION_LIST = [];               // TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));               // rptArchiveObj.iniPage();               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),                   function(result){                       $.bootstrapLoading.end();                       // console.log(result);                       ARCHIVE_LIST = result.data;                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                       ADVANCE_LIST = result.changes;                       // current_advance_id = ADVANCE_LIST.length > 0 ? ADVANCE_LIST[0].id : -1;                       TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                       BUSINESS_ID = ADVANCE_LIST.length > 0 ? ADVANCE_LIST[0].id : -1;                       buildAdvanceSelection();                       buildTplTree();                       rptArchiveObj.iniPage();                       current_stage_id = result.stgId;                   }, function(err){                       $.bootstrapLoading.end();                   }, function(ex){                       $.bootstrapLoading.end();                   }               );           } else if (type === 'material') {               $('#divSelectableStages').hide();               $('#divSelectableChanges').hide();               $('#divSelectableAdvances').hide();               $('#divSelectableAdvancePays').hide();               $('#divSelectableMaterials').show();               // 下列树结构重新加载               //rptArchiveObj.onClick(null, null, rptArchiveObj.currentNode);               const params = {tenderId: TENDER_ID, business_type: type};               $.bootstrapLoading.start();               ARCHIVE_LIST = [];               // ARCHIVE_ENCRYPTION_LIST = [];               // TOP_TREE_NODES = JSON.parse(JSON.stringify(ORG_TOP_TREE_NODES));               // rptArchiveObj.iniPage();               CommonAjax.postXsrfEx("/tender/report_api/getReportArchive4bz", params, 10000, true, getCookie('csrfToken_j'),                   function(result){                       $.bootstrapLoading.end();                       // console.log(result);                       ARCHIVE_LIST = result.data;                       ARCHIVE_ENCRYPTION_LIST = result.encryptionData;                       MATERIAL_LIST = result.changes;                       current_material_id = MATERIAL_LIST.length > 0 ? MATERIAL_LIST[0].id : -1;                       TOP_TREE_NODES = JSON.parse(JSON.stringify(result.rpt_tpl_data));                       // BUSINESS_ID = MATERIAL_LIST.length > 0 ? MATERIAL_LIST[0].id : -1;                       buildMaterialSelection();                       buildTplTree();                       rptArchiveObj.iniPage();                       current_stage_id = result.stgId;                   }, function(err){                       $.bootstrapLoading.end();                   }, function(ex){                       $.bootstrapLoading.end();                   }               );           }           if (needFileMsg[type] && needFileMsg[type].valid) {               $('#file-msg').show();           } else {               $('#file-msg').hide();           }        });    })    rptArchiveObj.iniPage();    $(document).ready(() => {        $('#change-select-date').datepicker({            onSelect: function(selectedDate) {                const rows = $('#change-select-list tr');                for (const r of rows) {                    const cid = $(r).find('input').attr('cid');                    const change = CHANGE_LIST.find(x => { return x.cid ? x.cid === cid : c.id === cid; });                    if (moment(selectedDate).isBefore(change.in_time)) {                        $(r).show();                    } else {                        $(r).hide();                    }                }            }        });    });</script>
 |