|
|
@@ -848,9 +848,23 @@ const projTreeObj = {
|
|
|
let shareImg = document.getElementById('share_pic'),
|
|
|
shareImgWidth = 13,
|
|
|
shareImgHeight = 13;
|
|
|
+ let defaultHeight = 18; // 单元格默认高度
|
|
|
let TreeNodeCellType = function () {
|
|
|
};
|
|
|
TreeNodeCellType.prototype = new GC.Spread.Sheets.CellTypes.Text();
|
|
|
+ // 自动行高处理 此函数在每次调用autoFitRow后调用,返回的值作为新的单元格高度
|
|
|
+ // 在单元格设置为自动行高后,单元格的内容有空格时,spreadjs会将空格认为是换行,会导致高度计算不正确,因此在setCellValue中处理空格
|
|
|
+ TreeNodeCellType.prototype.getAutoFitHeight = function(value, text, cellStyle, zoomFactor, context){
|
|
|
+ if (!defaultHeight) {
|
|
|
+ defaultHeight = context.sheet.getCell(context.row, -1).height();
|
|
|
+ }
|
|
|
+ const node = me.tree.items[context.row];
|
|
|
+ const nodeIndent = node ? (node.depth() + 1) * indent + node.depth() * levelIndent + imgWidth + 5 : 0;
|
|
|
+ const cellWidth = context.sheet.getCell(-1, context.col).width();
|
|
|
+ const textLength = this.getAutoFitWidth(...arguments);
|
|
|
+ const lineNum = Math.ceil(textLength / (cellWidth - nodeIndent));
|
|
|
+ return lineNum * defaultHeight;
|
|
|
+ };
|
|
|
TreeNodeCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
|
|
|
if (style.backColor) {
|
|
|
ctx.save();
|
|
|
@@ -1093,7 +1107,11 @@ const projTreeObj = {
|
|
|
const {row, col} = cell;
|
|
|
let dataCode = setting.header[col]['dataCode'];
|
|
|
let value = '';
|
|
|
- if(dataCode === 'unitPriceFile'){
|
|
|
+ if (dataCode === 'name') {
|
|
|
+ // 在单元格设置为自动行高后,单元格的内容有空格时,spreadjs会将空格认为是换行,因此需要处理空格
|
|
|
+ value = node.data.name && node.data.name.replace(new RegExp(' ', 'g'), '\t') || '';
|
|
|
+ }
|
|
|
+ else if(dataCode === 'unitPriceFile'){
|
|
|
if(node.data.projType === projectType.tender){
|
|
|
value = node.data.property && node.data.property.unitPriceFile && node.data.property.unitPriceFile.name ? node.data.property.unitPriceFile.name : '';
|
|
|
}
|
|
|
@@ -1120,7 +1138,9 @@ const projTreeObj = {
|
|
|
sheet.setRowCount(nodes.length);
|
|
|
let treeNodeCell = me.getTreeNodeCell(tree);
|
|
|
sheet.getRange(-1, 0, -1, 1).cellType(treeNodeCell);
|
|
|
+ const rows = [];
|
|
|
for(let i = 0; i < nodes.length; i++){
|
|
|
+ rows.push(i);
|
|
|
for(let j = 0; j < headers.length; j++){
|
|
|
sheet.getRange(-1, j, -1, 1).hAlign(GC.Spread.Sheets.HorizontalAlign[headers[j]['hAlign']]);
|
|
|
sheet.getRange(-1, j, -1, 1).vAlign(GC.Spread.Sheets.VerticalAlign[headers[j]['vAlign']]);
|
|
|
@@ -1136,6 +1156,7 @@ const projTreeObj = {
|
|
|
sheet.setRowVisible(nodes[i].serialNo(), nodes[i].visible);
|
|
|
}
|
|
|
}
|
|
|
+ sheetCommonObj.setRowsAutoFit(sheet, rows, 0, true);
|
|
|
};
|
|
|
me.renderSheetFuc(sheet, fuc);
|
|
|
},
|
|
|
@@ -1239,8 +1260,13 @@ const projTreeObj = {
|
|
|
getFileListWithPath:function (list) {
|
|
|
for(let n of list){
|
|
|
let node = projTreeObj.tree.findNode(n.ID);
|
|
|
- if(node) n.name = getPathName(node);
|
|
|
+ if(node) {
|
|
|
+ n.name = getPathName(node);
|
|
|
+ }
|
|
|
+ n.serialNo = node && node.serialNo() || 1;
|
|
|
}
|
|
|
+ // 按照正确的树结构排序
|
|
|
+ list.sort((a, b) => a.serialNo - b.serialNo);
|
|
|
|
|
|
function getPathName(node) {
|
|
|
if(node.parent && node.parent.data){
|
|
|
@@ -2042,7 +2068,7 @@ $(document).ready(function() {
|
|
|
dialog.modal('hide');
|
|
|
select.data.name = newName;
|
|
|
let sheet = projTreeObj.workBook.getActiveSheet();
|
|
|
- sheet.setValue(sheet.getActiveRowIndex(), 0, newName);
|
|
|
+ projTreeObj.setCellValue({ row: sheet.getActiveRowIndex(), col: 0 }, select, sheet, projTreeObj.setting);
|
|
|
});
|
|
|
});
|
|
|
|
|
|
@@ -2538,6 +2564,8 @@ function AddTenderItems(selected, projName, tenderName, property, callback, errC
|
|
|
});
|
|
|
let pojNode = projTreeObj.insert(projData, parent, next);
|
|
|
let tenderNode = projTreeObj.insert(tenderData, pojNode, null);
|
|
|
+ const rows = [pojNode.serialNo(), tenderNode.serialNo()];
|
|
|
+ sheetCommonObj.setRowsAutoFit(projTreeObj.workBook.getSheet(0), rows, 0, true)
|
|
|
callback();
|
|
|
}, errCB);
|
|
|
}, errCB);
|
|
|
@@ -2554,14 +2582,15 @@ function AddTenderItems(selected, projName, tenderName, property, callback, errC
|
|
|
updateDatas.push({updateType: 'update', updateData: {ID: pre.id(), NextSiblingID: tenderID}});
|
|
|
}
|
|
|
UpdateProjectData(updateDatas, function (datas) {
|
|
|
- let tenderNode = null;
|
|
|
datas.forEach(function (data) {
|
|
|
if(data.updateType === 'new') {
|
|
|
data.updateData.shareInfo = [];
|
|
|
setInitSummaryData(data.updateData);
|
|
|
data.updateData.feeStandardName = data.updateData.property.feeStandardName || '';
|
|
|
data.updateData.valuationType = data.updateData.property.valuationType === 'bill' ? '预算' : '工程量清单';
|
|
|
- tenderNode = projTreeObj.insert(data.updateData, tempProj, null);
|
|
|
+ const tenderNode = projTreeObj.insert(data.updateData, tempProj, null);
|
|
|
+ const rows = [tenderNode.serialNo()];
|
|
|
+ sheetCommonObj.setRowsAutoFit(projTreeObj.workBook.getSheet(0), rows, 0, true);
|
|
|
}
|
|
|
});
|
|
|
callback();
|
|
|
@@ -2601,7 +2630,8 @@ function AddChildrenItem(selected, name, property, type, existCallback, sucCallb
|
|
|
if (data.updateType === 'new') {
|
|
|
data.updateData.shareInfo = [];
|
|
|
setInitSummaryData(data.updateData);
|
|
|
- projTreeObj.insert(data.updateData, parent, null);
|
|
|
+ const node = projTreeObj.insert(data.updateData, parent, null);
|
|
|
+ sheetCommonObj.setRowsAutoFit(projTreeObj.workBook.getSheet(0), [node.serialNo()], 0, true);
|
|
|
}
|
|
|
});
|
|
|
sucCallback();
|
|
|
@@ -2641,7 +2671,8 @@ function AddSiblingsItem(selected, name, property, type, existCallback, sucCallb
|
|
|
if (data.updateType === 'new') {
|
|
|
data.updateData.shareInfo = [];
|
|
|
setInitSummaryData(data.updateData);
|
|
|
- projTreeObj.insert(data.updateData, parent, next);
|
|
|
+ const node = projTreeObj.insert(data.updateData, parent, next);
|
|
|
+ sheetCommonObj.setRowsAutoFit(projTreeObj.workBook.getSheet(0), [node.serialNo()], 0, true);
|
|
|
}
|
|
|
});
|
|
|
sucCallback();
|