|
@@ -212,6 +212,7 @@ let repositoryGljObj = {
|
|
me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
|
|
me.workBook = sheetOpr.buildSheet(container, me.setting, 30);
|
|
sheetCommonObj.spreadDefaultStyle(me.workBook);
|
|
sheetCommonObj.spreadDefaultStyle(me.workBook);
|
|
me.repositoryGljDelOpr();
|
|
me.repositoryGljDelOpr();
|
|
|
|
+ me.onContextmenuOpr();
|
|
me.bindEnterKey();
|
|
me.bindEnterKey();
|
|
me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
|
|
me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
|
|
me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
me.workBook.getActiveSheet().bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
@@ -333,26 +334,30 @@ let repositoryGljObj = {
|
|
//混凝土202、砂浆203、配合比204、机械3
|
|
//混凝土202、砂浆203、配合比204、机械3
|
|
if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
|
|
if(typeof info.oldSelections || info.oldSelections.length === 0 && info.newSelections.length > 0 || info.oldSelections[0].row !== info.newSelections[0].row){
|
|
let row = info.newSelections[0].row;
|
|
let row = info.newSelections[0].row;
|
|
- sheetOpr.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
|
|
|
|
- me.workBook.focus(true);
|
|
|
|
- me.currentComponent = [];
|
|
|
|
- that.workBook.getSheet(0).setRowCount(5);
|
|
|
|
- if(row < me.currentCache.length){
|
|
|
|
- //标记当前工料机
|
|
|
|
- me.currentGlj = me.currentCache[row];
|
|
|
|
- if(allowComponent.includes(me.currentCache[row].gljType)){
|
|
|
|
- //展示数据
|
|
|
|
- if(me.currentGlj.component.length > 0){
|
|
|
|
- me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
|
|
|
|
- if(me.currentComponent.length > 0){
|
|
|
|
- sheetOpr.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
|
|
|
|
- }
|
|
|
|
|
|
+ me.initSel(row);
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ initSel: function (row) {
|
|
|
|
+ let me = repositoryGljObj, that = gljComponentOprObj;
|
|
|
|
+ sheetOpr.cleanData(that.workBook.getSheet(0), that.setting, -1);
|
|
|
|
+ me.workBook.focus(true);
|
|
|
|
+ me.currentComponent = [];
|
|
|
|
+ that.workBook.getSheet(0).setRowCount(5);
|
|
|
|
+ if(row < me.currentCache.length){
|
|
|
|
+ //标记当前工料机
|
|
|
|
+ me.currentGlj = me.currentCache[row];
|
|
|
|
+ if(allowComponent.includes(me.currentCache[row].gljType)){
|
|
|
|
+ //展示数据
|
|
|
|
+ if(me.currentGlj.component.length > 0){
|
|
|
|
+ me.currentComponent = me.getCurrentComponent(me.currentGlj.component);
|
|
|
|
+ if(me.currentComponent.length > 0){
|
|
|
|
+ sheetOpr.showData(that.workBook.getSheet(0), that.setting, me.currentComponent);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else{
|
|
|
|
- me.currentGlj = null;
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ me.currentGlj = null;
|
|
}
|
|
}
|
|
},
|
|
},
|
|
onEnterCell: function (sender, args) {
|
|
onEnterCell: function (sender, args) {
|
|
@@ -374,19 +379,19 @@ let repositoryGljObj = {
|
|
let focusToCol;
|
|
let focusToCol;
|
|
function getFocusToCol (me){
|
|
function getFocusToCol (me){
|
|
if(!me.addGljObj[me.setting.header[0].dataCode]){
|
|
if(!me.addGljObj[me.setting.header[0].dataCode]){
|
|
- $('#alertGljTxt').text('编号不能为空,继续增加工料机?');
|
|
|
|
|
|
+ $('#alertGljTxt').text('编号不能为空,继续增加人材机?');
|
|
return 0;
|
|
return 0;
|
|
}
|
|
}
|
|
else if(!me.addGljObj[me.setting.header[1].dataCode]){
|
|
else if(!me.addGljObj[me.setting.header[1].dataCode]){
|
|
- $('#alertGljTxt').text('名称不能为空,继续增加工料机?');
|
|
|
|
|
|
+ $('#alertGljTxt').text('名称不能为空,继续增加人材机?');
|
|
return 1;
|
|
return 1;
|
|
}
|
|
}
|
|
else if(!me.addGljObj[me.setting.header[3].dataCode]){
|
|
else if(!me.addGljObj[me.setting.header[3].dataCode]){
|
|
- $('#alertGljTxt').text('计量单位不能为空,继续增加工料机?');
|
|
|
|
|
|
+ $('#alertGljTxt').text('计量单位不能为空,继续增加人材机?');
|
|
return 3;
|
|
return 3;
|
|
}
|
|
}
|
|
else if(!me.addGljObj[me.setting.header[5].dataCode]){
|
|
else if(!me.addGljObj[me.setting.header[5].dataCode]){
|
|
- $('#alertGljTxt').text('类型不能为空,继续增加工料机?');
|
|
|
|
|
|
+ $('#alertGljTxt').text('类型不能为空,继续增加人材机?');
|
|
return 5;
|
|
return 5;
|
|
}
|
|
}
|
|
else {
|
|
else {
|
|
@@ -579,103 +584,153 @@ let repositoryGljObj = {
|
|
me.mixUpdateRequest(updateArr, addArr, []);
|
|
me.mixUpdateRequest(updateArr, addArr, []);
|
|
}
|
|
}
|
|
},
|
|
},
|
|
- repositoryGljDelOpr: function () {
|
|
|
|
|
|
+ delGljs: function (sels) {
|
|
let me = repositoryGljObj;
|
|
let me = repositoryGljObj;
|
|
- me.workBook.commandManager().register('repositoryGljDel', function () {
|
|
|
|
- let sheet = me.workBook.getSheet(0),
|
|
|
|
- updateArr = [], removeArr = [],
|
|
|
|
- tempRemoveArr= [],
|
|
|
|
- refGljCodes = [], //已被引用的工料机
|
|
|
|
- updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
|
- sels = sheet.getSelections(),
|
|
|
|
- canUpdate = false,
|
|
|
|
- cacheSection = me.currentCache;
|
|
|
|
- if(sels.length > 0 && cacheSection.length > 0){
|
|
|
|
- for(let i = 0; i < sels.length; i++){
|
|
|
|
- if(sels[i].colCount === me.setting.header.length){
|
|
|
|
- for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
|
- if(sels[i].row + j < cacheSection.length){
|
|
|
|
- //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
|
|
|
|
- let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
|
|
|
|
- if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
|
- for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
|
- updateArr.push(updateGljs.updateArr[i]);
|
|
|
|
- }
|
|
|
|
- for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
|
- updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
|
|
|
|
- }
|
|
|
|
|
|
+ let sheet = me.workBook.getSheet(0),
|
|
|
|
+ updateArr = [], removeArr = [],
|
|
|
|
+ tempRemoveArr= [],
|
|
|
|
+ refGljCodes = [], //已被引用的工料机
|
|
|
|
+ updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
|
+ canUpdate = false,
|
|
|
|
+ cacheSection = me.currentCache;
|
|
|
|
+ if(sels.length > 0 && cacheSection.length > 0){
|
|
|
|
+ for(let i = 0; i < sels.length; i++){
|
|
|
|
+ if(sels[i].colCount === me.setting.header.length){
|
|
|
|
+ for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
|
+ if(sels[i].row + j < cacheSection.length){
|
|
|
|
+ //删除了已被引用成组成物的工料机,重新计算所有引用此组成物的工料机的单价、组成物数组
|
|
|
|
+ let updateGljs = me.getUpdateGljs(cacheSection[sels[i].row + j], true);
|
|
|
|
+ if(updateGljs.updateArr.length > 0 || updateGljs.updateBasePrcArr.length > 0){
|
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
|
+ }
|
|
|
|
+ for(let i = 0; i < updateGljs.updateBasePrcArr.length; i++){
|
|
|
|
+ updateBasePrcArr.push(updateGljs.updateBasePrcArr[i]);
|
|
}
|
|
}
|
|
- removeArr.push(cacheSection[sels[i].row + j].ID);
|
|
|
|
- //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
|
|
|
|
- //删除后重新计算引用了此工料机的定额单价
|
|
|
|
- updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
|
|
|
|
}
|
|
}
|
|
|
|
+ removeArr.push(cacheSection[sels[i].row + j].ID);
|
|
|
|
+ //tempRemoveArr.push({ID: cacheSection[sels[i].row + j].ID, code: cacheSection[sels[i].row + j].code});
|
|
|
|
+ //删除后重新计算引用了此工料机的定额单价
|
|
|
|
+ updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- else{
|
|
|
|
- let maxCol = sels[i].col + sels[i].colCount - 1;
|
|
|
|
- if(sels[i].col >= 2 && maxCol <= 4){
|
|
|
|
- for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
|
- if(sels[i].row + j < cacheSection.length){
|
|
|
|
- let updateObj = cacheSection[sels[i].row + j];
|
|
|
|
- for(let col = sels[i].col; col <= maxCol; col++){
|
|
|
|
- if(me.setting.header[col].dataCode === 'basePrice'){
|
|
|
|
- //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
|
|
|
|
- if(!allowComponent.includes(updateObj.gljType)){
|
|
|
|
- canUpdate = true;
|
|
|
|
- updateObj[me.setting.header[col].dataCode] = 0;
|
|
|
|
- updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- else{
|
|
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ let maxCol = sels[i].col + sels[i].colCount - 1;
|
|
|
|
+ if(sels[i].col >= 2 && maxCol <= 4){
|
|
|
|
+ for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
|
+ if(sels[i].row + j < cacheSection.length){
|
|
|
|
+ let updateObj = cacheSection[sels[i].row + j];
|
|
|
|
+ for(let col = sels[i].col; col <= maxCol; col++){
|
|
|
|
+ if(me.setting.header[col].dataCode === 'basePrice'){
|
|
|
|
+ //如果类型不为混凝土、砂浆、配合比、机械,才可删除单价 basePrice = 0
|
|
|
|
+ if(!allowComponent.includes(updateObj.gljType)){
|
|
canUpdate = true;
|
|
canUpdate = true;
|
|
- updateObj[me.setting.header[col].dataCode] = '';
|
|
|
|
|
|
+ updateObj[me.setting.header[col].dataCode] = 0;
|
|
|
|
+ updateBasePrcArr.push({gljId: updateObj.ID, gljType: updateObj.gljType, basePrice: 0});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(canUpdate){
|
|
|
|
- updateArr.push(updateObj);
|
|
|
|
|
|
+ else{
|
|
|
|
+ canUpdate = true;
|
|
|
|
+ updateObj[me.setting.header[col].dataCode] = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if(canUpdate){
|
|
|
|
+ updateArr.push(updateObj);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- //编号、名称、类型不可为空
|
|
|
|
- else{
|
|
|
|
- if(sels[i].row < cacheSection.length){
|
|
|
|
- let text = '', cantNullStr =['编码', '名称', '类型'];
|
|
|
|
- for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
|
|
|
|
- if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
|
|
|
|
- text += me.setting.header[col].headerName + " ";
|
|
|
|
- }
|
|
|
|
|
|
+ }
|
|
|
|
+ //编号、名称、类型不可为空
|
|
|
|
+ else{
|
|
|
|
+ if(sels[i].row < cacheSection.length){
|
|
|
|
+ let text = '', cantNullStr =['编码', '名称', '类型'];
|
|
|
|
+ for(let col = sels[i].col; col <= sels[i].col + sels[i].colCount -1; col++){
|
|
|
|
+ if(cantNullStr.indexOf(me.setting.header[col].headerName) !== -1){
|
|
|
|
+ text += me.setting.header[col].headerName + " ";
|
|
}
|
|
}
|
|
- $('#alertText').text(text + "不可为空!");
|
|
|
|
- $('#codeAlertBtn').click();
|
|
|
|
- $('#codAleConfBtn').click(function () {
|
|
|
|
- });
|
|
|
|
- $('#codAleClose').click(function () {
|
|
|
|
- });
|
|
|
|
}
|
|
}
|
|
|
|
+ $('#alertText').text(text + "不可为空!");
|
|
|
|
+ $('#codeAlertBtn').click();
|
|
|
|
+ $('#codAleConfBtn').click(function () {
|
|
|
|
+ });
|
|
|
|
+ $('#codAleClose').click(function () {
|
|
|
|
+ });
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if(removeArr.length > 0 || updateArr.length > 0){
|
|
|
|
- //删除警告
|
|
|
|
- $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
|
|
|
|
- $('#gljAlertBtn').click();
|
|
|
|
- //确认
|
|
|
|
- $('#aleConfBtn').click(function () {
|
|
|
|
- me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
|
- /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
|
- }*/
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ if(removeArr.length > 0 || updateArr.length > 0){
|
|
|
|
+ //删除警告
|
|
|
|
+ $('#alertGljTxt').text('可能已有定额引用了当前工料机,导致定额查找不到此工料机。确定要删除吗?');
|
|
|
|
+ $('#gljAlertBtn').click();
|
|
|
|
+ //确认
|
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
|
+ $('#aleConfBtn').bind('click', function () {
|
|
|
|
+ me.mixUpdateRequest(updateArr, [], removeArr);
|
|
|
|
+ /*if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
|
+ }*/
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ },
|
|
|
|
+ repositoryGljDelOpr: function () {
|
|
|
|
+ let me = repositoryGljObj;
|
|
|
|
+ me.workBook.commandManager().register('repositoryGljDel', function () {
|
|
|
|
+ let sels = me.workBook.getActiveSheet().getSelections();
|
|
|
|
+ me.delGljs(sels);
|
|
});
|
|
});
|
|
-
|
|
|
|
me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
me.workBook.commandManager().setShortcutKey(null, GC.Spread.Commands.Key.del, false, false, false, false);
|
|
me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
me.workBook.commandManager().setShortcutKey('repositoryGljDel', GC.Spread.Commands.Key.del, false, false, false, false);
|
|
},
|
|
},
|
|
|
|
+ onContextmenuOpr: function () {
|
|
|
|
+ let me = repositoryGljObj;
|
|
|
|
+ $.contextMenu({
|
|
|
|
+ selector: '#GLJListSheet',
|
|
|
|
+ build: function($triggerElement, e){
|
|
|
|
+ //控制允许右键菜单在哪个位置出现
|
|
|
|
+ let sheet = me.workBook.getSheet(0);
|
|
|
|
+ let offset = $("#GLJListSheet").offset(),
|
|
|
|
+ x = e.pageX - offset.left,
|
|
|
|
+ y = e.pageY - offset.top;
|
|
|
|
+ let target = sheet.hitTest(x, y);
|
|
|
|
+ let sel = sheet.getSelections()[0];
|
|
|
|
+ if(sel.row === -1){
|
|
|
|
+ sel.row = 0;
|
|
|
|
+ }
|
|
|
|
+ if(sel.col === -1){
|
|
|
|
+ sel.col = 0;
|
|
|
|
+ }
|
|
|
|
+ if(target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){//在表格内
|
|
|
|
+ me.initSel(target.row);
|
|
|
|
+ if(sel.row > target.row || sel.row + sel.rowCount - 1 < target.row ||
|
|
|
|
+ sel.col > target.col || sel.col + sel.colCount - 1 < target.col ){
|
|
|
|
+ sheet.setActiveCell(target.row, target.col);
|
|
|
|
+ }
|
|
|
|
+ return {
|
|
|
|
+ callback: function(){},
|
|
|
|
+ items: {
|
|
|
|
+ "delete": {
|
|
|
|
+ name: "删除",
|
|
|
|
+ disabled: function () {
|
|
|
|
+ return !(me.currentCache && me.currentCache[target.row]);
|
|
|
|
+ },
|
|
|
|
+ icon: "fa-remove",
|
|
|
|
+ callback: function (key, opt) {
|
|
|
|
+ let curSel = _.cloneDeep(sheet.getSelections()[0]);
|
|
|
|
+ curSel.colCount = me.setting.header.length;
|
|
|
|
+ me.delGljs([curSel]);
|
|
|
|
+ }}
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ }
|
|
|
|
+ else{
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ },
|
|
validUpdateObj: function (pasteObj, rowIdx) {
|
|
validUpdateObj: function (pasteObj, rowIdx) {
|
|
let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
|
|
let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
|
|
me = repositoryGljObj,
|
|
me = repositoryGljObj,
|