|
@@ -1,17 +1,48 @@
|
|
|
'use strict';
|
|
|
+/**
|
|
|
+ * 从cookie中读取缓存的列显示设置,没有则取默认
|
|
|
+ * @returns {*[]}
|
|
|
+ */
|
|
|
+function customColDisplay () {
|
|
|
+ const defaultSetting = [
|
|
|
+ { title: '投资估算', fields: ['gu_dgn_qty', 'gu_dgn_price', 'gu_tp'], visible: true },
|
|
|
+ { title: '设计概算', fields: ['gai_dgn_qty', 'gai_dgn_price', 'gai_tp'], visible: true },
|
|
|
+ { title: '施工图预算', fields: ['yu_dgn_qty', 'yu_dgn_price', 'yu_tp'], visible: true },
|
|
|
+ { title: '招标预算', fields: ['zb_dgn_qty', 'zb_dgn_price', 'zb_tp'], visible: true },
|
|
|
+ { title: '台账', fields: ['dgn_qty', 'dgn_price', 'total_price'], visible: true },
|
|
|
+ { title: '预估决算', fields: ['final_dgn_qty', 'final_dgn_price', 'final_tp'], visible: true },
|
|
|
+ ];
|
|
|
+ const settingStr = Cookies.get(ckColSetting);
|
|
|
+ if (settingStr) {
|
|
|
+ const customSetting = JSON.parse(settingStr);
|
|
|
+ for (const ds of defaultSetting) {
|
|
|
+ const cs = customSetting.find(x => {return x.title === ds.title});
|
|
|
+ if (cs) ds.visible = cs.visible;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return defaultSetting;
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
- *
|
|
|
- * @author Mai
|
|
|
- * @date
|
|
|
- * @version
|
|
|
+ * 根据列显示设置,调整setting中的列是否显示
|
|
|
+ * @param setting
|
|
|
+ * @param customDisplay
|
|
|
*/
|
|
|
+function customizeTreeSetting(setting, customDisplay) {
|
|
|
+ for (const cd of customDisplay) {
|
|
|
+ for (const c of setting.cols) {
|
|
|
+ if (cd.fields.indexOf(c.field) !== -1) {
|
|
|
+ c.defaultVisible = cd.visible;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
$(document).ready(() => {
|
|
|
const compareTypeKey = 'budget-compareType';
|
|
|
const stackedBarCoverKey = 'budget-stackedBarCover';
|
|
|
const stackedBarKey = 'budget-stackedBar';
|
|
|
+ const comparePhaseKey = 'budget-comparePhase';
|
|
|
autoFlashHeight();
|
|
|
const compareSpread = SpreadJsObj.createNewSpread($('#cost-compare')[0]);
|
|
|
const compareSheet = compareSpread.getActiveSheet();
|
|
@@ -19,6 +50,14 @@ $(document).ready(() => {
|
|
|
const getStackedBarTip = function (data) {
|
|
|
return data.stackedBarTips.join('\n');
|
|
|
};
|
|
|
+ const comparePhase = [
|
|
|
+ { key: 'gu', name: '投资估算', dgn1: 'gu_dgn_qty1', dgn2: 'gu_dgn_qty2', tp: 'gu_tp'},
|
|
|
+ { key: 'gai', name: '设计概算', dgn1: 'gai_dgn_qty1', dgn2: 'gai_dgn_qty2', tp: 'gai_tp'},
|
|
|
+ { key: 'yu', name: '施工图预算', dgn1: 'yu_dgn_qty1', dgn2: 'yu_dgn_qty2', tp: 'yu_tp'},
|
|
|
+ { key: 'zb', name: '招标预算', dgn1: 'zb_dgn_qty1', dgn2: 'zb_dgn_qty2', tp: 'zb_tp'},
|
|
|
+ { key: 'tz', name: '台账', dgn1: 'dgn_qty1', dgn2: 'dgn_qty2', tp: 'total_price'},
|
|
|
+ { key: 'final', name: '预估决算', dgn1: 'final_dgn_qty1', dgn2: 'final_dgn_qty2', tp: 'final_tp'},
|
|
|
+ ];
|
|
|
const spreadSetting = {
|
|
|
cols: [
|
|
|
{title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'},
|
|
@@ -42,9 +81,9 @@ $(document).ready(() => {
|
|
|
{title: '预估决算|数量1/数量2', colSpan: '3|1', rowSpan: '1|1', field: 'final_dgn_qty', hAlign: 2, width: 80, bc_type: 'number', visible: false},
|
|
|
{title: '|经济指标', colSpan: '|1', rowSpan: '|1', field: 'final_dgn_price', hAlign: 2, width: 80, type: 'Number', bc_type: 'number', visible: false},
|
|
|
{title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'final_tp', hAlign: 2, width: 80, type: 'Number', bc_type: 'number', visible: false},
|
|
|
- {title: '数据对比', colSpan: '1', rowSpan: '2', field: 'stackedBar', hAlign: 0, width: 300, cellType: 'stackedBar', stackedBarCover: false, bc_type: 'grid', visible: false, getTip: getStackedBarTip},
|
|
|
- {title: '增幅%|数量1/数量2', colSpan: '2|1', rowSpan: '1|1', field: 'grow_dgn_qty', hAlign: 2, width: 80},
|
|
|
- {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'grow_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
+ {title: '数据对比', colSpan: '1', rowSpan: '2', field: 'stackedBar', hAlign: 0, width: 300, cellType: 'stackedBar', stackedBarCover: false, bc_type: 'grid', defaultVisible: true, visible: false, getTip: getStackedBarTip},
|
|
|
+ {title: '增幅%|数量1/数量2', colSpan: '2|1', rowSpan: '1|1', field: 'compare_dgn_qty', hAlign: 2, width: 80},
|
|
|
+ {title: '|金额', colSpan: '|1', rowSpan: '|1', field: 'compare_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
|
],
|
|
|
emptyRows: 0,
|
|
|
headRows: 2,
|
|
@@ -61,6 +100,37 @@ $(document).ready(() => {
|
|
|
sjsSettingObj.setFxTreeStyle(spreadSetting, sjsSettingObj.FxTreeStyle.jz);
|
|
|
let sfSelect;
|
|
|
const compareObj = {
|
|
|
+ comparePhase1: 'gai',
|
|
|
+ comparePhase2: 'final',
|
|
|
+ getCompareSelectHtml() {
|
|
|
+ const html = [];
|
|
|
+ for (const cp of comparePhase) {
|
|
|
+ html.push(`<option value="${cp.key}">${cp.name}</option>`);
|
|
|
+ }
|
|
|
+ return html.join('');
|
|
|
+ },
|
|
|
+ initCompare() {
|
|
|
+ const selectHtml = this.getCompareSelectHtml();
|
|
|
+ $('#compare1').html(selectHtml);
|
|
|
+ $('#compare2').html(selectHtml);
|
|
|
+ const comparePhase = Cookies.get(comparePhaseKey).split(',');
|
|
|
+ this.setComparePhase(comparePhase[0] || this.comparePhase1, comparePhase[1] || this.comparePhase2);
|
|
|
+ },
|
|
|
+ getCompareHint(phase1, phase2) {
|
|
|
+ if (!phase1) phase1 = this.comparePhase1;
|
|
|
+ if (!phase2) phase2 = this.comparePhase2;
|
|
|
+ const cp1 = comparePhase.find(x => { return x.key === phase1; });
|
|
|
+ const cp2 = comparePhase.find(x => { return x.key === phase2; });
|
|
|
+ return `增减幅度=(${cp2.name}-${cp1.name})/${cp1.name}*100%`;
|
|
|
+ },
|
|
|
+ setComparePhase(phase1, phase2) {
|
|
|
+ compareObj.comparePhase1 = phase1;
|
|
|
+ compareObj.comparePhase2 = phase2;
|
|
|
+ $('#compare-hint').html(compareObj.getCompareHint());
|
|
|
+ compareObj.reCalculateCompareData();
|
|
|
+ $('#compare-set').modal('hide');
|
|
|
+ Cookies.set(comparePhaseKey, phase1 + ',' + phase2);
|
|
|
+ },
|
|
|
curFinalId() {
|
|
|
return this.finalInfo ? this.finalInfo.id : undefined;
|
|
|
},
|
|
@@ -74,11 +144,7 @@ $(document).ready(() => {
|
|
|
}
|
|
|
},
|
|
|
initShowType() {
|
|
|
- const type = this.compareType;
|
|
|
- spreadSetting.cols.forEach(x => {
|
|
|
- if (!x.bc_type) return;
|
|
|
- x.visible = x.bc_type === type;
|
|
|
- });
|
|
|
+ this.reCalcColVisible();
|
|
|
const colIndex = spreadSetting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
spreadSetting.cols[colIndex].stackedBarCover = parseInt(this.stackedBarCover);
|
|
|
},
|
|
@@ -203,6 +269,7 @@ $(document).ready(() => {
|
|
|
const expandTag = getLocalCache('revise-compare-level');
|
|
|
if (expandTag) compareObj.expand(compareTree, expandTag);
|
|
|
this.calcStackedBar(compareTree);
|
|
|
+ this.reCalculateCompareData(compareTree);
|
|
|
SpreadJsObj.loadSheetData(compareSheet, SpreadJsObj.DataType.Tree, compareTree);
|
|
|
},
|
|
|
loadFinalData(result, msg) {
|
|
@@ -221,9 +288,28 @@ $(document).ready(() => {
|
|
|
const expandTag = getLocalCache('revise-compare-level');
|
|
|
if (expandTag) compareObj.expand(finalTree, expandTag);
|
|
|
this.calcStackedBar(finalTree);
|
|
|
+ this.reCalculateCompareData(finalTree);
|
|
|
SpreadJsObj.loadSheetData(compareSheet, SpreadJsObj.DataType.Tree, finalTree);
|
|
|
if (sfSelect) sfSelect.reloadSelect(this.finalInfo.tender);
|
|
|
},
|
|
|
+ reCalculateCompareData(calcTree) {
|
|
|
+ const tree = calcTree || compareSheet.zh_tree;
|
|
|
+ if (!tree) return;
|
|
|
+
|
|
|
+ const cp1 = comparePhase.find(x => { return x.key === this.comparePhase1; });
|
|
|
+ const cp2 = comparePhase.find(x => { return x.key === this.comparePhase2; });
|
|
|
+ treeCalc.calculateAll(tree, function(node) {
|
|
|
+ node.compare_dgn_qty1 = node[cp1.dgn1] ? ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node[cp2.dgn1], node[cp1.dgn1]), node[cp1.dgn1], 4), 100) : 0;
|
|
|
+ node.compare_dgn_qty2 = node[cp1.dgn2] ? ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node[cp2.dgn1], node[cp1.dgn1]), node[cp1.dgn1], 4), 100) : 0;
|
|
|
+ node.compare_dgn_qty = node.compare_dgn_qty1
|
|
|
+ ? (node.compare_dgn_qty2 ? node.compare_dgn_qty1 + '/' + node.compare_dgn_qty2 : node.compare_dgn_qty1)
|
|
|
+ : (node.compare_dgn_qty2 ? '/' + node.compare_dgn_qty2 : '');
|
|
|
+ node.compare_tp = node[cp1.tp] ? ZhCalc.mul(ZhCalc.div(ZhCalc.sub(node[cp2.tp], node[cp1.tp]), node[cp1.tp], 4), 100) : 0;
|
|
|
+ });
|
|
|
+
|
|
|
+ const index = spreadSetting.cols.findIndex(x => { return x.field === 'compare_dgn_qty'});
|
|
|
+ SpreadJsObj.reloadColData(compareSheet, index, 2);
|
|
|
+ },
|
|
|
loadCacheData(){
|
|
|
let stackedBarCache = getLocalCache(stackedBarKey);
|
|
|
if (stackedBarCache === null) stackedBarCache = 'gai_tp,total_price,final_tp';
|
|
@@ -239,19 +325,25 @@ $(document).ready(() => {
|
|
|
const colIndex = spreadSetting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
SpreadJsObj.reloadColData(compareSheet, colIndex);
|
|
|
},
|
|
|
+ reCalcColVisible() {
|
|
|
+ const type = this.compareType;
|
|
|
+ spreadSetting.cols.forEach(x => {
|
|
|
+ if (!x.bc_type) return;
|
|
|
+ x.visible = x.bc_type === type && x.defaultVisible;
|
|
|
+ });
|
|
|
+ },
|
|
|
setCompareType(type) {
|
|
|
this.compareType = type || 'number';
|
|
|
$('[name=showType]').removeClass('active');
|
|
|
$(`[tag=${this.compareType}]`).addClass('active');
|
|
|
if (this.compareType === 'grid') {
|
|
|
- $('.ml-auto').show();
|
|
|
+ $('.ml-grid').show();
|
|
|
+ $('.ml-number').hide();
|
|
|
} else {
|
|
|
- $('.ml-auto').hide();
|
|
|
+ $('.ml-grid').hide();
|
|
|
+ $('.ml-number').show();
|
|
|
}
|
|
|
- spreadSetting.cols.forEach(x => {
|
|
|
- if (!x.bc_type) return;
|
|
|
- x.visible = x.bc_type === type;
|
|
|
- });
|
|
|
+ this.reCalcColVisible();
|
|
|
setLocalCache(compareTypeKey, this.compareType);
|
|
|
},
|
|
|
setStackedBarCover(cover){
|
|
@@ -262,7 +354,9 @@ $(document).ready(() => {
|
|
|
setLocalCache(stackedBarCoverKey, this.stackedBarCover);
|
|
|
}
|
|
|
};
|
|
|
+ customizeTreeSetting(spreadSetting, customColDisplay());
|
|
|
compareObj.loadCacheData();
|
|
|
+ compareObj.initCompare();
|
|
|
SpreadJsObj.initSheet(compareSheet, spreadSetting);
|
|
|
|
|
|
function compareCode(str1, str2, symbol = '-') {
|
|
@@ -339,7 +433,6 @@ $(document).ready(() => {
|
|
|
});
|
|
|
})('a[name=showLevel]', compareSheet);
|
|
|
|
|
|
-
|
|
|
class sfObject {
|
|
|
constructor() {
|
|
|
const self = this;
|
|
@@ -459,4 +552,57 @@ $(document).ready(() => {
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
+
|
|
|
+ $('#row-view').on('show.bs.modal', function () {
|
|
|
+ const html = [], customDisplay = customColDisplay();
|
|
|
+ for (const cd of customDisplay) {
|
|
|
+ html.push('<tr>');
|
|
|
+ html.push('<td>', cd.title, '</td>');
|
|
|
+ html.push('<td>', '<input type="checkbox"' + (cd.visible ? ' checked=""' : '') + '>', '</td>');
|
|
|
+ html.push('</tr>');
|
|
|
+ }
|
|
|
+ $('#row-view-list').html(html.join(''));
|
|
|
+ });
|
|
|
+ $('#row-view-ok').click(function () {
|
|
|
+ const customDisplay = customColDisplay();
|
|
|
+ const cvl = $('#row-view-list').children();
|
|
|
+ for (const cv of cvl) {
|
|
|
+ const title = $(cv).children()[0].innerHTML;
|
|
|
+ const check = $('input', cv)[0].checked;
|
|
|
+ const cd = customDisplay.find(function (c) {
|
|
|
+ return c.title === title;
|
|
|
+ });
|
|
|
+ cd.visible = check;
|
|
|
+ }
|
|
|
+ customizeTreeSetting(spreadSetting, customDisplay);
|
|
|
+ compareObj.loadCacheData();
|
|
|
+ SpreadJsObj.refreshColumnVisible(compareSheet);
|
|
|
+ Cookies.set(ckColSetting, JSON.stringify(customDisplay), 30*24*60*60*1000);
|
|
|
+ $('#row-view').modal('hide');
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#compare-set').on('show.bs.modal', function() {
|
|
|
+ $('#compare1').val(compareObj.comparePhase1);
|
|
|
+ $('#compare2').val(compareObj.comparePhase2);
|
|
|
+ $('#compare-active-hint').html(compareObj.getCompareHint());
|
|
|
+ });
|
|
|
+ $('#compare1').change(() => {
|
|
|
+ const phase1 = $('#compare1').val();
|
|
|
+ const phase2 = $('#compare2').val();
|
|
|
+ $('#compare-active-hint').html(compareObj.getCompareHint(phase1, phase2));
|
|
|
+ });
|
|
|
+ $('#compare2').change(() => {
|
|
|
+ const phase1 = $('#compare1').val();
|
|
|
+ const phase2 = $('#compare2').val();
|
|
|
+ $('#compare-active-hint').html(compareObj.getCompareHint(phase1, phase2));
|
|
|
+ });
|
|
|
+ $('#compare-set-ok').click(() => {
|
|
|
+ compareObj.setComparePhase($('#compare1').val(), $('#compare2').val());
|
|
|
+ });
|
|
|
+ $('#export-excel').click(function() {
|
|
|
+ const excelSetting = JSON.parse(JSON.stringify(compareSheet.zh_setting));
|
|
|
+ const gridIndex = excelSetting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
+ if (gridIndex >= 0) excelSetting.cols.splice(gridIndex, 1);
|
|
|
+ SpreadExcelObj.exportSimpleXlsxSheet(excelSetting, compareSheet.zh_tree.nodes, $('.sidebar-title').attr('data-original-title') + "-造价对比.xlsx");
|
|
|
+ });
|
|
|
});
|