流程问题修改-准入与后台
This commit is contained in:
@ -3,6 +3,8 @@ import { Modal, Form, Input, Select, Button, Upload, message, Row, Col, Descript
|
||||
import type { UploadProps } from 'antd';
|
||||
import { UploadOutlined } from '@ant-design/icons';
|
||||
import { uploadFile, invoiceView, invoiceAdd, invoiceEdit } from '../services';
|
||||
import { getDictList } from '@/servers/api/dicts'
|
||||
|
||||
interface props {
|
||||
visible: boolean;
|
||||
onOk: () => void;
|
||||
@ -10,6 +12,10 @@ interface props {
|
||||
initialValues?: any;
|
||||
readOnly?: boolean;
|
||||
}
|
||||
interface Dict {
|
||||
dicName: string;
|
||||
code: string;
|
||||
}
|
||||
interface viewDataData {
|
||||
id?: string | null;
|
||||
account?: string;
|
||||
@ -22,12 +28,12 @@ interface viewDataData {
|
||||
taxpayerCode?: string;
|
||||
taxpayerType?: string;
|
||||
attachment?: {
|
||||
uid: string;
|
||||
name: string;
|
||||
url: string;
|
||||
status: string;
|
||||
uid: string;
|
||||
name: string;
|
||||
url: string;
|
||||
status: string;
|
||||
}[];
|
||||
}
|
||||
}
|
||||
const InvoiceFormModal: React.FC<props> = ({
|
||||
visible,
|
||||
onOk,
|
||||
@ -36,10 +42,13 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
readOnly = false,
|
||||
}) => {
|
||||
const userId = sessionStorage.getItem('userId') || '';
|
||||
// 新增与修改
|
||||
// 新增与修改
|
||||
const [form] = Form.useForm();
|
||||
//查看
|
||||
const [viewData, setViewData] = useState<viewDataData>({});
|
||||
//纳税人option
|
||||
const [taxpayerType, setTaxpayerType] = useState<Dict[]>();
|
||||
|
||||
useEffect(() => {
|
||||
if (visible) {
|
||||
if (initialValues) {
|
||||
@ -53,8 +62,8 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
? [{ uid: '-1', name: data.qualificationCertificate, url: data.qualificationCertificate, status: 'done', response: { url: data.qualificationCertificate } }]
|
||||
: [],
|
||||
};
|
||||
console.log(fields,'fields');
|
||||
|
||||
console.log(fields, 'fields');
|
||||
|
||||
form.setFieldsValue(fields);
|
||||
setViewData(fields);
|
||||
}
|
||||
@ -62,6 +71,13 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
} else {
|
||||
form.resetFields(); // ✅ 只有无 initialValues 才重置
|
||||
}
|
||||
|
||||
getDictList('taxpayer_type').then((res) => {
|
||||
if (res.code == 200) {
|
||||
setTaxpayerType(res.data)
|
||||
}
|
||||
})
|
||||
|
||||
}
|
||||
}, [visible, initialValues]);
|
||||
|
||||
@ -76,8 +92,8 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
supplierId: userId,
|
||||
};
|
||||
|
||||
console.log(values,'values');
|
||||
|
||||
console.log(values, 'values');
|
||||
|
||||
if (!values.id) {
|
||||
invoiceAdd(payload).then((res) => {
|
||||
if (res.code == 200) {
|
||||
@ -103,6 +119,13 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
const uploadProps: UploadProps = {
|
||||
name: 'file',
|
||||
showUploadList: true,
|
||||
beforeUpload: (file) => {
|
||||
if (file.size > 1048576) { // 1MB
|
||||
message.error('文件大小不能超过1MB');
|
||||
return Upload.LIST_IGNORE; // 阻止上传
|
||||
}
|
||||
return true;
|
||||
},
|
||||
customRequest: async ({ file, onSuccess, onError }) => {
|
||||
try {
|
||||
const realFile = file as File;
|
||||
@ -168,7 +191,12 @@ const InvoiceFormModal: React.FC<props> = ({
|
||||
<Row gutter={24}>
|
||||
<Col span={24}>
|
||||
<Form.Item name="taxpayerType" label="纳税人类型" rules={[{ required: true }]}>
|
||||
<Select options={[{ label: '一般纳税人', value: '一般纳税人' }, { label: '小规模纳税人', value: '小规模纳税人' }]} />
|
||||
<Select style={{ width: 150 }} placeholder="请选择纳税人类型" allowClear>
|
||||
{taxpayerType?.map(item => (
|
||||
<Select.Option key={item.code} value={item.code}>{item.dicName}</Select.Option>
|
||||
))}
|
||||
</Select>
|
||||
|
||||
</Form.Item>
|
||||
</Col>
|
||||
<Col span={24}>
|
||||
|
Reference in New Issue
Block a user