소스 검색

Merge branch 'master' of http://smartcost.f3322.net:3000/SmartCost/ConstructionCost

Chenshilong 7 년 전
부모
커밋
8699c57bcf

+ 1 - 1
gulpfile.js

@@ -81,7 +81,7 @@ function minify(options) {
     if(options.jspaths){
         return gulp.src(options.jspaths)
             .pipe($.plumber())
-            .pipe(uglify())
+           // .pipe(uglify())
             .pipe($.concat(options.concatName+"."+version+".js"))
             .pipe(gulp.dest(scriptsDest));
     }

+ 44 - 2
modules/ration_glj/controllers/ration_glj_controller.js

@@ -3,10 +3,13 @@
  */
 let mongoose = require("mongoose")
 let ration_glj_facade = require('../facade/ration_glj_facade')
+import EngineeringLibModel from "../../users/models/engineering_lib_model";
 
 module.exports={
     createRationGLJ:createRationGLJ,
-    testGetQuantify:testGetQuantify
+    testGetQuantify:testGetQuantify,
+    getGLJData:getGLJData,
+    addGLJ:addGLJ
 }
 function createRationGLJ() {
     let gls = mongoose.model('ration_glj');
@@ -28,6 +31,45 @@ async function testGetQuantify() {
     }catch (err){
         console.log(err);
     }
+}
 
-
+async function getGLJData(req, res) {
+    let result={
+        error:0
+    }
+    try {
+        let info = await ration_glj_facade.getLibInfo(req);
+        console.log(info);
+        ration_glj_facade.getGLJData(info,function (err,datas) {
+            if(err){
+                result.error=1;
+                result.message = err.message;
+            }else {
+                result.datas = datas;
+            }
+            res.json(result);
+        });
+    }catch (err){
+        console.log(err);
+        result.error=1;
+        result.message = err.message;
+        res.json(result);
+    }
 }
+
+async function addGLJ(req, res){
+    let result={
+        error:0
+    }
+    try {
+        let data = req.body.data;
+        data = JSON.parse(data);
+        let datas= await ration_glj_facade.addGLJ(data);
+        result.data=datas;
+    }catch (err){
+        console.log(err);
+        result.error=1;
+        result.message = err.message;
+    }
+    res.json(result);
+}

+ 113 - 21
modules/ration_glj/facade/ration_glj_facade.js

@@ -18,13 +18,19 @@ let std_ration_lib_ration_items = mongoose.model('std_ration_lib_ration_items');
 let glj_calculate_facade = require('./glj_calculate_facade');
 let quantity_detail_facade = require('./quantity_detail_facade');
 let logger = require("../../../logs/log_helper").logger;
+import stdgljutil  from "../../../public/cache/std_glj_type_util";
+import EngineeringLibModel from "../../users/models/engineering_lib_model";
+import GljDao from "../../complementary_glj_lib/models/gljModel";
 
 
 module.exports={
     save:save,
     getData:getData,
     deleteByRation:deleteByRation,
-    getQuantityByProjectGLJ:getQuantityByProjectGLJ
+    getQuantityByProjectGLJ:getQuantityByProjectGLJ,
+    getLibInfo:getLibInfo,
+    getGLJData:getGLJData,
+    addGLJ:addGLJ
 }
 
 let operationMap={
@@ -66,10 +72,6 @@ async function getQuantityByProjectGLJ(condition) {
         ]
     }
     let rations = await ration.find(rationQuery,['ID','quantity']);
-    //deleteInfo: null
-    console.log("rationList-----");
-    console.log(rationList);
-
     return combineQuantity(results,rations);
 }
 
@@ -118,7 +120,7 @@ function get_lib_glj_info(ration_glj) {
                 ration_glj.basePrice = glj.basePrice;
                 ration_glj.shortName = glj.shortName;
                 ration_glj.type = glj.gljType;
-                ration_glj.repositoryId = glj.ration_glj
+                ration_glj.repositoryId = glj.repositoryId;
                 getInfoFromProjectGLJ(ration_glj).then(function (info) {
                     if(info){
                         let tem={};
@@ -158,20 +160,7 @@ function createNewRecord(ration_glj) {
 }
 
 async function getInfoFromProjectGLJ(ration_glj) {
-     let data = {
-         glj_id: ration_glj.GLJID,
-         project_id: ration_glj.projectID,
-         code: ration_glj.code,
-         name: ration_glj.name,
-         specs: ration_glj.specs,
-         unit: ration_glj.unit,
-         type: ration_glj.type,
-         type_of_work: ration_glj.type,
-         base_price: ration_glj.basePrice,
-         market_price: ration_glj.basePrice,
-         repositoryId:ration_glj.repositoryId
-     };
-
+     let data = getGLJSearchInfo(ration_glj);
      try {
          let projectGljModel = new GLJListModel();
          let result = await projectGljModel.addList(data);
@@ -545,6 +534,108 @@ function save (user_id, datas, callback) {
     })
 }
 
+async function getLibInfo(req){
+    let gljLibId = null, engineeringId, sessionCompilation = req.session.sessionCompilation,
+        rationValuation = sessionCompilation.ration_valuation,
+        billValuation = sessionCompilation.bill_valuation,
+        engineeringLibModel = new EngineeringLibModel();
+    if(rationValuation[0]){
+        let engineeringList = rationValuation[0].engineering_list;
+        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
+        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    }
+    else if(billValuation[0]){
+        let engineeringList = billValuation[0].engineering_list;
+        engineeringId = engineeringList.length > 0 ? engineeringList[0].engineering_id : null;
+        let engineeringInfo = await engineeringLibModel.getEngineering(engineeringId);
+        gljLibId = engineeringInfo.glj_lib.length > 0 && typeof engineeringInfo.glj_lib !== 'undefined' ? engineeringInfo.glj_lib[0].id : null;
+    }
+    let  data = {
+        userID: req.session.sessionUser.ssoId,
+        gljLibId: gljLibId,
+        compilationId: sessionCompilation._id
+    };
+    return data;
+}
+
+function getGLJData(info,callback) {
+    let gljDao = new GljDao();
+    let datas={};
+    let gljDistTypeCache = stdgljutil.getStdGljTypeCacheObj().toArray();
+    datas.distTypeTree=gljDistTypeCache;
+    async_n.parallel([
+        function (cb) {
+            gljDao.getGljTypes(info.gljLibId,function (err,data) {
+                if(err){
+                    cb(err);
+                }else {
+                    datas.treeData=data;
+                    cb(null);
+                }
+            })
+        },
+        function (cb) {
+            gljDao.getGljItems(info.gljLibId,info.userID,info.compilationId, function (err,data) {
+                if(err){
+                    cb(err);
+                }else {
+                    datas.stdGLJ=data.stdGljs;
+                    datas.complementaryGLJs=data.complementaryGljs;
+                    cb(null);
+                }
+            });
+        }
+    ], function (err) {
+        if(err){
+            callback(true, null);
+        }
+        else{
+            callback(false, datas);
+        }
+    })
+
+}
+
+function getGLJSearchInfo(ration_glj) {
+    let data = {
+        glj_id: ration_glj.GLJID,
+        project_id: ration_glj.projectID,
+        code: ration_glj.code,
+        name: ration_glj.name,
+        specs: ration_glj.specs,
+        unit: ration_glj.unit,
+        type: ration_glj.type,
+        type_of_work: ration_glj.type,
+        base_price: ration_glj.basePrice,
+        market_price: ration_glj.basePrice,
+        repositoryId:ration_glj.repositoryId
+    };
+    return data;
+}
+
+
+async function addGLJ(rgList) {
+    let newRecodes = [];
+   for(let g of rgList){
+       let projectGljModel = new GLJListModel();
+       let result = await projectGljModel.addList(getGLJSearchInfo(g));
+       g.marketPrice=result.unit_price.market_price;
+       g.adjustPrice=result.unit_price.base_price;
+       g.basePrice=result.unit_price.base_price;
+       g.projectGLJID=result.id;
+       g.isEstimate=result.is_evaluate;
+       g.ID=uuidV1();
+       newRecodes.push(createNewRecord(g));
+   }
+    await ration_glj.insertMany(newRecodes);
+    let result={
+        newRecodes:newRecodes,
+        showData:rgList
+    }
+   return result;
+}
+
 function getData(projectID, callback) {
     ration_glj.find({'projectID':projectID},(err,datas)=>{
         if(err){
@@ -561,4 +652,5 @@ function commonCallback(callback,result,err) {
     }else {
         callback(null,result);
     }
-}
+}
+

+ 4 - 1
modules/ration_glj/models/ration_glj.js

@@ -13,6 +13,7 @@ var ration_glj = new Schema({
     projectGLJID:Number,
     name:String,
     code:String,
+    rcode:String,
     specs:String,
     unit:String,
     shortName:String,
@@ -20,7 +21,9 @@ var ration_glj = new Schema({
     quantity:Number,
     customQuantity:Number,
     rationItemQuantity:Number,
-    marketPriceAdjust:Number
+    marketPriceAdjust:Number,
+    createType: {type: String,default:'normal'},//normal、add、replace  正常、添加工料机、替换工料机
+    from:{type: String,default:'std'}//std, cpt  来自标准工料机库、补充工料机库
 },{versionKey:false});
 
 mongoose.model('ration_glj', ration_glj);

+ 18 - 0
modules/ration_glj/routes/ration_glj_route.js

@@ -0,0 +1,18 @@
+/**
+ * Created by CSL on 2017-03-22.
+ */
+
+let express = require('express');
+let rgController = require('../controllers/ration_glj_controller');
+
+module.exports = function (app) {
+
+    var rgRouter = express.Router();
+    rgRouter.get('/getGLJData', rgController.getGLJData);
+    rgRouter.post('/addGLJ',rgController.addGLJ);
+    app.use('/rationGlj',rgRouter);
+}
+
+
+
+

+ 3 - 0
public/web/common_ajax.js

@@ -3,6 +3,9 @@
  */
 
 var CommonAjax = {
+    get:function (url,data,cb,dataType) {
+        $.get(url,data,cb,dataType)
+    },
     post: function (url, data, successCallback, errorCallback) {
         $.ajax({
             type:"POST",

+ 11 - 1
public/web/sheet/sheet_common.js

@@ -90,7 +90,7 @@ var sheetCommonObj = {
             area.vAlign(GC.Spread.Sheets.VerticalAlign.center);
         }
     },
-    showData: function(sheet, setting, data) {
+    showData: function(sheet, setting, data,distTypeTree) {
         var me = this, ch = GC.Spread.Sheets.SheetArea.viewport;
         sheet.suspendPaint();
         sheet.suspendEvent();
@@ -132,6 +132,16 @@ var sheetCommonObj = {
                 if(val!=null&&setting.header[col].cellType === "checkBox"){
                     this.setCheckBoxCell(row,col,sheet,val)
                  }
+                 if(setting.owner==='gljTree'){
+                    if(setting.header[col].cellType === "checkBox"){
+                        val==1?val:0;
+                        this.setCheckBoxCell(row,col,sheet,val);
+                    }
+                    if(setting.header[col].dataCode === 'gljType' && data[row].gljType){
+                        let distTypeVal =  distTypeTree.distTypes[distTypeTree.prefix + data[row].gljType].data.fullName;
+                        val=distTypeVal;
+                    }
+                 }
                 sheet.setValue(row, col, val, ch);
             }
         }

+ 2 - 2
server.js

@@ -45,8 +45,8 @@ app.engine('.html', require('ejs').__express);
 app.set('view engine', 'html');
 
 let bodyParser = require('body-parser');
-app.use(bodyParser.urlencoded({extended: false}));
-app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({limit: '3mb', extended: false}));
+app.use(bodyParser.json({limit: '3mb'}));
 
 app.use(session({
     name: 'usersSession',

+ 4 - 0
web/building_saas/css/main.css

@@ -309,3 +309,7 @@ body {
   max-width: 200px;
   display: inline-block;
 }
+.gc-column-header-cell{
+    text-align: center!important;
+}
+.modal-lg{max-width: 1000px}

+ 44 - 1
web/building_saas/main/html/main.html

@@ -557,6 +557,50 @@
             </div>
         </div>
     </div>
+    <!--工料机选择窗口-->
+    <div class="modal fade" id="glj_tree_div" data-backdrop="static">
+        <div class="modal-dialog modal-lg" role="document" id="modalCon">
+            <div class="modal-content" >
+                <div class="modal-header">
+                    <h5 class="modal-title">内容</h5>
+                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
+                        <span aria-hidden="true">&times;</span>
+                    </button>
+                </div>
+                <div class="modal-body">
+                    <div class="row">
+                        <div class="col-4">
+                            <div  class="modal-auto-height" id="componentTreeDiv" style="overflow: hidden">
+                                <!--<div class="print-list">-->
+                                <div style="width: 100%; height: 100%; overflow: auto">
+                                    <ul id="gljTree" class="ztree"></ul>
+                                </div>
+                                <!--</div>-->
+                            </div>
+                        </div>
+                        <div class="col-8">
+                            <div class="row">
+                                <div class="col-12" id="gljRadios">
+                                    <input type="radio" class="glj-radio" name="glj" value="allGljs" checked>所有工料机&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="stdGLJ">标准工料机&nbsp;&nbsp;
+                                    <input type="radio" class="glj-radio" name="glj" value="complementaryGLJs">补充工料机&nbsp;&nbsp;
+                                    <!-- <div class="form-group"><input id="searchGlj" type="text" class="form-control-sm" placeholder="查询工料机"></div>-->
+                                </div>
+                                <div class="modal-auto-height col-12" style="overflow: hidden" id="gljLibSheet">
+
+                                </div>
+                            </div>
+                        </div>
+                    </div>
+                </div>
+                <div class="modal-footer">
+                    <button type="button" id="componentsCacnel" class="btn btn-secondary" data-dismiss="modal">取消</button>
+                    <a href="javascript:void(0);" id="glj_selected_conf" class="btn btn-primary">确定</a>
+                </div>
+            </div>
+        </div>
+    </div>
+
     <!-- JS. -->
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.core.js"></script>
     <script type="text/javascript" src="/lib/ztree/jquery.ztree.excheck.js"></script>
@@ -587,7 +631,6 @@
     <script type="text/javascript" src="/web/building_saas/main/js/views/calc_program_manage.js"></script>
 
     <!-- JS. -->
-    <script src="/lib/jquery/jquery.min.js"></script>
     <script src="/lib/tether/tether.min.js"></script>
     <script src="/lib/bootstrap/bootstrap.min.js"></script>
     <script src="/web/building_saas/js/global.js"></script>

+ 36 - 5
web/building_saas/main/js/models/ration_glj.js

@@ -11,7 +11,6 @@ var ration_glj = {
             this.gljTree = cacheTree.createNew(this);
            // this.project = proj;
             this.datas = [];
-
             var sourceType = ModuleNames.ration_glj;
             this.getSourceType = function () {
                 return sourceType;
@@ -139,6 +138,7 @@ var ration_glj = {
             _.remove(glj_list,data.query);
             _.remove(gljOprObj.sheetData,data.query);
             gljOprObj.showRationGLJSheetData();
+            projectObj.project.projectGLJ.loadData();
         };
         // CSL,2017.05.09
         ration_glj.prototype.modifyQuantity = function (data, newQuantity) {
@@ -315,13 +315,44 @@ var ration_glj = {
                 project_id:recode.projectID,
                 repositoryId:recode.repositoryId
             };
-         /*   code: '01010101',
-                market_price: '40',
-                name: '水泥',
-                project_id: projectId*/
             var updateData = this.getUpdateData('ut_update',query,doc,'marketPriceAdjustUpdate');
             project.pushNow('updateRationGLJ',[this.getSourceType()],updateData);
         };
+        ration_glj.prototype.getGLJData = function(cb){
+            CommonAjax.get('/rationGlj/getGLJData', function (data) {
+                cb(data);
+            })
+        };
+        ration_glj.prototype.addGLJByLib=function (GLJSelection,ration,callback) {
+          var gljList=[];
+          var allGLJ=gljOprObj.stdGLJ.concat(gljOprObj.complementaryGLJs);
+            GLJSelection.sort();
+          _.forEach(GLJSelection,function (g) {
+              var glj=_.find(allGLJ,{'code':g});
+              var ration_glj ={
+                  projectID:ration.projectID,
+                  GLJID:glj.ID,
+                  rationID:ration.ID,
+                  rationItemQuantity:0,
+                  quantity:0,
+                  name:glj.name,
+                  code:glj.code,
+                  unit:glj.unit,
+                  specs:glj.specs,
+                  basePrice:glj.basePrice,
+                  shortName:glj.shortName,
+                  type:glj.gljType,
+                  createType:'add',
+                  repositoryId:glj.repositoryId
+              }
+              if(glj.hasOwnProperty("compilationId")){
+                  ration_glj.from="cpt";
+              }
+              gljList.push(ration_glj);
+          });
+            CommonAjax.post("/rationGlj/addGLJ",gljList,callback);
+        };
+
 
         return new ration_glj(project);
     }

+ 184 - 1
web/building_saas/main/js/views/glj_view.js

@@ -14,6 +14,8 @@ var gljOprObj = {
     assSheetData:[],
     detailSheet:null,
     detailData:[],
+    GLJSelection:[],
+    parentNodeIds:{},
     setting: {
         header: [
             {headerName: "编码", headerWidth: 100, dataCode: "code", dataType: "String", formatter: "@"},
@@ -68,6 +70,64 @@ var gljOprObj = {
             lockColumns:[2,3]
         }
     },
+    gljTreeSetting:{
+        view: {
+            //addHoverDom: gljTypeTreeOprObj.addHoverDom,
+            //removeHoverDom: gljTypeTreeOprObj.removeHoverDom,
+            expandSpeed: "",
+            selectedMulti: false
+        },
+        edit: {
+            enable: false,
+            editNameSelectAll: true,
+            showRemoveBtn: true,
+            showRenameBtn: true,
+            removeTitle: "删除节点",
+            renameTitle: "更改名称"
+        },
+        data: {
+            keep: {
+                parent:true,
+                leaf:true
+            },
+            key: {
+                children: "items",
+                name: "Name"
+            },
+            simpleData: {
+                enable: false,
+                idKey: "ID",
+                pIdKey: "ParentID",
+                rootPId: -1
+            }
+        },
+        callback:{
+            onClick: function(event,treeId,treeNode) {
+                let me = gljOprObj, gljTypeId = treeNode.ID;
+                if(me.gljCurTypeId !== treeNode.ID){
+                    me.gljCurTypeId = treeNode.ID;
+                    me.filterLibGLJSheetData();
+                    me.showLibGLJSheetData();
+                }
+            }
+        }
+    },
+    gljLibSheetSetting:{
+        owner:'gljTree',
+        header: [
+            {headerName:"选择", headerWidth: 40, dataCode: "select", hAlign: "center", vAlign: "center",cellType:"checkBox"},
+            {headerName:"编码",headerWidth:80,dataCode:"code", dataType: "String", formatter: "@", hAlign: "left", vAlign: "center"},
+            {headerName:"名称",headerWidth:120,dataCode:"name", dataType: "String", hAlign: "left", vAlign: "center"},
+            {headerName:"规格型号",headerWidth:80,dataCode:"specs", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"计量单位",headerWidth:80,dataCode:"unit", dataType: "String", hAlign: "center", vAlign: "center"},
+            {headerName:"单价",headerWidth:80,dataCode:"basePrice", dataType: "Number", formatter: "0.00", hAlign: "right", vAlign: "center"},
+            {headerName:"类型",headerWidth:80,dataCode:"gljType", dataType: "String",  hAlign: "center", vAlign: "center"}
+        ],
+        view:{
+            lockColumns:[0,1,2,3,4,5,6]
+        }
+    },
+    gljLibSheet:null,
     initSheet: function(sheet) {
         var me = this;
         me.sheet = sheet;
@@ -215,8 +275,10 @@ var gljOprObj = {
         }
         if(args.sheetName=='ration_coe'){
             gljOprObj.updateRationCoe(args,newval)
-        }else {
+        }else if(args.sheetName=='quantity_detail'){
             projectObj.project.quantity_detail.isSummationUpdate(args,gljOprObj.detailData,newval);
+        }else if(args.sheetName=='glj_lib'){
+            gljOprObj.setGLJSelection(args,newval);
         }
     },
     onCusButtonClick:function (sender,args){
@@ -628,8 +690,129 @@ var gljOprObj = {
         }
         return true;
     },
+    showLibGLJSheetData:function () {
+        this.gljLibSheetData=_.sortBy(this.gljLibSheetData, 'code');
+        this.gljLibSheet.setRowCount(this.gljLibSheetData.length);
+        sheetCommonObj.showData(this.gljLibSheet,this.gljLibSheetSetting,this.gljLibSheetData,gljOprObj.distTypeTree);
+    },
+    filterLibGLJSheetData:function () {
+        let me=this;
+        let val = $("input[name='glj']:checked").val();
+        if(val=='allGljs'){
+            me.gljLibSheetData =me.stdGLJ.concat(me.complementaryGLJs);
+        }else {
+            me.gljLibSheetData=me[val];
+        }
+        if(me.gljCurTypeId==undefined){
+            return;
+        }
+        if (me.parentNodeIds["_pNodeId_" + me.gljCurTypeId]) {
+            me.gljLibSheetData= _.filter(me.gljLibSheetData, function(n) {
+                return _.includes(me.parentNodeIds["_pNodeId_" + me.gljCurTypeId],n.gljClass);
+            });
+        } else {
+            me.gljLibSheetData = _.filter(me.gljLibSheetData,{'gljClass':me.gljCurTypeId});
+        }
+
+    },
+    setGLJSelection:function (args,newVal) {
+        if(newVal==1){
+            this.GLJSelection.push(this.gljLibSheetData[args.row].code);
+            this.gljLibSheetData[args.row].select=1;
+        }else if(newVal==0){
+            _.pull(this.GLJSelection,this.gljLibSheetData[args.row].code);
+            this.gljLibSheetData[args.row].select=0;
+        }
+    },
+    getComboData: function (gljDistType) {
+        let me = this;
+        let distType;
+        let distTypeTree = {
+            prefix : 'gljType',
+            distTypes: {},
+            comboDatas: [],
+            distTypesArr: []
+        };
+        gljDistType.forEach(function (typeData) {
+            let typeObj = {
+                data: typeData,
+                children: [],
+                parent: null
+            }
+            distTypeTree.distTypes[distTypeTree.prefix + typeData.ID] = typeObj;
+            distTypeTree.distTypesArr.push(typeObj);
+        });
+        gljDistType.forEach(function (typeData) {
+            distType = distTypeTree.distTypes[distTypeTree.prefix + typeData.ID];
+            let parent = distTypeTree.distTypes[distTypeTree.prefix + typeData.ParentID];
+            if(parent){
+                distType.parent = parent;
+                parent.children.push(distType);
+            }
+        });
+        distTypeTree.distTypesArr.forEach(function (distTypeObj) {
+            if(distTypeObj.data.fullName !== '材料' && distTypeObj.data.fullName !== '机械'){
+                distTypeTree.comboDatas.push({text: distTypeObj.data.fullName, value: distTypeObj.data.ID});
+            }
+        });
+        return distTypeTree;
+    },
     refreshView:function () {
         this.showRationGLJData();
     }
 }
 
+$(function(){
+    $('#glj_tree_div').on('shown.bs.modal', function (e) {
+        if(gljOprObj.gljLibSpresd==undefined){
+            gljOprObj.gljLibSpresd=sheetCommonObj.buildSheet($('#gljLibSheet')[0], gljOprObj.gljLibSheetSetting, gljOprObj.stdGLJ.length+gljOprObj.complementaryGLJs.length);
+            gljOprObj.gljLibSpresd.bind(GC.Spread.Sheets.Events.ButtonClicked,gljOprObj.onButtonClick);
+            gljOprObj.gljLibSheet = gljOprObj.gljLibSpresd.getSheet(0);
+            gljOprObj.gljLibSheet.options.isProtected = true;
+            gljOprObj.gljLibSheet.name('glj_lib');
+        }
+        gljOprObj.GLJSelection=[];
+        gljOprObj.gljLibSheetData =gljOprObj.stdGLJ.concat(gljOprObj.complementaryGLJs);
+        gljOprObj.showLibGLJSheetData();
+    });
+
+    $('.glj-radio').change(function () {
+        let val = $("input[name='glj']:checked").val();
+        if(val=='allGljs'){
+            gljOprObj.gljLibSheetData =gljOprObj.stdGLJ.concat(gljOprObj.complementaryGLJs);
+            gljOprObj.filterLibGLJSheetData();
+            gljOprObj.showLibGLJSheetData();
+        }else {
+            gljOprObj.gljLibSheetData=gljOprObj[val];
+            gljOprObj.filterLibGLJSheetData();
+            gljOprObj.showLibGLJSheetData();
+        }
+     })
+    $('#glj_selected_conf').click(function () {
+        gljOprObj.GLJSelection= _.filter(gljOprObj.GLJSelection,function (n) {
+            return _.find(gljOprObj.sheetData,{'code':n})?false:true;
+        })
+        if(gljOprObj.GLJSelection.length<1){
+            return;
+        }
+        var selected = projectObj.project.mainTree.selected;
+        if(selected&&selected.sourceType==ModuleNames.ration){
+            projectObj.project.ration_glj.addGLJByLib(gljOprObj.GLJSelection,selected.data,function (result) {
+                if(result){
+                    projectObj.project.ration_glj.datas = projectObj.project.ration_glj.datas.concat(result.newRecodes);
+                    gljOprObj.sheetData = gljOprObj.sheetData.concat(result.showData)
+                    gljOprObj.showRationGLJSheetData();
+                    projectObj.project.projectGLJ.loadData();
+                }
+                console.log("return---------------");
+                console.log(result);
+                $("#glj_tree_div").modal('hide');
+            });//doc.rationID=selected.data.ID;
+        }
+
+
+    })
+})
+
+
+

+ 25 - 0
web/building_saas/main/js/views/glj_view_contextMenu.js

@@ -27,6 +27,31 @@ var gljContextMenu = {
                         var deleteRow = sheetData[gljContextMenu.selectedRow];
                         projectObj.project.ration_glj.updataOrdelete(deleteRow);
                     }
+                },
+                "add_glj": {
+                    name: '添加工料机',
+                    icon: 'fa-remove',
+                    disabled: function () {
+                        var selected = projectObj.project.mainTree.selected;
+                        if(selected&&selected.sourceType==ModuleNames.ration){
+                            return false;
+                        }
+                        return true;
+                    },
+                    callback: function () {
+
+                        projectObj.project.ration_glj.getGLJData(function (result) {
+                            zTreeHelper.createTree(result.datas.treeData, gljOprObj.gljTreeSetting, "gljTree", gljOprObj);
+                            gljOprObj.stdGLJ=result.datas.stdGLJ;
+                            gljOprObj.complementaryGLJs=result.datas.complementaryGLJs;
+                            gljOprObj.distTypeTree=gljOprObj.getComboData(result.datas.distTypeTree);
+                            $('#modalCon').width($(window).width()*0.5);
+                            $("input[name='glj']").get(0).checked=true;
+                            $("#glj_tree_div").modal({show:true});
+                            console.log(result)
+                        })
+
+                    }
                 }
             }
         });