Commit 02806211 authored by GuanHua's avatar GuanHua
parents dad373bf 4a39aa83
import React, { useState, useEffect } from 'react'; import React, { useState, useEffect } from 'react';
import { Dropdown, Space, Menu, message } from 'antd'; import { Dropdown, Space, Menu, message } from 'antd';
import { CaretDownOutlined } from '@ant-design/icons';
import { getAuth, setAuth, setRouters } from '@/utils/auth'; import { getAuth, setAuth, setRouters } from '@/utils/auth';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
...@@ -65,9 +66,10 @@ const Roles: React.FC = () => { ...@@ -65,9 +66,10 @@ const Roles: React.FC = () => {
overlay={menuHeaderDropdown} overlay={menuHeaderDropdown}
placement="bottomRight" placement="bottomRight"
> >
<span style={{ cursor: 'pointer', padding: '0 15px' }}> <Space size={5} style={{ cursor: 'pointer', padding: '0 15px' }}>
{curRole?.memberRoleName} {curRole?.memberRoleName}
</span> <CaretDownOutlined />
</Space>
</Dropdown> </Dropdown>
) )
}; };
......
...@@ -54,17 +54,17 @@ export const MEMBER_OUTER_STATUS_TYPE = { ...@@ -54,17 +54,17 @@ export const MEMBER_OUTER_STATUS_TYPE = {
// 会员内部状态 Tag badge map // 会员内部状态 Tag badge map
export const MEMBER_INNER_STATUS_BADGE_COLOR = { export const MEMBER_INNER_STATUS_BADGE_COLOR = {
[MEMBER_INNER_STATUS_REGISTERED]: '#42526E', [MEMBER_INNER_STATUS_REGISTERED]: '#42526E',
[MEMBER_INNER_STATUS_UNCOMMITTED]: '#3F7ED2', [MEMBER_INNER_STATUS_UNCOMMITTED]: '#669EDE',
[MEMBER_INNER_STATUS_UNREVIEWED_1]: '#FF991F', [MEMBER_INNER_STATUS_UNREVIEWED_1]: '#FFC400',
[MEMBER_INNER_STATUS_UNREVIEWED_2]: '#FF991F', [MEMBER_INNER_STATUS_UNREVIEWED_2]: '#FFC400',
[MEMBER_INNER_STATUS_FAILED]: '#E63F3B', [MEMBER_INNER_STATUS_FAILED]: '#EF6260',
[MEMBER_INNER_STATUS_SUCCESS]: '#00B37A', [MEMBER_INNER_STATUS_SUCCESS]: '#41CC9E',
}; };
// 会员外部状态 Tag badge map // 会员外部状态 Tag badge map
export const MEMBER_OUTER_STATUS_BADGE_COLOR = { export const MEMBER_OUTER_STATUS_BADGE_COLOR = {
[MEMBER_OUTER_STATUS_UNCOMMITTED]: '#3F7ED2', [MEMBER_OUTER_STATUS_UNCOMMITTED]: '#669EDE',
[MEMBER_OUTER_STATUS_UNREVIEWED]: '#FF991F', [MEMBER_OUTER_STATUS_UNREVIEWED]: '#FFC400',
[MEMBER_OUTER_STATUS_FAILED]: '#E63F3B', [MEMBER_OUTER_STATUS_FAILED]: '#EF6260',
[MEMBER_OUTER_STATUS_SUCCESS]: '#00B37A', [MEMBER_OUTER_STATUS_SUCCESS]: '#41CC9E',
}; };
\ No newline at end of file
...@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = { ...@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = {
required: true, required: true,
'x-component-props': { 'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字', placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5, rows: 5,
}, },
'x-rules': [ 'x-rules': [
......
...@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = { ...@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea', 'x-component': 'textarea',
'x-component-props': { 'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字', placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5, rows: 5,
}, },
'x-rules': [ 'x-rules': [
......
...@@ -144,7 +144,6 @@ export const auditModalSchema: ISchema = { ...@@ -144,7 +144,6 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea', 'x-component': 'textarea',
'x-component-props': { 'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字', placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5, rows: 5,
}, },
'x-rules': [ 'x-rules': [
......
...@@ -222,9 +222,14 @@ export const auditModalSchema: ISchema = { ...@@ -222,9 +222,14 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea', 'x-component': 'textarea',
'x-component-props': { 'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字', placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5, rows: 5,
}, },
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 120,
}
],
}, },
}, },
}, },
......
import React, { useState, useEffect, useRef } from 'react'; 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 { Radio, ArrayTable } from '@formily/antd-components';
import { history, Prompt } from 'umi'; import { history, Prompt } from 'umi';
import { usePageStatus } from '@/hooks/usePageStatus'; import { usePageStatus } from '@/hooks/usePageStatus';
...@@ -44,6 +44,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -44,6 +44,7 @@ const AddBills: React.FC<{}> = (props: any) => {
const { pageStatus, preview, id } = usePageStatus(); const { pageStatus, preview, id } = usePageStatus();
const [visible, setVisible] = useState(false); const [visible, setVisible] = useState(false);
const [productRowSelection, productRowCtl] = useRowSelectionTable({ type: 'checkbox' }); const [productRowSelection, productRowCtl] = useRowSelectionTable({ type: 'checkbox' });
const [billInfo, setBillInfo] = useState(null);
const [unsaved, setUnsaved] = useState(false); const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false); const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false); const [submitLoading, setSubmitLoading] = useState(false);
...@@ -99,6 +100,24 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -99,6 +100,24 @@ const AddBills: React.FC<{}> = (props: any) => {
return []; 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 handleAdd = () => {
const orderNoVal = addSchemaAction.getFieldValue('orderNo'); const orderNoVal = addSchemaAction.getFieldValue('orderNo');
...@@ -122,7 +141,7 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -122,7 +141,7 @@ const AddBills: React.FC<{}> = (props: any) => {
); );
useEffect(() => { useEffect(() => {
getBillInfo();
}, []); }, []);
const handleSubmit = value => { const handleSubmit = value => {
...@@ -137,18 +156,22 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -137,18 +156,22 @@ const AddBills: React.FC<{}> = (props: any) => {
switch (invoicesTypeId) { switch (invoicesTypeId) {
// 采购入库单只能选择 订单 // 采购入库单只能选择 订单
case DOC_TYPE_PURCHASE_RECEIPT: { case DOC_TYPE_PURCHASE_RECEIPT: {
PublicApi.postOrderPurchaseReceiptAdd(payload) if (!id) {
.then(res => { PublicApi.postOrderPurchaseReceiptAdd(payload)
if (res.code !== 1000) { .then(res => {
return; if (res.code !== 1000) {
} return;
setUnsaved(false); }
setTimeout(() => { setUnsaved(false);
history.goBack(); setTimeout(() => {
}, 800); history.goBack();
}).finally(() => { }, 800);
setSubmitLoading(false); }).finally(() => {
}); setSubmitLoading(false);
});
} else {
// update action
}
break; break;
} }
...@@ -233,92 +256,94 @@ const AddBills: React.FC<{}> = (props: any) => { ...@@ -233,92 +256,94 @@ const AddBills: React.FC<{}> = (props: any) => {
} }
return ( return (
<PageHeaderWrapper <Spin spinning={infoLoading}>
onBack={() => history.goBack()} <PageHeaderWrapper
backIcon={<ReutrnEle description="返回" />} onBack={() => history.goBack()}
title={ backIcon={<ReutrnEle description="返回" />}
pageStatus === 0 title={
? '新建单据' pageStatus === 0
: pageStatus === 1 ? '新建单据'
? '编辑单据' : pageStatus === 1
: '查看单据' ? '编辑单据'
} : '查看单据'
extra={ }
preview != '1' extra={
? [ preview != '1'
<Button ? [
key="1" <Button
type="primary" key="1"
icon={<SaveOutlined />} type="primary"
loading={submitLoading} icon={<SaveOutlined />}
onClick={() => addSchemaAction.submit()} loading={submitLoading}
> onClick={() => addSchemaAction.submit()}
保存 >
</Button>, 保存
] </Button>,
: [] ]
} : []
> }
<Card> >
<NiceForm <Card>
expressionScope={{ <NiceForm
tableAddButton, expressionScope={{
}} tableAddButton,
components={{ }}
RadioGroup: Radio.Group, components={{
ArrayTable, RadioGroup: Radio.Group,
}} ArrayTable,
effects={($, actions) => { }}
createEffects($, actions) effects={($, actions) => {
onFormInputChange$().subscribe(() => { createEffects($, actions)
if (!unsaved) { onFormInputChange$().subscribe(() => {
setUnsaved(true); if (!unsaved) {
} setUnsaved(true);
}); }
}} });
onSubmit={handleSubmit} }}
actions={addSchemaAction} onSubmit={handleSubmit}
schema={addBillSchema} actions={addSchemaAction}
/> schema={addBillSchema}
</Card> />
</Card>
<ModalTable <ModalTable
modalTitle='选择货品' modalTitle='选择货品'
confirm={handleOkAddProduct} confirm={handleOkAddProduct}
cancel={() => setVisible(false)} cancel={() => setVisible(false)}
visible={visible} visible={visible}
columns={goodsColumns} columns={goodsColumns}
rowSelection={productRowSelection} rowSelection={productRowSelection}
fetchTableData={params => fetchProductList(params)} fetchTableData={params => fetchProductList(params)}
formilyProps={ formilyProps={
{ {
ctx: { ctx: {
schema: goodsSearchSchema, schema: goodsSearchSchema,
components: { components: {
Search, Search,
Submit, Submit,
}, },
effects: ($, actions) => { effects: ($, actions) => {
useStateFilterSearchLinkageEffect( useStateFilterSearchLinkageEffect(
$, $,
actions, actions,
'name', 'name',
FORM_FILTER_PATH, FORM_FILTER_PATH,
); );
useAsyncSelect('brandId', fetchBrand, ['name', 'id']); useAsyncSelect('brandId', fetchBrand, ['name', 'id']);
useAsyncSelect('customerCategoryId', fetchCustomerCategory, ['name', 'id']); useAsyncSelect('customerCategoryId', fetchCustomerCategory, ['name', 'id']);
}, },
inline: false, inline: false,
}
} }
} }
} tableProps={{
tableProps={{ rowKey: 'id',
rowKey: 'id', }}
}} />
/>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" /> <Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper> </PageHeaderWrapper>
</Spin>
); );
}; };
......
.safe {
padding: 4px 11px;
min-height: 32px;
border-radius: 4px;
border: 1px solid #d9d9d9;
cursor: pointer;
}
\ No newline at end of file
import React, { useState, useEffect, useRef } from 'react'; import React, { useState, useEffect, useRef } from 'react';
import { history } from 'umi'; import { history } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout'; import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { Input, Card } from 'antd'; import { Input, Card, Space, Modal } from 'antd';
import {
SettingOutlined,
} from '@ant-design/icons';
import { StandardTable } from 'god'; import { StandardTable } from 'god';
import { ColumnType } from 'antd/lib/table/interface'; import { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview'; import EyePreview from '@/components/EyePreview';
...@@ -9,47 +12,39 @@ import NiceForm from '@/components/NiceForm'; ...@@ -9,47 +12,39 @@ import NiceForm from '@/components/NiceForm';
import { createFormActions, FormEffectHooks } from '@formily/antd'; import { createFormActions, FormEffectHooks } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'; import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { inventorySchema } from './schema';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { inventorySchema, safetyModalSchema } from './schema';
import styles from './index.less';
const formActions = createFormActions(); const formActions = createFormActions();
const modalFormActions = createFormActions();
// 模拟请求
const fetchData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getWarehouseInventoryList({
itemNo: '',
goodsName: '',
specifications: '',
category: '',
brand: '',
warehouseId: '',
current: params.current,
pageSize: params.pageSize,
}).then(res => {
resolve(res.data);
});
});
};
const Inventory: React.FC<{}> = () => { const Inventory: React.FC<{}> = () => {
const [current, setCurrent] = useState(null);
const [modalVisible, setModalVisible] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const ref = useRef<any>({}); const ref = useRef<any>({});
const handleUpdateSafetyStock = record => {
setCurrent(record);
setModalVisible(true);
};
const columns: ColumnType<any>[] = [ const columns: ColumnType<any>[] = [
{ {
title: 'ID', title: 'ID',
align: 'center', align: 'center',
dataIndex: 'id', dataIndex: 'id',
key: 'id',
}, },
{ {
title: '商品名称', title: '商品名称',
dataIndex: 'goodsName', dataIndex: 'goodsName',
align: 'center', align: 'center',
key: 'goodsName',
render: (text: any, record: any) => ( render: (text: any, record: any) => (
<EyePreview <EyePreview
url={`/repositories/viewRepository?id=${record.key}&preview=1`} url={`/repositories/viewRepository?id=${record.id}&preview=1`}
> >
{text} {text}
</EyePreview> </EyePreview>
...@@ -57,65 +52,98 @@ const Inventory: React.FC<{}> = () => { ...@@ -57,65 +52,98 @@ const Inventory: React.FC<{}> = () => {
}, },
{ {
title: '规格型号', title: '规格型号',
align: 'center',
dataIndex: 'specifications', dataIndex: 'specifications',
key: 'specifications', align: 'center',
}, },
{ {
title: '品类', title: '品类',
align: 'center',
dataIndex: 'category', dataIndex: 'category',
key: 'category', align: 'center',
}, },
{ {
title: '品牌', title: '品牌',
align: 'center',
dataIndex: 'brand', dataIndex: 'brand',
key: 'brand', align: 'center',
}, },
{ {
title: '单位', title: '单位',
align: 'center',
dataIndex: 'unit', dataIndex: 'unit',
key: 'unit', align: 'center',
}, },
{ {
title: '价格', title: '价格',
align: 'center', dataIndex: 'costPrice',
dataIndex: 'price', align: 'center',
key: 'price', render: text => ${text}`
}, },
{ {
title: '仓库', title: '仓库',
align: 'center',
dataIndex: 'warehouse', dataIndex: 'warehouse',
key: 'warehouse', align: 'center',
}, },
{ {
title: '库存', title: '库存',
align: 'center',
dataIndex: 'inventory', dataIndex: 'inventory',
key: 'inventory', align: 'center',
}, },
{ {
title: '安全库存', title: '金额',
align: 'center', dataIndex: 'price',
align: 'center',
render: text => ${text}`
},
{
title: (
<Space>
安全库存
<SettingOutlined />
</Space>
),
dataIndex: 'safeStock', dataIndex: 'safeStock',
key: 'safeStock', align: 'center',
render: (text: any, record: any) => { render: (text, record) => (
return ( <div className={styles.safe} onClick={() => handleUpdateSafetyStock(record)}>
<Input {text}
value={record.safeInventory} </div>
allowClear ),
onChange={e => handleChange(e)}
></Input>
);
},
}, },
]; ];
const handleChange = (e: any) => { const fetchListData = (params: any) => {
console.log(e); return new Promise((resolve, reject) => {
PublicApi.getWarehouseInventoryList(params)
.then(res => {
if (res.code === 1000) {
resolve(res.data);
}
reject();
})
.catch(() => {
reject();
});
});
};
// 获取对应仓库
const fetchInventory = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll();
return data.map(v => ({ label: v.name, value: v.id }));
};
// 修改安全库存
const handleSubmit = async values => {
setConfirmLoading(true);
const res = await PublicApi.postWarehouseInventorySafetyUpdate({
id: current.id,
safetyInvoices: +values.safetyInvoices,
});
if (res.code === 1000) {
setModalVisible(false);
ref.current.reload();
}
setConfirmLoading(false);
}; };
return ( return (
...@@ -124,8 +152,10 @@ const Inventory: React.FC<{}> = () => { ...@@ -124,8 +152,10 @@ const Inventory: React.FC<{}> = () => {
<StandardTable <StandardTable
columns={columns} columns={columns}
currentRef={ref} currentRef={ref}
tableProps={{ rowKey: 'key' }} tableProps={{
fetchTableData={(params: any) => fetchData(params)} rowKey: 'id',
}}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={ controlRender={
<NiceForm <NiceForm
actions={formActions} actions={formActions}
...@@ -134,15 +164,37 @@ const Inventory: React.FC<{}> = () => { ...@@ -134,15 +164,37 @@ const Inventory: React.FC<{}> = () => {
useStateFilterSearchLinkageEffect( useStateFilterSearchLinkageEffect(
$, $,
actions, actions,
'search', 'goodsName',
FORM_FILTER_PATH, FORM_FILTER_PATH,
); );
useAsyncSelect('warehouseId', fetchInventory);
}} }}
schema={inventorySchema} schema={inventorySchema}
/> />
} }
/> />
</Card> </Card>
<Modal
title="调整安全库存"
visible={modalVisible}
confirmLoading={confirmLoading}
onOk={() => modalFormActions.submit()}
onCancel={() => setModalVisible(false)}
destroyOnClose
>
<NiceForm
effects={($, { setFieldState }) => {
}}
initialValues={{
safetyInvoices: current?.safeStock,
}}
actions={modalFormActions}
schema={safetyModalSchema}
onSubmit={handleSubmit}
/>
</Modal>
</PageHeaderWrapper> </PageHeaderWrapper>
); );
}; };
......
import { ISchema } from '@formily/antd'; import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PATTERN_MAPS } from '@/constants/regExp';
export const inventorySchema: ISchema = { export const inventorySchema: ISchema = {
type: 'object', type: 'object',
properties: { properties: {
megaLayout: { megaLayout: {
type: 'object', type: 'object',
'x-component': 'mega-layout', 'x-component': 'mega-layout',
properties: { properties: {
search: { goodsName: {
type: 'string', type: 'string',
'x-component': 'Search', 'x-component': 'Search',
'x-mega-props': {}, 'x-mega-props': {},
...@@ -21,36 +22,51 @@ export const inventorySchema: ISchema = { ...@@ -21,36 +22,51 @@ export const inventorySchema: ISchema = {
type: 'object', type: 'object',
'x-component': 'mega-layout', 'x-component': 'mega-layout',
'x-component-props': { 'x-component-props': {
inline: true, grid: true,
full: true,
autoRow: true,
columns: 6,
}, },
properties: { properties: {
itemNo: {
type: 'string',
'x-component-props': {
placeholder: '货号',
},
},
specifications: { specifications: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '请选择', placeholder: '规格型号',
}, },
enum: [],
}, },
category: { category: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '请选择品类', placeholder: '品类',
}, },
enum: [],
}, },
brand: { brand: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '请选择品牌', placeholder: '品牌',
}, },
enum: [],
}, },
warehouse: { warehouseId: {
type: 'string', type: 'string',
'x-component-props': { 'x-component-props': {
placeholder: '请选择仓库', placeholder: '仓库',
},
enum: [],
},
submit: {
'x-component': 'Submit',
'x-mega-props': {
span: 1,
},
'x-component-props': {
children: '查询',
}, },
enum: [],
}, },
}, },
}, },
...@@ -58,3 +74,32 @@ export const inventorySchema: ISchema = { ...@@ -58,3 +74,32 @@ export const inventorySchema: ISchema = {
}, },
}, },
}; };
export const safetyModalSchema: ISchema = {
type: 'object',
properties: {
MEAGLAYOUT: {
type: 'object',
'x-component': 'Mega-Layout',
'x-component-props': {
labelAlign: 'top',
},
properties: {
safetyInvoices: {
type: 'string',
title: '安全库存',
required: true,
'x-component-props': {
placeholder: '请输入',
},
'x-rules': [
{
pattern: PATTERN_MAPS.weight,
message: '请输入正数',
},
],
},
},
},
},
};
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