|
|
|
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';
|
|
|
|
|
|
|
|
|
|
|
|
@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();
|
|
|
|
function getDate(date){
|
|
|
|
//date是传过来的时间戳,注意需为13位,10位需*1000
|
|
|
|
//也可以不传,获取的就是当前时间
|
|
|
|
var time = new Date(date);
|
|
|
|
var year= time.getFullYear() //年
|
|
|
|
var month = ("0" + (time.getMonth() + 1)).slice(-2); //月
|
|
|
|
var day = ("0" + time.getDate()).slice(-2); //日
|
|
|
|
var mydate = year + "-" + month + "-" + day;
|
|
|
|
return mydate
|
|
|
|
}
|
|
|
|
let time = getDate(newdate)
|
|
|
|
this.http.post("/api/AssetLibraries",{
|
|
|
|
id: "",
|
|
|
|
name: value.name,
|
|
|
|
order: this.order,
|
|
|
|
tag: value.tag,
|
|
|
|
enabled: true,
|
|
|
|
modifiedTime: time
|
|
|
|
}).subscribe(data=>{
|
|
|
|
this.dialogRef.close();
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|