Forráskód Böngészése

refactor: 主体subjectID批量改成gatherID+事项设置不完善代码

outaozhen 3 éve
szülő
commit
3dd4b4aa24

+ 2 - 2
src/pages/Business/Inventory/index.tsx

@@ -97,8 +97,8 @@ const Inventory = () => {
   ]
 
   const handleMenuOnChange = (key: string) => {
-    const [subjectID, businessType] = key.split('_')
-    query({ subjectID, businessType })
+    const [gatherID, businessType] = key.split('_')
+    query({ gatherID, businessType })
   }
   return (
     <PageContainer title={false}>

+ 7 - 13
src/pages/Business/Matter/components/AddAssemblyModal.tsx

@@ -1,6 +1,6 @@
 import { CodepenSquareFilled, ProfileFilled, SlackSquareFilled } from '@ant-design/icons'
 import { Button, Card, Checkbox, Col, Row } from 'antd'
-import React, { useEffect, useState } from 'react'
+import React, { useState } from 'react'
 import { AssemblyEnum } from './AssemblyDetail'
 
 type AddAssemblyProps = {
@@ -8,27 +8,21 @@ type AddAssemblyProps = {
 }
 
 const AddAssemblyModal: React.FC<AddAssemblyProps> = ({ record, onChange }) => {
-  const assembly = record?.assembly
-  const [assemblyList, setAssemblyList] = useState([])
-  console.log(assemblyList)
+  const [assemblyList, setAssemblyList] = useState(record?.assembly || [])
 
   const handleAssemblyOnchange = (checked: boolean, checkName: string) => {
+    let newAssemblyList
     if (checked) {
-      setAssemblyList([...assemblyList, checkName])
+      newAssemblyList = [...assemblyList, checkName]
     } else {
-      setAssemblyList(assemblyList.filter(item => item !== checkName))
+      newAssemblyList = assemblyList.filter(item => item !== checkName)
     }
+    setAssemblyList(newAssemblyList)
     if (onChange) {
-      onChange(checkName)
+      onChange(newAssemblyList)
     }
   }
 
-  useEffect(() => {
-    if (assembly?.length) {
-      setAssemblyList(...assemblyList, assembly)
-    }
-  }, [assembly?.length])
-
   return (
     <Row gutter={16}>
       <Col span={8}>

+ 32 - 20
src/pages/Business/Matter/index.tsx

@@ -14,25 +14,25 @@ import { updateAssembly } from '@/services/api/business'
 
 interface IState {
   subjectParams: {
-    subjectID?: Nullable<string>
+    gatherID?: Nullable<string>
     businessType?: Nullable<string>
   }
   expandTreeIds: []
-  assembly: []
+  assemblyArr: []
 }
 
 const Matter: React.FC = () => {
   const [drawer, DrawerDom] = useDrawer()
   const [state, setState] = useState<IState>({
     subjectParams: {
-      subjectID: '',
+      gatherID: '',
       businessType: ''
     },
-    expandTreeIds: []
+    expandTreeIds: [],
+    assemblyArr: []
   })
 
-  const [assemblyArr, setAssemblyArr] = useState([])
-  console.log(assemblyArr)
+  // const [assemblyArr, setAssemblyArr] = useState([])
 
   const contentHeight = document.body.clientHeight - 122
   const [modal, ModalDOM] = useModal()
@@ -47,8 +47,22 @@ const Matter: React.FC = () => {
     expandTreeIds = []
   } = useRowScript(modal)
 
-  const handleChange = (checkName: string) => {
-    setAssemblyArr([...assemblyArr, checkName])
+  const handleOnok = async (assemblyList, record) => {
+    console.log(record?.ID)
+    if (record?.ID) {
+      const { code = -1 } = await updateAssembly({ ID: record?.ID, assembly: assemblyList })
+      if (code === consts.RET_CODE.SUCCESS) {
+        message.success('添加成功')
+        modal.close()
+        refresh()
+      }
+    }
+    return
+  }
+
+  const handleChange = (assemblyList: string[], record) => {
+    setState({ ...state, assemblyArr: assemblyList })
+    handleOnok(assemblyList, record)
   }
 
   const openDrawer = record => {
@@ -63,15 +77,13 @@ const Matter: React.FC = () => {
               okText: '确认',
               cancelText: '取消',
               width: 1000,
-              children: <AddAssemblyModal record={record} onChange={checkName => handleChange(checkName)} />,
-              onOk: async () => {
-                const { code = -1 } = await updateAssembly({ ID: record.ID, assembly: assemblyArr })
-                if (code === consts.RET_CODE.SUCCESS) {
-                  message.success('添加成功')
-                  modal.close()
-                  refresh()
-                }
-              }
+              children: (
+                <AddAssemblyModal
+                  record={record}
+                  onChange={assemblyList => handleChange(assemblyList, record)}
+                />
+              ),
+              onOk: handleOnok()
             })
           }}>
           添加组件
@@ -136,9 +148,9 @@ const Matter: React.FC = () => {
   ]
 
   const handleMenuOnChange = (key: string) => {
-    const [subjectID, businessType] = key.split('_')
-    setState({ ...state, subjectParams: { ...state.subjectParams, subjectID, businessType } })
-    query({ subjectID, businessType })
+    const [gatherID, businessType] = key.split('_')
+    setState({ ...state, subjectParams: { ...state.subjectParams, gatherID, businessType } })
+    query({ gatherID, businessType })
   }
 
   return (

+ 6 - 6
src/pages/Business/Process/hooks/useScripts.tsx

@@ -58,12 +58,12 @@ export default function useScripts(modal: ModalAction, subject: string) {
   } = useRequest(queryExecutorList, {
     manual: true,
     onSuccess: (result, params) => {
-      const { subjectID, businessType } = params[0]
+      const { gatherID, businessType } = params[0]
       seState({ total: result.data.total })
       dispatch({
         type: 'business/updateProcessMap',
         payload: {
-          ID: `${subjectID}_${businessType}`,
+          ID: `${gatherID}_${businessType}`,
           process: result.data.items
         }
       })
@@ -73,9 +73,9 @@ export default function useScripts(modal: ModalAction, subject: string) {
   const { data: { data: { items: matters = [] } = {} } = {} } = useRequest(
     () => {
       if (!subject) return
-      const [subjectID, businessType] = subject.split('_')
+      const [gatherID, businessType] = subject.split('_')
 
-      return queryMatterList({ subjectID, businessType, pageSize: 214000, matterType: 'matter' })
+      return queryMatterList({ gatherID, businessType, pageSize: 214000, matterType: 'matter' })
     },
     { refreshDeps: [subject] }
   )
@@ -129,8 +129,8 @@ export default function useScripts(modal: ModalAction, subject: string) {
         </ProForm>
       ),
       onOk: async (values: API.ExecutorItem) => {
-        const [subjectID, businessType] = subject.split('_')
-        values.subjectID = subjectID
+        const [gatherID, businessType] = subject.split('_')
+        values.gatherID = gatherID
         values.businessType = businessType
         let requestFn: Nullable<() => Promise<viod>> = null
         if (mode === 'add') {

+ 2 - 2
src/pages/Business/Process/index.tsx

@@ -84,10 +84,10 @@ const Process: React.FC<ProcessProps> = ({ processMap }) => {
   ]
 
   const handleMenuOnChange = (key: string) => {
-    const [subjectID, businessType] = key.split('_')
+    const [gatherID, businessType] = key.split('_')
     setState({ ...state, activeKey: key })
     startTransition(() => {
-      !processMap?.[state.activeKey] && query({ subjectID, businessType, pageSize: 214000 })
+      !processMap?.[state.activeKey] && query({ gatherID, businessType, pageSize: 214000 })
     })
   }
   return (

+ 6 - 6
src/pages/Business/RuleCode/index.tsx

@@ -175,8 +175,8 @@ const RulesCode = () => {
     manual: true,
     onSuccess: () => {
       message.success('规则更改成功')
-      const [subjectID, businessType] = state.activeKey.split('_')
-      tryQueryRuleCode({ businessType, subjectID })
+      const [gatherID, businessType] = state.activeKey.split('_')
+      tryQueryRuleCode({ businessType, gatherID })
     }
   })
 
@@ -213,10 +213,10 @@ const RulesCode = () => {
   }
 
   const ruleCodeHandler = () => {
-    const [subjectID, businessType] = state.activeKey.split('_')
+    const [gatherID, businessType] = state.activeKey.split('_')
     tryUpdateRuleCode({
       businessType,
-      subjectID,
+      gatherID,
       connector: state.connector,
       rules: ruleArr.map(item => {
         if (item.type === RuleOptionEunm.CURRENTYEAR || item.type === RuleOptionEunm.CURRENTMONTH) {
@@ -247,13 +247,13 @@ const RulesCode = () => {
     ) : null
 
   const handleMenuChange = (key: string, option: { key: string; label: string }) => {
-    const [subjectID, businessType] = key.split('_')
+    const [gatherID, businessType] = key.split('_')
     setState({
       ...state,
       activeKey: key,
       option: option
     })
-    tryQueryRuleCode({ businessType, subjectID })
+    tryQueryRuleCode({ businessType, gatherID })
   }
   return (
     <PageContainer title={false}>

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

@@ -33,17 +33,17 @@ const Step: React.FC<StepProps> = ({ processMap, dispatch }) => {
 
   useEffect(() => {
     if (state.activeKey) {
-      const [subjectID, businessType] = state.activeKey.split('_')
+      const [gatherID, businessType] = state.activeKey.split('_')
       dispatch({
         type: 'business/queryExecutor',
-        payload: { subjectID, businessType, pageSize: 214000 }
+        payload: { gatherID, businessType, pageSize: 214000 }
       })
     }
   }, [state.activeKey])
   const params = useMemo(() => {
     if (!state.activeKey) return {}
-    const [subjectID, businessType] = state.activeKey.split('_')
-    return { subjectID, businessType }
+    const [gatherID, businessType] = state.activeKey.split('_')
+    return { gatherID, businessType }
   }, [state.activeKey])
 
   const handleMenuChange = (key: string, option) => {
@@ -51,7 +51,7 @@ const Step: React.FC<StepProps> = ({ processMap, dispatch }) => {
 
     setState({ ...state, activeKey: key })
     actionRef.current?.reload()
-    // const [subjectID, businessType] = key.split('_')
+    // const [gatherID, businessType] = key.split('_')
     //
   }
   const columns: ProColumns = [
@@ -73,8 +73,8 @@ const Step: React.FC<StepProps> = ({ processMap, dispatch }) => {
   ]
 
   const handleBtnClick = async () => {
-    const [subjectID, businessType] = state.activeKey.split('_')
-    queryMatterList({ subjectID, businessType, pageSize: 214000, matterType: 'matter' }).then(
+    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({

+ 2 - 2
src/pages/Business/model.ts

@@ -62,11 +62,11 @@ const BusinessModel: BusinessModelType = {
     *queryExecutor({ payload }, { call, put }) {
       const response = yield call(queryExecutorList, payload)
       if (response?.code === consts.RET_CODE.SUCCESS) {
-        const { subjectID, businessType } = payload
+        const { gatherID, businessType } = payload
         yield put({
           type: 'saveProcessMap',
           payload: {
-            ID: `${subjectID}_${businessType}`,
+            ID: `${gatherID}_${businessType}`,
             process: response.data.items
           }
         })

+ 8 - 6
src/services/api/business.ts

@@ -2,7 +2,7 @@ import { BusinessType } from '@/enums/gc'
 import { request } from '@umijs/max'
 
 /** 清单模板 列表 */
-export async function queryProfileTemplateList(params: { businessType: BusinessType; subjectID: string }) {
+export async function queryProfileTemplateList(params: { businessType: BusinessType; gatherID: string }) {
   return request<API.ProfileTemplateItem[]>('/form/v1/profile/template/list', { params })
 }
 
@@ -57,7 +57,7 @@ export async function moveTemplate(params: { ID: string; moveID: string }) {
 }
 
 /** 编号规则生成器查询详情 */
-export async function queryRuleCodeList(params: { tab: string; subjectID: string }) {
+export async function queryRuleCodeList(params: { tab: string; gatherID: string }) {
   return request('/RuleCode/detail', {
     method: 'GET',
     params
@@ -74,7 +74,7 @@ export async function updateRuleCode(params: API.RuleCodeUpdateParams) {
 
 /** 获取执行者列表 */
 export async function queryExecutorList(params: {
-  subjectID: string
+  gatherID: string
   businessType: BusinessType
   pageSize: number
 }) {
@@ -109,7 +109,7 @@ export async function delExecutor(params: { ID: string }) {
 
 /** 获取事项列表 */
 export async function queryMatterList(params: {
-  subjectID: string
+  gatherID: string
   businessType: BusinessType
   pageSize: number
   /** category分类  matter事项 不传获得全部  */
@@ -122,7 +122,7 @@ export async function queryMatterList(params: {
 
 /** 获取事项树 */
 export async function queryMatterTree(params: {
-  subjectID: string
+  gatherID: string
   businessType: BusinessType
   pageSize: number
 }) {
@@ -156,7 +156,9 @@ export async function delMatter(params: { ID: string }) {
 }
 
 /** 保存事项组件 */
-export async function updateAssembly(params: { ID: string }) {
+export async function updateAssembly(params) {
+  console.log(params)
+
   return request('/Matter/updateAssembly', {
     method: 'POST',
     data: params

+ 1 - 1
src/services/api/project.ts

@@ -105,7 +105,7 @@ export async function setProjectPersonor(params: { ID: string; createdID: string
 }
 
 /** 审批流程-详情 */
-export async function queryApprovalDetail(params: { subjectID: string; businessType: string }) {
+export async function queryApprovalDetail(params: { gatherID: string; businessType: string }) {
   return request('/approval/detail', {
     params
   })

+ 1 - 1
src/services/api/subject.ts

@@ -25,7 +25,7 @@ export async function delSubject(params: API.DelSubjectParams) {
 }
 
 /** 获取步骤详情 */
-export async function queryParticipant(params: { subjectID: string; stepID: string }) {
+export async function queryParticipant(params: { gatherID: string; stepID: string }) {
   return request('/approval/participant', {
     params
   })

+ 3 - 3
src/services/api/typings.d.ts

@@ -408,7 +408,7 @@ declare namespace API {
 
   type RuleCodeParams = {
     tab: string
-    subjectID: string
+    gatherID: string
   }
 
   type ExecutorItem = {
@@ -483,7 +483,7 @@ declare namespace API {
 
   type MatterTreeItem = {
     ID?: string
-    subjectID?: string
+    gatherID?: string
     matterType?: 'category' | 'matter'
     businessType?: string
     parentID?: string
@@ -496,7 +496,7 @@ declare namespace API {
 
   type MatterItem = Omit<MatterTreeItem, 'children'>
 
-  type AddMatterParams = Pick<MatterTreeItem, 'subjectID' | 'businessType' | 'matterType' | 'name'>
+  type AddMatterParams = Pick<MatterTreeItem, 'gatherID' | 'businessType' | 'matterType' | 'name'>
 
   type UpdateMatterParams = Pick<MatterTreeItem, 'ID' | 'parentID' | 'name'>