|
@@ -76,6 +76,9 @@ var rationGLJOprObj = {
|
|
|
this.sheet.bind(GC.Spread.Sheets.Events.EditEnded, this.onCellEditEnd);
|
|
|
},
|
|
|
bindRationGljDelOpr: function () {
|
|
|
+ if (locked) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
const me = rationGLJOprObj;
|
|
|
const spreadBook = me.sheet.getParent();
|
|
|
spreadBook.commandManager().register('rationGljDelete', function () {
|
|
@@ -189,7 +192,7 @@ var rationGLJOprObj = {
|
|
|
const editingField = me.setting.header[args.col].dataCode;
|
|
|
const trimText = args.editingText ? args.editingText.trim() : '';
|
|
|
const curGLJ = cacheArr[args.row];
|
|
|
- const originText = curGLJ && !_commonUtil.isEmptyVal(curGLJ[editingField]) ? String(curGLJ[editingField]) : '';
|
|
|
+ const originText = curGLJ && !commonUtil.isEmptyVal(curGLJ[editingField]) ? String(curGLJ[editingField]) : '';
|
|
|
if (!trimText || trimText === originText) {
|
|
|
args.sheet.setValue(args.row, args.col, originText);
|
|
|
return;
|
|
@@ -231,57 +234,58 @@ var rationGLJOprObj = {
|
|
|
//控制允许右键菜单在哪个位置出现
|
|
|
let target = SheetDataHelper.safeRightClickSelection($triggerElement, e, me.sheet.getParent());
|
|
|
let sheet = me.sheet;
|
|
|
- let addDis = false, delDis = false;
|
|
|
- let rationGlj = [];
|
|
|
if(me.sheet.getParent().getActiveSheetIndex() === 0 && target.hitTestType === 3){//在表格内&& typeof target.row !== 'undefined' && typeof target.col !== 'undefined'
|
|
|
//rationGlj表
|
|
|
if(typeof target.row !== 'undefined'){
|
|
|
//控制按钮是否可用
|
|
|
sheet.setActiveCell(target.row, target.col);
|
|
|
- console.log(me.currentRationItem);
|
|
|
- if(me.currentRationItem){
|
|
|
- rationGlj = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
- if(!rationGlj ||target.row >= rationGlj.length){//右键定位在有数据的行,删除键才显示可用
|
|
|
- delDis = true;
|
|
|
- }
|
|
|
- else{//有数据
|
|
|
- if(typeof target.col === 'undefined'){//定位不在表格内
|
|
|
- delDis = true;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- addDis = true;
|
|
|
- delDis = true;
|
|
|
- }
|
|
|
- }
|
|
|
- else{
|
|
|
- addDis = true;
|
|
|
- delDis = true;
|
|
|
}
|
|
|
return {
|
|
|
callback: function(){},
|
|
|
items: {
|
|
|
- "add": {name: "添加人材机", disabled: addDis, icon: "fa-plus", callback: function (key, opt) {
|
|
|
- //默认radio所有工料机
|
|
|
- gljSelOprObj.initRadio();
|
|
|
- gljSelOprObj.gljCurTypeId = null;
|
|
|
- //默认点击树根节点
|
|
|
- if(gljSelOprObj.rootNode){
|
|
|
- gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
|
|
|
- gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
|
|
|
- }
|
|
|
- //弹出窗口
|
|
|
- $('#selGlj').modal('show');
|
|
|
- }},
|
|
|
- "delete": {name: "删除人材机", disabled: delDis, icon: "fa-remove", callback: function (key, opt) {
|
|
|
- rationGlj.splice(target.row, 1);
|
|
|
- me.updateRationItem(function(){
|
|
|
- me.sheet.getParent().focus();
|
|
|
- });
|
|
|
- sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|
|
|
- me.showGljItems(me.currentRationItem.ID);
|
|
|
- }},
|
|
|
+ "add": {
|
|
|
+ name: "添加人材机",
|
|
|
+ disabled: function () {
|
|
|
+ const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
|
|
|
+ if (locked || inValidCell || !me.currentRationItem) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ icon: "fa-plus",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ //默认radio所有工料机
|
|
|
+ gljSelOprObj.initRadio();
|
|
|
+ gljSelOprObj.gljCurTypeId = null;
|
|
|
+ //默认点击树根节点
|
|
|
+ if(gljSelOprObj.rootNode){
|
|
|
+ gljSelOprObj.treeObj.selectNode(gljSelOprObj.rootNode);
|
|
|
+ gljSelTreeOprObj.setting.callback.onClick(null, 'componentTree', gljSelOprObj.rootNode);
|
|
|
+ }
|
|
|
+ //弹出窗口
|
|
|
+ $('#selGlj').modal('show');
|
|
|
+ }},
|
|
|
+ "delete": {
|
|
|
+ name: "删除人材机",
|
|
|
+ disabled: function () {
|
|
|
+ const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
|
|
|
+ const rationGlj = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
+ const inValidData = !rationGlj || target.row >= rationGlj.length;
|
|
|
+ if (locked || inValidCell || !me.currentRationItem || inValidData) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ },
|
|
|
+ icon: "fa-remove",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ const rationGlj = me.cache['_GLJ_' + me.currentRationItem.ID];
|
|
|
+ rationGlj.splice(target.row, 1);
|
|
|
+ me.updateRationItem(function(){
|
|
|
+ me.sheet.getParent().focus();
|
|
|
+ });
|
|
|
+ sheetCommonObj.cleanData(me.sheet, me.setting, -1);
|
|
|
+ me.showGljItems(me.currentRationItem.ID);
|
|
|
+ }},
|
|
|
}
|
|
|
};
|
|
|
}
|
|
@@ -289,55 +293,65 @@ var rationGLJOprObj = {
|
|
|
else if(me.sheet.getParent().getActiveSheetIndex() === 2 && target.hitTestType === 3 && typeof target.row !== 'undefined' && typeof target.col !== 'undefined'){
|
|
|
let currentCache = raCoe.curRation && raCoe.isDef(raCoe.cache["_Coe_" + raCoe.curRation.ID]) ? raCoe.cache["_Coe_" + raCoe.curRation.ID] : [];
|
|
|
sheet.setActiveCell(target.row, target.col);
|
|
|
- //控制按钮是否可用
|
|
|
- let upDis = false,
|
|
|
- downDis = false,
|
|
|
- refDis = false;
|
|
|
- if(target.row >= currentCache.length){
|
|
|
- upDis = true;
|
|
|
- downDis = true;
|
|
|
- refDis = true;
|
|
|
- }
|
|
|
- else {
|
|
|
- if(!raCoe.isDef(currentCache[target.row - 1])){
|
|
|
- upDis = true;
|
|
|
- }
|
|
|
- if(!raCoe.isDef(currentCache[target.row + 1])){
|
|
|
- downDis = true;
|
|
|
- }
|
|
|
- }
|
|
|
return {
|
|
|
callback: function(){},
|
|
|
items: {
|
|
|
- "upMove": {name: "上移", disabled: upDis, icon: "fa-arrow-up", callback: function (key, opt) {
|
|
|
- raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
|
|
|
- }},
|
|
|
- "downMove": {name: "下移", disabled: downDis, icon: "fa-arrow-down", callback: function (key, opt) {
|
|
|
- raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
|
|
|
- }},
|
|
|
- "ref": {name: "添加到本节其他定额", disabled: refDis, icon: "fa-arrow-left", callback: function (key, opt) {
|
|
|
- raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
|
|
|
- for(let i = 0, len = updateArr.length; i < len; i++){
|
|
|
- let ration = updateArr[i];
|
|
|
- let rationCoeList = updateArr[i].rationCoeList;
|
|
|
- let newNo = 1;
|
|
|
- for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
|
|
|
- if(rationCoeList[j].no >= newNo){
|
|
|
- newNo = rationCoeList[j].no + 1;
|
|
|
+ "upMove": {
|
|
|
+ name: "上移",
|
|
|
+ disabled: function () {
|
|
|
+ const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
|
|
|
+ const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row - 1]);
|
|
|
+ return locked || inValidCell || inValidData
|
|
|
+ },
|
|
|
+ icon: "fa-arrow-up",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ raCoe.upMove(currentCache[target.row], currentCache[target.row - 1], {row: target.row - 1, col: target.col});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "downMove": {
|
|
|
+ name: "下移",
|
|
|
+ disabled: function () {
|
|
|
+ const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
|
|
|
+ const inValidData = target.row >= currentCache.length || !raCoe.isDef(currentCache[target.row + 1]);
|
|
|
+ return locked || inValidCell || inValidData;
|
|
|
+ },
|
|
|
+ icon: "fa-arrow-down",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ raCoe.downMove(currentCache[target.row], currentCache[target.row + 1], {row: target.row + 1, col: target.col});
|
|
|
+ }
|
|
|
+ },
|
|
|
+ "ref": {
|
|
|
+ name: "添加到本节其他定额",
|
|
|
+ disabled: function () {
|
|
|
+ const inValidCell = !commonUtil.isDef(target.row) || !commonUtil.isDef(target.col);
|
|
|
+ const inValidData = target.row >= currentCache.length;
|
|
|
+ return locked || inValidCell || inValidData;
|
|
|
+ },
|
|
|
+ icon: "fa-arrow-left",
|
|
|
+ callback: function (key, opt) {
|
|
|
+ raCoe.updateSectionRation(rationOprObj.currentRations["_SEC_ID_" + rationOprObj.currentSectionId], currentCache[target.row], function (updateArr) {
|
|
|
+ for(let i = 0, len = updateArr.length; i < len; i++){
|
|
|
+ let ration = updateArr[i];
|
|
|
+ let rationCoeList = updateArr[i].rationCoeList;
|
|
|
+ let newNo = 1;
|
|
|
+ for(let j = 0, jLen = rationCoeList.length; j < jLen; j++){
|
|
|
+ if(rationCoeList[j].no >= newNo){
|
|
|
+ newNo = rationCoeList[j].no + 1;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- let theCache = raCoe.cache["_Coe_" + ration.ID];
|
|
|
- if(theCache !== undefined && theCache !== null){
|
|
|
- let newCoe = {};
|
|
|
- for(let attr in currentCache[target.row]){
|
|
|
- newCoe[attr] = currentCache[target.row][attr];
|
|
|
+ let theCache = raCoe.cache["_Coe_" + ration.ID];
|
|
|
+ if(theCache !== undefined && theCache !== null){
|
|
|
+ let newCoe = {};
|
|
|
+ for(let attr in currentCache[target.row]){
|
|
|
+ newCoe[attr] = currentCache[target.row][attr];
|
|
|
+ }
|
|
|
+ newCoe.no = newNo;
|
|
|
+ theCache.push(newCoe);
|
|
|
}
|
|
|
- newCoe.no = newNo;
|
|
|
- theCache.push(newCoe);
|
|
|
}
|
|
|
- }
|
|
|
- });
|
|
|
- }}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
}
|