明树Git Lab
Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
J
jt_backend
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zengfanpei
jt_backend
Commits
5b49b936
Commit
5b49b936
authored
Nov 26, 2025
by
zfp1
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update
parent
1e45275f
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
137 additions
and
15 deletions
+137
-15
projectController.js
controller/projectController.js
+62
-3
project.js
db/model/jt/project.js
+5
-1
flowRecord.js
db/model/system/flowRecord.js
+53
-0
message.js
db/model/system/message.js
+6
-7
role.js
db/model/system/role.js
+4
-4
userModule.js
module/userModule.js
+7
-0
No files found.
controller/projectController.js
View file @
5b49b936
const
errorMessage
=
require
(
"../utils/errorMessage"
);
const
errorMessage
=
require
(
"../utils/errorMessage"
);
const
_
=
require
(
"lodash"
);
const
_
=
require
(
"lodash"
);
const
{
Op
,
where
}
=
require
(
'sequelize'
);
const
{
Op
}
=
require
(
'sequelize'
);
const
userModule
=
require
(
'../module/userModule'
);
async
function
getProjectFields
(
req
,
res
,
next
)
{
async
function
getProjectFields
(
req
,
res
,
next
)
{
try
{
try
{
...
@@ -43,7 +45,13 @@ async function getProjectFields(req, res, next) {
...
@@ -43,7 +45,13 @@ async function getProjectFields(req, res, next) {
next
(
error
);
next
(
error
);
}
}
}
}
/**
* 创建提交 创建
* @param {*} req
* @param {*} res
* @param {*} next
* @returns
*/
async
function
createProject
(
req
,
res
,
next
)
{
async
function
createProject
(
req
,
res
,
next
)
{
try
{
try
{
const
body
=
req
.
body
;
const
body
=
req
.
body
;
...
@@ -137,6 +145,24 @@ async function createProject(req, res, next) {
...
@@ -137,6 +145,24 @@ async function createProject(req, res, next) {
*/
*/
//B. 找到本公司审批人员发送消息-- 如果找不到人 则提示项目已保存,联系管理员添加【项目公司项目审批人】角色
//B. 找到本公司审批人员发送消息-- 如果找不到人 则提示项目已保存,联系管理员添加【项目公司项目审批人】角色
//A. 创建发起记录
//A. 创建发起记录
if
(
buttonType
===
'submit'
)
{
await
DB
.
FlowRecord
.
create
({
userId
:
req
.
user
.
id
,
actionName
:
'发起项目复核'
,
projectId
:
project
.
id
,
});
let
approvers
=
await
userModule
.
getProjectApprover
(
req
.
user
.
id
,
'xmgs_xmspr'
);
if
(
!
(
approvers
&&
approvers
.
length
>
0
))
{
return
res
.
sendError
(
'项目已保存,请联系管理员为本公司添加【项目公司项目审批人】角色人员'
);
}
await
DB
.
Message
.
createProjectMessage
({
projectId
:
project
.
id
,
creator
:
req
.
user
.
id
,
receivers
:
approvers
.
map
(
o
=>
o
.
id
),
type
:
2
,
content
:
`项目【
${
project
.
name
}
】已发起,请尽快处理!`
});
}
return
res
.
sendData
(
project
);
return
res
.
sendData
(
project
);
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -144,6 +170,13 @@ async function createProject(req, res, next) {
...
@@ -144,6 +170,13 @@ async function createProject(req, res, next) {
}
}
/**
* 更新提交 更新
* @param {*} req
* @param {*} res
* @param {*} next
* @returns
*/
async
function
updateProject
(
req
,
res
,
next
)
{
async
function
updateProject
(
req
,
res
,
next
)
{
try
{
try
{
let
body
=
req
.
body
;
let
body
=
req
.
body
;
...
@@ -258,8 +291,9 @@ async function updateProject(req, res, next) {
...
@@ -258,8 +291,9 @@ async function updateProject(req, res, next) {
}
}
const
ret
=
await
DB
.
Project
.
update
(
projectInfo
,
{
where
:
{
id
:
body
.
id
}
});
const
ret
=
await
DB
.
Project
.
update
(
projectInfo
,
{
where
:
{
id
:
body
.
id
}
});
/**
/**
* 根据前端加入的参数区分按钮 更新草稿并提交 更新草稿
* 根据前端加入的参数区分按钮 更新草稿并提交 更新草稿
TODO:
*/
*/
return
res
.
sendData
(
ret
);
return
res
.
sendData
(
ret
);
}
catch
(
error
)
{
}
catch
(
error
)
{
next
(
error
);
next
(
error
);
...
@@ -267,6 +301,31 @@ async function updateProject(req, res, next) {
...
@@ -267,6 +301,31 @@ async function updateProject(req, res, next) {
}
}
async
function
reviewProject
(
req
,
res
,
next
)
{
try
{
let
{
id
}
=
req
.
body
;
if
(
!
id
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
)
}
let
project
=
await
DB
.
Project
.
findOne
({
where
:
{
id
}
});
if
(
!
project
)
{
return
res
.
sendError
(
errorMessage
.
resourceNotFound
)
}
/**
* 1. 更新项目状态 3 复核通过 复核不通过则回到状态1
*/
if
(
buttonType
===
'approve'
)
{
await
DB
.
Project
.
update
({
status
:
3
},
{
where
:
{
id
}
});
}
else
{
await
DB
.
Project
.
update
({
status
:
1
},
{
where
:
{
id
}
});
}
return
res
.
sendData
();
}
catch
(
error
)
{
next
(
error
)
}
}
async
function
getProjectInfo
(
req
,
res
,
next
)
{
async
function
getProjectInfo
(
req
,
res
,
next
)
{
try
{
try
{
if
(
!
req
.
body
.
id
)
{
if
(
!
req
.
body
.
id
)
{
...
...
db/model/jt/project.js
View file @
5b49b936
...
@@ -2,7 +2,7 @@
...
@@ -2,7 +2,7 @@
const
{
DataTypes
}
=
require
(
'sequelize'
);
const
{
DataTypes
}
=
require
(
'sequelize'
);
const
sequelize
=
require
(
'../index'
);
const
sequelize
=
require
(
'../index'
);
const
User
=
require
(
'./system/user'
);
const
User
=
require
(
'.
.
/system/user'
);
const
Project
=
sequelize
.
define
(
'Project'
,
{
const
Project
=
sequelize
.
define
(
'Project'
,
{
// 定义字段
// 定义字段
...
@@ -21,6 +21,10 @@ const Project = sequelize.define('Project', {
...
@@ -21,6 +21,10 @@ const Project = sequelize.define('Project', {
key
:
'id'
,
key
:
'id'
,
},
},
},
},
projectLiuZhuanType
:
{
type
:
DataTypes
.
STRING
,
comment
:
"项目流转状态 草稿、待初审、初审退回、待终审、终审退回、待立项审批、立项审批退回、已立项、已暂停、已结束等"
,
},
/**
/**
* 项目基本信息
* 项目基本信息
*/
*/
...
...
db/model/system/flowRecord.js
0 → 100644
View file @
5b49b936
// models/flowRecord.js
const
{
DataTypes
}
=
require
(
'sequelize'
);
const
sequelize
=
require
(
'../index'
);
const
User
=
require
(
'./system/user'
);
const
{
act
}
=
require
(
'react'
);
/**
* 记录流程动作记录
*/
const
flowRecord
=
sequelize
.
define
(
'flowRecord'
,
{
// 定义字段
id
:
{
type
:
DataTypes
.
INTEGER
,
primaryKey
:
true
,
autoIncrement
:
true
},
userId
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"用户ID"
,
references
:
{
model
:
User
,
key
:
'id'
}
},
actionName
:
{
type
:
DataTypes
.
STRING
(
100
),
comment
:
"动作名称 发起项目复核 项目复核通过 项目复核退回 项目终审退回 项目终审通过 项目立项审批通过 项目立项审批不通过等"
},
projectId
:
{
type
:
DataTypes
.
INTEGER
,
comment
:
"项目ID"
},
del
:
{
type
:
DataTypes
.
INTEGER
,
defaultValue
:
0
,
comment
:
"0 正常 1 删除"
},
},
{
tableName
:
'system_user'
,
// 指定表名(如果与模型名不同)
timestamps
:
true
,
// 是否自动添加 createdAt 和 updatedAt 字段(覆盖全局设置)
});
// 同步模型到数据库(创建表)
flowRecord
.
sync
({
// force: false,
// force: true ,//会删除已存在表并重新创建
// alter: true
})
.
then
(()
=>
{
console
.
log
(
'flowRecord 表同步成功'
);
});
module
.
exports
=
flowRecord
;
\ No newline at end of file
db/model/system/message.js
View file @
5b49b936
...
@@ -31,20 +31,19 @@ const Message = sequelize.define('Message', {
...
@@ -31,20 +31,19 @@ const Message = sequelize.define('Message', {
allowNull
:
false
,
allowNull
:
false
,
comment
:
"消息内容"
comment
:
"消息内容"
},
},
/**
* 其他待存字段
*/
type
:
{
type
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
allowNull
:
true
,
allowNull
:
true
,
comment
:
"消息类型 1 系统消息 2 项目初步审核 3.项目终审"
comment
:
"消息类型 1 系统消息 2 项目初步审核 3.项目终审"
},
},
status
:
{
/**
* 其他待存字段
*/
projectId
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
defaultValue
:
0
,
comment
:
"关联项目ID"
comment
:
"0 未读 1 已读"
},
},
del
:
{
del
:
{
type
:
DataTypes
.
INTEGER
,
type
:
DataTypes
.
INTEGER
,
defaultValue
:
0
,
defaultValue
:
0
,
...
...
db/model/system/role.js
View file @
5b49b936
...
@@ -13,10 +13,10 @@ const Role = sequelize.define('Role', {
...
@@ -13,10 +13,10 @@ const Role = sequelize.define('Role', {
type
:
DataTypes
.
STRING
,
type
:
DataTypes
.
STRING
,
commnet
:
"角色名称"
,
commnet
:
"角色名称"
,
},
},
//
key: {
key
:
{
//
type: DataTypes.STRING,
type
:
DataTypes
.
STRING
,
//
commnet: "角色标识",
commnet
:
"角色标识"
,
//
},
},
// enable: {
// enable: {
// type: DataTypes.BOOLEAN,
// type: DataTypes.BOOLEAN,
// defaultValue: true,
// defaultValue: true,
...
...
module/userModule.js
View file @
5b49b936
...
@@ -95,9 +95,16 @@ async function setRoleMenu(roleId, menuIds, rolemenus) {
...
@@ -95,9 +95,16 @@ async function setRoleMenu(roleId, menuIds, rolemenus) {
}
}
}
}
async
function
getProjectApprover
(
userId
,
roleCode
)
{
// 获取当前用户公司的 具体角色 的用户列表
let
user
=
await
DB
.
User
.
findOne
({
where
:
{
id
:
userId
}
});
return
[];
}
module
.
exports
=
{
module
.
exports
=
{
setUserRole
,
setUserRole
,
setUserDepart
,
setUserDepart
,
setRoleMenu
,
setRoleMenu
,
getProjectApprover
,
}
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment