Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
J
JM_4-1
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
JM_4-1
Commits
4340345d
Commit
4340345d
authored
Jul 23, 2021
by
limingzhe
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: 子模版隐藏
parent
6cd8b41d
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
92 additions
and
21 deletions
+92
-21
sub-template.component.html
src/app/common/sub-template/sub-template.component.html
+1
-1
sub-template.component.ts
src/app/common/sub-template/sub-template.component.ts
+83
-16
upload-image-with-preview.component.ts
...image-with-preview/upload-image-with-preview.component.ts
+5
-1
form.component.html
src/app/form/form.component.html
+2
-2
form.component.ts
src/app/form/form.component.ts
+1
-1
No files found.
src/app/common/sub-template/sub-template.component.html
View file @
4340345d
...
...
@@ -18,7 +18,7 @@
</div>
<iframe
#
iframe
id=
"iframe"
[
src
]="
safeUrl
"
style=
"width: 95vw
; height: 70vh; border: 1px solid #ccc; padding: 5px;"
frameborder=
"0"
>
<iframe
*
ngIf=
"isShowFrame"
#
iframe
id=
"iframe"
[
src
]="
safeUrl
"
style=
"width: 98%
; height: 70vh; border: 1px solid #ccc; padding: 5px;"
frameborder=
"0"
>
</iframe>
...
...
src/app/common/sub-template/sub-template.component.ts
View file @
4340345d
...
...
@@ -29,6 +29,7 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
if
(
this
.
uploadUrl
)
{
this
.
_item
=
v
;
console
.
log
(
'
__ refreshSafeUrl 3
'
)
this
.
refreshSafeUrl
();
}
this
.
_data
=
v
;
...
...
@@ -41,6 +42,9 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
_item
;
_data
;
isShowFrame
=
true
;
@
Input
()
key
=
''
;
...
...
@@ -52,10 +56,17 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
constructor
(
private
el
:
ElementRef
,
private
appRef
:
ApplicationRef
,
private
nzMessageService
:
NzMessageService
,
private
sanitizer
:
DomSanitizer
)
{
console
.
log
(
'
in constructor 1111:
'
,
window
[
'
air
'
]);
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
window
[
'
air
'
].
getUploadCallback
=
(
url
,
data
)
=>
{
console
.
log
(
'
in getUploadCallback , url:
'
,
url
)
this
.
uploadUrl
=
url
;
this
.
uploadData
=
data
;
...
...
@@ -64,6 +75,12 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
this
.
setUploadUrl
();
if
(
!
window
[
'
hw_test_count
'
])
{
window
[
'
hw_test_count
'
]
=
0
}
window
[
'
hw_test_count
'
]
+=
1
;
console
.
log
(
'
window_count:
'
,
window
[
'
hw_test_count
'
])
}
...
...
@@ -71,17 +88,30 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
if
(
!
this
.
uploadUrl
)
{
console
.
log
(
'
this.uploadUrl -- 1 :
'
,
this
.
uploadUrl
)
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
console
.
log
(
'
this.uploadUrl -- 2 :
'
,
this
.
uploadUrl
)
console
.
log
(
'
(<any> window).courseware:
'
,
(
<
any
>
window
).
courseware
);
console
.
log
(
'
window_count:
'
,
window
[
'
hw_test_count
'
])
// console.log('this.iframe cWindow: ', this.iframe.nativeElement.contentWindow)
setTimeout
(()
=>
{
this
.
setUploadUrl
();
},
500
);
}
else
{
console
.
log
(
'
this.uploadUrl -- 3 :
'
,
this
.
uploadUrl
)
if
(
this
.
_data
)
{
this
.
_item
=
this
.
_data
;
console
.
log
(
'
__ refreshSafeUrl 4
'
)
this
.
refreshSafeUrl
()
}
...
...
@@ -93,7 +123,11 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
if
(
!
formUrl
)
{
formUrl
=
this
.
_item
.
formUrl
||
''
;
}
console
.
log
(
'
in refreshSafeUrl formUrl:
'
,
formUrl
)
this
.
safeUrl
=
this
.
sanitizer
.
bypassSecurityTrustResourceUrl
(
formUrl
);
console
.
log
(
'
in refreshSafeUrl safeUrl:
'
,
this
.
safeUrl
)
}
...
...
@@ -101,16 +135,19 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
isInit
=
false
;
ngOnInit
():
void
{
this
.
initListener
();
console
.
log
(
''
)
console
.
log
(
'
in ngOnInit
'
)
if
(
!
this
.
_item
)
{
this
.
_item
=
{};
}
this
.
refreshSafeUrl
();
console
.
log
(
'
__ refreshSafeUrl 1
'
)
this
.
initListener
();
...
...
@@ -133,6 +170,7 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
deleteSubTemplate
()
{
console
.
log
(
'
in deleteFunc
'
);
this
.
refreshSafeUrl
(
''
);
this
.
deleteFunc
.
emit
({});
}
...
...
@@ -148,10 +186,15 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
this
.
_item
.
formUrl
=
formUrl
;
this
.
_item
.
template
=
template
;
console
.
log
(
'
formUrl:
'
,
formUrl
)
console
.
log
(
'
__ refreshSafeUrl 2
'
)
this
.
refreshSafeUrl
();
this
.
closePanel
();
this
.
sendData
();
console
.
log
(
'
this.safeUrl 2 :
'
,
this
.
safeUrl
)
// const key = this.getQueryVariable(formUrl, 'key');
// console.log("key: ", key);
// console.log("url: ", this._item['safeUrl']);
...
...
@@ -177,19 +220,28 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
initListener
()
{
console
.
log
(
this
.
el
.
nativeElement
);
const
iframeContent
=
this
.
el
.
nativeElement
.
querySelector
(
'
#iframe
'
).
contentWindow
;
window
.
addEventListener
(
'
message
'
,
(
e
)
=>
{
const
msgFunc
=
(
e
)
=>
{
let
msgData
=
e
.
data
;
console
.
log
(
'
!!!e :
'
,
e
);
if
(
!
this
.
iframe
||
!
this
.
iframe
.
nativeElement
||
!
this
.
iframe
.
nativeElement
.
contentWindow
)
{
console
.
log
(
'
this.iframe not exist
'
);
window
.
removeEventListener
(
'
message
'
,
msgFunc
);
return
;
}
let
msgData
=
e
.
data
;
if
(
msgData
.
action
===
"
getData
"
)
{
console
.
log
(
"
getData e:
"
,
e
);
if
(
this
.
iframe
)
{
console
.
log
(
'
ifram exist:
'
,
this
.
iframe
);
}
if
(
!
msgData
.
urlParams
)
{
console
.
log
(
'
!msgData.urlParams:
'
,
msgData
)
return
;
...
...
@@ -202,14 +254,14 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
if
(
!
iframeCont
ent
)
{
if
(
!
this
.
iframe
.
nativeElem
ent
)
{
return
;
}
const
data
=
{
msg
:
'
success
'
,
data
:
JSON
.
stringify
(
this
.
_item
.
data
)};
iframeContent
.
postMessage
(
{
action
:
'
getData
'
,
data
:
JSON
.
stringify
(
data
)
},
'
*
'
);
//
this.iframe.nativeElement.contentWindow.postMessage( { action: 'getData', data: JSON.stringify(data) }, '*');
//
iframeContent.postMessage( { action: 'getData', data: JSON.stringify(data) }, '*');
this
.
iframe
.
nativeElement
.
contentWindow
.
postMessage
(
{
action
:
'
getData
'
,
data
:
JSON
.
stringify
(
data
)
},
'
*
'
);
}
...
...
@@ -228,6 +280,12 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
console
.
log
(
"
setData e:
"
,
e
);
if
(
this
.
iframe
)
{
console
.
log
(
'
ifram exist:
'
,
this
.
iframe
);
}
if
(
typeof
(
msgData
.
data
)
===
"
string
"
)
{
console
.
log
(
'
msgData is string
'
);
msgData
.
data
=
JSON
.
parse
(
msgData
.
data
);
...
...
@@ -242,17 +300,27 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
console
.
log
(
'
in getUpload
'
)
if
(
this
.
iframe
)
{
console
.
log
(
'
ifram exist:
'
,
this
.
iframe
);
}
// const iframeContent = this.el.nativeElement.querySelector('#iframe').contentWindow;
iframeContent
.
postMessage
({
this
.
iframe
.
nativeElement
.
contentWindow
.
postMessage
({
action
:
'
getUpload
'
,
uploadUrl
:
this
.
uploadUrl
,
uploadData
:
this
.
uploadData
},
'
*
'
);
}
}
if
(
this
.
iframe
?.
nativeElement
?.
contentWindow
)
{
this
.
iframe
.
nativeElement
.
contentWindow
.
addEventListener
(
'
message
'
,
msgFunc
);
});
}
}
async
getAllTemplateData
()
{
...
...
@@ -277,7 +345,6 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
]
resolve
(
data
);
return
if
(
data
)
{
console
.
log
(
'
data~~~:
'
,
data
);
resolve
(
JSON
.
parse
(
data
));
...
...
@@ -338,8 +405,8 @@ export class SubTemplateComponent implements OnDestroy, OnChanges {
}
ngOnDestroy
()
{
this
.
isShowFrame
=
false
;
}
}
src/app/common/upload-image-with-preview/upload-image-with-preview.component.ts
View file @
4340345d
...
...
@@ -49,14 +49,18 @@ export class UploadImageWithPreviewComponent implements OnDestroy, OnChanges {
setUploadUrl
()
{
if
(
!
this
.
uploadUrl
)
{
console
.
log
(
'
this.uploadUrl -=- 1 :
'
,
this
.
uploadUrl
)
this
.
uploadUrl
=
(
<
any
>
window
).
courseware
.
uploadUrl
();
this
.
uploadData
=
(
<
any
>
window
).
courseware
.
uploadData
();
console
.
log
(
'
this.uploadUrl -=- 2 :
'
,
this
.
uploadUrl
)
setTimeout
(()
=>
{
this
.
setUploadUrl
();
},
500
);
}
console
.
log
(
'
this.uploadUrl -=- 3 :
'
,
this
.
uploadUrl
)
}
...
...
src/app/form/form.component.html
View file @
4340345d
...
...
@@ -28,7 +28,7 @@
</div>
<div
*
ngIf=
"item.templateArr"
>
<
!-- <
div *ngIf="item.templateArr" >
<div *ngFor="let template of item.templateArr; let i = index" style="margin-bottom: 10px;">
<app-sub-template
...
...
@@ -47,7 +47,7 @@
<button nz-button nzType="primary" (click)="addSubTemplate()" style="border-radius: 0.5rem; border: 1px solid #ddd; margin-top: 15px;">
<i nz-icon nzType="plus" nzTheme="outline"></i>
添加子模板
</button>
</button>
-->
<!--
...
...
src/app/form/form.component.ts
View file @
4340345d
...
...
@@ -98,7 +98,7 @@ export class FormComponent implements OnInit, OnChanges, OnDestroy {
}
onDeleteTemplate
(
e
,
index
)
{
this
.
item
.
templateArr
[
index
]
=
{};
this
.
item
.
templateArr
.
splice
(
index
,
1
);
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