明树Git Lab

Commit 5e2bee82 authored by zfp1's avatar zfp1

1

parent 44b716e0
Pipeline #106035 passed with stage
in 3 seconds
......@@ -15,30 +15,33 @@ async function createTzmbzrs(req, res, next) {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//创建投资目标责任书数据
let ret = await DB.TzTzmbzrs.create(req.body);
//处理文件参数
req.body.zrswj = (req.body.zrswj || []).map(o => { return o && o.id || o });
req.body.chwj = (req.body.chwj || []).map(o => { return o && o.id || o });
req.body.jyglzrs = (req.body.jyglzrs || []).map(o => { return o && o.id || o });
//处理 责任指标 表
let tzmbzrsZbs = (req.body.tzmbzrsZbs || []).map(o => { o.projectId = req.body.projectId; return o });
let tzmbzrsZbs = (req.body.tzmbzrsZbs || []).map(o => { o.projectId = req.body.projectId; o.sourceId = ret.id; return o });
delete req.body.tzmbzrsZbs;
//处理 批复意见
let tzmbzrsPfyjs =(req.body.tzmbzrsPfyjs || []).map(o => { o.projectId = req.body.projectId; return o });
let tzmbzrsPfyjs = (req.body.tzmbzrsPfyjs || []).map(o => { o.projectId = req.body.projectId; o.sourceId = ret.id; return o });
//处理 年度经营责任书
let tzmbzrsNds = (req.body.tzmbzrsPfyjs || []).map(o => {
o.projectId = req.body.projectId;
let tzmbzrsNds = (req.body.tzmbzrsPfyjs || []).map(o => {
o.projectId = req.body.projectId;
o.sourceId = ret.id;
// o.jyglzrs = o.jyglzrs || [];
// o.jyglzrs = o.jyglzrs.map(j => { return j && j.id || j});
return o
return o
});
console.log(ret.id, "=====================")
//
//创建指标表数据
await DB.TzTzmbzrsZb.bulkCreate(tzmbzrsZbs);
await DB.TzTzmbzrsPfyj.bulkCreate(tzmbzrsPfyjs);
await DB.TzTzmbzrsNd.bulkCreate(tzmbzrsNds);
//
//创建投资目标责任书数据
let ret = await DB.TzTzmbzrs.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
......@@ -50,6 +53,10 @@ async function updateTzmbzrs(req, res, next) {
if (!(req.body.id && req.body.projectId)) {
return res.sendError(errorMessage.paramsError);
}
let ret = await DB.TzTzmbzrs.findOne(req.body, { where: { id: req.body.id }, raw: true });
if (!(ret && ret.id)) {
return res.sendError(errorMessage.paramsError);
}
//处理文件参数
req.body.zrswj = (req.body.zrswj || []).map(o => { return o && o.id });
req.body.chwj = (req.body.chwj || []).map(o => { return o && o.id });
......@@ -63,25 +70,25 @@ async function updateTzmbzrs(req, res, next) {
delete req.body.tzmbzrsNds;
//1.更新责任指标表数据
let ids = [], infos = [], newtzmbzrsZbs = [];
tzmbzrsZbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsZbs.push(o); } } else { ids.push(o.id); infos.push(o); } return o });
tzmbzrsZbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; o.sourceId = ret.id; newtzmbzrsZbs.push(o); } } else { ids.push(o.id); infos.push(o); } return o });
await DB.TzTzmbzrsZb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsZb.bulkCreate(newtzmbzrsZbs);//创建新的 没有id的
await Promise.all(infos.map(item => { DB.TzTzmbzrsZb.update(item, { where: { id: item.id } }) }));
//1.更新批复意见
let ids1 = [], infos1 = [], newtzmbzrsPfyjs= [];
tzmbzrsPfyjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsPfyjs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
let ids1 = [], infos1 = [], newtzmbzrsPfyjs = [];
tzmbzrsPfyjs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; o.sourceId = ret.id; newtzmbzrsPfyjs.push(o); } } else { ids1.push(o.id); infos1.push(o); } return o });
await DB.TzTzmbzrsPfyj.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids1 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsPfyj.bulkCreate(newtzmbzrsPfyjs);//创建新的 没有id的
await Promise.all(infos1.map(item => { DB.TzTzmbzrsPfyj.update(item, { where: { id: item.id } }) }));
let ids2 = [], infos2 = [], newtzmbzrsNds= [];
tzmbzrsNds.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzmbzrsNds.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
let ids2 = [], infos2 = [], newtzmbzrsNds = [];
tzmbzrsNds.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; o.sourceId = ret.id; newtzmbzrsNds.push(o); } } else { ids2.push(o.id); infos2.push(o); } return o });
await DB.TzTzmbzrsNd.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids2 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzmbzrsNd.bulkCreate(newtzmbzrsNds);//创建新的 没有id的
await Promise.all(infos2.map(item => { DB.TzTzmbzrsNd.update(item, { where: { id: item.id } }) }));
//2.更新责任书
let ret = await DB.TzTzmbzrs.update(req.body, { where: { id: req.body.id } });
return res.sendData(ret);
await DB.TzTzmbzrs.update(req.body, { where: { id: req.body.id } });
return res.sendData();
} catch (error) {
next(error);
}
......@@ -127,9 +134,6 @@ async function getTzmbzrsInfo(req, res, next) {
if (req.body.id) {
sewhere.id = req.body.id;
}
if (req.body.projectId) {
sewhere.projectId = req.body.projectId;
}
if (_.isEmpty(sewhere)) {
return res.sendError(errorMessage.paramsError);
}
......@@ -138,15 +142,15 @@ async function getTzmbzrsInfo(req, res, next) {
return res.sendError(errorMessage.resourceNotFound);
}
let tzmbzrsZbs = await DB.TzTzmbzrsZb.findAll({
where: { projectId: zrs.projectId },
where: { projectId: zrs.projectId, sourceId: zrs.id },
raw: true,
});
let tzmbzrsPfyjs = await DB.TzTzmbzrsPfyj.findAll({
where: { projectId: zrs.projectId },
where: { projectId: zrs.projectId, sourceId: zrs.id },
raw: true,
});
let tzmbzrsNds = await DB.TzTzmbzrsNd.findAll({
where: { projectId: zrs.projectId },
where: { projectId: zrs.projectId, sourceId: zrs.id },
raw: true,
});
// console.log(tzmbzrsZbs, "============", zrs)
......@@ -169,6 +173,14 @@ async function getTzmbzrsInfo(req, res, next) {
next(error);
}
}
async function deleteTzmbzrsInfo(req, res, next) {
try {
await DB.TzTzmbzrs.update({ del: 1 }, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
}
}
async function createTzkz(req, res, next) {
try {
......@@ -200,10 +212,10 @@ async function createTzkz(req, res, next) {
}
}
//处理安全质量环保
let tzkzaqzlhbs = (req.body.tzkzaqzlhbs || []).map(o => { o.projectId = req.body.projectId; return o; });
let tzkzaqzlhbs = (req.body.tzkzaqzlhbs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.tzkzaqzlhbs;
//处理工期
let tzkzgqs = (req.body.tzkzgqs || []).map(o => { o.projectId = req.body.projectId; return o; });
let tzkzgqs = (req.body.tzkzgqs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.tzkzgqs;
//创建
......@@ -272,14 +284,14 @@ async function updateTzkz(req, res, next) {
delete req.body.tzkztzekzs;
//处理工期
let ids4 = [], infos4 = [], newtzkzgqs= [];
let ids4 = [], infos4 = [], newtzkzgqs = [];
req.body.tzkzgqs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzkzgqs.push(o); } } else { ids4.push(o.id); infos4.push(o); } return o });
await DB.TzTzkzGq.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids4 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzGq.bulkCreate(newtzkzgqs);//创建新的 没有id的
await Promise.all(infos4.map(item => { DB.TzTzkzGq.update(item, { where: { id: item.id } }) }));
delete req.body.tzkzgqs;
//处理环保
let ids5 = [], infos5= [], newtzkzaqzlhbs = [];
let ids5 = [], infos5 = [], newtzkzaqzlhbs = [];
req.body.tzkzaqzlhbs.map(o => { if (!o.id) { if (!_.isEmpty(o)) { o.projectId = req.body.projectId; newtzkzaqzlhbs.push(o); } } else { ids5.push(o.id); infos5.push(o); } return o });
await DB.TzTzkzAqzlhb.destroy({ where: { projectId: req.body.projectId, id: { [Op.notIn]: ids5 } } }); // 删除id不在传入id数组里面的(用户在界面删除的)
await DB.TzTzkzAqzlhb.bulkCreate(newtzkzaqzlhbs);//创建新的 没有id的
......@@ -885,8 +897,8 @@ async function updateZdsxsp(req, res, next) {
await DB.TzZdsxspfl.bulkCreate(newArr);//创建新的 没有id的
await Promise.all(info.map(item => { DB.TzZdsxspfl.update(item, { where: { id: item.id } }) }));
delete req.body.zdsxspfls;
await DB.TzZdsxsp.update(req.body, {where: {id: req.body.id}});
await DB.TzZdsxsp.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
......@@ -929,8 +941,8 @@ async function createXmtc(req, res, next) {
return res.sendError(errorMessage.paramsError);
}
// 1. 文件
req.body.tcwj = (req.body.tcwj || []).map(o => { return o && o.id || o});
let tccwzbs = (req.body.tccwzbs || []).map(o => {o.projectId = req.body.projectId; return o;});
req.body.tcwj = (req.body.tcwj || []).map(o => { return o && o.id || o });
let tccwzbs = (req.body.tccwzbs || []).map(o => { o.projectId = req.body.projectId; return o; });
delete req.body.tccwzbs;
await DB.TzXmtcCwzb.bulkCreate(tccwzbs);
let ret = await DB.TzXmtc.create(req.body);
......@@ -960,7 +972,7 @@ async function getXmtcInfo(req, res, next) {
where: { projectId: xmtc.projectId },
raw: true,
});
xmtc.tccwzbs = tccwzbs;
return res.sendData(xmtc);
} catch (error) {
......@@ -989,8 +1001,8 @@ async function updateXmtc(req, res, next) {
await DB.TzXmtcCwzb.bulkCreate(newArr);//创建新的 没有id的
await Promise.all(info.map(item => { DB.TzXmtcCwzb.update(item, { where: { id: item.id } }) }));
delete req.body.tccwzbs;
await DB.TzXmtc.update(req.body, {where: {id: req.body.id}});
await DB.TzXmtc.update(req.body, { where: { id: req.body.id } });
return res.sendData({});
} catch (error) {
next(error);
......@@ -1059,4 +1071,5 @@ module.exports = {
getXmtcInfo,
updateXmtc,
getXmtcList,
deleteTzmbzrsInfo,
}
\ No newline at end of file
......@@ -54,6 +54,12 @@ const TzTzmbzrs = sequelize.define('TzTzmbzrs', {
comment: "经营管理责任书",
defaultValue: [],
},
xmnrgs: {
type: DataTypes.TEXT,
},
xmjjzbgs: {
type: DataTypes.TEXT,
},
projectId: {
type: DataTypes.INTEGER,
......
......@@ -25,6 +25,10 @@ const TzTzmbzrsNd = sequelize.define('TzTzmbzrsNd', {
type: DataTypes.TEXT,
comment: "说明",
},
sourceId: {
type: DataTypes.INTEGER,
comment: "关联责任书主体,来源id"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
......
......@@ -40,6 +40,10 @@ const TzTzmbzrsPfyj = sequelize.define('TzTzmbzrsPfyj', {
khgz: {
type: DataTypes.TEXT,
comment: "考核规则",
},
sourceId: {
type: DataTypes.INTEGER,
comment: "关联责任书主体,来源id"
},
projectId: {
type: DataTypes.INTEGER,
......
......@@ -45,7 +45,12 @@ const TzTzmbzrsZb = sequelize.define('TzTzmbzrsZb', {
type: DataTypes.TEXT,
comment: "考核说明",
},
sourceId: {
type: DataTypes.INTEGER,
comment: "关联责任书主体,来源id"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
......
......@@ -58,6 +58,7 @@ router.post('/createTzmbzrs', projectTzController.createTzmbzrs);
router.post('/updateTzmbzrs', projectTzController.updateTzmbzrs);
router.post('/getTzmbzrsList', projectTzController.getTzmbzrsList);
router.post('/getTzmbzrsInfo', projectTzController.getTzmbzrsInfo);
router.post('/deleteTzmbzrsInfo', projectTzController.deleteTzmbzrsInfo);
//投资控制
......
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