3.10 工程代码同步master

This commit is contained in:
jl-zhoujl2
2022-03-10 14:24:13 +08:00
parent 41ab55a4ac
commit 62f6b07ee2
914 changed files with 143121 additions and 29110 deletions

View File

@ -1,20 +1,21 @@
import React, { useEffect } from 'react';
import React, { useEffect, useState } from 'react';
import { Form, Input, Modal, Spin } from 'antd';
interface NewInvoiceProps {
modalVisible: boolean;
onCancel: () => void;
onSubmit: (value: any) => void;
onSubmit: (value: any) => Promise<any>;
title: string;
values: any;
loading: any;
}
const layout = {
labelCol: { span: 7 },
wrapperCol: { span: 12 },
labelCol: { span: 6 },
wrapperCol: { span: 13 },
};
const modalHeight = (window.innerHeight * 96) / 100;
const validateMessages = {
required: '请填写${label}',
types: {
@ -23,7 +24,9 @@ const validateMessages = {
};
const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
const { modalVisible, onCancel, title, onSubmit, values, loading } = props;
const { modalVisible, onCancel, title, onSubmit, values } = props;
//loading
const [loading, setLoading] = useState<boolean>(false);
const [form] = Form.useForm();
useEffect(() => {
@ -44,9 +47,12 @@ const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
form.submit();
};
const onFinish = (values: any) => {
onSubmit(values);
form.resetFields();
const onFinish = async (values: any) => {
setLoading(true);
await onSubmit(values).then((res) => {
setLoading(false);
form.resetFields();
});
};
return (
<Modal
@ -57,7 +63,11 @@ const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
onOk={onOk}
okText="保存"
cancelText="取消"
width={800}
width={'60%'}
style={{ maxHeight: modalHeight }}
bodyStyle={{ maxHeight: modalHeight - 107, overflowY: 'auto' }}
confirmLoading={loading}
centered
>
<Spin spinning={loading} delay={300}>
<Form
@ -68,17 +78,27 @@ const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
validateMessages={validateMessages}
preserve={false}
>
<Form.Item name="companyName" label="公司名称" rules={[{ required: true }]}>
<Form.Item
name="companyName"
label="公司名称"
rules={[{ required: true }, { max: 100, message: '最大不能超过100字' }]}
>
<Input placeholder="请填写公司名称" />
</Form.Item>
<Form.Item
name="taxpayerIdentification"
label="纳税人识别号"
rules={[{ required: true }]}
rules={[
{ required: true },
{
pattern: /^[0-9A-HJ-NPQRTUWXY]{15}$|^[0-9A-HJ-NPQRTUWXY]{17}$|^[0-9A-HJ-NPQRTUWXY]{18}$|^[0-9A-HJ-NPQRTUWXY]{20}$/,
message: '输入的纳税人识别号不正确',
},
]}
>
<Input placeholder="请填写纳税人识别号" />
</Form.Item>
<Form.Item name="companyAddress" label="公司地址" rules={[{ required: true }]}>
<Form.Item name="companyAddress" label="公司地址" rules={[{ required: true },{max: 150,message: "最大不能超过150字"}]}>
<Input placeholder="请填写公司地址" />
</Form.Item>
<Form.Item
@ -94,7 +114,7 @@ const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
>
<Input placeholder="请填写公司电话(手机号或固定电话)" />
</Form.Item>
<Form.Item name="bank" label="开户银行" rules={[{ required: true }]}>
<Form.Item name="bank" label="开户银行" rules={[{ required: true },{max: 30,message: "最大不能超过30字"}]}>
<Input placeholder="请填写开户银行" />
</Form.Item>
<Form.Item
@ -103,7 +123,7 @@ const NewInvoice: React.FC<NewInvoiceProps> = (props) => {
rules={[
{ required: true },
{
pattern: /^[1-9]\d{9,29}$/,
pattern: /^[0-9]\d{8,29}$/,
message: '输入的银行号码不正确',
},
]}

View File

@ -1,3 +1,4 @@
import { btnAuthority } from '@/utils/authority';
import ProTable, { ActionType, ProColumns } from '@ant-design/pro-table';
import { Button, Card, message, Popconfirm } from 'antd';
import React, { useState } from 'react';
@ -18,8 +19,6 @@ const InvoiceInformation: React.FC<{}> = () => {
const [invoiceLineData, setInvoiceLineData] = useState<any>({});
//存储修改和删除弹窗标题
const [invoiceModalTitle, setInvoiceModalTitle] = useState<any>('');
//弹窗的访问遮罩
const [spinLoading, setSpinLoading] = useState<boolean>(false);
const columns: ProColumns<any>[] = [
{
title: '序号',
@ -61,27 +60,32 @@ const InvoiceInformation: React.FC<{}> = () => {
title: '操作',
valueType: 'option',
width: 140,
render: (_, record) => [
<a
key="editable"
render: (_, record) =>
<>
<Button
type="text"
key="edit"
onClick={() => {
setInvoiceLineData(record);
setInvoiceModalTitle('编辑发票信息');
setInvoiceVisible(true);
}}
hidden={btnAuthority(["ebtp-supplier"])}
>
</a>,
</Button>
<Popconfirm
title="确定要删除吗?"
onConfirm={() => toDelete(record)}
okText="确定"
cancelText="取消"
key="del"
>
<a key="view"></a>
</Popconfirm>,
],
title="确定要删除吗?"
onConfirm={() => toDelete(record)}
okText="确定"
cancelText="取消"
key="del"
>
<Button type="text" key="del" hidden={btnAuthority(["ebtp-supplier"])}>
</Button>
</Popconfirm>
</>
},
];
const toDelete = async (value: any) => {
@ -98,54 +102,48 @@ const InvoiceInformation: React.FC<{}> = () => {
}
};
return (
<Card bodyStyle={{ padding: '12px 12px' }}>
<Card
title="常用发票信息管理"
bodyStyle={{ padding: '16px 24px 0px' }}
style={{ borderRadius: 6 }}
>
<div style={{textAlign:'right'}}>
<Button
type="primary"
style={{ float: 'right', marginBottom: 10, zIndex: 99 }}
style={{ marginBottom: 16, zIndex: 99 }}
onClick={() => {
setInvoiceModalTitle('新建发票信息');
setInvoiceVisible(true);
}}
key="1"
hidden={btnAuthority(["ebtp-supplier"])}
>
</Button>
<ProTable<any>
<ProTable
columns={columns}
actionRef={actionRef}
search={false}
options={false}
params={{
companyId: '9527',
}}
size="small"
//调用分页方法
request={async (params) => {
let value = {
data: [],
success: false,
total: 0,
pageSize: 10,
current: 1,
};
request={async (params) =>
await getInvoiceList(params).then((res) => {
value.data = res.data.records;
value.success = res.success;
value.total = res.data.total;
value.pageSize = res.data.size;
value.current = res.data.current;
value.data.forEach((element: any, index: any) => {
if (res.data.current == 1) {
element.key = index + 1;
} else {
element.key = res.data.size * (res.data.current - 1) + index + 1;
}
let data = res.data.records;
data.forEach((element: any, index: any) => {
element.key = res.data.size * (res.data.current - 1) + index + 1;
});
});
return value;
}}
return {
data: data,
success: res.success,
total: res.data.total,
pageSize: res.data.size,
current: res.data.current,
};
})
}
rowKey="id"
pagination={{
pageSize: 10,
@ -156,33 +154,32 @@ const InvoiceInformation: React.FC<{}> = () => {
title={invoiceModalTitle}
onCancel={() => {
setInvoiceLineData({});
setInvoiceVisible(false)
setInvoiceVisible(false);
}}
onSubmit={async (value) => {
setSpinLoading(true)
let param = {
...value,
companyId: '9527',
// companyId: '9527',
};
let success;
if (value.id == undefined || value.id == "") {
if (value.id == undefined || value.id == '') {
success = await handleAdd(param);
} else {
success = await handleUpdate(param);
}
if (success) {
setSpinLoading(false)
setInvoiceLineData({});
setInvoiceVisible(false);
if (actionRef.current) {
actionRef.current.reload();
}
actionRef.current?.reload?.();
return true
} else {
return false
}
}}
modalVisible={InvoiceVisible}
values={invoiceLineData}
loading={spinLoading}
/>
</div>
</Card>
);
};

View File

@ -10,7 +10,6 @@ export async function getInvoiceList(params: any) {
{
method: 'GET',
params:{
companyId:params.companyId,
pageNo:params.current,
pageSize:params.pageSize
}

View File

@ -6,14 +6,12 @@ import { addAndUpdateInvoice } from './service';
*/
export const handleUpdate = async (fields: any) => {
try {
await addAndUpdateInvoice({ ...fields });
message.success('编辑成功');
return true;
} catch (error) {
message.error('编辑失败');
return false;
}
return await addAndUpdateInvoice(fields).then(res => {
if(res?.code ==200) {
message.success('编辑成功');
}
return res?.success
});
};
/**
@ -22,12 +20,10 @@ export const handleUpdate = async (fields: any) => {
*/
export const handleAdd = async (fields: any) => {
try {
await addAndUpdateInvoice({ ...fields });
message.success('新建成功');
return true;
} catch (error) {
message.error('新建失败');
return false;
}
return await addAndUpdateInvoice(fields).then(res => {
if(res?.code ==200) {
message.success('新建成功');
}
return res?.success
});
};