|
|
@@ -0,0 +1,158 @@
|
|
|
+$(document).ready(() => {
|
|
|
+ autoFlashHeight();
|
|
|
+ $('#data-spread').height($('.sjs-height-0').height() - $('.nav-tabs').height() - 16);
|
|
|
+ const paySpreadSetting = {
|
|
|
+ cols: [
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 235, formatter: '@'},
|
|
|
+ {title: '扣款', colSpan: '1', rowSpan: '2', field: 'minus', hAlign: 1, width: 60, cellType: 'checkbox'},
|
|
|
+ ],
|
|
|
+ baseCols: [
|
|
|
+ {title: '名称', colSpan: '1', rowSpan: '2', field: 'name', hAlign: 0, width: 235, formatter: '@'},
|
|
|
+ {title: '扣款', colSpan: '1', rowSpan: '2', field: 'minus', hAlign: 1, width: 60, cellType: 'checkbox'},
|
|
|
+ ],
|
|
|
+ extraCols: [
|
|
|
+ {title: '标段1|第1期', colSpan: '1|1', rowSpan: '1|1', field: 'show_tp1', hAlign: 2, width: 80, type: 'Number', formatTitle: '%s|%f', formatField: 'show_tp_%d'},
|
|
|
+ ],
|
|
|
+ endCols: [
|
|
|
+ {title: '合计', colSpan: '1', rowSpan: '2', field: 'sum_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ ],
|
|
|
+ emptyRows: 0,
|
|
|
+ headRows: 2,
|
|
|
+ headRowHeight: [25, 25],
|
|
|
+ defaultRowHeight: 21,
|
|
|
+ headerFont: '12px 微软雅黑',
|
|
|
+ font: '12px 微软雅黑',
|
|
|
+ readOnly: true,
|
|
|
+ };
|
|
|
+
|
|
|
+ const paySpread = SpreadJsObj.createNewSpread($('#pay-spread')[0]);
|
|
|
+ const paySheet = paySpread.getActiveSheet();
|
|
|
+ const payGather = {
|
|
|
+ pays: [],
|
|
|
+ seData: 'cur',
|
|
|
+ gatherPays(tenders) {
|
|
|
+ this.pays = [];
|
|
|
+ for (const [i, t] of tenders.entries()) {
|
|
|
+ const endfix = '_' + (i + 1);
|
|
|
+ for (const data of t.pay) {
|
|
|
+ if (!data.name) data.name = '';
|
|
|
+ data.minus = data.minus ? 1 : 0;
|
|
|
+
|
|
|
+ let p = this.pays.find(x => { return x.name === data.name && x.minus === data.minus; });
|
|
|
+ if (!p) {
|
|
|
+ p = { name: data.name, minus: data.minus };
|
|
|
+ this.pays.push(p);
|
|
|
+ }
|
|
|
+ p['tp' + endfix] = ZhCalc.add(p['tp' + endfix], data.tp);
|
|
|
+ p['pre_tp' + endfix] = ZhCalc.add(p['pre_tp' + endfix], data.pre_tp);
|
|
|
+ p['end_tp' + endfix] = ZhCalc.add(p['end_tp' + endfix], data.end_tp);
|
|
|
+
|
|
|
+ p['sum_tp' + endfix] = ZhCalc.add(p['sum_tp' + endfix], data.tp);
|
|
|
+ p['sum_pre_tp' + endfix] = ZhCalc.add(p['sum_pre_tp' + endfix], data.pre_tp);
|
|
|
+ p['sum_end_tp' + endfix] = ZhCalc.add(p['sum_end_tp' + endfix], data.end_tp);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ gatherStageExtraData(tenders) {
|
|
|
+ this.tenderCount = tenders.length;
|
|
|
+ this.gatherPays(tenders);
|
|
|
+ },
|
|
|
+ rebuildSpreadSetting(tenders) {
|
|
|
+ paySpreadSetting.cols = [...paySpreadSetting.baseCols];
|
|
|
+ const pushExtraCols = function(spreadSetting) {
|
|
|
+ for (const [i, tender] of tenders.entries()) {
|
|
|
+ for (const col of spreadSetting.extraCols) {
|
|
|
+ const newCol = JSON.parse(JSON.stringify(col));
|
|
|
+ if (newCol.formatTitle) newCol.title = newCol.formatTitle.replace('%s', tender.name).replace('%f', tender.stage_filter);
|
|
|
+ if (newCol.formatField) newCol.field = newCol.formatField.replace('%d', i + 1);
|
|
|
+ spreadSetting.cols.push(newCol);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ };
|
|
|
+ pushExtraCols(paySpreadSetting);
|
|
|
+ paySpreadSetting.cols.push(...paySpreadSetting.endCols);
|
|
|
+ },
|
|
|
+ loadPayShowData(field) {
|
|
|
+ const prefix = field === 'end' ? 'end_' : '';
|
|
|
+ for (const cl of this.pays) {
|
|
|
+ for (let i = 1; i<= this.tenderCount; i++) {
|
|
|
+ cl['show_tp_' + i] = cl[prefix + 'tp_' + i];
|
|
|
+ }
|
|
|
+ cl.sum_tp = cl['sum_' + prefix + 'tp'];
|
|
|
+ }
|
|
|
+ SpreadJsObj.reloadColData(paySheet, 2, this.tenderCount + 1);
|
|
|
+ },
|
|
|
+ loadShowData(force = false) {
|
|
|
+ const field = $('[name=compare-data]:checked').val();
|
|
|
+ if (field === this.seData && !force) return;
|
|
|
+ this.seData = field;
|
|
|
+ this.loadPayShowData(field);
|
|
|
+ },
|
|
|
+ refreshShowData() {
|
|
|
+ const field = $('[name=compare-data]:checked').val();
|
|
|
+ if (field === this.seData) return;
|
|
|
+
|
|
|
+ this.loadShowData();
|
|
|
+ },
|
|
|
+ loadSheetData() {
|
|
|
+ SpreadJsObj.initSheet(paySheet, paySpreadSetting);
|
|
|
+ SpreadJsObj.loadSheetData(paySheet, SpreadJsObj.DataType.Data, this.pays);
|
|
|
+ SpreadJsObj.locateRow(paySheet, 0);
|
|
|
+ },
|
|
|
+ refreshStageExtraData(type) {
|
|
|
+ if (type) {
|
|
|
+ if (this.seType === type) return;
|
|
|
+ this.seType = type;
|
|
|
+ }
|
|
|
+ this.loadSheetData();
|
|
|
+ },
|
|
|
+ };
|
|
|
+ payGather.loadSheetData();
|
|
|
+
|
|
|
+ const tenderSelect = TenderSelectMulti({
|
|
|
+ title: '汇总标段',
|
|
|
+ type: 'gather',
|
|
|
+ dataType: 'stage',
|
|
|
+ zoneValid: false,
|
|
|
+ afterSelect: function(select) {
|
|
|
+ const data = { filter: 'pay', tender: select };
|
|
|
+ postData(`/sp/${spid}/spss/load`, data, function(result) {
|
|
|
+ payGather.rebuildSpreadSetting(result);
|
|
|
+ payGather.gatherStageExtraData(result);
|
|
|
+ SpreadJsObj.reLoadSheetHeader(paySheet, true);
|
|
|
+ payGather.loadShowData(true);
|
|
|
+ payGather.loadSheetData();
|
|
|
+ });
|
|
|
+ },
|
|
|
+ });
|
|
|
+ $('#gather-select').click(tenderSelect.showSelect);
|
|
|
+
|
|
|
+ $('[name=compare-data]').click(function() {
|
|
|
+ payGather.refreshShowData();
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#export-excel').click(function() {
|
|
|
+ const sheets = [];
|
|
|
+ sheets.push({ name: '合同支付', setting: paySpreadSetting, data: payGather.pays });
|
|
|
+ SpreadExcelObj.exportSimpleXlsxSheets(sheets, "计量汇总-合同支付.xlsx");
|
|
|
+ });
|
|
|
+ $.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');
|
|
|
+ $('.c-body table thead').css('left', '56px');
|
|
|
+ } else {
|
|
|
+ $('.panel-title').removeClass('fluid');
|
|
|
+ $('#sub-menu').addClass('panel-sidebar');
|
|
|
+ $('.c-body table thead').css('left', '176px');
|
|
|
+ }
|
|
|
+ autoFlashHeight();
|
|
|
+ paySpread.refresh();
|
|
|
+ }
|
|
|
+ });
|
|
|
+});
|