import DatePicker from '@/components/DatePicker' import { apiAutoCode } from '@/pages/Safe/Content/List/api' import { contractStore, tenderStore } from '@/store/mobx' import { iModalCommonProps } from '@/types/contract' import consts from '@/utils/consts' import { dayjsFormat } from '@/utils/util' import { Button, Form, Input, Modal, Select } from 'antd' import locale from 'antd/es/date-picker/locale/zh_CN' import React, { useEffect, useState } from 'react' import { apiGetReturnWay } from '../Tabs/Receivable/api' import styles from './index.module.scss' const ContractModal: React.FC = ({ modalObj: { type, visible, confirmLoading }, onConfirm, onCancel, reload, row }) => { const { Option } = Select const [ form ] = Form.useForm() const [ options, setOptions ] = useState([]) const modalObj = { create: { title: '新建合同', cancelText: '取消', okText: '确认添加' }, update: { title: '编辑合同', cancelText: '取消', okText: '确认' }, close: { title: '关闭合同', cancelText: '取消', okText: '确认关闭' }, del: { title: '删除合同', cancelText: '取消', okText: '确认删除' }, unlock: { title: '解锁合同', cancelText: '取消', okText: '确认解锁' }, return: { title: '添加回款', cancelText: '关闭', okText: '确认' } } useEffect(() => { if (visible) { form.setFieldsValue({ treeId: row.id, bidsectionId: row.bidsectionId }) if (type === "update") { const { content="", name="", price="", partyA="", partyB="", partyASigner="",partyBSigner="" } = contractStore.contract form.setFieldsValue({ content, name, price, partyA, partyB, partyASigner, partyBSigner }) } else if (type === 'return') { apiGetReturnWay().then(({ code = -1, data = [] }) => { if (code === consts.RET_CODE.SUCCESS) { const options = data.map((item: string) => ) setOptions(options) } }) form.setFieldsValue({ contractsId: contractStore.contract.id }) } else { form.setFieldsValue({ id: contractStore.contract.id }) } } }, [ visible ]) const autoCodeHandler = async () => { const { code = -1, data = "" } = await apiAutoCode(tenderStore.tender.bidsectionId, 'contractRule') if (code === consts.RET_CODE.SUCCESS) { if (data) { const ruleArr: string[] = [] const code = JSON.parse(data) for (const key in code) { if (Object.prototype.hasOwnProperty.call(code, key)) { const element = code[key] if (element) { ruleArr.push(element) } } } form.setFieldsValue({ code: ruleArr.join("-") }) } } } return ( {type === 'update' ? : ''} } >
{ type === 'create' ? ( <> autoCodeHandler()}>自动编号}> 元}> ) : '' } { type === 'update' ? ( <> ) : '' } { type === 'close' ? ( <> 关闭后,合同将锁定,无法进行编辑、上传文件等操作。 ) : '' } { type === 'unlock' ? ( <> 解锁后,合同将锁定,无法进行编辑、上传文件等操作。 ) : '' } { type === "del" ? ( <>

删除后,数据无法恢复,请谨慎操作。

请在下方文本框输入文本「确认删除本合同」,以此确认删除操作。

({ validator(rule, value) { if (!value || value !== "确认删除本合同") { return Promise.reject("请按照提示信息进行删除操作!") } return Promise.resolve() } }) ]}> ) : '' } { type === 'return' ? <> : '' }
) } export default ContractModal