Commit ddb59406 authored by wzy's avatar wzy

feat: 进销存-单据管理接口对接

parent 74f603e2
......@@ -59,11 +59,11 @@
/**
* 未审核
*/
export const DOC_STATUS_UNREVIEWED = 1;
export const DOC_STATUS_UNREVIEWED = 0;
/**
* 已审核
*/
export const DOC_STATUS_REVIEWED = 2;
export const DOC_STATUS_REVIEWED = 1;
export const DOC_STATUS = {
[DOC_STATUS_UNREVIEWED]: '未审核',
[DOC_STATUS_REVIEWED]: '已审核',
......
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { getIntl, history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Button, Card, Dropdown, Menu, Space, Badge, Popconfirm } from 'antd';
import { PlusOutlined, DownOutlined, DeleteOutlined, RollbackOutlined, SnippetsOutlined } from '@ant-design/icons';
import {
PlusOutlined,
DownOutlined,
DeleteOutlined,
RollbackOutlined,
SnippetsOutlined,
} from '@ant-design/icons';
import StandardTable from '@/components/StandardTable';
import moment from 'moment';
import { ColumnType } from 'antd/lib/table/interface';
import { getProductInvoicesList, getProductInvoicesTypeAll, getProductWarehouseAll, postProductInvoicesBatchDelete, postProductInvoicesBatchReview } from '@/services/ProductV2Api';
import {
getProductInvoicesList,
getProductInvoicesTypeAll,
getProductWarehouseAll,
postProductInvoicesBatchDelete,
postProductInvoicesBatchReview,
} from '@/services/ProductV2Api';
import EyePreview from '@/components/EyePreview';
import NiceForm from '@/components/NiceForm';
import { createFormActions } from '@formily/antd';
......@@ -14,7 +26,11 @@ import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilte
import { FORM_FILTER_PATH } from '@/formSchema/const';
import UploadModal from '@/components/UploadModal';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { DOC_STATUS_UNREVIEWED, DOC_STATUS_REVIEWED, DOC_STATUS } from '@/constants/commodity';
import {
DOC_STATUS_UNREVIEWED,
DOC_STATUS_REVIEWED,
DOC_STATUS,
} from '@/constants/commodity';
import { billsSchema } from './schema';
import { AuthUrl } from '@/components/AuthButton/AuthUrl';
import AuthButton from '@/components/AuthButton';
......@@ -27,6 +43,7 @@ const Bills: React.FC<{}> = () => {
const [visibleModal, setVisibleModal] = useState(false);
const [moreVisible, setMoreVisible] = useState(false);
const [batchLoading, setBatchLoading] = useState(false);
const [batchKey, setBatchKey] = useState<React.ReactText>('');
const fetchListData = async (params: any) => {
const res = await getProductInvoicesList(params);
......@@ -58,45 +75,47 @@ const Bills: React.FC<{}> = () => {
setBatchLoading(true);
postProductInvoicesBatchDelete({
ids,
}).then(res => {
if (res.code !== 1000) {
return;
}
if (callback) {
callback();
}
}).finally(() => {
setBatchLoading(false);
});
})
.then(res => {
if (res.code !== 1000) {
return;
}
if (callback) {
callback();
}
})
.finally(() => {
setBatchLoading(false);
});
};
const auditInvoices = (ids: number[], reviewType: number, callback?: () => void) => {
const auditInvoices = (
ids: number[],
reviewType: number,
callback?: () => void,
) => {
setBatchLoading(true);
postProductInvoicesBatchReview({
ids,
reviewType
}).then(res => {
if (res.code !== 1000) {
return;
}
if (callback) {
callback();
}
}).finally(() => {
setBatchLoading(false);
});
reviewType,
})
.then(res => {
if (res.code !== 1000) {
return;
}
if (callback) {
callback();
}
})
.finally(() => {
setBatchLoading(false);
});
};
const handleBatch = (key: React.ReactText) => {
if (!selectedRowKeys.length) {
return;
};
if (batchLoading) {
useEffect(() => {
if (batchLoading || !selectedRowKeys.length) {
return;
}
// 这边应该需要过滤下数据,先不做,看看后台是否有过滤
switch (key) {
switch (batchKey) {
case 'BatchDelete': {
deleteInvoices(selectedRowKeys, () => {
setSelectedRowKeys([]);
......@@ -124,10 +143,14 @@ const Bills: React.FC<{}> = () => {
default:
break;
}
setBatchKey('')
}, [batchKey]);
const handleBatch = (key: React.ReactText) => {
setBatchKey(key);
};
const menu = (
<AuthButton btnCode='bills.batch' >
<AuthButton btnCode="bills.batch">
<Menu onClick={e => handleBatch(e.key)}>
{/* <Menu.Item key="DeleteBatch" icon={<ZoomOutOutlined />}>
{intl.formatMessage({ id: 'stockSellStorage.shanchudaorupici' })}
......@@ -143,7 +166,6 @@ const Bills: React.FC<{}> = () => {
</Menu.Item>
</Menu>
</AuthButton>
);
const handleAudit = (id, reviewType) => {
......@@ -185,11 +207,6 @@ const Bills: React.FC<{}> = () => {
dataIndex: 'invoicesAbstract',
ellipsis: true,
},
// {
// title: intl.formatMessage({ id: 'stockSellStorage.huiyuanmingcheng' }),
// align: 'center',
// dataIndex: 'memberName',
// },
{
title: intl.formatMessage({ id: 'stockSellStorage.duiyingcangku' }),
align: 'center',
......@@ -199,24 +216,22 @@ const Bills: React.FC<{}> = () => {
title: intl.formatMessage({ id: 'stockSellStorage.jiaoyishijian' }),
align: 'center',
dataIndex: 'invoicesTime',
render: text => text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : '',
render: text => (text ? moment(text).format('YYYY-MM-DD HH:mm:ss') : ''),
},
// {
// title: intl.formatMessage({ id: 'stockSellStorage.dingdanhao' }),
// align: 'center',
// dataIndex: 'orderNo',
// },
{
title: intl.formatMessage({ id: 'stockSellStorage.danjuzhuangtai' }),
align: 'center',
dataIndex: 'state',
filters: [
{ text: DOC_STATUS[DOC_STATUS_UNREVIEWED], value: DOC_STATUS_UNREVIEWED },
{
text: DOC_STATUS[DOC_STATUS_UNREVIEWED],
value: DOC_STATUS_UNREVIEWED,
},
{ text: DOC_STATUS[DOC_STATUS_REVIEWED], value: DOC_STATUS_REVIEWED },
],
filterMultiple: false,
onFilter: (value, record) => record.state === value,
render: (text) => (
render: text => (
<Badge
color={text === DOC_STATUS_UNREVIEWED ? '#C1C7D0' : '#41CC9E'}
text={DOC_STATUS[text]}
......@@ -232,23 +247,35 @@ const Bills: React.FC<{}> = () => {
<>
{record.state === DOC_STATUS_UNREVIEWED && (
<>
<AuthButton btnCode='bills.edit' >
<Button type="link" onClick={() => history.push(`/memberCenter/tranactionAbility/stockSellStorage/bills/edit?id=${record.id}`)}>{intl.formatMessage({ id: 'stockSellStorage.xiugai' })}</Button>
<AuthButton btnCode="bills.edit">
<Button
type="link"
onClick={() =>
history.push(
`/memberCenter/tranactionAbility/stockSellStorage/bills/edit?id=${record.id}`,
)
}
>
{intl.formatMessage({ id: 'stockSellStorage.xiugai' })}
</Button>
</AuthButton>
<AuthButton btnCode='bills.shenhe' >
<Button type="link" onClick={() => handleAudit(record.id, 1)}>{intl.formatMessage({ id: 'stockSellStorage.shenhe' })}</Button>
<AuthButton btnCode="bills.shenhe">
<Button type="link" onClick={() => handleAudit(record.id, 1)}>
{intl.formatMessage({ id: 'stockSellStorage.shenhe' })}
</Button>
</AuthButton>
<AuthButton btnCode='bills.del' >
<AuthButton btnCode="bills.del">
<Popconfirm
title={intl.formatMessage({ id: 'stockSellStorage.quedingyaoshanchuma' })}
title={intl.formatMessage({
id: 'stockSellStorage.quedingyaoshanchuma',
})}
okText={intl.formatMessage({ id: 'stockSellStorage.shi' })}
cancelText={intl.formatMessage({ id: 'stockSellStorage.fou' })}
cancelText={intl.formatMessage({
id: 'stockSellStorage.fou',
})}
onConfirm={() => handleDelete(record.id)}
>
<Button
type="link"
danger
>
<Button type="link" danger>
{intl.formatMessage({ id: 'stockSellStorage.shanchu' })}
</Button>
</Popconfirm>
......@@ -256,7 +283,9 @@ const Bills: React.FC<{}> = () => {
</>
)}
{record.state === DOC_STATUS_REVIEWED && (
<Button type="link" onClick={() => handleAudit(record.id, 0)}>{intl.formatMessage({ id: 'stockSellStorage.fanshen' })}</Button>
<Button type="link" onClick={() => handleAudit(record.id, 0)}>
{intl.formatMessage({ id: 'stockSellStorage.fanshen' })}
</Button>
)}
</>
) : null;
......@@ -273,7 +302,7 @@ const Bills: React.FC<{}> = () => {
const controllerBtns = (
<Space>
<AuthButton btnCode='bills.add' >
<AuthButton btnCode="bills.add">
<Button
type="primary"
icon={<PlusOutlined />}
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getIntl } from 'umi';
import { DOC_STATUS, DOC_STATUS_UNREVIEWED, DOC_STATUS_REVIEWED } from '@/constants/commodity';
const intl = getIntl();
export const billsSchema: ISchema = {
type: 'object',
......@@ -56,24 +55,6 @@ export const billsSchema: ISchema = {
},
},
},
// memberName: {
// type: 'string',
// 'x-component-props': {
// placeholder: intl.formatMessage({id: 'stockSellStorage.huiyuanmingcheng'}),
// style: {
// width: 160,
// },
// },
// },
// orderNo: {
// type: 'string',
// 'x-component-props': {
// placeholder: intl.formatMessage({ id: 'stockSellStorage.dingdanhao' }),
// style: {
// width: 160,
// },
// },
// },
invoicesTypeId: {
type: 'string',
'x-component-props': {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment