|
@@ -11,7 +11,7 @@
|
|
$(document).ready(() => {
|
|
$(document).ready(() => {
|
|
const compareTypeKey = 'budget-compareType';
|
|
const compareTypeKey = 'budget-compareType';
|
|
const stackedBarCoverKey = 'budget-stackedBarCover';
|
|
const stackedBarCoverKey = 'budget-stackedBarCover';
|
|
- const stackedBarKey = 'budget-stackedBar-' + window.location.pathname.split('/')[2];
|
|
|
|
|
|
+ const stackedBarKey = 'budget-stackedBar';
|
|
autoFlashHeight();
|
|
autoFlashHeight();
|
|
const compareSpread = SpreadJsObj.createNewSpread($('#cost-compare')[0]);
|
|
const compareSpread = SpreadJsObj.createNewSpread($('#cost-compare')[0]);
|
|
const compareSheet = compareSpread.getActiveSheet();
|
|
const compareSheet = compareSpread.getActiveSheet();
|
|
@@ -91,13 +91,8 @@ $(document).ready(() => {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- getStackedBarField () {
|
|
|
|
- let stackedBarCache = getLocalCache(stackedBarKey);
|
|
|
|
- if (stackedBarCache === null) stackedBarCache = 'gai_tp,total_price,final_tp';
|
|
|
|
- return stackedBarCache ? stackedBarCache.split(',') : [];
|
|
|
|
- },
|
|
|
|
calcStackedBar(tree) {
|
|
calcStackedBar(tree) {
|
|
- const calcField = this.getStackedBarField();
|
|
|
|
|
|
+ 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 calc = function(node, base){
|
|
const calc = function(node, base){
|
|
// const parent = tree.getParent(node);
|
|
// const parent = tree.getParent(node);
|
|
@@ -211,33 +206,39 @@ $(document).ready(() => {
|
|
loadCacheData(){
|
|
loadCacheData(){
|
|
let stackedBarCache = getLocalCache(stackedBarKey);
|
|
let stackedBarCache = getLocalCache(stackedBarKey);
|
|
if (stackedBarCache === null) stackedBarCache = 'gai_tp,total_price,final_tp';
|
|
if (stackedBarCache === null) stackedBarCache = 'gai_tp,total_price,final_tp';
|
|
- this.stackedBarField = stackedBarCache ? stackedBarCache.split(',') : [];
|
|
|
|
- this.compareType = getLocalCache(compareTypeKey);
|
|
|
|
- this.stackedBarCover = getLocalCache(stackedBarCoverKey);
|
|
|
|
|
|
+ this.setStackedBarField(stackedBarCache ? stackedBarCache.split(',') : []);
|
|
|
|
+ this.setCompareType(getLocalCache(compareTypeKey));
|
|
|
|
+ this.setStackedBarCover(getLocalCache(stackedBarCoverKey));
|
|
this.initShowType();
|
|
this.initShowType();
|
|
},
|
|
},
|
|
setStackedBarField(field){
|
|
setStackedBarField(field){
|
|
this.stackedBarField = field;
|
|
this.stackedBarField = field;
|
|
setLocalCache(stackedBarKey, field.join(','));
|
|
setLocalCache(stackedBarKey, field.join(','));
|
|
- this.calcStackedBar(compareSheet.zh_tree);
|
|
|
|
- const colIndex = compareSheet.zh_setting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
|
|
|
+ if (compareSheet.zh_tree) this.calcStackedBar(compareSheet.zh_tree);
|
|
|
|
+ const colIndex = spreadSetting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
SpreadJsObj.reloadColData(compareSheet, colIndex);
|
|
SpreadJsObj.reloadColData(compareSheet, colIndex);
|
|
},
|
|
},
|
|
setCompareType(type) {
|
|
setCompareType(type) {
|
|
this.compareType = type;
|
|
this.compareType = type;
|
|
- setLocalCache(compareTypeKey, type);
|
|
|
|
|
|
+ $('[name=showType]').removeClass('active');
|
|
|
|
+ $(`[tag=${type}]`).addClass('active');
|
|
|
|
+ if (this.compareType === 'grid') {
|
|
|
|
+ $('.ml-auto').show();
|
|
|
|
+ } else {
|
|
|
|
+ $('.ml-auto').hide();
|
|
|
|
+ }
|
|
spreadSetting.cols.forEach(x => {
|
|
spreadSetting.cols.forEach(x => {
|
|
if (!x.bc_type) return;
|
|
if (!x.bc_type) return;
|
|
x.visible = x.bc_type === type;
|
|
x.visible = x.bc_type === type;
|
|
});
|
|
});
|
|
- SpreadJsObj.refreshColumnVisible(compareSheet);
|
|
|
|
|
|
+ setLocalCache(compareTypeKey, type);
|
|
},
|
|
},
|
|
setStackedBarCover(cover){
|
|
setStackedBarCover(cover){
|
|
- this.stackedBarCover = cover;
|
|
|
|
- setLocalCache(stackedBarCoverKey, cover);
|
|
|
|
- const colIndex = compareSheet.zh_setting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
|
- compareSheet.zh_setting.cols[colIndex].stackedBarCover = parseInt(cover);
|
|
|
|
|
|
+ this.stackedBarCover = cover || '1';
|
|
|
|
+ const colIndex = spreadSetting.cols.findIndex(x => { return x.field === 'stackedBar'});
|
|
|
|
+ spreadSetting.cols[colIndex].stackedBarCover = parseInt(cover);
|
|
SpreadJsObj.reloadColData(compareSheet, colIndex);
|
|
SpreadJsObj.reloadColData(compareSheet, colIndex);
|
|
|
|
+ setLocalCache(stackedBarCoverKey, cover);
|
|
}
|
|
}
|
|
};
|
|
};
|
|
compareObj.loadCacheData();
|
|
compareObj.loadCacheData();
|
|
@@ -414,13 +415,14 @@ $(document).ready(() => {
|
|
compareObj.setStackedBarField(field);
|
|
compareObj.setStackedBarField(field);
|
|
});
|
|
});
|
|
$('#dp-stackedBar').click(function() {
|
|
$('#dp-stackedBar').click(function() {
|
|
- const field = compareObj.getStackedBarField();
|
|
|
|
|
|
+ const field = compareObj.stackedBarField;
|
|
const checked = $('[name=stackedBar]');
|
|
const checked = $('[name=stackedBar]');
|
|
checked.each((i, x) => { x.checked = field.indexOf(x.value) >= 0; });
|
|
checked.each((i, x) => { x.checked = field.indexOf(x.value) >= 0; });
|
|
});
|
|
});
|
|
$('a[name=showType]').click(function () {
|
|
$('a[name=showType]').click(function () {
|
|
const type = this.getAttribute('tag');
|
|
const type = this.getAttribute('tag');
|
|
compareObj.setCompareType(type);
|
|
compareObj.setCompareType(type);
|
|
|
|
+ SpreadJsObj.refreshColumnVisible(compareSheet);
|
|
});
|
|
});
|
|
$('a[name=stackedBarCover]').click(function() {
|
|
$('a[name=stackedBarCover]').click(function() {
|
|
const cover = this.getAttribute('tag');
|
|
const cover = this.getAttribute('tag');
|