Browse Source

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

MaiXinRong 7 years ago
parent
commit
a2aca7ab98

+ 20 - 38
web/building_saas/glj/js/project_glj.js

@@ -25,7 +25,7 @@ let otherFileData = {};
 let currentTag = '';
 let isChanging = false;
 $(document).ready(function () {
-    $('#tab_gongliaoji').on('shown.bs.tab', function (e) {
+    $('#tab_gongliaoji').on('show.bs.tab', function (e) {
         init();
     });
 
@@ -157,50 +157,32 @@ $(document).ready(function () {
 /**
  * 初始化数据
  *
- * @return {void}
+ * @return {void|boolean}
  */
 function init() {
     // 加载工料机数据
-    $.ajax({
-        url: '/glj/getData',
-        type: 'post',
-        dataType: 'json',
-        data: {project_id: scUrlUtil.GetQueryString('project')},
-        error: function() {
-            // alert('数据传输错误');
-        },
-        beforeSend: function() {
-
-        },
-        success: function(response) {
-            if (response.err === 1) {
-                let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
-                alert(msg);
-                return false;
-            }
-            let data = response.data;
-            // 赋值
-            jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
-            mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
+    let data = projectObj.project.projectGLJ === null ? null : projectObj.project.projectGLJ.datas;
+    if (data === null) {
+        return false;
+    }
+    // 赋值
+    jsonData = data.gljList !== undefined && data.gljList.length > 0 ? data.gljList : [];
+    mixRatioConnectData = data.mixRatioConnectData !== undefined ? data.mixRatioConnectData : mixRatioConnectData;
 
-            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;
-            canNotChangeTypeId = data.constData.ownCompositionTypes !== undefined ?
-                data.constData.ownCompositionTypes : canNotChangeTypeId;
-            GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
+    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;
+    canNotChangeTypeId = data.constData.ownCompositionTypes !== undefined ?
+        data.constData.ownCompositionTypes : canNotChangeTypeId;
+    GLJTypeConst = data.constData.GLJTypeConst !== undefined ? JSON.parse(data.constData.GLJTypeConst) : GLJTypeConst;
 
-            let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
-            usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
-                data.constData.usedUnitPriceInfo : {};
-            // 存入缓存
-            projectObj.project.projectGLJ.datas = jsonData;
+    let usedTenderList = data.usedTenderList !== undefined ? data.usedTenderList : [];
+    usedUnitPriceInfo = data.constData.usedUnitPriceInfo !== undefined ?
+        data.constData.usedUnitPriceInfo : {};
 
-            spreadInit();
-            unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
-        }
-    });
+    unitPriceFileInit(usedUnitPriceInfo.name, usedTenderList);
 
+    setTimeout(spreadInit, 1);
 }
 
 /**

+ 2 - 1
web/building_saas/main/js/models/project.js

@@ -78,7 +78,8 @@ var PROJECT = {
             this.quantity_detail = quantity_detail.createNew(this);
             this.FeeRate = FeeRate.createNew(this);
             this.VolumePrice = VolumePrice.createNew(this);
-            this.projectGLJ = new projectGLJ(this);
+            this.projectGLJ = new ProjectGLJ();
+            this.projectGLJ.loadData();
             this.Decimal = {
                 common: {
                     quantity: 3,

+ 60 - 15
web/building_saas/main/js/models/project_glj.js

@@ -5,35 +5,80 @@
  * @date 2017/9/14
  * @version
  */
-function projectGLJ(project) {
-    this.project = project;
+function ProjectGLJ() {
     this.datas = null;
+    this.isLoading = false;
 }
 
 /**
- * 获取数据类型
+ * 加载数据
  *
- * @return {String}
+ * @return {boolean}
  */
-projectGLJ.prototype.getSourceType = function() {
-    let sourceType = ModuleNames.projectGLJ;
-    return sourceType;
+ProjectGLJ.prototype.loadData = function () {
+    let self = this;
+    if (self.isLoading) {
+        return false;
+    }
+    // 加载工料机数据
+    $.ajax({
+        url: '/glj/getData',
+        type: 'post',
+        dataType: 'json',
+        data: {project_id: scUrlUtil.GetQueryString('project')},
+        error: function() {
+            // alert('数据传输错误');
+        },
+        beforeSend: function() {
+            self.isLoading = true;
+        },
+        success: function(response) {
+            if (response.err === 1) {
+                let msg = response.msg !== undefined && response.msg !== '' ? response.msg : '读取工料机数据失败!';
+                alert(msg);
+                return false;
+            }
+            self.datas = response.data;
+            // 存入缓存
+            projectObj.project.projectGLJ = self;
+        }
+    });
 };
 
 /**
- * project中调用
+ * 获取对应工料机数据
  *
- * @return {void}
+ * @param {String} code
+ * @return {Object}
  */
-projectGLJ.prototype.createNew =  function() {
-    this.project.registerModule(ModuleNames.projectGLJ, this);
+ProjectGLJ.prototype.getDataByCode = function (code) {
+    let result = {};
+    if (this.datas === null) {
+        return result;
+    }
+
+    let gljList = this.datas.gljList;
+    if (gljList === undefined) {
+        return result;
+    }
+
+    for(let tmp of gljList) {
+        if (tmp.code === code) {
+            result = tmp;
+            break;
+        }
+    }
+
+    return result;
 };
 
 /**
- * 加载数据
+ * 修改工料机数据
  *
- * @return {void}
+ * @param {String} code
+ * @param {Object} data
+ * @return {boolean}
  */
-projectGLJ.prototype.loadData = function (datas) {
-    this.datas = datas;
+ProjectGLJ.prototype.updateData = function(code, data) {
+
 };