|
@@ -1,6 +1,6 @@
|
|
|
import DatePicker from '@/components/DatePicker'
|
|
|
import FileModal from '@/components/FileModal'
|
|
|
-import { contractStore } from '@/store/mobx'
|
|
|
+import { commonStore, contractStore } from '@/store/mobx'
|
|
|
import { ContractType } from '@/store/mobx/contract'
|
|
|
import { iReceivableState, iEditableCellProps } from '@/types/contract'
|
|
|
import { iFileModal } from '@/types/file'
|
|
@@ -8,13 +8,13 @@ import { contractConsts } from '@/utils/common/constStatus'
|
|
|
import consts from '@/utils/consts'
|
|
|
import { dayjsFormat, formatMoney } from '@/utils/util'
|
|
|
import { DisconnectOutlined } from '@ant-design/icons'
|
|
|
-import { Form, Input, Popconfirm, Table } from 'antd'
|
|
|
+import { Form, Input, Popconfirm, Table, Select } from 'antd'
|
|
|
// import locale from 'antd/es/date-picker/locale/zh_CN'
|
|
|
import dayjs from 'dayjs'
|
|
|
import { observer } from 'mobx-react'
|
|
|
import React, { useEffect, useState } from 'react'
|
|
|
import { apiDelReturn, apiGetReturns, apiUpdateReturn } from './api'
|
|
|
-
|
|
|
+const { Option } = Select
|
|
|
|
|
|
const EditableCell: React.FC<iEditableCellProps> = ({
|
|
|
editing,
|
|
@@ -27,7 +27,20 @@ const EditableCell: React.FC<iEditableCellProps> = ({
|
|
|
...restProps
|
|
|
}) => {
|
|
|
|
|
|
- const cellNode = cellType === 'text' ? <Input size="small" allowClear autoComplete="off"/> : <DatePicker size="small" allowClear />
|
|
|
+ let cellNode: React.ReactNode
|
|
|
+ switch (cellType) {
|
|
|
+ case 'text':
|
|
|
+ cellNode = <Input size="small" allowClear autoComplete="off" />
|
|
|
+ break
|
|
|
+ case 'DatePicker':
|
|
|
+ cellNode = <DatePicker size="small" allowClear />
|
|
|
+ break
|
|
|
+ case 'Select':
|
|
|
+ cellNode = <Select size="small">{commonStore.returnWayOptions.map(item => (<Option key={item} value={item}>{item}</Option>))}</Select>
|
|
|
+ break
|
|
|
+ default:
|
|
|
+ break
|
|
|
+ }
|
|
|
|
|
|
// const isDate = useMemo(() => {
|
|
|
// return dataIndex === 'createTime' || dataIndex === 'time'
|
|
@@ -37,7 +50,7 @@ const EditableCell: React.FC<iEditableCellProps> = ({
|
|
|
return (
|
|
|
<td {...restProps}>
|
|
|
{editing ? (
|
|
|
- <Form.Item name={dataIndex} style={{ margin: 0 }} rules={[ dataIndex === 'remarks' ? {} : { required: true, message: `请输入${title}!` } ]}>
|
|
|
+ <Form.Item name={dataIndex} style={{ margin: 0 }} rules={[ dataIndex === 'remarks' ? {} : { required: true, message: `请${cellType === 'text' ? '输入' : '选择'}${title}!` } ]}>
|
|
|
{cellNode}
|
|
|
</Form.Item>
|
|
|
) : (
|
|
@@ -49,7 +62,7 @@ const EditableCell: React.FC<iEditableCellProps> = ({
|
|
|
|
|
|
interface ReceivableProps {
|
|
|
updateTreeAndContract: () => Promise<void>
|
|
|
- type : 'income' | 'expenditure'
|
|
|
+ type: 'income' | 'expenditure'
|
|
|
}
|
|
|
const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type }) => {
|
|
|
const [ form ] = Form.useForm()
|
|
@@ -72,6 +85,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
}
|
|
|
|
|
|
useEffect(() => {
|
|
|
+ !commonStore.returnWayOptions.length && (commonStore.queryWayOptions())
|
|
|
if (contractStore.contract.id) {
|
|
|
if (contractStore.contract.id !== id) {
|
|
|
setId(contractStore.contract.id)
|
|
@@ -133,7 +147,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
render: (text: string) => <span>{dayjsFormat(text, 'YYYY-MM-DD')}</span>
|
|
|
},
|
|
|
{
|
|
|
- title: type === ContractType.INCOME ? '回款金额' : '支付金额',
|
|
|
+ title: type === ContractType.INCOME ? '回款金额' : '支付金额',
|
|
|
dataIndex: 'price',
|
|
|
editable: true,
|
|
|
width: '12%',
|
|
@@ -141,7 +155,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
render: (text: string) => <span className="pi-text-right pi-width-100P">{formatMoney(text)}</span>
|
|
|
},
|
|
|
{
|
|
|
- title: type === ContractType.INCOME ? '回款方式' : '支付方式',
|
|
|
+ title: type === ContractType.INCOME ? '回款方式' : '支付方式',
|
|
|
dataIndex: 'way',
|
|
|
editable: true,
|
|
|
width: '12%'
|
|
@@ -170,7 +184,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
title: '附件',
|
|
|
dataIndex: 'fileCounts',
|
|
|
// eslint-disable-next-line react/display-name
|
|
|
- render: (text: number, record: iReceivableState) => <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}><DisconnectOutlined style={{ color: '#007bff' }}/> {text}</span>
|
|
|
+ render: (text: number, record: iReceivableState) => <span className="pi-pointer" onClick={() => setFileModal({ ...fileModal, dataId: record.id, visible: true })}><DisconnectOutlined style={{ color: '#007bff' }} /> {text}</span>
|
|
|
},
|
|
|
{
|
|
|
title: '操作',
|
|
@@ -191,7 +205,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
<span className="pi-link-red pi-mg-left-5">删除</span>
|
|
|
</Popconfirm>
|
|
|
</div>
|
|
|
- : null
|
|
|
+ : null
|
|
|
}
|
|
|
}
|
|
|
]
|
|
@@ -219,7 +233,7 @@ const Receivable: React.FC<ReceivableProps> = ({ updateTreeAndContract, type })
|
|
|
...col,
|
|
|
onCell: (record: iReceivableState) => ({
|
|
|
record,
|
|
|
- cellType: col.dataIndex === 'createTime' || col.dataIndex === 'time' ? 'DatePicker' : 'text',
|
|
|
+ cellType: col.dataIndex === 'createTime' || col.dataIndex === 'time' ? 'DatePicker' : col.dataIndex === 'way' ? 'Select' : 'text',
|
|
|
dataIndex: col.dataIndex,
|
|
|
title: col.title,
|
|
|
editing: isEditing(record)
|