Commit b67e6c03 authored by XieZhiXiong's avatar XieZhiXiong

调整进销存路由相关

parent b9e57133
......@@ -90,14 +90,14 @@ const TranactionRoute: RouterChild = {
path: '/memberCenter/tranactionAbility/stockSellStorage/warehouse/edit',
name: 'editWarehouse',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/warehouse/addWarehouse',
component: '@/pages/transaction/stockSellStorage/warehouse/editWarehouse',
},
// 仓库-详情
{
path: '/memberCenter/tranactionAbility/stockSellStorage/warehouse/detail',
name: 'warehouseDetail',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/warehouse/addWarehouse',
component: '@/pages/transaction/stockSellStorage/warehouse/warehouseDetail',
},
// 单据类型
{
......@@ -117,14 +117,14 @@ const TranactionRoute: RouterChild = {
path: '/memberCenter/tranactionAbility/stockSellStorage/billsType/edit',
name: 'editBillsType',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/billsType/addBillsType',
component: '@/pages/transaction/stockSellStorage/billsType/editBillsType',
},
// 单据类型-详情
{
path: '/memberCenter/tranactionAbility/stockSellStorage/billsType/detail',
name: 'billsTypeDetail',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/billsType/addBillsType',
component: '@/pages/transaction/stockSellStorage/billsType/billsTypeDetail',
},
// 单据
{
......@@ -137,21 +137,21 @@ const TranactionRoute: RouterChild = {
path: '/memberCenter/tranactionAbility/stockSellStorage/bills/add',
name: 'addBills',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/bills/addBills/index',
component: '@/pages/transaction/stockSellStorage/bills/addBills',
},
// 单据-编辑
{
path: '/memberCenter/tranactionAbility/stockSellStorage/bills/edit',
name: 'editBills',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/bills/addBills/index',
component: '@/pages/transaction/stockSellStorage/bills/editBills',
},
// 单据-详情
{
path: '/memberCenter/tranactionAbility/stockSellStorage/bills/detail',
name: 'billsDetail',
hideInMenu: true,
component: '@/pages/transaction/stockSellStorage/bills/addBills/index',
component: '@/pages/transaction/stockSellStorage/bills/billsDetail',
},
// 库存
{
......
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillsForm from './components/BillsForm';
const AddBills: React.FC = () => {
const {
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
} = usePageStatus();
return (
<BillsForm
invoicesTypeId={invoicesTypeId}
relevanceInvoices={relevanceInvoices}
relevanceInvoicesId={relevanceInvoicesId}
/>
);
};
export default AddBills;
\ No newline at end of file
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillsForm from './components/BillsForm';
const BillsDetail: React.FC = () => {
const {
id,
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
} = usePageStatus();
return (
<BillsForm
id={id}
invoicesTypeId={invoicesTypeId}
relevanceInvoices={relevanceInvoices}
relevanceInvoicesId={relevanceInvoicesId}
/>
);
};
export default BillsDetail;
\ No newline at end of file
......@@ -2,7 +2,7 @@
* @Author: XieZhiXiong
* @Date: 2020-09-16 15:16:47
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-10-22 18:49:22
* @LastEditTime: 2020-10-23 16:00:01
* @Description: 联动逻辑相关
*/
import { Modal } from 'antd';
......
......@@ -42,15 +42,23 @@ const {
onFormInputChange$,
} = FormEffectHooks;
const AddBills: React.FC<{}> = (props: any) => {
const {
pageStatus,
preview,
id,
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
} = usePageStatus();
interface BillsFormProps {
id?: string;
validateId?: string;
// 是否是编辑的
isEdit?: boolean;
invoicesTypeId: string; // 单据类型ID
relevanceInvoices: string; // 对应单据
relevanceInvoicesId: string, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
};
const BillsForm: React.FC<BillsFormProps> = ({
id,
isEdit = false,
invoicesTypeId,
relevanceInvoices,
relevanceInvoicesId,
}) => {
const [visible, setVisible] = useState(false);
const [productRowSelection, productRowCtl] = useRowSelectionTable({ type: 'checkbox' });
const [billInfo, setBillInfo] = useState<{[key: string]: any}>({ transactionTime: moment().format('YYYY-MM-DD HH:mm:ss') });
......@@ -136,8 +144,6 @@ const AddBills: React.FC<{}> = (props: any) => {
...rest
} = res.data;
console.log('res', res.data.relevanceInvoicesId)
const details = invoicesDetailsList ? invoicesDetailsList.map(item => ({
...item,
product: item.productId,
......@@ -347,7 +353,7 @@ const AddBills: React.FC<{}> = (props: any) => {
setVisible(true);
};
const TableAddButton = pageStatus !== PageStatus.PREVIEW ? (
const TableAddButton = isEdit || !id ? (
<Button
style={{ marginBottom: 16 }}
block
......@@ -393,6 +399,9 @@ const AddBills: React.FC<{}> = (props: any) => {
// 采购入库单
case DOC_TYPE_PURCHASE_RECEIPT: {
if (!id) {
if (isEdit) {
return;
}
PublicApi.postOrderPurchaseReceiptAdd(payload)
.then(res => {
if (res.code !== 1000) {
......@@ -407,6 +416,9 @@ const AddBills: React.FC<{}> = (props: any) => {
});
} else {
// update action
if (!isEdit) {
return;
}
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
......@@ -433,6 +445,9 @@ const AddBills: React.FC<{}> = (props: any) => {
// 销售发货单
case DOC_TYPE_SALES_INVOICE: {
if (!id) {
if (isEdit) {
return;
}
PublicApi.postOrderSalesInvoiceOrder(payload)
.then(res => {
if (res.code !== 1000) {
......@@ -447,6 +462,9 @@ const AddBills: React.FC<{}> = (props: any) => {
});
} else {
// update action
if (!isEdit) {
return;
}
PublicApi.postWarehouseInvoicesUpdata({
id: +id,
invoicesAbstract: payload.invoicesAbstract,
......@@ -575,14 +593,14 @@ const AddBills: React.FC<{}> = (props: any) => {
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={
pageStatus === 0
? '新建单据'
: pageStatus === 1
? '编辑单据'
: '查看单据'
!id ?
'新建单据' :
isEdit ?
'编辑单据' :
'查看单据'
}
extra={
preview != '1'
(isEdit || !id)
? [
<Button
key="1"
......@@ -608,7 +626,7 @@ const AddBills: React.FC<{}> = (props: any) => {
RadioGroup: Radio.Group,
ArrayTable,
}}
editable={pageStatus !== PageStatus.PREVIEW}
editable={isEdit || !id}
effects={($, actions) => {
createEffects($, actions)
onFormInputChange$().subscribe(() => {
......@@ -664,4 +682,4 @@ const AddBills: React.FC<{}> = (props: any) => {
);
};
export default AddBills;
export default BillsForm;
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillsForm from './components/BillsForm';
const EditBills: React.FC = () => {
const {
id,
invoicesTypeId, // 单据类型ID
relevanceInvoices, // 对应单据
relevanceInvoicesId, // 单据id,可能是待新增销售发货单,待新增采购入库单跳转过来的
} = usePageStatus();
return (
<BillsForm
id={id}
invoicesTypeId={invoicesTypeId}
relevanceInvoices={relevanceInvoices}
relevanceInvoicesId={relevanceInvoicesId}
isEdit
/>
);
};
export default EditBills;
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Button, Card, Spin } from 'antd';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useInitValue } from '@/formSchema/effects/useInitValue';
import { PublicApi } from '@/services/api';
import { billsTypeDetailSchema } from './schema';
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillTypeForm from './components/BillTypeForm';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
const AddWarehouse: React.FC<{}> = props => {
const { pageStatus, preview, id } = usePageStatus();
const initValue = useInitValue(PublicApi.getWarehouseInvoicesTypeDetails);
const [info, setInfo] = useState({});
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const docTypeInfo = async () => {
if (!id) {
return;
}
setInfoLoading(true);
const infoRes = await PublicApi.getWarehouseInvoicesTypeDetails({
id,
});
if (infoRes.code === 1000) {
setInfo(infoRes.data);
}
setInfoLoading(false);
};
useEffect(() => {
docTypeInfo();
}, []);
const handleSubmit = value => {
if (!id) {
setSubmitLoading(true);
PublicApi.postWarehouseInvoicesTypeAdd({ ...value })
.then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack()
}, 800);
};
})
.finally(() => {
setSubmitLoading(false);
});
} else {
setSubmitLoading(true);
PublicApi.postWarehouseInvoicesTypeUpdate({
id: id,
...value,
}).then(res => {
if (res.code === 1000) {
history.goBack();
}
});
}
setUnsaved(false);
};
const AddBillsType: React.FC = () => {
const { id } = usePageStatus();
return (
<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={() => formActions.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
previewPlaceholder="' '"
editable={pageStatus !== PageStatus.PREVIEW}
effects={$ => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
initialValues={info}
onSubmit={handleSubmit}
actions={formActions}
schema={billsTypeDetailSchema}
/>
</Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper>
</Spin>
<BillTypeForm />
);
};
export default AddWarehouse;
export default AddBillsType;
\ No newline at end of file
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillTypeForm from './components/BillTypeForm';
const BillsTypeDetail: React.FC = () => {
const { id } = usePageStatus();
return (
<BillTypeForm id={id} />
);
};
export default BillsTypeDetail;
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { Button, Card, Spin } from 'antd';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { PublicApi } from '@/services/api';
import { billsTypeDetailSchema } from './schema';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
interface BillTypeFormProps {
id?: string;
validateId?: string;
// 是否是编辑的
isEdit?: boolean;
};
const BillTypeForm: React.FC<BillTypeFormProps> = ({
id,
isEdit = false,
}) => {
const [info, setInfo] = useState({});
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const docTypeInfo = async () => {
if (!id) {
return;
}
setInfoLoading(true);
const infoRes = await PublicApi.getWarehouseInvoicesTypeDetails({
id,
});
if (infoRes.code === 1000) {
setInfo(infoRes.data);
}
setInfoLoading(false);
};
useEffect(() => {
docTypeInfo();
}, []);
const handleSubmit = value => {
if (!id) {
if (isEdit) {
return;
}
setSubmitLoading(true);
PublicApi.postWarehouseInvoicesTypeAdd({ ...value })
.then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack()
}, 800);
};
})
.finally(() => {
setSubmitLoading(false);
});
} else {
if (!isEdit) {
return;
}
setSubmitLoading(true);
PublicApi.postWarehouseInvoicesTypeUpdate({
id: id,
...value,
}).then(res => {
if (res.code === 1000) {
history.goBack();
}
});
}
setUnsaved(false);
};
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={
!id ?
'新建单据类型' :
isEdit ?
'编辑单据类型' :
'查看单据类型'
}
extra={
(isEdit || !id)
? [
<Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => formActions.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
previewPlaceholder="' '"
editable={isEdit || !id}
effects={$ => {
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
initialValues={info}
onSubmit={handleSubmit}
actions={formActions}
schema={billsTypeDetailSchema}
/>
</Card>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</PageHeaderWrapper>
</Spin>
);
};
export default BillTypeForm;
import { ISchema } from '@formily/antd';
import { DOC_DIRECTION_WAREHOUSING, DOC_DIRECTION_OUTGOING, DOC_DIRECTION } from '@/constants';
export const billsTypeDetailSchema: ISchema = {
type: 'object',
properties: {
MEGA_LAYOUT: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 12,
labelAlign: 'left',
},
properties: {
number: {
type: 'string',
title: '单据类型编号',
'x-component-props': {
placeholder: '最长10个字符',
maxLength: 10,
},
'x-rules': [
{
required: true,
message: '请输入单据类型编号',
},
{
validator: value => {
const CNReg = /[\u4E00-\u9FA5]/g;
return CNReg.test(value) ? '请输入非中文字符,可以是字母 + 数字 + 字符的组合' : '';
},
},
],
},
name: {
type: 'string',
title: '单据类型名称',
'x-component-props': {
placeholder: '最长20个字符,10个汉字',
},
required: true,
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
},
direction: {
type: 'string',
title: '单据类型方向',
enum: [
{
label: DOC_DIRECTION[DOC_DIRECTION_WAREHOUSING],
value: DOC_DIRECTION_WAREHOUSING,
},
{
label: DOC_DIRECTION[DOC_DIRECTION_OUTGOING],
value: DOC_DIRECTION_OUTGOING,
},
],
'x-component-props': {
placeholder: '请选择',
},
required: true,
},
},
},
},
};
\ No newline at end of file
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import BillTypeForm from './components/BillTypeForm';
const EditBillsType: React.FC = () => {
const { id } = usePageStatus();
return (
<BillTypeForm id={id} isEdit />
);
};
export default EditBillsType;
\ No newline at end of file
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { DOC_DIRECTION_WAREHOUSING, DOC_DIRECTION_OUTGOING, DOC_DIRECTION } from '@/constants';
export const billsTypeSchema: ISchema = {
type: 'object',
properties: {},
};
export const billsTypeDetailSchema: ISchema = {
type: 'object',
properties: {
MEGA_LAYOUT: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 12,
labelAlign: 'left',
},
properties: {
number: {
type: 'string',
title: '单据类型编号',
'x-component-props': {
placeholder: '最长10个字符',
maxLength: 10,
},
'x-rules': [
{
required: true,
message: '请输入单据类型编号',
},
{
validator: value => {
const CNReg = /[\u4E00-\u9FA5]/g;
return CNReg.test(value) ? '请输入非中文字符,可以是字母 + 数字 + 字符的组合' : '';
},
},
],
},
name: {
type: 'string',
title: '单据类型名称',
'x-component-props': {
placeholder: '最长20个字符,10个汉字',
},
required: true,
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
},
direction: {
type: 'string',
title: '单据类型方向',
enum: [
{
label: DOC_DIRECTION[DOC_DIRECTION_WAREHOUSING],
value: DOC_DIRECTION_WAREHOUSING,
},
{
label: DOC_DIRECTION[DOC_DIRECTION_OUTGOING],
value: DOC_DIRECTION_OUTGOING,
},
],
'x-component-props': {
placeholder: '请选择',
},
required: true,
},
},
},
},
};
export const searchSchema: ISchema = {
type: 'object',
......
import React, { useState, useEffect } from 'react';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { Button, Card, Spin } from 'antd';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { warehouseDetailSchema } from './schema';
import { useLinkEnumEffect } from '@/components/NiceForm/linkages/linkEnum';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import WarehouseForm from './components/WarehouseForm';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
const AddWarehouse: React.FC<{}> = (props: any) => {
const { pageStatus, preview, id } = usePageStatus();
const [info, setInfo] = useState({});
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const getWarehouseInfo = async () => {
if (id) {
setInfoLoading(true);
const infoRes = await PublicApi.getWarehouseWarehouseDetails({
id,
});
const areaRes = await PublicApi.getManageAreaAll();
if (areaRes.code === 1000) {
const { data } = areaRes;
formActions.setFieldState('provinceId', targetState => {
targetState.originData = data;
targetState.props.enum = data.map(v => ({
label: v.name,
value: v.id,
}));
});
}
if (infoRes.code === 1000) {
setInfo(infoRes.data);
}
setInfoLoading(false);
} else {
const areaRes = await PublicApi.getManageAreaAll();
if (areaRes.code === 1000) {
const { data } = areaRes;
formActions.setFieldState('provinceId', targetState => {
targetState.originData = data;
targetState.props.enum = data.map(v => ({
label: v.name,
value: v.id,
}));
});
}
}
};
useEffect(() => {
getWarehouseInfo();
}, []);
// 获取手机code
const fetchTelCode = async () => {
const { data } = await PublicApi.getManageCountryAreaGetTelCode();
return data;
};
const handleSubmit = value => {
if (!id) {
setSubmitLoading(true);
PublicApi.postWarehouseWarehouseAdd({ ...value }).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack();
}, 800);
};
}).finally(() => {
setSubmitLoading(false);
});
} else {
setSubmitLoading(true);
PublicApi.postWarehouseWarehouseUpdate({
id: id,
...value,
}).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack();
}, 800);
};
}).finally(() => {
setSubmitLoading(false);
});
}
setUnsaved(false);
};
const AddWarehouse: React.FC = () => {
const { id } = usePageStatus();
return (
<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={() => formActions.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
previewPlaceholder="' '"
editable={pageStatus !== PageStatus.PREVIEW}
effects={($, { setFieldState }) => {
useLinkEnumEffect('areaResponses', result =>
result.map(v => ({
label: v.name,
value: v.id,
})),
);
useAsyncSelect('telCode', fetchTelCode);
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
initialValues={info}
onSubmit={handleSubmit}
actions={formActions}
schema={warehouseDetailSchema}
/>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
<WarehouseForm />
);
};
export default AddWarehouse;
export default AddWarehouse;
\ No newline at end of file
import React, { useState, useEffect } from 'react';
import { history, Prompt } from 'umi';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import { SaveOutlined } from '@ant-design/icons';
import { createFormActions, FormEffectHooks } from '@formily/antd';
import { Button, Card, Spin } from 'antd';
import ReutrnEle from '@/components/ReturnEle';
import NiceForm from '@/components/NiceForm';
import { warehouseDetailSchema } from './schema';
import { useLinkEnumEffect } from '@/components/NiceForm/linkages/linkEnum';
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { PublicApi } from '@/services/api';
const formActions = createFormActions();
const {
onFormInputChange$,
} = FormEffectHooks;
interface WarehouseFormProps {
id?: string;
validateId?: string;
// 是否是编辑的
isEdit?: boolean;
};
const WarehouseForm: React.FC<WarehouseFormProps> = ({
id,
isEdit = false,
}) => {
const [info, setInfo] = useState({});
const [unsaved, setUnsaved] = useState(false);
const [infoLoading, setInfoLoading] = useState(false);
const [submitLoading, setSubmitLoading] = useState(false);
const getWarehouseInfo = async () => {
if (id) {
setInfoLoading(true);
const infoRes = await PublicApi.getWarehouseWarehouseDetails({
id,
});
const areaRes = await PublicApi.getManageAreaAll();
if (areaRes.code === 1000) {
const { data } = areaRes;
formActions.setFieldState('provinceId', targetState => {
targetState.originData = data;
targetState.props.enum = data.map(v => ({
label: v.name,
value: v.id,
}));
});
}
if (infoRes.code === 1000) {
setInfo(infoRes.data);
}
setInfoLoading(false);
} else {
const areaRes = await PublicApi.getManageAreaAll();
if (areaRes.code === 1000) {
const { data } = areaRes;
formActions.setFieldState('provinceId', targetState => {
targetState.originData = data;
targetState.props.enum = data.map(v => ({
label: v.name,
value: v.id,
}));
});
}
}
};
useEffect(() => {
getWarehouseInfo();
}, []);
// 获取手机code
const fetchTelCode = async () => {
const { data } = await PublicApi.getManageCountryAreaGetTelCode();
return data;
};
const handleSubmit = value => {
if (!id) {
if (isEdit) {
return;
}
setSubmitLoading(true);
PublicApi.postWarehouseWarehouseAdd({ ...value }).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack();
}, 800);
};
}).finally(() => {
setSubmitLoading(false);
});
} else {
if (!isEdit) {
return;
}
setSubmitLoading(true);
PublicApi.postWarehouseWarehouseUpdate({
id: id,
...value,
}).then(res => {
if (res.code === 1000) {
setTimeout(() => {
history.goBack();
}, 800);
};
}).finally(() => {
setSubmitLoading(false);
});
}
setUnsaved(false);
};
return (
<Spin spinning={infoLoading}>
<PageHeaderWrapper
onBack={() => history.goBack()}
backIcon={<ReutrnEle description="返回" />}
title={
!id ?
'新建仓库' :
isEdit ?
'编辑仓库' :
'查看仓库'
}
extra={
(isEdit || !id)
? [
<Button
key="1"
type="primary"
icon={<SaveOutlined />}
loading={submitLoading}
onClick={() => formActions.submit()}
>
保存
</Button>,
]
: []
}
>
<Card>
<NiceForm
previewPlaceholder="' '"
editable={isEdit || !id}
effects={($, { setFieldState }) => {
useLinkEnumEffect('areaResponses', result =>
result.map(v => ({
label: v.name,
value: v.id,
})),
);
useAsyncSelect('telCode', fetchTelCode);
onFormInputChange$().subscribe(() => {
if (!unsaved) {
setUnsaved(true);
}
});
}}
initialValues={info}
onSubmit={handleSubmit}
actions={formActions}
schema={warehouseDetailSchema}
/>
</Card>
</PageHeaderWrapper>
<Prompt when={unsaved} message="您还有未保存的内容,是否确定要离开?" />
</Spin>
);
};
export default WarehouseForm;
import { ISchema } from '@formily/antd';
import { PATTERN_MAPS } from '@/constants/regExp';
export const warehouseDetailSchema: ISchema = {
type: 'object',
properties: {
MEGA_LAYOUT: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 12,
labelAlign: 'left',
},
properties: {
name: {
type: 'string',
title: '仓库名称',
'x-component-props': {
placeholder: '请输入',
},
'x-rules': [
{
required: true,
message: '请输入仓库名称',
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
required: true,
},
MEGA_LAYOUT1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
label: '仓库地址',
wrapperCol: 24,
},
properties: {
MEGA_LAYOUT1_1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 3,
},
properties: {
provinceId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 省 -',
},
'x-linkages': [
{
type: 'value:linkage',
condition: '{{!!$value}}',
origin: 'provinceId',
target: 'cityId',
},
],
required: true,
},
cityId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 市 -',
},
'x-linkages': [
{
type: 'value:linkage',
condition: '{{!!$value}}',
origin: 'cityId',
target: 'areaId',
},
],
required: true,
},
areaId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 县 / 区 -',
},
required: true,
},
},
},
address: {
type: 'string',
required: true,
'x-component': 'TextArea',
'x-component-props': {
placeholder: '请输入详细地址(最长50个字符,25个汉字)',
rows: 5,
},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 50,
}
],
},
},
},
principal: {
type: 'string',
title: '仓库负责人',
'x-component-props': {},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 16,
}
],
},
MEGA_LAYOUT2: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
label: '联系电话',
wrapperCol: 24,
},
properties: {
MEGA_LAYOUT2_1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
},
properties: {
telCode: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '请选择',
},
},
tel: {
type: 'string',
'x-mega-props': {
span: 3,
},
'x-component-props': {
placeholder: '请输入你的手机号码',
maxLength: 11,
},
'x-rules': [
{
pattern: PATTERN_MAPS.phone,
message: '请输入正确格式的手机号',
},
],
},
},
},
},
},
},
},
},
};
\ No newline at end of file
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import WarehouseForm from './components/WarehouseForm';
const EditWarehouse: React.FC = () => {
const { id } = usePageStatus();
return (
<WarehouseForm id={id} isEdit />
);
};
export default EditWarehouse;
\ No newline at end of file
......@@ -37,7 +37,7 @@ const WareHouse: React.FC<{}> = () => {
render: (text: any, record: any) => {
return (
<EyePreview
url={`/memberCenter/tranactionAbility/stockSellStorage/warehouse/detail?id=${record.id}&preview=1`}
url={`/memberCenter/tranactionAbility/stockSellStorage/warehouse/detail?id=${record.id}`}
>
{text}
</EyePreview>
......
......@@ -84,172 +84,6 @@ export const warehouseSchema: ISchema = {
},
};
export const warehouseDetailSchema: ISchema = {
type: 'object',
properties: {
MEGA_LAYOUT: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
labelCol: 4,
wrapperCol: 12,
labelAlign: 'left',
},
properties: {
name: {
type: 'string',
title: '仓库名称',
'x-component-props': {
placeholder: '请输入',
},
'x-rules': [
{
required: true,
message: '请输入仓库名称',
},
{
limitByte: true, // 自定义校验规则
maxByte: 20,
}
],
required: true,
},
MEGA_LAYOUT1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
label: '仓库地址',
wrapperCol: 24,
},
properties: {
MEGA_LAYOUT1_1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
autoRow: true,
columns: 3,
},
properties: {
provinceId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 省 -',
},
'x-linkages': [
{
type: 'value:linkage',
condition: '{{!!$value}}',
origin: 'provinceId',
target: 'cityId',
},
],
required: true,
},
cityId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 市 -',
},
'x-linkages': [
{
type: 'value:linkage',
condition: '{{!!$value}}',
origin: 'cityId',
target: 'areaId',
},
],
required: true,
},
areaId: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '- 县 / 区 -',
},
required: true,
},
},
},
address: {
type: 'string',
required: true,
'x-component': 'TextArea',
'x-component-props': {
placeholder: '请输入详细地址(最长50个字符,25个汉字)',
rows: 5,
},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 50,
}
],
},
},
},
principal: {
type: 'string',
title: '仓库负责人',
'x-component-props': {},
'x-rules': [
{
limitByte: true, // 自定义校验规则
maxByte: 16,
}
],
},
MEGA_LAYOUT2: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
label: '联系电话',
wrapperCol: 24,
},
properties: {
MEGA_LAYOUT2_1: {
type: 'object',
'x-component': 'mega-layout',
'x-component-props': {
grid: true,
full: true,
},
properties: {
telCode: {
type: 'string',
enum: [],
'x-component-props': {
placeholder: '请选择',
},
},
tel: {
type: 'string',
'x-mega-props': {
span: 3,
},
'x-component-props': {
placeholder: '请输入你的手机号码',
maxLength: 11,
},
'x-rules': [
{
pattern: PATTERN_MAPS.phone,
message: '请输入正确格式的手机号',
},
],
},
},
},
},
},
},
},
},
};
export const searchSchema: ISchema = {
type: 'object',
properties: {
......
import React from 'react';
import { usePageStatus } from '@/hooks/usePageStatus';
import WarehouseForm from './components/WarehouseForm';
const WarehouseDetail: React.FC = () => {
const { id } = usePageStatus();
return (
<WarehouseForm id={id} />
);
};
export default WarehouseDetail;
\ No newline at end of file
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