Browse Source

定额附注条件存储。

Chenshilong 8 years ago
parent
commit
f8f5ddf77d

+ 0 - 1
modules/ration_repository/controllers/coe_controller.js

@@ -22,7 +22,6 @@ module.exports ={
 
     getCoeItemsByIDs: function(req,res){
         coeList.getCoeItemsByIDs(JSON.parse(req.body.data), function(err,data){
-            console.log(JSON.stringify(data));;
             callback(req, res, err, 'Get coe', data);
         });
     }

+ 3 - 1
modules/ration_repository/models/ration_item.js

@@ -12,6 +12,7 @@ var rationGljItemSchema = mongoose.Schema({
     consumeAmt: Number,
     proportion: Number //配合比,暂时无需使用,默认0
 }, { _id: false });
+
 var rationItemSchema = mongoose.Schema({
     ID:Number,
     code: String,
@@ -22,7 +23,8 @@ var rationItemSchema = mongoose.Schema({
     rationRepId: Number,
     caption: String,
     feeType: Number,
-    rationGljList: [rationGljItemSchema]
+    rationGljList: [rationGljItemSchema],
+    rationCoeList: Array
 });
 var rationItemModel = db.model("rationItems",rationItemSchema, "rationItems")
 var counter = require('../../../public/counter/counter');

+ 10 - 5
web/maintain/ration_repository/js/ration.js

@@ -44,13 +44,18 @@ var rationOprObj = {
         me.workBook.getSheet(0).bind(GC.Spread.Sheets.Events.CellClick, me.onCellClick);
     },
     onCellClick: function(sender, args) {
-        var me = rationOprObj, sheet = rationGLJOprObj.workBook.getSheet(0), setting = rationGLJOprObj.setting;
+        var me = rationOprObj, sheetGLJ = rationGLJOprObj.workBook.getSheet(0), settingGLJ = rationGLJOprObj.setting,
+            sheetCoe = rationCoeOprObj.workBook.getSheet(0), settingCoe = rationCoeOprObj.setting;
         if(args.sheetArea === GC.Spread.Sheets.SheetArea.colHeader || args.sheetArea === GC.Spread.Sheets.SheetArea.corner){
-            sheetCommonObj.cleanSheet(sheet, setting, -1);
-            sheetCommonObj.shieldAllCells(sheet);
+            sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
+            sheetCommonObj.shieldAllCells(sheetGLJ);
+            sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
+            sheetCommonObj.shieldAllCells(sheetCoe);
         } else {
-            sheetCommonObj.cleanSheet(sheet, setting, -1);
-            sheetCommonObj.shieldAllCells(sheet);
+            sheetCommonObj.cleanSheet(sheetGLJ, settingGLJ, -1);
+            sheetCommonObj.shieldAllCells(sheetGLJ);
+            sheetCommonObj.cleanSheet(sheetCoe, settingCoe, -1);
+            sheetCommonObj.shieldAllCells(sheetCoe);
             var cacheSection = me.getCache();
             if (cacheSection && args.row < cacheSection.length) {
                 rationGLJOprObj.getGljItems(cacheSection[args.row]);

+ 19 - 24
web/maintain/ration_repository/js/ration_coe.js

@@ -8,9 +8,9 @@ var rationCoeOprObj = {
     cache: {},
     setting: {
         header:[
-            {headerName:"编号",headerWidth:160,dataCode:"ID", dataType: "Number"},
+            {headerName:"编号",headerWidth:120,dataCode:"ID", dataType: "Number"},
             {headerName:"名称",headerWidth:400,dataCode:"name", dataType: "String"},
-            {headerName:"内容",headerWidth:500,dataCode:"content", dataType: "String"}
+            {headerName:"内容",headerWidth:300,dataCode:"content", dataType: "String"}
         ],
         view:{
             comboBox:[],
@@ -45,7 +45,7 @@ var rationCoeOprObj = {
 
         }
     },
-    onClipboardPasting: function(sender, args) {
+/*    onClipboardPasting: function(sender, args) {
         var me = rationCoeOprObj;
         if (args.cellRange.colCount != 1 || args.cellRange.col != 0 || !(me.currentRationItem)) {
             args.cancel = true;
@@ -58,22 +58,20 @@ var rationCoeOprObj = {
                 var tmpCoeIDs = sheetCommonObj.analyzePasteData({header:[{dataCode: "ID"}] }, info);
                 var IDs = [];
                 for (var i = 0; i < tmpCoeIDs.length; i++) {
-                    IDs.push(tmpCoeIDs[i].ID);
+                    IDs.push(tmpCoeIDs[i]);
                 }
-                me.addCoeItems(IDs, me.libID);
+                me.addCoeItems(IDs);
             } else {
                 //修改用量
             }
         }
-    },
+    },*/
     onCellEditEnd: function(sender, args){
         var me = rationCoeOprObj;
-        if (args.col = 0) {
-            //重新录入附注条件的ID
-            if (args.editingText == null || args.editingText.trim() == "") {
-                //delete
-                if (me.cache["_Coe_" + me.currentRationItem.ID]) {
-                    var cacheArr = me.cache["_Coe_" + me.currentRationItem.ID];
+        if (args.col == 0) {   // 编号列
+            if (args.editingText == null || args.editingText.trim() == "") {  //delete
+                var cacheArr = me.cache["_Coe_" + me.currentRationItem.ID];
+                if (cacheArr) {
                     if (args.row < cacheArr.length) {
                         cacheArr.splice(args.row, 1);
                         me.updateRationItem();
@@ -91,12 +89,12 @@ var rationCoeOprObj = {
         }
     },
 
-    addCoeItems: function(coeIDs, repId) {
+    addCoeItems: function(coeIDs) {
         var me = this;
         $.ajax({
             type:"POST",
             url:"api/getCoeItemsByIDs",
-            data:{"coeIDs": JSON.stringify(coeIDs), repId: repId},
+            data: {"data": JSON.stringify({"libID": me.libID, "coeIDs": coeIDs})},
             dataType:"json",
             cache:false,
             timeout:5000,
@@ -112,7 +110,7 @@ var rationCoeOprObj = {
                         for (var i = 0; i < rstArr.length; i++) {
                             var hasDup = false;
                             for (var j = 0; j < cacheArr.length; j++) {
-                                if (cacheArr[j].ID == rstArr[i].ID) {
+                                if (cacheArr[j] == rstArr[i]) {
                                     hasDup = true;
                                     break;
                                 }
@@ -123,8 +121,8 @@ var rationCoeOprObj = {
                         }
                         cacheArr.sort(function(a, b) {
                             var rst = 0;
-                            if (a.ID > b.ID) rst = 1
-                            else if (a.ID < b.ID) rst = -1;
+                            if (a > b) rst = 1
+                            else if (a < b) rst = -1;
                             return rst;
                         });
                         me.cache["_Coe_" + me.currentRationItem.ID] = cacheArr.concat(newAddArr);
@@ -145,18 +143,18 @@ var rationCoeOprObj = {
     updateRationItem: function() {
         var me = this, updateArr = [];
         if (me.currentRationItem) {
-            me.currentRationItem.rationCoeList = me.buildRationItemCoe();
+            me.currentRationItem.rationCoeList = me.getCoeIDsArr();
             updateArr.push(me.currentRationItem);
             rationOprObj.mixUpdateRequest(updateArr, [], []);
         }
     },
 
-    buildRationItemCoe: function(){
+    getCoeIDsArr: function(){
         var me = this, rst = [];
         if (me.currentRationItem && me.cache["_Coe_" + me.currentRationItem.ID]) {
             var cacheArr = me.cache["_Coe_" + me.currentRationItem.ID];
             for (var i = 0; i < cacheArr.length; i++) {
-                rst.push({ID: cacheArr[i].ID});
+                rst.push(cacheArr[i].ID);
             }
         }
         return rst;
@@ -180,10 +178,8 @@ var rationCoeOprObj = {
                 timeout:5000,
                 success:function(result){
                     sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
-                    if (result) {
-                        alert(JSON.stringify(result.data));
-                        alert(JSON.stringify(rationCoeList));
 
+                    if (result.data) {
                         var cacheArr = [];
                         for (var i = 0; i < result.data.length; i++) {
                             for (var j = 0; j < rationCoeList.length; j++) {
@@ -193,7 +189,6 @@ var rationCoeOprObj = {
                                 }
                             }
                         };
-                        alert(JSON.stringify(cacheArr));
                         me.cache["_Coe_" + rationID] = cacheArr;
                         me.showCoeItems(rationID);
                     }

+ 1 - 0
web/maintain/ration_repository/js/ration_glj.js

@@ -114,6 +114,7 @@ var rationGLJOprObj = {
             success:function(result){
                 sheetCommonObj.cleanSheet(me.workBook.getSheet(0), me.setting, -1);
                 if (result) {
+                    alert(JSON.stringify(result.data));
                     var rstArr = [], dummyR = {gljId: 0, consumeAmt:0}, newAddArr = [];
                     for (var i = 0; i < result.data.length; i++) {
                         dummyR.gljId = result.data[i].ID;