|
@@ -409,6 +409,7 @@ let repositoryGljObj = {
|
|
|
sheetCommonObj.bindEscKey(me.workBook, [{sheet: me.workBook.getSheet(0), editStarting: me.onCellEditStart, editEnded: me.onCellEditEnd}]);
|
|
|
me.bindEnterKey();
|
|
|
me.repositoryGljDelOpr();
|
|
|
+ me.onContextmenuOpr();
|
|
|
me.setUnitCombo(me.workBook.getActiveSheet(), me.setting.header);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasting, me.onClipboardPasting);
|
|
|
me.workBook.bind(GC.Spread.Sheets.Events.ClipboardPasted, me.onClipboardPasted);
|
|
@@ -538,7 +539,8 @@ let repositoryGljObj = {
|
|
|
},
|
|
|
initSel: function (row) {
|
|
|
let me = repositoryGljObj, that = gljComponentOprObj;
|
|
|
- sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
|
|
|
+ sheetCommonObj.cleanData(that.workBook.getSheet(0), that.setting, -1);
|
|
|
+ //sheetCommonObj.cleanSheet(that.workBook.getSheet(0), that.setting, -1);
|
|
|
me.workBook.focus(true);
|
|
|
me.currentComponent = [];
|
|
|
that.workBook.getSheet(0).setRowCount(10);
|
|
@@ -634,6 +636,7 @@ let repositoryGljObj = {
|
|
|
me.addGljObj = null;
|
|
|
args.sheet.suspendEvent();
|
|
|
args.sheet.suspendPaint();
|
|
|
+ console.log('enter');
|
|
|
for(let col=0; col<me.setting.header.length; col++){
|
|
|
if(col === 0){
|
|
|
me.workBook.getSheet(0).getCell(me.editingRowIdx, 0).formatter("@");
|
|
@@ -690,8 +693,13 @@ let repositoryGljObj = {
|
|
|
},
|
|
|
onCellEditEnd: function(sender, args) {
|
|
|
let me = repositoryGljObj, that = gljComponentOprObj,
|
|
|
- rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me),
|
|
|
updateArr = [], addArr = [], updateBasePrcArr = [];
|
|
|
+ let deESCFields = ['code', 'name', 'specs'];//消除转义字符
|
|
|
+ if(deESCFields.includes(me.setting.header[args.col]['dataCode'])){
|
|
|
+ args.editingText = me.isDef(args.editingText) ? args.editingText.toString().replace(/[\r, \n]/g, '') : '';
|
|
|
+ args.sheet.setValue(args.row, args.col, args.editingText);
|
|
|
+ }
|
|
|
+ let rObj = sheetsOprObj.combineRowData(me.workBook.getSheet(0), me.setting, args.row, me);
|
|
|
me.editingRowIdx = args.row;
|
|
|
//rObj.basePrice = rObj.basePrice ? rObj.basePrice : 0;
|
|
|
me.initPrice(rObj);
|
|
@@ -842,149 +850,200 @@ let repositoryGljObj = {
|
|
|
me.mixUpdateRequest(updateArr, addArr, []);
|
|
|
}
|
|
|
},
|
|
|
- //删除人材机前需要判断人材机是否有被引用,被引用了则不可删除
|
|
|
- repositoryGljDelOpr: function () {
|
|
|
+ delGljs: function (sels) {
|
|
|
let me = repositoryGljObj;
|
|
|
- me.workBook.commandManager().register('repositoryGljDel', function () {
|
|
|
- let sheet = me.workBook.getSheet(0),
|
|
|
- updateArr = [], removeArr = [],
|
|
|
- removeIDs = [],
|
|
|
- removeNames = [],
|
|
|
- updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
- sels = sheet.getSelections(),
|
|
|
- canUpdate = false,
|
|
|
- cacheSection = me.currentCache,
|
|
|
- updateBackups = [];
|
|
|
- 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){
|
|
|
- removeArr.push(cacheSection[sels[i].row + j]);
|
|
|
- removeIDs.push(cacheSection[sels[i].row + j].ID);
|
|
|
- removeNames.push(cacheSection[sels[i].row + j].name);
|
|
|
- //删除后重新计算引用了此工料机的定额单价
|
|
|
- updateBasePrcArr.push({gljId: cacheSection[sels[i].row + j].ID, gljType: cacheSection[sels[i].row + j].gljType, basePrice: 0, delete: 1});
|
|
|
+ let sheet = me.workBook.getSheet(0),
|
|
|
+ updateArr = [], removeArr = [],
|
|
|
+ removeIDs = [],
|
|
|
+ removeNames = [],
|
|
|
+ updateBasePrcArr = [],//删除基价单位后重新计算
|
|
|
+ canUpdate = false,
|
|
|
+ cacheSection = me.currentCache,
|
|
|
+ updateBackups = [];
|
|
|
+ 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){
|
|
|
+ removeArr.push(cacheSection[sels[i].row + j]);
|
|
|
+ removeIDs.push(cacheSection[sels[i].row + j].ID);
|
|
|
+ removeNames.push(cacheSection[sels[i].row + j].name);
|
|
|
+ //删除后重新计算引用了此工料机的定额单价
|
|
|
+ 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;
|
|
|
+ let cantNullDataCode = ['code', 'name', 'gljType'];
|
|
|
+ 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++){
|
|
|
+ let dataCode = me.setting.header[col].dataCode;
|
|
|
+ if(cantNullDataCode.includes(dataCode)){
|
|
|
+ $('#alertText').text(me.setting.header[col].headerName + "不可为空!");
|
|
|
+ $('#codeAlert').modal('show');
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ canUpdate = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else{
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if(canUpdate){
|
|
|
+ //删除警告
|
|
|
+ let upAlertText = '确认删除选中字段?';
|
|
|
+ $('#alertGljTxt').text(upAlertText);
|
|
|
+ $('#gljAlert').modal('show');
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
+ //确认
|
|
|
+ $('#aleConfBtn').bind('click', function () {
|
|
|
+ for(let i = 0; i < sels.length; i++) {
|
|
|
let maxCol = sels[i].col + sels[i].colCount - 1;
|
|
|
- let cantNullDataCode = ['code', 'name', 'gljType'];
|
|
|
- for(let j = 0; j < sels[i].rowCount; j++){
|
|
|
- if(sels[i].row + j < cacheSection.length){
|
|
|
+ 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++){
|
|
|
+ for (let col = sels[i].col; col <= maxCol; col++) {
|
|
|
let dataCode = me.setting.header[col].dataCode;
|
|
|
- if(cantNullDataCode.includes(dataCode)){
|
|
|
- $('#alertText').text(me.setting.header[col].headerName + "不可为空!");
|
|
|
- $('#codeAlert').modal('show');
|
|
|
- return false;
|
|
|
+ if (me.priceCols.includes(col)) {
|
|
|
+ me.setGljPrice(updateObj, 0, col);
|
|
|
+ updateBasePrcArr.push({
|
|
|
+ gljId: updateObj.ID,
|
|
|
+ gljType: updateObj.gljType,
|
|
|
+ basePrice: 0
|
|
|
+ });
|
|
|
}
|
|
|
else {
|
|
|
- canUpdate = true;
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- if(canUpdate){
|
|
|
- //删除警告
|
|
|
- let upAlertText = '确认删除选中字段?';
|
|
|
- $('#alertGljTxt').text(upAlertText);
|
|
|
- $('#gljAlert').modal('show');
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
- //确认
|
|
|
- $('#aleConfBtn').bind('click', function () {
|
|
|
- for(let i = 0; i < sels.length; i++) {
|
|
|
- let maxCol = sels[i].col + sels[i].colCount - 1;
|
|
|
- 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++) {
|
|
|
- let dataCode = me.setting.header[col].dataCode;
|
|
|
- if (me.priceCols.includes(col)) {
|
|
|
- me.setGljPrice(updateObj, 0, col);
|
|
|
- updateBasePrcArr.push({
|
|
|
- gljId: updateObj.ID,
|
|
|
- gljType: updateObj.gljType,
|
|
|
- basePrice: 0
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- if (dataCode === 'materialType') {
|
|
|
- updateObj['materialCoe'] = null;
|
|
|
- }
|
|
|
- updateObj[dataCode] = '';
|
|
|
+ if (dataCode === 'materialType') {
|
|
|
+ updateObj['materialCoe'] = null;
|
|
|
}
|
|
|
+ updateObj[dataCode] = '';
|
|
|
}
|
|
|
- updateArr.push(updateObj);
|
|
|
}
|
|
|
+ updateArr.push(updateObj);
|
|
|
}
|
|
|
}
|
|
|
- me.mixUpdateRequest(updateArr, [], []);
|
|
|
- if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- }
|
|
|
- });
|
|
|
+ }
|
|
|
+ me.mixUpdateRequest(updateArr, [], []);
|
|
|
+ if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- }
|
|
|
- if(removeArr.length > 0){
|
|
|
- $.bootstrapLoading.start();
|
|
|
- CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeIDs}, function (rstData) {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- //存在被引用的人材机(标准/补充定额库)
|
|
|
- if(rstData.isUsed){
|
|
|
- $('#gljAlert').find('.modal-body h5').text('已有定额引用了当前人材机,不可删除。');
|
|
|
- $('#gljAlert').modal('show');
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
- $('#aleConfBtn').bind('click', function () {
|
|
|
- $('#gljAlert').modal('hide');
|
|
|
- me.workBook.focus(true)
|
|
|
- });
|
|
|
- }
|
|
|
- else {
|
|
|
- $('#gljAlert').find('.modal-body h5').text(`确定要删除人材机 “${removeNames.join(',')}” 吗? `);
|
|
|
- setTimeout(function () {
|
|
|
- $('#gljAlert').modal('show');
|
|
|
- }, 200);
|
|
|
- //确认
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
- $('#aleConfBtn').bind('click', function () {
|
|
|
- for(let removeD of removeArr){
|
|
|
- let updateGljs = me.getUpdateGljs(removeD, true);
|
|
|
- if(updateGljs.updateArr.length > 0){
|
|
|
- for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
- updateArr.push(updateGljs.updateArr[i]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- me.mixUpdateRequest(updateArr, [], removeIDs);
|
|
|
- if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
- me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
- me.workBook.focus(true);
|
|
|
- }
|
|
|
- });
|
|
|
- }
|
|
|
- }, function () {
|
|
|
- $.bootstrapLoading.end();
|
|
|
- $('#gljAlert').find('.modal-body h5').text('查询引用错误,不可删除。');
|
|
|
+ }
|
|
|
+ if(removeArr.length > 0){
|
|
|
+ $.bootstrapLoading.start();
|
|
|
+ CommonAjax.post('/stdGljRepository/api/isUsed', {gljIds: removeIDs}, function (rstData) {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ //存在被引用的人材机(标准/补充定额库)
|
|
|
+ if(rstData.isUsed){
|
|
|
+ $('#gljAlert').find('.modal-body h5').text('已有定额引用了当前人材机,不可删除。');
|
|
|
$('#gljAlert').modal('show');
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
$('#aleConfBtn').bind('click', function () {
|
|
|
$('#gljAlert').modal('hide');
|
|
|
- $('#aleConfBtn').unbind('click');
|
|
|
- me.workBook.focus(true);
|
|
|
+ me.workBook.focus(true)
|
|
|
});
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ $('#gljAlert').find('.modal-body h5').text(`确定要删除人材机 “${removeNames.join(',')}” 吗? `);
|
|
|
+ setTimeout(function () {
|
|
|
+ $('#gljAlert').modal('show');
|
|
|
+ }, 200);
|
|
|
+ //确认
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
+ $('#aleConfBtn').bind('click', function () {
|
|
|
+ for(let removeD of removeArr){
|
|
|
+ let updateGljs = me.getUpdateGljs(removeD, true);
|
|
|
+ if(updateGljs.updateArr.length > 0){
|
|
|
+ for(let i = 0; i < updateGljs.updateArr.length; i++){
|
|
|
+ updateArr.push(updateGljs.updateArr[i]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.mixUpdateRequest(updateArr, [], removeIDs);
|
|
|
+ if(updateBasePrcArr.length > 0 && me.rationLibs.length > 0){
|
|
|
+ me.updateRationBasePrcRq(updateBasePrcArr);
|
|
|
+ me.workBook.focus(true);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }, function () {
|
|
|
+ $.bootstrapLoading.end();
|
|
|
+ $('#gljAlert').find('.modal-body h5').text('查询引用错误,不可删除。');
|
|
|
+ $('#gljAlert').modal('show');
|
|
|
+ $('#aleConfBtn').bind('click', function () {
|
|
|
+ $('#gljAlert').modal('hide');
|
|
|
+ $('#aleConfBtn').unbind('click');
|
|
|
+ me.workBook.focus(true);
|
|
|
});
|
|
|
- }
|
|
|
+ });
|
|
|
}
|
|
|
+ }
|
|
|
+ },
|
|
|
+ //删除人材机前需要判断人材机是否有被引用,被引用了则不可删除
|
|
|
+ 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('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) {
|
|
|
let rst = {updateGlj: [], updateBasePrcArr: []}, backUpObj = {},
|
|
|
me = repositoryGljObj,
|