| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050 | 
							- 'use strict';
 
- /**
 
-  *
 
-  *
 
-  * @author Mai
 
-  * @date
 
-  * @version
 
-  */
 
- const rptCustomObj = (function () {
 
-     // 审批人选择
 
-     const sAuditSelect = 'audit_select';
 
-     let stageFlow = [];
 
-     // 汇总表
 
-     const sGatherSelect = 'gather_select';
 
-     let gsObj = {
 
-         setting: null,
 
-         gsSheet: null,
 
-         grSheet: null,
 
-         tenderSourceTree: null,
 
-         grArray: [],
 
-         orgSelect: null,
 
-     };
 
-     // 期选择
 
-     const sStageSelect = 'stage_select';
 
-     const grSpreadSetting = {
 
-         baseCols: [
 
-             {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 240, formatter: '@', readOnly: true},
 
-         ],
 
-         extraCols: [
 
-             {title: '%s', colSpan: '1', rowSpan: '1', field: '%s', hAlign: 1, vAlign: '1', width: 60, cellType: 'checkbox', readOnly: true},
 
-         ],
 
-         emptyRows: 0,
 
-         headRows: 1,
 
-         headRowHeight: [32],
 
-         defaultRowHeight: 21,
 
-         headerFont: '12px 微软雅黑',
 
-         font: '12px 微软雅黑',
 
-         headColWidth: []
 
-     };
 
-     const gatherSelectSpreadObj = {
 
-         _getStageSelectHtml: function (valid) {
 
-             const html = [];
 
-             for (let i = 1; i <= valid; i++) {
 
-                 html.push(`<option value="${i}">第${i}期</option>`);
 
-             }
 
-             return html.join('');
 
-         },
 
-         _rebuildStageSelect: function () {
 
-             if (gsObj.setting.type === 'stage') {
 
-                 const validStage = _.min(_.map(gsObj.grArray, 'stageCount'));
 
-                 $('#gather-stage').html(this._getStageSelectHtml(validStage));
 
-             } else if (gsObj.setting.type === 'stage-zone') {
 
-                 const validStage = _.max(_.map(gsObj.grArray, 'stageCount'));
 
-                 $('#gather-stage-begin').html(this._getStageSelectHtml(validStage));
 
-                 $('#gather-stage-end').html(this._getStageSelectHtml(validStage));
 
-             }
 
-         },
 
-         _addTender: function (tender) {
 
-             const gr = gsObj.grArray.find(function (x) {
 
-                 return x.tid === tender.tid;
 
-             });
 
-             const t = {tid: tender.tid, name: tender.name, stageCount: tender.stageCount};
 
-             if (!gr) gsObj.grArray.push(t);
 
-             return t;
 
-         },
 
-         _removeTender: function (tender) {
 
-             const gri = gsObj.grArray.findIndex(function (x, i, arr) {
 
-                 return x.tid === tender.tid;
 
-             });
 
-             if (gri >= 0) gsObj.grArray.splice(gri, 1);
 
-         },
 
-         reloadResultData: function () {
 
-             SpreadJsObj.reLoadSheetData(gsObj.grSheet);
 
-             this._rebuildStageSelect();
 
-         },
 
-         gsButtonClicked: function (e, info) {
 
-             if (!info.sheet.zh_setting) return;
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field !== 'selected') return;
 
-             const node = SpreadJsObj.getSelectObject(info.sheet);
 
-             node.selected = !node.selected;
 
-             if (node.children && node.children.length > 0) {
 
-                 const posterity = gsObj.tenderSourceTree.getPosterity(node);
 
-                 for (const p of posterity) {
 
-                     p.selected = node.selected;
 
-                     if (!p.children || p.children.length === 0){
 
-                         if (p.selected) {
 
-                             gatherSelectSpreadObj._addTender(p);
 
-                         } else {
 
-                             gatherSelectSpreadObj._removeTender(p);
 
-                         }
 
-                     }
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row, posterity.length + 1);
 
-             } else {
 
-                 if (node.selected) {
 
-                     gatherSelectSpreadObj._addTender(node);
 
-                 } else {
 
-                     gatherSelectSpreadObj._removeTender(node);
 
-                 }
 
-                 SpreadJsObj.reLoadRowData(info.sheet, info.row, 1);
 
-             }
 
-             gatherSelectSpreadObj.reloadResultData();
 
-         },
 
-         grButtonClicked: function (e, info) {
 
-             if (!info.sheet.zh_setting) return;
 
-             const col = info.sheet.zh_setting.cols[info.col];
 
-             if (col.field === 'name') return;
 
-             const node = SpreadJsObj.getSelectObject(info.sheet);
 
-             const refreshRows = [info.row];
 
-             node[col.field] = !node[col.field];
 
-             for (const rCol of info.sheet.zh_setting.cols) {
 
-                 if (rCol.field !== 'name' && rCol.field !== col.field) {
 
-                     node[rCol.field] = false;
 
-                 }
 
-             }
 
-             if (node[col.field]) {
 
-                 for (const [i, gra] of gsObj.grArray.entries()) {
 
-                     if (gra[col.field] && gra.tid !== node.tid) {
 
-                         gra[col.field] = false;
 
-                         refreshRows.push(i);
 
-                     }
 
-                 }
 
-             }
 
-             SpreadJsObj.reLoadRowsData(info.sheet, refreshRows);
 
-         },
 
-         initSelectTenders: function (tenders) {
 
-             if (!tenders) return;
 
-             const specCol = gsObj.setting.special ? gsObj.setting.special : [];
 
-             const select = [];
 
-             for (const node of gsObj.tenderSourceTree.nodes) {
 
-                 node.selected = false;
 
-             }
 
-             for (const t of tenders) {
 
-                 const tender = gsObj.tenderSourceTree.nodes.find(function (x) { return x.tid === t.tid});
 
-                 if (!tender) continue;
 
-                 tender.selected = true;
 
-                 select.push(tender);
 
-                 const st = this._addTender(tender);
 
-                 for (const sc of specCol) {
 
-                     st[sc.key] = t[sc.key];
 
-                 }
 
-             }
 
-             SpreadJsObj.reLoadColsData(gsObj.gsSheet, [0]);
 
-             if (select.length > 0) SpreadJsObj.locateTreeNode(gsObj.gsSheet, select[0].tmt_id);
 
-             this.reloadResultData();
 
-         },
 
-     };
 
-     // 材差 - 期选择
 
-     const sMaterialSumSelect = 'material_sum_select';
 
-     // 变更令选择
 
-     const sChangeSelect = 'change_select';
 
-     const changeObj = {
 
-         changes: null,
 
-         latestPush: null,
 
-         loadChanges: async function () {
 
-             const self = this;
 
-             const result = await postDataAsync(`/tender/${window.location.pathname.split('/')[2]}/load`, { filter: 'change'});
 
-             this.changes = result.change;
 
-             const html = [];
 
-             for (const c of this.changes) {
 
-                 html.push('<tr>', `<td class="text-center"><input type="checkbox" name="change-select-check" value="${c.cid}"></td>`, `<td>${c.code}</td>`, `<td>${c.name}</td>`, '</tr>');
 
-             }
 
-             $('#change-select-list').html(html.join(''));
 
-             $('[name=change-select-check]').click(function () {
 
-                 const selectChange = $('[name=change-select-check]:checked');
 
-                 const selectHtml = [];
 
-                 for (const sc of selectChange) {
 
-                     const c = self.changes.find(x => { return x.cid === sc.value });
 
-                     selectHtml.push(`<tr><td class="text-center">${selectHtml.length + 1}</td><td>${c.code}</td><td>${c.name}</td></tr>`);
 
-                 }
 
-                 $('#change-select-result').html(selectHtml.join(''));
 
-             });
 
-             $('#change-select-all').click(function () {
 
-                 const change = $('[name=change-select-check]');
 
-                 const selectHtml = [];
 
-                 for (const sc of change) {
 
-                     sc.checked = this.checked;
 
-                     if (this.checked) {
 
-                         const c = self.changes.find(x => { return x.cid === sc.value });
 
-                         selectHtml.push(`<tr><td class="text-center">${selectHtml.length + 1}</td><td>${c.code}</td><td>${c.name}</td></tr>`);
 
-                     }
 
-                 }
 
-                 $('#change-select-result').html(selectHtml.join(''));
 
-             });
 
-         },
 
-         show: async function (title, resolve) {
 
-             this.latestPush = null;
 
-             $('#change-select-title').html(title);
 
-             if (!this.changes) {
 
-                 await this.loadChanges();
 
-             }
 
-             if (resolve) {
 
-                 setTimeout(() => { $("#change-select").modal('show'); }, 1000);
 
-             } else {
 
-                 $('#change-select').modal('show');
 
-             }
 
-             $('#change-select-ok').unbind('click');
 
-             $('#change-select-ok').bind('click', () => {
 
-                 rptCustomObj.resetChangeSelect(resolve);
 
-             });
 
-         }
 
-     };
 
-     const getStageFlowSelectHtml = function (select, id) {
 
-         const html = [];
 
-         html.push('<select style="width: 80%" id="' + id + '" sf-title="' + select.title + '">');
 
-         const maxOrder = stageFlow.reduce((rst, sf) => { return sf.audit_order && sf.audit_order > rst ? sf.audit_order : rst;}, 1);
 
-         for (const sf of stageFlow) {
 
-             const flow = sf.audit_order
 
-                 ? ( sf.audit_order === maxOrder ? '终审' : transFormToChinese(sf.audit_order) + '审')
 
-                 : '原报';
 
-             html.push(`<option ${sf.visible ? '' : 'style="display: none"'} value="${sf.audit_order}">${sf.name}-${sf.role}(${flow})</option>`);
 
-         }
 
-         html.push('</select>');
 
-         return html.join('');
 
-     };
 
-     const checkAsSelectValid = function (validFlow, asSelect) {
 
-         for (const s of asSelect) {
 
-             const f = validFlow.find(function (x) {
 
-                 return x.aid === s.aid && x.order === s.order;
 
-             });
 
-             if (!f) {
 
-                 $('#audit-select-hint').html('本期审批流程发生变动,原审批人选择不适配,需重新选择').show();
 
-                 return false;
 
-             }
 
-         }
 
-         $('#audit-select-hint').hide();
 
-         return true;
 
-     };
 
-     const initAuditSelect = function (asSetting, asSelect) {
 
-         const setting = JSON.parse(asSetting), select = asSelect;
 
-         $('#audit-select-title').html(setting.title);
 
-         if (setting.hideSign) {
 
-             $('#pnl_eSignature').hide();
 
-         } else {
 
-             $('#pnl_eSignature').show();
 
-         }
 
-         $('#pnl_audit_select div button').html('<i class="fa fa-pencil"></i><br>' + (setting.caption || '审批人选择'));
 
-         const html = [];
 
-         for (const [i, s] of setting.select.entries()) {
 
-             html.push('<tr>');
 
-             html.push('<td>', s.title, '</td>');
 
-             html.push('<td>', getStageFlowSelectHtml(s, 'sf-' + i), '</td>');
 
-             html.push('</tr>');
 
-         }
 
-         $('#audit-select-list').html(html.join(''));
 
-         for (const [i, s] of setting.select.entries()) {
 
-             const obj = $('#sf-' + i);
 
-             const s = select[i];
 
-             obj[0].selectedIndex = s ? stageFlow.findIndex(function (x) {
 
-                 return x.order === s.order && x.aid === s.aid;
 
-             }) : -1;
 
-         }
 
-         if (asSelect.length === 0 || !checkAsSelectValid(stageFlow, asSelect)) {
 
-             $('#audit-select').modal('show');
 
-         }
 
-     };
 
-     const initGrSpreadSetting = function (gsSetting) {
 
-         grSpreadSetting.cols = [];
 
-         for (const bc of grSpreadSetting.baseCols) {
 
-             grSpreadSetting.cols.push(bc);
 
-             if (bc.field === 'name') bc.width = gsSetting.nameColWidth ? gsSetting.nameColWidth : 240;
 
-         }
 
-         if (gsSetting.special) {
 
-             for (const s of gsSetting.special) {
 
-                 for (const ec of grSpreadSetting.extraCols) {
 
-                     const c = {};
 
-                     c.title = ec.title.replace('%s', s.title);
 
-                     c.colSpan = ec.colSpan;
 
-                     c.field = ec.field.replace('%s', s.key);
 
-                     c.hAlign = ec.hAlign;
 
-                     c.width = s.width ? s.width : ec.width;
 
-                     c.cellType = ec.cellType;
 
-                     c.readOnly = ec.readOnly;
 
-                     grSpreadSetting.cols.push(c);
 
-                 }
 
-             }
 
-         }
 
-     };
 
-     const initGatherSelect = function (gsSetting, gsSelect, rptName, resolve = null) {
 
-         gsObj.grArray = [];
 
-         gsObj.setting = JSON.parse(gsSetting);
 
-         gsObj.orgSelect = gsSelect;
 
-         $('#gather-select-count').html(gsSelect ? gsSelect.tenders.length : 0);
 
-         $('#gather-select-title').html(gsObj.setting.title + (rptName ? '-' + rptName : ''));
 
-         initGrSpreadSetting(gsObj.setting);
 
-         SpreadJsObj.initSheet(gsObj.grSheet, grSpreadSetting);
 
-         // 初始化选择结果
 
-         SpreadJsObj.loadSheetData(gsObj.grSheet, SpreadJsObj.DataType.Data, gsObj.grArray);
 
-         gatherSelectSpreadObj.initSelectTenders(gsSelect ? gsSelect.tenders : []);
 
-         $('[name=gather-type]').hide();
 
-         if (gsObj.setting.type === 'month' || gsObj.setting.type === 'months') $('#gather-by-month').show();
 
-         if (gsObj.setting.type === 'zone') $('#gather-by-zone').show();
 
-         if (gsObj.setting.type === 'stage') $('#gather-by-stage').show();
 
-         if (gsObj.setting.type === 'stage-zone') $('#gather-by-stage-zone').show();
 
-         if (gsObj.setting.type === 'custom-zone') $('#gather-by-custom-zone').show();
 
-         if (gsSelect) {
 
-             if (gsSelect.zone) {
 
-                 $('#gather-zone').val(gsSelect.zone ? gsSelect.zone : '');
 
-             } else if (gsSelect.custom_zone) {
 
-                 $('#gather-custom-zone').val(gsSelect.custom_zone ? gsSelect.custom_zone : '');
 
-             } else if (gsSelect.month) {
 
-                 $('#gather-month').val(gsSelect.month ? gsSelect.month: '');
 
-             } else if (gsSelect.stage) {
 
-                 $('#gather-stage').val(gsSelect.stage || '');
 
-             } else if (gsSelect.stage_zone) {
 
-                 const [stageBegin, stageEnd] = gsSelect.stage_zone ? gsSelect.stage_zone.split(':') : ['', ''];
 
-                 $('#gather-stage-begin').val(stageBegin);
 
-                 $('#gather-stage-end').val(stageEnd);
 
-             }
 
-         }
 
-         // 初始化
 
-         if (resolve) {
 
-             setTimeout(() => { $("#gather-select").modal('show'); }, 1000);
 
-         } else {
 
-             $("#gather-select").modal('show');
 
-         }
 
-         $('#gather-select-ok').unbind('click');
 
-         $('#gather-select-ok').bind('click', () => {
 
-             rptCustomObj.resetGatherSelect(resolve);
 
-             // $("#gather-select").modal('hide');
 
-         });
 
-     };
 
-     const initStageSelect = function (gsSetting, gsSelect, rptName, resolve = null) {
 
-         const setting = JSON.parse(gsSetting);
 
-         $('#stage-select-count').html(gsSelect && gsSelect.stages ? gsSelect.stages.length : 0);
 
-         $('#stage-select-title').html(setting.title + (rptName ? '-' + rptName : ''));
 
-         // 初始化选择结果
 
-         $('#stage-select-hint').attr('min-select', setting.min).attr('max-select', setting.max).hide();
 
-         for (const sc of $('[name=stage-select-check]')) {
 
-             sc.checked = false;
 
-         }
 
-         if (gsSelect && gsSelect.stages) {
 
-             for (const s of gsSelect.stages) {
 
-                 $('#stage-select-' + s)[0].checked = true;
 
-             }
 
-         }
 
-         if (resolve) {
 
-             setTimeout(() => { $("#stage-select").modal('show'); }, 1000);
 
-         } else {
 
-             $("#stage-select").modal('show');
 
-         }
 
-         $('#stage-select-ok').unbind('click');
 
-         $('#stage-select-ok').bind('click', () => {
 
-             rptCustomObj.resetStageSelect(resolve);
 
-             // $("#stage-select").modal('hide');
 
-         });
 
-         $('#stage-select-all').unbind('click');
 
-         $('#stage-select-all').bind('click', function () {
 
-             const material = $('[name=stage-select-check]');
 
-             for (const m of material) {
 
-                 m.checked = this.checked;
 
-             }
 
-         });
 
-     };
 
-     const initChangeSelect = function (gsSetting, rptName, resolve = null) {
 
-         changeObj.show('选择工程变更' + (rptName ? '-' + rptName : ''), resolve);
 
-     };
 
-     const initMaterialSumSelect = function (gsSetting, gsSelect, rptName, resolve = null) {
 
-         const setting = JSON.parse(gsSetting);
 
-         $('#material-sum-select-count').html(gsSelect && gsSelect.materials ? gsSelect.materials.length : 0);
 
-         $('#material-sum-select-title').html((setting.title || '请选择材差期') + (rptName ? '-' + rptName : ''));
 
-         // 初始化选择结果
 
-         $('#material-sum-select-hint').attr('min-select', setting.min).attr('max-select', setting.max).hide();
 
-         for (const sc of $('[name=material-sum-select-check]')) {
 
-             sc.checked = false;
 
-         }
 
-         if (gsSelect && gsSelect.materials) {
 
-             for (const s of gsSelect.materials) {
 
-                 $('#material-sum-select-' + s)[0].checked = true;
 
-             }
 
-         }
 
-         if (resolve) {
 
-             setTimeout(() => { $("#material-sum-select").modal('show'); }, 1000);
 
-         } else {
 
-             $("#material-sum-select").modal('show');
 
-         }
 
-         $('#material-sum-select-ok').unbind('click');
 
-         $('#material-sum-select-ok').bind('click', () => {
 
-             rptCustomObj.resetMaterialSumSelect(resolve);
 
-             // $("#stage-select").modal('hide');
 
-         });
 
-         $('#material-sum-select-all').unbind('click');
 
-         $('#material-sum-select-all').bind('click', function () {
 
-             const material = $('[name=material-sum-select-check]');
 
-             for (const m of material) {
 
-                 m.checked = this.checked;
 
-             }
 
-         });
 
-     };
 
-     const init = function (cDefine, sfData, cSelect, rptName, resolve = null) {
 
-         stageFlow = sfData;
 
-         if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
 
-             $('#pnl_audit_select').show();
 
-             initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect[sAuditSelect] : []);
 
-         } else {
 
-             $('#pnl_eSignature').show();
 
-             $('#pnl_audit_select').hide();
 
-         }
 
-         if (cDefine && cDefine[sGatherSelect] && cDefine[sGatherSelect].enable && cDefine[sGatherSelect].setting) {
 
-             $('#pnl_gather_select').show();
 
-             initGatherSelect(cDefine[sGatherSelect].setting, cSelect ? cSelect[sGatherSelect] : null, rptName, resolve);
 
-         } else {
 
-             $('#pnl_gather_select').hide();
 
-         }
 
-         if (cDefine && cDefine[sStageSelect] && cDefine[sStageSelect].enable && cDefine[sStageSelect].setting) {
 
-             $('#pnl_stage_select').show();
 
-             initStageSelect(cDefine[sStageSelect].setting, cSelect ? cSelect[sStageSelect] : null, rptName, resolve);
 
-         } else {
 
-             $('#pnl_stage_select').hide();
 
-         }
 
-         if (cDefine && cDefine[sMaterialSumSelect] && cDefine[sMaterialSumSelect].enable && cDefine[sMaterialSumSelect].setting) {
 
-             $('#pnl_material_sum_select').show();
 
-             initMaterialSumSelect(cDefine[sMaterialSumSelect].setting, cSelect ? cSelect[sMaterialSumSelect] : null, rptName, resolve);
 
-         } else {
 
-             $('#pnl_material_sum_select').hide();
 
-         }
 
-         if (cDefine && cDefine[sChangeSelect] && cDefine[sChangeSelect].enable) {
 
-             initChangeSelect(cDefine[sChangeSelect].setting, rptName, resolve);
 
-         }
 
-     };
 
-     const reloadReportData = async function (result) {
 
-         let pageRst = result.data;
 
-         if (result.signatureRelInfo && result.signatureRelInfo.length > 0) {
 
-             CURRENT_ROLE_REL_ID = result.signatureRelInfo[0].id;
 
-             ROLE_REL_LIST = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
 
-             STAGE_AUDIT = result.stageAudit;
 
-             rptSignatureHelper.originalRoleRelList = zTreeOprObj._parseRoleRelList(result.signatureRelInfo[0].rel_content);
 
-             rptSignatureHelper.mergeSignDate(pageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
 
-             rptSignatureHelper.mergeSignature(pageRst, ROLE_REL_LIST, true, getStageStatus() !== 3);
 
-             await rptSignatureHelper.resetDummySignature(pageRst, ROLE_REL_LIST, getStageStatus() !== 3); // 这里重新整理签章坐标信息(因签章大小在后台暂时获取不到,挪到前端处理)
 
-             rptSignatureHelper.mergeSignAudit(pageRst, ROLE_REL_LIST, STAGE_AUDIT, getStageStatus() !== 3);
 
-             if (PAGE_SHOW.isTextSignature) {
 
-                 resetTextSignature(pageRst, getStageStatus() !== 3);
 
-             }
 
-         } else {
 
-             CURRENT_ROLE_REL_ID = -1;
 
-             ROLE_REL_LIST = [];
 
-         }
 
-         let canvas = zTreeOprObj.canvas;
 
-         if (pageRst && pageRst.items && pageRst.items.length > 0) {
 
-             zTreeOprObj.resetAfter(pageRst);
 
-             zTreeOprObj.currentRptPageRst = pageRst;
 
-             zTreeOprObj.maxPages = pageRst.items.length;
 
-             zTreeOprObj.currentPage = 1;
 
-             zTreeOprObj.displayPageValue();
 
-             let size = JpcCanvasOutput.getReportSizeInPixel(zTreeOprObj.currentRptPageRst, getScreenDPI());
 
-             canvas.width = size[0] + 20;
 
-             if (size[1] > size[0]) {
 
-                 canvas.height = size[1] + 100;
 
-             } else {
 
-                 canvas.height = size[1] + 50;
 
-             }
 
-             // zTreeOprObj.resetESignature(zTreeOprObj.currentRptPageRst);
 
-             rptSignatureHelper.buildSelectableAccount();
 
-             rptSignatureHelper.buildSelectableAccountUsed();
 
-             rptSignatureHelper.buildRoleDom(ROLE_LIST);
 
-             zTreeOprObj.showPage(1, canvas);
 
-         } else {
 
-             //返回了无数据表
 
-             JpcCanvasOutput.cleanCanvas(canvas);
 
-             JpcCanvasOutput.drawPageBorder(zTreeOprObj.currentRptPageRst, canvas, getScreenDPI());
 
-         }
 
-         rptCustomObj.init(result.customDefine, result.stageFlow, result.customSelect);
 
-         try {
 
-             if (is_debug && result.debugInfo) {
 
-                 console.log('含有key的debug信息:');
 
-                 for (const k in result.debugInfo.key) {
 
-                     console.log(k + ':', ...result.debugInfo.key[k]);
 
-                 }
 
-                 console.log('其他debug信息:');
 
-                 for (const di of result.debugInfo.other) {
 
-                     console.log(...di);
 
-                 }
 
-             }
 
-         } catch(err) {
 
-         }
 
-         zTreeOprObj.countChkedRptTpl();
 
-     };
 
-     const getCommonParams = function (data) {
 
-         data.pageSize = rptControlObj.getCurrentPageSize();
 
-         data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
 
-         data.custCfg = CUST_CFG;
 
-         data.project_id = PROJECT_ID;
 
-         data.tender_id = TENDER_ID;
 
-         data.stage_id = getStageId();
 
-         data.stage_status = getStageStatus();
 
-         data.stage_order = getStageOrder();
 
-         data.stage_times = getStageTimes();
 
-         data.material_order = getMaterialOrder();
 
-     };
 
-     const resetAuditSelect = function () {
 
-         const selObj = $('select', '#audit-select-list');
 
-         const data = { audit_select: [], closeWatermark: getCloseWatermark() };
 
-         getCommonParams(data);
 
-         for (const s of selObj) {
 
-             const sf = stageFlow[s.selectedIndex];
 
-             if (!sf) {
 
-                 $('#audit-select-hint').html('未选择' + s.attributes['sf-title'].value).show();
 
-                 return;
 
-             }
 
-             data.audit_select.push({...sf, sort: sf.audit_order});
 
-         }
 
-         $('#audit-select-hint').hide();
 
-         postData('/report/cDefine', data, function (result) {
 
-             reloadReportData(result);
 
-             $('#audit-select').modal('hide');
 
-             rptArchiveObj.toggleBtn(true);
 
-             if (PAGE_SHOW.showArchive) {
 
-                 rptArchiveObj.showArchivedItem(zTreeOprObj.currentNode);
 
-             }
 
-         });
 
-     };
 
-     const resetGatherSelect = function (resolve = null) {
 
-         const data = {}, hintObj = $('#gather-hint');
 
-         if (!resolve) getCommonParams(data);
 
-         data[sGatherSelect] = {
 
-             tenders: [],
 
-             type: gsObj.setting.type,
 
-         };
 
-         const specCol = gsObj.setting.special ? gsObj.setting.special : [];
 
-         for (const sc of specCol) {
 
-             sc.sCount = 0;
 
-         }
 
-         for (const gra of gsObj.grArray) {
 
-             const ra = {tid: gra.tid};
 
-             for (const sc of specCol) {
 
-                 if (gra[sc.key]) {
 
-                     ra[sc.key] = true;
 
-                     sc.sCount += 1;
 
-                 }
 
-             }
 
-             data[sGatherSelect].tenders.push(ra);
 
-         }
 
-         for (const sc of specCol) {
 
-             if (sc.sCount === 0) {
 
-                 hintObj.html('请选择 ' + sc.title).show();
 
-                 return;
 
-             }
 
-         }
 
-         if (gsObj.setting.onlySpec) {
 
-             if (data[sGatherSelect].tenders.length > specCol.length) {
 
-                 hintObj.html('请勿选择普通汇总项目').show();
 
-                 return;
 
-             }
 
-         } else {
 
-             if (data[sGatherSelect].tenders.length <= specCol.length) {
 
-                 hintObj.html('请至少选择1个普通汇总项目').show();
 
-                 return;
 
-             }
 
-         }
 
-         if (gsObj.setting.type === 'month' || gsObj.setting.type === 'months') {
 
-             data[sGatherSelect].month = $('#gather-month').val();
 
-             if (data[sGatherSelect].month === '') {
 
-                 hintObj.html('请选择 汇总年月').show();
 
-                 return;
 
-             }
 
-         } else if (gsObj.setting.type === 'zone') {
 
-             data[sGatherSelect].zone = $('#gather-zone').val();
 
-             if (data[sGatherSelect].zone === '') {
 
-                 hintObj.html('请选择 汇总周期').show();
 
-                 return;
 
-             } else if(data[sGatherSelect].zone.indexOf(' - ') < 0) {
 
-                 hintObj.html('请选择 完整汇总周期').show();
 
-                 return;
 
-             }
 
-         } else if (gsObj.setting.type === 'stage') {
 
-             data[sGatherSelect].stage = _.toInteger($('#gather-stage').val()) || 0;
 
-             const validStage = _.min(_.map(gsObj.grArray, 'stageCount'));
 
-             if (!data[sGatherSelect].stage) {
 
-                 hintObj.html('请选择 汇总期').show();
 
-                 return;
 
-             }
 
-             if (data[sGatherSelect].stage > validStage) {
 
-                 hintObj.html('选择的期无效,请重新选择').show();
 
-                 return;
 
-             }
 
-         } else if (gsObj.setting.type === 'stage-zone') {
 
-             const stageBegin = _.toInteger($('#gather-stage-begin').val()) || 0;
 
-             const stageEnd = _.toInteger($('#gather-stage-end').val()) || 0;
 
-             const validStage = _.max(_.map(gsObj.grArray, 'stageCount'));
 
-             if (!stageBegin || !stageEnd) {
 
-                 hintObj.html('请选择 汇总开始期与结束期').show();
 
-                 return;
 
-             }
 
-             if (stageEnd <= stageBegin) {
 
-                 hintObj.html('结束期应大于开始期').show();
 
-                 return;
 
-             }
 
-             if (stageEnd > validStage) {
 
-                 hintObj.html('选择的期无效,请重新选择').show();
 
-                 return;
 
-             }
 
-             data[sGatherSelect].stage_zone = stageBegin + ':' + stageEnd;
 
-         } else if (gsObj.setting.type === 'custom-zone') {
 
-             data[sGatherSelect].custom_zone = $('#gather-custom-zone').val();
 
-             if (data[sGatherSelect].custom_zone === '') {
 
-                 hintObj.html('请选择 汇总周期').show();
 
-                 return;
 
-             } else if(data[sGatherSelect].custom_zone.indexOf(' - ') < 0) {
 
-                 hintObj.html('请选择 完整汇总周期').show();
 
-                 return;
 
-             }
 
-         }
 
-         if (data[sGatherSelect].tenders.length > 20) {
 
-             hintObj.html('您选择的标段过多,请移除部分').show();
 
-             return;
 
-         }
 
-         hintObj.hide();
 
-         if (resolve) {
 
-             resolve(data);
 
-             rptArchiveObj.toggleBtn(false);
 
-         } else {
 
-             postData('/report/cDefine', data, function (result) {
 
-                 reloadReportData(result);
 
-                 const gather_select = customSelects.gather_select.find(function (x) {
 
-                     return x.id === zTreeOprObj.currentNode.refId;
 
-                 });
 
-                 if (gather_select) {
 
-                     gather_select.gather_select = data[sGatherSelect];
 
-                 }
 
-                 $('#gather-select-count').html(data[sGatherSelect].tenders.length);
 
-                 $('#gather-select').modal('hide');
 
-                 rptArchiveObj.toggleBtn(true);
 
-                 if (PAGE_SHOW.showArchive) {
 
-                     rptArchiveObj.showArchivedItem(zTreeOprObj.currentNode);
 
-                 }
 
-             });
 
-         }
 
-     };
 
-     const resetStageSelect = function (resolve = null) {
 
-         const data = {}, hintObj = $('#stage-select-hint');
 
-         if (!resolve) getCommonParams(data);
 
-         data[sStageSelect] = {
 
-             stages: [],
 
-         };
 
-         for (const sc of $('[name=stage-select-check]:checked')) {
 
-             data[sStageSelect].stages.push(parseInt($(sc).attr('stage-order')));
 
-         }
 
-         if (data[sStageSelect].stages.length < parseInt(hintObj.attr('min-select'))) {
 
-             hintObj.html('请至少选择' + hintObj.attr('min-select') + '期数据').show();
 
-             return;
 
-         } else if (data[sStageSelect].stages.length > parseInt(hintObj.attr('max-select'))) {
 
-             hintObj.html('最多只能选择' + hintObj.attr('max-select') + '期数据').show();
 
-             return;
 
-         }
 
-         hintObj.hide();
 
-         if (resolve) {
 
-             resolve(data);
 
-         } else {
 
-             postData('/report/cDefine', data, function (result) {
 
-                 reloadReportData(result);
 
-                 const stage_select = customSelects.stage_select.find(function (x) {
 
-                     return x.id === zTreeOprObj.currentNode.refId;
 
-                 });
 
-                 if (stage_select) {
 
-                     stage_select.stage_select = data[sStageSelect];
 
-                 }
 
-                 $('#stage-select-count').html(data[sStageSelect].stages.length);
 
-                 $('#stage-select').modal('hide');
 
-                 rptArchiveObj.toggleBtn(true);
 
-                 if (PAGE_SHOW.showArchive) {
 
-                     rptArchiveObj.showArchivedItem(zTreeOprObj.currentNode);
 
-                 }
 
-             });
 
-         }
 
-     };
 
-     const resetMaterialSumSelect = function (resolve = null) {
 
-         const data = {}, hintObj = $('#material-sum-select-hint');
 
-         if (!resolve) getCommonParams(data);
 
-         data[sMaterialSumSelect] = {
 
-             materials: [],
 
-         };
 
-         for (const mc of $('[name=material-sum-select-check]:checked')) {
 
-             data[sMaterialSumSelect].materials.push(parseInt($(mc).attr('material-order')));
 
-         }
 
-         if (data[sMaterialSumSelect].materials.length < parseInt(hintObj.attr('min-select'))) {
 
-             hintObj.html('请至少选择' + hintObj.attr('min-select') + '期数据').show();
 
-             return;
 
-         } else if (data[sMaterialSumSelect].materials.length > parseInt(hintObj.attr('max-select'))) {
 
-             hintObj.html('最多只能选择' + hintObj.attr('max-select') + '期数据').show();
 
-             return;
 
-         }
 
-         hintObj.hide();
 
-         if (resolve) {
 
-             resolve(data);
 
-         } else {
 
-             postData('/report/cDefine', data, function (result) {
 
-                 reloadReportData(result);
 
-                 const material_sum_select = customSelects[sMaterialSumSelect].find(function (x) {
 
-                     return x.id === zTreeOprObj.currentNode.refId;
 
-                 });
 
-                 if (material_sum_select) {
 
-                     material_sum_select.material_sum_select = data[sMaterialSumSelect];
 
-                 }
 
-                 $('#material-sum-select-count').html(data[sMaterialSumSelect].materials.length);
 
-                 $('#material-sum-select').modal('hide');
 
-                 rptArchiveObj.toggleBtn(true);
 
-                 if (PAGE_SHOW.showArchive) {
 
-                     rptArchiveObj.showArchivedItem(zTreeOprObj.currentNode);
 
-                 }
 
-             });
 
-         }
 
-     };
 
-     const resetChangeSelect = function (resolve = null) {
 
-         const data = {}, hintObj = $('#change-select-hint');
 
-         if (!resolve) getCommonParams(data);
 
-         data[sChangeSelect] = [];
 
-         for (const sc of $('[name=change-select-check]:checked')) {
 
-             data[sChangeSelect].push(sc.value);
 
-         }
 
-         if (data[sChangeSelect].length === 0) {
 
-             hintObj.html('请至少选择一条变更令').show();
 
-             return;
 
-         } else {
 
-             hintObj.hide();
 
-         }
 
-         if (resolve) {
 
-             resolve(data);
 
-         } else {
 
-             postData('/report/cDefine', data, function (result) {
 
-                 changeObj.latestSelect = data[sChangeSelect];
 
-                 reloadReportData(result);
 
-                 $('#change-select').modal('hide');
 
-                 rptArchiveObj.toggleBtn(true);
 
-                 if (PAGE_SHOW.showArchive) {
 
-                     rptArchiveObj.showArchivedItem(zTreeOprObj.currentNode);
 
-                 }
 
-             });
 
-         }
 
-     };
 
-     const _createTenderTreeForCross = function (tenders, category, rstItems) {
 
-         if (rstItems instanceof Array && rstItems.length === 0) {
 
-             //1. 先确定category方式(‘年份’、‘姓名’、‘类型’)及顺序
 
-             let ctArr = [];
 
-             for (let cat of category) {
 
-                 if (cat.level) {
 
-                     ctArr.push(cat);
 
-                 }
 
-             }
 
-             ctArr.sort(function (item1, item2) {
 
-                 return parseInt(item1.level) - parseInt(item2.level);
 
-             }); //保证顺序
 
-             const _buildDeftNodes = function(startIdx, parentItem) {
 
-                 if (ctArr.length > startIdx) {
 
-                     let item = {};
 
-                     if (parentItem instanceof Array) {
 
-                         parentItem.push(item);
 
-                     } else {
 
-                         parentItem.items.push(item);
 
-                     }
 
-                     for (let idx = 0; idx < ctArr[startIdx].value.length; idx++) {
 
-                         item.name = ctArr[startIdx].value[idx].value;
 
-                         item.id = ctArr[startIdx].id; //这个相当于类型id,如68:年份 69:类型,105:姓名
 
-                         item.value_id = ctArr[startIdx].value[idx].id; //每个大类下又有小类,如:2018/2019, 土建/房建, 具体用户姓名...
 
-                         item.cid = ctArr[startIdx].value[idx].cid; //这个值 = item.id
 
-                         item.pid = ctArr[startIdx].value[idx].pid; //project id?
 
-                         item.tenderId = -1;
 
-                         item.selected = false;
 
-                         item.isParent = true;
 
-                         item.last_stage = -1;
 
-                         item.items = [];
 
-                         _buildDeftNodes(startIdx + 1, item);
 
-                     }
 
-                 }
 
-             };
 
-             // const _get
 
-             //2. 创建基本结构
 
-             _buildDeftNodes(0, rstItems);
 
-             //3. 挂上标段
 
-             const _putupTheTender = function (tender) {
 
-                 const _findType = function (parentItem) {
 
-                     for (let cat of tender.category) {
 
-                         if (cat.cid === parentItem.cid && cat.value === parentItem.value_id) {
 
-                             if (parentItem.items.length === 0) {
 
-                                 // 到底了,挂上
 
-                                 let lastStage = -1;
 
-                                 if (tender.lastStage) {
 
-                                     lastStage = tender.lastStage.times;
 
-                                 }
 
-                                 let item = {
 
-                                     name: tender.name,
 
-                                     id  : -1,
 
-                                     value_id: cat.value,
 
-                                     cid : cat.cid,
 
-                                     pid : -1,
 
-                                     tenderId: tender.id,
 
-                                     selected : false,
 
-                                     isParent: true,
 
-                                     last_stage: lastStage,
 
-                                     items : [],
 
-                                 }
 
-                                 parentItem.items.push(item);
 
-                             } else {
 
-                                 for (let nodeItem of parentItem.items) {
 
-                                     _findType(tender, nodeItem);
 
-                                 }
 
-                             }
 
-                             break;
 
-                         }
 
-                     }
 
-                 };
 
-                 for (let nodeItem of rstItems) {
 
-                     _findType(nodeItem);
 
-                 }
 
-             };
 
-             for (let tender of tenders) {
 
-                 _putupTheTender(tender);
 
-             }
 
-         }
 
-     };
 
-     const initTenderTreeForCross = function (tenders, category) {
 
-         //用户跨标段设置电子签名用
 
-         let rstItems = [];
 
-         _createTenderTreeForCross(tenders, category, rstItems);
 
-         _buildTenderRow('batch_projects_individual', rstItems);
 
-     };
 
-     const _buildTenderRow = function(tbDomId, topTreeNodes) {
 
-         let tbDom = $("#" + tbDomId);
 
-         tbDom.empty();
 
-         tbDom.append('<tr><th>名称</th><th>计量期</th><th>签名</th><th>选择</th></tr>');
 
-         let _pushRptLine = function (nodeItem, level) {
 
-             if (nodeItem.isParent) {
 
-                 tbDom.append('<tr><td class="in-'+ (level + 1) + '"><i class="fa fa-folder-o"></i> ' + nodeItem.name + '</td><td></td><td></td><td></td></tr>')
 
-                 //<td class="in-1"><i class="fa fa-folder-o"></i> 2019</td>
 
-             } else {
 
-                 //
 
-             }
 
-         };
 
-         for (const topItem of topTreeNodes) {
 
-             _pushRptLine(topItem, 0);
 
-         }
 
-     };
 
-     const initTenderTree = function (tenders, category) {
 
-         const gsSpread = SpreadJsObj.createNewSpread($('#gather-source-spread')[0]);
 
-         gsObj.gsSheet = gsSpread.getActiveSheet();
 
-         const spreadSetting = {
 
-             cols: [
 
-                 {title: '选择', field: 'selected', hAlign: 1, width: 40, formatter: '@', cellType: 'checkbox', readOnly: true},
 
-                 {title: '名称', field: 'name', hAlign: 0, width: 300, formatter: '@', readOnly: true, cellType: 'tree'},
 
-                 {title: '期数', field: 'phase', hAlign: 1, width: 60, formatter: '@', readOnly: true},
 
-                 {title: '审批状态', field: 'status', hAlign: 1, width: 60, formatter: '@', readOnly: true}
 
-             ],
 
-             emptyRows: 0,
 
-             headRows: 1,
 
-             headRowHeight: [32],
 
-             defaultRowHeight: 21,
 
-             headerFont: '12px 微软雅黑',
 
-             font: '12px 微软雅黑',
 
-             headColWidth: [0],
 
-             selectedBackColor: '#fffacd',
 
-         };
 
-         SpreadJsObj.initSheet(gsObj.gsSheet, spreadSetting);
 
-         gsObj.tenderSourceTree = Tender2Tree.convert(category, tenders, ledgerAuditConst, auditConst);
 
-         SpreadJsObj.loadSheetData(gsObj.gsSheet, SpreadJsObj.DataType.Tree, gsObj.tenderSourceTree);
 
-         gsSpread.bind(spreadNS.Events.ButtonClicked, gatherSelectSpreadObj.gsButtonClicked);
 
-         const grSpread = SpreadJsObj.createNewSpread($('#gather-result-spread')[0]);
 
-         gsObj.grSheet = grSpread.getActiveSheet();
 
-         grSpread.bind(spreadNS.Events.ButtonClicked, gatherSelectSpreadObj.grButtonClicked);
 
-         $('#gather-hint').hide();
 
-         $('#gather-select').bind('shown.bs.modal', function () {
 
-             if (gsSpread) gsSpread.refresh();
 
-             if (grSpread) grSpread.refresh();
 
-         });
 
-         $('.datepicker-here').datepicker({
 
-             autoClose: true,
 
-         });
 
-     };
 
-     const comfirmSelectPromise = function (rptName, gather_select) {
 
-         const promise = new Promise(function (resolve, reject) {
 
-             init(gather_select.custom_define, customSelects.stageFlow, gather_select, rptName, resolve, reject);
 
-         });
 
-         return promise;
 
-     };
 
-     const getCustomSelect = async function (params) {
 
-         if (!params.rpt_ids || params.rpt_ids.length === 0) return;
 
-         const currentRptId = zTreeOprObj.currentNode ? zTreeOprObj.currentNode.refId : -1;
 
-         params.customSelect = [];
 
-         const chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
 
-         for (const rptId of params.rpt_ids) {
 
-             const gather_select = customSelects.gather_select.find(function (x) {
 
-                 return x.id === rptId;
 
-             });
 
-             const stage_select = customSelects.stage_select.find(function (x) {
 
-                 return x.id === rptId;
 
-             });
 
-             const change_select = customSelects.change_select.find(function (x) {
 
-                 return x.id === rptId;
 
-             });
 
-             const material_sum_select = customSelects.material_sum_select.find(function (x) {
 
-                 return x.id === rptId;
 
-             });
 
-             if (gather_select && gather_select.custom_define && gather_select.custom_define[sGatherSelect].enable) {
 
-                 if (rptId === currentRptId) {
 
-                     const data = {};
 
-                     data[sGatherSelect] = gather_select[sGatherSelect];
 
-                     params.customSelect.push(data);
 
-                 } else {
 
-                     const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
 
-                     const select = await comfirmSelectPromise(chkNode ? chkNode.name : '', gather_select);
 
-                     params.customSelect.push(select);
 
-                     $('#gather-select').modal('hide');
 
-                 }
 
-             } else if (stage_select && stage_select.custom_define && stage_select.custom_define[sStageSelect].enable) {
 
-                 if (rptId === currentRptId) {
 
-                     const data = {};
 
-                     data[sStageSelect] = stage_select[sStageSelect];
 
-                     params.customSelect.push(data);
 
-                 } else {
 
-                     const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
 
-                     const select = await comfirmSelectPromise(chkNode ? chkNode.name : '', stage_select);
 
-                     params.customSelect.push(select);
 
-                     $('#stage-select').modal('hide');
 
-                 }
 
-             } else if (change_select && change_select.custom_define && change_select.custom_define[sChangeSelect].enable ) {
 
-                 if (rptId === currentRptId && changeObj.latestPush) {
 
-                     const data = {};
 
-                     data[sChangeSelect] = changeObj.latestSelect;
 
-                     params.customSelect.push(data);
 
-                 } else {
 
-                     const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
 
-                     const select = await comfirmSelectPromise(chkNode ? chkNode.name : '', change_select);
 
-                     params.customSelect.push(select);
 
-                     $('#change-select').modal('hide');
 
-                 }
 
-             } else if (material_sum_select && material_sum_select.custom_define && material_sum_select.custom_define[sMaterialSumSelect].enable) {
 
-                 if (rptId === currentRptId) {
 
-                     const data = {};
 
-                     data[sMaterialSumSelect] = material_sum_select[sMaterialSumSelect];
 
-                     params.customSelect.push(data);
 
-                 } else {
 
-                     const chkNode = chkNodes.find(function (x) { return x.refId === rptId});
 
-                     const select = await comfirmSelectPromise(chkNode ? chkNode.name : '', material_sum_select);
 
-                     params.customSelect.push(select);
 
-                     $('#material-sum-select').modal('hide');
 
-                 }
 
-             } else {
 
-                 params.customSelect.push(null);
 
-             }
 
-         }
 
-     };
 
-     const showMaterialSelect = function () {
 
-         const needShow = function () {
 
-             if (zTreeOprObj.currentNode) {
 
-                 const ms = dataSelects.material_select.find(function (x) { return x.id === zTreeOprObj.currentNode.refId});
 
-                 if (ms) return true;
 
-             }
 
-             const chkNodes = zTreeOprObj.treeObj.getCheckedNodes(true);
 
-             for (const node of chkNodes) {
 
-                 const ms = dataSelects.material_select.find(function (x) { return x.id === node.refId});
 
-                 if (ms) return true;
 
-             }
 
-             return false;
 
-         };
 
-         if (needShow()) {
 
-             $('#material').show();
 
-         } else {
 
-             $('#material').hide();
 
-         }
 
-     };
 
-     const postReportData = function (url, params, successCallback, errorCallBack, showWaiting = true) {
 
-         if (showWaiting) showWaitingView();
 
-         $.ajax({
 
-             type:"POST",
 
-             url: url,
 
-             data: {'params': JSON.stringify(params)},
 
-             dataType: 'json',
 
-             cache: false,
 
-             timeout: 300000,
 
-             beforeSend: function(xhr) {
 
-                 let csrfToken = Cookies.get('csrfToken_j');
 
-                 xhr.setRequestHeader('x-csrf-token', csrfToken);
 
-             },
 
-             success: function(result){
 
-                 successCallback(result);
 
-                 if (showWaiting) closeWaitingView();
 
-             },
 
-             error: function(jqXHR, textStatus, errorThrown){
 
-                 toastr.error('error: ' + textStatus + " " + errorThrown);
 
-                 if (errorCallBack) {
 
-                     errorCallBack();
 
-                 }
 
-                 if (showWaiting) closeWaitingView();
 
-             }
 
-         });
 
-     };
 
-     const changeMaterial = function (obj) {
 
-         $('#material-select').attr('m-order', $(obj).attr('m-order')).html(obj.innerText);
 
-         const data = {};
 
-         getCommonParams(data);
 
-         postReportData('/tender/report_api/getReport', data, reloadReportData);
 
-     };
 
-     return {
 
-         init,
 
-         resetAuditSelect, resetGatherSelect, resetStageSelect, resetChangeSelect, resetMaterialSumSelect,
 
-         initTenderTree,
 
-         initTenderTreeForCross,
 
-         getCustomSelect,
 
-         showMaterialSelect, changeMaterial,
 
-     };
 
- })();
 
 
  |