Bläddra i källkod

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

zhangweicheng 7 år sedan
förälder
incheckning
c373fc976d

+ 31 - 0
web/building_saas/js/global.js

@@ -47,3 +47,34 @@ $(function () {
     });
 
 });
+
+/**
+ * 设置本地缓存
+ *
+ * @param {String} key
+ * @param {String|Number} value
+ * @return {void}
+ */
+function setLocalCache(key, value) {
+    const storage = window.localStorage;
+    if (!storage || key === '' || value === '') {
+        return;
+    }
+
+    storage.setItem(key, value);
+}
+
+/**
+ * 获取本地缓存
+ *
+ * @param {String} key
+ * @return {String}
+ */
+function getLocalCache(key) {
+    const storage = window.localStorage;
+    if (!storage || key === '') {
+        return null;
+    }
+
+    return storage.getItem(key);
+}

+ 16 - 10
web/building_saas/main/js/main.js

@@ -28,6 +28,16 @@ $(function () {
         projectObj.mainSpread.refresh();
         refreshSubSpread();
     });
+
+    const projectId = scUrlUtil.GetQueryString('project');
+    // 绑定点击事件
+    projectObj.mainSpread.bind(GC.Spread.Sheets.Events.CellClick, function(sender, info) {
+        if (info.row !== undefined && projectId !== undefined) {
+            setLocalCache('lastRow:' + projectId, info.row);
+            setLocalCache('lastCol:' + projectId, info.col);
+        }
+    });
+
 });
 
 /**
@@ -85,12 +95,9 @@ function slideResize(rootElement, callback) {
             callback();
             drag = false;
             // 存入本地缓存
-            const storage = window.localStorage;
-            if (storage) {
-                const id = rootElement.attr('id');
-                storage.setItem('topHeight:' + id, topChangeHeight);
-                storage.setItem('bottomHeight:' + id, bottomChangeHeight);
-            }
+            const id = rootElement.attr('id');
+            setLocalCache('topHeight:' + id, topChangeHeight);
+            setLocalCache('bottomHeight:' + id, bottomChangeHeight);
         }
     });
 }
@@ -103,12 +110,11 @@ function slideResize(rootElement, callback) {
  * @return {void}
  */
 function loadSize(tag, callback) {
-    const storage = window.localStorage;
-    if (!storage || tag === '') {
+    if (tag === '') {
         return;
     }
-    const topHeight = storage.getItem('topHeight:' + tag);
-    const bottomHeight = storage.getItem('bottomHeight:' + tag);
+    const topHeight = getLocalCache('topHeight:' + tag);
+    const bottomHeight = getLocalCache('bottomHeight:' + tag);
     if (topHeight === null || bottomHeight === null) {
         return;
     }

+ 3 - 0
web/building_saas/main/js/models/calc_base.js

@@ -399,6 +399,7 @@ let cbCalctor = {
 };
 
 let calcBase = {
+    success: false,
     //清单固定行
     fixedFlag: null,
     fixedBills: Object.create(null),
@@ -426,6 +427,7 @@ let calcBase = {
             $CBP = cbParser,
             $CBC = cbCalctor;
         try {
+            me.success = false;
             //分析输入式合法性
             let exp = $CBA.legalExp(node.data.userCalcBase);
             if(!exp){
@@ -440,6 +442,7 @@ let calcBase = {
                 throw '表达式不正确';
             }
             //存储
+            me.success = true;
             node.data.calcBase = exp;
             node.data.calcBaseValue = parseFloat(calcBaseValue).toDecimal(decimalObj.decimal('totalPrice', node));
             me.project.calcProgram.calculate(node);

+ 7 - 0
web/building_saas/main/js/views/calc_base_view.js

@@ -161,6 +161,10 @@ let calcBaseView = {
 
     initCalctor: function (node) {
         let me = calcBaseView;
+        //输入框显示原本的
+        if(me.isDef(node.data.calcBase)){
+            me.inputExpr.val(node.data.calcBase);
+        }
         me.buildSheet();
         let baseObj = me.getFigure(node);
         me.showData(me.toViewData(baseObj));
@@ -221,6 +225,9 @@ let calcBaseView = {
             let selected = projectObj.project.mainTree.selected;
             selected.data.userCalcBase = me.getInputExpr();
             projectObj.project.calcBase.calculate(selected);
+            if(projectObj.project.calcBase.success){
+                $('#qd-jsjs').modal('hide');
+            }
         });
     },
 

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

@@ -47,7 +47,6 @@ decimalObj.decimal = function (field, node) {
 
 function returnV(v, r){
     if(isDef(v)){
-        console.log(v);
         return v;
     }
     return r;

+ 13 - 0
web/building_saas/main/js/views/project_view.js

@@ -415,6 +415,7 @@ var projectObj = {
                 that.mainSpread.bind(GC.Spread.Sheets.Events.EditEnded, that.mainSpreadEditEnded);
                 that.mainSpread.bind(GC.Spread.Sheets.Events.RangeChanged, that.mainSpreadRangeChanged);
                 that.loadMainSpreadContextMenu();
+                that.loadFocusLocation();
             }
             else {
 
@@ -534,6 +535,18 @@ var projectObj = {
         this.project.Bills.updateAll();
         calc = null;
     }*/
+    // 获取上次退出时的焦点位置
+    loadFocusLocation: function() {
+        const projectId = scUrlUtil.GetQueryString('project');
+        let row = getLocalCache('lastRow:' + projectId);
+        let col = getLocalCache('lastCol:' + projectId);
+        if (row !== null && col !== null) {
+            row = parseInt(row);
+            col = parseInt(col);
+            const sheet = this.mainSpread.getActiveSheet();
+            sheet.setSelection(row, col, 1, 1);
+        }
+    },
 };
 
 $('#insert').click(function () {

+ 1 - 1
web/common/html/header.html

@@ -5,7 +5,7 @@
             <a class="nav-link" href="#" aria-expanded="false" data-toggle="modal" data-target="#poj-set"><i class="fa fa-cube"></i> 项目属性</a>
         </li>
         <li class="nav-item">
-            <a class="nav-link" href="#" aria-expanded="false"><i class="fa fa-sliders"></i> 选项</a>
+            <a class="nav-link" href="#" aria-expanded="false" data-toggle="modal" data-target="#opts-set"><i class="fa fa-sliders"></i> 选项</a>
         </li>
         <li class="nav-item dropdown">
             <a class="nav-link dropdown-toggle" href="#" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false"><i class="fa fa-wrench"></i> 工具</a>