Commit 02806211 authored by GuanHua's avatar GuanHua
parents dad373bf 4a39aa83
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>
)
};
......
......@@ -54,17 +54,17 @@ export const MEMBER_OUTER_STATUS_TYPE = {
// 会员内部状态 Tag badge map
export const MEMBER_INNER_STATUS_BADGE_COLOR = {
[MEMBER_INNER_STATUS_REGISTERED]: '#42526E',
[MEMBER_INNER_STATUS_UNCOMMITTED]: '#3F7ED2',
[MEMBER_INNER_STATUS_UNREVIEWED_1]: '#FF991F',
[MEMBER_INNER_STATUS_UNREVIEWED_2]: '#FF991F',
[MEMBER_INNER_STATUS_FAILED]: '#E63F3B',
[MEMBER_INNER_STATUS_SUCCESS]: '#00B37A',
[MEMBER_INNER_STATUS_UNCOMMITTED]: '#669EDE',
[MEMBER_INNER_STATUS_UNREVIEWED_1]: '#FFC400',
[MEMBER_INNER_STATUS_UNREVIEWED_2]: '#FFC400',
[MEMBER_INNER_STATUS_FAILED]: '#EF6260',
[MEMBER_INNER_STATUS_SUCCESS]: '#41CC9E',
};
// 会员外部状态 Tag badge map
export const MEMBER_OUTER_STATUS_BADGE_COLOR = {
[MEMBER_OUTER_STATUS_UNCOMMITTED]: '#3F7ED2',
[MEMBER_OUTER_STATUS_UNREVIEWED]: '#FF991F',
[MEMBER_OUTER_STATUS_FAILED]: '#E63F3B',
[MEMBER_OUTER_STATUS_SUCCESS]: '#00B37A',
[MEMBER_OUTER_STATUS_UNCOMMITTED]: '#669EDE',
[MEMBER_OUTER_STATUS_UNREVIEWED]: '#FFC400',
[MEMBER_OUTER_STATUS_FAILED]: '#EF6260',
[MEMBER_OUTER_STATUS_SUCCESS]: '#41CC9E',
};
\ No newline at end of file
......@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = {
required: true,
'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5,
},
'x-rules': [
......
......@@ -137,7 +137,6 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea',
'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5,
},
'x-rules': [
......
......@@ -144,7 +144,6 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea',
'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5,
},
'x-rules': [
......
......@@ -222,9 +222,14 @@ export const auditModalSchema: ISchema = {
'x-component': 'textarea',
'x-component-props': {
placeholder: '在此输入你的内容,最长120个字符,60个汉字',
maxLength: 60,
rows: 5,
},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 120,
}
],
},
},
},
......
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>
);
};
......
.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 { history } from 'umi';
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 { ColumnType } from 'antd/lib/table/interface';
import EyePreview from '@/components/EyePreview';
......@@ -9,47 +12,39 @@ import NiceForm from '@/components/NiceForm';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { inventorySchema } from './schema';
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 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 modalFormActions = createFormActions();
const Inventory: React.FC<{}> = () => {
const [current, setCurrent] = useState(null);
const [modalVisible, setModalVisible] = useState(false);
const [confirmLoading, setConfirmLoading] = useState(false);
const ref = useRef<any>({});
const handleUpdateSafetyStock = record => {
setCurrent(record);
setModalVisible(true);
};
const columns: ColumnType<any>[] = [
{
title: 'ID',
align: 'center',
dataIndex: 'id',
key: 'id',
},
{
title: '商品名称',
dataIndex: 'goodsName',
align: 'center',
key: 'goodsName',
render: (text: any, record: any) => (
<EyePreview
url={`/repositories/viewRepository?id=${record.key}&preview=1`}
url={`/repositories/viewRepository?id=${record.id}&preview=1`}
>
{text}
</EyePreview>
......@@ -57,65 +52,98 @@ const Inventory: React.FC<{}> = () => {
},
{
title: '规格型号',
align: 'center',
dataIndex: 'specifications',
key: 'specifications',
align: 'center',
},
{
title: '品类',
align: 'center',
dataIndex: 'category',
key: 'category',
align: 'center',
},
{
title: '品牌',
align: 'center',
dataIndex: 'brand',
key: 'brand',
align: 'center',
},
{
title: '单位',
align: 'center',
dataIndex: 'unit',
key: 'unit',
align: 'center',
},
{
title: '价格',
align: 'center',
dataIndex: 'price',
key: 'price',
dataIndex: 'costPrice',
align: 'center',
render: text => ${text}`
},
{
title: '仓库',
align: 'center',
dataIndex: 'warehouse',
key: 'warehouse',
align: 'center',
},
{
title: '库存',
align: 'center',
dataIndex: 'inventory',
key: 'inventory',
align: 'center',
},
{
title: '安全库存',
align: 'center',
title: '金额',
dataIndex: 'price',
align: 'center',
render: text => ${text}`
},
{
title: (
<Space>
安全库存
<SettingOutlined />
</Space>
),
dataIndex: 'safeStock',
key: 'safeStock',
render: (text: any, record: any) => {
return (
<Input
value={record.safeInventory}
allowClear
onChange={e => handleChange(e)}
></Input>
);
},
align: 'center',
render: (text, record) => (
<div className={styles.safe} onClick={() => handleUpdateSafetyStock(record)}>
{text}
</div>
),
},
];
const handleChange = (e: any) => {
console.log(e);
const fetchListData = (params: any) => {
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 (
......@@ -124,8 +152,10 @@ const Inventory: React.FC<{}> = () => {
<StandardTable
columns={columns}
currentRef={ref}
tableProps={{ rowKey: 'key' }}
fetchTableData={(params: any) => fetchData(params)}
tableProps={{
rowKey: 'id',
}}
fetchTableData={(params: any) => fetchListData(params)}
controlRender={
<NiceForm
actions={formActions}
......@@ -134,15 +164,37 @@ const Inventory: React.FC<{}> = () => {
useStateFilterSearchLinkageEffect(
$,
actions,
'search',
'goodsName',
FORM_FILTER_PATH,
);
useAsyncSelect('warehouseId', fetchInventory);
}}
schema={inventorySchema}
/>
}
/>
</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>
);
};
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { PATTERN_MAPS } from '@/constants/regExp';
export const inventorySchema: ISchema = {
type: 'object',
properties: {
megaLayout: {
type: 'object',
'x-component': 'mega-layout',
'x-component': 'mega-layout',
properties: {
search: {
goodsName: {
type: 'string',
'x-component': 'Search',
'x-mega-props': {},
......@@ -21,36 +22,51 @@ export const inventorySchema: ISchema = {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
inline: true,
grid: true,
full: true,
autoRow: true,
columns: 6,
},
properties: {
itemNo: {
type: 'string',
'x-component-props': {
placeholder: '货号',
},
},
specifications: {
type: 'string',
'x-component-props': {
placeholder: '请选择',
placeholder: '规格型号',
},
enum: [],
},
category: {
type: 'string',
'x-component-props': {
placeholder: '请选择品类',
placeholder: '品类',
},
enum: [],
},
brand: {
type: 'string',
'x-component-props': {
placeholder: '请选择品牌',
placeholder: '品牌',
},
enum: [],
},
warehouse: {
warehouseId: {
type: 'string',
'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 = {
},
},
};
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