明树Git Lab

Commit 742f9ba0 authored by zfp1's avatar zfp1

update

parent aefdc8f2
Pipeline #105224 passed with stage
in 4 seconds
...@@ -744,6 +744,105 @@ async function getJsqtzjcList (req, res, next) { ...@@ -744,6 +744,105 @@ async function getJsqtzjcList (req, res, next) {
next(error); next(error);
} }
} }
async function createZdsxsp(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
//日常自查 投资(成本)分析会
let zdsxspfls = req.body.zdsxspfls || [];
let newArr = [];
for (let index = 0; index < zdsxspfls.length; index++) {
const element = zdsxspfls[index];
element.projectId = projectId;
element.wj = (element.wj || []).map(o => {return o && o.id || o});
newArr.push(element);
}
delete req.body.zdsxspfls;
await DB.TzZdsxspfl.bulkCreate(newArr);
let ret = await DB.TzZdsxsp.create(req.body);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
async function getZdsxspInfo (req, res, next) {
try {
let search = {};
if (req.body.id) {
search.id = req.body.id;
}
if (req.body.projectId) {
search.projectId = req.body.projectId;
}
if (_.isEmpty(search)) {
return res.sendError(errorMessage.paramsError);
}
let zdsxsp = await DB.TzZdsxsp.findOne({where: search, raw: true});
if(!(zdsxsp && zdsxsp.id && zdsxsp.projectId)) {
return res.sendError(errorMessage.resourceNotFound);
}
let zdsxspfls = await DB.TzZdsxspfl.findAll({
where: {projectId: req.body.projectId},
raw: true,
});
let newArr = [];
for (let index = 0; index < zdsxspfls.length; index++) {
const element = zdsxspfls[index];
if(element.wj && element.wj.length > 0) {
element.wj = await DB.File.findAll({where: {id: {[Op.in]: element.wj}}, raw: true});
}
newArr.push(element);
}
zdsxsp.zdsxspfls = zdsxspfls;
return res.sendData(zdsxsp);
} catch (error) {
next(error);
}
}
async function updateZdsxsp(req, res, next) {
try {
if (!req.body.projectId) {
return res.sendError(errorMessage.paramsError);
}
return res.sendData({});
} catch (error) {
next(error);
}
}
async function getZdsxspList (req, res, next) {
try {
let page = req.body.page || 1;
let limit = req.body.pagesize || req.body.pageSize || 10;
let offset = (page - 1) * limit;
let search = {};
search.order = [['createdAt', 'DESC']];
search.limit = limit;
search.offset = offset;
let where = { del: 0 };
// if (req.body.projectName) {
// where = {
// [Op.or]: [
// { projectName: { [Op.like]: `%${req.body.projectName}%` } },
// ],
// del: 0
// }
// }
search.where = where;
if (req.body.attributes && req.body.attributes.length) {
search.attributes = req.body.attributes;
}
let ret = await DB.TzJsqtzjc.findAndCountAll(search);
return res.sendData(ret);
} catch (error) {
next(error);
}
}
...@@ -768,4 +867,8 @@ module.exports = { ...@@ -768,4 +867,8 @@ module.exports = {
updateJsqtzjc, updateJsqtzjc,
getJsqtzjcList, getJsqtzjcList,
getJsqtzjcInfo, getJsqtzjcInfo,
createZdsxsp,
getZdsxspInfo,
updateZdsxsp,
getZdsxspList,
} }
\ No newline at end of file
...@@ -56,6 +56,12 @@ const TzJsqtzjc = require("./model/jt/tzJsqtzjc"); ...@@ -56,6 +56,12 @@ const TzJsqtzjc = require("./model/jt/tzJsqtzjc");
const TzJsqtzjcTzfx = require("./model/jt/tzJsqtzjcTzfx"); const TzJsqtzjcTzfx = require("./model/jt/tzJsqtzjcTzfx");
const TzJsqtzjcrcjc = require("./model/jt/tzJsqtzjcrcjc"); const TzJsqtzjcrcjc = require("./model/jt/tzJsqtzjcrcjc");
const TzJsqtzjcZxjc = require("./model/jt/tzJsqtzjcZxjc"); const TzJsqtzjcZxjc = require("./model/jt/tzJsqtzjcZxjc");
const TzZdsxsp = require("./model/jt/tzZdsxsp");
const TzZdsxspfl = require("./model/jt/tzZdsxspfl");
/** /**
* 业务表 * 业务表
*/ */
...@@ -112,6 +118,8 @@ global.DB = { ...@@ -112,6 +118,8 @@ global.DB = {
TzJsqtzjcTzfx, TzJsqtzjcTzfx,
TzJsqtzjcrcjc, TzJsqtzjcrcjc,
TzJsqtzjcZxjc, TzJsqtzjcZxjc,
TzZdsxsp,
TzZdsxspfl,
} }
......
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 重大事项审批
const TzZdsxsp = sequelize.define('TzZdsxsp', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
/* -------------------------------------------------------- */
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_zdsxsp', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdsxsp.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdsxsp 表同步成功');
});
module.exports = TzZdsxsp;
\ No newline at end of file
const { DataTypes } = require('sequelize');
const sequelize = require('../index');
const moment = require('moment');
//投中管理- 重大事项审批分类
const TzZdsxspfl = sequelize.define('TzZdsxspfl', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
lx: {
type: DataTypes.JSON,
comment: "类型---级联选择"
},
sm: {
type: DataTypes.TEXT,
comment: "说明"
},
wj: {
type: DataTypes.JSON,
comment: "文件"
},
projectId: {
type: DataTypes.INTEGER,
comment: "所属项目ID",
},
del: {
type: DataTypes.INTEGER,
defaultValue: 0,
comment: "0 正常 1 删除"
},
createdAt: {
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('createdAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
},
updatedAt: { // 同样处理 updatedAt
type: DataTypes.DATE,
defaultValue: new Date(),
get() {
const rawValue = this.getDataValue('updatedAt');
return rawValue ? moment(rawValue).format('YYYY-MM-DD HH:mm:ss') : '';
}
}
}, {
tableName: 'jt_tz_zdsxspfl', // 指定表名(如果与模型名不同)
timestamps: true, // 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
TzZdsxspfl.sync({
// force: false,
// force: true ,//会删除已存在表并重新创建
alter: true
})
.then(() => {
console.log('TzZdsxspfl 表同步成功');
});
module.exports = TzZdsxspfl;
\ No newline at end of file
...@@ -78,6 +78,11 @@ router.post('/createJsqtzjc', projectTzController.createJsqtzjc); ...@@ -78,6 +78,11 @@ router.post('/createJsqtzjc', projectTzController.createJsqtzjc);
router.post('/updateJsqtzjc', projectTzController.updateJsqtzjc); router.post('/updateJsqtzjc', projectTzController.updateJsqtzjc);
router.post('/getJsqtzjcList', projectTzController.getJsqtzjcList); router.post('/getJsqtzjcList', projectTzController.getJsqtzjcList);
router.post('/getJsqtzjcInfo', projectTzController.getJsqtzjcInfo); router.post('/getJsqtzjcInfo', projectTzController.getJsqtzjcInfo);
//重大事项审批
router.post('/createZdsxsp', projectTzController.createZdsxsp);
router.post('/updateZdsxsp', projectTzController.updateZdsxsp);
router.post('/getZdsxspList', projectTzController.getZdsxspList);
router.post('/getZdsxspInfo', projectTzController.getZdsxspInfo);
module.exports = router; module.exports = router;
\ 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