TonyKang 8 rokov pred
rodič
commit
6f9867cbb4

+ 1 - 0
modules/rationRepository/controllers/rationChapterTreeController.js

@@ -12,6 +12,7 @@ var callback = function(req,res,err,data){
     if(err){
         res.status(500)
         res.json({success:false,error:err});
+        //res.json(err);
     }
     else{
         res.status(204);

+ 9 - 5
modules/rationRepository/models/rationChapterTree.js

@@ -24,11 +24,15 @@ var rationChapterTreeDAO = function(){};
 
 rationChapterTreeDAO.prototype.getRationChapterTree = function(repositoryName,callback){
     repositoryMap.getRealLibName(repositoryName, function(err, rst){
-        rationChapterTreeModel.find({"rationRepId": rst[0].ID, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
-            if(data.length) callback(false,data);
-            else  if(err) callback("获取定额树错误!",false)
-            else callback(false,false);
-        })
+        if (err || rst.length == 0) {
+            callback("获取定额库错误!",false)
+        } else {
+            rationChapterTreeModel.find({"rationRepId": rst[0].ID, "$or": [{"isDeleted": null}, {"isDeleted": false} ]},function(err,data){
+                if(data.length) callback(false,data);
+                else  if(err) callback("获取定额树错误!",false)
+                else callback(false,false);
+            })
+        }
     })
 }
 

+ 21 - 0
modules/rationRepository/models/rationItem.js

@@ -0,0 +1,21 @@
+/**
+ * Created by Tony on 2017/4/28.
+ */
+var mongoose = require("mongoose");
+var dbm = require("../../../config/db/db_manager");
+var db = dbm.getCfgConnection("rationRepository")
+//var async = require("async");
+var Schema = mongoose.Schema;
+
+var rationChapterTreeSchema = mongoose.Schema({
+    ID:Number,
+    //ÒÔÏÂÊÇ»ùÓÚÒÑÓÐaccess¿â
+    code: String,
+    name: String,
+    unit: String,
+    basePrice: Number,
+    sectionId: Number,
+    caption: String,
+    feeType: Number
+});
+

+ 1 - 1
modules/rationRepository/models/repositoryMap.js

@@ -37,7 +37,7 @@ rationRepositoryDao.prototype.getRealLibName = function(dispName,callback){
             if (err) {
                 callback('Error', null);
             } else {
-                callback(0, data);
+                callback(false, data);
             }
         });
     } else {

+ 7 - 0
server.js

@@ -145,6 +145,13 @@ app.get('/rationRepository/ration', function(req, res) {
             userID: req.session.userID
         });
 });
+app.get('/rationRepository/gongliao', function(req, res) {
+    res.render('rationLibEditor/gongliao.html',
+        {
+            userAccount: req.session.userAccount,
+            userID: req.session.userID
+        });
+});
 app.use("/rationRepository/api",rationRepository_Router);
 
 app.get("/stdBillsmain", function(req, res){

+ 5 - 3
web/rationLibEditor/dinge.html

@@ -877,9 +877,10 @@
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.exedit.js"></script>
-    <script type="text/javascript" src="/web/rationLibEditor/js/_zSpread.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/chapterTree.js"></script>
-    <script type="text/javascript" src="/web/rationLibEditor/js/dinge.js"></script>
+    <script type="text/javascript" src="/web/rationLibEditor/js/sheetCommon.js"></script>
+    <script type="text/javascript" src="/web/rationLibEditor/js/ration.js"></script>
+    <script type="text/javascript" src="/web/rationLibEditor/js/rationGLJ.js"></script>
     <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>
     <SCRIPT type="text/javascript">
 /*var rationName = getQueryString("rationname");*/
@@ -1366,7 +1367,8 @@ $("#bt-inputCode").blur(function(){
     autoFlashHeight();
     $(document).ready(function(){
         pageOprObj.initParam();
-        rationOprObj.mkRationItemSpread();
+        rationOprObj.buildSheet($("#rationItemsSheet")[0]);
+        rationGLJOprObj.buildSheet($("#rationGLJSheet")[0]);
     });
 </script>
 

+ 1 - 2
web/rationLibEditor/gongliao.html

@@ -192,11 +192,10 @@
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/lib/global.js"></script>
     <!-- zTree -->
-    <script src = "/lib/spreadjs/gc.spread.sheets.all.10.0.1.min.js"></script>
+    <script src = "/lib/spreadjs/sheets/gc.spread.sheets.all.10.0.1.min.js"></script>
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
   	<script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
     <script type="text/javascript" src="/web/rationLibEditor/js/gongliao.js"></script>
-    <script type="text/javascript" src="/web/rationLibEditor/js/_zSpread.js"></script>
     <SCRIPT type="text/javascript">
   		<!--
 var setting = {

+ 0 - 172
web/rationLibEditor/js/_zSpread.js

@@ -1,172 +0,0 @@
-/**
- * Created by Syusuke on 2017/3/17.
- *
- */
-(function($){
-    var _spSetting = {
-        spType:"",
-        header:[],
-        view:{
-            comboBox:[],
-            lockedCells:[]
-        },
-        private:{
-            spType:"",
-            colCount:0,
-            sectionSelected:null,
-            cellPrimValue:null,
-            cellCurrValue:null
-        }
-    }
-
-    _tools = {
-        isArray:function(arr){
-            return Object.prototype.toString.apply(arr) === "[object Array]"
-        },
-        clone:function(obj){
-            if(obj===null) return null;
-            var o = _tools.isArray(obj)?[]:{};
-            for(var i in obj){
-                o[i] = (obj[i] instanceof Date) ? new Date(obj[i].getTime()): (typeof obj[i] === "object"? _tools.clone(obj[i]): obj[i]);
-            }
-            return o;
-        }
-    }
-
-
-    var _initSpread = function(spID,spSetting){
-        spSetting.private.colCount = spSetting.header.length;
-        spSetting.private.spType = spSetting.spType;
-        var spread = new GC.Spread.Sheets.Workbook(spID[0],{sheetCount:1});
-        var ActiveSheet = spread.getActiveSheet();
-        ActiveSheet.setColumnCount(spSetting.header.length, GC.Spread.Sheets.SheetArea.viewport);
-        ActiveSheet.options.isProtected = true;
-        ActiveSheet.getRange(-1, 0, -1 ,100, GC.Spread.Sheets.SheetArea.viewport).locked(false);
-        spread.options.tabStripVisible = false;
-        spread.options.scrollbarMaxAlign = false;
-        for(var i=0;i<spSetting.header.length;i++){
-            ActiveSheet.setValue(0, i, spSetting.header[i].headerName, GC.Spread.Sheets.SheetArea.colHeader);
-            ActiveSheet.setColumnWidth(i,spSetting.header[i].headerWidth, GC.Spread.Sheets.SheetArea.colHeader);
-        }
-        for(var i=0;i<spSetting.view.comboBox.length;i++){
-                var c = spSetting.view.comboBox[i]
-                var cellType = new GC.Spread.Sheets.CellTypes.ComboBox();
-                cellType.items(c.items);
-                ActiveSheet.getRange(c.row,c.col,c.rowCount,c.colCount, GC.Spread.Sheets.SheetArea.viewport).cellType(cellType);
-            }
-        ActiveSheet.getRange(-1, 1, -1 , 100, GC.Spread.Sheets.SheetArea.viewport).locked(true);
-
-        ActiveSheet.bind(GC.Spread.Sheets.Events.EditStarting,function(sender,args){
-            spSetting.private.cellCurrValue = null;
-            spSetting.private.cellPrimValue = ActiveSheet.getValue(args.row,args.col);
-        })
-
-        ActiveSheet.bind(GC.Spread.Sheets.Events.EditEnding,function(sender,args){
-            spSetting.private.cellCurrValue = args.editingText;
-            if(args.col == 0){
-                var a = spSetting.view.lockedCells;
-                var b = [];
-                ActiveSheet.getRange(args.row, 1, 1 , 100, GC.Spread.Sheets.SheetArea.viewport).locked(args.editingText == null);
-                a.forEach(function(x){
-                    b.push(x.col);
-                })
-                b.forEach(function(x){
-                    ActiveSheet.getCell(args.row,x).locked(true);
-                });
-                if(args.editingText == null){
-                    removeAction(spSetting)
-                   for(var i=0;i<spSetting.private.colCount;i++){
-                       ActiveSheet.setValue(args.row,i,null);
-                   }
-                }else{
-                    insertAction(spSetting,function(status){
-                        if(status == 204)
-                            ActiveSheet.setValue(args.row,0,null)
-                        spSetting.private.cellCurrValue = null;
-                        spSetting.private.cellPrimValue = null;
-                    });
-                }
-            }else
-           // var code = ActiveSheet.getValue(args.row,0);
-            {
-                var data = [];
-                for(var i=0;i<spSetting.header.length;i++){
-                    data.push(ActiveSheet.getValue(args.row,i))
-                }
-                data[args.col] = args.editingText
-                updateAction(spSetting,data);
-            }
-        })
-        return spread;
-    }
-    function insertAction(spSetting,callback){
-        var value =JSON.stringify(spSetting.private);
-        $.ajax({
-            type:"POST",
-            url:"http://localhost:6060/rationLibEditor/insert" + spSetting.private.spType,
-            data:{"rationLibName":params.realLibName,"value":value},
-            dataType:"json",
-            cache:false,
-            timeout:50000,
-            success:function(result,textStatus,status){
-                if(status.status == 204){
-                    alert("编号为"+spSetting.private.cellCurrValue+"已存在,不可重复添加!")
-                    callback(status.status)
-                }
-
-                spSetting.private.cellCurrValue = null;
-                spSetting.private.cellPrimValue = null;
-            },
-            error:function(err){
-                alert(err.statusText);
-                spSetting.private.cellCurrValue = null;
-                spSetting.private.cellPrimValue = null;
-            }
-        })
-    }
-    function updateAction(spSetting,data){
-        var value = JSON.stringify(spSetting.private);
-        var datas = JSON.stringify(data);
-        $.ajax({
-            type:"POST",
-            url:"http://localhost:6060/rationLibEditor/update" + spSetting.private.spType,
-            data:{"rationLibName":params.realLibName,"value":value,"data":datas},
-            dataType:"json",
-            cache:false,
-            timeout:50000,
-            success:function(result,textStatus,status){
-                spSetting.private.cellCurrValue = null;
-                spSetting.private.cellPrimValue = null;
-            },
-            error:function(err){
-                alert(err.responseText.error)
-                spSetting.private.cellCurrValue = null;
-                spSetting.private.cellPrimValue = null;
-            }
-        })
-    }
-    function removeAction(spSetting){
-        var value = JSON.stringify(spSetting.private);
-        $.ajax({
-            type:"POST",
-            url:"http://localhost:6060/rationLibEditor/remove" + spSetting.private.spType,
-            data:{"rationLibName":params.realLibName,"value":value},
-            dataType:"json",
-            cache:false,
-            timeout:50000,
-            success:function(result){
-                spSetting.private.cellCurrValue = null;
-                spSetting.private.cellPrimValue = null;
-            },
-            error:function(){
-            }
-        })
-    }
-    $.fn.Spread = {
-        init:function(spID,zSetting){
-            var spSetting = _tools.clone(_spSetting);
-            $.extend(true,spSetting,zSetting);
-            return  _initSpread(spID,spSetting);
-        }
-    }
-}(jQuery))

+ 2 - 2
web/rationLibEditor/js/chapterTree.js

@@ -36,7 +36,7 @@ var zTreeOprObj = {
                 }
             },
             error:function(err){
-                alert(err.responseText.error)
+                alert(err.responseJSON.error);
             }
         })
     },
@@ -61,7 +61,7 @@ var zTreeOprObj = {
         me.addNewNode(rawNode, lastNodeId, function(err, rst){
             if (!(err)) {
                 var newNodes = [], isSilent = false;
-                newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:true, items:[]});
+                newNodes.push({ rationRepId: rst.data.rationRepId, ID: rst.data.ID, ParentID:-1, NextSiblingID:-1, name:"新增节点",isParent:false, items:[]});
                 if (treeObj) {
                     treeObj.addNodes(null, -1, newNodes, isSilent);
                 } else {

+ 0 - 62
web/rationLibEditor/js/dinge.js

@@ -1,62 +0,0 @@
-/**
- * Created by Syusuke on 2017/3/17.
- */
-//---------------------------------------------------页面跳转
-var params = {}
-$("#dinge").click(function(){
-    $(this).attr('href', "/rationLibEditor/rationLib" + "?params=" + JSON.stringify(params))
-})
-$("#gongliao").click(function(){
-    $(this).attr('href', "/rationLibEditor/gongliao" + "?params=" + JSON.stringify(params))
-});
-
-var rationOprObj = {
-    rationSpread : null,
-    rationGLJSpread: null,
-    spSetting_ration: {
-        spType:"Ration",
-        header:[
-            {headerName:"编码",headerWidth:120,data:"rationCode"},
-            {headerName:"名称",headerWidth:400,data:"rationName"},
-            {headerName:"单位",headerWidth:120,data:"unit"},
-            {headerName:"基价",headerWidth:120,data:"basePrice"},
-            {headerName:"显示名称(以%s表示参数)",headerWidth:450,data:"caption"},
-            {headerName:"取费专业",headerWidth:120,data:"feeType"}
-        ],
-        view:{
-            comboBox:[
-                {row:-1,col:2,rowCount:-1,colCount:1}
-            ],
-            lockedCells:[
-                {row:-1,col:3,rowCount:-1, colCount:1}
-            ]
-        }
-    },
-    spSetting_rationGLJ: {
-        spType:"RationGLJ",
-        header:[
-            {headerName:"编码",headerWidth:160},
-            {headerName:"名称",headerWidth:400},
-            {headerName:"单位",headerWidth:160},
-            {headerName:"单位基价",headerWidth:160},
-            {headerName:"定额消耗",headerWidth:160},
-            {headerName:"类型",headerWidth:160},
-            {headerName:"操作",headerWidth:130}
-        ],
-        view:{
-            comboBox:[],
-            lockedCells:[
-                {row:-1,col:1,rowCount:-1, colCount:1},
-                {row:-1,col:2,rowCount:-1, colCount:1},
-                {row:-1,col:3,rowCount:-1, colCount:1},
-                {row:-1,col:5,rowCount:-1, colCount:1},
-                {row:-1,col:6,rowCount:-1, colCount:1}
-            ]
-        }
-    },
-    mkRationItemSpread: function() {
-        var me = this;
-        me.rationSpread =  $.fn.Spread.init($("#rationItemsSheet"), me.spSetting_ration);
-        me.rationGLJSpread =  $.fn.Spread.init($("#rationGLJSheet"), me.spSetting_rationGLJ);
-    }
-}

+ 36 - 0
web/rationLibEditor/js/ration.js

@@ -0,0 +1,36 @@
+/**
+ * Created by Tony on 2017/4/28.
+ */
+var params = {}
+$("#dinge").click(function(){
+    $(this).attr('href', "/rationRepository/ration" + "?params=" + JSON.stringify(params))
+})
+$("#gongliao").click(function(){
+    $(this).attr('href', "/rationRepository/gongliao" + "?params=" + JSON.stringify(params))
+});
+
+var rationOprObj = {
+    sheet: null,
+    setting: {
+        header:[
+            {headerName:"编码",headerWidth:120,data:"rationCode"},
+            {headerName:"名称",headerWidth:400,data:"rationName"},
+            {headerName:"单位",headerWidth:120,data:"unit"},
+            {headerName:"基价",headerWidth:120,data:"basePrice"},
+            {headerName:"显示名称(以%s表示参数)",headerWidth:450,data:"caption"},
+            {headerName:"取费专业",headerWidth:120,data:"feeType"}
+        ],
+        view:{
+            comboBox:[
+                {row:-1,col:2,rowCount:-1,colCount:1}
+            ],
+            lockedCells:[
+                {row:-1,col:3,rowCount:-1, colCount:1}
+            ]
+        }
+    },
+    buildSheet: function(container) {
+        var me = this;
+        me.sheet = sheetCommonObj.buildSheet(container, me.setting);
+    }
+}

+ 31 - 0
web/rationLibEditor/js/rationGLJ.js

@@ -0,0 +1,31 @@
+/**
+ * Created by Tony on 2017/4/28.
+ */
+var rationGLJOprObj = {
+    sheet: null,
+    setting: {
+        header:[
+            {headerName:"编码",headerWidth:160},
+            {headerName:"名称",headerWidth:400},
+            {headerName:"单位",headerWidth:160},
+            {headerName:"单位基价",headerWidth:160},
+            {headerName:"定额消耗",headerWidth:160},
+            {headerName:"类型",headerWidth:160},
+            {headerName:"操作",headerWidth:130}
+        ],
+        view:{
+            comboBox:[],
+            lockedCells:[
+                {row:-1,col:1,rowCount:-1, colCount:1},
+                {row:-1,col:2,rowCount:-1, colCount:1},
+                {row:-1,col:3,rowCount:-1, colCount:1},
+                {row:-1,col:5,rowCount:-1, colCount:1},
+                {row:-1,col:6,rowCount:-1, colCount:1}
+            ]
+        }
+    },
+    buildSheet: function(container) {
+        var me = this;
+        me.sheet = sheetCommonObj.buildSheet(container, me.setting);
+    }
+}

+ 35 - 0
web/rationLibEditor/js/sheetCommon.js

@@ -0,0 +1,35 @@
+/**
+ * Created by Tony on 2017/4/28.
+ */
+var sheetCommonObj = {
+    buildSheet: function(container, setting) {
+        var me = this;
+        var spread = new GC.Spread.Sheets.Workbook(container, { sheetCount: 1 });
+        spread.options.tabStripVisible = false;
+        spread.options.showHorizontalScrollbar = false;
+        var spreadNS = GC.Spread.Sheets;
+        var sheet = spread.getSheet(0);
+        sheet.suspendPaint();
+        sheet.suspendEvent();
+        //Set rowHeader count and columnHeader count.
+        sheet.setRowCount(1, spreadNS.SheetArea.colHeader);
+        sheet.setColumnCount(setting.header.length, spreadNS.SheetArea.viewport);
+        sheet.options.colHeaderAutoTextIndex = 1;
+        sheet.options.colHeaderAutoText = spreadNS.HeaderAutoText.numbers;
+        sheet.showRowOutline(false);
+        //setup column header
+        me.buildHeader(sheet, setting);
+        //setup cells
+        sheet.setRowCount(5);
+        sheet.resumeEvent();
+        sheet.resumePaint();
+        return sheet;
+    },
+    buildHeader: function(sheet, setting){
+        var me = this, ch = GC.Spread.Sheets.SheetArea.colHeader;
+        for (var i = 0; i < setting.header.length; i++) {
+            sheet.setValue(0, i, setting.header[i].headerName, ch);
+            sheet.setColumnWidth(i, setting.header[i].headerWidth?setting.header[i].headerWidth:100);
+        }
+    }
+}