瀏覽代碼

feat: 步骤执行者抽出dva

outaozhen 3 年之前
父節點
當前提交
2df8e54915

+ 11 - 5
src/pages/Business/Process/index.tsx

@@ -6,6 +6,7 @@ import useScripts from './hooks/useScripts'
 import { Button } from 'antd'
 import ProTable, { ProColumnType } from '@ant-design/pro-table'
 import LeftMenu from '../RuleCode/components/LeftMenu'
+import { connect } from '@umijs/max'
 
 export const menuOptions = [{ label: '预算业务审批', value: BusinessType.BUDGET }]
 
@@ -13,12 +14,12 @@ type iProcessProps = {
   activeKey: BusinessType
 }
 
-const Process = () => {
+const Process = ({ dispatch, processList }) => {
   const [state, setState] = useState<iProcessProps>({
     activeKey: null
   })
   const [modal, ModalDOM] = useModal()
-  const { query, data, loading, addOrEdit, del } = useScripts(modal)
+  const { data, loading, addOrEdit, del } = useScripts(modal)
 
   const columns: ProColumnType<API.ExecutorItem>[] = [
     {
@@ -77,7 +78,10 @@ const Process = () => {
     const [subjectID, businessType] = key.split('_')
     setState({ ...state, activeKey: key })
     startTransition(() => {
-      query({ subjectID, businessType })
+      dispatch({
+        type: 'business/queryExecutor',
+        payload: { subjectID, businessType }
+      })
     })
   }
   return (
@@ -96,7 +100,7 @@ const Process = () => {
             rowKey="ID"
             search={false}
             columns={columns}
-            dataSource={data.items}
+            dataSource={processList}
             loading={loading}
             pagination={{ total: data.total }}
           />
@@ -107,4 +111,6 @@ const Process = () => {
   )
 }
 
-export default Process
+export default connect(({ business }: { processList: BusinessModelState }) => ({
+  processList: business.processList
+}))(Process)

+ 0 - 1
src/pages/Business/RuleCode/components/LeftMenu/index.tsx

@@ -25,7 +25,6 @@ const LeftMenu: React.FC<LeftMenuProps> = ({ title = '业务主体列表', onCha
     activeKey: null,
     selectedKeysValue: ''
   })
-  console.log(state.activeKey)
 
   const handleOnSelect = ({ key }) => {
     const [value, label] = key.split('_')

+ 17 - 1
src/pages/Business/model.ts

@@ -1,5 +1,6 @@
 // import { getProjectTypeList } from '@/services/api/project'
 // import consts from '@/utils/consts'
+import { queryExecutorList } from '@/services/api/business'
 import { queryInstitutionList } from '@/services/api/institution'
 import { querySubjectList } from '@/services/api/subject'
 import consts from '@/utils/consts'
@@ -7,6 +8,8 @@ import type { Effect, Reducer } from '@umijs/max'
 
 export interface BusinessModelState {
   institutionList: API.InstitutionList[]
+  subjectList: API.SubjectParams[]
+  processList: API.ExecutorItem[]
 }
 
 export interface BusinessModelType {
@@ -15,6 +18,7 @@ export interface BusinessModelType {
   effects: {
     queryInstitution: Effect
     querySubject: Effect
+    queryExecutor: Effect
   }
   reducers: {
     save: Reducer<BusinessModelState>
@@ -27,7 +31,8 @@ const BusinessModel: BusinessModelType = {
   namespace: 'business',
   state: {
     institutionList: [],
-    subjectList: []
+    subjectList: [],
+    processList: []
   },
   effects: {
     *queryInstitution({ payload }, { call, put }) {
@@ -51,6 +56,17 @@ const BusinessModel: BusinessModelType = {
           }
         })
       }
+    },
+    *queryExecutor({ payload }, { call, put }) {
+      const response = yield call(queryExecutorList, payload)
+      if (response?.code === consts.RET_CODE.SUCCESS) {
+        yield put({
+          type: 'save',
+          payload: {
+            processList: response.data.items
+          }
+        })
+      }
     }
   },
   reducers: {