Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
D
DG_FAF
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
DG_FAF
Commits
ab64f8b3
Commit
ab64f8b3
authored
Feb 18, 2023
by
李维
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
部分完成表单部分
圈出正确单词部分还有问题
parent
7396c13d
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
281 additions
and
33 deletions
+281
-33
custom-hot-zone.component.scss
...app/common/custom-hot-zone/custom-hot-zone.component.scss
+1
-1
form.component.html
form_angular/src/app/form/form.component.html
+156
-21
form.component.ts
form_angular/src/app/form/form.component.ts
+124
-11
No files found.
form_angular/src/app/common/custom-hot-zone/custom-hot-zone.component.scss
View file @
ab64f8b3
...
...
@@ -13,7 +13,7 @@
margin
:
auto
;
width
:
95%
;
height
:
35
vw
;
height
:
100
vw
;
border
:
2px
dashed
#ddd
;
border-radius
:
0
.5rem
;
...
...
form_angular/src/app/form/form.component.html
View file @
ab64f8b3
This diff is collapsed.
Click to expand it.
form_angular/src/app/form/form.component.ts
View file @
ab64f8b3
...
...
@@ -12,7 +12,7 @@ import {
}
from
'
@angular/core
'
;
import
{
JsonPipe
}
from
'
@angular/common
'
;
import
{
removeItemFromArr
}
from
'
../play/Unit
'
;
import
{
NzMessageService
}
from
'
ng-zorro-antd
'
;
@
Component
({
selector
:
'
app-form
'
,
...
...
@@ -26,10 +26,12 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
// 储存对象
item
;
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
)
{
// 表格编辑缓存
editCache
:
{
[
key
:
string
]:
{
edit
:
boolean
;
data
}
}
=
{};
}
constructor
(
private
appRef
:
ApplicationRef
,
private
changeDetectorRef
:
ChangeDetectorRef
,
private
nzMessageService
:
NzMessageService
)
{
}
ngOnInit
()
{
this
.
item
=
{};
...
...
@@ -44,26 +46,137 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy, AfterViewIni
},
this
.
saveKey
);
}
ngAfterViewInit
()
{
saveHotZone
(
group
,
e
)
{
console
.
log
(
'
e:
'
,
e
);
const
{
bgItem
,
hotZoneItemArr
}
=
e
;
group
.
bgItem
=
bgItem
;
group
.
hotZoneItemArr
=
hotZoneItemArr
;
this
.
save
();
}
// 添加热区配置
addHotZoneConfig
()
{
if
(
!
this
.
item
.
hotZoneConfigArr
)
{
this
.
item
.
hotZoneConfigArr
=
[];
}
this
.
item
.
hotZoneConfigArr
.
push
({
linkHotZoneIndex
:
1
,
contentList
:
[
{
index
:
0
,
text
:
"
item-1
"
}
]
})
this
.
save
()
}
ngOnChanges
()
{
// 添加热区内容配置
addHotZoneConfigItem
(
it
)
{
console
.
log
(
it
.
contentList
)
if
(
!
it
.
contentList
)
{
it
.
contentList
=
[];
}
it
.
contentList
=
[
...
it
.
contentList
,
this
.
getDefaultConfigContentItem
()
];
const
lastIndex
=
it
.
contentList
.
length
-
1
;
const
lastItem
=
it
.
contentList
[
lastIndex
];
this
.
startHotZoneConfigEdit
(
lastIndex
,
lastItem
);
this
.
save
();
}
ngOnDestroy
()
{
// 删除热区内容配置
deleteHotZoneConfigItem
(
it
,
index
)
{
if
(
!
it
.
contentList
)
{
it
.
contentList
=
[];
}
it
.
contentList
.
splice
(
index
,
1
);
it
.
contentList
=
[
...
it
.
contentList
];
this
.
save
();
}
saveHotZone
(
group
,
e
)
{
console
.
log
(
'
e:
'
,
e
);
const
{
bgItem
,
hotZoneItemArr
}
=
e
;
group
.
bgItem
=
bgItem
;
group
.
hotZoneItemArr
=
hotZoneItemArr
;
// 获取默认热区内容配置
getDefaultConfigContentItem
()
{
return
{
text
:
""
,
image_url
:
""
,
hotZoneIndex
:
null
,
score
:
0
}
}
// 开始编辑表格的一行
startHotZoneConfigEdit
(
id
:
number
,
originData
)
{
if
(
!
this
.
editCache
[
id
+
''
])
{
this
.
editCache
[
id
+
''
]
=
{
edit
:
true
,
data
:
{
...
originData
}
};
}
else
{
this
.
editCache
[
id
+
''
].
edit
=
true
;
}
}
// 取消表格一行的编辑
cancelHotZoneConfigEdit
(
id
:
number
,
originData
):
void
{
this
.
editCache
[
id
+
''
]
=
{
data
:
{
...
originData
},
edit
:
false
};
}
// 保存表格内容
saveHotZoneConfigEdit
(
id
:
number
,
it
):
void
{
Object
.
assign
(
it
.
contentList
[
id
],
this
.
editCache
[
id
+
''
].
data
);
this
.
editCache
[
id
+
''
].
edit
=
false
;
this
.
save
();
}
// 添加分数组
addScoreConfig
()
{
if
(
!
this
.
item
.
scoreConfigArr
)
{
this
.
item
.
scoreConfigArr
=
[];
}
this
.
item
.
scoreConfigArr
.
push
({
linkHotZoneIndex
:
1
})
this
.
save
()
}
// 复制数据
copyChangeData
()
{
const
jsonData
=
this
.
item
;
const
oInput
=
document
.
createElement
(
'
input
'
);
oInput
.
value
=
JSON
.
stringify
(
jsonData
);
document
.
body
.
appendChild
(
oInput
);
oInput
.
select
();
// 选择对象
document
.
execCommand
(
'
Copy
'
);
// 执行浏览器复制命令
document
.
body
.
removeChild
(
oInput
);
this
.
nzMessageService
.
success
(
'
复制成功
'
);
}
ngAfterViewInit
()
{
}
ngOnChanges
()
{
}
ngOnDestroy
()
{
}
/**
* 储存图片数据
* @param e
...
...
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