Sfoglia il codice sorgente

feat: 回款状态发生变化,项目节、合同详情数据自动刷新

lanjianrong 4 anni fa
parent
commit
cd03196688

+ 8 - 3
src/pages/Contract/Content/Income/components/TableContent/index.tsx

@@ -69,6 +69,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
     initData()
   }, [])
   const initData = async () => {
+
     const data = await apiContractIncome(tenderStore.bid)
     if (data.code === consts.RET_CODE.SUCCESS) {
       if (data.isTemplate && data.isTemplate === 1) {
@@ -85,6 +86,10 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
         contractReturnStore.updateTree(data.sectionTree.children)
       }
     }
+    // 初始化时如果id存在说明只是table更新了,那么要将store里面的合同数据也一起更新,防止合同详情不是最新的数据
+    if (row.id) {
+      handleRowClick(row.id, row.bidsectionId)
+    }
   }
   interface HandleLabelProps {
     id: string
@@ -256,7 +261,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
   const onClickRow = (record: iIncomeTree) => {
     return {
       onClick() {
-        rowClickHandler(record.id, record.bidsectionId, record.isEdit, record.isNew)
+        handleRowClick(record.id, record.bidsectionId, record.isEdit, record.isNew)
       },
       onDoubleClick() {
         contractReturnStore.rowChange(row.id)
@@ -265,7 +270,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
   }
 
   // 行点击回调
-  const rowClickHandler = async (id: string, bid: string, isEdit?: boolean, isNew?: boolean) => {
+  const handleRowClick = async (id: string, bid: string, isEdit?: boolean, isNew?: boolean) => {
     if (!isEdit && !isNew) {
       const { code = -1, section = {}, contract: newContract = {} } = await apiGetIncome(id, bid)
       if (code === consts.RET_CODE.SUCCESS) {
@@ -412,7 +417,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
             <Detail {...contractReturnStore.contract} />
           </TabPane>
           <TabPane key="2" tab="合同回款">
-            <Receivable />
+            <Receivable updateTreeAndContract={initData}/>
           </TabPane>
           <TabPane key="3" tab="合同文件">
             <File />

+ 6 - 8
src/pages/Contract/Content/Income/components/Tabs/Receivable/index.tsx

@@ -24,7 +24,6 @@ const EditableCell: React.FC<iEditableCellProps> = ({
   index,
   ...restProps
 }) => {
-  // console.log(dataIndex, record)
 
   const cellNode = cellType === 'text' ? <Input size="small" allowClear /> : <DatePicker size="small" allowClear locale={locale} />
 
@@ -44,8 +43,10 @@ const EditableCell: React.FC<iEditableCellProps> = ({
   )
 }
 
-
-const Receivable: React.FC<{}> = () => {
+interface ReceivableProps {
+  updateTreeAndContract: () => Promise<void>
+}
+const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract }) => {
   const [ form ] = Form.useForm()
   const [ data, setData ] = useState<Array<iReceivableState>>([])
   const [ id, setId ] = useState<string>('')
@@ -61,6 +62,7 @@ const Receivable: React.FC<{}> = () => {
     if (code === consts.RET_CODE.SUCCESS) {
       const newData = data.filter(item => item.id !== id)
       setData(newData)
+      updateTreeAndContract()
     }
   }
 
@@ -98,14 +100,10 @@ const Receivable: React.FC<{}> = () => {
             ...row
           })
           setData(newData)
+          updateTreeAndContract()
         }
       }
       setEditingKey('')
-      // else {
-      //   newData.push(row)
-      //   setData(newData)
-      //   setEditingKey('')
-      // }
     } catch (errInfo) {
       console.log('Validate Failed:', errInfo)
     }

+ 6 - 3
src/pages/Contract/Content/Spending/components/TableContent/index.tsx

@@ -84,6 +84,9 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
         contractPaidStore.updateTree(data.sectionTree.children)
       }
     }
+    if (row.id) {
+      handleRowClick(row.id, row.bidsectionId)
+    }
   }
   interface iLabelHandlerProps {
     id: string
@@ -257,7 +260,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
   const onClickRow = (record: iIncomeTree) => {
     return {
       onClick() {
-        rowClickHandler(record.id, record.bidsectionId, record.isEdit, record.isNew)
+        handleRowClick(record.id, record.bidsectionId, record.isEdit, record.isNew)
       },
       onDoubleClick() {
         contractPaidStore.rowChange(row.id)
@@ -266,7 +269,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
   }
 
   // 行点击回调
-  const rowClickHandler = async (id: string, bid: string, isEdit?: boolean, isNew?: boolean) => {
+  const handleRowClick = async (id: string, bid: string, isEdit?: boolean, isNew?: boolean) => {
     if (!isEdit && !isNew) {
       const { code = -1, section = {}, contract: newContract = {} } = await apiGetExpenditure(id, bid)
       if (code === consts.RET_CODE.SUCCESS) {
@@ -410,7 +413,7 @@ const GCsheet: React.FC<iTableContentPorps> = ({ changeModalType, row, setRow, h
             <Detail {...contractPaidStore.contract} />
           </TabPane>
           <TabPane key="2" tab="合同支出">
-            <Receivable />
+            <Receivable updateTreeAndContract={initData}/>
           </TabPane>
           <TabPane key="3" tab="合同文件">
             <File />

+ 6 - 2
src/pages/Contract/Content/Spending/components/Tabs/Receivable/index.tsx

@@ -43,8 +43,10 @@ const EditableCell: React.FC<iEditableCellProps> = ({
   )
 }
 
-
-const Receivable: React.FC<{}> = () => {
+interface ReceivableProps {
+  updateTreeAndContract: () => Promise<void>
+}
+const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract }) => {
   const [ form ] = Form.useForm()
   const [ data, setData ] = useState<Array<iReceivableState>>([])
   const [ id, setId ] = useState<string>('')
@@ -60,6 +62,7 @@ const Receivable: React.FC<{}> = () => {
     if (code === consts.RET_CODE.SUCCESS) {
       const newData = data.filter(item => item.id !== id)
       setData(newData)
+      updateTreeAndContract()
     }
   }
 
@@ -96,6 +99,7 @@ const Receivable: React.FC<{}> = () => {
             ...row
           })
           setData(newData)
+          updateTreeAndContract()
         }
       }
       setEditingKey('')