Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JJ39
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
JJ39
Commits
2fcdeff5
Commit
2fcdeff5
authored
Aug 12, 2024
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix: 回退到之前版本
parent
f55f0abd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
31 additions
and
154 deletions
+31
-154
form.component.html
form/src/app/form/form.component.html
+24
-85
form.component.ts
form/src/app/form/form.component.ts
+7
-69
No files found.
form/src/app/form/form.component.html
View file @
2fcdeff5
...
...
@@ -13,21 +13,7 @@
</app-audio-recorder>
</div>
<div
style=
"margin: 30px;"
>
<nz-radio-group
[
ngModel
]="
item
.
mode
"
(
ngModelChange
)="
radioChange
($
event
,
item
,
'
mode
')"
>
<div
style=
"display: flex; flex-wrap: wrap; width: 100%;"
>
<h3
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
single
'"
>
单页题目
</h3>
<h3
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
multiple
'"
>
多页题目
</h3>
</div>
</nz-radio-group>
</div>
<!-- <div style="margin: 30px; width: 650px; display: flex; align-items: start;">
<div
style=
"margin: 30px; width: 650px; display: flex; align-items: start;"
>
<h3
style=
"width: 100px;"
>
问题文本:
</h3>
<textarea
rows=
"5"
nz-input
[(
ngModel
)]="
item
.
text
"
(
blur
)="
save
()"
></textarea>
</div>
...
...
@@ -44,7 +30,7 @@
x
</button>
</div>
</div>
-->
</div>
...
...
@@ -53,82 +39,35 @@
<div
*
ngFor=
"let page of item.pageArr; let i = index"
style=
"border: 2px #ccc solid; border-radius: 15px; width: 1000px; margin: 30px; padding: 20px;"
>
<h3>
页-{{i+1}}:
</h3>
<div
[
class
.
disabled
]="(
item
.
mode =
=
'
single
')
&&
(
i
!=
0
)"
style=
"border: 2px #ccc solid; border-radius: 15px; width: 900px; margin: 30px"
>
<div
*
ngFor=
"let part of page.partArr; let j = index"
style=
" width: 90%; padding: 30px; margin: 10px;
border: 1px #ccc solid; border-radius: 15px;"
>
<div
style=
"display: flex; align-items: center; justify-content: space-between;"
>
<h4>
段落-{{j+1}}:
</h4>
<button
style=
"float: right; margin-right: 0px;"
nz-button
nzType=
"danger"
(
click
)="
deletePartBtnClick
(
j
,
page
)"
>
删除段落
</button>
</div>
<div
style=
"margin-bottom: 10px;"
>
<!-- <span style="margin-right: 20px;">段落-{{i+1}}: </span> -->
<nz-radio-group
[
ngModel
]="
part
.
type
"
(
ngModelChange
)="
radioChange
($
event
,
part
,
'
type
')"
>
<div
style=
"display: flex; flex-wrap: wrap; width: 100%;"
>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
text
'"
>
文本
</label>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
pic
'"
>
图片
</label>
</div>
</nz-radio-group>
</div>
<div
*
ngIf=
"part.type == 'pic'"
style=
"margin-top: 10px; display: flex; "
>
<div
style=
"width: 300px;"
>
<app-upload-image-with-preview
[
picUrl
]="
part
.
pic_url
"
(
imageUploaded
)="
onItemImgUploadSuccess
($
event
,
part
,
'
pic_url
')"
>
</app-upload-image-with-preview>
</div>
<button
*
ngIf=
"part.pic_url"
style=
"float: right;"
nz-button
nzType=
""
(
click
)="
onDeletaImg
(
part
,
'
pic_url
')"
>
x
</button>
</div>
<div
*
ngIf=
"part.type == 'text'"
>
<input
type=
"text"
nz-input
[(
ngModel
)]="
part
.
text
"
(
blur
)="
savePartText
(
part
)"
style=
" width: 700px;"
>
<nz-radio-group
[
ngModel
]="
page
.
type
"
(
ngModelChange
)="
radioChange
($
event
,
page
,
'
type
')"
>
<div
style=
"display: flex; flex-wrap: wrap; width: 100%;"
>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
fill
'"
>
填空
</label>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
drag
'"
>
拖拽
</label>
</div>
</nz-radio-group>
<div
style=
"color: #aaa; margin: 10px;"
>
示例:What's [your] name? (正确选项使用中括号括起来)
</div>
<div
*
ngFor=
"let ques of page.quesArr; let j = index"
style=
"margin: 10px; display: flex; align-items:center;"
>
<span
style=
""
>
题-{{j+1}}:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
ques
.
text
"
(
blur
)="
save
()"
style=
" width: 300px;"
>
<button
style=
"margin-left: 10px;"
nz-button
nzType=
"danger"
(
click
)="
deleteQuesBtnClick
(
page
.
quesArr
,
j
)"
>
删除题
</button>
</div>
<div
style=
"
padding
: 30px;"
>
<button
nz-button
nzType=
"dashed"
(
click
)="
addOne
PartBtnClick
(
page
)"
style=
"width: 200px; height: 10
0px;"
>
<div
style=
"
margin-top
: 30px;"
>
<button
nz-button
nzType=
"dashed"
(
click
)="
addOne
QuesBtnClick
(
page
)"
style=
"width: 150px; height: 5
0px;"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
添加
段落
添加
一题
</button>
</div>
</div>
<nz-radio-group
[
ngModel
]="
page
.
type
"
(
ngModelChange
)="
radioChange
($
event
,
page
,
'
type
')"
>
<div
style=
"display: flex; flex-wrap: wrap; width: 100%;"
>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
fill
'"
>
填空
</label>
<label
style=
"margin-left: 5px;"
nz-radio
[
nzValue
]="'
drag
'"
>
拖拽
</label>
</div>
</nz-radio-group>
<div
style=
"color: #aaa; margin: 10px;"
>
示例:What's [your] name? (正确选项使用中括号括起来)
</div>
<div
*
ngFor=
"let ques of page.quesArr; let j = index"
style=
"margin: 10px; display: flex; align-items:center;"
>
<span
style=
""
>
题-{{j+1}}:
</span>
<input
type=
"text"
nz-input
[(
ngModel
)]="
ques
.
text
"
(
blur
)="
save
()"
style=
" width: 300px;"
>
<button
style=
"margin-left: 10px;"
nz-button
nzType=
"danger"
(
click
)="
deleteQuesBtnClick
(
page
.
quesArr
,
j
)"
>
删除题
</button>
</div>
<div
style=
"margin-top: 30px;"
>
<button
nz-button
nzType=
"dashed"
(
click
)="
addOneQuesBtnClick
(
page
)"
style=
"width: 150px; height: 50px;"
>
<i
nz-icon
nzType=
"plus-circle"
nzTheme=
"outline"
></i>
添加一题
</button>
</div>
</div>
...
...
form/src/app/form/form.component.ts
View file @
2fcdeff5
...
...
@@ -527,45 +527,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
if
(
!
this
.
item
.
pageArr
)
{
this
.
item
.
pageArr
=
[];
}
if
(
!
this
.
item
.
mode
)
{
this
.
item
.
mode
=
'
single
'
;
}
this
.
test
();
}
test
()
{
this
.
splitTextIntoObjects
(
'
aaa [bbb] ccc eeefff aaa [ddd] [zzz].
'
)
}
splitTextIntoObjects
(
text
)
{
const
regex
=
/
[\[\]]
/
;
// 使用split方法分割文本
// 注意:split方法会移除分隔符,只保留分隔符之间的文本
// 但由于我们想要知道哪里被分割了,所以实际上我们可能不需要直接这样做
// 然而,如果你只是想要分割后的文本块(不包括'['和']'),下面这样就可以了
const
result
=
text
.
split
(
regex
);
// if (!this.item.partArr) {
// this.item.partArr = [];
// }
const
resultArr
=
[];
result
.
forEach
((
it
,
i
)
=>
{
const
obj
=
{
text
:
it
,
isUnderline
:
i
%
2
==
1
,
}
resultArr
.
push
(
obj
);
});
return
resultArr
;
}
savePartText
(
part
)
{
console
.
log
(
'
part:
'
,
part
);
part
.
textArr
=
this
.
splitTextIntoObjects
(
part
.
text
);
this
.
save
();
}
...
...
@@ -631,10 +597,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
radioChange
(
e
,
item
,
key
)
{
console
.
log
(
'
e:
'
,
e
);
item
[
key
]
=
e
;
this
.
save
();
}
...
...
@@ -815,11 +779,8 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
isPreviewTemplate
=
false
;
}
addOnePartBtnClick
(
page
)
{
if
(
!
page
.
partArr
)
{
page
.
partArr
=
[];
}
page
.
partArr
.
push
(
addOnePartBtnClick
()
{
this
.
item
.
partArr
.
push
(
{
type
:
"
text
"
}
...
...
@@ -864,32 +825,11 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
this
.
save
();
}
deletePartBtnClick
(
i
,
it
=
null
)
{
if
(
!
it
)
{
it
=
this
.
item
;
}
it
.
partArr
.
splice
(
i
,
1
);
this
.
syncDataPage1
();
deletePartBtnClick
(
i
)
{
this
.
item
.
partArr
.
splice
(
i
,
1
);
this
.
save
();
}
syncDataPage1
()
{
if
(
this
.
item
.
mode
!=
'
single
'
)
{
return
;
}
const
pageDataOne
=
this
.
item
.
pageArr
[
0
];
for
(
let
i
=
1
;
i
<
this
.
item
.
pageArr
.
length
;
i
++
)
{
const
curPageData
=
this
.
item
.
pageArr
[
i
];
if
(
curPageData
)
{
curPageData
.
partArr
=
JSON
.
parse
(
JSON
.
stringify
(
pageDataOne
.
partArr
));
}
}
}
deletePageBtnClick
(
i
)
{
this
.
item
.
quesArr
.
splice
(
i
,
1
);
this
.
save
();
...
...
@@ -923,8 +863,6 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
// this.item.customTypeGroupArr = this.customTypeGroupArr;
// }
this
.
syncDataPage1
();
(
<
any
>
window
).
courseware
.
setData
(
this
.
item
,
null
,
this
.
saveKey
);
this
.
refresh
();
...
...
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