zhangweicheng 7 years atrás
parent
commit
7bb026377a

+ 1 - 0
config/gulpConfig.js

@@ -114,6 +114,7 @@ module.exports = {
         'web/building_saas/main/js/views/confirm_modal.js',
         'web/building_saas/main/js/views/zlfb_view.js',
         'web/building_saas/main/js/views/installation_fee_view.js',
+        'web/building_saas/main/js/views/project_glj_view.js',
         'public/web/rpt_tpl_def.js',
         'public/web/treeDataHelper.js',
         'public/web/ztree_common.js',

+ 2 - 0
modules/complementary_glj_lib/models/gljModel.js

@@ -372,6 +372,7 @@ class GljDao {
             for(let gljData of componentStdGljData) {
                 gljData.connectCode = libGljData.code;
                 gljData.consumption = componentConsume[gljData.ID + '_std'];
+                gljData.from='std';
                 result.push(gljData);
             }
         }
@@ -382,6 +383,7 @@ class GljDao {
             for(let gljData of componentCptGljData) {
                 gljData.connectCode = libGljData.code;
                 gljData.consumption = componentConsume[gljData.ID + '_cpt'];
+                gljData.from='cpt';
                 result.push(gljData);
             }
         }

+ 4 - 1
modules/glj/models/glj_list_model.js

@@ -654,8 +654,11 @@ class GLJListModel extends BaseModel {
                 glj_id: tmp.ID,
                 specs: tmp.specs,
                 unit: tmp.unit === undefined ? '' : tmp.unit,
-                original_code:tmp.code
+                original_code:tmp.code,
             };
+            if(tmp.from=='cpt'){
+                unitPriceData.is_add = 1;
+            }
             unitPriceInsertData.push(unitPriceData);
         }
         // 整理完后开始插入数据

+ 27 - 0
public/web/common_ajax.js

@@ -90,5 +90,32 @@ var CommonAjax = {
                 }
             }
         });
+    },
+    specialPost:function (url, data,successCallback, errorCallback) {
+        $.ajax({
+            url: url,
+            type: 'post',
+            data: data,
+            dataType: 'json',
+            error: function() {
+                alert('数据传输有误!');
+                if (errorCallback) {
+                    errorCallback();
+                }
+            },
+            success: function(response) {
+                // 修改失败则恢复原值
+                if (response.err !== 0) {
+                    alert('更改数据失败!');
+                    if (errorCallback) {
+                        errorCallback();
+                    }
+                } else {
+                    if (successCallback) {
+                        successCallback(response);
+                    }
+                }
+            }
+        });
     }
 };

+ 21 - 3
public/web/sheet/sheet_common.js

@@ -166,7 +166,7 @@ var sheetCommonObj = {
                 this.setCheckBoxCell(row,col,sheet,val)
             }
             if(setting.header[col].cellType === "comboBox"){
-                this.setComboBox(row,col,sheet,setting.header[col].options);
+                this.setComboBox(row,col,sheet,setting.header[col].options,setting.header[col].editorValueType);
             }
             if(setting.header[col].cellType === "selectButton"){
                 this.setSelectButton(row,col,sheet,setting.header[col]);
@@ -186,6 +186,7 @@ var sheetCommonObj = {
             }
             sheet.setValue(row, col, val, ch);
         }
+        this.setRowStyle(row,sheet,data[row].bgColour);
         if(setting.autoFit==true){
             sheet.getRange(row, -1, 1, -1, GC.Spread.Sheets.SheetArea.viewport).wordWrap(true);
             sheet.autoFitRow(row);
@@ -247,12 +248,29 @@ var sheetCommonObj = {
         sheet.getCell(row, col).hAlign(GC.Spread.Sheets.HorizontalAlign.center);
 
     },
-    setComboBox(row,col,sheet,options){
+    setComboBox(row,col,sheet,options,editorValueType){
         //let combo = new GC.Spread.Sheets.CellTypes.ComboBox();
         let dynamicCombo = sheetCommonObj.getDynamicCombo(true);
-        dynamicCombo.itemHeight(options.length).items(options);
+        if(options){
+            dynamicCombo.itemHeight(options.length).items(options);
+            if(editorValueType==true){
+                dynamicCombo.editorValueType(GC.Spread.Sheets.CellTypes.EditorValueType.value);
+            }
+        }
         sheet.setCellType(row, col,dynamicCombo,GC.Spread.Sheets.SheetArea.viewport);
     },
+    setRowStyle(row,sheet,bgColour) {
+        if(bgColour){
+            let style = new GC.Spread.Sheets.Style();
+            style.backColor = bgColour;
+            style.borderLeft = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+            style.borderTop = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+            style.borderRight = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+            style.borderBottom = new GC.Spread.Sheets.LineBorder("#D4D4D4", GC.Spread.Sheets.LineStyle.thin);
+            sheet.setStyle(row, -1, style);
+        }
+    },
+
     setSelectButton(row,col,sheet,header){
         let getSelectButton = function (cellWidth=100) {
             function moreButton() {

+ 6 - 6
web/building_saas/glj/html/project_glj.html

@@ -12,10 +12,9 @@
 </div>
 <div class="container-fluid">
     <div class="row">
-        <div class="col-lg-12 p-0" id="glj-main">
+        <div class="col-lg-12 p-0" id="project-glj-main">
             <div class="top-content">
-                <div class="main-data-top" id="project_glj_sheet">
-                    <p style="text-align: center; margin-top: 30px;">正在加载数据</p>
+                <div class="main-data-top" style="width: 100%" id="project_glj_sheet">
                 </div>
             </div>
             <div class="resize"></div>
@@ -28,7 +27,7 @@
                         <a class="nav-link" data-toggle="tab" data-name="mix_ratio_sheet" id="mix_ratio_link" href="#ph_div" role="tab">配合比表</a>
                     </li>
                     <li class="nav-item">
-                        <a class="nav-link" data-toggle="tab" data-name="machine_sheet" id="machine_ratio_link" href="#jx_div" role="tab">机械单价</a>
+                        <a class="nav-link" data-toggle="tab" data-name="machine_sheet" id="machine_ratio_link" href="#ph_div" role="tab">机械单价</a>
                     </li>
                 </ul>
                 <!-- Tab panes -->
@@ -40,12 +39,13 @@
                     </div>
                     <div class="tab-pane" id="ph_div" role="tabpanel">
                         <div class="main-data-bottom" id="mix_ratio_sheet">
+                            test
                         </div>
                     </div>
-                    <div class="tab-pane" id="jx_div" role="tabpanel">
+             <!--       <div class="tab-pane" id="jx_div" role="tabpanel">
                         <div class="main-data-bottom" id="machine_sheet">
                         </div>
-                    </div>
+                    </div>-->
                 </div>
             </div>
         </div>

+ 3 - 57
web/building_saas/glj/js/project_glj.js

@@ -264,9 +264,9 @@ function init() {
             jsonData = sortProjectGLJ(jsonData);
             mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
             mixRatioMap = data.mixRatioMap !== undefined ? data.mixRatioMap : mixRatioMap;
-            host = data.constData.hostname !== undefined ? data.constData.hostname : '';
+           // host = data.constData.hostname !== undefined ? data.constData.hostname : '';
             materialIdList = data.constData.materialIdList !== undefined ? data.constData.materialIdList : materialIdList;
-            roomId = data.constData.roomId !== undefined ? data.constData.roomId : roomId;
+            //roomId = data.constData.roomId !== undefined ? data.constData.roomId : roomId;
             canNotChangeTypeId = data.constData.ownCompositionTypes !== undefined ?
                 data.constData.ownCompositionTypes : canNotChangeTypeId;
             GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
@@ -391,7 +391,7 @@ function successTrigger(field, info,id) {
             projectGLJSpread.changeSupplyType(info);
             break;
         case 'is_evaluate':
-            changeIsEvaluate(id);
+            projectObj.project.projectGLJ.changeIsEvaluate(id);
             break;
     }
     // 重新加载数据到缓存
@@ -404,60 +404,6 @@ function successTrigger(field, info,id) {
     gljOprObj.refreshView();
 }
 
-//更新是否暂估
-function changeIsEvaluate (id){
-    let projectGLJ = projectObj.project.projectGLJ;
-    let datas = projectGLJ.datas;
-    let gljList = datas.gljList;
-    let glj = _.find(gljList, {'id': id});
-    if(glj){
-        let con_key = gljOprObj.getIndex(glj,gljKeyArray);
-        let pratioM =datas.mixRatioConnectData[con_key];//找到父key
-        let conditions = [];
-        if(pratioM&&pratioM.length>0){
-            for(let p_key of pratioM ){
-                conditions.push(gljOprObj.getConditionByKey(p_key));
-            }
-        }
-        let gljs = projectGLJ.getProjectGLJs(conditions,false);
-        gljs.push(glj);
-        let nodes = projectGLJ.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
-        //更新对应的工料机类型的定额
-        let ration =_.find(projectObj.project.Ration.datas,{'type':rationType.gljRation,'projectGLJID':glj.id});
-        if(ration){
-            ration.isEstimate =glj.is_evaluate?1:0;
-            let ration_node = projectObj.project.mainTree.getNodeByID(ration.ID);
-            ration_node?projectObj.mainController.refreshTreeNode([ration_node]):"";
-        }
-        projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
-    }
-}
-
-/**
- * socket.io相关初始化
- *
- * @return {void}
- */
-function socketInit() {
-    if (socket === null) {
-        socket = io('http://' + host + ':3300');
-        socket.on('connect', function () {
-            socket.emit('join', roomId);
-            console.log('单价文件同步连接成功');
-        });
-    }
-
-    // 接收到改变
-    socket.on('dataChange', function (data) {
-        data = JSON.parse(data);
-        if (data.newValue === undefined) {
-            return false;
-        }
-        $("#message").html('市场单位已被修改,<a href="javascript:void(0);" id="load-data">点击加载</a>');
-        $("#notify").slideDown('fast');
-    });
-}
-
 //过滤消耗量为0的项目工料机
 function filterProjectGLJ(jsonData) {
     if (jsonData.length > 0) {

+ 1 - 1
web/building_saas/glj/js/project_glj_spread.js

@@ -18,7 +18,7 @@ function ProjectGLJSpread() {
     this.firstMixRatioRow = -1;
     this.successCallback = null;
     this.supplyType = ['自行采购', '部分甲供', '完全甲供', '甲定乙供'];
-    this.supplyComboMap = [{text:"自行采购",value:0},{text:"完全甲供",value:2},{text:"部分甲供",value:1},{text:"甲定乙供",value:3}];//后来调整了下拉选项的顺序,为了不改之前的业务逻辑,这里的值对换了一下
+    this.supplyComboMap = supplyComboMap
     // 工料机类型是混凝土、砂浆、配合比、机械(不包括机械组成物)时,供货方式列只读。
     this.supplyReadonlyType = notEditType;
 }

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

@@ -43,7 +43,7 @@
             <ul class="nav nav-tabs flex-column" role="tablist">
                 <li class="nav-item"><a class="active" data-toggle="tab" href="#zaojiashu" id="tab_zaojiashu" role="tab">造价书</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#gongliaoji" id="tab_gongliaoji" data-name="tab_gongliaoji" role="tab">工料机</a></li>
-               <!-- <li class="nav-item"><a data-toggle="tab" href="#project_glj" id="tab_project_glj" data-name="tab_project_glj" role="tab">工料机2</a></li>-->
+                <li class="nav-item"><a data-toggle="tab" href="#project_glj" id="tab_project_glj" data-name="tab_project_glj" role="tab">工料机新</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#fee_rates" id="tab_fee_rate" role="tab" >费率</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#calc_program_manage" id="tab_calc_program_manage" role="tab">计算程序</a></li>
                 <li class="nav-item"><a data-toggle="tab" href="#reports" role="tab" id="tab_report" onclick="rptTplObj.iniPage();">报表</a></li>
@@ -1157,6 +1157,7 @@
         <script type="text/javascript" src='/web/building_saas/main/js/views/confirm_modal.js'></script>
         <script type="text/javascript" src='/web/building_saas/main/js/views/zlfb_view.js'></script>
         <script type="text/javascript" src='/web/building_saas/main/js/views/installation_fee_view.js'></script>
+        <script type="text/javascript" src='/web/building_saas/main/js/views/project_glj_view.js'></script>
         <!--报表-->
         <script type="text/javascript" src="/public/web/rpt_tpl_def.js"></script>
         <script type="text/javascript" src="/public/web/treeDataHelper.js"></script>

+ 1 - 0
web/building_saas/main/js/models/main_consts.js

@@ -304,4 +304,5 @@ const engineeringType = {
 
 const installFeeType = ['子目费用','分项费用','措施费用'];
 const installSectionBase = ['分别按人材机乘系数','人工','材料','机械'];
+const supplyComboMap = [{text:"自行采购",value:0},{text:"完全甲供",value:2},{text:"部分甲供",value:1},{text:"甲定乙供",value:3}];//后来调整了下拉选项的顺序,为了不改之前的业务逻辑,这里的值对换了一下
 

+ 61 - 2
web/building_saas/main/js/models/project_glj.js

@@ -252,7 +252,7 @@ ProjectGLJ.prototype.updateGLJProperty = function (node, updateField, newval) {
 
 }
 
-ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from) {
+ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from,cb) {
     let me = this;
     let projectGljs = this.datas.gljList;
     let pgljID = from=="rg"?recode.projectGLJID:recode.id;//和定额工料机统一接口,项目工料机ID取值不一样
@@ -277,6 +277,9 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from) {
             projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
             socket.emit('unitFileChangeNotify', JSON.stringify(data));
             projectObj.project.markUpdateProject({projectID:projectObj.project.ID(),'unitFileID':socketObject.getUnitFileRoomID()},"unitFile");
+            if(cb){
+                cb(gljs);
+            }
             $.bootstrapLoading.end();
         }
         $.bootstrapLoading.start();
@@ -286,8 +289,64 @@ ProjectGLJ.prototype.updatePrice = function (recode, updateField, newval,from) {
     } else {
         gljOprObj.showRationGLJSheetData();
     }
+};
+
+ProjectGLJ.prototype.pGljUpdate= function (data,callback) {
+    let me = this;
+    $.bootstrapLoading.start();
+    CommonAjax.specialPost( '/glj/update',data,function (result) {
+        let glj = me.getByID(data.id);//更新缓存
+        let impactList = [];
+        glj[data.field] = data.value;
+        if(data.extend&&data.extend!=""){
+            let extend = JSON.parse(data.extend);
+            for (let key in extend) {
+                glj[key] = extend[key];
+            }
+        }
+        if(data.field == 'is_evaluate'){
+            impactList =  me.changeIsEvaluate(data.id);
+        }
+        if(callback){
+            callback(impactList);
+        }
+        $.bootstrapLoading.end();
+    });
+};
+
+//更新是否暂估
+ProjectGLJ.prototype.changeIsEvaluate=function (id){
+    let projectGLJ = projectObj.project.projectGLJ;
+    let datas = projectGLJ.datas;
+    let gljList = datas.gljList;
+    let glj = _.find(gljList, {'id': id});
+    if(glj){
+        let con_key = gljOprObj.getIndex(glj,gljKeyArray);
+        let pratioM =datas.mixRatioConnectData[con_key];//找到父key
+        let conditions = [];
+        if(pratioM&&pratioM.length>0){
+            for(let p_key of pratioM ){
+                conditions.push(gljOprObj.getConditionByKey(p_key));
+            }
+        }
+        let gljs = projectGLJ.getProjectGLJs(conditions,false);
+        gljs.push(glj);
+        let nodes = projectGLJ.getImpactRationNodes(gljs);//取到因为改变工料机价格而受影响的定额
+        //更新对应的工料机类型的定额
+        let ration =_.find(projectObj.project.Ration.datas,{'type':rationType.gljRation,'projectGLJID':glj.id});
+        if(ration){
+            ration.isEstimate =glj.is_evaluate?1:0;
+            let ration_node = projectObj.project.mainTree.getNodeByID(ration.ID);
+            ration_node?projectObj.mainController.refreshTreeNode([ration_node]):"";
+        }
+        projectObj.project.calcProgram.calcRationsAndSave(nodes);//触发计算程序
+        return gljs;
+    }
 }
 
+ProjectGLJ.prototype.getByID = function (ID) {
+    return _.find(this.datas.gljList,{'id':ID});
+};
 
 ProjectGLJ.prototype.refreshTreeNodePriceIfNeed = function (data) {
     if ((data.unit_price.type == gljType.MAIN_MATERIAL || data.unit_price.type == gljType.EQUIPMENT) && projectInfoObj.projectInfo.property.displaySetting.disPlayMainMaterial == true) {
@@ -399,7 +458,7 @@ ProjectGLJ.prototype.getAdjustPrice = function (glj) {
         //let labour=1;
         let coe = labour && labour.coe ? labour.coe : 1;
         return scMathUtil.roundTo(parseFloat(coe * scMathUtil.roundForObj(glj.unit_price.base_price,decimal)), -decimal);
-    } else if (notEditType.indexOf(glj.unit_price.type)>0&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
+    } else if (notEditType.indexOf(glj.unit_price.type)!=-1&&glj.ratio_data.length>0) {//对于混凝土、配合比、砂浆、机械台班,调整价根据组成物计算得出。
         let p =0;
         for(let ratio of glj.ratio_data){
            let tem =  _.find( projectObj.project.projectGLJ.datas.gljList,{

+ 1 - 1
web/building_saas/main/js/models/ration.js

@@ -414,7 +414,7 @@ var Ration = {
                 });
 
                 if(data.length<recodes.length){//说明有部分定额编号没找到记录
-                    alert('当前库中找不到定额"' + recodes[data.length-1].value + '"');
+                    alert('当前库中找不到定额"' + recodes[data.length].value + '"');
                 }
             })
         };

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

@@ -952,13 +952,12 @@ var gljOprObj = {
     setGLJPrice:function (data,glj) {
         let proGLJ =  projectObj.project.projectGLJ;
         glj = glj?glj:_.find(proGLJ.datas.gljList, {'id': data.projectGLJID});
+        data.marketPrice = proGLJ.getMarketPrice(glj);
         if(this.calcPriceDiff(glj)==true) {//计取价差
             data.basePrice = proGLJ.getBasePrice(glj);
-            data.marketPrice = proGLJ.getMarketPrice(glj);
             data.adjustPrice = proGLJ.getAdjustPrice(glj);
         }else {//不计价差
             data.basePrice = proGLJ.getMarketPrice(glj);
-            data.marketPrice = proGLJ.getMarketPrice(glj);
             data.adjustPrice = proGLJ.getMarketPrice(glj);
         }
         return data;

+ 245 - 12
web/building_saas/main/js/views/project_glj_view.js

@@ -2,28 +2,261 @@
  * Created by zhang on 2018/3/13.
  */
 projectGljObject={
-    projectGljSetting:{},
-    projectGljSpread:{},
-    projectGljSheet:{},
-    projectGljSheetData:{}
+    projectGljSetting:{
+        header: [
+            {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
+            {headerName: "规格型号", headerWidth: 120, dataCode: "specs", hAlign: "left", dataType: "String"},
+            {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
+            {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
+            {headerName: "总消耗量", headerWidth: 100, dataCode: "quantity", hAlign: "right", dataType: "Number",decimalField:'glj.quantity'},
+            {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.quantity',validator:"number"},
+            {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
+            {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"},
+            {headerName: "是否暂估", headerWidth: 60, dataCode: "is_evaluate", hAlign: "center", dataType: "String",cellType:'checkBox'},
+            {headerName: "供货方式", headerWidth: 80, dataCode: "supply", hAlign: "center", dataType: "String",cellType:'comboBox',editorValueType:true,options:supplyComboMap},
+            {headerName: "甲供数量", headerWidth: 100, dataCode: "supply_quantity", hAlign: "right", dataType: "String",validator:"number"},
+            {headerName: "交货方式", headerWidth: 90, dataCode: "delivery", hAlign: "left", dataType: "String"},
+            {headerName: "送达地点", headerWidth: 100, dataCode: "delivery_address", hAlign: "left", dataType: "String"},
+            {headerName: "不调价", headerWidth: 55, dataCode: "is_adjust_price", dataType: "String",cellType: "checkBox"}
+        ],
+        view: {
+            lockColumns: [0,1,2,3,4,5,7,12,13]
+        }
+    },
+    projectGljSpread:null,
+    projectGljSheet:null,
+    projectGljSheetData:[],
+    mixRatioSetting:{
+        header:[
+            {headerName: "编码", headerWidth: 80, dataCode: "code", dataType: "String"},
+            {headerName: "名称", headerWidth: 160, dataCode: "name", dataType: "String"},
+            {headerName: "单位", headerWidth: 45, dataCode: "unit", hAlign: "center", dataType: "String"},
+            {headerName: "类型", headerWidth: 45, dataCode: "short_name", hAlign: "center", dataType: "String"},
+            {headerName: "定额价", headerWidth: 70, dataCode: "basePrice", hAlign: "right", dataType: "Number",decimalField:'glj.quantity',validator:"number"},
+            {headerName: "调整价", headerWidth: 70, dataCode: "adjustPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice"},
+            {headerName: "市场价", headerWidth: 70, dataCode: "marketPrice", hAlign: "right", dataType: "Number",decimalField:"glj.unitPrice",validator:"number"}
+        ],
+        view: {
+            lockColumns: [0,1]
+        }
+    },
+    mixRatioSpread:null,
+    mixRatioSheet:null,
+    mixRatioData:[],
+    initProjectGljSpread:function () {
+        this.projectGljSpread = SheetDataHelper.createNewSpread($("#project_glj_sheet")[0]);
+        this.projectGljSheet = this.projectGljSpread .getSheet(0);
+        this.initSheet(this.projectGljSheet,this.projectGljSetting);
+        this.projectGljSheet.bind(GC.Spread.Sheets.Events.SelectionChanged,this.onProjectGljSelectionChange);
+        this.projectGljSheet.bind(GC.Spread.Sheets.Events.EditStarting,this.onProjectGljEditStarting);
+        this.projectGljSheet.name('projectGljSheet');
+    },
+    onProjectGljEditStarting:function (sender, args) {
+        let me = projectGljObject;
+        let row = args.row;
+        let col = args.col;
+        let dataCode = me.projectGljSetting.header[col].dataCode;
+        if(dataCode=='is_adjust_price'||dataCode=='is_evaluate'){
+            args.cancel = true;
+        }
+    },
+    onProjectGljSelectionChange:function (sender, args) {
+        let me = projectGljObject;
+        let row = args.newSelections[0].row;
+        let col = args.newSelections[0].col;
+        let data = me.projectGljSheetData[row];
+        let dataCode = me.projectGljSetting.header[col].dataCode;
+        if(dataCode=='basePrice'||dataCode=='marketPrice'||dataCode=='supply'){//有组成物时,市场单价、定额价、供货方式不能修改
+            let priceCell = false;
+            if (data.ratio_data  && data.ratio_data.length > 0){
+                priceCell = true;
+            }
+            if(priceCell==false&&dataCode=='basePrice'&&data.is_add!=1){//如果不是新增,定额价不可修改。
+                priceCell = true;
+            }
+            me.projectGljSheet.getCell(row, col,  GC.Spread.Sheets.SheetArea.viewport).locked(priceCell);
+        }
+        if(dataCode == 'supply_quantity'){
+            if (data.supply == 1) {// 如果为部分甲供则甲供数量需要可编辑
+                me.projectGljSheet.getCell(row, col,  GC.Spread.Sheets.SheetArea.viewport).locked(false);
+            }else {
+                me.projectGljSheet.getCell(row, col,  GC.Spread.Sheets.SheetArea.viewport).locked(true);
+            }
+        }
+        me.projectGljSheet.repaint();
+    },
 
 
+    showProjectGljData:function () {
+        let projectGljSheetData = [];
+        let gljList = projectObj.project.projectGLJ.datas.gljList;
+        gljList = filterProjectGLJ(gljList);
+        gljList = sortProjectGLJ(gljList);
+        for(let glj of gljList){
+            projectGljSheetData.push(this.getSheetDataByGLJ(glj));
+        }
+        this.projectGljSheetData = projectGljSheetData;
+        this.projectGljSheet.setRowCount(0);
+        sheetCommonObj.showData(this.projectGljSheet, this.projectGljSetting,this.projectGljSheetData);
+        this.projectGljSheet.setRowCount(this.projectGljSheetData.length);
+    },
+    getSheetDataByGLJ:function (glj) {
+        let projectGLJ = projectObj.project.projectGLJ;
+        let materialIdList = projectGLJ.datas.constData.materialIdList;
+        let data ={
+            id:glj.id,
+            code:glj.code,
+            name:glj.name,
+            specs:glj.specs,
+            unit:glj.unit,
+            type:glj.type,
+            short_name:projectGLJ.getShortNameByID(glj.type),
+            quantity:glj.quantity,
+            supply:glj.supply,
+            supply_quantity:glj.supply_quantity,
+            delivery:glj.delivery,
+            delivery_address:glj.delivery_address,
+            is_adjust_price:glj.is_adjust_price,
+            ratio_data:glj.ratio_data,
+            is_add:glj.unit_price.is_add,
+            bgColour:'white'
+        };
+        gljOprObj.setGLJPrice(data,glj);
 
+        //供货方式为完全甲供时设置甲供数量为总消耗量
+        if (data.supply == 2) {
+            data.supply_quantity = glj.quantity;
+        }
+        // 只有材料才显示是否暂估
+        if (materialIdList.indexOf(glj.type) >= 0) {
+            data.is_evaluate = glj.is_evaluate;
+        }
+        //bgColour
+        if(data.basePrice == data.marketPrice){//如果定额价等于市场价时,改底色。 优先度低于有组成物时的底色
+            data.bgColour = "#C4CAFB";
+        }
+        if (notEditType.indexOf(glj.type) >= 0) {
+            if (data.ratio_data  && data.ratio_data.length > 0){//有组成物时
+                //设置底色
+                data.bgColour = "#E0E0E0";
+            }
+        }
+        return data;
+    },
+    refreshProjectGljRow:function (row) {
+        let me = projectGljObject;
+        let rowData = me.projectGljSheetData[row];
+        let glj = projectObj.project.projectGLJ.getByID(rowData.id);
+        if(glj){
+            me.projectGljSheetData[row] = me.getSheetDataByGLJ(glj);
+        }
+        sheetCommonObj.showRowData(this.projectGljSheet, this.projectGljSetting,row,this.projectGljSheetData);
+    },
+    initSheet: function (sheet,setting) {
+        var me = this;
+        sheetCommonObj.initSheet(sheet, setting, 30);
+        sheet.bind(GC.Spread.Sheets.Events.ValueChanged, me.onSheetValueChange);
+    },
+    onSheetValueChange:function (e,info) {
+        let me = projectGljObject;
+        if(info.sheetName=='projectGljSheet'){
+            me.onProjectGLJValueChange(e,info);
+        }
+    },
+    onProjectGLJValueChange:function (e,info) {
+        let projectGLJ = projectObj.project.projectGLJ;
+        let me = projectGljObject,row = info.row, col = info.col;
+        let dataCode = me.projectGljSetting.header[col].dataCode;
+        let recode = me.projectGljSheetData[row];
+        let value = info.newValue;
+        if (!me.checkData(col,me.projectGljSetting,value)) {
+            alert('输入的数据类型不对,请重新输入!');
+            return ;
+        }
+        let callback=function (impactList) {
+            info.sheet.suspendPaint();
+            info.sheet.suspendEvent();
+            me.refreshProjectGljRow(row);
+            for(let g of impactList){
+                let index = _.findIndex(me.projectGljSheetData, { 'id': g.id });
+                if(index>=0&&index != row){
+                    me.refreshProjectGljRow(index);
+                }
+            }
+            info.sheet.resumeEvent();
+            info.sheet.resumePaint();
+        };
+        if(dataCode=='basePrice'||dataCode=='marketPrice'){
+            value= scMathUtil.roundForObj(value,getDecimal('glj.unitPrice'));//修改市场价和修改定额价时需要重新记算很多受影响的树节点,现在改成与定字额工料机那里调相同的方法。
+            let editField = dataCode === 'basePrice'?"base_price":"market_price";
+            projectObj.project.projectGLJ.updatePrice(recode,editField,value,'pg',callback);
+
+        }else {
+            let extend = {};
+            // 如果是供货方式则需要处理数据
+            if (dataCode === 'supply') {
+                extend.supply_quantity = me.getSupplyQuantity(value, recode.quantity);
+            }
+            if(dataCode === 'supply_quantity'){//修改数量需做4舍5入
+                value= value.toDecimal(getDecimal('glj.quantity'));
+            }
+            if(dataCode === 'is_evaluate'||dataCode === 'is_adjust_price'){
+                if(value == true){
+                    value = 1;
+                }else if(value == false){
+                    value = 0;
+                }
+            }
+            extend = Object.keys(extend).length > 0 ?  JSON.stringify(extend) : '';
+            let updateData = {id: recode.id, field: dataCode, value: value, extend: extend};
+            projectGLJ.pGljUpdate(updateData,callback);
+        }
+    },
+    getSupplyQuantity : function(supplyType, quantity) {
+        // 自行采购和甲定乙供则把甲供数量设置为0,其余情况则设置为当前总消耗量
+        let supplyQuantity = supplyType == 0 || supplyType == 3 ? 0 : quantity;
+        supplyQuantity = parseFloat(supplyQuantity);
+        return supplyQuantity;
+    },
+    checkData : function(col,setting, value) {
+        let result = true;
+        let validator = setting.header[col].validator !== undefined ? setting.header[col].validator : null;
+        if (validator === null) {
+            return result;
+        }
+        switch (validator) {
+            case 'number':
+                let regular = /^\d+(\.\d+)?$/;
+                result = regular.test(value);
+                break;
+            case 'boolean':
+                let booleanValue = [true, false];
+                result = booleanValue.indexOf(value) >= 0;
+                break;
+        }
+        return result;
+    }
 };
 
 
 $(function () {
-
-
     $('#tab_project_glj').on('show.bs.tab', function (e) {
+        let me = projectGljObject;
         $(e.relatedTarget.hash).removeClass('active');
-
-
-
-
-
+        setTimeout(function () {
+            if(me.projectGljSpread==null){
+                me.initProjectGljSpread();
+            }
+            me.showProjectGljData();
+            loadSize("project-glj-main", function () {
+                me.projectGljSpread.refresh();
+            });
+        },1)
+    });
+    slideResize($("#project-glj-main"), function () {
+        projectGljObject.projectGljSpread.refresh();
     });
-
 });