Преглед на файлове

fix: 修复收入、支出合同使用同一套自动编号的bug

lanjianrong преди 4 години
родител
ревизия
443b7cc3d4

+ 2 - 3
src/pages/Contract/Content/Income/components/Modal/index.tsx

@@ -1,7 +1,6 @@
 import Authorization from '@/components/Authorization'
 import DatePicker from '@/components/DatePicker'
 import { contractReturnStore, tenderStore } from '@/store/mobx'
-import contractReturn from '@/store/mobx/contractReturn'
 import { iModalCommonProps } from '@/types/contract'
 import consts from '@/utils/consts'
 import { dayjsFormat, handleAutoCode } from '@/utils/util'
@@ -11,7 +10,7 @@ import dayjs from 'dayjs'
 import React, { ChangeEvent, useEffect, useState } from 'react'
 import { apiGetReturnWay } from '../Tabs/Receivable/api'
 import styles from './index.module.scss'
-const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible, confirmLoading }, onConfirm, onCancel, reload, row }) => {
+const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible, confirmLoading, contractType }, onConfirm, onCancel, reload, row }) => {
   const { Option } = Select
   const [ form ] = Form.useForm()
   const [ options, setOptions ] = useState<string[]>([])
@@ -72,7 +71,7 @@ const ContractModal: React.FC<iModalCommonProps> = ({ modalObj: { type, visible,
     }
   }, [ visible ])
   const autoCode = async () => {
-    const ruleArr = await handleAutoCode(tenderStore.tender.bidsectionId, 'contractReturnRule')
+    const ruleArr = await handleAutoCode(tenderStore.tender.bidsectionId, contractType === 'income' ? 'contractReturnRule' : 'contractPaidRule')
     form.setFieldsValue({ code: ruleArr.join('-') })
   }
 

+ 58 - 55
src/pages/Contract/Content/Income/index.tsx

@@ -4,7 +4,7 @@ import RuleModal from '@/components/RuleModal'
 import SvgIcon from '@/components/SvgIcon'
 import { apiSaveRule } from '@/pages/Safe/Content/List/api'
 import { contractReturnStore, tenderStore } from '@/store/mobx'
-import { iIncomeTree, iModalBooleanProps } from '@/types/contract'
+import { iIncomeTree, iModalProps } from '@/types/contract'
 import { contractTreeBaseId } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { Button, message, Tooltip } from 'antd'
@@ -23,10 +23,11 @@ interface iModal {
 
 const Income: React.FC<RouteComponentProps> = ({ history }) => {
 
-  const [ modalObj, setModalObj ] = useState<iModalBooleanProps>({
+  const [ modalObj, setModalObj ] = useState<iModalProps>({
     type: '',
     visible: false,
-    confirmLoading: false
+    confirmLoading: false,
+    contractType: 'income'
   })
   const [ row, setRow ] = useState<iIncomeTree>({
     elderBrother: false,
@@ -64,6 +65,8 @@ const Income: React.FC<RouteComponentProps> = ({ history }) => {
     })
     const { code = -1, contract = {} } = await apiResfulContract(type, values)
     if (code === consts.RET_CODE.SUCCESS) {
+      console.log(contract)
+
       contractReturnStore.updateContract(contract)
       contractReturnStore.resetTree(tenderStore.bid)
       if (type === 'return') {
@@ -89,7 +92,7 @@ const Income: React.FC<RouteComponentProps> = ({ history }) => {
       return contractReturnStore.addRowTree(payload.id)
     }
     const { code = -1, section = {} } = await apiResfulContractTree(type, payload)
-    if ( code === consts.RET_CODE.SUCCESS) {
+    if (code === consts.RET_CODE.SUCCESS) {
       contractReturnStore.resetTree(tenderStore.bid)
       if (type !== 'add' && type !== 'del') {
         setRow({ ...row, ...section })
@@ -124,51 +127,51 @@ const Income: React.FC<RouteComponentProps> = ({ history }) => {
           <div className="pi-flex-row">
             {
               row.id ?
-              <>
-                <Tooltip title="添加子项">
-                  <Button type="text" icon={<SvgIcon type="xxh-plus" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('add', { id: row.id, bidsectionId: row.bidsectionId })} />
-                </Tooltip>
-                {
-                  !row.children?.length ?
-                  <Tooltip title="删除">
-                    <Button type="text" icon={<SvgIcon type="xxh-times" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('del', { id: row.id, bidsectionId: row.bidsectionId })} />
-                  </Tooltip>
-                  : <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-times" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
-                }
-                {
-                  row.parentId && row.parentId !== contractTreeBaseId ?
-                  <Tooltip title="升级">
-                    <Button type="text" icon={<SvgIcon type="xxh-arrow-left" style={{ color: '#007bff', fontSize: 12 }} onClick={() => treeResfulApiHandler('depth', { id: row.id, bidsectionId: row.bidsectionId, operation: 'upDepth' })} />} />
-                  </Tooltip>
-                  :
-                  <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-left" style={{ color: '#9a9a9a', fontSize: 12 }}/></span>
-                }
-                {
-                  row.elderBrother ?
-                  <Tooltip title="降级">
-                    <Button type="text" icon={<SvgIcon type="xxh-arrow-right" style={{ color: '#007bff', fontSize: 12 }}/>} onClick={() => treeResfulApiHandler('depth', { id: row.id, bidsectionId: row.bidsectionId, operation: 'downDepth' })}  />
-                  </Tooltip>
-                  :
-                  <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-right" style={{ color: '#9a9a9a', fontSize: 12 }}/></span>
-                }
-                {
-                  row.elderBrother ?
-                  <Tooltip title="上移">
-                    <Button type="text" icon={<SvgIcon type="xxh-arrow-up" style={{ color: '#007bff', fontSize: 12 }}/>} onClick={() => treeResfulApiHandler('serial', { id: row.id, bidsectionId: row.bidsectionId, operation: 'upSerial' })}  disabled={!row.elderBrother} />
-                  </Tooltip>
-                  :
-                  <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-up" style={{ color: '#9a9a9a', fontSize: 12 }}/></span>
-                }
-                {
-                  !row.isEnd ?
-                  <Tooltip title="下移">
-                    <Button type="text" icon={<SvgIcon type="xxh-arrow-down" style={{ color: '#007bff', fontSize: 12 }}/>} onClick={() => treeResfulApiHandler('serial', { id: row.id, bidsectionId: row.bidsectionId, operation: 'downSerial' })} disabled={row.isEnd} />
+                <>
+                  <Tooltip title="添加子项">
+                    <Button type="text" icon={<SvgIcon type="xxh-plus" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('add', { id: row.id, bidsectionId: row.bidsectionId })} />
                   </Tooltip>
-                  :
-                  <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-down" style={{ color: '#9a9a9a', fontSize: 12 }}/></span>
-                }
-              </>
-              : ''
+                  {
+                    !row.children?.length ?
+                      <Tooltip title="删除">
+                        <Button type="text" icon={<SvgIcon type="xxh-times" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('del', { id: row.id, bidsectionId: row.bidsectionId })} />
+                      </Tooltip>
+                      : <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-times" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
+                  }
+                  {
+                    row.parentId && row.parentId !== contractTreeBaseId ?
+                      <Tooltip title="升级">
+                        <Button type="text" icon={<SvgIcon type="xxh-arrow-left" style={{ color: '#007bff', fontSize: 12 }} onClick={() => treeResfulApiHandler('depth', { id: row.id, bidsectionId: row.bidsectionId, operation: 'upDepth' })} />} />
+                      </Tooltip>
+                      :
+                      <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-left" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
+                  }
+                  {
+                    row.elderBrother ?
+                      <Tooltip title="降级">
+                        <Button type="text" icon={<SvgIcon type="xxh-arrow-right" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('depth', { id: row.id, bidsectionId: row.bidsectionId, operation: 'downDepth' })} />
+                      </Tooltip>
+                      :
+                      <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-right" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
+                  }
+                  {
+                    row.elderBrother ?
+                      <Tooltip title="上移">
+                        <Button type="text" icon={<SvgIcon type="xxh-arrow-up" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('serial', { id: row.id, bidsectionId: row.bidsectionId, operation: 'upSerial' })} disabled={!row.elderBrother} />
+                      </Tooltip>
+                      :
+                      <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-up" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
+                  }
+                  {
+                    !row.isEnd ?
+                      <Tooltip title="下移">
+                        <Button type="text" icon={<SvgIcon type="xxh-arrow-down" style={{ color: '#007bff', fontSize: 12 }} />} onClick={() => treeResfulApiHandler('serial', { id: row.id, bidsectionId: row.bidsectionId, operation: 'downSerial' })} disabled={row.isEnd} />
+                      </Tooltip>
+                      :
+                      <span className="pi-width-32 pi-height-32 pi-pd-tb-4 pi-flex-row-center"><SvgIcon type="xxh-arrow-down" style={{ color: '#9a9a9a', fontSize: 12 }} /></span>
+                  }
+                </>
+                : ''
             }
           </div>
         </Slot>
@@ -176,14 +179,14 @@ const Income: React.FC<RouteComponentProps> = ({ history }) => {
           <Button type="ghost" size="small" icon={<SvgIcon type="xxh-cog" />} className="pi-mg-right-3" style={{ color: '#007bff' }} onClick={() => setRuleModal({ ...ruleModal, visible: true })}>设置</Button>
           {
             showCBtn ?
-            <Authorization type="contract" auth="add">
-              <Button type="primary" size="small" onClick={() => setModalObj({ ...modalObj, type: 'create', visible: true })}>新建收入合同</Button>
-            </Authorization>
-            : ""
+              <Authorization type="contract" auth="add">
+                <Button type="primary" size="small" onClick={() => setModalObj({ ...modalObj, type: 'create', visible: true })}>新建收入合同</Button>
+              </Authorization>
+              : ""
           }
         </Slot>
       </Header>
-      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} history={history}/>
+      <TableContent changeModalType={changeModalType} row={row} setRow={(record: iIncomeTree) => setRow({ ...row, ...record })} history={history} />
       <RuleModal
         type={consts.RULE.CONTRACT_RETURN}
         title="合同管理编号设置"
@@ -191,8 +194,8 @@ const Income: React.FC<RouteComponentProps> = ({ history }) => {
         onCreate={onRuleCreate}
         loading={ruleModal.loading}
         onCancel={() => setRuleModal({ ...ruleModal, visible: false })}
-       />
-      <ContractModal row={row} modalObj={modalObj} onConfirm={onCreate} onCancel={ () => setModalObj({ ...modalObj, visible: false })} reload={(type) => handleReload(type)} />
+      />
+      <ContractModal row={row} modalObj={modalObj} onConfirm={onCreate} onCancel={() => setModalObj({ ...modalObj, visible: false })} reload={(type) => handleReload(type)} />
     </div>
   )
 }

+ 4 - 3
src/pages/Contract/Content/Spending/index.tsx

@@ -5,7 +5,7 @@ import RuleModal from '@/components/RuleModal'
 import SvgIcon from '@/components/SvgIcon'
 import { apiSaveRule } from '@/pages/Safe/Content/List/api'
 import { contractPaidStore, tenderStore } from '@/store/mobx'
-import { iIncomeTree, iModalBooleanProps } from '@/types/contract'
+import { iIncomeTree, iModalProps } from '@/types/contract'
 import { contractTreeBaseId } from '@/utils/common/constStatus'
 import consts from '@/utils/consts'
 import { Button, message, Tooltip } from 'antd'
@@ -21,10 +21,11 @@ interface iModal {
 }
 
 const Expenditure:React.FC<RouteComponentProps> = ({ history }) => {
-  const [ modalObj, setModalObj ] = useState<iModalBooleanProps>({
+  const [ modalObj, setModalObj ] = useState<iModalProps>({
     type: '',
     visible: false,
-    confirmLoading: false
+    confirmLoading: false,
+    contractType: 'spending'
   })
   const [ row, setRow ] = useState<iIncomeTree>({
     elderBrother: false,