Browse Source

清单、定额计算基数ui统一

zhongzewei 7 năm trước cách đây
mục cha
commit
042966d4cb

+ 52 - 31
web/building_saas/main/js/views/calc_base_view.js

@@ -2,19 +2,24 @@
  * Created by Zhong on 2017/12/1.
  */
 /*
-* 清单计算基数
+* 计算基数,清单、定额统一ui
 * */
 let calcBaseView = {
     //可用计算基数的清单固定列映射(与fixedFlag)
     inputExpr: $('#calcBaseExp'),
     confirmBtn: $('#calcBaseConf'),
+    type: {bills: 'bills', ration: 'ration'},
+    curType: null,
     editingCell: null,
     workBook: null,
     setting:{
-        header: [
+        billsHeader: [
             {name: '计算基础名称', dataCode: 'base', width: 280, vAlign: 'center', hAlign: 'left'},
             {name: '金额', dataCode: 'price', width: 120, vAlign: 'center', hAlign: 'right'}
         ],
+        rationHeader: [
+
+        ],
         options: {
             tabStripVisible:  false,
             allowCopyPasteExcelStyle : false,
@@ -62,6 +67,14 @@ let calcBaseView = {
         if(!this.workBook){
             this.workBook = new GC.Spread.Sheets.Workbook($('#billsBaseSpread')[0], {sheetCount: 1});
             this.setOptions(this.workBook, this.setting.options);
+            //bills
+            if(this.curType === this.type.bills){
+                this.setting.header = this.setting.billsHeader;
+            }
+            //ration
+            else {
+
+            }
             this.buildHeader(this.workBook.getActiveSheet(), this.setting.header);
             this.bindEvent(this.workBook);
         }
@@ -79,7 +92,6 @@ let calcBaseView = {
         let cols = this.setting.header;
         let fuc = function () {
             sheet.setRowCount(datas.length);
-            //sheet.setFormatter(-1, 1, '@');
             let style = new GC.Spread.Sheets.Style();
             style.formatter = MainTreeCol.getNumberFormatter(decimalObj.bills.totalPrice, true);
             sheet.setStyle(-1, 1, style);
@@ -109,16 +121,10 @@ let calcBaseView = {
     isDef: function (v) {
         return v !== undefined && v !== null;
     },
-    isFlag: function (v) {
-        return this.isDef(v.flagsIndex) && this.isDef(v.flagsIndex.fixed);
-    },
     ifEdit: function () {
         var selected = projectObj.project.mainTree.selected;
         return MainTreeCol.readOnly.forCalcBase(selected)?false:true;
     },
-    canBase: function (node) {
-        return node.sourceType === projectObj.project.Bills.getSourceType() && node.children.length === 0;
-    },
     //计算基数转换为显示数据Obj to Array
     toViewData: function (obj) {
         let rst = [];
@@ -131,16 +137,25 @@ let calcBaseView = {
         return rst;
     },
 
-    initCalctor: function (node) {
+    initCalctor: function (type) {//type = bills、ration
         let me = calcBaseView;
-        //输入框显示原本的
-        if(me.isDef(node.data.calcBase)){
-            me.inputExpr.val(cbParser.toFExpr(node.data.calcBase));
+        let showDatas;
+        $('#qd-jsjs').modal('show');
+        if(type === me.type.bills){//bills
+            me.curType = type;
+            let node = projectObj.project.mainTree.selected;
+            //输入框显示原本的
+            if(me.isDef(node.data.calcBase)){
+                me.inputExpr.val(cbParser.toFExpr(node.data.calcBase));
+            }
+            let baseObj = projectObj.project.calcBase.getBaseByClass(node);
+            showDatas = me.toViewData(baseObj);
+        }
+        else{//ration
+
         }
         me.buildSheet();
-        let baseObj = projectObj.project.calcBase.getBaseByClass(node);
-        // console.log(baseObj);
-        me.showData(me.toViewData(baseObj));
+        me.showData(showDatas);
 
     },
 
@@ -200,10 +215,17 @@ let calcBaseView = {
     calcBaseConf: function () {
         let me = calcBaseView;
         me.confirmBtn.bind('click', function () {
-            let selected = projectObj.project.mainTree.selected;
-            projectObj.updateCellValue(selected, me.getInputExpr(), {data: {field: 'calcBase'}});
-            if(projectObj.project.calcBase.success){
-                $('#qd-jsjs').modal('hide');
+            //bills
+            if(me.curType === me.type.bills){
+                let selected = projectObj.project.mainTree.selected;
+                projectObj.updateCellValue(selected, me.getInputExpr(), {data: {field: 'calcBase'}});
+                if(projectObj.project.calcBase.success){
+                    $('#qd-jsjs').modal('hide');
+                }
+            }
+            //ration
+            else{
+
             }
         });
     },
@@ -215,11 +237,11 @@ let calcBaseView = {
         }
         CalcBaseCellType.prototype = new ns.CellTypes.Text();
         CalcBaseCellType.prototype.paint = function (ctx, value, x, y, w, h, style, options) {
-          //  if(value!=null){
-               // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
-               // ctx.fillText(value,x+w-3,y+h-3);
-                GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
-           // }
+            //  if(value!=null){
+            // ctx.fillText(value,x+3+ctx.measureText(value).width,y+h-3);
+            // ctx.fillText(value,x+w-3,y+h-3);
+            GC.Spread.Sheets.CellTypes.Text.prototype.paint.apply(this, arguments);
+            // }
             if(calcBaseView.editingCell){
                 if(calcBaseView.editingCell.row==options.row&&calcBaseView.editingCell.col==options.col){
                     var image = document.getElementById('f_btn'),imageMagin = 3;
@@ -272,7 +294,7 @@ let calcBaseView = {
                 var imageHeight = hitinfo.cellRect.height-2*imageMagin;
                 var imageWidth = hitinfo.cellRect.width*2/7;
                 if(hitinfo.x<offset&&hitinfo.x>offset-imageWidth){
-                    $('#qd-jsjs').modal({show: true});
+                    calcBaseView.initCalctor(calcBaseView.type.bills);
                 }
             }
         };
@@ -289,10 +311,9 @@ let calcBaseView = {
 };
 
 $(document).ready(function () {
-   $('#qd-jsjs').on('shown.bs.modal', function () {
-       calcBaseView.initCalctor(projectObj.project.mainTree.selected);
-       calcBaseView.workBook.refresh();
-   });
+    $('#qd-jsjs').on('shown.bs.modal', function () {
+        calcBaseView.workBook.refresh();
+    });
 
     $('#qd-jsjs').on('hidden.bs.modal', function () {
         //清空输入框
@@ -309,4 +330,4 @@ $(document).ready(function () {
 
     //confirmBtn
     calcBaseView.calcBaseConf();
-});
+});

+ 1 - 1
web/building_saas/main/js/views/main_tree_col.js

@@ -205,7 +205,7 @@ let MainTreeCol = {
         },
 
         calcBase: function () {
-            return calcBaseView.getCalcBaseCellType();
+            return calcBaseView.getCalcBaseCellType('bills');
         },
 
         // CSL, 2017-11-28