zhangweicheng 4 年之前
父节点
当前提交
a3cafa3dd2
共有 2 个文件被更改,包括 77 次插入13 次删除
  1. 1 1
      web/building_saas/glj/html/project_glj.html
  2. 76 12
      web/building_saas/main/js/views/project_glj_view.js

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

@@ -114,7 +114,7 @@
                         <option value="江北区" >江北区</option>
                       </select>
                       <label class="mx-2" for="info_year">期数</label>
-                      <select class="form-control form-control-sm" style="font-size: .875rem; width:80px;" id="info_year">
+                      <select class="form-control form-control-sm" style="font-size: .875rem; width:100px;" id="info_year">
                         <option value=""></option>
                         <option value="2020" >2020</option>
                         <option value="2019" >2019</option>

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

@@ -15,9 +15,8 @@ let projectGljObject={
     mixRatioSetting:{},
     infoPriceSetting:{
       header:[
-        {headerName: "编号", headerWidth: 100, dataCode: "code", dataType: "String"},
-        {headerName: "材料名称", headerWidth: 180, dataCode: "name", dataType: "String"},
-        {headerName: "规格型号", headerWidth: 160, dataCode: "specs", hAlign: "left", dataType: "String"},
+        {headerName: "材料名称", headerWidth: 360, dataCode: "name", dataType: "String"},
+        {headerName: "规格型号", headerWidth: 240, dataCode: "specs", hAlign: "left", dataType: "String"},
         {headerName: "单位", headerWidth: 50, dataCode: "unit", dataType: "String",hAlign: "center"},
         {headerName: "含税市场价", headerWidth: 160, dataCode: "taxPrice", hAlign: "right", dataType: "Number",validator:"number"}//,decimalField:"glj.unitPrice"
     ],
@@ -83,8 +82,9 @@ let projectGljObject={
       sheetCommonObj.spreadDefaultStyle(this.infoPriceSpread);
       this.infoPriceSheet = this.infoPriceSpread .getSheet(0);
       this.initSheet(this.infoPriceSheet,this.infoPriceSetting);
+      this.infoPriceSheet.bind(GC.Spread.Sheets.Events.TopRowChanged, _.debounce(this.onInfoTopRowChanged, 100));
       this.infoPriceSheet.name('infoPriceSheet');
-
+      this.infoPriceSheet.setRowCount(0);
 
       this.getInfoPriceOptions();
     },
@@ -372,7 +372,12 @@ let projectGljObject={
       sheetCommonObj.showData(me.relatedRationSheet, me.relatedRationSetting,rations);
       me.relatedRationSheet.setRowCount(rations.length);
     },
-
+    showInforPriceData:function(datas){
+      let me = this;
+      me.infoPriceData = datas;
+      sheetCommonObj.showData(me.infoPriceSheet, me.infoPriceSetting,datas);
+      me.infoPriceSheet.setRowCount(datas.length);
+    },
     getMixRatioSheetData:function (glj) {
         let data ={
             id:glj.id,
@@ -1219,6 +1224,9 @@ let projectGljObject={
                     callback: function (key, opt) {
                         let row = me.rightClickTarget.row;
                         me.deleteMixRatio(row);
+                    },
+                    visible: function(key, opt){
+                      if(!$('#mixRatio-nav').hasClass('active')) return false;
                     }
                 },
                 "addMixRatio":{
@@ -1231,6 +1239,9 @@ let projectGljObject={
                     callback: function (key, opt) {
                         me.selectedProjectGLJ = projectGljObject.getProjectGLJSelected();
                         getGLJData('addMix', null, true, null);
+                    },
+                    visible: function(key, opt){
+                      if(!$('#mixRatio-nav').hasClass('active')) return false;
                     }
                 }
             }
@@ -1293,13 +1304,58 @@ let projectGljObject={
       let years = _.keysIn(options.periodMap);
       this.createSelectOptions($("#info_year"),_.sortBy(years));   
     },
-    createSelectOptions(ele,opts){
+    createSelectOptions:function(ele,opts){
       ele.empty();
       let str = `<option value=""></option>`;
       for(let o of opts){
         str +=`<option value="${o}">${o}</option>`
       }
       ele.html(str);
+    },
+    onInfoTopRowChanged:function(sender, args){
+      let me = projectGljObject;
+      const bottomRow = args.sheet.getViewportBottomRow(1);
+      if(me.infoPriceData >= me.infoPriceTotalSize) return;
+      if(me.infoPriceData.length - bottomRow < 20 ){   
+        if(projectGljObject.infoPriceLastLoadingRow == me.infoPriceData.length){//如果最后一行已经加载过了,就不用再加载了,不然会重复加载
+          return;
+        }
+        console.log(bottomRow);
+        me.infoPriceLastLoadingRow = me.infoPriceData.length;
+        me.searchInfoPrice(me.infoPriceData[me.infoPriceData.length - 1]._id)
+      } 
+
+      
+    },
+    searchInfoPrice:async function(objectID){
+      let year = $('#info_year').val();
+      let month =  $('#info_month').val();
+      let area = $('#info_area').val();
+      let keyWord = $('#info_search_name').val();
+      let me = projectGljObject;
+      try {
+        if(year !="" && month!="" && area!="") {
+          let condition = {
+            period:year+"-"+month,
+            area:area
+          }
+          let data ={condition:condition};
+          if(keyWord !="")  data.keyWord = keyWord;
+          if(objectID) data.lastID = objectID;
+          let result = await ajaxPost("/infoPrice/getDataByCondition",data);
+          if(objectID){//分页查询
+            sheetCommonObj.appendData(me.infoPriceSheet, me.infoPriceData.length, 0, me.infoPriceSetting, result.items);
+            me.infoPriceData.splice(me.infoPriceData.length, 0, ...result.items);
+          }else{
+            me.infoPriceTotalSize = result.totalSize;
+            me.infoPriceLastLoadingRow = 0;
+            me.showInforPriceData(result.items);
+          }
+        }
+      } catch (error) {
+        console.log(error) 
+      }
+      
     }
 };
 
@@ -1668,15 +1724,23 @@ $(function () {
       if(month !=""){
         if(_.includes(options,month)){
           $("#info_month").val(month);
-          // to do 
-          //获取信息价内容
+          projectGljObject.searchInfoPrice();
         }
       }
     });
     $('#info_month').change(function () {
-      let month = $(this).val();
-      console.log(month);
-       // to do 
-       //获取信息价内容
+      projectGljObject.searchInfoPrice();
+    });
+    $('#info_area').change(function () {
+      projectGljObject.searchInfoPrice();
     });
+   /*  $('#info_search_name').on('keypress', function (e) {
+      if (e.keyCode === 13) {
+        projectGljObject.searchInfoPrice();
+      }
+    });
+    $('#info_search_btn').on('click', function (e) {
+      projectGljObject.searchInfoPrice();
+    }); */
+
 });