Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
F
form_upload_folder
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
form_upload_folder
Commits
d7e3efa8
Commit
d7e3efa8
authored
Jul 03, 2024
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: debug
parent
783b94c5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
0 deletions
+55
-0
form.component.html
form/src/app/form/form.component.html
+16
-0
form.component.ts
form/src/app/form/form.component.ts
+39
-0
No files found.
form/src/app/form/form.component.html
View file @
d7e3efa8
...
@@ -25,6 +25,22 @@
...
@@ -25,6 +25,22 @@
</div>
</div>
<div
style=
"float: right; margin-right: -110px;"
align=
"center"
>
<button
style=
""
nz-button
nzShape=
"circle"
(
click
)="
sortQues
(
i
+
1
,
i
)"
>
<i
nz-icon
nzType=
"up"
nzTheme=
"outline"
></i>
</button>
<div
style=
"margin: 5px;"
>
<input
type=
"text"
style=
"text-align: center; width: 50px;"
nz-input
[(
ngModel
)]="
ques
.
quesIndex
"
(
blur
)="
sortQues
(
i
+
1
,
ques
.
quesIndex
)"
>
</div>
<button
style=
""
nz-button
nzShape=
"circle"
(
click
)="
sortQues
(
i
+
1
,
i
+
2
)"
>
<i
nz-icon
nzType=
"down"
nzTheme=
"outline"
></i>
</button>
</div>
<div
style=
" display: flex; align-items: center; "
>
<div
style=
" display: flex; align-items: center; "
>
<span>
标题:
</span>
<span>
标题:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
ques
.
title
"
(
blur
)="
save
()"
style=
" width: 350px;"
>
<input
type=
"text"
nz-input
[(
ngModel
)]="
ques
.
title
"
(
blur
)="
save
()"
style=
" width: 350px;"
>
...
...
form/src/app/form/form.component.ts
View file @
d7e3efa8
...
@@ -509,9 +509,46 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -509,9 +509,46 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// if (!this.item.group_arr) {
// if (!this.item.group_arr) {
// this.item.group_arr = [];
// this.item.group_arr = [];
// }
// }
this
.
refreshQuesIndex
();
}
refreshQuesIndex
()
{
this
.
item
.
quesArr
.
forEach
((
element
,
index
)
=>
{
element
.
quesIndex
=
index
+
1
;
});
}
}
sortQues
(
baseId
,
targetId
)
{
console
.
log
(
'
baseIndex :
'
+
baseId
);
console
.
log
(
'
targetIndex :
'
+
targetId
);
this
.
moveElement
(
this
.
item
.
quesArr
,
baseId
-
1
,
targetId
-
1
);
// this.refreshQuesIndex();
}
moveElement
(
arr
,
fromIndex
,
toIndex
)
{
// 检查索引是否有效
if
(
fromIndex
<
0
||
fromIndex
>=
arr
.
length
||
toIndex
<
0
||
toIndex
>=
arr
.
length
)
{
throw
new
Error
(
'
Invalid index
'
);
}
// 获取要移动的元素
const
element
=
arr
[
fromIndex
];
// 移除元素
arr
.
splice
(
fromIndex
,
1
);
// 插入元素到新位置
arr
.
splice
(
toIndex
,
0
,
element
);
this
.
save
();
return
arr
;
}
...
@@ -1340,6 +1377,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
...
@@ -1340,6 +1377,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
*/
*/
save
()
{
save
()
{
this
.
refreshQuesIndex
();
// if (this.tempItem) {
// if (this.tempItem) {
// this.item.tempItem = this.tempItem;
// this.item.tempItem = this.tempItem;
// }
// }
...
...
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