Просмотр исходного кода

fix: 事项列表数据同步问题

lanjianrong 2 лет назад
Родитель
Сommit
4fd72d4267

+ 3 - 3
src/pages/Business/Matter/components/AssemblyDetail.tsx

@@ -22,9 +22,9 @@ export enum Assembly {
 }
 
 export const assemblyToMap = {
-  [Assembly.FORM]: { name: '表单', type: '通用型' },
-  [Assembly.COSTPROFILE]: { name: '送审资料', type: '唯一型' },
-  [Assembly.DATAPROFILE]: { name: '造价文件', type: '唯一型' }
+  [Assembly.FORM]: { name: '表单', type: '通用型', permKey: 'formPermission' },
+  [Assembly.COSTPROFILE]: { name: '送审资料', type: '唯一型', permKey: 'costPermission' },
+  [Assembly.DATAPROFILE]: { name: '造价文件', type: '唯一型', permKey: 'profilePermission' }
 }
 
 type AssemblyDetailProps = {

+ 6 - 3
src/pages/Business/Matter/hooks/useRowScript.tsx

@@ -3,7 +3,7 @@ import type { ModalAction } from '@/components/Modal'
 import { message, Modal } from 'antd'
 import { addMatter, delMatter, queryMatterTree, updateMatter } from '@/services/api/business'
 import { useState } from 'react'
-import { useRequest } from '@umijs/max'
+import { useDispatch, useRequest } from '@umijs/max'
 import consts from '@/utils/consts'
 import { flatMapDeep } from 'lodash'
 
@@ -22,8 +22,8 @@ interface IState {
 }
 
 export function useRowScript(modal: ModalAction, dataID: string) {
-  // const [rowKeys, setRowKeys] = useState<string[]>([])
   const [state, setState] = useState<IState>({})
+  const dispatch = useDispatch()
   const {
     data,
     run: query,
@@ -42,7 +42,10 @@ export function useRowScript(modal: ModalAction, dataID: string) {
           rowKeys: flatMapDeep(data, (item: API.MatterTreeItem) => [item.ID]) || [],
           record: null
         })
-        // setRowKeys(flatMapDeep(data, (item: API.MatterTreeItem) => [item.ID]))
+        dispatch({
+          type: 'business/updateMatterMap',
+          payload: { ID: dataID, list: data }
+        })
       }
     }
   )

+ 18 - 27
src/pages/Business/Step/components/Flow/components/Drawer/Auditor/MatterPermission.tsx

@@ -1,18 +1,7 @@
+import { Assembly, assemblyToMap } from '@/pages/Business/Matter/components/AssemblyDetail'
 import { Card, Checkbox } from 'antd'
 import { flatMapDeep } from 'lodash'
 
-export enum MatterPerm {
-  FORM = 'formPermission',
-  COST = 'costPermission',
-  PROFILE = 'profilePermission'
-}
-
-const matterPermMap = {
-  [MatterPerm.FORM]: '表单',
-  [MatterPerm.COST]: '造价文件',
-  [MatterPerm.PROFILE]: '资料清单'
-}
-
 type MatterPermissionProps = {
   defaultValue: {
     matterID: string
@@ -25,7 +14,7 @@ type MatterPermissionProps = {
 }
 
 const MatterPermission: React.FC<MatterPermissionProps> = ({ defaultValue, toggleMatter, matterList }) => {
-  const matterFlattenList = flatMapDeep(matterList, item => [item, ...item.children])
+  const matterFlattenList = flatMapDeep(matterList, item => [item, ...(item?.children || [])])
   return (
     <div
       style={{ maxHeight: document.querySelector('body')?.clientHeight - 186 }}
@@ -36,21 +25,23 @@ const MatterPermission: React.FC<MatterPermissionProps> = ({ defaultValue, toggl
           size="small"
           className="mb-2!"
           title={matterFlattenList.find(item => item.ID === matter.matterID)?.name}>
-          {[MatterPerm.COST, MatterPerm.FORM, MatterPerm.PROFILE].map(item => (
-            <div key={item} className="flex justify-between items-center my-1">
-              <div className="flex-1">{matterPermMap[item]}</div>
-              <div className="w-40">
-                <Checkbox.Group
-                  defaultValue={matter[item]}
-                  options={[
-                    { label: '查看', value: 'view' },
-                    { label: '编辑', value: 'edit' }
-                  ]}
-                  onChange={checkedValue => toggleMatter(matter.matterID, { [item]: checkedValue })}
-                />
+          {matterFlattenList
+            .find(item => item.ID === matter.matterID)
+            ?.assembly?.map((item: Assembly) => (
+              <div key={item} className="flex justify-between items-center my-1">
+                <div className="flex-1">{assemblyToMap[item].name}</div>
+                <div className="w-40">
+                  <Checkbox.Group
+                    defaultValue={matter[assemblyToMap[item].permKey]}
+                    options={[
+                      { label: '查看', value: 'view' },
+                      { label: '编辑', value: 'edit' }
+                    ]}
+                    onChange={checkedValue => toggleMatter(matter.matterID, { [item]: checkedValue })}
+                  />
+                </div>
               </div>
-            </div>
-          ))}
+            ))}
         </Card>
       ))}
     </div>

+ 1 - 1
src/pages/Business/Step/components/Flow/components/Drawer/Auditor/RelatedMatter.tsx

@@ -19,7 +19,7 @@ const RelatedMatter: React.FC<RelatedMatterpProps> = ({ defaultValue, matterList
       title: '执行中',
       align: 'center',
       render: (_, record) => {
-        if (record?.children) return null
+        if (!record?.parentID) return null
         return (
           <Checkbox
             defaultChecked={defaultValue.includes(record.ID)}

+ 1 - 1
src/pages/Business/Step/index.tsx

@@ -110,7 +110,7 @@ const Step: React.FC<StepProps> = ({ executorMap, matterMap, conditionSchema, di
     }
   ]
 
-  const handleBtnClick = async () => {
+  const handleBtnClick = () => {
     drawer.open({
       title: state.subjectName,
       destroyOnClose: true,