|
@@ -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;
|