Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
P
problem_rectification
Project
Project
Details
Activity
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
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
David Yang
problem_rectification
Commits
40f35588
Commit
40f35588
authored
May 27, 2026
by
David Yang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: demo
parent
8bb072d7
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1123 additions
and
0 deletions
+1123
-0
ProblemRectification.js
src/services/demo/ProblemRectification.js
+235
-0
ProblemRectificationForm.jsx
src/services/demo/ProblemRectificationForm.jsx
+888
-0
No files found.
src/services/demo/ProblemRectification.js
0 → 100644
View file @
40f35588
import
React
from
'react'
import
{
queryRecords
,
batchRemoveRecords
,
createRecord
,
getSubjectView
,
batchUpdateRecords
,
createNotice
,
sendNotice
,
loadUser
,
executeAction
,
updateRecord
,
importRecords
}
from
'./DataService'
import
BaseService
from
'./BaseService'
import
dayjs
from
'dayjs'
import
{
message
}
from
'antd'
import
UserSelectForm
from
'@/pages/app/problem_rectification/UserSelectForm'
import
SheetHelper
from
'@/utils/SheetHelper'
export
class
ProblemRectificationService
extends
BaseService
{
constructor
()
{
super
()
}
// 推送问题整改表
async
shareProblemRectificationFormTable
(
params
,
callbacks
,
options
)
{
const
selectedRowIds
=
callbacks
?.
gridRef
?.
current
?.
getSelectedRows
?.()
const
selectedRecords
=
await
this
.
processSelectedRecords
(
selectedRowIds
,
params
.
node
?.
data
,
options
?.
subjectName
||
''
,
callbacks
)
console
.
log
(
'currentView'
,
callbacks
?.
gridRef
?.
current
?.
getCurrentView
?.())
// 在外层用闭包变量收集选择结果,onOk 时读取
let
selectedFillers
=
[]
let
selectedAuditors
=
[]
callbacks
?.
modalApi
.
confirm
({
title
:
'选择填报人/审核人'
,
content
:
(
<
UserSelectForm
onChangeFillers
=
{
values
=>
{
selectedFillers
=
values
||
[]
}}
onChangeAuditors
=
{
values
=>
{
selectedAuditors
=
values
||
[]
}}
/
>
),
width
:
600
,
onOk
:
async
()
=>
{
// 在这里即可拿到两组用户 _id
if
(
!
selectedFillers
?.
length
||
!
selectedAuditors
?.
length
)
{
message
.
error
(
'请先选择 填报人 和 审核人'
)
return
Promise
.
reject
()
}
console
.
log
(
'填报人 user_id 列表'
,
selectedFillers
)
console
.
log
(
'审核人 user_id 列表'
,
selectedAuditors
)
const
user_id
=
callbacks
?.
userInfo
?.
_id
const
restriction_key
=
'_id'
const
restriction_value
=
selectedRecords
.
map
(
item
=>
item
.
_id
)
const
result
=
await
createRecord
({
subject
:
'message_reference_id'
,
title
:
`推送 问题整改表 填写`
,
metadata
:
{
sender
:
user_id
,
editor
:
selectedFillers
,
auditor
:
selectedAuditors
,
restriction_key
:
restriction_key
,
restriction_value
:
restriction_value
,
view_name
:
callbacks
?.
gridRef
?.
current
?.
getCurrentView
?.()
||
''
,
subject_name
:
'problem_rectification'
}
})
// 创建oa流程
const
progress_id_editor
=
[]
for
(
const
userId
of
selectedFillers
)
{
const
userInfo
=
await
loadUser
(
userId
)
console
.
log
(
'userInfo'
,
userInfo
)
const
oaProcessResult
=
await
executeAction
(
'oa_notice:createProgress'
,
{
title
:
`
${
dayjs
().
format
(
'YYYY-MM-DD'
)}
填写问题整改表`
,
classify
:
'流程待办'
,
contentType
:
'流程待办'
,
receiveUserId
:
userId
,
receiveUserName
:
userInfo
.
username
,
receiveDisplayName
:
userInfo
.
display_name
,
sendUserId
:
user_id
,
sendUserName
:
callbacks
?.
userInfo
?.
username
,
sendDisplayName
:
callbacks
?.
userInfo
?.
display_name
,
returnUrl
:
`
${
location
.
origin
}
/problem_rectification_form?id=
${
result
.
name
}
`
,
})
console
.
log
(
'userId'
,
userId
)
console
.
log
(
'oaProcessResult'
,
oaProcessResult
)
progress_id_editor
.
push
(
oaProcessResult
?.
data
?.
taskId
)
}
console
.
log
(
'progress_id_editor'
,
progress_id_editor
)
// 更新消息通知中填写人oa流程ID
await
updateRecord
(
result
.
_id
,
{
metadata
:
{
progress_id_editor
:
progress_id_editor
}
})
// 批量更新填写人
await
batchUpdateRecords
({
subject
:
'problem_rectification'
,
filter
:
{
'_id'
:
{
$in
:
selectedRecords
.
map
(
item
=>
item
.
_id
)
}
},
data
:
{
'metadata.fill_in_the_people'
:
selectedFillers
}
})
// 给填报人 推送消息通知
const
editorNoticeResult
=
await
createNotice
({
title
:
'推送 问题整改表 填写'
,
content
:
`请点击链接 填写 问题整改表,
${
location
.
origin
}
/problem_rectification_form?id=
${
result
.
name
}
`
,
type
:
'internal'
,
from
:
user_id
,
to
:
selectedFillers
,
settings
:
{}
})
await
sendNotice
(
editorNoticeResult
.
name
)
callbacks
?.
onRefreshGrid
()
message
.
success
(
'已发送消息通知'
)
}
})
}
// 导出问题整改表
async
exportProblemRectificationFormTable
(
params
,
callbacks
,
options
)
{
console
.
log
(
'exportProblemRectificationFormTable'
,
params
,
callbacks
)
const
selectedRowIds
=
callbacks
?.
gridRef
?.
current
?.
getSelectedRows
?.()
||
[]
const
records
=
await
this
.
processSelectedRecords
(
selectedRowIds
,
params
.
node
?.
data
,
options
?.
subjectName
||
''
,
callbacks
)
const
result
=
await
queryRecords
({
subject
:
'problem_rectification'
,
filter
:
{
'_id'
:
{
$in
:
selectedRowIds
}
}
})
const
data
=
result
?.
records
?.
map
(
item
=>
{
return
{
检查项目名称
:
item
.
metadata
.
project_name
,
检查实施单位
:
item
.
metadata
.
inspect_the_implementing_unit
,
检查实施时间
:
item
.
metadata
.
check_the_implementation_time
,
检查报告出具日
:
item
.
metadata
.
inspection_report_date
,
问题简述
:
item
.
metadata
.
problem_brief
,
问题发现情况
:
item
.
metadata
.
problem_discovery_situation
,
责任部门
:
item
.
metadata
.
responsible_department
,
整改进度
:
item
.
metadata
.
rectification_progress
,
整改情况
:
item
.
metadata
.
rectification_situation
,
问题来源
:
item
.
metadata
.
problem_from
,
问题类型
:
item
.
metadata
.
problem_type
,
反馈单位
:
item
.
metadata
.
feedback_unit
,
问题涉及业务领域
:
item
.
metadata
.
related_issue_domain
,
预计整改完成时间
:
item
.
metadata
.
the_time_of_rectification
?
dayjs
(
item
.
metadata
.
the_time_of_rectification
).
format
(
'YYYY-MM-DD'
)
:
''
,
备注
:
item
.
metadata
.
remark
,
}
})
SheetHelper
.
save
(
data
,
`
${
dayjs
().
format
(
'YYYY-MM-DD'
)}
问题整改表.xlsx`
)
message
.
success
(
'导出成功'
)
return
result
}
// 问题整改归档
async
batch_archive
(
params
,
callbacks
,
options
)
{
console
.
log
(
'batch_archive'
,
params
,
callbacks
)
const
selectedRowIds
=
callbacks
?.
gridRef
?.
current
?.
getSelectedRows
?.()
||
[]
const
records
=
await
this
.
processSelectedRecords
(
selectedRowIds
,
params
.
node
?.
data
,
options
?.
subjectName
||
''
,
callbacks
)
const
result
=
await
importRecords
(
'problem_rectification_archive_records'
,
records
.
map
(
item
=>
{
return
{
title
:
item
.
title
||
undefined
,
metadata
:
{
inspect_the_implementing_unit
:
item
.
metadata
.
inspect_the_implementing_unit
,
check_the_implementation_time
:
item
.
metadata
.
check_the_implementation_time
,
inspection_report_date
:
item
.
metadata
.
inspection_report_date
,
problem_discovery_situation
:
item
.
metadata
.
problem_discovery_situation
,
responsible_department
:
item
.
metadata
.
responsible_department
.
join
(
','
),
rectification_progress
:
item
.
metadata
.
rectification_progress
,
rectification_situation
:
item
.
metadata
.
rectification_situation
,
feedback_unit
:
item
.
metadata
.
feedback_unit
,
remark
:
item
.
metadata
.
remark
,
the_time_of_rectification
:
item
.
metadata
.
the_time_of_rectification
,
fill_in_the_people
:
item
.
metadata
.
fill_in_the_people
?
item
.
metadata
.
fill_in_the_people
.
map
(
item
=>
item
.
_id
)
:
undefined
,
review_people
:
item
.
metadata
.
review_people
?
item
.
metadata
.
review_people
.
map
(
item
=>
item
.
_id
)
:
undefined
,
problem_from
:
item
.
metadata
.
problem_from
,
problem_type
:
item
.
metadata
.
problem_type
,
related_issue_domain
:
item
.
metadata
.
related_issue_domain
,
problem_brief
:
item
.
metadata
.
problem_brief
,
audit_status
:
item
.
metadata
.
audit_status
,
final_audit_status
:
item
.
metadata
.
final_audit_status
,
project_name
:
item
.
metadata
.
project_name
,
rectification_proof_materials
:
item
.
metadata
.
rectification_proof_materials
||
undefined
}
}
}))
await
createRecord
({
subject
:
'issue_rectification_archive'
,
title
:
`问题整改归档
${
dayjs
().
format
(
'YYYY-MM-DD'
)}
`
,
metadata
:
{
reference_records
:
Object
.
values
(
result
.
insertedIds
)
}
})
message
.
success
(
'批量归档成功'
)
}
}
export
default
ProblemRectificationService
src/services/demo/ProblemRectificationForm.jsx
0 → 100644
View file @
40f35588
import
{
Modal
,
Button
,
message
,
Spin
,
Space
}
from
'antd'
import
RecordGrid
from
'@/components/RecordGrid'
import
{
useParams
,
useQuery
,
useLocation
,
history
}
from
'umi'
import
{
getSubjectViewDetail
,
queryRecords
,
batchUpdateRecords
,
sendNotice
,
createNotice
,
loadRecord
,
updateRecord
,
loadUser
,
executeAction
}
from
'@/services/DataService'
import
{
useState
,
useEffect
,
useRef
,
useMemo
,
useCallback
}
from
'react'
import
bgIntegrityRisk
from
'@/assets/bg-integrity-risk.png'
import
{
CheckOutlined
}
from
'@ant-design/icons'
import
{
useUserInfo
}
from
'@/hooks/user'
import
dayjs
from
'dayjs'
const
GRID_READONLY_OPTIONS
=
{
disableAddColumn
:
true
,
hideCreateRecordBtn
:
true
,
disablePersistence
:
true
,
hideEditRecordBtn
:
true
,
hideFilterBtn
:
true
,
hideGroupBtn
:
true
,
hideSearchBtn
:
true
,
disableAddRow
:
true
,
hideFillBtn
:
true
,
hideImportBtn
:
true
,
hideTriggerBtn
:
true
}
export
default
props
=>
{
const
params
=
useParams
()
const
location
=
useLocation
()
const
[
subject
,
setSubject
]
=
useState
(
null
)
const
[
currentView
,
setCurrentView
]
=
useState
(
null
)
const
[
currentViewDetail
,
setCurrentViewDetail
]
=
useState
({})
const
[
loading
,
setLoading
]
=
useState
(
false
)
const
gridRef
=
useRef
(
null
)
const
[
restrictionKey
,
setRestrictionKey
]
=
useState
(
null
)
const
[
restrictionValue
,
setRestrictionValue
]
=
useState
([])
const
[
sender
,
setSender
]
=
useState
(
null
)
const
[
editor
,
setEditor
]
=
useState
(
null
)
const
[
auditor
,
setAuditor
]
=
useState
(
null
)
const
[
userType
,
setUserType
]
=
useState
(
null
)
const
[
messageId
,
setMessageId
]
=
useState
(
null
)
const
[
progressIdEditor
,
setProgressIdEditor
]
=
useState
(
null
)
const
[
progressIdAuditor
,
setProgressIdAuditor
]
=
useState
(
null
)
const
[
progressIdSender
,
setProgressIdSender
]
=
useState
(
null
)
const
[
editorStatus
,
setEditorStatus
]
=
useState
(
null
)
const
[
auditorStatus
,
setAuditorStatus
]
=
useState
(
null
)
const
[
senderStatus
,
setSenderStatus
]
=
useState
(
null
)
const
userInfo
=
useUserInfo
()
const
isMountedRef
=
useRef
(
true
)
// 检查用户登录状态
useEffect
(()
=>
{
if
(
!
userInfo
||
userInfo
.
type
===
'guest'
)
{
history
.
push
(
'/login?redirect='
+
encodeURIComponent
(
location
.
pathname
+
location
.
search
)
)
}
},
[
userInfo
,
location
])
// 直接从URL获取messageId,避免异步状态问题
const
query
=
new
URLSearchParams
(
location
.
search
)
const
messageIdFromUrl
=
query
.
get
(
'id'
)
const
userTypeFromUrl
=
query
.
get
(
'type'
)
useEffect
(()
=>
{
return
()
=>
{
isMountedRef
.
current
=
false
}
},
[])
const
{
data
:
record
}
=
useQuery
({
queryKey
:
[
'problem_rectification_record'
,
messageIdFromUrl
],
queryFn
:
async
()
=>
{
try
{
setMessageId
(
messageIdFromUrl
)
setUserType
(
userTypeFromUrl
)
if
(
!
messageIdFromUrl
)
return
null
const
result
=
await
loadRecord
(
messageIdFromUrl
)
return
result
}
catch
(
err
)
{
console
.
error
(
'加载记录失败:'
,
err
)
return
null
}
},
enabled
:
!!
messageIdFromUrl
})
useEffect
(()
=>
{
document
.
title
=
'问题整改填写表'
if
(
record
)
{
initializeData
(
record
)
}
},
[
record
])
const
toIdString
=
value
=>
{
if
(
value
===
null
||
value
===
undefined
)
return
''
return
String
(
value
).
trim
()
}
const
normalizeUserIds
=
list
=>
{
if
(
!
list
)
return
[]
if
(
Array
.
isArray
(
list
))
{
return
list
.
map
(
item
=>
{
if
(
typeof
item
===
'object'
)
{
return
item
.
_id
||
item
.
id
||
item
.
user_id
||
item
.
userId
}
return
item
})
.
filter
(
Boolean
)
.
map
(
toIdString
)
}
if
(
typeof
list
===
'object'
)
{
return
[
list
.
_id
||
list
.
id
||
list
.
user_id
||
list
.
userId
].
filter
(
Boolean
).
map
(
toIdString
)
}
return
[
toIdString
(
list
)].
filter
(
Boolean
)
}
const
normalizeSingleUserId
=
value
=>
{
if
(
!
value
)
return
''
if
(
typeof
value
===
'object'
)
{
return
toIdString
(
value
.
_id
||
value
.
id
||
value
.
user_id
||
value
.
userId
)
}
return
toIdString
(
value
)
}
const
normalizeProgressParticipants
=
value
=>
{
if
(
!
value
)
return
[]
const
list
=
Array
.
isArray
(
value
)
?
value
:
[
value
]
return
list
.
map
(
item
=>
{
if
(
!
item
)
return
''
if
(
typeof
item
===
'string'
||
typeof
item
===
'number'
)
return
String
(
item
)
if
(
typeof
item
===
'object'
)
{
return
(
item
.
user_id
||
item
.
userId
||
item
.
_id
||
item
.
id
||
item
.
taskId
||
item
.
task_id
||
item
.
value
||
item
.
name
||
''
)
}
return
''
})
.
flatMap
(
val
=>
val
.
split
(
','
)
.
map
(
part
=>
part
.
trim
())
.
filter
(
Boolean
)
)
.
map
(
toIdString
)
}
const
initializeData
=
async
record
=>
{
const
{
metadata
}
=
record
||
{}
if
(
!
metadata
||
typeof
metadata
!==
'object'
)
{
return
}
const
{
subject_name
,
view_name
,
restriction_key
,
restriction_value
,
sender
,
editor
,
auditor
,
progress_id_editor
,
progress_id_auditor
,
progress_id_sender
,
editor_status
,
auditor_status
,
sender_status
}
=
metadata
||
{}
console
.
log
(
'metadata'
,
metadata
)
setSender
(
sender
)
setEditor
(
editor
)
setAuditor
(
auditor
)
setRestrictionKey
(
restriction_key
)
setProgressIdEditor
(
progress_id_editor
)
setProgressIdAuditor
(
progress_id_auditor
)
setProgressIdSender
(
progress_id_sender
)
setEditorStatus
(
editor_status
)
setAuditorStatus
(
auditor_status
)
setSenderStatus
(
sender_status
)
const
normalizedRestrictionValue
=
Array
.
isArray
(
restriction_value
)
?
restriction_value
:
typeof
restriction_value
===
'string'
&&
restriction_value
.
length
?
restriction_value
.
split
(
','
)
:
[]
setRestrictionValue
(
normalizedRestrictionValue
)
if
(
subject_name
)
{
setSubject
(
subject_name
)
}
if
(
view_name
&&
subject_name
)
{
setCurrentView
(
view_name
)
try
{
const
res
=
await
getSubjectViewDetail
(
subject_name
,
view_name
)
setCurrentViewDetail
(
res
||
{})
}
catch
(
error
)
{
console
.
error
(
'获取视图详情失败:'
,
error
)
}
}
}
// 使用useMemo优化restrictions计算,避免不必要的重新渲染
const
computedRestrictions
=
useMemo
(()
=>
{
if
(
!
restrictionKey
)
return
[]
return
[
{
type
:
'field'
,
field
:
restrictionKey
,
value
:
restrictionValue
}
]
},
[
restrictionKey
,
restrictionValue
])
// 使用useMemo优化useFrontView配置
const
frontViewConfig
=
useMemo
(()
=>
{
// 如果 currentViewDetail 没有加载完成,返回 null
if
(
!
currentViewDetail
?.
name
&&
!
currentViewDetail
?.
settings
)
{
return
null
}
// 确保 settings 存在,避免空值问题
const
settings
=
currentViewDetail
?.
settings
||
{}
return
{
autoSave
:
true
,
...
settings
,
// 首先展开所有原有配置
// 合并 restrictions 数组,将原有的和计算出的合并
restrictions
:
[
...(
settings
.
restrictions
||
[]),
...
computedRestrictions
],
// 合并 columns 数组
columns
:
[
{
title
:
'标题'
,
field
:
'title'
,
width
:
100
,
hide
:
true
},
...(
settings
.
columns
||
[])
]
}
},
[
currentViewDetail
,
computedRestrictions
])
// 使用useCallback优化onUpdateRecord回调
const
handleUpdateRecord
=
useCallback
(
async
params
=>
{
// 先计算新的restriction_value数组
const
newRestrictionValue
=
Array
.
from
(
new
Set
([...(
restrictionValue
||
[]),
params
.
record
.
_id
])
)
// 更新本地状态
setRestrictionValue
(
newRestrictionValue
)
// 使用计算出的新数组更新记录
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
restriction_value
:
newRestrictionValue
}
})
},
[
restrictionValue
,
messageIdFromUrl
]
)
const
progressEditorIds
=
useMemo
(
()
=>
normalizeProgressParticipants
(
progressIdEditor
),
[
progressIdEditor
]
)
const
progressAuditorIds
=
useMemo
(
()
=>
normalizeProgressParticipants
(
progressIdAuditor
),
[
progressIdAuditor
]
)
const
progressSenderIds
=
useMemo
(
()
=>
normalizeProgressParticipants
(
progressIdSender
),
[
progressIdSender
]
)
const
editorUserIds
=
useMemo
(()
=>
normalizeUserIds
(
editor
),
[
editor
])
const
auditorUserIds
=
useMemo
(()
=>
normalizeUserIds
(
auditor
),
[
auditor
])
const
senderUserId
=
useMemo
(()
=>
normalizeSingleUserId
(
sender
),
[
sender
])
const
currentUserId
=
useMemo
(
()
=>
(
userInfo
?.
_id
?
String
(
userInfo
.
_id
).
trim
()
:
null
),
[
userInfo
]
)
const
isProgressEditor
=
useMemo
(()
=>
{
if
(
!
currentUserId
)
return
false
return
(
progressEditorIds
.
includes
(
currentUserId
)
||
editorUserIds
.
includes
(
currentUserId
)
)
},
[
currentUserId
,
progressEditorIds
,
editorUserIds
])
const
isProgressAuditor
=
useMemo
(()
=>
{
if
(
!
currentUserId
)
return
false
return
(
progressAuditorIds
.
includes
(
currentUserId
)
||
auditorUserIds
.
includes
(
currentUserId
)
)
},
[
currentUserId
,
progressAuditorIds
,
auditorUserIds
])
const
isProgressSender
=
useMemo
(()
=>
{
if
(
!
currentUserId
)
return
false
return
(
progressSenderIds
.
includes
(
currentUserId
)
||
(
senderUserId
?
senderUserId
===
currentUserId
:
false
)
)
},
[
currentUserId
,
progressSenderIds
,
senderUserId
])
const
canEdit
=
useMemo
(()
=>
{
if
(
!
currentUserId
)
return
false
if
(
isProgressSender
)
return
true
if
(
isProgressEditor
)
{
return
editorStatus
!==
'已完成'
}
if
(
isProgressAuditor
)
{
if
(
editorStatus
!==
'已完成'
)
{
return
true
}
return
auditorStatus
!==
'已完成'
}
return
false
},
[
currentUserId
,
isProgressSender
,
isProgressEditor
,
isProgressAuditor
,
editorStatus
,
auditorStatus
])
const
recordGridReadonly
=
canEdit
?
GRID_READONLY_OPTIONS
:
true
return
(
<
Spin
spinning=
{
loading
}
>
<
div
style=
{
{
height
:
'calc(100vh - 300px)'
,
padding
:
'20px 30px 10px'
,
backgroundImage
:
`url(${bgIntegrityRisk})`
,
backgroundSize
:
'cover'
,
backgroundPosition
:
'center'
}
}
>
<
div
style=
{
{
display
:
'flex'
,
justifyContent
:
'center'
}
}
></
div
>
<
div
style=
{
{
height
:
'calc(100vh - 120px)'
,
borderRadius
:
'20px'
,
background
:
'#fff'
,
padding
:
'20px'
,
boxShadow
:
'0 0 10px 0 rgba(0, 0, 0, 0.1)'
}
}
>
{
subject
&&
currentView
&&
frontViewConfig
&&
(
<
RecordGrid
ref=
{
gridRef
}
key=
{
`${subject}-${currentView}-${JSON.stringify(frontViewConfig.restrictions || [])}`
}
subjectName=
{
subject
}
quickSelect=
{
true
}
toolBarRightSlot=
{
()
=>
(
<
div
>
{
(
editor
||
[]).
some
(
item
=>
item
.
_id
===
userInfo
?.
_id
)
&&
(
<
Button
style=
{
{
marginRight
:
'10px'
}
}
type=
"primary"
icon=
{
<
CheckOutlined
/>
}
disabled=
{
editorStatus
===
'已完成'
}
onClick=
{
async
()
=>
{
setLoading
(
true
)
// 给审核人发送消息通知
const
noticeResult
=
await
createNotice
({
title
:
'问题整改表填写完成'
,
content
:
`问题整改表填写完成, 请审核, 审核链接:${window.location.href}`
,
type
:
'internal'
,
from
:
userInfo
?.
_id
,
to
:
auditor
})
await
sendNotice
(
noticeResult
.
name
)
// 更新填写人oa流程, 创建审批人oa流程,更新消息通知中审批人oa流程ID
// 填写人oa流程更新状态 已完成
for
(
const
progressId
of
progressIdEditor
||
[])
{
await
executeAction
(
'oa_notice:updateProgressStatus'
,
{
taskId
:
progressId
}
)
}
// 创建审批人oa流程
const
progressIdAuditor
=
[]
for
(
const
auditorInfo
of
auditor
||
[])
{
const
oaProcessResult
=
await
executeAction
(
'oa_notice:createProgress'
,
{
title
:
`${dayjs().format(
'YYYY-MM-DD'
)} 问题整改表审核`
,
classify
:
'流程待办'
,
contentType
:
'流程待办'
,
receiveUserId
:
auditorInfo
.
_id
,
receiveUserName
:
auditorInfo
.
username
,
receiveDisplayName
:
auditorInfo
.
display_name
,
sendUserId
:
userInfo
?.
_id
,
sendUserName
:
userInfo
.
username
,
sendDisplayName
:
userInfo
.
display_name
,
returnUrl
:
`${window.location.href}`
}
)
progressIdAuditor
.
push
(
oaProcessResult
?.
data
?.
taskId
)
}
// 更新消息通知中审批人oa流程ID和编辑人状态
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
progress_id_auditor
:
progressIdAuditor
,
editor_status
:
'已完成'
,
auditor_status
:
'未审批'
,
review_people
:
auditor
}
})
// 更新本地状态
setEditorStatus
(
'已完成'
)
setAuditorStatus
(
'未审批'
)
await
batchUpdateRecords
({
subject
:
subject
,
filter
:
{
_id
:
{
$in
:
restrictionValue
}
},
data
:
{
'metadata.review_people'
:
auditor
}
})
message
.
success
(
'已发送审核消息通知'
)
gridRef
?.
current
?.
refreshServerSide
({
purge
:
true
})
setLoading
(
false
)
}
}
>
送审
</
Button
>
)
}
{
(
auditor
||
[]).
some
(
item
=>
item
.
_id
===
userInfo
?.
_id
)
&&
(
<
Space
style=
{
{
marginRight
:
'10px'
}
}
>
<
Button
type=
"primary"
icon=
{
<
CheckOutlined
/>
}
disabled=
{
auditorStatus
===
'已完成'
}
onClick=
{
async
()
=>
{
if
(
loading
)
return
if
(
!
subject
)
return
try
{
setLoading
(
true
)
// 重新获取最新的记录数据,确保包含所有新增的记录
const
latestRecord
=
await
loadRecord
(
messageIdFromUrl
)
const
latestRestrictionValue
=
latestRecord
?.
metadata
?.
restriction_value
||
[]
const
result
=
await
queryRecords
({
subject
:
subject
,
page_size
:
1000
,
filter
:
{
_id
:
{
$in
:
latestRestrictionValue
}
}
})
const
records
=
result
?.
records
||
[]
if
(
!
records
.
length
)
{
message
.
info
(
'无可审批记录'
)
return
}
const
recordIds
=
records
.
map
(
item
=>
item
.
_id
)
.
filter
(
Boolean
)
await
batchUpdateRecords
({
subject
:
subject
,
filter
:
{
_id
:
{
$in
:
recordIds
}
},
data
:
{
'metadata.review_people'
:
userInfo
?.
_id
,
'metadata.audit_status'
:
'已审批'
,
}
})
const
noticeResult
=
await
createNotice
({
title
:
'问题整改表已审批,请核查'
,
content
:
`问题整改表已审批,请核查, 核查链接:${window.location.href}`
,
type
:
'internal'
,
from
:
userInfo
?.
_id
,
to
:
sender
})
await
sendNotice
(
noticeResult
.
name
)
// 更新审批人oa流程,创建最终审批人oa流程, 更新消息通知中审批人oa流程ID
// 审批人oa流程更新状态 已完成
for
(
const
progressId
of
progressIdAuditor
||
[])
{
await
executeAction
(
'oa_notice:updateProgressStatus'
,
{
taskId
:
progressId
}
)
}
// 创建最终审批人oa流程
const
oaProcessResult
=
await
executeAction
(
'oa_notice:createProgress'
,
{
title
:
`${dayjs().format(
'YYYY-MM-DD'
)} 问题整改表最终审核`
,
classify
:
'流程待办'
,
contentType
:
'流程待办'
,
receiveUserId
:
sender
.
_id
,
receiveUserName
:
sender
.
username
,
receiveDisplayName
:
sender
.
display_name
,
sendUserId
:
userInfo
?.
_id
,
sendUserName
:
userInfo
.
username
,
sendDisplayName
:
userInfo
.
display_name
,
returnUrl
:
`${window.location.href}`
}
)
const
progressIdSender
=
oaProcessResult
?.
data
?.
taskId
// 更新消息通知中最终审批人oa流程ID和审批人状态
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
progress_id_sender
:
progressIdSender
,
auditor_status
:
'已完成'
,
sender_status
:
'未审批'
}
})
// 更新本地状态
setAuditorStatus
(
'已完成'
)
setSenderStatus
(
'未审批'
)
message
.
success
(
'一键复核成功,已发送最终审核消息通知'
)
gridRef
?.
current
?.
refreshServerSide
({
purge
:
true
})
}
catch
(
err
)
{
console
.
error
(
'一键复核失败:'
,
err
)
message
.
error
(
'一键复核失败,请稍后重试'
)
}
finally
{
if
(
isMountedRef
.
current
)
{
setLoading
(
false
)
}
}
}
}
>
一键复核
</
Button
>
<
Button
disabled=
{
auditorStatus
===
'已完成'
}
onClick=
{
async
()
=>
{
try
{
setLoading
(
true
)
// 重新获取最新的记录数据
const
latestRecord
=
await
loadRecord
(
messageIdFromUrl
)
const
latestRestrictionValue
=
latestRecord
?.
metadata
?.
restriction_value
||
[]
// 批量更新所有记录的审批状态为已驳回,并填写审批人
await
batchUpdateRecords
({
subject
:
subject
,
filter
:
{
_id
:
{
$in
:
latestRestrictionValue
}
},
data
:
{
'metadata.review_people'
:
auditor
,
'metadata.audit_status'
:
'已驳回'
}
})
// 给填写人发送OA通知
const
noticeResult
=
await
createNotice
({
title
:
'问题整改表审核驳回'
,
content
:
`问题整改表审核驳回,请重新填写,填写链接:${window.location.href}`
,
type
:
'internal'
,
from
:
userInfo
?.
_id
,
to
:
editor
.
map
(
item
=>
item
.
_id
)
})
await
sendNotice
(
noticeResult
.
name
)
// 更新审批人oa流程状态为已完成
for
(
const
progressId
of
progressIdAuditor
||
[])
{
await
executeAction
(
'oa_notice:updateProgressStatus'
,
{
taskId
:
progressId
}
)
}
// 创建填写人oa流程
const
progressIdEditor
=
[]
for
(
const
editorInfo
of
editor
||
[])
{
const
oaProcessResult
=
await
executeAction
(
'oa_notice:createProgress'
,
{
title
:
`审核驳回,请重新填写问题整改表 ${dayjs().format(
'YYYY-MM-DD'
)}`
,
classify
:
'流程待办'
,
contentType
:
'流程待办'
,
receiveUserId
:
editorInfo
.
_id
,
receiveUserName
:
editorInfo
.
username
,
receiveDisplayName
:
editorInfo
.
display_name
,
sendUserId
:
userInfo
?.
_id
,
sendUserName
:
userInfo
.
username
,
sendDisplayName
:
userInfo
.
display_name
,
returnUrl
:
`${window.location.href}`
}
)
progressIdEditor
.
push
(
oaProcessResult
?.
data
?.
taskId
)
}
// 更新审批人状态为已完成,填写人状态为未完成
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
auditor_status
:
'已完成'
,
editor_status
:
'未完成'
,
progress_id_editor
:
progressIdEditor
}
})
// 更新本地状态
setAuditorStatus
(
'已完成'
)
setEditorStatus
(
'未完成'
)
message
.
success
(
'已驳回审核,已通知填写人重新填写'
)
gridRef
?.
current
?.
refreshServerSide
({
purge
:
true
})
}
catch
(
err
)
{
console
.
error
(
'驳回失败:'
,
err
)
message
.
error
(
'驳回失败,请稍后重试'
)
}
finally
{
if
(
isMountedRef
.
current
)
{
setLoading
(
false
)
}
}
}
}
>
驳回
</
Button
>
</
Space
>
)
}
{
sender
?.
_id
===
userInfo
?.
_id
&&
(
<
Space
>
<
Button
type=
"primary"
disabled=
{
senderStatus
===
'已完成'
||
senderStatus
===
'已驳回'
}
onClick=
{
async
()
=>
{
if
(
loading
)
return
if
(
!
subject
)
return
try
{
setLoading
(
true
)
// 重新获取最新的记录数据,确保包含所有新增的记录
const
latestRecord
=
await
loadRecord
(
messageIdFromUrl
)
const
latestRestrictionValue
=
latestRecord
?.
metadata
?.
restriction_value
||
[]
const
result
=
await
queryRecords
({
subject
:
subject
,
page_size
:
1000
,
filter
:
{
_id
:
{
$in
:
latestRestrictionValue
}
}
})
const
records
=
result
?.
records
||
[]
const
recordIds
=
records
.
map
(
item
=>
item
.
_id
)
.
filter
(
Boolean
)
if
(
!
recordIds
.
length
)
{
message
.
info
(
'无可最终审核记录'
)
return
}
await
batchUpdateRecords
({
subject
:
subject
,
filter
:
{
_id
:
{
$in
:
recordIds
}
},
data
:
{
'metadata.final_audit_status'
:
'已审批'
}
})
// 更新最终审批人oa流程状态 progressIdSender 是字符串
await
executeAction
(
'oa_notice:updateProgressStatus'
,
{
taskId
:
progressIdSender
}
)
// 更新发送人状态
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
sender_status
:
'已完成'
}
})
// 更新本地状态
setSenderStatus
(
'已完成'
)
message
.
success
(
'一键最终审核成功'
)
gridRef
?.
current
?.
refreshServerSide
({
purge
:
true
})
}
catch
(
err
)
{
console
.
error
(
'一键最终审核失败:'
,
err
)
message
.
error
(
'一键最终审核失败,请稍后重试'
)
}
finally
{
if
(
isMountedRef
.
current
)
{
setLoading
(
false
)
}
}
}
}
>
一键最终审核
</
Button
>
<
Button
disabled=
{
senderStatus
===
'已完成'
||
senderStatus
===
'已驳回'
}
onClick=
{
async
()
=>
{
try
{
setLoading
(
true
)
// 重新获取最新的记录数据
const
latestRecord
=
await
loadRecord
(
messageIdFromUrl
)
const
latestRestrictionValue
=
latestRecord
?.
metadata
?.
restriction_value
||
[]
const
result
=
await
createNotice
({
title
:
'驳回问题整改表最终审批'
,
content
:
`驳回问题整改表最终审批, 请重新填写,填写链接:${window.location.href}`
,
type
:
'internal'
,
from
:
userInfo
?.
_id
,
to
:
editor
.
map
(
item
=>
item
.
_id
)
})
await
sendNotice
(
result
.
name
)
await
batchUpdateRecords
({
subject
:
subject
,
filter
:
{
_id
:
{
$in
:
latestRestrictionValue
}
},
data
:
{
'metadata.final_audit_status'
:
'已驳回'
}
})
// 更新最终审批人oa流程状态
await
executeAction
(
'oa_notice:updateProgressStatus'
,
{
taskId
:
progressIdSender
}
)
// 只将填写人状态改成未完成,最终审批状态改成已完成
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
editor_status
:
'未完成'
,
sender_status
:
'已完成'
}
})
// 更新本地状态
setSenderStatus
(
'已完成'
)
setEditorStatus
(
'未完成'
)
// 创建填写人oa流程
const
progressIdEditor
=
[]
for
(
const
editorInfo
of
editor
||
[])
{
const
oaProcessResult
=
await
executeAction
(
'oa_notice:createProgress'
,
{
title
:
`最终审批驳回,请重新填写问题整改表 ${dayjs().format(
'YYYY-MM-DD'
)}`
,
classify
:
'流程待办'
,
contentType
:
'流程待办'
,
receiveUserId
:
editorInfo
.
_id
,
receiveUserName
:
editorInfo
.
username
,
receiveDisplayName
:
editorInfo
.
display_name
,
sendUserId
:
userInfo
?.
_id
,
sendUserName
:
userInfo
.
username
,
sendDisplayName
:
userInfo
.
display_name
,
returnUrl
:
`${window.location.href}`
}
)
progressIdEditor
.
push
(
oaProcessResult
?.
data
?.
taskId
)
}
await
updateRecord
(
messageIdFromUrl
,
{
metadata
:
{
progress_id_editor
:
progressIdEditor
}
})
message
.
success
(
'已驳回最终审批'
)
gridRef
?.
current
?.
refreshServerSide
({
purge
:
true
})
}
catch
(
err
)
{
console
.
error
(
'驳回审批失败:'
,
err
)
message
.
error
(
'驳回审批失败,请稍后重试'
)
}
finally
{
if
(
isMountedRef
.
current
)
{
setLoading
(
false
)
}
}
}
}
>
驳回审批
</
Button
>
</
Space
>
)
}
</
div
>
)
}
authApp=
{
'problem_rectification'
}
useCustomContextMenu=
{
false
}
readonly=
{
recordGridReadonly
}
useFrontView=
{
frontViewConfig
}
actions=
{
{
onEditorOpen
:
params
=>
console
.
log
(
params
),
onFieldPreview
:
params
=>
console
.
log
(
params
),
onUpdateRecord
:
handleUpdateRecord
}
}
useCustomSidebar=
{
false
}
/>
)
}
</
div
>
</
div
>
</
Spin
>
)
}
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