|
@@ -1,22 +1,23 @@
|
|
import useDrawer from '@/components/Drawer'
|
|
import useDrawer from '@/components/Drawer'
|
|
-// import { mockNodes } from '@/components/Flow/src/shared/transformer'
|
|
|
|
-import { queryMatterList } from '@/services/api/business'
|
|
|
|
import { queryApprovalDetail } from '@/services/api/project'
|
|
import { queryApprovalDetail } from '@/services/api/project'
|
|
import consts from '@/utils/consts'
|
|
import consts from '@/utils/consts'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
import { PageContainer } from '@ant-design/pro-layout'
|
|
-import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table'
|
|
|
|
|
|
+import ProTable, { ProColumns } from '@ant-design/pro-table'
|
|
import { connect } from '@umijs/max'
|
|
import { connect } from '@umijs/max'
|
|
import { Button } from 'antd'
|
|
import { Button } from 'antd'
|
|
-import { Dispatch, useEffect, useMemo, useRef, useState } from 'react'
|
|
|
|
|
|
+import { Dispatch, useEffect, useState } from 'react'
|
|
import { BusinessModelState } from '../model'
|
|
import { BusinessModelState } from '../model'
|
|
import LeftMenu from '../RuleCode/components/LeftMenu'
|
|
import LeftMenu from '../RuleCode/components/LeftMenu'
|
|
import ApprovalFlow from './components/Flow'
|
|
import ApprovalFlow from './components/Flow'
|
|
import { transformToFlowNodes } from './components/Flow/shared/transformer'
|
|
import { transformToFlowNodes } from './components/Flow/shared/transformer'
|
|
|
|
|
|
type StepProps = {
|
|
type StepProps = {
|
|
- processMap: {
|
|
|
|
|
|
+ executorMap: {
|
|
[key: string]: API.ExecutorItem[]
|
|
[key: string]: API.ExecutorItem[]
|
|
}
|
|
}
|
|
|
|
+ matterMap: {
|
|
|
|
+ [key: string]: API.MatterItem[]
|
|
|
|
+ }
|
|
conditionSchema: Record<
|
|
conditionSchema: Record<
|
|
string,
|
|
string,
|
|
{
|
|
{
|
|
@@ -29,45 +30,55 @@ type StepProps = {
|
|
}
|
|
}
|
|
type iState = {
|
|
type iState = {
|
|
activeKey: string | null
|
|
activeKey: string | null
|
|
- process: API.ApprovalProcess[]
|
|
|
|
|
|
+ process: {
|
|
|
|
+ detail: API.ApprovalProcess[]
|
|
|
|
+ list: any[]
|
|
|
|
+ }
|
|
subjectName?: string
|
|
subjectName?: string
|
|
}
|
|
}
|
|
-const Step: React.FC<StepProps> = ({ processMap, conditionSchema, dispatch }) => {
|
|
|
|
|
|
+const Step: React.FC<StepProps> = ({ executorMap, matterMap, conditionSchema, dispatch }) => {
|
|
const [drawer, DrawerDOM] = useDrawer()
|
|
const [drawer, DrawerDOM] = useDrawer()
|
|
- const actionRef = useRef<ActionType>()
|
|
|
|
const [state, setState] = useState<iState>({
|
|
const [state, setState] = useState<iState>({
|
|
activeKey: null,
|
|
activeKey: null,
|
|
- process: []
|
|
|
|
|
|
+ process: {}
|
|
})
|
|
})
|
|
|
|
|
|
useEffect(() => {
|
|
useEffect(() => {
|
|
|
|
+ async function initData(params: { gatherID: string; businessType: string }) {
|
|
|
|
+ const {
|
|
|
|
+ code = -1,
|
|
|
|
+ data: { process = [], processList = [] }
|
|
|
|
+ } = await queryApprovalDetail(params)
|
|
|
|
+ if (code === consts.RET_CODE.SUCCESS) {
|
|
|
|
+ setState({ ...state, process: { detail: process, list: processList } })
|
|
|
|
+ }
|
|
|
|
+ }
|
|
if (state.activeKey) {
|
|
if (state.activeKey) {
|
|
const [gatherID, businessType] = state.activeKey.split('_')
|
|
const [gatherID, businessType] = state.activeKey.split('_')
|
|
- dispatch({
|
|
|
|
- type: 'business/queryExecutor',
|
|
|
|
- payload: { gatherID, businessType, pageSize: 214000 }
|
|
|
|
- })
|
|
|
|
|
|
+ if (!executorMap?.[state.activeKey]) {
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'business/queryExecutor',
|
|
|
|
+ payload: { gatherID, businessType, pageSize: 214000 }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
|
|
+ if (!matterMap?.[state.activeKey]) {
|
|
|
|
+ dispatch({
|
|
|
|
+ type: 'business/queryMatter',
|
|
|
|
+ payload: { gatherID, businessType, pageSize: 214000, matterType: 'matter' }
|
|
|
|
+ })
|
|
|
|
+ }
|
|
if (!conditionSchema?.[state.activeKey]) {
|
|
if (!conditionSchema?.[state.activeKey]) {
|
|
dispatch({
|
|
dispatch({
|
|
type: 'business/queryCondition',
|
|
type: 'business/queryCondition',
|
|
payload: state.activeKey
|
|
payload: state.activeKey
|
|
})
|
|
})
|
|
}
|
|
}
|
|
|
|
+ initData({ gatherID, businessType })
|
|
}
|
|
}
|
|
}, [state.activeKey])
|
|
}, [state.activeKey])
|
|
- const params = useMemo(() => {
|
|
|
|
- if (!state.activeKey) return {}
|
|
|
|
- const [gatherID, businessType] = state.activeKey.split('_')
|
|
|
|
- return { gatherID, businessType }
|
|
|
|
- }, [state.activeKey])
|
|
|
|
|
|
|
|
- const handleMenuChange = (key: string, option) => {
|
|
|
|
- console.log(option)
|
|
|
|
-
|
|
|
|
- setState({ ...state, activeKey: key })
|
|
|
|
- actionRef.current?.reload()
|
|
|
|
- // const [gatherID, businessType] = key.split('_')
|
|
|
|
- //
|
|
|
|
|
|
+ const handleMenuChange = (key: string, option?: { value: string; label: string }) => {
|
|
|
|
+ setState({ ...state, activeKey: key, subjectName: option?.label || '' })
|
|
}
|
|
}
|
|
const columns: ProColumns = [
|
|
const columns: ProColumns = [
|
|
{
|
|
{
|
|
@@ -76,38 +87,31 @@ const Step: React.FC<StepProps> = ({ processMap, conditionSchema, dispatch }) =>
|
|
width: '50%'
|
|
width: '50%'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- dataIndex: 'executor',
|
|
|
|
|
|
+ dataIndex: 'executorName',
|
|
title: '执行者',
|
|
title: '执行者',
|
|
width: '20%'
|
|
width: '20%'
|
|
},
|
|
},
|
|
{
|
|
{
|
|
- dataIndex: 'matter',
|
|
|
|
|
|
+ dataIndex: 'matterNames',
|
|
title: '事项名称',
|
|
title: '事项名称',
|
|
width: '30%'
|
|
width: '30%'
|
|
}
|
|
}
|
|
]
|
|
]
|
|
|
|
|
|
const handleBtnClick = async () => {
|
|
const handleBtnClick = async () => {
|
|
- const [gatherID, businessType] = state.activeKey.split('_')
|
|
|
|
- queryMatterList({ gatherID, businessType, pageSize: 214000, matterType: 'matter' }).then(
|
|
|
|
- ({ code = -1, data: { items: matters = [] } = {} }) => {
|
|
|
|
- if (code === consts.RET_CODE.SUCCESS) {
|
|
|
|
- drawer.open({
|
|
|
|
- title: state.subjectName,
|
|
|
|
- destroyOnClose: true,
|
|
|
|
- children: (
|
|
|
|
- <ApprovalFlow
|
|
|
|
- executorList={processMap[state.activeKey]}
|
|
|
|
- matterList={matters}
|
|
|
|
- dataID={state.activeKey}
|
|
|
|
- defaultValue={transformToFlowNodes(state.process)}
|
|
|
|
- // defaultValue={mockNodes}
|
|
|
|
- />
|
|
|
|
- )
|
|
|
|
- })
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- )
|
|
|
|
|
|
+ drawer.open({
|
|
|
|
+ title: state.subjectName,
|
|
|
|
+ destroyOnClose: true,
|
|
|
|
+ children: (
|
|
|
|
+ <ApprovalFlow
|
|
|
|
+ executorList={executorMap[state.activeKey]}
|
|
|
|
+ matterList={matterMap[state.activeKey]}
|
|
|
|
+ dataID={state.activeKey}
|
|
|
|
+ defaultValue={transformToFlowNodes(state.process.detail)}
|
|
|
|
+ // defaultValue={mockNodes}
|
|
|
|
+ />
|
|
|
|
+ )
|
|
|
|
+ })
|
|
}
|
|
}
|
|
return (
|
|
return (
|
|
<PageContainer title={false}>
|
|
<PageContainer title={false}>
|
|
@@ -115,11 +119,10 @@ const Step: React.FC<StepProps> = ({ processMap, conditionSchema, dispatch }) =>
|
|
<LeftMenu title="业务主体" onChange={handleMenuChange} />
|
|
<LeftMenu title="业务主体" onChange={handleMenuChange} />
|
|
<div className="w-6/7 ml-8 bg-white rounded-20px">
|
|
<div className="w-6/7 ml-8 bg-white rounded-20px">
|
|
<ProTable
|
|
<ProTable
|
|
- manualRequest
|
|
|
|
- actionRef={actionRef}
|
|
|
|
- params={params}
|
|
|
|
columns={columns}
|
|
columns={columns}
|
|
search={false}
|
|
search={false}
|
|
|
|
+ rowKey="ID"
|
|
|
|
+ dataSource={state.process.list}
|
|
toolbar={{
|
|
toolbar={{
|
|
actions: [
|
|
actions: [
|
|
<Button key="step-config" type="primary" onClick={handleBtnClick}>
|
|
<Button key="step-config" type="primary" onClick={handleBtnClick}>
|
|
@@ -127,18 +130,6 @@ const Step: React.FC<StepProps> = ({ processMap, conditionSchema, dispatch }) =>
|
|
</Button>
|
|
</Button>
|
|
]
|
|
]
|
|
}}
|
|
}}
|
|
- request={async params => {
|
|
|
|
- const {
|
|
|
|
- code,
|
|
|
|
- data: { subjectName, process = [], processList = [] }
|
|
|
|
- } = await queryApprovalDetail(params)
|
|
|
|
- setState({ ...state, process, subjectName })
|
|
|
|
- return {
|
|
|
|
- total: processList.length,
|
|
|
|
- data: processList,
|
|
|
|
- success: code === consts.RET_CODE.SUCCESS
|
|
|
|
- }
|
|
|
|
- }}
|
|
|
|
/>
|
|
/>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
@@ -148,6 +139,7 @@ const Step: React.FC<StepProps> = ({ processMap, conditionSchema, dispatch }) =>
|
|
}
|
|
}
|
|
|
|
|
|
export default connect(({ business }: { business: BusinessModelState }) => ({
|
|
export default connect(({ business }: { business: BusinessModelState }) => ({
|
|
- processMap: business.processMap,
|
|
|
|
|
|
+ executorMap: business.executorMap,
|
|
|
|
+ matterMap: business.matterMap,
|
|
conditionSchema: business.conditionSchema
|
|
conditionSchema: business.conditionSchema
|
|
}))(Step)
|
|
}))(Step)
|