上海预案管理平台
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.
 
 
 
 
 

51 lines
1.9 KiB

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: 'editmatlibrary',
templateUrl: './editmatlibrary.component.html',
styleUrls: ['./material-bank.component.scss']
})
export class EditMatLibrary {
myControl = new FormControl();
constructor(private http: HttpClient,public dialogRef: MatDialogRef<EditMatLibrary>,@Inject(MAT_DIALOG_DATA) public data) {}
name:any
input:any
ngOnInit(): void {
this.name = this.data.material.name
this.input = this.data.material.tag
}
onNoClick(): void {
this.dialogRef.close();
}
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.put(`/api/AssetLibraries/${this.data.material.id}`,{
id: this.data.material.id,
name: value.name,
order: this.data.material.order,
tag: value.tag,
enabled: true,
modifiedTime: time
}).subscribe(data=>{
this.dialogRef.close();
})
}
}