明树Git Lab

Commit d7880b9d authored by zfp1's avatar zfp1

update

parent ac73ce5a
......@@ -282,11 +282,16 @@ async function saveProjectPreLixiang(req, res, next) {
*/
async function queryLixiangResult(req, res, next) {
try {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
//请求能建提供接口
let result = {success: true};
//成功
if(result.success) {
let proInfo = await projectModule.getProjectInfo(body);
//1. 更新项目状态
await DB.Project.update({projectLzType: 5}, {where: {id}});
}
} catch (error) {
next(error);
......@@ -745,96 +750,7 @@ async function getProjectInfo(req, res, next) {
if (!req.body.id) {
return res.sendError(errorMessage.resourceNotFound);
}
let project = await DB.Project.findOne({
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
}
let ret = await projectModule.getProjectInfo(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
......
......@@ -25,7 +25,7 @@ const Project = sequelize.define('Project', {
},
projectLzType: {
type: DataTypes.INTEGER,
comment: "项目流转状态: 1. 待立项(保存), 3. 立项审批中, 5. 已立项, 7. 决策审批中, 9. 已决策 ",
comment: "项目流转状态: 状态1 - 待立项 状态 3 -- 立项审批中 5 已立项 7 -- 决策审批中",
},
del: {
type: DataTypes.INTEGER,
......
......@@ -31,7 +31,7 @@ async function handleProjectData(ret, queryAttrs) {
const element = ret.rows[index];
console.log(element);
for (const key in element) {
if(!_.isEmpty(resources[key])) {
if (!_.isEmpty(resources[key])) {
element[key] = resources[key][element[key]]
}
......@@ -49,7 +49,7 @@ async function getResourceByKeys(keys) {
return {};
}
let ret = await DB.Resources.findAll({
where: { key: { [Op.in]: keys } ,del: 0},
where: { key: { [Op.in]: keys }, del: 0 },
include: [
{
model: DB.ResourcesInfo,
......@@ -71,6 +71,100 @@ async function getResourceByKeys(keys) {
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) {
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