Преглед изворни кода

feat: 审核资料清单模板增加业务主体内容

outaozhen пре 3 година
родитељ
комит
658d1a58fa

+ 4 - 3
src/pages/Business/Inventory/hooks/useRowScript.tsx

@@ -82,7 +82,7 @@ export function useRowScript(modal: ModalAction) {
   const handleRowClick = (record: API.ProfileTemplateItem) => setState({ ...state, record })
 
   /** 新建目录 */
-  const addFolder = () => {
+  const addFolder = subjectParams => {
     modal.open({
       title: '新建目录',
       okText: '确认',
@@ -101,7 +101,7 @@ export function useRowScript(modal: ModalAction) {
         </ProForm>
       ),
       onOk: async (values: { name: string; parentID: string }) => {
-        const { code = -1 } = await createTemplateFolder(values)
+        const { code = -1 } = await createTemplateFolder({ ...values, ...subjectParams })
         if (code === consts.RET_CODE.SUCCESS) {
           message.success('新建目录成功')
           modal.close()
@@ -136,7 +136,7 @@ export function useRowScript(modal: ModalAction) {
   }
 
   /** 新建文件 */
-  const addFile = (mode?: 'add' | 'update' = 'add') => {
+  const addFile = (mode?: 'add' | 'update', subjectParams) => {
     modal.open({
       title: mode === 'add' ? '新增文件' : '编辑文件',
       okText: '确认',
@@ -190,6 +190,7 @@ export function useRowScript(modal: ModalAction) {
       onOk: async (values: any) => {
         const { code = -1 } = await saveTemplateFile({
           ...values,
+          ...subjectParams,
           required: !!values.required,
           enable: !!values.enable
         })

+ 23 - 3
src/pages/Business/Inventory/index.tsx

@@ -16,15 +16,29 @@ import {
 } from '@ant-design/icons'
 import LeftMenu from '../RuleCode/components/LeftMenu'
 import ProTable from '@ant-design/pro-table'
+import { useState } from 'react'
 
 export enum TemplateMode {
   PAPER = 'paper',
   UPLOAD = 'upload'
 }
 
+interface IState {
+  subjectParams: {
+    gatherID?: Nullable<string>
+    businessType?: Nullable<string>
+  }
+}
+
 const Inventory = () => {
   const contentHeight = document.body.clientHeight - 122
   const [modal, ModalDOM] = useModal()
+  const [state, setState] = useState<IState>({
+    subjectParams: {
+      gatherID: '',
+      businessType: ''
+    }
+  })
   const {
     query,
     loading,
@@ -99,6 +113,7 @@ const Inventory = () => {
   const handleMenuOnChange = (key: string) => {
     const [gatherID, businessType] = key.split('_')
     query({ gatherID, businessType })
+    setState({ ...state, subjectParams: { ...state.subjectParams, gatherID, businessType } })
   }
   return (
     <PageContainer title={false}>
@@ -111,7 +126,12 @@ const Inventory = () => {
             headerTitle={
               <div className="flex flex-nowrap justify-start items-center">
                 <div className="children:mx-1 px-1 py-2 ">
-                  <Button icon={<FolderAddOutlined />} size="small" type="primary" ghost onClick={addFolder}>
+                  <Button
+                    icon={<FolderAddOutlined />}
+                    size="small"
+                    type="primary"
+                    ghost
+                    onClick={() => addFolder(state.subjectParams)}>
                     新建目录
                   </Button>
                   <Button
@@ -119,7 +139,7 @@ const Inventory = () => {
                     size="small"
                     type="primary"
                     ghost
-                    onClick={() => addFile()}>
+                    onClick={() => addFile('add', state.subjectParams)}>
                     新建文件
                   </Button>
                   <Button
@@ -129,7 +149,7 @@ const Inventory = () => {
                     ghost
                     onClick={() => {
                       record?.folder && editFolder()
-                      !record?.folder && addFile('update')
+                      !record?.folder && addFile('update', state.subjectParams)
                     }}
                     disabled={!record}>
                     编辑