明树Git Lab

Commit b5546376 authored by zfp1's avatar zfp1

update

parent 55112b3b
...@@ -313,7 +313,7 @@ async function queryLixiangResult(req, res, next) { ...@@ -313,7 +313,7 @@ async function queryLixiangResult(req, res, next) {
let result = {success: true}; let result = {success: true};
//成功 //成功
if(result.success) { if(result.success) {
let proInfo = await projectModule.getProjectInfo(req.body); let proInfo = await projectModule.getProjectInfoByLixiang(req.body);
//1. 更新项目状态 //1. 更新项目状态
await DB.Project.update({projectLzType: 5}, {where: {id: req.body.id}}); await DB.Project.update({projectLzType: 5}, {where: {id: req.body.id}});
//2. 存储快照 关联关系太多 全部建立快照表工程过大,暂时存储形式 //2. 存储快照 关联关系太多 全部建立快照表工程过大,暂时存储形式
...@@ -459,15 +459,14 @@ async function xiangmujuecegengxin(body, projectLzType) { ...@@ -459,15 +459,14 @@ async function xiangmujuecegengxin(body, projectLzType) {
/** /**
* 决策保存 * 决策填报保存
*/ */
async function saveJuece(req, res, next) { async function saveJuece(req, res, next) {
try { try {
let body = req.body; if (!req.body.id) {
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound) return res.sendError(errorMessage.resourceNotFound)
} }
await xiangmujuecegengxin(body); let ret = await xiangmujuecegengxin(req.body, 7); //决策填报中
return res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -476,22 +475,43 @@ async function saveJuece(req, res, next) { ...@@ -476,22 +475,43 @@ async function saveJuece(req, res, next) {
async function startJuece(req, res, next) { async function startJuece(req, res, next) {
try { try {
let body = req.body; if (!req.body.id) {
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound) return res.sendError(errorMessage.resourceNotFound)
} }
await DB.FlowRecord.create({ await DB.FlowRecord.create({
userId: req.user.id, userId: req.user.id,
actionName: '发起项目决策审批', actionName: '发起项目决策审批',
projectId: project.id, projectId: req.body.id,
}); });
let ret = await xiangmujuecegengxin(body, 7); let ret = await xiangmujuecegengxin(req.body, 8); //决策审批中
return ret; return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
} }
} }
/**
* 主动查询决策审批结果
*/
async function queryJueceResult(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
//请求能建提供接口
let result = {success: true};
//成功
if(result.success) {
//1. 更新项目状态
await DB.Project.update({projectLzType: 9}, {where: {id: req.body.id}}); //已经决策成功
return res.sendData();
} else {
return res.sendError(errorMessage.resourceNotFound); //暂时
}
} catch (error) {
next(error);
}
}
/** /**
...@@ -761,7 +781,7 @@ async function getProjectInfo(req, res, next) { ...@@ -761,7 +781,7 @@ async function getProjectInfo(req, res, next) {
if(lixiang && lixiang.id) { if(lixiang && lixiang.id) {
obj.lixiang = lixiang.lixiang; //快照 obj.lixiang = lixiang.lixiang; //快照
//当项目状态 进入决策信息填报时候 //当项目状态 进入决策信息填报时候
if([].includes(ret && ret.projectLzType)) { if([7, 8, 9].includes(ret && ret.projectLzType)) {
obj.juece = ret; obj.juece = ret;
} }
} else { } else {
...@@ -968,4 +988,5 @@ module.exports = { ...@@ -968,4 +988,5 @@ module.exports = {
startJuece, startJuece,
saveProjectPreLixiang, saveProjectPreLixiang,
queryLixiangResult, queryLixiangResult,
queryJueceResult,
} }
\ No newline at end of file
...@@ -166,6 +166,73 @@ async function getProjectInfo({id}) { ...@@ -166,6 +166,73 @@ async function getProjectInfo({id}) {
} }
async function getProjectInfoByLixiang({id}) {
let project = await DB.Project.findOne({
where: { id: id },
// raw: true,
include: [
{
model: DB.ProjectBjtj,
as: 'projectBjtjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectCwpjzb,
as: 'projectCwpjzbs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectGdxx,
as: 'projectGdxxs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectJsgm,
as: 'projectJsgms',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectSpyj,
as: 'projectSpyjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectXmtzze,
as: 'projectXmtzzes',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.File,
as: 'files',
// where: { del: 0 },
// attributes: [],
through: { attributes: ['proFieldKey'] },
}
],
// raw: true
});
project = project.toJSON();
project.projectXmtzzes = utils.buildTree2(project.projectXmtzzes, 'xh', 'parentXh');
//处理文件 还原成项目各个字段拥有的文件
let files = project.files || [];
files = files.map(o => { o.proFieldKey = o.jt_project_file && o.jt_project_file.proFieldKey; delete o.jt_project_file; return o; });
let keyFiles = _.groupBy(files, 'proFieldKey');
delete project.files;
let ret = {
...project,
...keyFiles
}
return ret;
}
...@@ -187,4 +254,5 @@ async function getProjectInfo({id}) { ...@@ -187,4 +254,5 @@ async function getProjectInfo({id}) {
module.exports = { module.exports = {
handleProjectData, handleProjectData,
getProjectInfo, getProjectInfo,
getProjectInfoByLixiang,
} }
\ No newline at end of file
...@@ -22,12 +22,14 @@ router.post('/queryLixiangResult', projectController.queryLixiangResult); ...@@ -22,12 +22,14 @@ router.post('/queryLixiangResult', projectController.queryLixiangResult);
router.post('/saveJuece', projectController.saveJuece); //决策保存 router.post('/saveJuece', projectController.saveJuece); //决策保存
router.post('/startJuece', projectController.startJuece); router.post('/startJuece', projectController.startJuece);
router.post('/queryJueceResult', projectController.queryJueceResult);
router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/updateProject', projectController.updateProject); router.post('/updateProject', projectController.updateProject);
router.post('/deleteProject', projectController.deleteProject); router.post('/deleteProject', projectController.deleteProject);
router.post('/listProject', projectController.listProject); router.post('/listProject', projectController.listProject);
router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/exportExcel', projectController.exportExcel); router.post('/exportExcel', projectController.exportExcel);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment