import Header from '@/components/Header' import Slot from '@/components/Header/slot' 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 { ContractTree, iModalProps } from '@/types/contract' import { contractTreeBaseId } from '@/utils/common/constStatus' import consts from '@/utils/consts' import { Button, message, Tooltip } from 'antd' import React, { useState } from 'react' 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' import { ContractType } from '@/store/mobx/contractReturn' interface iModal { visible: boolean loading: boolean } const Income: React.FC = (props) => { const { history } = props const [ modalObj, setModalObj ] = useState({ type: '', visible: false, confirmLoading: false, contractType: 'income' }) const [ row, setRow ] = useState({ elderBrother: false, isEnd: false, attribsortution: 0, attribution: '', bidsectionId: '', children: [], code: '', contractCode: '', contractId: '', contractName: '', contractPrice: '', contractReturned: '', contractStatus: 0, contractsPaid: '', createTime: '', depth: 0, id: '', name: '', operation: '', parentId: '', projectId: '', serial: 0, templateNumber: 0 }) const [ ruleModal, setRuleModal ] = useState({ visible: false, loading: false }) const onCreate = async (values: any, type: any) => { setModalObj({ ...modalObj, confirmLoading: true }) const { code = -1, contract = {} } = await apiResfulContract(type, values) if (code === consts.RET_CODE.SUCCESS) { contractReturnStore.updateContract(contract) contractReturnStore.resetTree(tenderStore.bid) if (type === 'return') { contractReturnStore.changeUpdate('2') } } setModalObj({ ...modalObj, type: '', visible: false, confirmLoading: false }) } const changeModalType = (type: string) => { setModalObj({ ...modalObj, visible: true, type }) } const treeResfulApiHandler = async (type: string, payload: any) => { const { code = -1, section = {} } = await apiResfulContractTree(type, payload, consts.CONTRACT_TREE.RETURN) if (code === consts.RET_CODE.SUCCESS) { contractReturnStore.resetTree(tenderStore.bid) if (type !== 'add' && type !== 'del') { setRow({ ...row, ...section }) } } } const onRuleCreate = async (ruleValue: any) => { setRuleModal({ ...ruleModal, loading: true }) const { code = -1 } = await apiSaveRule({ bidsectionId: tenderStore.bid, type: 'contract_return_rule', rule: ruleValue }) if (code === consts.RET_CODE.SUCCESS) { message.success("规则更改成功") } setRuleModal({ ...ruleModal, loading: false, visible: false }) } // 切换到删除合同弹窗 const handleReload = (type: string) => { setModalObj({ ...modalObj, visible: false }) setTimeout(() => { setModalObj({ ...modalObj, visible: true, type }) }, 300) } const showCBtn = () => { return !row.children && !row.contractCode && row.id } return (
{ row.id ? <>
{ showCBtn ? : "" }
setRow({ ...row, ...record })} history={history} type={ContractType.INCOME} /> setRuleModal({ ...ruleModal, visible: false })} /> setModalObj({ ...modalObj, visible: false })} reload={(type) => handleReload(type)} />
) } export default Income