|
@@ -9,8 +9,132 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
const rptCustomObj = (function () {
|
|
const rptCustomObj = (function () {
|
|
|
|
+ // 审批人选择
|
|
const sAuditSelect = 'audit_select';
|
|
const sAuditSelect = 'audit_select';
|
|
let stageFlow = [];
|
|
let stageFlow = [];
|
|
|
|
+ // 汇总表
|
|
|
|
+ const sGatherSelect = 'gather_select';
|
|
|
|
+ let gsObj = {
|
|
|
|
+ setting: null,
|
|
|
|
+
|
|
|
|
+ gsSheet: null,
|
|
|
|
+ grSheet: null,
|
|
|
|
+
|
|
|
|
+ tenderSourceTree: null,
|
|
|
|
+ grArray: [],
|
|
|
|
+
|
|
|
|
+ orgSelect: null,
|
|
|
|
+ };
|
|
|
|
+ const grSpreadSetting = {
|
|
|
|
+ baseCols: [
|
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '1', field: 'name', hAlign: 0, width: 180, 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 = {
|
|
|
|
+ _addTender: function (tender) {
|
|
|
|
+ const gr = gsObj.grArray.find(function (x) {
|
|
|
|
+ return x.tid === tender.tid;
|
|
|
|
+ });
|
|
|
|
+ const t = {tid: tender.tid, name: tender.name}
|
|
|
|
+ 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);
|
|
|
|
+ },
|
|
|
|
+ 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 || tenders.length === 0) 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});
|
|
|
|
+ tender.selected = true;
|
|
|
|
+ select.push(tender);
|
|
|
|
+ const st = this._addTender(tender);
|
|
|
|
+ for (const sc of specCol) {
|
|
|
|
+ st[sc.key] = t[sc.key];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.reLoadNodesData(gsObj.gsSheet, select);
|
|
|
|
+ if (select.length > 0) SpreadJsObj.locateTreeNode(gsObj.gsSheet, select.tmt_id);
|
|
|
|
+ this.reloadResultData();
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
|
|
const getStageFlowSelectHtml = function (select, id) {
|
|
const getStageFlowSelectHtml = function (select, id) {
|
|
const html = [];
|
|
const html = [];
|
|
@@ -60,14 +184,67 @@ const rptCustomObj = (function () {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
|
|
+ const initGrSpreadSetting = function (gsSetting) {
|
|
|
|
+ grSpreadSetting.cols = [];
|
|
|
|
+ for (const bc of grSpreadSetting.baseCols) {
|
|
|
|
+ grSpreadSetting.cols.push(bc);
|
|
|
|
+ }
|
|
|
|
+ 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) {
|
|
|
|
+ gsObj.setting = JSON.parse(gsSetting);
|
|
|
|
+ gsObj.setting.type = 'zone';
|
|
|
|
+ gsObj.orgSelect = gsSelect;
|
|
|
|
+ $('#audit-select-title').html(gsObj.setting.title);
|
|
|
|
+ initGrSpreadSetting(gsObj.setting);
|
|
|
|
+ SpreadJsObj.initSheet(gsObj.grSheet, grSpreadSetting);
|
|
|
|
+ if (gsObj.setting.type === 'month') {
|
|
|
|
+ $('#gather-by-month').show();
|
|
|
|
+ $('#gather-by-zone').hide();
|
|
|
|
+ } else if (gsObj.setting.type === 'zone') {
|
|
|
|
+ $('#gather-by-month').hide();
|
|
|
|
+ $('#gather-by-zone').show();
|
|
|
|
+ }
|
|
|
|
+ SpreadJsObj.loadSheetData(gsObj.grSheet, SpreadJsObj.DataType.Data, gsObj.grArray);
|
|
|
|
+ // 初始化选择结果
|
|
|
|
+ if (gsSelect) {
|
|
|
|
+ if (gsSelect.zone) {
|
|
|
|
+ $('#gather-zone').val(gsSelect.zone ? gsSelect.zone : '');
|
|
|
|
+ } else {
|
|
|
|
+ $('#gather-month').val(gsSelect.month ? gsSelect.month: '');
|
|
|
|
+ }
|
|
|
|
+ gatherSelectSpreadObj.initSelectTenders(gsSelect.tenders);
|
|
|
|
+ }
|
|
|
|
+ // 初始化
|
|
|
|
+ $("#gather-select").modal('show');
|
|
|
|
+ };
|
|
const init = function (cDefine, sfData, cSelect) {
|
|
const init = function (cDefine, sfData, cSelect) {
|
|
stageFlow = sfData;
|
|
stageFlow = sfData;
|
|
if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
|
|
if (cDefine && cDefine[sAuditSelect] && cDefine[sAuditSelect].enable && cDefine[sAuditSelect].setting) {
|
|
$('#pnl_audit_select').show();
|
|
$('#pnl_audit_select').show();
|
|
- initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect.audit_select : []);
|
|
|
|
|
|
+ initAuditSelect(cDefine[sAuditSelect].setting, cSelect ? cSelect[sAuditSelect] : []);
|
|
} else {
|
|
} else {
|
|
$('#pnl_audit_select').hide();
|
|
$('#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] : []);
|
|
|
|
+ } else {
|
|
|
|
+ $('#pnl_gather_select').hide();
|
|
|
|
+ }
|
|
};
|
|
};
|
|
|
|
|
|
const reloadReportData = function (result) {
|
|
const reloadReportData = function (result) {
|
|
@@ -128,9 +305,7 @@ const rptCustomObj = (function () {
|
|
}
|
|
}
|
|
};
|
|
};
|
|
|
|
|
|
- const resetAuditSelect = function () {
|
|
|
|
- const selObj = $('select', '#audit-select-list');
|
|
|
|
- const data = { audit_select: [] };
|
|
|
|
|
|
+ const getCommonParams = function (data) {
|
|
data.pageSize = rptControlObj.getCurrentPageSize();
|
|
data.pageSize = rptControlObj.getCurrentPageSize();
|
|
data.orientation = rptControlObj.getCurrentOrientation();
|
|
data.orientation = rptControlObj.getCurrentOrientation();
|
|
data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
|
|
data.rpt_tpl_id = zTreeOprObj.currentNode.refId;
|
|
@@ -141,6 +316,12 @@ const rptCustomObj = (function () {
|
|
data.stage_status = getStageStatus();
|
|
data.stage_status = getStageStatus();
|
|
data.stage_order = getStageOrder();
|
|
data.stage_order = getStageOrder();
|
|
data.stage_times = getStageTimes();
|
|
data.stage_times = getStageTimes();
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ const resetAuditSelect = function () {
|
|
|
|
+ const selObj = $('select', '#audit-select-list');
|
|
|
|
+ const data = { audit_select: [] };
|
|
|
|
+ getCommonParams(data);
|
|
for (const s of selObj) {
|
|
for (const s of selObj) {
|
|
const sf = stageFlow[s.selectedIndex];
|
|
const sf = stageFlow[s.selectedIndex];
|
|
if (!sf) {
|
|
if (!sf) {
|
|
@@ -156,5 +337,97 @@ const rptCustomObj = (function () {
|
|
});
|
|
});
|
|
};
|
|
};
|
|
|
|
|
|
- return {init, resetAuditSelect};
|
|
|
|
|
|
+ const resetGatherSelect = function () {
|
|
|
|
+ const data = {}, hintObj = $('#gather-hint');
|
|
|
|
+ getCommonParams(data);
|
|
|
|
+ data[sGatherSelect] = {
|
|
|
|
+ tenders: [],
|
|
|
|
+ type: gsObj.setting.type,
|
|
|
|
+ };
|
|
|
|
+ const specCol = gsObj.setting.special ? gsObj.setting.special : [];
|
|
|
|
+ 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 (data[sGatherSelect].tenders.length <= specCol.length) {
|
|
|
|
+ hintObj.html('请至少选择1个普通汇总项目').show();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (gsObj.setting.type === 'month') {
|
|
|
|
+ data[sGatherSelect].month = $('#gather-month').val();
|
|
|
|
+ if (data[sGatherSelect].month === '') {
|
|
|
|
+ hintObj.html('请选择 汇总年月').show();
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ hintObj.hide();
|
|
|
|
+ postData('/report/cDefine', data, function (result) {
|
|
|
|
+ reloadReportData(result);
|
|
|
|
+ $('#gather-select').modal('hide');
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ 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: 180, 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);
|
|
|
|
+ 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,
|
|
|
|
+ });
|
|
|
|
+ };
|
|
|
|
+
|
|
|
|
+ return {init, resetAuditSelect, resetGatherSelect, initTenderTree};
|
|
})();
|
|
})();
|