明树Git Lab

Commit d7880b9d authored by zfp1's avatar zfp1

update

parent ac73ce5a
...@@ -282,11 +282,16 @@ async function saveProjectPreLixiang(req, res, next) { ...@@ -282,11 +282,16 @@ async function saveProjectPreLixiang(req, res, next) {
*/ */
async function queryLixiangResult(req, res, next) { async function queryLixiangResult(req, res, next) {
try { try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
//请求能建提供接口 //请求能建提供接口
let result = {success: true}; let result = {success: true};
//成功 //成功
if(result.success) { if(result.success) {
let proInfo = await projectModule.getProjectInfo(body);
//1. 更新项目状态
await DB.Project.update({projectLzType: 5}, {where: {id}});
} }
} catch (error) { } catch (error) {
next(error); next(error);
...@@ -745,96 +750,7 @@ async function getProjectInfo(req, res, next) { ...@@ -745,96 +750,7 @@ async function getProjectInfo(req, res, next) {
if (!req.body.id) { if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound); return res.sendError(errorMessage.resourceNotFound);
} }
let project = await DB.Project.findOne({ let ret = await projectModule.getProjectInfo(req.body);
where: { id: req.body.id },
// raw: true,
include: [
{
model: DB.ProjectBjtj,
as: 'projectBjtjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectCwpjzb,
as: 'projectCwpjzbs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectFxgl,
as: 'projectFxgls',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectGdxx,
as: 'projectGdxxs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectJczt,
as: 'projectJczts',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectJsgm,
as: 'projectJsgms',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectLcbjd,
as: 'projectLcbjds',
},
{
model: DB.ProjectSpyj,
as: 'projectSpyjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectTzzjll,
as: 'projectTzzjlls',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectTzzt,
as: 'projectTzzts',
// 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 res.sendData(ret); return res.sendData(ret);
} catch (error) { } catch (error) {
next(error); next(error);
......
...@@ -25,7 +25,7 @@ const Project = sequelize.define('Project', { ...@@ -25,7 +25,7 @@ const Project = sequelize.define('Project', {
}, },
projectLzType: { projectLzType: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
comment: "项目流转状态: 1. 待立项(保存), 3. 立项审批中, 5. 已立项, 7. 决策审批中, 9. 已决策 ", comment: "项目流转状态: 状态1 - 待立项 状态 3 -- 立项审批中 5 已立项 7 -- 决策审批中",
}, },
del: { del: {
type: DataTypes.INTEGER, type: DataTypes.INTEGER,
......
...@@ -31,10 +31,10 @@ async function handleProjectData(ret, queryAttrs) { ...@@ -31,10 +31,10 @@ async function handleProjectData(ret, queryAttrs) {
const element = ret.rows[index]; const element = ret.rows[index];
console.log(element); console.log(element);
for (const key in element) { for (const key in element) {
if(!_.isEmpty(resources[key])) { if (!_.isEmpty(resources[key])) {
element[key] = resources[key][element[key]] element[key] = resources[key][element[key]]
} }
} }
newRet.push(element); newRet.push(element);
} }
...@@ -49,7 +49,7 @@ async function getResourceByKeys(keys) { ...@@ -49,7 +49,7 @@ async function getResourceByKeys(keys) {
return {}; return {};
} }
let ret = await DB.Resources.findAll({ let ret = await DB.Resources.findAll({
where: { key: { [Op.in]: keys } ,del: 0}, where: { key: { [Op.in]: keys }, del: 0 },
include: [ include: [
{ {
model: DB.ResourcesInfo, model: DB.ResourcesInfo,
...@@ -71,6 +71,100 @@ async function getResourceByKeys(keys) { ...@@ -71,6 +71,100 @@ async function getResourceByKeys(keys) {
return obj; return obj;
} }
async function getProjectInfo({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.ProjectFxgl,
as: 'projectFxgls',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectGdxx,
as: 'projectGdxxs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectJczt,
as: 'projectJczts',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectJsgm,
as: 'projectJsgms',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectLcbjd,
as: 'projectLcbjds',
},
{
model: DB.ProjectSpyj,
as: 'projectSpyjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectTzzjll,
as: 'projectTzzjlls',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectTzzt,
as: 'projectTzzts',
// 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;
}
...@@ -91,5 +185,6 @@ async function getResourceByKeys(keys) { ...@@ -91,5 +185,6 @@ async function getResourceByKeys(keys) {
module.exports = { module.exports = {
handleProjectData handleProjectData,
getProjectInfo,
} }
\ No newline at end of file
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