|
@@ -11,10 +11,10 @@ import STDRationLibMapModel from "../../common/std/std_ration_lib_map_model";
|
|
|
import STDBillLibListsModel from "../../common/std/std_bills_lib_lists_model";
|
|
|
import STDGLJLibMapModel from "../../common/std/std_glj_lib_map_model";
|
|
|
import STDFeeRateLibsModel from "../../common/std/std_fee_rate_libs_model";
|
|
|
-import {default as EngineeringConst, List as EngineeringList} from "../../common/const/engineering";
|
|
|
+import { default as EngineeringConst, List as EngineeringList } from "../../common/const/engineering";
|
|
|
import BillsTemplateModel from "../models/bills_template_model";
|
|
|
-import {default as BillsFixedFlagConst, List as BillsFixedFlagList} from "../../common/const/bills_fixed.js";
|
|
|
-import {default as BillsTypeFlagConst, List as BillsTypeFlagList} from "../../common/const/bills_type.js";
|
|
|
+import { default as BillsFixedFlagConst, List as BillsFixedFlagList } from "../../common/const/bills_fixed.js";
|
|
|
+import { default as BillsTypeFlagConst, List as BillsTypeFlagList } from "../../common/const/bills_type.js";
|
|
|
import EngineeringLibModel from "../models/engineering_lib_model";
|
|
|
import STDLabourCoesModel from "../../common/std/std_labour_coes_model";
|
|
|
import STDCalcProgramModel from "../../common/std/std_calc_program_model";
|
|
@@ -26,11 +26,12 @@ import basicInfoFacade from "../../basic_info_lib/facade/basic_info_facade";
|
|
|
import progressiveFacade from "../../progressive_interval_lib/facade/progressive_facade";
|
|
|
import vvTaxFacade from "../../vehicleVessel_lib/facade/vvTax_facade";
|
|
|
import billCodeFacade from "../../bill_code_lib/facade/bill_code_facade";
|
|
|
-import {default as category, List as categoryList} from "../../common/const/category_const.js";
|
|
|
-import locationList from "../../common/const/locationList";
|
|
|
+import { default as category, List as categoryList } from "../../common/const/category_const.js";
|
|
|
+import locationList from "../../common/const/locationList";
|
|
|
|
|
|
let config = require("../../../config/config.js");
|
|
|
const fs = require('fs');
|
|
|
+let _ = require('lodash');
|
|
|
|
|
|
class CompilationController extends BaseController {
|
|
|
|
|
@@ -74,11 +75,11 @@ class CompilationController extends BaseController {
|
|
|
id: id,
|
|
|
compilationList: compilationList,
|
|
|
categoryList: categoryList,
|
|
|
- locationList:locationList,
|
|
|
+ locationList: locationList,
|
|
|
selectedCompilation: selectedCompilation,
|
|
|
- title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
|
|
|
+ title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
|
|
|
layout: 'users/views/layout/layout',
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
|
|
|
};
|
|
|
|
|
|
response.render('users/views/compilation/index', renderData);
|
|
@@ -156,6 +157,7 @@ class CompilationController extends BaseController {
|
|
|
// 获取计价规则中对应的标准库数据
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
engineeringList = await engineeringLibModel.getLibsByValuationID(valuationId);
|
|
|
+ engineeringList = _.sortBy(engineeringList, ['seq'])
|
|
|
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
@@ -170,8 +172,8 @@ class CompilationController extends BaseController {
|
|
|
valuationId: valuationId,
|
|
|
section: section,
|
|
|
layout: 'users/views/layout/layout',
|
|
|
- title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
|
|
|
+ title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
|
|
|
};
|
|
|
response.render('users/views/compilation/add', renderData);
|
|
|
}
|
|
@@ -233,9 +235,9 @@ class CompilationController extends BaseController {
|
|
|
calculationList = await stdCalcProgramModel.getProgramList(selectedCompilation._id);
|
|
|
|
|
|
//获取列设置库
|
|
|
- mainTreeColList = await mainColFacade.getColLibsByCompilationID(selectedCompilation._id);
|
|
|
+ mainTreeColList = await mainColFacade.getColLibsByCompilationID(selectedCompilation._id);
|
|
|
|
|
|
- //获取清单模板库
|
|
|
+ //获取清单模板库
|
|
|
billTemplateList = await billTemplateFacade.getTemplateLibByCompilationID(selectedCompilation._id);
|
|
|
|
|
|
// 获取对应的计价规则数据
|
|
@@ -246,29 +248,29 @@ class CompilationController extends BaseController {
|
|
|
|
|
|
// 获取对应专业工程下的标准库数据
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
- libData = await engineeringLibModel.findDataByCondition({_id:engineerID});
|
|
|
+ libData = await engineeringLibModel.findDataByCondition({ _id: engineerID });
|
|
|
|
|
|
// 获取清单模板数据
|
|
|
let billsTemplateModel = new BillsTemplateModel();
|
|
|
billsTemplateData = await billsTemplateModel.getTemplateData(valuationId, libData.engineering);
|
|
|
|
|
|
//获取清单指引数据
|
|
|
- billsGuidanceList = await billsGuidanceFc.getBillsGuideLibs({compilationId: selectedCompilation._id, $or: [{deleted: null}, {deleted: false}]});
|
|
|
+ billsGuidanceList = await billsGuidanceFc.getBillsGuideLibs({ compilationId: selectedCompilation._id, $or: [{ deleted: null }, { deleted: false }] });
|
|
|
|
|
|
//获取工程特征库
|
|
|
- featureList = await projectFeatureFacade.findByCondition({compilationId: selectedCompilation._id},null,false);
|
|
|
+ featureList = await projectFeatureFacade.findByCondition({ compilationId: selectedCompilation._id }, null, false);
|
|
|
|
|
|
//获取基本信息库
|
|
|
- infoList = await basicInfoFacade.findByCondition({},null,false);
|
|
|
+ infoList = await basicInfoFacade.findByCondition({}, null, false);
|
|
|
|
|
|
//获取累进区间库
|
|
|
- progressiveList = await progressiveFacade.findByCondition({},null,false);
|
|
|
+ progressiveList = await progressiveFacade.findByCondition({}, null, false);
|
|
|
|
|
|
//获取车船税库
|
|
|
vvTaxList = await vvTaxFacade.findByCondition({}, false, false);
|
|
|
|
|
|
- //获取递延清单库
|
|
|
- billCodeList = await billCodeFacade.findByCondition({}, false, false);
|
|
|
+ //获取递延清单库
|
|
|
+ billCodeList = await billCodeFacade.findByCondition({}, false, false);
|
|
|
|
|
|
} catch (error) {
|
|
|
console.log(error);
|
|
@@ -289,19 +291,19 @@ class CompilationController extends BaseController {
|
|
|
artificialCoefficientList: JSON.stringify(artificialCoefficientList),
|
|
|
feeRateList: JSON.stringify(feeRateList),
|
|
|
billsTemplateData: JSON.stringify(billsTemplateData),
|
|
|
- billTemplateList:JSON.stringify(billTemplateList),
|
|
|
+ billTemplateList: JSON.stringify(billTemplateList),
|
|
|
mainTreeColList: JSON.stringify(mainTreeColList),
|
|
|
- gljCol:JSON.stringify(libData.glj_col),
|
|
|
+ gljCol: JSON.stringify(libData.glj_col),
|
|
|
calculationList: JSON.stringify(calculationList),
|
|
|
billsGuidanceList: JSON.stringify(billsGuidanceList),
|
|
|
- featureList:JSON.stringify(featureList),
|
|
|
+ featureList: JSON.stringify(featureList),
|
|
|
infoList: JSON.stringify(infoList),
|
|
|
- progressiveList:JSON.stringify(progressiveList),
|
|
|
+ progressiveList: JSON.stringify(progressiveList),
|
|
|
vvTaxList: JSON.stringify(vvTaxList),
|
|
|
billCodeList: JSON.stringify(billCodeList),
|
|
|
- title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
|
|
|
+ title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
|
|
|
layout: 'users/views/layout/layout',
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
|
|
|
};
|
|
|
response.render('users/views/compilation/engineering', renderData);
|
|
|
}
|
|
@@ -342,22 +344,22 @@ class CompilationController extends BaseController {
|
|
|
* @param response
|
|
|
* @returns {Promise.<void>}
|
|
|
*/
|
|
|
- async deleteEngineer(request,response){
|
|
|
- let result={
|
|
|
- error:0
|
|
|
+ async deleteEngineer(request, response) {
|
|
|
+ let result = {
|
|
|
+ error: 0
|
|
|
};
|
|
|
try {
|
|
|
let data = request.body.data;
|
|
|
data = JSON.parse(data);
|
|
|
- if(data.id ){
|
|
|
+ if (data.id) {
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
- result.data = await engineeringLibModel.deleteById(data.id,true);
|
|
|
- }else {
|
|
|
+ result.data = await engineeringLibModel.deleteById(data.id, true);
|
|
|
+ } else {
|
|
|
throw new Error("提交数据有误");
|
|
|
}
|
|
|
- }catch (err){
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
|
}
|
|
|
response.json(result);
|
|
@@ -369,23 +371,23 @@ class CompilationController extends BaseController {
|
|
|
* @param response
|
|
|
* @returns {Promise.<void>}
|
|
|
*/
|
|
|
- async updateEngineer(request,response){
|
|
|
- let result={
|
|
|
- error:0
|
|
|
+ async updateEngineer(request, response) {
|
|
|
+ let result = {
|
|
|
+ error: 0
|
|
|
};
|
|
|
try {
|
|
|
let data = request.body.data;
|
|
|
data = JSON.parse(data);
|
|
|
- if(data.id && data.updateData){
|
|
|
+ if (data.id && data.updateData) {
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
- result.data = await engineeringLibModel.updateById(data.id,data.updateData);
|
|
|
- }else {
|
|
|
+ result.data = await engineeringLibModel.updateById(data.id, data.updateData);
|
|
|
+ } else {
|
|
|
throw new Error("提交数据有误");
|
|
|
}
|
|
|
|
|
|
- }catch (err){
|
|
|
+ } catch (err) {
|
|
|
console.log(err);
|
|
|
- result.error=1;
|
|
|
+ result.error = 1;
|
|
|
result.message = err.message;
|
|
|
}
|
|
|
response.json(result);
|
|
@@ -493,7 +495,7 @@ class CompilationController extends BaseController {
|
|
|
* @param {object} response
|
|
|
* @return {void}
|
|
|
*/
|
|
|
- async setFileTypes(request, response) {
|
|
|
+ async setFileTypes(request, response) {
|
|
|
let id = request.body.id;
|
|
|
let section = request.params.section;
|
|
|
let fileTypes = request.body.fileTypes;
|
|
@@ -586,22 +588,22 @@ class CompilationController extends BaseController {
|
|
|
response.json(responseData);
|
|
|
}
|
|
|
|
|
|
- async setDescription(request, response){
|
|
|
+ async setDescription(request, response) {
|
|
|
let compilationId = request.body.id;
|
|
|
let description = request.body.description;
|
|
|
- try{
|
|
|
+ try {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
await compilationModel.setDescription(compilationId, description);
|
|
|
- response.json({err: 0, msg: '', data: null});
|
|
|
+ response.json({ err: 0, msg: '', data: null });
|
|
|
}
|
|
|
- catch (err){
|
|
|
- response.json({err: 1, msg: err, data: null});
|
|
|
+ catch (err) {
|
|
|
+ response.json({ err: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
- async setOverWriteUrl(request, response){
|
|
|
+ async setOverWriteUrl(request, response) {
|
|
|
let compilationId = request.body.id;
|
|
|
let overWriteUrl = request.body.overWriteUrl;
|
|
|
- try{
|
|
|
+ try {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
//绝对路径
|
|
|
let absoluteUrl = request.app.locals.rootDir + overWriteUrl;
|
|
@@ -609,33 +611,33 @@ class CompilationController extends BaseController {
|
|
|
let fileExists = fs.existsSync(absoluteUrl);
|
|
|
let pricePropertiesTemplate = [],
|
|
|
consumeAmtPropertiesTemplate = [];
|
|
|
- if(fileExists && fs.statSync(absoluteUrl).isFile()){
|
|
|
+ if (fileExists && fs.statSync(absoluteUrl).isFile()) {
|
|
|
//读取配置文件并赋值
|
|
|
let overWriteExports = require(absoluteUrl);
|
|
|
- if(overWriteExports){
|
|
|
+ if (overWriteExports) {
|
|
|
pricePropertiesTemplate = overWriteExports.pricePropertiesTemplate ? overWriteExports.pricePropertiesTemplate : [];
|
|
|
consumeAmtPropertiesTemplate = overWriteExports.consumeAmtPropertiesTemplate ? overWriteExports.consumeAmtPropertiesTemplate : [];
|
|
|
}
|
|
|
}
|
|
|
await compilationModel.setOverWriteUrl(compilationId, overWriteUrl, pricePropertiesTemplate, consumeAmtPropertiesTemplate);
|
|
|
- response.json({err: 0, msg: '', data: null});
|
|
|
+ response.json({ err: 0, msg: '', data: null });
|
|
|
}
|
|
|
- catch (err){
|
|
|
+ catch (err) {
|
|
|
console.log(err);
|
|
|
- response.json({err: 1, msg: err, data: null});
|
|
|
+ response.json({ err: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
- async setExample(request, response){
|
|
|
+ async setExample(request, response) {
|
|
|
let compilationId = request.body.id,
|
|
|
example = request.body.example;
|
|
|
try {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
await compilationModel.setExample(compilationId, example);
|
|
|
- response.json({err: 0, msg: 'success', data: null});
|
|
|
+ response.json({ err: 0, msg: 'success', data: null });
|
|
|
}
|
|
|
- catch (err){
|
|
|
+ catch (err) {
|
|
|
console.log(err);
|
|
|
- response.json({err: 1, msg: err, data: null});
|
|
|
+ response.json({ err: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -687,9 +689,9 @@ class CompilationController extends BaseController {
|
|
|
compilationList: compilationList,
|
|
|
valuationId: valuationId,
|
|
|
section: section,
|
|
|
- title : config[process.env.NODE_ENV].title?config[process.env.NODE_ENV].title:'养护云版',
|
|
|
+ title: config[process.env.NODE_ENV].title ? config[process.env.NODE_ENV].title : '养护云版',
|
|
|
layout: 'users/views/layout/layout',
|
|
|
- LicenseKey:config.getLicenseKey(process.env.NODE_ENV)
|
|
|
+ LicenseKey: config.getLicenseKey(process.env.NODE_ENV)
|
|
|
};
|
|
|
response.render('users/views/compilation/template', renderData);
|
|
|
}
|
|
@@ -710,9 +712,9 @@ class CompilationController extends BaseController {
|
|
|
let result = await billsTemplateModel.updateTemplate(valuationId, engineering, data);
|
|
|
|
|
|
if (result) {
|
|
|
- response.json({error: 0, message: '', data: data});
|
|
|
+ response.json({ error: 0, message: '', data: data });
|
|
|
} else {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -728,11 +730,11 @@ class CompilationController extends BaseController {
|
|
|
|
|
|
}
|
|
|
|
|
|
- async addEngineer(request,response){
|
|
|
+ async addEngineer(request, response) {
|
|
|
let engineeringLibModel = new EngineeringLibModel();
|
|
|
try {
|
|
|
await engineeringLibModel.addEngineer(request.body);
|
|
|
- }catch (error) {
|
|
|
+ } catch (error) {
|
|
|
console.log(error);
|
|
|
}
|
|
|
response.redirect(request.headers.referer);
|
|
@@ -753,21 +755,21 @@ class CompilationController extends BaseController {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
let result = await compilationModel.updateCategory(valuationId, category);
|
|
|
if (result) {
|
|
|
- response.json({error: 0, message: '', data: null});
|
|
|
+ response.json({ error: 0, message: '', data: null });
|
|
|
} else {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
- } catch(error) {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ } catch (error) {
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
}
|
|
|
- /**
|
|
|
- * 更改编办默认工程所在工
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return {Promise.<void>}
|
|
|
- */
|
|
|
+ /**
|
|
|
+ * 更改编办默认工程所在工
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return {Promise.<void>}
|
|
|
+ */
|
|
|
async changeLocation(request, response) {
|
|
|
let compilationId = request.body.id;
|
|
|
let location = request.body.location;
|
|
@@ -775,49 +777,49 @@ class CompilationController extends BaseController {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
let result = await compilationModel.updateLocation(compilationId, location);
|
|
|
if (result) {
|
|
|
- response.json({error: 0, message: '', data: null});
|
|
|
+ response.json({ error: 0, message: '', data: null });
|
|
|
} else {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
- } catch(error) {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ } catch (error) {
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
- /**
|
|
|
- * 更改编办默认工程所在工
|
|
|
- *
|
|
|
- * @param request
|
|
|
- * @param response
|
|
|
- * @return {Promise.<void>}
|
|
|
- */
|
|
|
- async changeFreeUse(request, response) {
|
|
|
+ /**
|
|
|
+ * 更改编办默认工程所在工
|
|
|
+ *
|
|
|
+ * @param request
|
|
|
+ * @param response
|
|
|
+ * @return {Promise.<void>}
|
|
|
+ */
|
|
|
+ async changeFreeUse(request, response) {
|
|
|
let compilationId = request.body.id;
|
|
|
let freeUse = request.body.freeUse;
|
|
|
try {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
let result = await compilationModel.updateFreeUse(compilationId, freeUse);
|
|
|
if (result) {
|
|
|
- response.json({error: 0, message: '', data: null});
|
|
|
+ response.json({ error: 0, message: '', data: null });
|
|
|
} else {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
- } catch(error) {
|
|
|
- response.json({error: 1, message: '更新数据错误', data: null});
|
|
|
+ } catch (error) {
|
|
|
+ response.json({ error: 1, message: '更新数据错误', data: null });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- async setEdition(request, response){
|
|
|
+ async setEdition(request, response) {
|
|
|
let compilationId = request.body.id;
|
|
|
let edition = request.body.edition;
|
|
|
- try{
|
|
|
+ try {
|
|
|
let compilationModel = new CompilationModel();
|
|
|
await compilationModel.setEdition(compilationId, edition);
|
|
|
- response.json({err: 0, msg: '', data: null});
|
|
|
+ response.json({ err: 0, msg: '', data: null });
|
|
|
}
|
|
|
- catch (err){
|
|
|
- response.json({err: 1, msg: err, data: null});
|
|
|
+ catch (err) {
|
|
|
+ response.json({ err: 1, msg: err, data: null });
|
|
|
}
|
|
|
}
|
|
|
async setSerialNumber(request, response) {
|