瀏覽代碼

新增允许用户对编号进行操作

zhongzewei 8 年之前
父節點
當前提交
46e0109ae7

+ 20 - 14
modules/billsLib/billsLibModel/billsLibInterfaces.js

@@ -462,7 +462,6 @@ billsLibDao.prototype.createJobContent = function(cJobData, callback){
     counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1, function(err, result){
         var id = result.value.sequence_value;
         var newJobContent;
-        if(field == "content"){
             newJobContent = {
                 id: id,
                 billsLibId: billsLibId,
@@ -470,14 +469,11 @@ billsLibDao.prototype.createJobContent = function(cJobData, callback){
                 content: data,
                 deleted: false
             }
-        }
         JobContent.create(newJobContent, function(err){
             if(err){
                 callback(1, "Error", null);
-                console.log('error');
             }
             else{
-                console.log(id);
                 callback(0, "", id);
             }
         });
@@ -550,7 +546,6 @@ billsLibDao.prototype.createItemCharacter = function(cItemData, callback){
     var newItemCharacter;
     counter.counterDAO.getIDAfterCount(counter.moduleName.billsLib, 1, function(err, result){
         var id = result.value.sequence_value;
-        if(field === 'content'){
             newItemCharacter = {
                 id: id,
                 billsLibId: billsLibId,
@@ -558,7 +553,6 @@ billsLibDao.prototype.createItemCharacter = function(cItemData, callback){
                 code: serialNo,
                 deleted: false
             }
-        }
         ItemCharacter.create(newItemCharacter, function(err){
             if(err){
                 callback(1, "Error", null);
@@ -612,14 +606,26 @@ billsLibDao.prototype.updateValue = function(uData, callback){
         });
     }
     else if(type === 'update'){
-        ItemCharacter.update({id: updateId,  'itemValue.code': data.code}, {$set: {'itemValue.$.value': data.value}}, function(err){
-            if(err){
-                callback(1, 'Error');
-            }
-            else{
-                callback(0, '');
-            }
-        });
+        if(data.field === 'code'){
+            ItemCharacter.update({id: updateId,  'itemValue.code': data.code}, {$set: {'itemValue.$.code': data.newData}}, function(err){
+                if(err){
+                    callback(1, 'Error');
+                }
+                else{
+                    callback(0, '');
+                }
+            });
+        }
+        else {
+            ItemCharacter.update({id: updateId,  'itemValue.code': data.code}, {$set: {'itemValue.$.value': data.newData}}, function(err){
+                if(err){
+                    callback(1, 'Error');
+                }
+                else{
+                    callback(0, '');
+                }
+            });
+        }
     }
     //delete
     else {

+ 1 - 1
public/web/idTree.js

@@ -340,7 +340,7 @@ var idTree = {
                 if (orgPre.preSibling) {
                     orgPre.preSibling.setNextSibling(this);
                 }
-                orgPre.seNextSibling(this.nextSibling);
+                orgPre.setNextSibling(this.nextSibling);
                 this.preSibling = orgPre.preSibling;
                 orgPre.preSibling = this;
                 this.setNextSibling(orgPre);

+ 0 - 1
web/billsLib/html/neirong.html

@@ -194,7 +194,6 @@
         });
         function buildAllJobs(spreadAllJobs, setting){
             setSheet.initSheet(spreadAllJobs, setting);
-            setSheet.setEditCol(spreadAllJobs.getActiveSheet(), 1);
             myKey.downKey(spreadAllJobs);
             myKey.enterKey(spreadAllJobs);
             TREE_SHEET_HELPER.loadSheetHeader(setting, spreadAllJobs.getActiveSheet());

+ 1 - 2
web/billsLib/html/tezheng.html

@@ -203,7 +203,6 @@
             setSheet.initSheet(spread, setting);
             myKey.downKey(spread);
             myKey.enterKey(spread);
-            setSheet.setEditCol(spread.getActiveSheet(), 1);
             TREE_SHEET_HELPER.loadSheetHeader(setting, spread.getActiveSheet());
             itemsAjax.getItemCharacter(billsLibId, function(datas){
                 spread.getActiveSheet().suspendPaint();
@@ -238,7 +237,7 @@
         function buildEigenvalue(spread, setting){
             setSheet.initSheet(spread, setting);
             setSheet.setMaxRowCount(spread.getActiveSheet(), 10);
-            setSheet.setEditCol(spread.getActiveSheet(), 1);
+           // setSheet.setEditCol(spread.getActiveSheet(), 1);
             myKey.downKey(spread);
             myKey.enterKey(spread);
             TREE_SHEET_HELPER.loadSheetHeader(setting, spread.getActiveSheet());

+ 80 - 47
web/billsLib/scripts/dbController.js

@@ -363,7 +363,9 @@ var tools = {
     },
 
     reSetCell: function(sheet, rowIdx, colIdx, value, id){
-        sheet.getCell(rowIdx, colIdx, GC.Spread.Sheets.SheetArea.viewport).value(value);
+        if(value && colIdx){
+            sheet.getCell(rowIdx, colIdx, GC.Spread.Sheets.SheetArea.viewport).value(value);
+        }
         sheet.setTag(rowIdx, 0, id);
         sheet.setTag(rowIdx, 1, id);
     },
@@ -826,53 +828,80 @@ var valueController = {
             if(selectedId){
                 isRepeat = tools.isRepeat(valueController.getValues(totalItems, selectedId), field, newValue, 'document');
                 if(!tagId && !isRepeat && newValue){//create
-                    if(field === 'value'){
-                        valueController.createValue(sheet, totalItems, selectedId, newValue);
-                    }
-                    else {
+                   // if(field === 'value'){
+                        valueController.createValue(sheet, totalItems, selectedId, field, newValue);
+                  //  }
+                    /*else {
                         sheet.getCell(args.row, args.col).value('');
-                    }
+                    }*/
                 }
                 else if(tagId && !isRepeat && newValue !== orgValue){//update
-                    if(field === 'value'){
-                        valueController.updateValue(totalItems, tagId, newValue);
-                    }
-                    else {
+                   // if(field === 'value'){
+                        valueController.updateValue(totalItems, tagId, newValue, field);
+                    console.log('updateV');
+                  //  }
+                   /* else {
                         sheet.getCell(args.row, args.col).value(orgValue);
-                    }
+                    }*/
                 }
                 if(isRepeat){
                     if(tagId && newValue){
                         sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value(orgValue);
+                        console.log('rePV1');
                     }
                     else {
                         sheet.getCell(args.row, args.col, GC.Spread.Sheets.SheetArea.viewport).value('');
+                        console.log('rePV2');
                     }
                 }
             }
         });
     },
 
-    createValue: function(sheet, totalItems, id, newValue){
-        var newData, newCode = valueController.getCode(totalItems, id);
-        newData = {code: newCode, value: newValue};
+    createValue: function(sheet, totalItems, id, field, newValue){
+        var newData;
+        if(field === 'value'){
+            var newCode = valueController.getCode(totalItems, id);
+            newData = {code: newCode, value: newValue};
+            tools.reSetCell(sheet, sheet.getActiveRowIndex(), 0, newCode, newCode);
+        }
+        else {
+            newData = {code: newValue, value: ''};
+            tools.reSetCell(sheet, sheet.getActiveRowIndex(), null, null, newValue);
+        }
         totalItems.findItem(id).data.itemValue.push(newData);
         itemsAjax.updateValue(id, newData, null, 'create');
-        tools.reSetCell(sheet, sheet.getActiveRowIndex(), 0, newCode, newCode);
     },
 
-    updateValue: function(totalItems, tagId, newValue){
-        var updateData = {code: tagId, value: newValue};
+    updateValue: function(totalItems, tagId, newData, field){
+        var updateData = {code: tagId, newData: newData, field: field};
         var itemVals = totalItems.findItem(selectedId).data.itemValue;
-        if(itemVals){
-            var index;
-            itemVals.forEach(function(val){
-                if(val.code === tagId){
-                    index = itemVals.indexOf(val);
-                    itemVals.splice(index, 1);
-                }
-            });
-            itemVals.splice(index, 0, updateData);
+        if(field === 'value'){
+            var updateEle = {code: tagId, value: newData};
+            if(itemVals){
+                var index;
+                itemVals.forEach(function(val){
+                    if(val.code === tagId){
+                        index = itemVals.indexOf(val);
+                        itemVals.splice(index, 1);
+                    }
+                });
+                itemVals.splice(index, 0, updateEle);
+            }
+        }
+        else {
+            if(itemVals){
+                var updateEle;
+                var index;
+                itemVals.forEach(function(val){
+                    if(val.code === tagId){
+                        updateEle = {code: newData, value: val.value};
+                        index = itemVals.indexOf(val);
+                        itemVals.splice(index, 1);
+                    }
+                });
+                itemVals.splice(index, 0, updateEle);
+            }
         }
         itemsAjax.updateValue(selectedId, updateData, null, 'update');
     },
@@ -914,7 +943,6 @@ var totalJobsController = {
             setting.cols.forEach(function(col, colIdx){
                 if(args.col === colIdx){
                     field = col.data.field;
-                    console.log('colIdx' + colIdx);
                 }
             });
             isRepeat = tools.isRepeat(totalJobs.jobsArr, field, newData, 'reference');
@@ -922,12 +950,7 @@ var totalJobsController = {
                 totalJobsController.createJob(sheet, totalJobs, field, newData, args);
             }
             else if(tagId && !isRepeat && newData !== orgJobData){//update
-                if(field === 'content'){
                     totalJobsController.updateJob(totalJobs, tagId, field, newData);
-                }
-                else {
-                    sheet.getCell(args.row, args.col).value(orgJobData);
-                }
             }
             if(isRepeat){
                 if(tagId && newData){
@@ -952,17 +975,25 @@ var totalJobsController = {
             });
         }
         else {
-            sheet.getCell(args.row, args.col).value('');
+            maxJobsNumber = maxJobsNumber >= newData ? maxJobsNumber : newData;
+            console.log('maxJobs: ' + maxJobsNumber + 'code: ' + newData);
+            jobsAjax.createJobContent(billsLibId, field, '', newData, function(id){
+                var newJobData, newJob;
+                newJobData = {id: id, content: '', code: newData};
+                newJob = createObj.newJob(newJobData);
+                totalJobs.jobsArr.push(newJob);
+                tools.reSetCell(sheet, args.row, 0, null, id);
+            });
         }
     },
 
     updateJob: function(totalJobs, id, field, newData){
-        totalJobs.jobsArr.forEach(function(job){
-            if(job.data[field] === newData){
-                job.data[field] = newData;
-            }
-        });
-        jobsAjax.updateJobContent(id, field, newData);
+            totalJobs.jobsArr.forEach(function(job){
+                if(job.data[field] === newData){
+                    job.data[field] = newData;
+                }
+            });
+            jobsAjax.updateJobContent(id, field, newData);
     }
 };
 
@@ -981,15 +1012,10 @@ var totalItemsController = {
             });
             isRepeat = tools.isRepeat(totalItems.itemsArr, field, newData, 'reference');
             if(!tagId && !isRepeat && newData){//create
-                totalItemsController.createJob(sheet, totalItems, field, newData, args);
+                totalItemsController.createItem(sheet, totalItems, field, newData, args);
             }
             else if(tagId && !isRepeat && newData !== orgItemData){//update
-                if(field === 'content'){
                     totalItemsController.updateItem(totalItems, tagId, field, newData);
-                }
-                else {
-                    sheet.getCell(args.row, args.col).value(orgItemData);
-                }
             }
             if(isRepeat){
                 if(tagId && newData){
@@ -1014,12 +1040,19 @@ var totalItemsController = {
             });
         }
         else {
-            sheet.getCell(args.row, args.col).value('');
+            maxItemsNumber = maxItemsNumber >= newData ? maxItemsNumber : newData;
+            itemsAjax.createItemCharacter(billsLibId, field, '', newData, function(id){
+                var newItemData, newItem;
+                newItemData = {id: id, content: '', code: newData};
+                newItem = createObj.newItem(newItemData);
+                totalItems.itemsArr.push(newItem);
+                tools.reSetCell(sheet, args.row, 0, null, id);
+            });
         }
     },
 
     updateItem: function(totalItems, id, field, newData){
-        totalItems.jobsArr.forEach(function(item){
+        totalItems.itemsArr.forEach(function(item){
             if(item.data[field] === newData){
                 item.data[field] = newData;
             }