Commit 6f9d2b3a authored by tjy's avatar tjy
parents ff616e94 17c0bcfc
......@@ -26,8 +26,8 @@
"dependencies": {
"@ant-design/icons": "^4.2.1",
"@ant-design/pro-layout": "^5.0.16",
"@formily/antd": "^1.2.10",
"@formily/antd-components": "^1.2.10",
"@formily/antd": "^1.2.11",
"@formily/antd-components": "^1.2.11",
"@umijs/hooks": "^1.9.3",
"@umijs/preset-react": "1.x",
"@umijs/test": "^3.2.0",
......
import React from 'react';
import SchemaForm, {
IAntdSchemaFormProps, createVirtualBox, registerVirtualBox,
IAntdSchemaFormProps, createVirtualBox, registerVirtualBox, Schema, SchemaField, FormButtonGroup, Reset, createControllerBox,
} from '@formily/antd';
import { Button, Space, Row, Col } from 'antd';
import styled from 'styled-components'
......@@ -18,6 +18,7 @@ import CustomRelevance from './components/CustomRelevance';
import Children from './components/Children';
import CircleBox from './components/CircleBox';
import './index.less'
import { Input } from '@formily/antd-components';
export interface NiceFormProps extends IAntdSchemaFormProps {}
......@@ -42,6 +43,37 @@ registerVirtualBox('flex-layout', (_props) => {
</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 { children, components, ...reset } = props;
const customComponents = {
......@@ -57,7 +89,9 @@ const NiceForm: React.FC<NiceFormProps> = props => {
CustomRegistryPhone,
CustomRelevance,
Children,
CircleBox
CircleBox,
SchemaFormButtonGroup,
FlexBox
};
const defineComponents = Object.assign(customComponents, components);
......
import React, { Component } from 'react';
import { Link } from 'umi'
import SchemaForm, { SchemaField, Schema, createControllerBox } from '@formily/antd';
import { Modal } from 'antd';
class Index extends Component<{}, {}> {
render() {
......
......@@ -14,7 +14,7 @@ import ReutrnEle from '@/components/ReturnEle';
import './index.less'
import NiceForm from '@/components/NiceForm'
import { repositDetailSchema } from './schema'
import { createFormActions, ISchema } from '@formily/antd'
import { createFormActions, ISchema, FormEffectHooks } from '@formily/antd'
import EyePreview from '@/components/EyePreview'
import { findItemAndDelete } from '@/utils'
import { PublicApi } from '@/services/api'
......@@ -32,14 +32,6 @@ const fetchProductList = async (params) => {
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 AddRepository:React.FC<{}> = (props) => {
......@@ -52,6 +44,17 @@ const AddRepository:React.FC<{}> = (props) => {
const initValue = useInitValue(PublicApi.getWarehouseFreightSpaceDetails)
const [visibleChannelMember, setVisibleChannelMember] = 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 [productRowSelection, productRowCtl] = useRowSelectionTable({type: 'radio'})
......@@ -236,6 +239,13 @@ const AddRepository:React.FC<{}> = (props) => {
}}
effects={() => {
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}
actions={addSchemaAction}
......
This diff is collapsed.
......@@ -149,7 +149,7 @@ const Repositories: React.FC<{}> = () => {
const handleAdjust = (record: any) => {
history.push(
`/memberCenter/commodityAbility/repositories/adjustRepository?id=${record.key}`,
`/memberCenter/commodityAbility/repositories/adjustRepository?id=${record.id}`,
);
};
......
This diff is collapsed.
import React, { useState } from 'react'
import { history } from 'umi'
import { Form, Row, Col, Input, Button } from 'antd'
import {
UserOutlined,
......@@ -7,6 +8,7 @@ import {
} from '@ant-design/icons';
import styles from '../index.less'
import { PublicApi } from '@/services/api';
import { setAuth } from '@/utils/auth';
const LoginWrap: React.FC = () => {
const [validFrame, setValidFrame] = useState(false)
......@@ -15,7 +17,13 @@ const LoginWrap: React.FC = () => {
const finish = (value:any) => {
console.log(value)
PublicApi.postMemberLogin(value).then(res => {
console.log(res)
const { data } = res
setAuth({
memberId: data.memberId,
userId: data.userId,
token: data.token
})
history.push('/')
})
}
......
This source diff could not be displayed because it is too large. You can view the blob instead.
export interface AuthInfo {
userId: number,
memberId: number,
token: string
}
export const setAuth = (info: AuthInfo) => {
window.localStorage.setItem('auth', JSON.stringify(info))
}
export const getAuth = () => {
try {
return JSON.parse(window.localStorage.getItem('auth'))
} catch (error) {
return {}
}
}
......@@ -2,6 +2,7 @@ import { extend, ResponseError, OnionOptions, RequestOptionsInit, ResponseInterc
import responseCode from '@/constants/responseCode'
import { IRequestError, IRequestSuccess } from '..';
import { message } from 'antd'
import { getAuth } from './auth';
export type CtlType = 'none' | 'message'
// 根前缀请求路径
......@@ -49,7 +50,9 @@ const errorHandler = (error: ResponseError): IRequestError => {
}
const defaultHeaders = {
'Content-Type': 'Application/json'
'Content-Type': 'Application/json',
// 能力中心特定标识, 不可修改
source: '1'
}
/**
......@@ -64,10 +67,20 @@ const baseRequest = extend({
// 请求拦截器
baseRequest.interceptors.request.use((url: string, options: RequestOptionsInit): { url: string, options: RequestOptionsInit } => {
// 判断是否有权限
const loginAfterHeaders = getAuth()
const headers = {
...options.headers,
...loginAfterHeaders
}
return {
// 前缀如果已经带上api, 跳过自动补前缀
url: url.startsWith('/api') ? url : basePrefix + url,
options,
options: {
...options,
headers
},
};
});
......
......@@ -7,6 +7,7 @@ const tokens = [
'8d14d945507d1f8cd89afe139ca6d111bbad25f702fafe0aec59d3c9cd2e0ffe', // 物流服务
'3a46198c5b97ac7147e5b07ad2dff5ac5c93c1afed47e1911961db87149e6ebf', // 商户会员管理服务
'efe99e20ed1375dc0db3e809e4fc7692f42ecebaf60cd77e65c50ed65d6ba6c4', // 商品服务
'c789e0e56ee8a8cc2fbd85f930eb2928c58fc1014583c6643acf29cff954da49', // 支付服务
]
const genMap = (tokens) => {
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