You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
93 lines
3.6 KiB
93 lines
3.6 KiB
4 years ago
|
import { Component, OnInit, Inject } from '@angular/core';
|
||
|
import { HttpClient, HttpHeaders } from '@angular/common/http';
|
||
|
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog';
|
||
|
import { MatSnackBar, MatSnackBarConfig } from '@angular/material/snack-bar';
|
||
|
import {CanvasShareDataService,DisposalNodeData} from '../../canvas-share-data.service' //引入服务
|
||
|
import { FlatTreeControl } from '@angular/cdk/tree';
|
||
|
import { MatTreeFlatDataSource, MatTreeFlattener } from '@angular/material/tree';
|
||
|
|
||
|
@Component({
|
||
|
selector: 'dialog-examination-questions',
|
||
|
templateUrl: './examinationQuestions.html',
|
||
|
styleUrls: ['./collection-tools.component.scss',]
|
||
|
})
|
||
|
export class examinationQuestions {
|
||
|
|
||
|
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>,
|
||
|
@Inject(MAT_DIALOG_DATA) public data) {}
|
||
|
// tree配置
|
||
|
private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数
|
||
|
return {
|
||
|
expandable: !!node.children && node.children.length > 0,
|
||
|
name: node.name || node.Name,
|
||
|
level: level,
|
||
|
id: node.id || node.Id,
|
||
|
children:node.children,
|
||
|
isTemplate:node.isTemplate,
|
||
|
isNewElement:node.isNewElement,
|
||
|
isLook:node.isLook,
|
||
|
isLookPattern:node.isLookPattern || null
|
||
|
};
|
||
|
}
|
||
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable);
|
||
|
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children);
|
||
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
||
|
hasChild = (_: number, node: any) => node.expandable;
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
this.dataSource.data = this.data.treeData
|
||
|
this.treeControl.expandAll()
|
||
|
}
|
||
|
|
||
|
}
|
||
|
|
||
|
@Component({
|
||
|
selector: 'dialog-upload-questions',
|
||
|
templateUrl: './uploadQuestions.html',
|
||
|
styleUrls: ['./collection-tools.component.scss',]
|
||
|
})
|
||
|
export class uploadQuestions {
|
||
|
|
||
|
constructor(private http:HttpClient, public dialog: MatDialog, public snackBar: MatSnackBar, public dialogRef: MatDialogRef<any>,
|
||
|
@Inject(MAT_DIALOG_DATA) public data) {}
|
||
|
// tree配置
|
||
|
private _transformer = (node, level: number) => {//要给渲染节点传那些属性参数
|
||
|
return {
|
||
|
expandable: !!node.children && node.children.length > 0,
|
||
|
name: node.name || node.Name,
|
||
|
level: level,
|
||
|
id: node.id || node.Id,
|
||
|
children:node.children,
|
||
|
isTemplate:node.isTemplate,
|
||
|
isNewElement:node.isNewElement,
|
||
|
isLook:node.isLook,
|
||
|
isLookPattern:node.isLookPattern || null
|
||
|
};
|
||
|
}
|
||
|
treeControl = new FlatTreeControl<any>(node => node.level, node => node.expandable);
|
||
|
treeFlattener = new MatTreeFlattener(this._transformer, node => node.level, node => node.expandable, node => node.children);
|
||
|
dataSource = new MatTreeFlatDataSource(this.treeControl, this.treeFlattener);
|
||
|
hasChild = (_: number, node: any) => node.expandable;
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
this.dataSource.data = this.data.treeData
|
||
|
this.treeControl.expandAll()
|
||
|
}
|
||
|
|
||
|
//上传
|
||
|
submit () {
|
||
|
if (this.data.question.grade && this.data.question.keynote) {
|
||
|
const config = new MatSnackBarConfig();
|
||
|
config.verticalPosition = 'top';
|
||
|
config.duration = 3000
|
||
|
this.snackBar.open('上传成功','确定',config);
|
||
|
this.dialogRef.close()
|
||
|
} else {
|
||
|
const config = new MatSnackBarConfig();
|
||
|
config.verticalPosition = 'top';
|
||
|
config.duration = 3000
|
||
|
this.snackBar.open('请填写必填项','确定',config);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
}
|