|
@@ -2,6 +2,7 @@
|
|
|
* Created by vian on 2017/4/12.
|
|
|
*/
|
|
|
var dbController = {
|
|
|
+ currentEditData: null,
|
|
|
insert: function(controller, btn){
|
|
|
tools.btnClose(btn);
|
|
|
btn.attr('doing', 'true');
|
|
@@ -274,19 +275,24 @@ var dbController = {
|
|
|
},
|
|
|
|
|
|
editData: function(controller){
|
|
|
+ controller.sheet.bind(GC.Spread.Sheets.Events.EditStarting, function (sender, args) {
|
|
|
+ dbController.currentEditData = args.sheet.getValue(args.row, args.col);
|
|
|
+ });
|
|
|
controller.sheet.bind(GC.Spread.Sheets.Events.EditEnded, function(sender, args){
|
|
|
var node = controller.tree.selected, updateId, field;
|
|
|
if(node){
|
|
|
updateId = node.getID();
|
|
|
- billsLibSetting.cols.forEach(function(col, idx){
|
|
|
- if(args.col === idx){
|
|
|
- field = col.data.field;
|
|
|
- node.data[field] = args.editingText;
|
|
|
- sheetBillsDatas.datasIdx['rowIdx'+ args.row][field] = args.editingText;
|
|
|
+ field = billsLibSetting.cols[args.col].data.field;
|
|
|
+ if(field === 'engineering'){
|
|
|
+ if(isNaN(args.editingText) || args.editingText % 1 !== 0){
|
|
|
+ args.sheet.setValue(args.row, args.col, dbController.currentEditData ? dbController.currentEditData : '');
|
|
|
+ alert('工程专业只能输入整数!');
|
|
|
+ return;
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ node.data[field] = args.editingText;
|
|
|
+ sheetBillsDatas.datasIdx['rowIdx'+ args.row][field] = args.editingText;
|
|
|
billsAjax.updateBills(userAccount, billsLibId, updateId, field, args.editingText);
|
|
|
- //sheetBillsDatas = tools.getsheetDatas(controller.sheet, 'bills', controller);
|
|
|
}
|
|
|
else {
|
|
|
args.sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
|
|
@@ -569,7 +575,6 @@ var tools = {
|
|
|
|
|
|
getValidDatas: function(sheet, setting, args){
|
|
|
let validDatas = [];
|
|
|
- const colLen = 4;
|
|
|
let orgRow = args.cellRange.row, orgCol = args.cellRange.col, rowCount = args.cellRange.rowCount, colCount = args.cellRange.colCount;
|
|
|
let maxRow = orgRow + rowCount - 1, maxCol = orgCol + colCount -1;
|
|
|
for(let i =orgRow; i<=maxRow; i++){
|
|
@@ -577,45 +582,30 @@ var tools = {
|
|
|
for(let j= orgCol; j<=maxCol; j++){
|
|
|
let value = sheet.getValue(i, j);
|
|
|
if(value){
|
|
|
- setting.cols.forEach(function(col, colIdx){
|
|
|
+ /* setting.cols.forEach(function(col, colIdx){
|
|
|
if(colIdx === j){
|
|
|
validData[col.data.field] = value;
|
|
|
}
|
|
|
- });
|
|
|
+ });*/
|
|
|
+ if(setting.cols[j].data.field === 'engineering'){
|
|
|
+ if(!isNaN(value) && value % 1 === 0){
|
|
|
+ validData[setting.cols[j].data.field] = value;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ validData[setting.cols[j].data.field] = value;
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
if(!tools.isEmptyObj(validData)){
|
|
|
validDatas.push(validData);
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- //---------------------------------------
|
|
|
- /*for(let i=orgRow; i<= maxRow; i++){
|
|
|
- if(tools.getValidRow(sheet, i)){
|
|
|
- console.log(`validRow: ${i}`);
|
|
|
- let validData = {code: '', name: '', unit: '', ruleText: ''};
|
|
|
- for(var j=orgCol; j<=maxCol; j++){
|
|
|
- let field;
|
|
|
- setting.cols.forEach(function(col, colIdx){
|
|
|
- if(colIdx === j){
|
|
|
- field = col.data.field;
|
|
|
- if(sheet.getValue(i, j)){
|
|
|
- validData[field] = sheet.getValue(i, j);
|
|
|
- }
|
|
|
- }
|
|
|
- });
|
|
|
- //validData[field] = sheet.getValue(i, j);
|
|
|
- }
|
|
|
- validDatas.push(validData);
|
|
|
- }
|
|
|
- }*/
|
|
|
return validDatas;
|
|
|
},
|
|
|
|
|
|
getValidRow: function(sheet, rowIdx){
|
|
|
- const colCount = 4;
|
|
|
+ const colCount = 5;
|
|
|
let isValid = false;
|
|
|
for(let i=0; i< colCount; i++){
|
|
|
if(sheet.getValue(rowIdx, i, GC.Spread.Sheets.SheetArea.viewport)){
|
|
@@ -1659,7 +1649,7 @@ var jobsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if (controller.tree.selected && newData !== me.currentEditData) {
|
|
|
+ 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
|
|
@@ -1874,7 +1864,7 @@ var itemsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if (controller.tree.selected && newData !== me.currentEditData) {
|
|
|
+ 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
|
|
@@ -2194,7 +2184,7 @@ var totalJobsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if(newData !== me.currentEditData){
|
|
|
+ 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);
|
|
@@ -2282,7 +2272,7 @@ var totalItemsController = {
|
|
|
field = col.data.field;
|
|
|
}
|
|
|
});
|
|
|
- if(newData !== me.currentEditData){
|
|
|
+ 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);
|