Bläddra i källkod

修复编办保存bug

olym 7 år sedan
förälder
incheckning
5d1c91efbe
2 ändrade filer med 9 tillägg och 3 borttagningar
  1. 5 3
      modules/users/models/engineering_lib_model.js
  2. 4 0
      web/users/js/compilation.js

+ 5 - 3
modules/users/models/engineering_lib_model.js

@@ -69,12 +69,13 @@ class EngineeringLibModel extends BaseModel {
             let compilationModel = new CompilationModel();
             let engineeringLib = await compilationModel.getEngineeringLib(valuationId, data.section, data.engineering);
 
-            let result = false;
             if (engineeringLib === null) {
                 // 不存在则插入
                 result = await this.db.create(data);
             } else {
-                engineeringLib = engineeringLib.length > 0 ? engineeringLib[0] : {};
+                delete data.id;
+                delete data.section;
+                delete data.engineering;
                 // 存在则直接更新
                 let condition = {_id: engineeringLib.engineering_id};
                 result = await this.db.update(condition, data);
@@ -96,11 +97,12 @@ class EngineeringLibModel extends BaseModel {
                     throw '新增编办数据中的专业工程失败!';
                 }
             }
+
         } catch (error) {
             console.log(error);
             result = false;
         }
-
+        console.log(result ? 'pass' : 'fail');
         return result;
     }
 

+ 4 - 0
web/users/js/compilation.js

@@ -391,6 +391,10 @@ function validLib() {
             throw '请添加定额库';
         }
 
+        if ($("input:hidden[name='glj_lib']").length <= 0) {
+            throw '请添加工料机库';
+        }
+
         if ($("input:hidden[name='fee_lib']").length <= 0) {
             throw '请添加费率标准';
         }