明树Git Lab

Commit 1da64ebe authored by zfp1's avatar zfp1

update

parent 529e06a0
let o = {
id: {
_mark: 'system',
fieldName: 'id',
_modelAttribute: true,
field: 'id'
},
projectName: {
comment: '项目名称',
_mark: 'xmjbxx',
fieldName: 'projectName',
_modelAttribute: true,
field: 'projectName'
},
projectShortName: {
comment: '项目简称',
_mark: 'xmjbxx',
fieldName: 'projectShortName',
_modelAttribute: true,
field: 'projectShortName'
},
returnModel: {
comment: '回报模式',
_mark: 'xmjbxx',
fieldName: 'returnModel',
_modelAttribute: true,
field: 'returnModel'
},
a1: {
comment: '决策及批复信息',
_mark: 'jcpfxx',
fieldName: 'a1',
_modelAttribute: true,
field: 'a1'
},
a2: {
comment: '项目公司落实批复信息',
_mark: 'xmgslspfxx',
fieldName: 'a2',
_modelAttribute: true,
field: 'a2'
},
a3: {
comment: '项目合法合规性附件',
_mark: 'xmfhhgxffj',
fieldName: 'a3',
_modelAttribute: true,
field: 'a3'
},
a4: {
comment: '全生命周期策划文件',
_mark: 'qshmkchw',
fieldName: 'a4',
_modelAttribute: true,
field: 'a4'
},
a5: {
comment: '项目绩效评价',
_mark: 'xmjxxpj',
fieldName: 'a5',
_modelAttribute: true,
field: 'a5'
},
a6: {
comment: '目标责任书考核',
_mark: 'mbzrskh',
fieldName: 'a6',
_modelAttribute: true,
field: 'a6'
},
a7: {
comment: '后评价',
_mark: 'hpj',
fieldName: 'a7',
_modelAttribute: true,
field: 'a7'
},
a8: {
comment: '重大事项上报',
_mark: 'zdsxsb',
fieldName: 'a8',
_modelAttribute: true,
field: 'a8'
},
a9: {
comment: '投资分析',
_mark: 'tzfx',
fieldName: 'a9',
_modelAttribute: true,
field: 'a9'
},
a10: {
comment: '投资检查',
_mark: 'tzjc',
fieldName: 'a10',
_modelAttribute: true,
field: 'a10'
},
invtRetcompletionRate: {
comment: '投资回收完成率',
_mark: 'tzhs',
fieldName: 'invtRetcompletionRate',
_modelAttribute: true,
field: 'invtRetcompletionRate'
},
a11: {
comment: '管理费上缴',
_mark: 'glfsj',
fieldName: 'a11',
_modelAttribute: true,
field: 'a11'
},
a12: {
comment: 'PPP整改方案',
_mark: 'pppzgfa',
fieldName: 'a12',
_modelAttribute: true,
field: 'a12'
},
a13: {
comment: '项目结束/暂停(备案资料)',
_mark: 'xmjs/zt',
fieldName: 'a13',
_modelAttribute: true,
field: 'a13'
}
}
let a = [{a: 1}, {a:2}];
const _ = require('lodash');
let b = _.groupBy(o, '_mark');
console.log(b);
\ No newline at end of file
a = a.map(o => {return {id: o.a}});
console.log(a);
\ No newline at end of file
......@@ -11,7 +11,7 @@
"host": "localhost",
"port": 3306,
"username": "root",
"password": "zhangqi1997.",
"password": "123456",
"database": "gzbjt",
"logging": true
},
......
......@@ -47,21 +47,208 @@ async function getProjectFields(req, res, next) {
async function createProject(req, res, next) {
try {
const body = req.body;
console.log(DB.Project.rawAttributes);
const ret = await DB.Project.create(body);
return res.sendData();
/*
1.处理特殊字段:
projectJsgms :关联建设规模表
projectGdxxs : 关联股东信息表
projectXmtzzes :关联项目投资额表
projectBjtjs :关联项目核心边界条件表
projectSpyjs :关联审批意见表
lxzl :关联projectFiles-File文件表
lxpfwj :关联projectFiles-File文件表
xgshcl :关联projectFiles-File文件表
*/
// 1. 先创建项目
let projectInfo = _.omit(body, ['projectJsgms', 'projectGdxxs', 'projectXmtzzes', 'projectBjtjs', 'projectSpyjs', 'lxzl', 'lxpfwj', 'xgshcl']);
let project = await DB.Project.create(projectInfo);
// 处理 projectJsgms
let projectJsgms = body.projectJsgms || [];
projectJsgms = projectJsgms.map(o => { o.projectId = project.id; return o });
await DB.ProjectJsgm.bulkCreate(projectJsgms);
// 处理 projectGdxxs
let projectGdxxs = body.projectGdxxs || [];
projectGdxxs = projectGdxxs.map(o => { o.projectId = project.id; return o });
await DB.ProjectGdxx.bulkCreate(projectGdxxs)
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
projectBjtjs = projectBjtjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectBjtj.bulkCreate(projectBjtjs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
projectXmtzzes = utils.disTree(projectXmtzzes);
projectXmtzzes = projectXmtzzes.map(o => { o.projectId = project.id; return o });
await DB.ProjectXmtzze.bulkCreate(projectXmtzzes);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
projectSpyjs = utils.disTree(projectSpyjs);
projectSpyjs = projectSpyjs.map(o => { o.projectId = project.id; return o });
await DB.ProjectSpyj.bulkCreate(projectSpyjs);
// 立项资料
let lxzl = body.lxzl || [];
lxzl = lxzl.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'lxzl' } });
// 立项批复文件
let lxpfwj = body.lxpfwj || [];
lxpfwj = lxpfwj.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'lxpfwj' } });
// 相关上会材料
let xgshcl = body.xgshcl || [];
xgshcl = xgshcl.map(o => { return { fileId: o.id, projectId: project.id, proFieldKey: 'xgshcl' } });
// 处理文件
let proFiles = _.concat(lxzl, lxpfwj, xgshcl);
await DB.ProjectFile.bulkCreate(proFiles);
return res.sendData(project);
} catch (error) {
next(error);
}
}
async function getProjectInfo(req, res, next) {
try {
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.ProjectJsgm,
as: 'projectJsgms',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectGdxx,
as: 'projectGdxxs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectXmtzze,
as: 'projectXmtzzes',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectBjtj,
as: 'projectBjtjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.ProjectSpyj,
as: 'projectSpyjs',
// where: { del: 0 },
// attributes: [],
},
{
model: DB.File,
as: 'files',
// where: { del: 0 },
// attributes: [],
through: { attributes: ['proFieldKey'] },
}
],
// raw: true
});
project = project.toJSON();
//处理 projectXmtzzes 树结构
let projectXmtzzes = project.projectXmtzzes || [];
project.projectXmtzzes = utils.buildTree(projectXmtzzes, 'kid');
//处理文件 还原成项目各个字段拥有的文件
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);
} catch (error) {
next(error);
}
}
async function updateProject(req, res, next) {
try {
let body = req.body;
if (!body.id) {
return res.sendError(errorMessage.resourceNotFound)
}
const ret = await DB.Project.update(body, { where: { id: body.id } });
/*
1.处理特殊字段:
projectJsgms :关联建设规模表
projectGdxxs : 关联股东信息表
projectXmtzzes :关联项目投资额表
projectBjtjs :关联项目核心边界条件表
projectSpyjs :关联审批意见表
lxzl :关联projectFiles-File文件表
lxpfwj :关联projectFiles-File文件表
xgshcl :关联projectFiles-File文件表
*/
// 1. 先创建项目
let project = body;
let projectInfo = _.omit(body, ['projectJsgms', 'projectGdxxs', 'projectXmtzzes', 'projectBjtjs', 'projectSpyjs', 'lxzl', 'lxpfwj', 'xgshcl']);
// 处理 projectJsgms
let projectJsgms = body.projectJsgms || [];
projectJsgms = projectJsgms.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectJsgm.destroy({ where: { projectId: project.id } });
await DB.ProjectJsgm.bulkCreate(projectJsgms);
// 处理 projectGdxxs
let projectGdxxs = body.projectGdxxs || [];
projectGdxxs = projectGdxxs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectGdxx.destroy({ where: { projectId: project.id } });
await DB.ProjectGdxx.bulkCreate(projectGdxxs)
// 处理 projectBjtjs
let projectBjtjs = body.projectBjtjs || [];
projectBjtjs = projectBjtjs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectBjtj.destroy({ where: { projectId: project.id } });
await DB.ProjectBjtj.bulkCreate(projectBjtjs);
// 处理 projectXmtzzes
let projectXmtzzes = body.projectXmtzzes || [];
projectXmtzzes = utils.disTree(projectXmtzzes);
projectXmtzzes = projectXmtzzes.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectXmtzze.destroy({ where: { projectId: project.id } });
await DB.ProjectXmtzze.bulkCreate(projectXmtzzes);
// 处理 projectSpyjs
let projectSpyjs = body.projectSpyjs || [];
projectSpyjs = utils.disTree(projectSpyjs);
projectSpyjs = projectSpyjs.map(o => { o.projectId = project.id; delete o.id; return o });
await DB.ProjectSpyj.destroy({ where: { projectId: project.id } });
await DB.ProjectSpyj.bulkCreate(projectSpyjs);
// 立项资料
let lxzl = body.lxzl || [];
let needIds = []; let createIds = [];
lxzl.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'lxzl'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'lxzl' } });
// 立项批复文件
let lxpfwj = body.lxpfwj || [];
lxpfwj.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'lxpfwj'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'lxpfwj' } });
// 相关上会材料
let xgshcl = body.xgshcl || [];
xgshcl.map(o => { if (!o.proFieldKey) { createIds.push({id: o.id, proFieldKey: 'xgshcl'}) } else { needIds.push(o.id) }; return { fileId: o.id, projectId: project.id, proFieldKey: 'xgshcl' } });
// 处理文件
//1. 删除
await DB.ProjectFile.destroy({
where: {
projectId: project.id,
fileId: { [Op.notIn]: needIds }
}
});
//2. 创建
if(createIds.length) {
let creProFiles = createIds.map(o=> {return {projectId: project.id, fileId: o.id, proFieldKey: o.proFieldKey}});
await DB.ProjectFile.bulkCreate(creProFiles);
}
const ret = await DB.Project.update(projectInfo, { where: { id: body.id } });
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -180,6 +367,7 @@ async function exportExcel(req, res, next) {
module.exports = {
getProjectFields,
createProject,
getProjectInfo,
listProject,
deleteProject,
updateProject,
......
......@@ -128,11 +128,11 @@ ResourcesInfo.belongsTo(Resources, { foreignKey: 'resourceId' });
Project.hasMany(ProjectBjtj, { foreignKey: 'projectId', as: 'projectBjtjs' });
ProjectBjtj.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-财务评价指标 1:n */
Project.hasMany(ProjectCwpjzb, { foreignKey: 'projectId', as: 'projectCwpjzbs' });
ProjectCwpjzb.belongsTo(Project, { foreignKey: 'projectId' });
// Project.hasMany(ProjectCwpjzb, { foreignKey: 'projectId', as: 'projectCwpjzbs' });
// ProjectCwpjzb.belongsTo(Project, { foreignKey: 'projectId' });
/**项目-项目附件 1:n */
Project.belongsToMany(File, { through: 'jt_project_file', foreignKey: 'projectId', as: 'files', otherKey: 'fileId' });
File.belongsTo(Project, { through: 'jt_project_file', foreignKey: 'fileId', otherKey: 'projectId' });
File.belongsToMany(Project, { through: 'jt_project_file', foreignKey: 'fileId', otherKey: 'projectId', as: 'pros' });
/**项目-股东信息 1:n */
Project.hasMany(ProjectGdxx, { foreignKey: 'projectId', as: 'projectGdxxs' });
ProjectGdxx.belongsTo(Project, { foreignKey: 'projectId' });
......
......@@ -84,24 +84,24 @@ const Project = sequelize.define('Project', {
//项目基本信息
projectName: { type: DataTypes.STRING, allowNull: true, comment: "项目名称" },
projectCode: { type: DataTypes.STRING, allowNull: true, comment: "项目编号" },
isZjc: { type: DataTypes.ENUM('1', '2'), allowNull: true, comment: "是否再决策" }, // 1是 2 否
sfzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否再决策" }, // 1是 2 否
projectForeignName: { type: DataTypes.STRING, allowNull: true, comment: "项目外文名称" },
sfnjlhtxm: { type: DataTypes.ENUM('1', '2'), allowNull: true, comment: "是否能建联合体项目" }, // 1是 2 否
sfnjlhtxm: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建联合体项目" }, // 1是 2 否
applicationUnit: { type: DataTypes.STRING, allowNull: true, comment: "申报单位" },
zyfzy: { type: DataTypes.STRING, allowNull: true, comment: "主业/非主业" }, //TODO:下拉
zsqy: { type: DataTypes.STRING, allowNull: true, comment: "直属企业" },
sfnjzdhzytz: { type: DataTypes.STRING, allowNull: true, comment: "是否能建重大或重要投资" },
sfzzjc: { type: DataTypes.STRING, allowNull: true, comment: "是否自主决策" },
sfnjzdhzytz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否能建重大或重要投资" },
sfzzjc: { type: DataTypes.INTEGER, allowNull: true, comment: "是否自主决策" },
financialStatementType: { type: DataTypes.STRING, allowNull: true, comment: "财务报表类型" }, //TODO:下拉
zfsphzbajb: { type: DataTypes.STRING, allowNull: true, comment: "政府审批(核准、备案)级别" }, //TODO:下拉
sflxbqyscx: { type: DataTypes.STRING, allowNull: true, comment: "是否履行标前预审程序" },
sflxbqyscx: { type: DataTypes.INTEGER, allowNull: true, comment: "是否履行标前预审程序" },
//项目所在地
domesticOrOverseas: { type: DataTypes.STRING, allowNull: true, comment: "境内/外" },//TODO:下拉
sjnzjjw: { type: DataTypes.STRING, allowNull: true, comment: "省(境内)/洲际(境外)" },//TODO:下拉
cityOrCountry: { type: DataTypes.STRING, allowNull: true, comment: "地市(境内)/国家(境外)" },//TODO:下拉
qxjngjjw: { type: DataTypes.STRING, allowNull: true, comment: "区县(境内)/国家(境外)" },//TODO:下拉
xmqy: { type: DataTypes.STRING, allowNull: true, comment: "项目区域" },//TODO:下拉
sfydylyxgj: { type: DataTypes.STRING, allowNull: true, comment: "是否一带一路沿线国家" },
sfydylyxgj: { type: DataTypes.INTEGER, allowNull: true, comment: "是否一带一路沿线国家" },
//计量币种
bizhong: { type: DataTypes.STRING, allowNull: true, comment: "币种" },//TODO:下拉
huilv: { type: DataTypes.DECIMAL(3, 2), allowNull: true, comment: "汇率" },
......@@ -124,9 +124,9 @@ const Project = sequelize.define('Project', {
tzznflgs: { type: DataTypes.STRING, allowNull: true, comment: "投资指南分类概述" },
gmjjhy: { type: DataTypes.STRING, allowNull: true, comment: "国民经济行业" },//TODO:下拉
// 特别关注、特别监管类等信息
sfxbgjfzggwhswbhz: { type: DataTypes.STRING, allowNull: true, comment: "是否需报国家发展改革委和商务部核准" },//TODO:下拉
sfgjldjq: { type: DataTypes.STRING, allowNull: true, comment: "是否国家领导见签" },//TODO:下拉
sfjntbjgl: { type: DataTypes.STRING, allowNull: true, comment: "是否境内特别监管类" },//TODO:下拉
sfxbgjfzggwhswbhz: { type: DataTypes.INTEGER, allowNull: true, comment: "是否需报国家发展改革委和商务部核准" },//TODO:下拉
sfgjldjq: { type: DataTypes.INTEGER, allowNull: true, comment: "是否国家领导见签" },//TODO:下拉
sfjntbjgl: { type: DataTypes.INTEGER, allowNull: true, comment: "是否境内特别监管类" },//TODO:下拉
//建设规模(实物量指标)
//股东信息
//项目必要性及可行性
......@@ -137,7 +137,6 @@ const Project = sequelize.define('Project', {
// 项目投资总额
// xmzbjwy: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "项目资本金(万元)" },
// pfztz: { type: DataTypes.DECIMAL(19, 8), allowNull: true, comment: "批复总投资" },
......@@ -1736,7 +1735,7 @@ const Project = sequelize.define('Project', {
// 同步模型到数据库(创建表)
Project.sync({
// force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
......@@ -34,8 +34,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
njfhlDw: {
type: DataTypes.STRING,
comment: "年均负荷率单位",
defaultValue: "%"
comment: "年均负荷率单位"
},
dwscfwzcbSz: {
type: DataTypes.DECIMAL(20, 4),
......@@ -43,8 +42,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
dwscfwzcbDw: {
type: DataTypes.STRING,
comment: "单位生产服务总成本单位",
defaultValue: "%"
comment: "单位生产服务总成本单位"
},
dwsjSz: {
type: DataTypes.DECIMAL(20, 4),
......@@ -64,8 +62,7 @@ const projectBjtj = sequelize.define('projectBjtj', {
},
ykphddw: {
type: DataTypes.STRING,
comment: "盈亏平衡点单位",
defaultValue: "%"
comment: "盈亏平衡点单位"
},
bcsm: {
type: DataTypes.STRING,
......@@ -87,13 +84,13 @@ const projectBjtj = sequelize.define('projectBjtj', {
comment: "0 正常 1 删除"
},
}, {
tableName: 'jt_project_gdxx', // 指定表名(如果与模型名不同)
tableName: 'jt_project_bjtj', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
projectBjtj.sync({
// force: false,
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// const { DataTypes } = require('sequelize');
// const sequelize = require('../index');
// 财务评价指标
const projectCwpjzb = sequelize.define('projectCwpjzb', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING,
comment: "指标名称"
},
num: {
type: DataTypes.DECIMAL(20, 4),
comment: "数量"
},
unit: {
type: DataTypes.STRING,
comment: "单位"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
}, {
tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// // 财务评价指标----废弃
// const projectCwpjzb = sequelize.define('projectCwpjzb', {
// id: {
// type: DataTypes.INTEGER,
// primaryKey: true,
// autoIncrement: true
// },
// name: {
// type: DataTypes.STRING,
// comment: "指标名称"
// },
// num: {
// type: DataTypes.DECIMAL(20, 4),
// comment: "数量"
// },
// unit: {
// type: DataTypes.STRING,
// comment: "单位"
// },
// projectId: {
// type: DataTypes.INTEGER,
// comment: "所属项目ID",
// },
// }, {
// tableName: 'jt_project_cwpjzb', // 指定表名(如果与模型名不同)
// timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
// });
// 同步模型到数据库(创建表)
projectCwpjzb.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectCwpjzb 表同步成功');
});
// // 同步模型到数据库(创建表)
// projectCwpjzb.sync({
// // force: false,
// // force: true ,//会删除已存在表并重新创建
// // alter: true
// })
// .then(() => {
// console.log('projectCwpjzb 表同步成功');
// });
module.exports = projectCwpjzb;
\ No newline at end of file
// module.exports = projectCwpjzb;
\ No newline at end of file
......@@ -4,7 +4,7 @@ const sequelize = require('../index');
const File = require('../system/file');
const Project = require('./project');
const projectFile = sequelize.define('projectFile', {
const ProjectFile = sequelize.define('ProjectFile', {
// 定义字段
id: {
type: DataTypes.INTEGER,
......@@ -19,7 +19,7 @@ const projectFile = sequelize.define('projectFile', {
type: DataTypes.INTEGER,
references: { model: Project, key: 'id' }
},
projectKey: {
proFieldKey: {
type: DataTypes.STRING, //项目表中文件字段key
}
}, {
......@@ -28,13 +28,14 @@ const projectFile = sequelize.define('projectFile', {
});
// 同步模型到数据库(创建表)
projectFile.sync({
// force: false, // force: true 会删除已存在表并重新创建
alter: true
ProjectFile.sync({
force: false, //
// force: true //会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectFile 表同步成功');
console.log('ProjectFile 表同步成功');
});
module.exports = projectFile;
\ No newline at end of file
module.exports = ProjectFile;
\ No newline at end of file
......@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 股东信息
const projectGdxx = sequelize.define('projectGdxx', {
const ProjectGdxx = sequelize.define('ProjectGdxx', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......@@ -56,14 +56,14 @@ const projectGdxx = sequelize.define('projectGdxx', {
});
// 同步模型到数据库(创建表)
projectGdxx.sync({
// force: false,
ProjectGdxx.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectGdxx 表同步成功');
console.log('ProjectGdxx 表同步成功');
});
module.exports = projectGdxx;
\ No newline at end of file
module.exports = ProjectGdxx;
\ No newline at end of file
......@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 建设规模
const projectJsgm = sequelize.define('projectJsgm', {
const ProjectJsgm = sequelize.define('ProjectJsgm', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......@@ -39,14 +39,14 @@ const projectJsgm = sequelize.define('projectJsgm', {
});
// 同步模型到数据库(创建表)
projectJsgm.sync({
// force: false,
ProjectJsgm.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectJsgm 表同步成功');
console.log('ProjectJsgm 表同步成功');
});
module.exports = projectJsgm;
\ No newline at end of file
module.exports = ProjectJsgm;
\ No newline at end of file
......@@ -2,7 +2,7 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 审批意见
const projectSpyj = sequelize.define('projectSpyj', {
const ProjectSpyj = sequelize.define('ProjectSpyj', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
......@@ -36,14 +36,14 @@ const projectSpyj = sequelize.define('projectSpyj', {
});
// 同步模型到数据库(创建表)
projectSpyj.sync({
// force: false,
ProjectSpyj.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectSpyj 表同步成功');
console.log('ProjectSpyj 表同步成功');
});
module.exports = projectSpyj;
\ No newline at end of file
module.exports = ProjectSpyj;
\ No newline at end of file
......@@ -2,12 +2,16 @@ const { DataTypes } = require('sequelize');
const sequelize = require('../index');
// 项目总投资总额(全口径)
const projectXmtzze = sequelize.define('projectXmtzze', {
const ProjectXmtzze = sequelize.define('ProjectXmtzze', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
kid: {
type: DataTypes.INTEGER,
comment: "表格行ID"
},
xh: {
type: DataTypes.STRING,
comment: "序号"
......@@ -27,8 +31,7 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
},
parentId: {
type: DataTypes.INTEGER,
comment: "上级ID",
defaultValue: 0
comment: "上级ID"
},
projectId: {
......@@ -47,14 +50,14 @@ const projectXmtzze = sequelize.define('projectXmtzze', {
});
// 同步模型到数据库(创建表)
projectXmtzze.sync({
// force: false,
ProjectXmtzze.sync({
force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.then(() => {
console.log('projectXmtzze 表同步成功');
console.log('ProjectXmtzze 表同步成功');
});
module.exports = projectXmtzze;
\ No newline at end of file
module.exports = ProjectXmtzze;
\ No newline at end of file
......@@ -13,7 +13,7 @@ module.exports = async (req, res, next) => {
}
req.headers.authorization = req.headers.authorization || req.headers.Authorization;
const userStr = await ioRedis.get(`token:${req.headers.authorization}`);
console.log(userStr)
// console.log("middleware request文件:", userStr)
if (userStr) {
try {
req.user = JSON.parse(userStr);
......
module.exports = {
}
\ No newline at end of file
......@@ -10,9 +10,9 @@ const projectController = require('../controller/projectController');
*/
router.post('/createProject', projectController.createProject);
router.post('/updateProject', projectController.updateProject);
// router.post('/deleteProject', projectController.deleteProject);
router.post('/deleteProject', projectController.deleteProject);
router.post('/listProject', projectController.listProject);
// router.post('/getProject', projectController.getProject);
router.post('/getProjectInfo', projectController.getProjectInfo);
router.post('/getProjectFields', projectController.getProjectFields);
router.post('/exportExcel', projectController.exportExcel);
......
......@@ -28,9 +28,9 @@ function checkUserPassword({ reqPw, salt, userPw }) {
}
}
function buildTree(nodes) {
function buildTree(nodes, keyid = 'id') {
// 创建一个映射,将节点ID映射到节点对象
const nodeMap = new Map(nodes.map(node => [String(node.id), { ...node, children: [] }]));
const nodeMap = new Map(nodes.map(node => [String(node[keyid]), { ...node, children: [] }]));
// 遍历所有节点,并将它们添加到对应父节点的children数组中
nodes.forEach(node => {
......@@ -39,7 +39,7 @@ function buildTree(nodes) {
// 确保父节点在映射中存在
if (nodeMap.has(parentId)) {
// 将当前节点添加到父节点的children数组中
nodeMap.get(parentId).children.push(nodeMap.get(String(node.id)));
nodeMap.get(parentId).children.push(nodeMap.get(String(node[keyid])));
nodeMap.get(parentId).children = _.orderBy(nodeMap.get(parentId).children, 'order')
}
}
......
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