Browse Source

信息价功能

zhangweicheng 4 years ago
parent
commit
ae10a170f4

+ 5 - 0
modules/main/controllers/info_price_controller.js

@@ -15,6 +15,11 @@ let controller = {
       data = JSON.parse(data);
       return await info_price_facade.getDataByCondition(data,req.session.sessionCompilation);
     },
+    getClassByAreaID:async function (req){
+        let data = req.body.data;
+        data = JSON.parse(data);
+        return await info_price_facade.getClassByAreaID(data,req.session.sessionCompilation);
+    },
     mutiApplyInfoPrice:async function (req){
       let data = req.body.data;
       data = JSON.parse(data);

+ 32 - 0
modules/main/facade/info_price_facade.js

@@ -4,17 +4,20 @@
 module.exports={
   getOptions,
   getDataByCondition,
+  getClassByAreaID,
   mutiApplyInfoPrice
 };
 
 const mongoose = require('mongoose');
 let infoLibModel = mongoose.model("std_price_info_lib");
+let infoClassModel = mongoose.model("std_price_info_class");
 let infoItemsModel = mongoose.model("std_price_info_items");
 let infoAreasModel = mongoose.model("std_price_info_areas");
 let unitPriceModel = mongoose.model("unit_price"); 
 let _ = require("lodash");
 let gljUtil = require('../../../public/web/gljUtil');
 const scMathUtil = require('../../../public/scMathUtil').getUtil();
+let projectfacade = require('./project_facade');
 // 载入模块
 var Segment = require('segment');
 // 创建实例
@@ -46,6 +49,35 @@ async function getOptions(data,compilation){//data 是预留对象,暂时不
   return {areas:areas,periodMap:periodMap}
 }
 
+async function getClassByAreaID(data,compilation){
+  console.log(data);
+  //要先知道根据期数和编办查找库ID
+  let newList = [];
+  let lib = await infoLibModel.findOne({compilationID:compilation._id,period:data.period})
+  if(lib){
+    let infoClass =  await infoClassModel.find({areaID:data.areaID,libID:lib.ID}).lean();
+    let parentMap=_.groupBy(infoClass, 'ParentID');
+    for(let key in parentMap){
+      parentMap[key] = projectfacade.sortChildren(parentMap[key]);
+    }
+    
+    if(parentMap && parentMap['-1']){
+      getChildern(parentMap['-1'],newList,parentMap)
+    }
+  }
+  
+
+
+  function getChildern(children,list,pm){
+    for(let c of children){
+      list.push(c);
+      if(pm[c.ID]){
+        getChildern(pm[c.ID],list,pm)
+      }
+    }
+  }
+  return newList;
+}
 
 async function getDataByCondition(data,compilation){
   let result = {};

+ 1 - 0
modules/main/routes/info_price_route.js

@@ -8,6 +8,7 @@ module.exports = function (app) {
     let infoController = require('../controllers/info_price_controller');
     infoRouter.post('/getOptions', infoController.action);
     infoRouter.post('/getDataByCondition', infoController.action);
+    infoRouter.post('/getClassByAreaID', infoController.action);
     infoRouter.post('/mutiApplyInfoPrice', infoController.action);
 
     app.use('/infoPrice', infoRouter);

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

@@ -164,6 +164,7 @@ var sheetCommonObj = {
         let styleRow=[];
         sheet.suspendPaint();
         sheet.suspendEvent();
+        sheet.setRowCount(data.length);
         for (let col = 0; col < setting.header.length; col++) {
             let hAlign = "left", vAlign = "center";
             if (setting.header[col].hAlign) {

+ 5 - 1
web/building_saas/glj/html/project_glj.html

@@ -152,9 +152,13 @@
               <label class="mr-auto" id = "info-warning"></label>    
               <input type="hidden" class="form-control form-control-sm" id="info_glj_name">
               <input type="hidden" class="form-control form-control-sm" id="info_glj_code">       
+              <input type="hidden" class="form-control form-control-sm" id="info_class">       
               <button type="button" class="btn btn-primary  btn-sm" id="muti_apply_info">批量套用</button>
             </div>
-            <div class="main-data-bottom" id="info_price_sheet"> </div>
+            <div class="main-data-bottom" id="info_price_main" style="display: flex;overflow: hidden;"> 
+              <div id="info_class_sheet" style="width: 30%; overflow: hidden;"></div>
+              <div id="info_price_sheet" style=" width: 70%;overflow: hidden;"></div>
+            </div>
           </div>
         </div>
       </div>

+ 0 - 1
web/building_saas/main/js/views/export_view.js

@@ -41,7 +41,6 @@ const ExportView = (() => {
         sheetCommonObj.spreadDefaultStyle(spread);
         let sheet = spread.getSheet(0);
         sheetCommonObj.initSheet(sheet, sheetSetting, 30);
-        sheet.setRowCount(datas.length);
         sheetCommonObj.showTreeData(sheet, sheetSetting, datas);
     }
     //获取设置的工程编号

+ 2 - 2
web/building_saas/main/js/views/index_view.js

@@ -239,8 +239,8 @@ let indexObj= {
         this.spread.setActiveSheetIndex(1);
         let sheet = this.spread.getActiveSheet();
         refreshValue();
-        this.setRowCountAndLock(sheet,this.engineerFeatureDatas);
         sheetCommonObj.showTreeData(sheet, this.engineerFeatureSetting,this.engineerFeatureDatas);
+        this.setRowCountAndLock(sheet,this.engineerFeatureDatas);
         function refreshValue() {
             let map = projectObj.project.property.engineerFeatures?_.indexBy(projectObj.project.property.engineerFeatures,'ID'):{};
             for(let f of indexObj.engineerFeatureDatas){
@@ -335,8 +335,8 @@ let indexObj= {
         let oldData = sel.row<this.ecoQuantityDatas.length?this.ecoQuantityDatas[sel.row]:null;
         this.ecoQuantityDatas = this.getIndexBillsData(parentMap);
         sheet.setRowCount(0);
-        this.setRowCountAndLock(sheet,this.ecoQuantityDatas);
         sheetCommonObj.showTreeData(sheet, this.ecoQuantitySetting,this.ecoQuantityDatas);
+        this.setRowCountAndLock(sheet,this.ecoQuantityDatas);
         sel.row = oldData?_.findIndex(this.ecoQuantityDatas,{'ID':oldData.ID}):0;
         sheet.setSelection(sel.row==-1?0:sel.row,sel.col,sel.rowCount,sel.colCount);
 

+ 0 - 1
web/building_saas/main/js/views/item_increase_fee_view.js

@@ -104,7 +104,6 @@ let itemIncreaseFeeObj = {
             if(node.data.calcBase&&node.data.calcBase!="") delete tem.selected;//有基数计算的不可选
             this.scopeDatas.push(tem);
         }
-        this.scopeSheet.setRowCount(this.scopeDatas.length);
         sheetCommonObj.showTreeData(this.scopeSheet, this.scopeSetting,this.scopeDatas);
     },
     onScopeCheckBoxClick:function (sender,args) {

+ 121 - 52
web/building_saas/main/js/views/project_glj_view.js

@@ -13,50 +13,28 @@ let projectGljObject = {
   projectGljSheet: null,
   materialTreeSheet: null,
   projectGljSheetData: [],
+  infoPriceData:[],
+  infoClassData:[],
   mixRatioSetting: {},
   infoPriceSetting: {
-    header: [{
-        headerName: "材料名称",
-        headerWidth: 320,
-        dataCode: "name",
-        dataType: "String"
-      },
-      {
-        headerName: "规格型号",
-        headerWidth: 200,
-        dataCode: "specs",
-        hAlign: "left",
-        dataType: "String"
-      },
-      {
-        headerName: "单位",
-        headerWidth: 50,
-        dataCode: "unit",
-        dataType: "String",
-        hAlign: "center"
-      },
-      {
-        headerName: "含税市场价",
-        headerWidth: 100,
-        dataCode: "taxPrice",
-        hAlign: "right",
-        dataType: "Number",
-        validator: "number"
-      },
-      {
-        headerName: "不含税市场价",
-        headerWidth: 100,
-        dataCode: "noTaxPrice",
-        hAlign: "right",
-        dataType: "Number",
-        validator: "number"
-      } //,decimalField:"glj.unitPrice"
+    header: [
+      { headerName: "材料名称", headerWidth: 320, dataCode: "name",  dataType: "String"},
+      { headerName: "规格型号", headerWidth: 200, dataCode: "specs",hAlign: "left",dataType: "String" },
+      { headerName: "单位",headerWidth: 50,dataCode: "unit", dataType: "String", hAlign: "center"},
+      { headerName: "含税市场价", headerWidth: 100, dataCode: "taxPrice", hAlign: "right",dataType: "Number",  validator: "number" },
+      { headerName: "不含税市场价", headerWidth: 100,   dataCode: "noTaxPrice",   hAlign: "right",   dataType: "Number",    validator: "number"   } //,decimalField:"glj.unitPrice"
     ],
     view: {
       lockColumns: [0, 1, 2, 3, 4] //,
       //colHeaderHeight:30
     }
   },
+  infoClassSetting:{
+    header: [{ headerName: "分类", headerWidth: 420, dataCode: "name",  dataType: "String"}],
+    view: {
+      lockColumns: [0] 
+    }
+  },
   relatedRationSetting: {
     header: [{
         headerName: "编码",
@@ -224,6 +202,7 @@ let projectGljObject = {
     this.initSheet(this.infoPriceSheet, this.infoPriceSetting);
     this.infoPriceSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, _.debounce(this.onInfoTopRowChanged, 100)); 
     this.infoPriceSheet.bind(GC.Spread.Sheets.Events.CellDoubleClick, this.onInfoPriceDoubleClick);
+    this.infoPriceSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, this.infoPriceSelectionChange);
     this.infoPriceSheet.name('infoPriceSheet');
     this.infoPriceSheet.setRowCount(0);
     this.getInfoPriceOptions();
@@ -234,6 +213,19 @@ let projectGljObject = {
       this.initInfoPriceRightClick();
     }
   },
+  initInfoClassSpread: function () {
+    if (this.infoClassSpread) return this.infoClassSpread.refresh();
+    this.infoClassSpread = SheetDataHelper.createNewSpread($("#info_class_sheet")[0]);
+    sheetCommonObj.spreadDefaultStyle(this.infoPriceSpread);
+    this.infoClassSheet = this.infoClassSpread.getSheet(0);
+    this.initSheet(this.infoClassSheet, this.infoClassSetting);
+    this.infoClassSheet.name('infoClassSheet');
+    this.infoClassSheet.setRowCount(0);
+    this.infoClassSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, this.infoClassSelectionChange);
+    if (projectReadOnly) {
+      disableSpread(this.infoClassSpread);
+    } 
+  },
   initSpreads: function () {
     if (this.projectGljSpread == null) this.initProjectGljSpread();
     //if(materialAdjustObj.spread == null) materialAdjustObj.initSpread();
@@ -529,20 +521,44 @@ let projectGljObject = {
     sheetCommonObj.showData(me.relatedRationSheet, me.relatedRationSetting, rations);
     me.relatedRationSheet.setRowCount(rations.length);
   },
+  setInfoClassSelection:function(){
+    let me = this;
+    let priceRow = me.infoPriceSheet.getSelections()[0].row;
+    let infoPrice = me.infoPriceData[priceRow];
+    if(infoPrice && me.infoClassData.length > 0){
+      const index = _.findIndex(me.infoClassData,{'ID':infoPrice.classID});
+      me.infoClassSheet.setSelection(index,0,1,1);
+      //me.infoClassSheet.clearSelection(); 清除焦点行
+      me.infoClassSheet.showRow(index, GC.Spread.Sheets.VerticalPosition.center);
+    }
+
+
+  },
   showInforPriceData: function (datas) {
     let me = this;
     me.infoPriceData = datas;
     sheetCommonObj.showData(me.infoPriceSheet, me.infoPriceSetting, datas);
     me.infoPriceSheet.setRowCount(datas.length);
+    if(datas.length > 0) me.setInfoClassSelection();
+  },
+  showInforClassData: function (datas) {
+    let me = this;
+    me.infoClassData = datas;
+    for(let d of datas){
+      d.collapsed = false;
+    }
+    sheetCommonObj.showTreeData(me.infoClassSheet, me.infoClassSetting, datas);
   },
   autoShowInfoPriceData: function () { 
     if (!$('#info-nav').hasClass('active')) return;
     let projectGLJData = this.getProjectGLJSelected();
-    $('#info_search_name').val(projectGLJData.name);
-    let code = projectGLJData.code.substr(0, 4);
-    $('#info_glj_name').val(projectGLJData.name);
-    $('#info_glj_code').val(code);
-    this.searchInfoPrice(null);
+    if(projectGLJData){
+      $('#info_search_name').val(projectGLJData.name);
+      let code = projectGLJData.code.substr(0, 4);
+      $('#info_glj_name').val(projectGLJData.name);
+      $('#info_glj_code').val(code);
+      this.searchInfoPrice(null);
+    }
   },
   getMixRatioSheetData: function (glj) {
     let data = {
@@ -622,9 +638,23 @@ let projectGljObject = {
     $("#tab_zaojiashu").click();
     locateObject.locateNode(record.ID);
   },
-  onInfoPriceDoubleClick: function name(sender, args) {
+  onInfoPriceDoubleClick: function(sender, args) {
     projectGljObject.preApplyInfoPrice(args.row);
   },
+  infoPriceSelectionChange:function(sender, args){
+    projectGljObject.setInfoClassSelection();
+  },
+  infoClassSelectionChange:function(sender, args){
+    let me = projectGljObject;
+    let row = args.newSelections[0].row;
+    let infoClass = me.infoClassData[row];
+    if(infoClass){
+      $("#info_class").val(infoClass.ID);
+      $("#info_glj_name").val("")//清除工料机名字搜索项
+      me.searchInfoPrice();
+    }
+
+  },
   onProjectGljSelectionChange: function (sender, args) {
     let me = projectGljObject;
     let newSel = args.newSelections[0];
@@ -657,6 +687,7 @@ let projectGljObject = {
     sel.colCount = 1;
     me.showMixRatioData();
     me.showRelatedRationDatas();
+    $("#info_class").val("");
     me.autoShowInfoPriceData();
   },
   rightClickCallback: function (row) {
@@ -1653,12 +1684,28 @@ let projectGljObject = {
       if (projectGljObject.infoPriceLastLoadingRow == me.infoPriceData.length) { //如果最后一行已经加载过了,就不用再加载了,不然会重复加载
         return;
       }
-      console.log(bottomRow);
       me.infoPriceLastLoadingRow = me.infoPriceData.length;
       //只有在空的搜索条件下才执行分页查询,其它情况无法分页
       if ($('#info_search_name').val() == "") me.searchInfoPrice(me.infoPriceData[me.infoPriceData.length - 1]._id)
     }
   },
+  searchInfoClass:async function(){
+    let me = projectGljObject;
+    let areaID = $('#info_area').val();
+    let year = $('#info_year').val();
+    let month = $('#info_month').val();
+    let datas = [];
+    $('#info_class').val("");
+    try {
+      if (year != "" && month != "" && areaID != ""){
+        let period = year + "-" + month;
+        datas = await ajaxPost("/infoPrice/getClassByAreaID", {areaID:areaID,period:period});
+      }
+      me.showInforClassData(datas);
+    } catch (error) {
+       console.log(error)
+    }
+  },
   searchInfoPrice: async function (objectID) {
     let year = $('#info_year').val();
     let month = $('#info_month').val();
@@ -1666,6 +1713,7 @@ let projectGljObject = {
     let keyWord = $('#info_search_name').val();
     let name =  $('#info_glj_name').val();
     let code =  $('#info_glj_code').val();
+    let classID = $("#info_class").val();
     let me = projectGljObject;
     try {
       if (year != "" && month != "" && areaID != "") {
@@ -1673,10 +1721,16 @@ let projectGljObject = {
           period: year + "-" + month,
           areaID: areaID
         }
+        if(classID!=""){
+          keyWord = "";
+          condition.classID = classID;
+        } 
+        
         if (projectGljObject.addCommonInfoPriceID) projectGljObject.addCommonInfoPriceID(condition);
         let data = {
           condition: condition
         };
+        
         if (keyWord != "") data.keyWord = keyWord;
         if (name !="") data.keyWord = name;
         if (objectID) data.lastID = objectID;
@@ -1688,6 +1742,7 @@ let projectGljObject = {
         } else {
           me.infoPriceTotalSize = result.totalSize;
           me.infoPriceLastLoadingRow = 0;
+
           me.showInforPriceData(result.items);
           if (result.totalSize == 0) {
             $("#info-warning").text("当前材料没有信息价! ");
@@ -1707,6 +1762,7 @@ let projectGljObject = {
   preApplyInfoPrice: function (row) {
     let info = this.infoPriceData[row];
     let projectGLJData = this.getProjectGLJSelected();
+    if(!projectGLJData) return;
     if (projectGLJData.ratio_data && projectGLJData.ratio_data.length > 0) return;
     let marketPrice = this.getInfoMarketPrice(info);
     if (projectGLJData.unit == info.unit) {
@@ -1751,8 +1807,17 @@ let projectGljObject = {
     return gljUtil.getInfoMarketPrice(info, taxType);
   },
   refreshInfoPrice: function () { 
-    $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height()-10);
-    projectGljObject.initInfoPriceSpread();
+    this.setInfoDivHeight();
+    if ($('#info_price_sheet').is(':visible')){
+      this.initInfoPriceSpread();
+      this.initInfoClassSpread();
+    }
+  },
+  setInfoDivHeight:function(){
+    let info_height = $("#mix_ratio_sheet").height() - $("#infoToolDiv").height()-10;
+    $('#info_price_main').height(info_height);
+    $('#info_class_sheet').height(info_height);
+    $('#info_price_sheet').height(info_height);
   }
 };
 
@@ -1811,8 +1876,7 @@ function loadProjectGljSize() {
         me.projectGljSpread ? me.projectGljSpread.refresh() : '';
         me.mixRatioSpread ? me.mixRatioSpread.refresh() : '';
         //信息价相关
-        $('#info_price_sheet').height($("#mix_ratio_sheet").height() - $("#infoToolDiv").height());
-        if ($('#info_price_sheet').is(':visible')) me.initInfoPriceSpread();
+        me.refreshInfoPrice();
       });
     }
 
@@ -2137,7 +2201,7 @@ $(function () {
     projectGljObject.refreshInfoPrice();
     projectGljObject.autoShowInfoPriceData(); 
   });
-  $('#info_year').change(function () {
+  $('#info_year').change(async function () {
     let periodMap = projectGljObject.infoPriceOptions.periodMap;
     let year = $(this).val();
     let month = $("#info_month").val();
@@ -2147,21 +2211,25 @@ $(function () {
     if (month != "") {
       if (_.includes(options, month)) {
         $("#info_month").val(month);
+        projectGljObject.searchInfoClass();
         projectGljObject.searchInfoPrice();
       }
     }
   });
-  $('#info_month').change(function () {
-    projectGljObject.searchInfoPrice();
+  $('#info_month').change(async function () {
+    await projectGljObject.searchInfoClass();
+    await projectGljObject.searchInfoPrice();
   });
-  $('#info_area').change(function () {
-    projectGljObject.searchInfoPrice();
+  $('#info_area').change(async function () {
+    await projectGljObject.searchInfoClass()
+    await projectGljObject.searchInfoPrice();
   });
   $('#info_search_name').on('keypress', function (e) {
     $("#info-warning").text("");
     if (e.keyCode === 13) {
       $('#info_glj_name').val("");
       $('#info_glj_code').val("");
+      $('#info_class').val("");
       projectGljObject.searchInfoPrice();
     }
   });
@@ -2169,6 +2237,7 @@ $(function () {
   $('#info_search_btn').on('click', function (e) {
     $('#info_glj_name').val("");
     $('#info_glj_code').val("");
+    $('#info_class').val("");
     projectGljObject.searchInfoPrice();
   });
 

+ 3 - 2
web/over_write/js/chongqing_2018.js

@@ -10,9 +10,10 @@ if(typeof projectGljObject !== 'undefined'){
         {ID:'MAIN_MATERIAL',text:'主材'}
     ];
     $('#menu_index_info').show();
-  projectGljObject.addCommonInfoPriceID = function (condition) { 
+    //2020-11-06 暂时去掉主城区加载通用 
+ /*  projectGljObject.addCommonInfoPriceID = function (condition) { 
     if(condition.areaID != projectGljObject.commonInfoPriceID) condition.commonInfoPriceID = projectGljObject.commonInfoPriceID;
-  }
+  } */
 }
 if(typeof gljUtil !== 'undefined'){
     gljUtil.hasCompMachine = [301,304];//有组成物的机械