소스 검색

bug fixed

zhangweicheng 7 년 전
부모
커밋
7d0032a354
1개의 변경된 파일8개의 추가작업 그리고 10개의 파일을 삭제
  1. 8 10
      modules/glj/models/unit_price_file_model.js

+ 8 - 10
modules/glj/models/unit_price_file_model.js

@@ -7,6 +7,7 @@
  */
 import BaseModel from "../../common/base/base_model";
 import CounterModel from "./counter_model";
+const ProjectModel = require('../../pm/models/project_model').project;
 import {default as UnitPriceFileSchema, collectionName as collectionName} from "./schemas/unit_price_file";
 
 class UnitPriceFileModel extends BaseModel {
@@ -71,19 +72,16 @@ class UnitPriceFileModel extends BaseModel {
             if (isNaN(projectId) || projectId <= 0) {
                 throw '标段id有误';
             }
-            result = await this.findDataByCondition({project_id: projectId});
-
-            // 如果没有找到则新增一条记录
-            if (!result) {
-                let data = {
-                    // @todo 后续再项目中获取
-                    name: 'projectName',
-                    project_id: projectId
-                };
-                result = await this.add(data);
+
+            let unitPriceFileId =await ProjectModel.getUnitPriceFileId(projectId);
+            if (unitPriceFileId <= 0) {
+                throw '没有对应的单价文件';
             }
+            result = await this.findDataByCondition({id: unitPriceFileId});
+
         } catch (error) {
             console.log('error:' + error);
+            throw '没有对应的单价文件 '
         }
 
         return result;