Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
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
linweijiong
jinfa-admin
Commits
0bb1eb39
Commit
0bb1eb39
authored
Dec 24, 2020
by
前端-钟卫鹏
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix:商品品类高级筛选变更为Cascader联级选择
parent
ac2f7abc
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
98 additions
and
41 deletions
+98
-41
CustomCategorySearch.tsx
src/components/NiceForm/components/CustomCategorySearch.tsx
+54
-0
CustomInputSearch.tsx
src/components/NiceForm/components/CustomInputSearch.tsx
+0
-6
Search.tsx
src/components/NiceForm/components/Search.tsx
+4
-3
index.tsx
src/components/NiceForm/index.tsx
+3
-1
index.tsx
src/pages/commodity/effect/index.tsx
+6
-1
index.tsx
src/pages/commodity/productWillCheck/index.tsx
+10
-6
index.tsx
src/pages/commodity/products/index.tsx
+10
-6
index.tsx
src/pages/commodity/schema/index.tsx
+11
-18
No files found.
src/components/NiceForm/components/CustomCategorySearch.tsx
0 → 100644
View file @
0bb1eb39
import
React
,
{
useState
,
useEffect
}
from
'react'
;
import
{
Input
,
Space
,
Select
,
Button
,
Cascader
}
from
'antd'
;
import
{
useFieldState
,
FormPath
,
FormEffectHooks
,
useFormEffects
}
from
'@formily/antd'
;
/**
* 筛选项 搜索和远程数据结合的 Cascader
* 属性Data数据暂存至schema的props下的dataOption
*/
const
CustomCategorySearch
=
props
=>
{
const
justifyAlign
=
props
.
props
[
'x-component-props'
].
align
||
'flex-end'
const
option
=
props
.
props
[
'x-component-props'
].
dataoption
const
[
dataOption
,
setDataOption
]
=
useState
<
any
>
([])
const
[
value
,
setValue
]
=
useState
<
any
>
([])
useEffect
(()
=>
{
setDataOption
(
option
)
},
[
option
])
useFormEffects
(()
=>
{
FormEffectHooks
.
onFormReset$
().
subscribe
(()
=>
{
setValue
([])
})
})
const
onChange
=
(
value
,
selectedOptions
)
=>
{
props
.
mutators
.
change
(
value
[
value
.
length
-
1
])
setValue
(
value
)
}
const
displayRender
=
(
label
)
=>
{
return
label
[
label
.
length
-
1
];
}
return
(
<
Space
size=
{
20
}
style=
{
{
justifyContent
:
justifyAlign
,
width
:
'100%'
}
}
>
<
Cascader
options=
{
dataOption
}
onChange=
{
onChange
}
value=
{
value
}
displayRender=
{
displayRender
}
{
...
props
.
props
['
x
-
component
-
props
']}
/>
</
Space
>
);
};
CustomCategorySearch
.
defaultProps
=
{};
CustomCategorySearch
.
isFieldComponent
=
true
;
export
default
CustomCategorySearch
;
src/components/NiceForm/components/CustomInputSearch.tsx
View file @
0bb1eb39
...
@@ -13,12 +13,6 @@ import { PublicApi } from '@/services/api';
...
@@ -13,12 +13,6 @@ import { PublicApi } from '@/services/api';
const
{
Option
}
=
Select
const
{
Option
}
=
Select
// export interface SearchProps {
// value: string;
// mutators: any;
// props: any;
// }
const
CustomInputSearch
=
props
=>
{
const
CustomInputSearch
=
props
=>
{
const
{
form
}
=
props
const
{
form
}
=
props
const
justifyAlign
=
props
.
props
[
'x-component-props'
].
align
||
'flex-end'
const
justifyAlign
=
props
.
props
[
'x-component-props'
].
align
||
'flex-end'
...
...
src/components/NiceForm/components/Search.tsx
View file @
0bb1eb39
...
@@ -15,11 +15,11 @@ const Search = props => {
...
@@ -15,11 +15,11 @@ const Search = props => {
const
[
state
,
setState
]
=
useFieldState
({
const
[
state
,
setState
]
=
useFieldState
({
filterSearch
:
false
,
filterSearch
:
false
,
});
});
const
{
const
{
align
,
align
,
advanced
=
true
,
// 是否展示高级筛选
advanced
=
true
,
// 是否展示高级筛选
tip
,
// 搜索框悬浮提示
tip
,
// 搜索框悬浮提示
...
rest
...
rest
}
=
props
.
props
[
'x-component-props'
];
}
=
props
.
props
[
'x-component-props'
];
const
justifyAlign
=
align
||
'flex-end'
;
const
justifyAlign
=
align
||
'flex-end'
;
...
@@ -56,6 +56,7 @@ const Search = props => {
...
@@ -56,6 +56,7 @@ const Search = props => {
<
Button
<
Button
onClick=
{
()
=>
{
onClick=
{
()
=>
{
props
.
form
.
reset
();
props
.
form
.
reset
();
sessionStorage
.
setItem
(
'tableRest'
,
'true'
)
props
.
form
.
submit
();
props
.
form
.
submit
();
}
}
}
}
>
>
...
...
src/components/NiceForm/index.tsx
View file @
0bb1eb39
...
@@ -8,7 +8,8 @@ import CustomStatus from './components/CustomStatus';
...
@@ -8,7 +8,8 @@ import CustomStatus from './components/CustomStatus';
import
CustomAddArray
from
'./components/CustomAddArray'
;
import
CustomAddArray
from
'./components/CustomAddArray'
;
import
CustomSlider
from
'./components/CustomSlider'
;
import
CustomSlider
from
'./components/CustomSlider'
;
import
Search
from
'./components/Search'
;
import
Search
from
'./components/Search'
;
import
CustomInputSearch
from
'./components/CustomInputSearch'
import
CustomInputSearch
from
'./components/CustomInputSearch'
;
import
CustomCategorySearch
from
'./components/CustomCategorySearch'
;
import
Submit
from
'./components/Submit'
;
import
Submit
from
'./components/Submit'
;
import
Text
from
'./components/Text'
;
import
Text
from
'./components/Text'
;
import
CardCheckBox
from
'./components/CardCheckBox'
;
import
CardCheckBox
from
'./components/CardCheckBox'
;
...
@@ -77,6 +78,7 @@ export const componentExport = {
...
@@ -77,6 +78,7 @@ export const componentExport = {
CustomRadio
,
CustomRadio
,
Search
,
Search
,
CustomInputSearch
,
CustomInputSearch
,
CustomCategorySearch
,
Submit
,
Submit
,
Text
,
Text
,
CardCheckBox
,
CardCheckBox
,
...
...
src/pages/commodity/effect/index.tsx
View file @
0bb1eb39
...
@@ -21,7 +21,12 @@ export const searchBrandOptionEffect = (context: any, fieldName: string) => {
...
@@ -21,7 +21,12 @@ export const searchBrandOptionEffect = (context: any, fieldName: string) => {
export
const
searchCustomerCategoryOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
export
const
searchCustomerCategoryOptionEffect
=
(
context
:
any
,
fieldName
:
string
)
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
context
.
getFieldState
(
fieldName
,
state
=>
{
PublicApi
.
getProductSelectGetSelectCategory
({
name
:
state
.
props
[
'x-component-props'
].
searchValue
}).
then
(
res
=>
{
// PublicApi.getProductSelectGetSelectCategory({ name: state.props['x-component-props'].searchValue }).then(res => {
// context.setFieldState(fieldName, state => {
// state.props['x-component-props'].dataoption = res.data
// })
// })
PublicApi
.
getProductPlatformGetCategoryTree
().
then
(
res
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
context
.
setFieldState
(
fieldName
,
state
=>
{
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
state
.
props
[
'x-component-props'
].
dataoption
=
res
.
data
})
})
...
...
src/pages/commodity/productWillCheck/index.tsx
View file @
0bb1eb39
...
@@ -43,11 +43,16 @@ const Products: React.FC<{}> = () => {
...
@@ -43,11 +43,16 @@ const Products: React.FC<{}> = () => {
key
:
'memberName'
,
key
:
'memberName'
,
},
},
{
{
title
:
'品类'
,
title
:
'
会员
品类'
,
dataIndex
:
[
'customerCategory'
,
'name'
],
dataIndex
:
[
'customerCategory'
,
'name'
],
key
:
'customerCategory.name'
,
key
:
'customerCategory.name'
,
},
},
{
{
title
:
'平台品类'
,
dataIndex
:
[
'customerCategory'
,
'category'
,
'name'
],
key
:
'customerCategory.category.name'
,
},
{
title
:
'品牌'
,
title
:
'品牌'
,
dataIndex
:
[
'brand'
,
'name'
],
dataIndex
:
[
'brand'
,
'name'
],
key
:
'brand.name'
,
key
:
'brand.name'
,
...
@@ -164,10 +169,10 @@ const Products: React.FC<{}> = () => {
...
@@ -164,10 +169,10 @@ const Products: React.FC<{}> = () => {
FormEffectHooks
.
onFieldChange$
(
'brandId'
).
subscribe
(
state
=>
{
FormEffectHooks
.
onFieldChange$
(
'brandId'
).
subscribe
(
state
=>
{
searchBrandOptionEffect
(
actions
,
'brandId'
)
searchBrandOptionEffect
(
actions
,
'brandId'
)
})
})
FormEffectHooks
.
onFieldChange$
(
'c
ustomerC
ategoryId'
).
subscribe
(
state
=>
{
FormEffectHooks
.
onFieldChange$
(
'categoryId'
).
subscribe
(
state
=>
{
searchCustomerCategoryOptionEffect
(
actions
,
'c
ustomerC
ategoryId'
)
searchCustomerCategoryOptionEffect
(
actions
,
'categoryId'
)
})
})
}
}
}
}
schema=
{
productWillSchema
}
schema=
{
productWillSchema
}
/>
/>
}
}
...
@@ -177,4 +182,4 @@ const Products: React.FC<{}> = () => {
...
@@ -177,4 +182,4 @@ const Products: React.FC<{}> = () => {
)
)
}
}
export
default
Products
export
default
Products
\ No newline at end of file
src/pages/commodity/products/index.tsx
View file @
0bb1eb39
...
@@ -42,11 +42,16 @@ const Products: React.FC<{}> = () => {
...
@@ -42,11 +42,16 @@ const Products: React.FC<{}> = () => {
key
:
'memberName'
,
key
:
'memberName'
,
},
},
{
{
title
:
'品类'
,
title
:
'
会员
品类'
,
dataIndex
:
[
'customerCategory'
,
'name'
],
dataIndex
:
[
'customerCategory'
,
'name'
],
key
:
'customerCategory.name'
,
key
:
'customerCategory.name'
,
},
},
{
{
title
:
'平台品类'
,
dataIndex
:
[
'customerCategory'
,
'category'
,
'name'
],
key
:
'customerCategory.category.name'
,
},
{
title
:
'品牌'
,
title
:
'品牌'
,
dataIndex
:
[
'brand'
,
'name'
],
dataIndex
:
[
'brand'
,
'name'
],
key
:
'brand.name'
,
key
:
'brand.name'
,
...
@@ -152,10 +157,10 @@ const Products: React.FC<{}> = () => {
...
@@ -152,10 +157,10 @@ const Products: React.FC<{}> = () => {
FormEffectHooks
.
onFieldChange$
(
'brandId'
).
subscribe
(
state
=>
{
FormEffectHooks
.
onFieldChange$
(
'brandId'
).
subscribe
(
state
=>
{
searchBrandOptionEffect
(
actions
,
'brandId'
)
searchBrandOptionEffect
(
actions
,
'brandId'
)
})
})
FormEffectHooks
.
onFieldChange$
(
'c
ustomerC
ategoryId'
).
subscribe
(
state
=>
{
FormEffectHooks
.
onFieldChange$
(
'categoryId'
).
subscribe
(
state
=>
{
searchCustomerCategoryOptionEffect
(
actions
,
'c
ustomerC
ategoryId'
)
searchCustomerCategoryOptionEffect
(
actions
,
'categoryId'
)
})
})
}
}
}
}
schema=
{
productSchema
}
schema=
{
productSchema
}
/>
/>
}
}
...
@@ -165,4 +170,4 @@ const Products: React.FC<{}> = () => {
...
@@ -165,4 +170,4 @@ const Products: React.FC<{}> = () => {
)
)
}
}
export
default
Products
export
default
Products
\ No newline at end of file
src/pages/commodity/schema/index.tsx
View file @
0bb1eb39
...
@@ -58,19 +58,16 @@ export const productSchema: ISchema = {
...
@@ -58,19 +58,16 @@ export const productSchema: ISchema = {
dataoption
:
[],
dataoption
:
[],
},
},
},
},
c
ustomerC
ategoryId
:
{
categoryId
:
{
type
:
'string'
,
type
:
'string'
,
'x-component'
:
'Custom
Input
Search'
,
'x-component'
:
'Custom
Category
Search'
,
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'
商品
品类'
,
placeholder
:
'
平台
品类'
,
showSearch
:
true
,
showSearch
:
true
,
showArrow
:
true
,
defaultActiveFirstOption
:
false
,
filterOption
:
false
,
notFoundContent
:
null
,
notFoundContent
:
null
,
style
:
{
width
:
'174px'
},
style
:
{
width
:
'174px'
},
searchValue
:
null
,
dataoption
:
[]
,
dataoption
:
[]
fieldNames
:
{
label
:
'title'
,
value
:
'id'
,
children
:
'children'
},
},
},
},
},
status
:
{
status
:
{
...
@@ -223,19 +220,16 @@ export const productWillSchema: ISchema = {
...
@@ -223,19 +220,16 @@ export const productWillSchema: ISchema = {
dataoption
:
[],
dataoption
:
[],
},
},
},
},
c
ustomerC
ategoryId
:
{
categoryId
:
{
type
:
'string'
,
type
:
'string'
,
'x-component'
:
'Custom
Input
Search'
,
'x-component'
:
'Custom
Category
Search'
,
'x-component-props'
:
{
'x-component-props'
:
{
placeholder
:
'
商品
品类'
,
placeholder
:
'
平台
品类'
,
showSearch
:
true
,
showSearch
:
true
,
showArrow
:
true
,
defaultActiveFirstOption
:
false
,
filterOption
:
false
,
notFoundContent
:
null
,
notFoundContent
:
null
,
style
:
{
width
:
'174px'
},
style
:
{
width
:
'174px'
},
searchValue
:
null
,
dataoption
:
[]
,
dataoption
:
[]
fieldNames
:
{
label
:
'title'
,
value
:
'id'
,
children
:
'children'
},
},
},
},
},
'NO_NAME_FIELD_$2'
:
{
'NO_NAME_FIELD_$2'
:
{
...
@@ -294,4 +288,4 @@ export const productWillSchema: ISchema = {
...
@@ -294,4 +288,4 @@ export const productWillSchema: ISchema = {
},
},
},
},
},
},
};
};
\ No newline at end of file
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