Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-platform
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
陈智峰
jinfa-platform
Commits
452e54a3
Commit
452e54a3
authored
Sep 12, 2020
by
XieZhiXiong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善进销存 -》 仓库相关
parent
461808eb
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
187 additions
and
98 deletions
+187
-98
linkEnum.ts
src/components/NiceForm/linkages/linkEnum.ts
+14
-3
index.tsx
src/pages/member/memberImport/schema/index.tsx
+33
-20
addWarehouse.tsx
...s/transaction/stockSellStorage/warehouse/addWarehouse.tsx
+114
-69
index.tsx
...s/transaction/stockSellStorage/warehouse/schema/index.tsx
+26
-6
No files found.
src/components/NiceForm/linkages/linkEnum.ts
View file @
452e54a3
/*
* @Author: XieZhiXiong
* @Date: 2020-08-06 11:20:13
* @LastEditors: XieZhiXiong
* @LastEditTime: 2020-09-12 17:17:31
* @Description:
*/
import
{
useValueLinkageEffect
,
FormPath
,
FormEffectHooks
}
from
'@formily/antd'
import
{
useValueLinkageEffect
,
FormPath
,
FormEffectHooks
}
from
'@formily/antd'
...
@@ -76,8 +83,13 @@ export const useLinkEnumEffect = (childKey, transformFn?, findKey = 'id') => {
...
@@ -76,8 +83,13 @@ export const useLinkEnumEffect = (childKey, transformFn?, findKey = 'id') => {
if
(
state
.
value
===
undefined
)
{
if
(
state
.
value
===
undefined
)
{
}
else
{
}
else
{
if
(
originData
.
length
>
0
)
{
if
(
originData
.
length
>
0
)
{
const
result
=
originData
.
find
(
v
=>
v
[
findKey
]
===
state
.
value
)[
childKey
]
||
[]
const
current
=
originData
.
find
(
v
=>
v
[
findKey
]
===
state
.
value
)
if
(
state
.
modified
&&
state
.
initialValue
)
{
if
(
!
current
)
{
return
}
const
result
=
current
[
childKey
]
||
[]
if
(
state
.
modified
)
{
targetState
.
value
=
undefined
targetState
.
value
=
undefined
}
}
targetState
.
originData
=
result
targetState
.
originData
=
result
...
@@ -86,7 +98,6 @@ export const useLinkEnumEffect = (childKey, transformFn?, findKey = 'id') => {
...
@@ -86,7 +98,6 @@ export const useLinkEnumEffect = (childKey, transformFn?, findKey = 'id') => {
}
}
})
})
})
})
},
},
reject
:
({
target
},
{
setFieldState
,
getFieldState
})
=>
{
reject
:
({
target
},
{
setFieldState
,
getFieldState
})
=>
{
setFieldState
(
target
,
targetState
=>
{
setFieldState
(
target
,
targetState
=>
{
...
...
src/pages/member/memberImport/schema/index.tsx
View file @
452e54a3
...
@@ -255,31 +255,44 @@ export const initDetailSchema = (props: any) => {
...
@@ -255,31 +255,44 @@ export const initDetailSchema = (props: any) => {
'x-component-props'
:
{
'x-component-props'
:
{
label
:
'注册手机'
,
label
:
'注册手机'
,
required
:
true
,
required
:
true
,
inline
:
true
,
wrapperCol
:
24
,
},
},
properties
:
{
properties
:
{
countryCodeId
:
{
MEGA_LAYOUT1_1_1
:
{
type
:
'
string'
,
type
:
'
object'
,
enum
:
[]
,
'x-component'
:
'mega-layout'
,
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'请选择'
,
grid
:
true
,
full
:
true
,
},
},
required
:
true
,
properties
:
{
},
countryCodeId
:
{
phone
:
{
type
:
'string'
,
type
:
'string'
,
enum
:
[],
required
:
true
,
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'请选择'
,
placeholder
:
'请输入你的手机号码'
,
},
maxLength
:
11
,
required
:
true
,
},
'x-rules'
:
[
{
pattern
:
PATTERN_MAPS
.
phone
,
message
:
'请输入正确格式的手机号'
,
},
},
],
phone
:
{
},
type
:
'string'
,
required
:
true
,
'x-mega-props'
:
{
span
:
2
,
},
'x-component-props'
:
{
placeholder
:
'请输入你的手机号码'
,
maxLength
:
11
,
},
'x-rules'
:
[
{
pattern
:
PATTERN_MAPS
.
phone
,
message
:
'请输入正确格式的手机号'
,
},
],
},
},
},
},
},
},
},
email
:
{
email
:
{
...
...
src/pages/transaction/stockSellStorage/warehouse/addWarehouse.tsx
View file @
452e54a3
import
React
from
'react'
;
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
history
}
from
'umi'
;
import
{
history
,
Prompt
}
from
'umi'
;
import
{
PageHeaderWrapper
}
from
'@ant-design/pro-layout'
;
import
{
PageHeaderWrapper
}
from
'@ant-design/pro-layout'
;
import
{
SaveOutlined
}
from
'@ant-design/icons'
;
import
{
SaveOutlined
}
from
'@ant-design/icons'
;
import
{
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
createFormActions
,
FormEffectHooks
}
from
'@formily/antd'
;
import
{
Button
,
Card
}
from
'antd'
;
import
{
Button
,
Card
,
Spin
}
from
'antd'
;
import
ReutrnEle
from
'@/components/ReturnEle'
;
import
ReutrnEle
from
'@/components/ReturnEle'
;
import
NiceForm
from
'@/components/NiceForm'
;
import
NiceForm
from
'@/components/NiceForm'
;
import
{
warehouseDetailSchema
}
from
'./schema'
;
import
{
warehouseDetailSchema
}
from
'./schema'
;
import
{
useLinkEnumEffect
}
from
'@/components/NiceForm/linkages/linkEnum'
;
import
{
useLinkEnumEffect
}
from
'@/components/NiceForm/linkages/linkEnum'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
import
{
useAsyncSelect
}
from
'@/formSchema/effects/useAsyncSelect'
;
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
;
import
{
usePageStatus
,
PageStatus
}
from
'@/hooks/usePageStatus'
;
import
{
useInitValue
}
from
'@/formSchema/effects/useInitValue'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
PublicApi
}
from
'@/services/api'
;
const
addSchemaAction
=
createFormActions
();
const
formActions
=
createFormActions
();
const
{
onFormInputChange$
,
}
=
FormEffectHooks
;
const
AddWarehouse
:
React
.
FC
<
{}
>
=
(
props
:
any
)
=>
{
const
AddWarehouse
:
React
.
FC
<
{}
>
=
(
props
:
any
)
=>
{
const
{
pageStatus
,
preview
,
id
}
=
usePageStatus
();
const
{
pageStatus
,
preview
,
id
}
=
usePageStatus
();
const
initValue
=
useInitValue
(
PublicApi
.
getWarehouseWarehouseDetails
);
const
[
info
,
setInfo
]
=
useState
({});
const
[
unsaved
,
setUnsaved
]
=
useState
(
false
);
const
[
infoLoading
,
setInfoLoading
]
=
useState
(
false
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
getWarehouseInfo
=
async
()
=>
{
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
);
};
useEffect
(()
=>
{
getWarehouseInfo
();
},
[]);
// 获取手机code
// 获取手机code
const
fetchTelCode
=
async
()
=>
{
const
fetchTelCode
=
async
()
=>
{
...
@@ -26,78 +59,90 @@ const AddWarehouse: React.FC<{}> = (props: any) => {
...
@@ -26,78 +59,90 @@ const AddWarehouse: React.FC<{}> = (props: any) => {
};
};
const
handleSubmit
=
value
=>
{
const
handleSubmit
=
value
=>
{
if
(
pageStatus
===
0
)
if
(
!
id
)
{
return
PublicApi
.
postWarehouseWarehouseAdd
({
...
value
}).
then
(
res
=>
{
setSubmitLoading
(
true
);
if
(
res
.
code
===
1000
)
return
history
.
goBack
();
PublicApi
.
postWarehouseWarehouseAdd
({
...
value
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
{
setTimeout
(()
=>
{
history
.
goBack
();
},
800
);
};
}).
finally
(()
=>
{
setSubmitLoading
(
false
);
});
});
else
}
else
{
return
PublicApi
.
postWarehouseWarehouseUpdate
({
setSubmitLoading
(
true
);
PublicApi
.
postWarehouseWarehouseUpdate
({
id
:
id
,
id
:
id
,
...
value
,
...
value
,
}).
then
(
res
=>
{
}).
then
(
res
=>
{
if
(
res
.
code
===
1000
)
return
history
.
goBack
();
if
(
res
.
code
===
1000
)
{
setTimeout
(()
=>
{
history
.
goBack
();
},
800
);
};
}).
finally
(()
=>
{
setSubmitLoading
(
false
);
});
});
}
setUnsaved
(
false
);
};
};
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"
onClick=
{
()
=>
addSchemaAction
.
submit
()
}
icon=
{
<
SaveOutlined
/>
}
>
loading=
{
submitLoading
}
保存
onClick=
{
()
=>
formActions
.
submit
()
}
</
Button
>,
>
]
保存
:
[]
</
Button
>,
}
]
>
:
[]
<
Card
>
}
<
NiceForm
>
previewPlaceholder=
"' '"
<
Card
>
editable=
{
pageStatus
!==
PageStatus
.
PREVIEW
}
<
NiceForm
effects=
{
(
$
,
{
setFieldState
})
=>
{
previewPlaceholder=
"' '"
$
(
'onFormMount'
).
subscribe
(
state
=>
{
editable=
{
pageStatus
!==
PageStatus
.
PREVIEW
}
PublicApi
.
getManageAreaAll
().
then
(
res
=>
{
effects=
{
(
$
,
{
setFieldState
})
=>
{
if
(
res
.
code
===
1000
)
{
useLinkEnumEffect
(
'areaResponses'
,
result
=>
const
{
data
}
=
res
;
result
.
map
(
v
=>
({
setFieldState
(
'provinceId'
,
targetState
=>
{
label
:
v
.
name
,
targetState
.
originData
=
data
;
value
:
v
.
id
,
targetState
.
props
.
enum
=
data
.
map
(
v
=>
({
})),
label
:
v
.
name
,
);
value
:
v
.
id
,
useAsyncSelect
(
'telCode'
,
fetchTelCode
);
}));
onFormInputChange$
().
subscribe
(()
=>
{
});
if
(
!
unsaved
)
{
setUnsaved
(
true
);
}
}
});
});
});
}
}
useLinkEnumEffect
(
'areaResponses'
,
result
=>
initialValues=
{
info
}
result
.
map
(
v
=>
({
onSubmit=
{
handleSubmit
}
label
:
v
.
name
,
actions=
{
formActions
}
value
:
v
.
id
,
schema=
{
warehouseDetailSchema
}
})),
/>
);
</
Card
>
useAsyncSelect
(
'telCode'
,
fetchTelCode
);
</
PageHeaderWrapper
>
}
}
<
Prompt
when=
{
unsaved
}
message=
"您还有未保存的内容,是否确定要离开?"
/>
initialValues=
{
initValue
}
</
Spin
>
onSubmit=
{
handleSubmit
}
actions=
{
addSchemaAction
}
schema=
{
warehouseDetailSchema
}
/>
</
Card
>
</
PageHeaderWrapper
>
);
);
};
};
...
...
src/pages/transaction/stockSellStorage/warehouse/schema/index.tsx
View file @
452e54a3
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
warehouseSchema
:
ISchema
=
{
export
const
warehouseSchema
:
ISchema
=
{
type
:
'object'
,
type
:
'object'
,
...
@@ -166,11 +167,18 @@ export const warehouseDetailSchema: ISchema = {
...
@@ -166,11 +167,18 @@ export const warehouseDetailSchema: ISchema = {
},
},
address
:
{
address
:
{
type
:
'string'
,
type
:
'string'
,
required
:
true
,
'x-component'
:
'TextArea'
,
'x-component'
:
'TextArea'
,
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'请输入详细地址(最长50个字符,25个汉字)'
,
placeholder
:
'请输入详细地址(最长50个字符,25个汉字)'
,
rows
:
5
,
},
},
required
:
true
,
'x-rules'
:
[
{
limitByte
:
true
,
// 自定义校验规则
maxByte
:
50
,
}
],
},
},
},
},
},
},
...
@@ -199,16 +207,28 @@ export const warehouseDetailSchema: ISchema = {
...
@@ -199,16 +207,28 @@ export const warehouseDetailSchema: ISchema = {
type
:
'string'
,
type
:
'string'
,
enum
:
[],
enum
:
[],
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
''
,
placeholder
:
'
请选择
'
,
},
},
},
},
tel
:
{
tel
:
{
type
:
'string'
,
type
:
'string'
,
'x-mega-props'
:
{
span
:
3
},
'x-mega-props'
:
{
span
:
3
,
},
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'请输入你的手机号码'
,
placeholder
:
'请输入你的手机号码'
,
maxLength
:
11
,
maxLength
:
11
,
},
},
'x-rules'
:
[
{
required
:
true
,
message
:
'请输入你的手机号码'
,
},
{
pattern
:
PATTERN_MAPS
.
phone
,
message
:
'请输入正确格式的手机号'
,
},
],
},
},
},
},
},
},
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment