|
@@ -16,6 +16,9 @@ $(document).ready(() => {
|
|
const compareSpread = SpreadJsObj.createNewSpread($('#cost-compare')[0]);
|
|
const compareSpread = SpreadJsObj.createNewSpread($('#cost-compare')[0]);
|
|
const compareSheet = compareSpread.getActiveSheet();
|
|
const compareSheet = compareSpread.getActiveSheet();
|
|
|
|
|
|
|
|
+ const getStackedBarTip = function (data) {
|
|
|
|
+ return data.stackedBarTips.join('\n');
|
|
|
|
+ };
|
|
const spreadSetting = {
|
|
const spreadSetting = {
|
|
cols: [
|
|
cols: [
|
|
{title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'},
|
|
{title: '项目节编号', colSpan: '1', rowSpan: '2', field: 'code', hAlign: 0, width: 150, formatter: '@', cellType: 'tree'},
|
|
@@ -36,7 +39,7 @@ $(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: '决算|数量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_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: '|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},
|
|
|
|
|
|
+ {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: '增幅%|数量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: '|1', field: 'grow_tp', hAlign: 2, width: 80, type: 'Number'},
|
|
],
|
|
],
|
|
@@ -93,6 +96,7 @@ $(document).ready(() => {
|
|
calcStackedBar(tree) {
|
|
calcStackedBar(tree) {
|
|
const calcField = this.stackedBarField;
|
|
const calcField = this.stackedBarField;
|
|
const calcFieldColor = { 'gu_tp': '#657798', 'gai_tp': '#EE6666', 'yu_tp': '#74CBED', 'total_price': '#FAC858', 'final_tp': '#62DAAB' };
|
|
const calcFieldColor = { 'gu_tp': '#657798', 'gai_tp': '#EE6666', 'yu_tp': '#74CBED', 'total_price': '#FAC858', 'final_tp': '#62DAAB' };
|
|
|
|
+ const calcFieldCaption = { 'gu_tp': '估算', 'gai_tp': '概算', 'yu_tp': '预算', 'total_price': '台账', 'final_tp': '决算' };
|
|
const calc = function(node, base){
|
|
const calc = function(node, base){
|
|
// const parent = tree.getParent(node);
|
|
// const parent = tree.getParent(node);
|
|
// if (!parent) {
|
|
// if (!parent) {
|
|
@@ -102,8 +106,10 @@ $(document).ready(() => {
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
node.stackedBar = [];
|
|
node.stackedBar = [];
|
|
|
|
+ node.stackedBarTips = [];
|
|
for (const cf of calcField) {
|
|
for (const cf of calcField) {
|
|
node.stackedBar.push({color: calcFieldColor[cf], percent: ZhCalc.div(node[cf], base), field: cf});
|
|
node.stackedBar.push({color: calcFieldColor[cf], percent: ZhCalc.div(node[cf], base), field: cf});
|
|
|
|
+ node.stackedBarTips.push(`${calcFieldCaption[cf]}: ${node[cf] || 0}`);
|
|
}
|
|
}
|
|
if (node.children) {
|
|
if (node.children) {
|
|
for (const child of node.children) {
|
|
for (const child of node.children) {
|
|
@@ -114,7 +120,7 @@ $(document).ready(() => {
|
|
let commonBase = 0;
|
|
let commonBase = 0;
|
|
tree.children.forEach(x => {
|
|
tree.children.forEach(x => {
|
|
for (const cf of calcField) {
|
|
for (const cf of calcField) {
|
|
- commonBase = Math.max(x[cf], commonBase);
|
|
|
|
|
|
+ commonBase = Math.max(x[cf] || 0, commonBase);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
for (const child of tree.children) {
|
|
for (const child of tree.children) {
|