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.
52 lines
1.4 KiB
52 lines
1.4 KiB
4 years ago
|
import { Component, OnInit, Inject } from '@angular/core';
|
||
|
import {MatTreeFlatDataSource, MatTreeFlattener} from '@angular/material/tree';
|
||
|
import {FlatTreeControl} from '@angular/cdk/tree';
|
||
|
import { HttpClient } from '@angular/common/http';
|
||
|
import {MatDialog, MatDialogRef, MAT_DIALOG_DATA} from '@angular/material/dialog';
|
||
|
import {FormControl} from '@angular/forms';
|
||
|
import { MatSnackBar } from '@angular/material/snack-bar';
|
||
|
import format from 'date-fns/format';
|
||
|
|
||
|
|
||
|
|
||
|
@Component({
|
||
|
selector: 'addmatlibrary',
|
||
|
templateUrl: './addmatlibrary.component.html',
|
||
|
styleUrls: ['./material-bank.component.scss']
|
||
|
})
|
||
|
export class AddMatLibrary {
|
||
|
myControl = new FormControl();
|
||
|
constructor(private http: HttpClient,public dialogRef: MatDialogRef<AddMatLibrary>,@Inject(MAT_DIALOG_DATA) public data) {}
|
||
|
|
||
|
ngOnInit(): void {
|
||
|
if (this.data.length) {
|
||
|
this.order = this.data[this.data.length - 1].order + 1
|
||
|
} else {
|
||
|
this.order =0
|
||
|
}
|
||
|
}
|
||
|
|
||
|
onNoClick(): void {
|
||
|
this.dialogRef.close();
|
||
|
}
|
||
|
|
||
|
order:number; //order
|
||
|
|
||
|
onSubmit(value){
|
||
|
let newdate = new Date();
|
||
|
let time = format(newdate, 'yyyy-MM-dd')
|
||
|
this.http.post("/api/AssetLibraries",{
|
||
|
id: "",
|
||
|
name: value.name,
|
||
|
order: this.order,
|
||
|
tag: value.tag,
|
||
|
enabled: true,
|
||
|
modifiedTime: time
|
||
|
}).subscribe(data=>{
|
||
|
this.dialogRef.close();
|
||
|
})
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|