lanjianrong 3 years atrás
parent
commit
5f28c2ac1d

+ 1 - 1
config/config.ts

@@ -22,7 +22,7 @@ export default defineConfig({
   mfsu: {},
   fastRefresh: true,
   unocss: {
-    watch: ['src/*.{jsx,tsx,less}', 'src/pages/**/*.{jsx,tsx,less}', 'src/components/**/*.{jsx,tsx,less}'] // 添加其他包含 unocss 的 classname 的文件目录
+    watch: ['src/pages/**/*.{jsx,tsx,less}', 'src/components/**/*.{jsx,tsx,less}'] // 添加其他包含 unocss 的 classname 的文件目录
   },
   // Fast Refresh 热更新
   theme: {},

+ 25 - 65
src/pages/Business/ProcessUser/index.tsx

@@ -61,8 +61,19 @@ const ProcessUser = props => {
 
   const { run: tryApprovalAccountDetail } = useRequest(queryApprovalAccountDetail, {
     manual: true,
-    onSuccess: result => {
-      setState({ ...state, approvalAccountDetail: result })
+    onSuccess: (result: API.ApprovalAccountDetail[]) => {
+      setState({
+        ...state,
+        approvalAccountDetail:
+          result?.reduce((prev, curr) => {
+            const obj = { ...prev }
+            obj[curr.name] = {
+              [`${curr.name}InstitutionID`]: curr.institutionID,
+              [`${curr.name}AccountIDs`]: curr.accountIDs
+            }
+            return obj
+          }, {}) || []
+      })
     }
   })
 
@@ -97,53 +108,7 @@ const ProcessUser = props => {
   }, [])
 
   const form = createForm({
-    initialValues: {
-      receiver: {
-        receiverInstitutionID: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'receiver')
-          .map(item => item.institutionID)
-          .toString(),
-        receiverAccountIDs: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'receiver')
-          .reduce(item => item.accountIDs).accountIDs
-      },
-      fgLeader: {
-        fgLeaderInstitutionID: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'fgLeader')
-          .map(item => item.institutionID)
-          .toString(),
-        fgLeaderAccountIDs: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'fgLeader')
-          .reduce(item => item.accountIDs).accountIDs
-      },
-      zxLeader: {
-        zxLeaderInstitutionID: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'zxLeader')
-          .map(item => item.institutionID)
-          .toString(),
-        zxLeaderAccountIDs: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'zxLeader')
-          .reduce(item => item.accountIDs).accountIDs
-      },
-      post: {
-        postInstitutionID: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'post')
-          .map(item => item.institutionID)
-          .toString(),
-        postAccountIDs: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'post')
-          .reduce(item => item.accountIDs).accountIDs
-      },
-      archive: {
-        archiveInstitutionID: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'archive')
-          .map(item => item.institutionID)
-          .toString(),
-        archiveAccountIDs: state.approvalAccountDetail.data
-          ?.filter(item => item.name === 'archive')
-          .reduce(item => item.accountIDs).accountIDs
-      }
-    },
+    initialValues: {},
     effects() {
       onFieldReact('receiver.receiverInstitutionID', async field => {
         if (!field.dataSource?.length) {
@@ -249,19 +214,14 @@ const ProcessUser = props => {
     }
   })
 
-  const onFinish = values => {
-    trysaveApprovalAccount({
-      archiveAccountIDs: values.archive.archiveAccountIDs,
-      archiveInstitutionID: values.archive.archiveInstitutionID,
-      fgLeaderAccountIDs: values.fgLeader.fgLeaderAccountIDs,
-      fgLeaderInstitutionID: values.fgLeader.fgLeaderInstitutionID,
-      postAccountIDs: values.post.postAccountIDs,
-      postInstitutionID: values.post.postInstitutionID,
-      receiverAccountIDs: values.receiver.receiverAccountIDs,
-      receiverInstitutionID: values.receiver.receiverInstitutionID,
-      zxLeaderAccountIDs: values.zxLeader.zxLeaderAccountIDs,
-      zxLeaderInstitutionID: values.zxLeader.zxLeaderInstitutionID
-    })
+  const onFinish = (values: Record<string, any>) => {
+    const keys = Object.keys(values)
+    const params = keys.reduce((prev, curr) => {
+      const obj = { ...prev, ...values[curr] }
+      return obj
+    }, {})
+
+    trysaveApprovalAccount(params)
   }
   return (
     <PageContainer title={false}>
@@ -276,11 +236,11 @@ const ProcessUser = props => {
           <div className="flex flex-row mb-5 w-full text-xl">流程用户设置</div>
           <div className="max-w-800px">
             <div className="w-600px">
-              <Form form={form} labelCol={12}>
+              <Form form={form} labelCol={8} wrapperCol={16}>
                 <SchemaField schema={schema} />
-                <FormButtonGroup className="ml-150px">
+                <FormButtonGroup.Sticky className="ml-100px">
                   <Submit onSubmit={onFinish}>提交</Submit>
-                </FormButtonGroup>
+                </FormButtonGroup.Sticky>
               </Form>
             </div>
           </div>

+ 5 - 5
src/pages/Business/ProcessUser/schema.ts

@@ -24,7 +24,7 @@ export const schema = {
               'x-component': 'Select',
               'x-validator': [],
               'x-component-props': {
-                style: { width: '150px' }
+                // style: { width: '150px' }
               },
               'x-decorator-props': {},
               name: 'receiverInstitutionID',
@@ -80,7 +80,7 @@ export const schema = {
               'x-component': 'Select',
               'x-validator': [],
               'x-component-props': {
-                style: { width: '150px' }
+                // style: { width: '150px' }
               },
               'x-decorator-props': {},
               name: 'fgLeaderInstitutionID',
@@ -134,7 +134,7 @@ export const schema = {
               'x-component': 'Select',
               'x-validator': [],
               'x-component-props': {
-                style: { width: '150px' }
+                // style: { width: '150px' }
               },
               'x-decorator-props': {},
               name: 'zxLeaderInstitutionID',
@@ -189,7 +189,7 @@ export const schema = {
               'x-component': 'Select',
               'x-validator': [],
               'x-component-props': {
-                style: { width: '150px' }
+                // style: { width: '150px' }
               },
               'x-decorator-props': {},
               name: 'postInstitutionID',
@@ -244,7 +244,7 @@ export const schema = {
               'x-component': 'Select',
               'x-validator': [],
               'x-component-props': {
-                style: { width: '150px' }
+                // style: { width: '150px' }
               },
               'x-decorator-props': {},
               name: 'archiveInstitutionID',