Explorar el Código

feat: 合同管理-初次选择模板未选择模板关闭按钮跳转概括页

lanjianrong hace 4 años
padre
commit
3314fe47c0

+ 18 - 9
src/pages/Contract/Content/Income/components/TableContent/index.tsx

@@ -23,10 +23,12 @@ interface iTableContentPorps {
   changeModalType: (type: string) => void
   row: iIncomeTree
   setRow: (record: iIncomeTree) => void
+  history: any
 }
 
 
-const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow }) => {
+const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, history }) => {
+
   const [ sectionTemplate, setSectionTemplate ] = useState<iShowTemplateState>({
     isShow: false,
     template: '',
@@ -63,9 +65,9 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
   const { TabPane } = Tabs
 
   useEffect(() => {
-    initHandler()
+    initData()
   }, [])
-  const initHandler = async () => {
+  const initData = async () => {
     const data  = await apiContractIncome(tenderStore.bid)
     if (data.code === consts.RET_CODE.SUCCESS) {
       if (data.isTemplate && data.isTemplate === 1) {
@@ -83,13 +85,13 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
       }
     }
   }
-  interface iLabelHandlerProps {
+  interface HandleLabelProps {
     id: string
     bidsectionId: string
     name?: string
   }
 
-  const newLabelHandler = async (type: string, payload: iLabelHandlerProps) => {
+  const handleNewLabel = async (type: string, payload: HandleLabelProps) => {
     let RET_CODE: number = -1
     if (type === 'create') {
       payload.name = inputEl.current?.state.value
@@ -109,7 +111,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
   const codeChange = async (row: iIncomeTree, value: string) => {
     const { code = -1 } = await apiUpdateSerial(row.id, row.bidsectionId, value)
     if (code === consts.RET_CODE.SUCCESS) {
-      initHandler()
+      initData()
     }
   }
   const inputEl = useRef<Input>(null)
@@ -165,8 +167,8 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
             size="small"
             type="text"
             ref={inputEl}
-            onPressEnter={() => newLabelHandler(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
-            onBlur={() => newLabelHandler(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
+            onPressEnter={() => handleNewLabel(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
+            onBlur={() => handleNewLabel(type, { id: type === 'edit' ? record.id : record.parentId, bidsectionId: record.bidsectionId })}
             />)
         } else {
           return <span>{text}</span>
@@ -219,7 +221,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
     }
     const { code = -1 } = await apiSetTemplate(sectionTemplate.template, tenderStore.tender.bidsectionId, 0)
     if (code === consts.RET_CODE.SUCCESS) {
-      await initHandler()
+      await initData()
     }
     setSectionTemplate({
       ...sectionTemplate,
@@ -227,6 +229,12 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
       isShow: false
     })
   }
+
+  // modal 关闭 - 回调
+  const handleModalCancel = () => {
+    history.push('/console/contract/content/summary')
+  }
+
   // 模板选择radio切换回调
   const handleRadioEvent = (e: RadioChangeEvent) => {
     if (e.target.checked) {
@@ -283,6 +291,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
     okText="确定"
     confirmLoading={sectionTemplate.loading}
     cancelText="关闭"
+    onCancel={handleModalCancel}
     closable={false}
     keyboard={false}
     onOk={() => handleModalConfirm()}

+ 7 - 2
src/pages/Contract/Content/Income/index.tsx

@@ -13,13 +13,16 @@ import { apiResfulContract, apiResfulContractTree } from './api'
 import ContractModal from './components/Modal'
 import TableContent from './components/TableContent'
 import Authorization from '@/components/Authorization'
+import { RouteComponentProps } from 'react-router'
 
 interface iModal {
   visible: boolean
   loading: boolean
 }
 
-export default function Income() {
+
+const Income: React.FC<RouteComponentProps> = ({ history }) => {
+
   const [ modalObj, setModalObj ] = useState<iModalBooleanProps>({
     type: '',
     visible: false,
@@ -180,7 +183,7 @@ export default function Income() {
           }
         </Slot>
       </Header>
-      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} />
+      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} history={history}/>
       <RuleModal
         type={consts.RULE.CONTRACT_RETURN}
         title="合同管理编号设置"
@@ -193,3 +196,5 @@ export default function Income() {
     </div>
   )
 }
+
+export default Income

+ 15 - 5
src/pages/Contract/Content/Spending/components/TableContent/index.tsx

@@ -23,10 +23,11 @@ interface iTableContentPorps {
   changeModalType: (type: string) => void
   row: iIncomeTree
   setRow: (record: iIncomeTree) => void
+  history: any
 }
 
 
-const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow }) => {
+const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, history }) => {
   const [ sectionTemplate, setSectionTemplate ] = useState<iShowTemplateState>({
     isShow: false,
     template: '',
@@ -63,9 +64,9 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
   const { TabPane } = Tabs
 
   useEffect(() => {
-    initHandler()
+    initData()
   }, [])
-  const initHandler = async () => {
+  const initData = async () => {
     const data  = await apiContractExpenditure(tenderStore.bid)
     if (data.code === consts.RET_CODE.SUCCESS) {
       if (data.isTemplate && data.isTemplate === 1) {
@@ -109,7 +110,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
   const codeChange = async (row: iIncomeTree, value: string) => {
     const { code = -1 } = await apiUpdateSerial(row.id, row.bidsectionId, value)
     if (code === consts.RET_CODE.SUCCESS) {
-      initHandler()
+      initData()
     }
   }
   const inputEl = useRef<Input>(null)
@@ -219,7 +220,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
     }
     const { code = -1 } = await apiSetTemplate(sectionTemplate.template, tenderStore.tender.bidsectionId, 1)
     if (code === consts.RET_CODE.SUCCESS) {
-      await initHandler()
+      await initData()
     }
     setSectionTemplate({
       ...sectionTemplate,
@@ -227,6 +228,14 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
       isShow: false
     })
   }
+
+
+  // modal 关闭 - 回调
+  const handleModalCancel = () => {
+    history.push('/console/contract/content/summary')
+  }
+
+
   // 模板选择radio切换回调
   const handleRadioEvent = (e: RadioChangeEvent) => {
     if (e.target.checked) {
@@ -283,6 +292,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow })
     okText="确定"
     confirmLoading={sectionTemplate.loading}
     cancelText="关闭"
+    onCancel={handleModalCancel}
     closable={false}
     keyboard={false}
     onOk={() => handleModalConfirm()}

+ 5 - 2
src/pages/Contract/Content/Spending/index.tsx

@@ -13,13 +13,14 @@ import React, { useState } from 'react'
 import { apiResfulContract, apiResfulContractTree } from './api'
 import ContractModal from '@/pages/Contract/Content/Income/components/Modal'
 import TableContent from './components/TableContent'
+import { RouteComponentProps } from 'react-router'
 
 interface iModal {
   visible: boolean
   loading: boolean
 }
 
-export default function Expenditure() {
+const Expenditure:React.FC<RouteComponentProps> = ({ history }) => {
   const [ modalObj, setModalObj ] = useState<iModalBooleanProps>({
     type: '',
     visible: false,
@@ -180,7 +181,7 @@ export default function Expenditure() {
           }
         </Slot>
       </Header>
-      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} />
+      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} history={history}/>
       <RuleModal
         type={consts.RULE.CONTRACT_PAID}
         title="合同管理编号设置"
@@ -193,3 +194,5 @@ export default function Expenditure() {
     </div>
   )
 }
+
+export default Expenditure

+ 3 - 0
src/types/router.d.ts

@@ -1,4 +1,5 @@
 import { RouteProps } from 'react-router'
+import * as H from 'history'
 interface RouteModel {
   path: string;
   component?: any;
@@ -40,6 +41,8 @@ interface NavigationGuardsProps extends RouteProps {
   // check: () => void
   // saveMatch: (path: string) => void
 }
+
+
 export {
   RouteModel,
   NavigationGuardsProps,