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
780725b3
Commit
780725b3
authored
Sep 30, 2020
by
Bill
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
完善校验
parent
9828d35c
Hide whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
90 additions
and
52 deletions
+90
-52
advertisementInfo.tsx
src/pages/content/advertisement/advertisementInfo.tsx
+2
-0
advertisementInfoSchema.tsx
.../content/advertisement/schema/advertisementInfoSchema.tsx
+7
-1
announceInfo.tsx
src/pages/content/announcements/announceInfo.tsx
+2
-0
announceInfoSchema.tsx
...pages/content/announcements/schema/announceInfoSchema.tsx
+1
-1
columnInfo.tsx
src/pages/content/columnManagement/columnInfo.tsx
+2
-3
CustomTable.tsx
src/pages/content/components/FilterTable/CustomTable.tsx
+0
-19
FilterTable.tsx
src/pages/content/components/FilterTable/FilterTable.tsx
+5
-6
index.tsx
src/pages/content/components/FilterTable/index.tsx
+0
-3
useValidator.tsx
src/pages/content/hooks/useValidator.tsx
+25
-0
imageInfo.tsx
src/pages/content/imagesManagement/imageInfo.tsx
+2
-0
infomationInfo.tsx
src/pages/content/infomation/infomationInfo.tsx
+4
-2
infomationInfoSchema.tsx
src/pages/content/infomation/schema/infomationInfoSchema.tsx
+18
-9
tagsInfo.tsx
src/pages/content/tagsManagement/tagsInfo.tsx
+22
-8
No files found.
src/pages/content/advertisement/advertisementInfo.tsx
View file @
780725b3
...
...
@@ -11,10 +11,12 @@ import { Input, Select } from 'antd';
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useInitialValues
}
from
'../hooks/useInitialValues'
;
import
CustomUpload
from
'../components/WrapCustomUpload'
;
import
useCustomValidator
from
'../hooks/useValidator'
const
actions
=
createFormActions
();
const
AdvertisementInfo
=
()
=>
{
useCustomValidator
()
const
{
id
,
preview
}
=
usePageStatus
();
const
initialValues
=
useInitialValues
({
id
:
id
},
PublicApi
.
getManageContentAdvertGet
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
...
...
src/pages/content/advertisement/schema/advertisementInfoSchema.tsx
View file @
780725b3
...
...
@@ -34,7 +34,7 @@ const schema = {
"x-rules"
:
[
{
"required"
:
true
,
"message"
:
"最长
20个字符,1
0个汉字"
"message"
:
"最长
60个字符,3
0个汉字"
},
{
limitByte
:
true
,
// 自定义校验规则
...
...
@@ -70,6 +70,12 @@ const schema = {
title
:
'跳转链接'
,
type
:
'string'
,
'x-component'
:
'Input'
,
"x-rules"
:
[
{
limitByte
:
true
,
// 自定义校验规则
maxByte
:
100
,
}
]
},
imageUrl
:
{
type
:
"object"
,
...
...
src/pages/content/announcements/announceInfo.tsx
View file @
780725b3
...
...
@@ -14,10 +14,12 @@ import { useInitialValues } from '../hooks/useInitialValues';
import
CustomCheckbox
from
'../components/CustomCheckbox'
;
import
BraftEditor
from
'braft-editor'
;
import
{
setFormStatus
}
from
'../utils/utils'
;
import
useCustomValidator
from
'../hooks/useValidator'
const
actions
=
createFormActions
();
const
AdvertisementInfo
=
()
=>
{
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
initialValues
:
any
=
useInitialValues
({
id
:
id
},
PublicApi
.
getManageContentNoticeGet
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
...
...
src/pages/content/announcements/schema/announceInfoSchema.tsx
View file @
780725b3
...
...
@@ -23,7 +23,7 @@ const schema = {
"x-rules"
:
[
{
"required"
:
true
,
"message"
:
"最长
20个字符,1
0个汉字"
"message"
:
"最长
60个字符,3
0个汉字"
},
{
limitByte
:
true
,
// 自定义校验规则
...
...
src/pages/content/columnManagement/columnInfo.tsx
View file @
780725b3
...
...
@@ -6,6 +6,7 @@ import ReutrnEle from '@/components/ReturnEle';
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
;
import
{
history
,
Prompt
}
from
'umi'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
useCustomValidator
from
'../hooks/useValidator'
interface
IOption
{
value
:
number
|
string
,
...
...
@@ -41,9 +42,6 @@ const schema = {
name
:
'name'
,
title
:
'栏目名称'
,
'x-component'
:
'Input'
,
'x-component-props'
:
{
maxLength
:
20
},
"required"
:
true
,
"x-rules"
:
[
{
...
...
@@ -89,6 +87,7 @@ const useInitialValues = (id) => {
}
const
ColumnInfo
=
()
=>
{
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
initialValues
=
useInitialValues
(
id
);
...
...
src/pages/content/components/FilterTable/CustomTable.tsx
deleted
100644 → 0
View file @
9828d35c
import
React
from
'react'
;
import
{
Table
}
from
'antd'
;
const
CustomTable
=
(
props
)
=>
{
const
{
column
,
dataSource
,
...
rest
}
=
props
;
return
(
<
div
>
<
Table
column=
{
column
}
dataSource=
{
dataSource
}
{
...
rest
}
></
Table
>
</
div
>
)
}
export
default
CustomTable
;
\ No newline at end of file
src/pages/content/components/FilterTable/FilterTable.tsx
View file @
780725b3
import
React
from
'react'
;
import
React
,
{
useEffect
}
from
'react'
;
import
{
SchemaForm
,
registerVirtualBox
registerVirtualBox
,
SchemaField
,
registerValidationRules
}
from
'@formily/antd'
;
import
{
Row
,
Col
}
from
'antd'
;
// import { FormMegaLayout, Input } from '@formily/antd-components';
import
{
SchemaField
}
from
"@formily/antd"
;
const
renderCol
=
(
schema
)
=>
{
const
{
flexcol
=
{},
}
=
schema
&&
schema
[
'x-component-props'
]
||
{};
...
...
@@ -17,7 +18,6 @@ const renderCol = (schema) => {
registerVirtualBox
(
'CustomFlexRowLayout'
,
(
props
)
=>
{
const
schemaProps
=
props
;
console
.
log
(
"CustomFlexRowLayout"
,
schemaProps
);
const
childProperties
=
schemaProps
.
schema
&&
schemaProps
.
schema
.
getOrderProperties
()
||
[];
const
{
justify
=
"start"
,
align
=
"top"
}
=
schemaProps
&&
schemaProps
.
props
&&
schemaProps
.
props
[
'x-component-props'
]
||
{}
return
(
...
...
@@ -35,9 +35,7 @@ const FlexColumnLayoutStyle = {
}
registerVirtualBox
(
'CustomFlexColumnLayout'
,
(
props
)
=>
{
const
schemaProps
=
props
;
console
.
log
(
"CustomFlexColumnLayout"
,
schemaProps
);
const
childProperties
=
schemaProps
.
schema
&&
schemaProps
.
schema
.
getOrderProperties
()
||
[];
console
.
log
(
"childProperties"
,
childProperties
)
const
{
style
}
=
schemaProps
&&
schemaProps
.
props
&&
schemaProps
.
props
[
'x-component-props'
]
||
{};
return
(
...
...
@@ -58,6 +56,7 @@ registerVirtualBox('CustomFlexColumnLayout', (props) => {
const
FilterTable
=
(
props
)
=>
{
const
{
actions
,
schema
,
components
,
...
rest
}
=
props
;
return
(
<
div
>
<
SchemaForm
...
...
src/pages/content/components/FilterTable/index.tsx
View file @
780725b3
import
FilterTable
from
'./FilterTable'
;
import
CustomTable
from
'./CustomTable'
;
import
{
SchemaFlexRowLayout
,
SchemaFlexColumnLayout
}
from
'./FlexLayout'
;
export
{
FilterTable
,
CustomTable
,
SchemaFlexRowLayout
,
SchemaFlexColumnLayout
}
\ No newline at end of file
src/pages/content/hooks/useValidator.tsx
0 → 100644
View file @
780725b3
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
registerValidationRules
}
from
'@formily/antd'
;
const
useCustomValidator
=
()
=>
{
useEffect
(()
=>
{
//自定义校验规则
registerValidationRules
({
limitByte
:
(
value
,
desc
,
rules
)
=>
{
const
{
allowChineseTransform
=
true
,
maxByte
}
=
desc
;
let
str
=
value
;
let
message
=
`不能超过
${
maxByte
}
个字符`
if
(
allowChineseTransform
)
{
str
=
str
.
replace
(
/
[\u
4E00-
\u
9FA5
]
/g
,
"AA"
);
message
+=
`,或者
${
maxByte
/
2
}
个汉字`
}
return
str
.
length
>
maxByte
?
message
:
""
;
}
});
},
[])
}
export
default
useCustomValidator
src/pages/content/imagesManagement/imageInfo.tsx
View file @
780725b3
...
...
@@ -10,10 +10,12 @@ import { Input, Select } from 'antd';
import
CustomUpload
from
'../components/WrapCustomUpload'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
{
useInitialValues
}
from
'../hooks/useInitialValues'
;
import
useCustomValidator
from
'../hooks/useValidator'
const
actions
=
createFormActions
();
const
ImageInfo
=
()
=>
{
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
initialValues
:
any
=
useInitialValues
({
id
:
id
},
PublicApi
.
getManageContentImageGet
);
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
...
...
src/pages/content/infomation/infomationInfo.tsx
View file @
780725b3
import
React
,
{
useEffect
,
useState
}
from
'react'
;
import
{
SchemaForm
,
Submit
,
FormButtonGroup
,
Reset
,
create
VirtualBox
,
createFormAction
s
}
from
'@formily/antd'
;
import
{
Card
,
Select
,
Input
,
Checkbox
,
Grid
,
Button
}
from
'antd'
;
import
{
SchemaForm
,
Submit
,
FormButtonGroup
,
Reset
,
create
FormActions
,
registerValidationRule
s
}
from
'@formily/antd'
;
import
{
Card
,
Select
,
Input
,
Checkbox
}
from
'antd'
;
import
{
PageHeaderWrapper
}
from
'@ant-design/pro-layout'
;
import
ReutrnEle
from
'@/components/ReturnEle'
;
import
{
usePageStatus
}
from
'@/hooks/usePageStatus'
;
...
...
@@ -13,12 +13,14 @@ import { useInitialValues } from '../hooks/useInitialValues';
import
{
PublicApi
}
from
'@/services/api'
;
import
infomationInfoSchema
from
'./schema/infomationInfoSchema'
;
import
CustomUpload
from
'../components/WrapCustomUpload'
;
import
useCustomValidator
from
'../hooks/useValidator'
const
actions
=
createFormActions
();
const
{
TextArea
}
=
Input
;
const
InfomationInfo
=
()
=>
{
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
[
isTop
,
setIsTop
]
=
useState
(
1
);
const
[
labelIds
,
setLabelIds
]
=
useState
<
number
[]
>
([]);
...
...
src/pages/content/infomation/schema/infomationInfoSchema.tsx
View file @
780725b3
...
...
@@ -33,12 +33,14 @@ const schema = {
title
:
'标题'
,
'x-component'
:
'Input'
,
'x-component-props'
:
{
placeholder
:
'30个字符,15个汉字'
},
"x-rules"
:
{
"required"
:
true
,
"message"
:
"最长30个字符,15个汉字"
placeholder
:
'最长30个汉字,60个字符'
,
},
"x-rules"
:
[
{
limitByte
:
true
,
maxByte
:
60
}
]
},
columnId
:
{
name
:
'columnId'
,
...
...
@@ -131,11 +133,18 @@ const schema = {
"x-component"
:
'TextArea'
,
"x-component-props"
:
{
placeholder
:
"最长300个字符,150个汉字"
,
rows
:
5
,
},
"x-rules"
:
{
"required"
:
true
,
"message"
:
"最长300个字符,150个汉字"
},
"x-rules"
:
[
{
"required"
:
true
,
"message"
:
"最长300个字符,150个汉字"
},
{
limitByte
:
true
,
maxByte
:
300
}
],
},
contentLayout
:
{
'x-component'
:
'mega-layout'
,
...
...
src/pages/content/tagsManagement/tagsInfo.tsx
View file @
780725b3
...
...
@@ -7,6 +7,7 @@ import { usePageStatus } from '@/hooks/usePageStatus';
import
{
history
,
Prompt
}
from
'umi'
;
import
{
useInitialValues
}
from
'../hooks/useInitialValues'
;
import
{
PublicApi
}
from
'@/services/api'
;
import
useCustomValidator
from
'../hooks/useValidator'
const
{
TextArea
}
=
Input
;
const
schema
=
{
...
...
@@ -27,20 +28,32 @@ const schema = {
title
:
'标签名称'
,
'x-component'
:
'Input'
,
"required"
:
true
,
"x-rules"
:
{
"required"
:
true
,
"message"
:
"请填写标签名称"
},
"x-rules"
:
[
{
"required"
:
true
,
"message"
:
"请填写标签名称"
},
{
limitByte
:
true
,
// 自定义校验规则
maxByte
:
20
,
}
],
},
explain
:
{
name
:
'explain'
,
title
:
'标签说明'
,
'x-component'
:
'TextArea'
,
"required"
:
true
,
"x-rules"
:
{
"required"
:
true
,
"message"
:
"请选择标签说明"
},
"x-rules"
:
[
{
"required"
:
true
,
"message"
:
"请选择标签说明"
},
{
limitByte
:
true
,
// 自定义校验规则
maxByte
:
80
,
}
],
},
}
}
...
...
@@ -50,6 +63,7 @@ const schema = {
const
TagInfo
=
()
=>
{
useCustomValidator
();
const
{
id
,
preview
}
=
usePageStatus
();
const
[
submitLoading
,
setSubmitLoading
]
=
useState
(
false
);
const
initialValues
=
useInitialValues
({
id
:
id
},
PublicApi
.
getManageContentLabelGet
);
...
...
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