Commit 9bd7f371 authored by XieZhiXiong's avatar XieZhiXiong

完善

parent 943827f6
import React, { useState, useEffect } from 'react';
import { Dropdown, Space, Menu, message } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons';
import { getAuth, setAuth, setRouters } from '@/utils/auth';
import { PublicApi } from '@/services/api';
......@@ -65,9 +66,10 @@ const Roles: React.FC = () => {
overlay={menuHeaderDropdown}
placement="bottomRight"
>
<span style={{ cursor: 'pointer', padding: '0 15px' }}>
<Space size={5} style={{ cursor: 'pointer', padding: '0 15px' }}>
{curRole?.memberRoleName}
</span>
<CaretDownOutlined />
</Space>
</Dropdown>
)
};
......
import React, { useState, useEffect, useRef } from 'react';
import { Button, Card, message } from 'antd';
import { Button, Card, Spin, message } from 'antd';
import { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi';
import { usePageStatus } from '@/hooks/usePageStatus';
......@@ -44,6 +44,7 @@ const AddBills: React.FC<{}> = (props: any) => {
const { pageStatus, preview, id } = usePageStatus();
const [visible, setVisible] = useState(false);
const [productRowSelection, productRowCtl] = useRowSelectionTable({ type: 'checkbox' });
const [billInfo, setBillInfo] = useState(null);
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
......@@ -99,6 +100,24 @@ const AddBills: React.FC<{}> = (props: any) => {
return [];
}
// 获取单据详情
const getBillInfo = () => {
if (!id) {
return;
}
setInfoLoading(true);
PublicApi.getWarehouseInvoicesDetails({
invoicesId: id,
}).then(res => {
if (res.code !== 1000) {
return;
}
setBillInfo(res.data);
}).finally(() => {
setInfoLoading(false);
});
};
// 弹出单据明细
const handleAdd = () => {
const orderNoVal = addSchemaAction.getFieldValue('orderNo');
......@@ -122,7 +141,7 @@ const AddBills: React.FC<{}> = (props: any) => {
);
useEffect(() => {
getBillInfo();
}, []);
const handleSubmit = value => {
......@@ -137,18 +156,22 @@ const AddBills: React.FC<{}> = (props: any) => {
switch (invoicesTypeId) {
// 采购入库单只能选择 订单
case DOC_TYPE_PURCHASE_RECEIPT: {
PublicApi.postOrderPurchaseReceiptAdd(payload)
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
if (!id) {
PublicApi.postOrderPurchaseReceiptAdd(payload)
.then(res => {
if (res.code !== 1000) {
return;
}
setUnsaved(false);
setTimeout(() => {
history.goBack();
}, 800);
}).finally(() => {
setSubmitLoading(false);
});
} else {
// update action
}
break;
}
......@@ -233,92 +256,94 @@ const AddBills: React.FC<{}> = (props: any) => {
}
return (
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={
pageStatus === 0
? '新建单据'
: pageStatus === 1
? '编辑单据'
: '查看单据'
}
extra={
preview != '1'
? [
<Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => addSchemaAction.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
expressionScope={{
tableAddButton,
}}
components={{
RadioGroup: Radio.Group,
ArrayTable,
}}
effects={($, actions) => {
createEffects($, actions)
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
onSubmit={handleSubmit}
actions={addSchemaAction}
schema={addBillSchema}
/>
</Card>
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={
pageStatus === 0
? '新建单据'
: pageStatus === 1
? '编辑单据'
: '查看单据'
}
extra={
preview != '1'
? [
<Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => addSchemaAction.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
expressionScope={{
tableAddButton,
}}
components={{
RadioGroup: Radio.Group,
ArrayTable,
}}
effects={($, actions) => {
createEffects($, actions)
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
onSubmit={handleSubmit}
actions={addSchemaAction}
schema={addBillSchema}
/>
</Card>
<ModalTable
modalTitle='选择货品'
confirm={handleOkAddProduct}
cancel={() => setVisible(false)}
visible={visible}
columns={goodsColumns}
rowSelection={productRowSelection}
fetchTableData={params => fetchProductList(params)}
formilyProps={
{
ctx: {
schema: goodsSearchSchema,
components: {
Search,
Submit,
},
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
useAsyncSelect('brandId', fetchBrand, ['name', 'id']);
useAsyncSelect('customerCategoryId', fetchCustomerCategory, ['name', 'id']);
},
inline: false,
<ModalTable
modalTitle='选择货品'
confirm={handleOkAddProduct}
cancel={() => setVisible(false)}
visible={visible}
columns={goodsColumns}
rowSelection={productRowSelection}
fetchTableData={params => fetchProductList(params)}
formilyProps={
{
ctx: {
schema: goodsSearchSchema,
components: {
Search,
Submit,
},
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
useAsyncSelect('brandId', fetchBrand, ['name', 'id']);
useAsyncSelect('customerCategoryId', fetchCustomerCategory, ['name', 'id']);
},
inline: false,
}
}
}
}
tableProps={{
rowKey: 'id',
}}
/>
tableProps={{
rowKey: 'id',
}}
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper>
</Spin>
);
};
......
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