Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
PU-11
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
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
template admin
PU-11
Commits
d246eaa1
Commit
d246eaa1
authored
Jun 21, 2020
by
Chen Jiping
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改校验
parent
a08e95be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
7 deletions
+17
-7
form.component.html
src/app/form/form.component.html
+1
-1
form.component.ts
src/app/form/form.component.ts
+16
-6
No files found.
src/app/form/form.component.html
View file @
d246eaa1
...
@@ -46,7 +46,7 @@
...
@@ -46,7 +46,7 @@
<nz-form-item>
<nz-form-item>
<nz-form-label
[
nzSpan
]="
6
"
nzNoColon=
true
>
标题
</nz-form-label>
<nz-form-label
[
nzSpan
]="
6
"
nzNoColon=
true
>
标题
</nz-form-label>
<nz-form-control
[
nzSpan
]="
8
"
>
<nz-form-control
[
nzSpan
]="
8
"
>
<textarea
rows=
"4"
nz-input
[(
ngModel
)]="
data
.
title
"
(
blur
)="
saveContent
(
data
.
title
)"
></textarea>
<textarea
rows=
"4"
nz-input
[(
ngModel
)]="
data
.
title
"
(
ngModelChange
)="
check
(
data
.
title
,
10
)"
(
blur
)="
saveContent
(
data
.
title
)"
></textarea>
</nz-form-control>
</nz-form-control>
</nz-form-item>
</nz-form-item>
</div>
</div>
...
...
src/app/form/form.component.ts
View file @
d246eaa1
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
}
from
'
@angular/core
'
;
import
{
Component
,
EventEmitter
,
Input
,
OnDestroy
,
OnChanges
,
OnInit
,
Output
,
ApplicationRef
,
ChangeDetectorRef
}
from
'
@angular/core
'
;
import
{
NzMessageService
}
from
'
ng-zorro-antd/message
'
;
import
{
NzMessageService
}
from
'
ng-zorro-antd/message
'
;
import
{
max
}
from
'
rxjs/operators
'
;
@
Component
({
@
Component
({
selector
:
'
app-form
'
,
selector
:
'
app-form
'
,
...
@@ -121,9 +122,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -121,9 +122,9 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
save
();
this
.
save
();
}
}
saveContent
(
value
)
{
check
(
value
,
maxLength
:
number
)
{
if
(
!
value
)
{
if
(
!
value
)
{
return
;
return
true
;
}
}
const
chr
=
value
.
split
(
/
\s
+|
\?
|
\.
|
\,
|
\!
/
);
const
chr
=
value
.
split
(
/
\s
+|
\?
|
\.
|
\,
|
\!
/
);
...
@@ -136,14 +137,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -136,14 +137,23 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
}
}
}
if
(
count
<=
10
)
{
if
(
count
<=
maxLength
)
{
this
.
save
()
;
return
true
;
}
}
else
{
else
{
let
id
=
this
.
message
.
error
(
'
超过
10
个单词量
'
,
{
nzDuration
:
0
}).
messageId
;
let
id
=
this
.
message
.
error
(
'
超过
'
+
maxLength
+
'
个单词量
'
,
{
nzDuration
:
0
}).
messageId
;
setTimeout
(()
=>
{
setTimeout
(()
=>
{
this
.
message
.
remove
(
id
);
this
.
message
.
remove
(
id
);
},
3000
);
},
2000
);
return
false
;
}
}
saveContent
(
value
)
{
let
result
=
this
.
check
(
value
,
10
);
if
(
result
)
{
this
.
save
();
}
}
}
}
...
...
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