Commit 81852234 authored by 前端-许佳敏's avatar 前端-许佳敏

拆分仓位页面

parent c8dbdc23
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
"dependencies": { "dependencies": {
"@ant-design/icons": "^4.2.1", "@ant-design/icons": "^4.2.1",
"@ant-design/pro-layout": "^5.0.16", "@ant-design/pro-layout": "^5.0.16",
"@formily/antd": "^1.2.10", "@formily/antd": "^1.2.11",
"@formily/antd-components": "^1.2.10", "@formily/antd-components": "^1.2.11",
"@umijs/hooks": "^1.9.3", "@umijs/hooks": "^1.9.3",
"@umijs/preset-react": "1.x", "@umijs/preset-react": "1.x",
"@umijs/test": "^3.2.0", "@umijs/test": "^3.2.0",
......
import React from 'react'; import React from 'react';
import SchemaForm, { import SchemaForm, {
IAntdSchemaFormProps, createVirtualBox, registerVirtualBox, IAntdSchemaFormProps, createVirtualBox, registerVirtualBox, Schema, SchemaField, FormButtonGroup, Reset, createControllerBox,
} from '@formily/antd'; } from '@formily/antd';
import { Button, Space, Row, Col } from 'antd'; import { Button, Space, Row, Col } from 'antd';
import styled from 'styled-components' import styled from 'styled-components'
...@@ -18,6 +18,7 @@ import CustomRelevance from './components/CustomRelevance'; ...@@ -18,6 +18,7 @@ import CustomRelevance from './components/CustomRelevance';
import Children from './components/Children'; import Children from './components/Children';
import CircleBox from './components/CircleBox'; import CircleBox from './components/CircleBox';
import './index.less' import './index.less'
import { Input } from '@formily/antd-components';
export interface NiceFormProps extends IAntdSchemaFormProps {} export interface NiceFormProps extends IAntdSchemaFormProps {}
...@@ -42,6 +43,37 @@ registerVirtualBox('flex-layout', (_props) => { ...@@ -42,6 +43,37 @@ registerVirtualBox('flex-layout', (_props) => {
</RowLayout> </RowLayout>
) )
}) })
registerVirtualBox('empty-layout', (_props) => {
const { children, props } = _props
return (
<div>{children}</div>
)
})
const SchemaFormButtonGroup = createVirtualBox('schemaButtonGroup', FormButtonGroup)
const SchemaButton = createVirtualBox('schemaButton', Button)
const SchemaSubmit = createVirtualBox('schemaSubmit', Submit)
const SchemaReset = createVirtualBox('schemaReset', Reset)
export const FlexBox = createVirtualBox('flexBox', props => <Row {...props}/>)
// 该组件用于schema中嵌套表单, 不过控制台会出现警告
const schemaLayout = createControllerBox("schemaLayout", (_props) => {
const { schema } = _props;
const componentProps = schema.getExtendsComponentProps();
const { properties } = schema.toJSON();
const nestedSchema = new Schema({
type: "object",
properties
});
// const { visible, title, onCancel, footer, ...others } = componentProps;
return (
<NiceForm>
<SchemaField schema={nestedSchema}></SchemaField>
</NiceForm>
);
});
const NiceForm: React.FC<NiceFormProps> = props => { const NiceForm: React.FC<NiceFormProps> = props => {
const { children, components, ...reset } = props; const { children, components, ...reset } = props;
const customComponents = { const customComponents = {
...@@ -57,7 +89,9 @@ const NiceForm: React.FC<NiceFormProps> = props => { ...@@ -57,7 +89,9 @@ const NiceForm: React.FC<NiceFormProps> = props => {
CustomRegistryPhone, CustomRegistryPhone,
CustomRelevance, CustomRelevance,
Children, Children,
CircleBox CircleBox,
SchemaFormButtonGroup,
FlexBox
}; };
const defineComponents = Object.assign(customComponents, components); const defineComponents = Object.assign(customComponents, components);
......
import React, { Component } from 'react'; import React, { Component } from 'react';
import { Link } from 'umi' import { Link } from 'umi'
import SchemaForm, { SchemaField, Schema, createControllerBox } from '@formily/antd';
import { Modal } from 'antd';
class Index extends Component<{}, {}> { class Index extends Component<{}, {}> {
render() { render() {
......
...@@ -14,7 +14,7 @@ import ReutrnEle from '@/components/ReturnEle'; ...@@ -14,7 +14,7 @@ import ReutrnEle from '@/components/ReturnEle';
import './index.less' import './index.less'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { repositDetailSchema } from './schema' import { repositDetailSchema } from './schema'
import { createFormActions, ISchema } from '@formily/antd' import { createFormActions, ISchema, FormEffectHooks } from '@formily/antd'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
import { findItemAndDelete } from '@/utils' import { findItemAndDelete } from '@/utils'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
...@@ -32,14 +32,6 @@ const fetchProductList = async (params) => { ...@@ -32,14 +32,6 @@ const fetchProductList = async (params) => {
return res.data return res.data
} }
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
return data.map(v => ({
value: v.id,
label: v.name
}))
}
const addSchemaAction = createFormActions() const addSchemaAction = createFormActions()
const AddRepository:React.FC<{}> = (props) => { const AddRepository:React.FC<{}> = (props) => {
...@@ -52,6 +44,17 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -52,6 +44,17 @@ const AddRepository:React.FC<{}> = (props) => {
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails) const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
const [visibleChannelMember, setVisibleChannelMember] = useState(false) const [visibleChannelMember, setVisibleChannelMember] = useState(false)
const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false) const [visibleChannelRroduct, setVisibleChannelRroduct] = useState(false)
// 获取到的所有仓库, 用于选中后获得仓库库存
const repositRef = useRef<any>({})
const fetchWarehouseAll = async () => {
const { data } = await PublicApi.getWarehouseWarehouseAll()
repositRef.current = data
return data.map(v => ({
value: v.id,
label: v.name
}))
}
const [memberRowSelection, memberRowCtl] = useRowSelectionTable() const [memberRowSelection, memberRowCtl] = useRowSelectionTable()
const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'}) const [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
...@@ -236,6 +239,13 @@ const AddRepository:React.FC<{}> = (props) => { ...@@ -236,6 +239,13 @@ const AddRepository:React.FC<{}> = (props) => {
}} }}
effects={() => { effects={() => {
useAsyncSelect('warehouseId', fetchWarehouseAll) useAsyncSelect('warehouseId', fetchWarehouseAll)
FormEffectHooks.onFieldValueChange$('warehouseId').subscribe(state => {
console.log(state.value)
addSchemaAction.setFieldState('inventory', targetState => {
const data = repositRef.current
targetState.props['x-component-props'].max = Array.isArray(data) ? data.find(v => v.id === state.value)?.principal : 200
})
})
}} }}
onSubmit={handleSubmit} onSubmit={handleSubmit}
actions={addSchemaAction} actions={addSchemaAction}
......
This diff is collapsed.
...@@ -149,7 +149,7 @@ const Repositories: React.FC<{}> = () => { ...@@ -149,7 +149,7 @@ const Repositories: React.FC<{}> = () => {
const handleAdjust = (record: any) => { const handleAdjust = (record: any) => {
history.push( history.push(
`/memberCenter/commodityAbility/repositories/adjustRepository?id=${record.key}`, `/memberCenter/commodityAbility/repositories/adjustRepository?id=${record.id}`,
); );
}; };
......
This diff is collapsed.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -7,6 +7,7 @@ const tokens = [ ...@@ -7,6 +7,7 @@ const tokens = [
'8d14d945507d1f8cd89afe139ca6d111bbad25f702fafe0aec59d3c9cd2e0ffe', // 物流服务 '8d14d945507d1f8cd89afe139ca6d111bbad25f702fafe0aec59d3c9cd2e0ffe', // 物流服务
'3a46198c5b97ac7147e5b07ad2dff5ac5c93c1afed47e1911961db87149e6ebf', // 商户会员管理服务 '3a46198c5b97ac7147e5b07ad2dff5ac5c93c1afed47e1911961db87149e6ebf', // 商户会员管理服务
'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4', // 商品服务 'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4', // 商品服务
'c789e0e56ee8a8cc2fbd85f930eb2928c58fc1014583c6643acf29cff954da49', // 支付服务
] ]
const genMap = (tokens) => { const genMap = (tokens) => {
return tokens.map(v => { return tokens.map(v => {
......
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