|
@@ -151,7 +151,6 @@ var dbController = {
|
|
|
delete: function(controller, btn, totalJobs, totalItems){
|
|
|
tools.btnClose(btn);
|
|
|
btn.attr('doing', 'true');
|
|
|
- console.log(`beforeNodeId :${controller.tree.selected.getID()}`);
|
|
|
var node = controller.tree.selected;
|
|
|
if(node){
|
|
|
var deleteIds = [];
|
|
@@ -372,7 +371,7 @@ var createObj = {
|
|
|
|
|
|
TotalItems.prototype.findItem = function(id){
|
|
|
return this.items[this.prefix + id] ? this.items[this.prefix + id] : null;
|
|
|
- }
|
|
|
+ };
|
|
|
|
|
|
TotalItems.prototype.loadItems = function (nodes, datas){
|
|
|
var me = this;
|
|
@@ -419,6 +418,8 @@ var tools = {
|
|
|
sheet.options.isProtected = true;
|
|
|
let dataCode = args.col === 0 ? 'code' : 'content';
|
|
|
let orgCode = args.row < arr.length ? arr[args.row][field].data[dataCode] : '';
|
|
|
+ $('#alertCof').unbind('click');
|
|
|
+ $('#alertCls').unbind('click');
|
|
|
$('#alertCls').click(function () {
|
|
|
sheet.options.isProtected = false;
|
|
|
sheet.getCell(args.row, args.col).value(orgCode);
|
|
@@ -434,6 +435,8 @@ var tools = {
|
|
|
args.sheet.options.isProtected = true;
|
|
|
let dataCode = args.col === 0 ? 'code' : 'content';
|
|
|
let orgCode = args.row < arr.length ? arr[args.row].data[dataCode] : '';
|
|
|
+ $('#alertCof').unbind('click');
|
|
|
+ $('#alertCls').unbind('click');
|
|
|
$('#alertCls').click(function () {
|
|
|
args.sheet.options.isProtected = false;
|
|
|
args.sheet.getCell(args.row, args.col).value(orgCode);
|
|
@@ -460,7 +463,7 @@ var tools = {
|
|
|
btn.removeClass("disabled");
|
|
|
//btn.attr(attr, 'false');
|
|
|
},
|
|
|
- isExist: function (totalArr, field, newData, orgData){
|
|
|
+ /*isExist: function (totalArr, field, newData, orgData){
|
|
|
var isExist = false;
|
|
|
if(totalArr.length > 0){
|
|
|
totalArr.forEach(function(item){
|
|
@@ -470,10 +473,20 @@ var tools = {
|
|
|
});
|
|
|
}
|
|
|
return isExist;
|
|
|
+ },*/
|
|
|
+ isExist: function (totalArr, field, newData){
|
|
|
+ var isExist = false;
|
|
|
+ if(totalArr.length > 0){
|
|
|
+ totalArr.forEach(function(item){
|
|
|
+ if(item.data[field] == newData){
|
|
|
+ isExist = true;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return isExist;
|
|
|
},
|
|
|
isRepeat: function(arr, field, newData, ref, classify){
|
|
|
var isRepeat = false;
|
|
|
- if(field === 'code'){
|
|
|
if(classify){
|
|
|
if(arr){
|
|
|
arr.forEach(function(item){
|
|
@@ -498,7 +511,6 @@ var tools = {
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
return isRepeat;
|
|
|
},
|
|
|
|
|
@@ -1221,8 +1233,6 @@ var tools = {
|
|
|
rebuildArr.sort(myCompareCode);
|
|
|
if(rebuildArr[0].code){
|
|
|
maxItemsNumber = maxItemsNumber + 1 > rebuildArr[0].code ? maxItemsNumber : rebuildArr[0].code;
|
|
|
- console.log(`maxJobs`);
|
|
|
- console.log(maxItemsNumber);
|
|
|
}
|
|
|
rebuildArr.forEach(function(data){
|
|
|
if(data.type !== 'CreateT' && data.field === 'content' ){
|
|
@@ -1535,7 +1545,6 @@ let pasteController = {
|
|
|
}
|
|
|
}
|
|
|
setSheet.setMaxRowCount(sheet, totalJobs.jobsArr);
|
|
|
- console.log(totalJobs);
|
|
|
tools.reshowData(sheet, totalJobs.jobsArr, totalJobsSetting, true);
|
|
|
sheetJobsDatas = tools.getsheetDatas(sheet, 'total');
|
|
|
},
|
|
@@ -1553,19 +1562,19 @@ let pasteController = {
|
|
|
});
|
|
|
}
|
|
|
else if(datas[i].type === CreateT){
|
|
|
- newItemData = {id: datas[i].newItemId, content: datas[i].content, code: datas[i].code};
|
|
|
+ newItemData = {id: datas[i].newItemId, content: datas[i].content, code: datas[i].code, itemValue: []};
|
|
|
newItem = createObj.newItem(newItemData);
|
|
|
totalItems.itemsArr.push(newItem);
|
|
|
totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
|
|
|
}
|
|
|
else if(datas[i].type !== CreateT && datas[i].field === 'content'){
|
|
|
- newItemData = {id: datas[i].newItemId, content: datas[i].data, code: datas[i].code};
|
|
|
+ newItemData = {id: datas[i].newItemId, content: datas[i].data, code: datas[i].code, itemValue: []};
|
|
|
newItem = createObj.newItem(newItemData);
|
|
|
totalItems.itemsArr.push(newItem);
|
|
|
totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
|
|
|
}
|
|
|
else if(datas[i].type !== 'CreateT' && datas[i].field === 'code'){
|
|
|
- newItemData = {id: datas[i].newItemId, content: '', code: datas[i].data};
|
|
|
+ newItemData = {id: datas[i].newItemId, content: '', code: datas[i].data, itemValue: []};
|
|
|
newItem = createObj.newItem(newItemData);
|
|
|
totalItems.itemsArr.push(newItem);
|
|
|
totalItems.items[totalItems.prefix + datas[i].newItemId] = newItem;
|
|
@@ -1597,7 +1606,7 @@ let pasteController = {
|
|
|
valuesArr.splice(index, 0, updateEle);
|
|
|
}
|
|
|
}
|
|
|
- else if(datas[i].type !== 'UpdateT' && datas[i].field === 'code'){
|
|
|
+ else if(datas[i].type === 'Update' && datas[i].field === 'code'){
|
|
|
if(valuesArr){
|
|
|
for(let j=0; j< valuesArr.length; j++){
|
|
|
if(datas[i].orgId === valuesArr[j].code){
|
|
@@ -1606,7 +1615,7 @@ let pasteController = {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else if(datas[i].type !== 'UpdateT' && datas[i].field === 'value'){
|
|
|
+ else if(datas[i].type === 'Update' && datas[i].field === 'value'){
|
|
|
if(valuesArr){
|
|
|
for(let j=0; j< valuesArr.length; j++){
|
|
|
if(datas[i].orgId === valuesArr[j].code){
|
|
@@ -1620,11 +1629,11 @@ let pasteController = {
|
|
|
valuesArr.push(newValueData);
|
|
|
|
|
|
}
|
|
|
- else if(datas[i].type !== 'CreateT' && datas[i].field === 'value'){
|
|
|
+ else if(datas[i].type === 'Create' && datas[i].field === 'value'){
|
|
|
let newValueData = {value: datas[i].data, code: datas[i].code};
|
|
|
valuesArr.push(newValueData);
|
|
|
}
|
|
|
- else if(datas[i].type !== 'CreateT' && datas[i].field === 'code'){
|
|
|
+ else if(datas[i].type === 'Create' && datas[i].field === 'code'){
|
|
|
let newValueData = {value: '', code: datas[i].data};
|
|
|
valuesArr.push(newValueData);
|
|
|
}
|
|
@@ -1637,9 +1646,11 @@ let pasteController = {
|
|
|
};
|
|
|
|
|
|
var jobsController = {
|
|
|
+ currentEditData: null,
|
|
|
editData: function(controller, sheet, totalJobs, setting){
|
|
|
- sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
|
|
|
- orgJobData = sheet.getCell(args.row, args.col).value();
|
|
|
+ let me = jobsController;
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ me.currentEditData = sheet.getValue(args.row, args.col);
|
|
|
});
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args) {
|
|
|
var field, newData = args.editingText, id = sheet.getTag(args.row, args.col);
|
|
@@ -1648,8 +1659,8 @@ var jobsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if (controller.tree.selected) {
|
|
|
- var isExist = tools.isExist(totalJobs.jobsArr, field, newData, orgJobData);
|
|
|
+ if (controller.tree.selected && newData !== me.currentEditData) {
|
|
|
+ var isExist = tools.isExist(totalJobs.jobsArr, field, newData);
|
|
|
var isRepeat = tools.isRepeat(controller.tree.selected.jobs, field ,newData, 'reference', 'job');
|
|
|
//create
|
|
|
if(!id && newData && !isRepeat){
|
|
@@ -1661,22 +1672,16 @@ var jobsController = {
|
|
|
}
|
|
|
}
|
|
|
//update
|
|
|
- else if(id && newData !== orgJobData && !isRepeat){
|
|
|
+ else if(id && !isRepeat){
|
|
|
jobsController.update(sheet, controller, totalJobs, field, newData, id, isExist, args, setting);
|
|
|
}
|
|
|
//处理重复
|
|
|
if(isRepeat){
|
|
|
- ///if(id && newData){
|
|
|
tools.alertOpr(args, sheet, '该工作内容已存在!', controller.tree.selected.jobs, 'job');
|
|
|
- // }
|
|
|
- // else {
|
|
|
- //sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
|
|
|
- // tools.alertOpr(sheet, controller.tree.selected.jobs, 'jobs');
|
|
|
- // }
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- sheet.getCell(args.row, args.col).value('');
|
|
|
+ sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -1709,7 +1714,7 @@ var jobsController = {
|
|
|
if(field === 'content'&& newData === job.data.content){
|
|
|
let serialNo = tools.getSerialNo(controller.tree.selected.jobs);//update--
|
|
|
//billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', job.data.id);//update--
|
|
|
- billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
|
|
|
+ billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
|
|
|
job.count++;
|
|
|
// controller.tree.selected.jobs.push(job);//update--
|
|
|
controller.tree.selected.jobs.push({job: job, serialNo: serialNo});//update--
|
|
@@ -1718,7 +1723,7 @@ var jobsController = {
|
|
|
}
|
|
|
else if(field == 'code' && newData == job.data.code){
|
|
|
let serialNo = tools.getSerialNo(controller.tree.selected.jobs);//update--
|
|
|
- billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
|
|
|
+ billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'jobs', {id: job.data.id, serialNo: serialNo});//update--
|
|
|
job.count++;
|
|
|
controller.tree.selected.jobs.push({job: job, serialNo: serialNo});//update--
|
|
|
// tools.reshowData(sheet, controller.tree.selected.jobs, setting, true);//update--
|
|
@@ -1856,10 +1861,12 @@ var jobsController = {
|
|
|
};
|
|
|
|
|
|
var itemsController = {
|
|
|
+ currentEditData: null,
|
|
|
editData: function(controller, sheet, totalItems, setting){
|
|
|
- sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
|
|
|
- orgItemData = sheet.getCell(args.row, args.col).value();
|
|
|
- });
|
|
|
+ let me = itemsController;
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ me.currentEditData = sheet.getValue(args.row, args.col);
|
|
|
+ })
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args) {
|
|
|
var field, newData = args.editingText, id = sheet.getTag(args.row, args.col);
|
|
|
setting.cols.forEach(function (col, idx) {
|
|
@@ -1867,8 +1874,8 @@ var itemsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if (controller.tree.selected) {
|
|
|
- var isExist = tools.isExist(totalItems.itemsArr, field, newData, orgItemData);
|
|
|
+ if (controller.tree.selected && newData !== me.currentEditData) {
|
|
|
+ var isExist = tools.isExist(totalItems.itemsArr, field, newData);
|
|
|
var isRepeat = tools.isRepeat(controller.tree.selected.items, field ,newData, 'reference', 'item');
|
|
|
//create
|
|
|
if(!id && newData && !isRepeat){
|
|
@@ -1880,7 +1887,7 @@ var itemsController = {
|
|
|
}
|
|
|
}
|
|
|
//update
|
|
|
- else if(id && newData !== orgItemData && !isRepeat){
|
|
|
+ else if(id && !isRepeat){
|
|
|
itemsController.update(sheet, controller, totalItems, field, newData, id, isExist, args, setting);
|
|
|
}
|
|
|
//处理重复
|
|
@@ -1889,7 +1896,7 @@ var itemsController = {
|
|
|
}
|
|
|
}
|
|
|
else {
|
|
|
- sheet.getCell(args.row, args.col).value('');
|
|
|
+ sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -1898,7 +1905,6 @@ var itemsController = {
|
|
|
if(field === 'content'){
|
|
|
maxItemsNumber++;
|
|
|
let serialNo = tools.getSerialNo(controller.tree.selected.items);
|
|
|
- console.log(`billsLibId: ${billsLibId} billsId: ${controller.tree.selected.getID()} content: ${newData} code: ${maxItemsNumber}`);
|
|
|
itemsAjax.edCreateItem(userAccount, billsLibId, controller.tree.selected.getID(), newData, maxItemsNumber, serialNo, function(newItemId){
|
|
|
let newItemData, newItem;
|
|
|
newItemData = {id: newItemId, content: newData, code: maxItemsNumber};
|
|
@@ -1920,14 +1926,14 @@ var itemsController = {
|
|
|
totalItems.itemsArr.forEach(function(item){
|
|
|
if(field === 'content'&& newData === item.data.content){
|
|
|
let serialNo = tools.getSerialNo(controller.tree.selected.items);
|
|
|
- billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
|
|
|
+ billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
|
|
|
item.count++;
|
|
|
controller.tree.selected.items.push({item: item, serialNo: serialNo});
|
|
|
tools.orderReshowData(sheet, controller.tree.selected.items, setting, 'item', true);
|
|
|
}
|
|
|
else if(field == 'code' && newData == item.data.code){
|
|
|
let serialNo = tools.getSerialNo(controller.tree.selected.items);
|
|
|
- billsAjax.updateBills(billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
|
|
|
+ billsAjax.updateBills(userAccount, billsLibId, controller.tree.selected.getID(), 'items', {id: item.data.id, serialNo: serialNo});
|
|
|
item.count++;
|
|
|
controller.tree.selected.items.push({item: item, serialNo: serialNo});
|
|
|
tools.orderReshowData(sheet, controller.tree.selected.items, setting, 'item', true);
|
|
@@ -1978,14 +1984,6 @@ var itemsController = {
|
|
|
else {
|
|
|
tools.alertOpr(args, sheet, '该编号不存在,请重新输入!', controller.tree.selected.items, 'item');
|
|
|
}
|
|
|
- /* if(typeof newData === 'number'){
|
|
|
- sheet.getCell(args.row, args.col).value(orgItemData);
|
|
|
- }
|
|
|
- else {
|
|
|
- //编号只能为数字
|
|
|
- sheet.getCell(args.row, args.col).value('');
|
|
|
- }
|
|
|
- }*/
|
|
|
}
|
|
|
},
|
|
|
upMove: function (controller, sheet) {
|
|
@@ -2054,37 +2052,42 @@ var itemsController = {
|
|
|
};
|
|
|
|
|
|
var valueController = {
|
|
|
+ currentEditData: null,
|
|
|
editData: function(totalItems, sheet, setting){
|
|
|
- sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
|
|
|
- orgValue = sheet.getValue(args.row, args.col);
|
|
|
- });
|
|
|
+ let me = valueController;
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ me.currentEditData = sheet.getValue(args.row, args.col);
|
|
|
+ })
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
|
|
|
- var newValue = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
+ var newValue = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
setting.cols.forEach(function(col, colIdx){
|
|
|
if(args.col === colIdx){
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if(selectedId){
|
|
|
+ if(selectedId && newValue!== me.currentEditData){
|
|
|
isRepeat = tools.isRepeat(valueController.getValues(totalItems, selectedId), field, newValue, 'document');
|
|
|
if(!tagId && !isRepeat && newValue){//create
|
|
|
- valueController.createValue(sheet, totalItems, selectedId, field, newValue);
|
|
|
+ valueController.createValue(sheet, totalItems, selectedId, field, newValue, args);
|
|
|
}
|
|
|
- else if(tagId && !isRepeat && newValue !== orgValue){//update
|
|
|
- valueController.updateValue(userAccount, totalItems, tagId, newValue, field);
|
|
|
+ else if(tagId && !isRepeat){//update
|
|
|
+ valueController.updateValue(totalItems, tagId, newValue, field, args);
|
|
|
}
|
|
|
if(isRepeat){
|
|
|
if(tagId && newValue){
|
|
|
- sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value(orgValue);
|
|
|
+ sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value(me.currentEditData);
|
|
|
}
|
|
|
else {
|
|
|
sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ else{
|
|
|
+ sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
|
|
|
+ }
|
|
|
});
|
|
|
},
|
|
|
- createValue: function(sheet, totalItems, id, field, newValue){
|
|
|
+ createValue: function(sheet, totalItems, id, field, newValue, args){
|
|
|
var newData;
|
|
|
if(field === 'value'){
|
|
|
var newCode = valueController.getCode(totalItems, id);
|
|
@@ -2092,7 +2095,7 @@ var valueController = {
|
|
|
tools.reSetCell(sheet, sheet.getActiveRowIndex(), 0, newCode, newCode);
|
|
|
}
|
|
|
else {
|
|
|
- if(typeof newValue === 'number'){
|
|
|
+ if(!isNaN(newValue)){
|
|
|
newData = {code: newValue, value: ''};
|
|
|
tools.reSetCell(sheet, sheet.getActiveRowIndex(), null, null, newValue);
|
|
|
}
|
|
@@ -2106,7 +2109,7 @@ var valueController = {
|
|
|
valueDatas = tools.getsheetDatas(sheet, 'total');
|
|
|
},
|
|
|
|
|
|
- updateValue: function(totalItems, tagId, newData, field){
|
|
|
+ updateValue: function(totalItems, tagId, newData, field, args){
|
|
|
var updateData = {code: tagId, newData: newData, field: field};
|
|
|
var itemVals = totalItems.findItem(selectedId).data.itemValue;
|
|
|
if(field === 'value'){
|
|
@@ -2178,26 +2181,33 @@ var valueController = {
|
|
|
};
|
|
|
|
|
|
var totalJobsController = {
|
|
|
+ currentEditData: null,
|
|
|
eiditData: function(totalJobs, sheet, setting){
|
|
|
- sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
|
|
|
- orgJobData = sheet.getCell(args.row, args.col).value();
|
|
|
- });
|
|
|
+ let me = totalJobsController;
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ me.currentEditData = sheet.getValue(args.row, args.col);
|
|
|
+ })
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
|
|
|
- var newData = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
+ var newData = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
setting.cols.forEach(function(col, colIdx){
|
|
|
if(args.col === colIdx){
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference', null);
|
|
|
- if(!tagId && !isRepeat && newData){//create
|
|
|
- totalJobsController.createJob(sheet, totalJobs, field, newData, args);
|
|
|
- }
|
|
|
- else if(tagId && !isRepeat && newData !== orgJobData){//update
|
|
|
+ if(newData !== me.currentEditData){
|
|
|
+ isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference', null);
|
|
|
+ if(!tagId && !isRepeat && newData){//create
|
|
|
+ totalJobsController.createJob(sheet, totalJobs, field, newData, args);
|
|
|
+ }
|
|
|
+ else if(tagId && !isRepeat){//update
|
|
|
totalJobsController.updateJob(totalJobs, tagId, field, newData, args);
|
|
|
+ }
|
|
|
+ if(isRepeat){
|
|
|
+ tools.alertTotalOpr(args, '该工作内容已存在!', totalJobs.jobsArr);
|
|
|
+ }
|
|
|
}
|
|
|
- if(isRepeat){
|
|
|
- tools.alertTotalOpr(args, '该工作内容已存在!', totalJobs.jobsArr);
|
|
|
+ else{
|
|
|
+ sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
|
|
|
}
|
|
|
});
|
|
|
},
|
|
@@ -2259,26 +2269,33 @@ var totalJobsController = {
|
|
|
};
|
|
|
|
|
|
var totalItemsController = {
|
|
|
+ currentEditData: null,
|
|
|
eiditData: function(totalItems, sheet, setting){
|
|
|
- sheet.bind(GC.Spread.Sheets.Events.EnterCell, function(sender, args){
|
|
|
- orgItemData = sheet.getCell(args.row, args.col).value();
|
|
|
+ let me = totalItemsController;
|
|
|
+ sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ me.currentEditData = sheet.getValue(args.row, args.col);
|
|
|
});
|
|
|
sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
|
|
|
- var newData = sheet.getValue(args.row, args.col), tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
+ var newData = args.editingText, tagId = sheet.getTag(args.row, args.col), field, isRepeat;
|
|
|
setting.cols.forEach(function(col, colIdx){
|
|
|
if(args.col === colIdx){
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference', null);
|
|
|
- if(!tagId && !isRepeat && newData){//create
|
|
|
- totalItemsController.createItem(sheet, totalItems, field, newData, args);
|
|
|
- }
|
|
|
- else if(tagId && !isRepeat && newData !== orgItemData){//update
|
|
|
+ if(newData !== me.currentEditData){
|
|
|
+ isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference', null);
|
|
|
+ if(!tagId && !isRepeat && newData){//create
|
|
|
+ totalItemsController.createItem(sheet, totalItems, field, newData, args);
|
|
|
+ }
|
|
|
+ else if(tagId && !isRepeat ){//update
|
|
|
totalItemsController.updateItem(totalItems, tagId, field, newData, args);
|
|
|
+ }
|
|
|
+ else if(isRepeat){
|
|
|
+ tools.alertTotalOpr(args, '该项目特征已存在!', totalItems.itemsArr);
|
|
|
+ }
|
|
|
}
|
|
|
- if(isRepeat){
|
|
|
- tools.alertTotalOpr(args, '该项目特征已存在!', totalItems.itemsArr);
|
|
|
+ else{
|
|
|
+ sheet.getCell(args.row, args.col).value(me.currentEditData ? me.currentEditData : '');
|
|
|
}
|
|
|
});
|
|
|
},
|