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
shenshaokai
jinfa-admin
Commits
4015b637
Commit
4015b637
authored
Jul 19, 2021
by
Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 内容管理bug
parent
2b3fa50c
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
25 deletions
+22
-25
schema.tsx
src/pages/content/category/schema.tsx
+6
-0
useInitialValues.tsx
src/pages/content/hooks/useInitialValues.tsx
+1
-1
infomationInfo.tsx
src/pages/content/infomation/infomationInfo.tsx
+15
-24
No files found.
src/pages/content/category/schema.tsx
View file @
4015b637
...
@@ -44,6 +44,12 @@ export const classSchema: ISchema = {
...
@@ -44,6 +44,12 @@ export const classSchema: ISchema = {
"x-component-props"
:
{
"x-component-props"
:
{
placeholder
:
'最多100个字符,50个汉字'
placeholder
:
'最多100个字符,50个汉字'
},
},
"x-rules"
:
[
{
limitByte
:
true
,
maxByte
:
100
}
]
},
},
level
:
{
level
:
{
type
:
'string'
,
type
:
'string'
,
...
...
src/pages/content/hooks/useInitialValues.tsx
View file @
4015b637
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
React
,
{
useEffect
,
useState
}
from
'react'
;
const
useInitialValues
=
(
params
,
service
)
=>
{
const
useInitialValues
=
(
params
,
service
)
=>
{
const
[
state
,
setState
]
=
useState
(
{}
)
const
[
state
,
setState
]
=
useState
(
null
)
useEffect
(()
=>
{
useEffect
(()
=>
{
if
(
params
.
id
)
{
if
(
params
.
id
)
{
service
(
params
).
then
((
data
)
=>
{
service
(
params
).
then
((
data
)
=>
{
...
...
src/pages/content/infomation/infomationInfo.tsx
View file @
4015b637
...
@@ -18,7 +18,7 @@ import { GetManageContentCategoryAllResponse } from '@/services/PlatformApi';
...
@@ -18,7 +18,7 @@ import { GetManageContentCategoryAllResponse } from '@/services/PlatformApi';
import
{
COLUMN_CATEGORY
}
from
'@/constants/const/content'
;
import
{
COLUMN_CATEGORY
}
from
'@/constants/const/content'
;
const
actions
=
createFormActions
();
const
actions
=
createFormActions
();
const
{
onFieldValueChange$
}
=
FormEffectHooks
const
{
onFieldValueChange$
,
onFieldInputChange$
}
=
FormEffectHooks
const
{
TextArea
}
=
Input
;
const
{
TextArea
}
=
Input
;
...
@@ -31,13 +31,13 @@ type ColumnType = 0 | 1 | 2;
...
@@ -31,13 +31,13 @@ type ColumnType = 0 | 1 | 2;
type
ColumnListType
=
{
type
ColumnListType
=
{
label
:
string
,
label
:
string
,
value
:
number
,
value
:
number
,
type
:
1
|
2
type
:
1
|
2
|
number
&
{}
}
}
const
InfomationInfo
=
()
=>
{
const
InfomationInfo
=
()
=>
{
useCustomValidator
();
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
{
id
,
preview
}
=
usePageStatus
();
const
[
isTop
,
setIsTop
]
=
useState
(
1
);
//
const [isTop, setIsTop] = useState(1);
const
[
labelIds
,
setLabelIds
]
=
useState
<
number
[]
>
([]);
const
[
labelIds
,
setLabelIds
]
=
useState
<
number
[]
>
([]);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
[
unsaved
,
setUnsaved
]
=
useState
(
true
);
const
[
unsaved
,
setUnsaved
]
=
useState
(
true
);
...
@@ -92,24 +92,28 @@ const InfomationInfo = () => {
...
@@ -92,24 +92,28 @@ const InfomationInfo = () => {
},
[])
},
[])
useEffect
(()
=>
{
useEffect
(()
=>
{
const
data
=
initialValues
.
data
||
{}
if
(
initialValues
===
null
)
{
return
;
}
const
data
=
initialValues
!
.
data
||
{}
const
content
=
data
.
content
;
const
content
=
data
.
content
;
if
(
content
)
{
if
(
content
)
{
const
editorState
=
BraftEditor
.
createEditorState
(
content
);
const
editorState
=
BraftEditor
.
createEditorState
(
content
);
actions
.
setFieldValue
(
'layout.contentLayout.content'
,
editorState
);
actions
.
setFieldValue
(
'layout.contentLayout.content'
,
editorState
);
}
}
setFormStatus
(
'layout.contentLayout.content'
,
'readOnly'
,
isView
);
setFormStatus
(
'layout.contentLayout.content'
,
'readOnly'
,
isView
);
/** @tofix 这里写的不是很好, 这里分类联动应该单独一个组件抽离 */
if
(
category
)
{
if
(
category
)
{
actions
.
setFieldValue
(
'layout.categoryLayout.firstCategoryName'
,
data
.
firstCategoryName
);
actions
.
setFieldValue
(
'layout.categoryLayout.firstCategoryName'
,
data
.
firstCategoryName
);
const
secondCategory
=
category
.
filter
((
_row
)
=>
_row
.
id
===
data
.
firstCategoryId
)[
0
]?.
list
||
[];
const
secondCategory
=
category
.
filter
((
_row
)
=>
_row
.
id
===
data
.
firstCategoryId
)[
0
]?.
list
||
[];
const
options
=
secondCategory
.
map
((
_row
:
any
)
=>
({
label
:
_row
.
name
,
value
:
_row
.
id
,
children
:
_row
.
list
}))
const
options
=
secondCategory
.
map
((
_row
:
any
)
=>
({
label
:
_row
.
name
,
value
:
_row
.
id
,
children
:
_row
.
list
}))
setFormStatus
(
'layout.categoryLayout.secondCategoryId'
,
'options'
,
options
);
setFormStatus
(
'layout.categoryLayout.secondCategoryId'
,
'options'
,
options
);
actions
.
setFieldValue
(
'layout.categoryLayout.secondCategoryId'
,
data
.
secondCategoryId
);
//
actions.setFieldValue('layout.categoryLayout.secondCategoryId', data.secondCategoryId);
const
thirdCategory
=
options
.
filter
((
_row
)
=>
_row
.
value
===
data
.
secondCategoryId
)[
0
]?.
children
||
[];
const
thirdCategory
=
options
.
filter
((
_row
)
=>
_row
.
value
===
data
.
secondCategoryId
)[
0
]?.
children
||
[];
const
thirdOptions
=
thirdCategory
.
map
((
_row
:
any
)
=>
({
label
:
_row
.
name
,
value
:
_row
.
id
,
children
:
_row
.
list
}))
const
thirdOptions
=
thirdCategory
.
map
((
_row
:
any
)
=>
({
label
:
_row
.
name
,
value
:
_row
.
id
,
children
:
_row
.
list
}))
setFormStatus
(
'layout.categoryLayout.thirdlyCategoryId'
,
'options'
,
thirdOptions
);
setFormStatus
(
'layout.categoryLayout.thirdlyCategoryId'
,
'options'
,
thirdOptions
);
actions
.
setFieldValue
(
'layout.categoryLayout.thirdlyCategoryId'
,
data
.
thirdlyCategoryId
);
//
actions.setFieldValue('layout.categoryLayout.thirdlyCategoryId', data.thirdlyCategoryId);
}
}
if
(
column
)
{
if
(
column
)
{
const
targetColumn
=
column
.
filter
((
_item
)
=>
_item
.
value
===
data
.
columnId
)[
0
];
const
targetColumn
=
column
.
filter
((
_item
)
=>
_item
.
value
===
data
.
columnId
)[
0
];
...
@@ -121,7 +125,7 @@ const InfomationInfo = () => {
...
@@ -121,7 +125,7 @@ const InfomationInfo = () => {
}
}
}
}
setFormStatus('layout.imageUpload', 'imgUrl', data.imageUrl)
setFormStatus('layout.imageUpload', 'imgUrl', data.imageUrl)
setIsTop(data.top);
//
setIsTop(data.top);
setLabelIds(data.labelIds)
setLabelIds(data.labelIds)
setFormStatus('layout.labelIds', 'seletedTag', data.labelIds)
setFormStatus('layout.labelIds', 'seletedTag', data.labelIds)
}, [initialValues, category, column])
}, [initialValues, category, column])
...
@@ -130,7 +134,6 @@ const InfomationInfo = () => {
...
@@ -130,7 +134,6 @@ const InfomationInfo = () => {
const content = value.content.toHTML();
const content = value.content.toHTML();
const tempPostData = {
const tempPostData = {
...value,
...value,
top: isTop,
type: type,
type: type,
labelIds: labelIds || [],
labelIds: labelIds || [],
content: content,
content: content,
...
@@ -163,7 +166,7 @@ const InfomationInfo = () => {
...
@@ -163,7 +166,7 @@ const InfomationInfo = () => {
>
>
<Card>
<Card>
<SchemaForm
<SchemaForm
initialValues
={initialValues?.data}
value
={initialValues?.data}
onSubmit={handleSubmit}
onSubmit={handleSubmit}
schema={infomationInfoSchema}
schema={infomationInfoSchema}
editable={isAdd || isEdit}
editable={isAdd || isEdit}
...
@@ -174,7 +177,6 @@ const InfomationInfo = () => {
...
@@ -174,7 +177,6 @@ const InfomationInfo = () => {
CustomUpload, CustomTags, CustomEditor,
CustomUpload, CustomTags, CustomEditor,
}}
}}
effects={($) => {
effects={($) => {
onFieldValueChange$('layout.columnId').subscribe(({ value }) => {
onFieldValueChange$('layout.columnId').subscribe(({ value }) => {
actions.setFieldState('layout.columnId', state => {
actions.setFieldState('layout.columnId', state => {
const currentType = state.props["x-component-props"]!.options?.filter((_row) => _row.value === value)[0];
const currentType = state.props["x-component-props"]!.options?.filter((_row) => _row.value === value)[0];
...
@@ -182,16 +184,14 @@ const InfomationInfo = () => {
...
@@ -182,16 +184,14 @@ const InfomationInfo = () => {
setType(currentType ? currentType.type : 0)
setType(currentType ? currentType.type : 0)
})
})
})
})
onField
ValueChange$('layout.categoryLayout.*(firstCategoryId,secondCategoryId, thirdly
CategoryId)').subscribe(({ value, props, name }) => {
onField
InputChange$('layout.categoryLayout.*(firstCategoryId,second
CategoryId)').subscribe(({ value, props, name }) => {
const matchName = name.match(/(.*?)Id/)
const matchName = name.match(/(.*?)Id/)
;
if(matchName?.length !== 2) {
if(matchName?.length !== 2) {
return
return
}
}
const target = props["x-component-props"]!.options.filter((_row) => _row.value === value)[0];
const target = props["x-component-props"]!.options.filter((_row) => _row.value === value)[0];
actions.setFieldValue(`
layout
.
categoryLayout
.
$
{
matchName
[
1
]}
Name
`, target?.label)
actions.setFieldValue(`
layout
.
categoryLayout
.
$
{
matchName
[
1
]}
Name
`, target?.label)
if(name === 'thirdlyCategoryId') {
return;
}
const childrenName = name === 'firstCategoryId' ? 'secondCategoryId' : 'thirdlyCategoryId';
const childrenName = name === 'firstCategoryId' ? 'secondCategoryId' : 'thirdlyCategoryId';
const optionChildren = target?.children || [];
const optionChildren = target?.children || [];
const list = optionChildren?.map((_item) => ({ label: _item.name, value: _item.id, children: _item.list }) );
const list = optionChildren?.map((_item) => ({ label: _item.name, value: _item.id, children: _item.list }) );
...
@@ -203,15 +203,6 @@ const InfomationInfo = () => {
...
@@ -203,15 +203,6 @@ const InfomationInfo = () => {
}}
}}
expressionScope={{
expressionScope={{
isTop: (
<Checkbox
checked={!!isTop}
onChange={(e) => setIsTop(e.target.checked ? 1 : 0)}
disabled={false}
>
置顶
</Checkbox>
),
tagOnChange: (value) => {
tagOnChange: (value) => {
setLabelIds(value);
setLabelIds(value);
},
},
...
...
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