|
@@ -39,11 +39,11 @@ const projTreeObj = {
|
|
|
autoUpdate: false
|
|
|
},
|
|
|
header: [
|
|
|
- {name: '工程列表', dataCode: 'name', width: 800, vAlign: 'center', hAlign: 'left'},
|
|
|
- {name: '工程造价', dataCode: 'engineeringCost', width: 170, vAlign: 'center', hAlign: 'right'},
|
|
|
- {name: '单价文件', dataCode: 'unitPriceFile', width: 250, vAlign: 'center', hAlign: 'left'},
|
|
|
- {name: '费率文件', dataCode: 'feeRateFile', width: 250, vAlign: 'center', hAlign: 'left'},
|
|
|
- {name: '创建日期', dataCode: 'createDateTime', width: 90, vAlign: 'center', hAlign: 'center'}
|
|
|
+ {name: '工程列表', dataCode: 'name', width: 0.48, vAlign: 'center', hAlign: 'left'},
|
|
|
+ {name: '工程造价', dataCode: 'engineeringCost', width: 0.13, vAlign: 'center', hAlign: 'right'},
|
|
|
+ {name: '单价文件', dataCode: 'unitPriceFile', width: 0.15, vAlign: 'center', hAlign: 'left'},
|
|
|
+ {name: '费率文件', dataCode: 'feeRateFile', width: 0.15, vAlign: 'center', hAlign: 'left'},
|
|
|
+ {name: '创建日期', dataCode: 'createDateTime', width: 0.09, vAlign: 'center', hAlign: 'center'}
|
|
|
],
|
|
|
//选中行颜色
|
|
|
style: {
|
|
@@ -110,9 +110,11 @@ const projTreeObj = {
|
|
|
};
|
|
|
sheet.setColumnCount(headers.length);
|
|
|
sheet.setRowHeight(0, 40, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
+ let workBookWidth = getWorkBookWidth();
|
|
|
for(let i = 0, len = headers.length; i < len; i++){
|
|
|
sheet.setValue(0, i, headers[i].name, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
- sheet.setColumnWidth(i, headers[i].width, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
+ let width = workBookWidth * headers[i].width;
|
|
|
+ sheet.setColumnWidth(i, width, GC.Spread.Sheets.SheetArea.colHeader);
|
|
|
}
|
|
|
};
|
|
|
me.renderSheetFuc(sheet, fuc);
|
|
@@ -124,9 +126,147 @@ const projTreeObj = {
|
|
|
this.setOptions(newWorkBook, setting.options);
|
|
|
this.buildHeader(newWorkBook.getActiveSheet(), setting.header);
|
|
|
this.bindEvent(newWorkBook);
|
|
|
+ this.loadContextMenu()
|
|
|
}
|
|
|
return newWorkBook;
|
|
|
},
|
|
|
+ loadContextMenu: function () {
|
|
|
+ let me = this;
|
|
|
+ $.contextMenu({
|
|
|
+ selector: '#projSpread',
|
|
|
+ build: function ($trigger, e) {
|
|
|
+ let target = SheetDataHelper.safeRightClickSelection($trigger, e, me.workBook);
|
|
|
+ me.initSelection({row: target.row, rowCount: 1}, me.preSelection ? me.preSelection : null, me.workBook.getActiveSheet());
|
|
|
+ return target.hitTestType === GC.Spread.Sheets.SheetArea.viewport || target.hitTestType === GC.Spread.Sheets.SheetArea.rowHeader;
|
|
|
+ },
|
|
|
+ items: {
|
|
|
+ "addFolder": {
|
|
|
+ name: "新建文件夹",
|
|
|
+ icon: 'fa-folder-o',
|
|
|
+ disabled: function () {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ $("#add-folder-dialog").modal("show");
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#folder-name')[0].focus();
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "addProject": {
|
|
|
+ name: "新建建设项目",
|
|
|
+ icon: 'fa-cubes',
|
|
|
+ disabled: function () {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ $('#add-project-dialog').modal('show');
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#project-name')[0].focus();
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "addEngineering": {
|
|
|
+ name: "新建单项工程",
|
|
|
+ icon: 'fa-cube',
|
|
|
+ disabled: function () {
|
|
|
+ let node = me.tree.selected;
|
|
|
+ if(node && node.data.projType !== projectType.folder){
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ let selectedItem = me.tree.selected;
|
|
|
+ try {
|
|
|
+ if(selectedItem !== null && selectedItem.data.projType !== projectType.folder){
|
|
|
+ $("#add-engineering-dialog").modal("show");
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#engineering-name')[0].focus();
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+
|
|
|
+ } catch (error) {
|
|
|
+ alert(error);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "addTender": {
|
|
|
+ name: "新建单位工程",
|
|
|
+ icon: 'fa-sticky-note-o',
|
|
|
+ disabled: function () {
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ //弹出新建单位工程之前,判断当前使用版本,且当前使用单位工程数是否已到最大值
|
|
|
+ let selectedItem = me.tree.selected;
|
|
|
+ $("#add-tender-dialog").modal("show");
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "spr1": '--------',
|
|
|
+ "rename": {
|
|
|
+ name: "重命名",
|
|
|
+ icon: 'fa-edit',
|
|
|
+ disabled: function () {
|
|
|
+ return !me.tree.selected;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ $('#rename-name').val(projTreeObj.tree.selected.data.name ? projTreeObj.tree.selected.data.name : '');
|
|
|
+ $('#rename-dialog').modal('show');
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#rename-name')[0].focus();
|
|
|
+ }, 300);
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "delete": {
|
|
|
+ name: "删除",
|
|
|
+ icon: 'fa-remove',
|
|
|
+ disabled: function () {
|
|
|
+ let node = me.tree.selected;
|
|
|
+ return !node || (node.data.projType === projectType.folder && node.children.length > 0);
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ if (projTreeObj.tree && projTreeObj.tree.selected) {
|
|
|
+ $('#del').modal('show');
|
|
|
+ }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "copyTo": {
|
|
|
+ name: "复制到",
|
|
|
+ icon: 'fa-copy',
|
|
|
+ disabled: function () {
|
|
|
+ let node = me.tree.selected;
|
|
|
+ return !(node && node.data.projType === projectType.tender);
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+ let selectedItem = projTreeObj.tree.selected;
|
|
|
+ try {
|
|
|
+ let selectedType = selectedItem !== null && selectedItem.data !== undefined ?
|
|
|
+ selectedItem.data.projType : '';
|
|
|
+ if (selectedType !== projectType.tender) {
|
|
|
+ throw '请选择单位工程进行复制';
|
|
|
+ }
|
|
|
+ } catch (error) {
|
|
|
+ alert(error);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ $('#copy-to-dialog').modal('show');
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "spr2": '--------',
|
|
|
+ "share": {
|
|
|
+ name: "分享",
|
|
|
+ icon: 'fa-share',
|
|
|
+ disabled: function () {
|
|
|
+ return true;
|
|
|
+ },
|
|
|
+ callback: function (key, opt) {
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ }
|
|
|
+ });
|
|
|
+ },
|
|
|
getSelStyle: function (backColor) {
|
|
|
let style = new GC.Spread.Sheets.Style();
|
|
|
style.backColor = backColor;
|
|
@@ -152,6 +292,7 @@ const projTreeObj = {
|
|
|
initSelection: function (newSel, oldSel = null,sheet) {
|
|
|
let me = this;
|
|
|
let node = me.tree.items[newSel.row];
|
|
|
+ node = node ? node : null;
|
|
|
//恢复底色
|
|
|
if(oldSel){
|
|
|
me.setSelStyle(oldSel, me.setting.style.defalutBackColor,sheet);
|
|
@@ -839,6 +980,13 @@ const projTreeObj = {
|
|
|
};
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
+ //列宽随着屏幕改变
|
|
|
+ $(window).resize(function () {
|
|
|
+ autoPmWdith(projTreeObj.workBook, projTreeObj.setting.header);
|
|
|
+ autoPmWdith(gcTreeObj.workBook, gcTreeObj.setting.header);
|
|
|
+
|
|
|
+ });
|
|
|
+
|
|
|
init();
|
|
|
$('#tab_pm_all').on('show.bs.tab', function () {
|
|
|
if(gcTreeObj.workBook){
|
|
@@ -883,13 +1031,13 @@ $(document).ready(function() {
|
|
|
bindModalsHidden($('#add-project-dialog'), $('#add-engineering-dialog'), $('#add-folder-dialog'), $('#rename-dialog'));
|
|
|
|
|
|
// 新增建设项目点击
|
|
|
- $('#add-project-btn').click(function () {
|
|
|
+ /*$('#add-project-btn').click(function () {
|
|
|
let selectedItem = projTreeObj.tree.selected;
|
|
|
$('#add-project-dialog').modal('show');
|
|
|
setTimeout(function () {
|
|
|
$('#project-name')[0].focus();
|
|
|
}, 300);
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
// 新增建设项目操作
|
|
|
$('#addProjOk').click(function () {
|
|
@@ -920,7 +1068,7 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
// 新增单项项目点击
|
|
|
- $("#add-engineering-btn").click(function() {
|
|
|
+ /* $("#add-engineering-btn").click(function() {
|
|
|
let selectedItem = projTreeObj.tree.selected;
|
|
|
try {
|
|
|
if(selectedItem !== null && selectedItem.data.projType !== projectType.folder){
|
|
@@ -933,7 +1081,7 @@ $(document).ready(function() {
|
|
|
} catch (error) {
|
|
|
alert(error);
|
|
|
}
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
// 新增单项工程操作
|
|
|
$("#add-engineering-confirm").click(function() {
|
|
@@ -941,11 +1089,11 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
// 新增单位工程点击
|
|
|
- $("#add-tender-btn").click(function() {
|
|
|
+ /*$("#add-tender-btn").click(function() {
|
|
|
//弹出新建单位工程之前,判断当前使用版本,且当前使用单位工程数是否已到最大值
|
|
|
let selectedItem = projTreeObj.tree.selected;
|
|
|
$("#add-tender-dialog").modal("show");
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
//新建单位工程-建设项目提示
|
|
|
$('#poj-name').change(function () {
|
|
@@ -1041,12 +1189,12 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
// 新增文件夹按钮点击
|
|
|
- $("#add-folder-btn").click(function() {
|
|
|
+ /*$("#add-folder-btn").click(function() {
|
|
|
$("#add-folder-dialog").modal("show");
|
|
|
setTimeout(function () {
|
|
|
$('#folder-name')[0].focus();
|
|
|
}, 300);
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
// 新增文件夹操作
|
|
|
$("#add-folder-confirm").click(function() {
|
|
@@ -1054,11 +1202,11 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
// 删除按钮点击
|
|
|
- $('#del-btn').click(function() {
|
|
|
+ /* $('#del-btn').click(function() {
|
|
|
if (projTreeObj.tree && projTreeObj.tree.selected) {
|
|
|
$('#del').modal('show');
|
|
|
}
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
// 删除时文字替换
|
|
|
$('#del').on('show.bs.modal', function() {
|
|
@@ -1120,7 +1268,7 @@ $(document).ready(function() {
|
|
|
});
|
|
|
|
|
|
// 重命名按钮点击
|
|
|
- $('#rename-btn').click(function() {
|
|
|
+ /*$('#rename-btn').click(function() {
|
|
|
if (!projTreeObj.tree) {
|
|
|
return false;
|
|
|
}
|
|
@@ -1133,7 +1281,7 @@ $(document).ready(function() {
|
|
|
setTimeout(function () {
|
|
|
$('#rename-name')[0].focus();
|
|
|
}, 300);
|
|
|
- });
|
|
|
+ });*/
|
|
|
|
|
|
// 重命名操作
|
|
|
$("#rename-confirm").click(function() {
|
|
@@ -1160,7 +1308,7 @@ $(document).ready(function() {
|
|
|
|
|
|
|
|
|
// 复制到按钮点击
|
|
|
- $('#copy-to-btn').click(function () {
|
|
|
+ /*$('#copy-to-btn').click(function () {
|
|
|
let selectedItem = projTreeObj.tree.selected;
|
|
|
try {
|
|
|
let selectedType = selectedItem !== null && selectedItem.data !== undefined ?
|
|
@@ -1173,7 +1321,7 @@ $(document).ready(function() {
|
|
|
return false;
|
|
|
}
|
|
|
$('#copy-to-dialog').modal('show');
|
|
|
- });
|
|
|
+ });*/
|
|
|
// 复制到弹层替换
|
|
|
/* $('#copy-to-dialog').on('show.bs.modal', function () {
|
|
|
copytoZTree = ConvertTreeToZtree(projTreeObj.tree, $('#treeDemo2'), null);
|
|
@@ -1246,6 +1394,24 @@ $(document).ready(function() {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+//获取工作表总宽度
|
|
|
+function getWorkBookWidth(){
|
|
|
+ return workBookWidth = $(window).width() - $('.pm-side').width() - 90;
|
|
|
+}
|
|
|
+
|
|
|
+//根据当前工作表的宽度更改比例
|
|
|
+function autoPmWdith(workBook, headers){
|
|
|
+ if(workBook){
|
|
|
+ const sheet = workBook.getActiveSheet();
|
|
|
+ projTreeObj.renderSheetFuc(sheet, function () {
|
|
|
+ let workBookWidth = getWorkBookWidth();
|
|
|
+ for(let col = 0; col < headers.length; col++){
|
|
|
+ sheet.setColumnWidth(col, workBookWidth * headers[col]['width'], GC.Spread.Sheets.SheetArea.colHeader)
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* 初始化数据
|
|
|
*
|
|
@@ -1984,7 +2150,7 @@ function AddFolder() {
|
|
|
$('#folder-name').val('');
|
|
|
setDangerInfo($('#folder-name-info'), '', false);
|
|
|
};
|
|
|
- if (selectedItem !== null) {
|
|
|
+ if (selectedItem) {
|
|
|
// 判断是否超过3层
|
|
|
if(!withinTreble(selectedItem)){
|
|
|
alert("文件夹不能超过3层");
|