3.10 工程代码同步master
This commit is contained in:
@ -1,125 +1,159 @@
|
||||
import React, { useState, useRef, } from 'react';
|
||||
import { message, Button } from 'antd';
|
||||
import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
||||
import React, { useState, useRef, useEffect } from 'react';
|
||||
import { Button, Card } from 'antd';
|
||||
import ProTable, { ProColumns, ActionType } from '@ant-design/pro-table';
|
||||
import { TableListItem, FormValueType } from './data.d'
|
||||
import UpdateForm from './components/updateForm';
|
||||
import { updateInv, getList } from './service';
|
||||
import { addInvoice, getList } from './service';
|
||||
import EditInvoiceSupplier from './components/EditInvoiceSupplier';
|
||||
import { handleUpdate } from './utils';
|
||||
import ViewInvoiceSupplier from './components/ViewInvoiceSupplier';
|
||||
import '@/assets/zjl_style.less';
|
||||
import { btnAuthority } from '@/utils/authority';
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 更新节点
|
||||
* @param fields
|
||||
*/
|
||||
const handleUpdate = async (fields: FormValueType) => {
|
||||
const hide = message.loading('正在配置');
|
||||
try {
|
||||
await updateInv({
|
||||
companyName: fields.companyName,
|
||||
shibieNo: fields.shibieNo,
|
||||
companyAdd: fields.companyAdd,
|
||||
companyPhone: fields.companyPhone,
|
||||
bank: fields.bank,
|
||||
bankNo: fields.bankNo,
|
||||
area: fields.area,
|
||||
allAdd: fields.allAdd,
|
||||
man: fields.man,
|
||||
manPh: fields.manPh,
|
||||
status: fields.status,
|
||||
});
|
||||
hide();
|
||||
|
||||
message.success('配置成功');
|
||||
return true;
|
||||
} catch (error) {
|
||||
hide();
|
||||
message.error('配置失败请重试!');
|
||||
return false;
|
||||
}
|
||||
};
|
||||
const invoice: React.FC<{}> = () => {
|
||||
const InvoiceSupplier: React.FC<{}> = () => {
|
||||
const actionRef = useRef<ActionType>();
|
||||
//修改页面显隐
|
||||
const [updateModalVis, handleUpdateModalVis] = useState<boolean>(false);
|
||||
//查看页面显隐
|
||||
const [viewModalVis, handleViewModalVis] = useState<boolean>(false);
|
||||
//存值
|
||||
const [formValues, setFormValues] = useState({});
|
||||
const [recordValues, setRecordValues] = useState<any>();
|
||||
//分页参数
|
||||
const [page, setPage] = useState<any>({
|
||||
pageSize: 10,
|
||||
pageNo: 1,
|
||||
});
|
||||
|
||||
const columns: ProColumns<TableListItem>[] = [
|
||||
{ title: '序号', dataIndex: 'index', valueType: 'index', width: 10, },
|
||||
{ title: '项目名称', dataIndex: 'proName', width: 300, copyable: true },
|
||||
const toEdit = (param: any) => {
|
||||
setRecordValues(param);
|
||||
handleUpdateModalVis(true);
|
||||
};
|
||||
|
||||
const toView = (param: any) => {
|
||||
setRecordValues(param);
|
||||
handleViewModalVis(true);
|
||||
};
|
||||
|
||||
const columns: ProColumns<any>[] = [
|
||||
{
|
||||
title: '发票类型', dataIndex: 'type', width: 150,
|
||||
title: '序号',
|
||||
dataIndex: 'key',
|
||||
key: 'key',
|
||||
width: 60,
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '项目名称',
|
||||
dataIndex: 'projectName',
|
||||
key: 'projectName',
|
||||
},
|
||||
{
|
||||
title: '公司名称',
|
||||
dataIndex: 'companyName',
|
||||
key: 'companyName',
|
||||
},
|
||||
{
|
||||
title: '发票类型',
|
||||
dataIndex: 'type',
|
||||
key: 'type',
|
||||
valueType: 'select',
|
||||
valueEnum: {
|
||||
0: { text: '普通' },
|
||||
1: { text: '专用' },
|
||||
'0': '增值税普通发票',
|
||||
'1': '增值税专用发票',
|
||||
},
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '发票状态',
|
||||
dataIndex: 'state',
|
||||
valueType: 'select',
|
||||
valueEnum: {
|
||||
'0': '未开',
|
||||
'1': '已开',
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '状态', dataIndex: 'status', width: 100,
|
||||
valueEnum: {
|
||||
0: { text: '未开', status: 'Processing' },
|
||||
1: { text: '已开', status: 'Success' },
|
||||
},
|
||||
title: '是否需要邮寄',
|
||||
render:(_: any,record: any) => record.isMail == -1 ? '无需邮寄' : '需要邮寄',
|
||||
search: false,
|
||||
},
|
||||
{
|
||||
title: '操作', dataIndex: 'option', width: 180,
|
||||
title: '操作',
|
||||
dataIndex: 'option',
|
||||
width: 80,
|
||||
valueType: 'option',
|
||||
render: (_, record) => {
|
||||
return (
|
||||
<>
|
||||
{record.status == 0 ?
|
||||
<Button size='small' onClick={() => { setFormValues(record); handleUpdateModalVis(true); }}>修改</Button>
|
||||
: <Button size='small' onClick={() => { setFormValues(record); handleUpdateModalVis(true); }}>查看</Button>
|
||||
}
|
||||
</>
|
||||
)
|
||||
}
|
||||
search: false,
|
||||
render: (_, record) =>
|
||||
record.state == 1 ? (
|
||||
<Button type="text" key="view" onClick={() => toView(record)}>
|
||||
查看
|
||||
</Button>
|
||||
) : (
|
||||
<Button type="text" key="edit" onClick={() => toEdit(record)} hidden={btnAuthority(["ebtp-supplier"])}>
|
||||
修改
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
];
|
||||
return (
|
||||
<PageHeaderWrapper>
|
||||
<ProTable<any>
|
||||
actionRef={actionRef}//action触发后更新表格
|
||||
columns={columns}//表格
|
||||
<Card
|
||||
title="我的发票列表"
|
||||
bodyStyle={{ padding: '1px 24px' }}
|
||||
style={{ borderRadius: 6 }}
|
||||
className="confirm"
|
||||
>
|
||||
<ProTable
|
||||
actionRef={actionRef} //action触发后更新表格
|
||||
columns={columns} //表格
|
||||
search={{ labelWidth: 70, span: 6 }}
|
||||
pagination={{ defaultPageSize: 10 }}//默认显示条数
|
||||
request={(params, sorter, filter) => getList({ ...params, sorter, filter }).then((res) => {
|
||||
console.log(res);
|
||||
const result = {
|
||||
data: res.data.payVoList,
|
||||
total: res.data.total,
|
||||
success: res.data.success,
|
||||
pageSize: res.data.pageSize,
|
||||
current: res.data.current
|
||||
};
|
||||
return result;
|
||||
})}
|
||||
bordered
|
||||
onReset={() => setPage({ pageSize: 10, pageNo: 1 })}
|
||||
pagination={{
|
||||
defaultPageSize: 10,
|
||||
onChange: (page, pageSize) => setPage({ pageSize: pageSize, pageNo: page }),
|
||||
onShowSizeChange: (current, pageSize) => setPage({ pageSize: pageSize, pageNo: current }),
|
||||
}} //默认显示条数
|
||||
options={false}
|
||||
size="small"
|
||||
request={async (params) =>
|
||||
await getList(params, page).then((res) => {
|
||||
let data = res.data.records;
|
||||
data.forEach((ele: any, index: any) => {
|
||||
ele.key = res.data.size * (res.data.current - 1) + index + 1;
|
||||
});
|
||||
return {
|
||||
data: data,
|
||||
total: res.data.total,
|
||||
success: res.success,
|
||||
pageSize: res.data.size,
|
||||
current: res.data.current,
|
||||
};
|
||||
})
|
||||
}
|
||||
/>
|
||||
{formValues && Object.keys(formValues).length ? (
|
||||
//分派界面
|
||||
<UpdateForm
|
||||
onCancel={() => {
|
||||
<EditInvoiceSupplier
|
||||
onCancel={() => {
|
||||
handleUpdateModalVis(false);
|
||||
setRecordValues(undefined);
|
||||
actionRef.current?.reload?.();
|
||||
}}
|
||||
onSubmit={async (value) => {
|
||||
const success = await handleUpdate(value);
|
||||
if (success) {
|
||||
handleUpdateModalVis(false);
|
||||
setFormValues({});
|
||||
}}
|
||||
onSubmit={async (value) => {
|
||||
const success = await handleUpdate(value);
|
||||
if (success) {
|
||||
handleUpdateModalVis(false);
|
||||
setFormValues({});
|
||||
if (actionRef.current) {
|
||||
actionRef.current.reload();
|
||||
}
|
||||
}
|
||||
}}
|
||||
updateModalVis={updateModalVis}
|
||||
values={formValues}
|
||||
/>
|
||||
) : null}
|
||||
</PageHeaderWrapper>
|
||||
|
||||
)
|
||||
setRecordValues(undefined);
|
||||
actionRef.current?.reload?.();
|
||||
}
|
||||
}}
|
||||
modalVisible={updateModalVis}
|
||||
values={recordValues}
|
||||
/>
|
||||
<ViewInvoiceSupplier
|
||||
onCancel={() => {
|
||||
handleViewModalVis(false);
|
||||
setRecordValues(undefined);
|
||||
}}
|
||||
modalVisible={viewModalVis}
|
||||
values={recordValues}
|
||||
/>
|
||||
</Card>
|
||||
);
|
||||
};
|
||||
export default invoice;
|
||||
export default InvoiceSupplier;
|
||||
|
Reference in New Issue
Block a user