17 changed files with 551 additions and 464 deletions
@ -1,6 +1,6 @@
|
||||
{ |
||||
"/api": { |
||||
"target": "http://39.106.78.171:8890/", |
||||
"target": "http://218.75.214.31:28085/", |
||||
"secure": false, |
||||
"changeOrigin": true |
||||
} |
||||
|
@ -1,41 +1,62 @@
|
||||
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'; |
||||
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: '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 |
||||
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; |
||||
} |
||||
onNoClick(): void { |
||||
|
||||
this.dialogRef.close(); |
||||
} |
||||
onSubmit(value){ |
||||
let newdate = new Date(); |
||||
let time = format(newdate, 'yyyy-MM-dd')
|
||||
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(); |
||||
}) |
||||
} |
||||
} |
||||
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(); |
||||
}); |
||||
} |
||||
} |
||||
|
@ -1,572 +1,596 @@
|
||||
import { Component, OnInit, Inject } from '@angular/core'; |
||||
import { HttpClient } from '@angular/common/http'; |
||||
import { MatDialog, MatDialogRef, MAT_DIALOG_DATA } from '@angular/material/dialog'; |
||||
import { AddMatLibrary } from './addmatlibrary.component' |
||||
import { EditMatLibrary } from './editmatlibrary.component' |
||||
import { AddOriginalCopy } from './addoriginalcopy.component' |
||||
import { MatTableDataSource } from '@angular/material/table'; |
||||
import { EditOriginalCopy } from './editoriginalcopy.component' |
||||
import { SelectOriginalCopy } from './selectoriginalcopy.component' |
||||
import { MatSnackBar,MatSnackBarConfig } from '@angular/material/snack-bar'; |
||||
import format from 'date-fns/format'; |
||||
|
||||
|
||||
|
||||
import { Component, OnInit, Inject } from "@angular/core"; |
||||
import { HttpClient } from "@angular/common/http"; |
||||
import { |
||||
MatDialog, |
||||
MatDialogRef, |
||||
MAT_DIALOG_DATA, |
||||
} from "@angular/material/dialog"; |
||||
import { AddMatLibrary } from "./addmatlibrary.component"; |
||||
import { EditMatLibrary } from "./editmatlibrary.component"; |
||||
import { AddOriginalCopy } from "./addoriginalcopy.component"; |
||||
import { MatTableDataSource } from "@angular/material/table"; |
||||
import { EditOriginalCopy } from "./editoriginalcopy.component"; |
||||
import { SelectOriginalCopy } from "./selectoriginalcopy.component"; |
||||
import { MatSnackBar, MatSnackBarConfig } from "@angular/material/snack-bar"; |
||||
@Component({ |
||||
selector: 'app-material-bank', |
||||
templateUrl: './material-bank.component.html', |
||||
styleUrls: ['./material-bank.component.scss'] |
||||
selector: "app-material-bank", |
||||
templateUrl: "./material-bank.component.html", |
||||
styleUrls: ["./material-bank.component.scss"], |
||||
}) |
||||
export class MaterialBankComponent implements OnInit { |
||||
|
||||
constructor(private http:HttpClient,public dialog: MatDialog,public snackBar: MatSnackBar) { } |
||||
constructor( |
||||
private http: HttpClient, |
||||
public dialog: MatDialog, |
||||
public snackBar: MatSnackBar |
||||
) {} |
||||
|
||||
ngOnInit(): void { |
||||
this.http.get('/api/AssetLibraries').subscribe(data=>{ |
||||
this.material = data[0] |
||||
this.allMaterialBank = data |
||||
this.getSourceMaterial() |
||||
}) |
||||
this.http.get("/api/AssetLibraries").subscribe((data) => { |
||||
this.material = data[0]; |
||||
this.allMaterialBank = data; |
||||
this.getSourceMaterial(); |
||||
}); |
||||
} |
||||
|
||||
allMaterialBank:any = []; //所有素材库
|
||||
material:any={name:''}; //选中的素材库
|
||||
materialIndex:any=0; //选中的素材库index
|
||||
allMaterialBank: any = []; //所有素材库
|
||||
material: any = { name: "" }; //选中的素材库
|
||||
materialIndex: any = 0; //选中的素材库index
|
||||
|
||||
sourceMaterial:any; //素材库对应所有原件
|
||||
Original:any; //选中的原件
|
||||
OriginalIndex:any=null; //选中的原件index
|
||||
isshow = true//左侧列表的显示隐藏
|
||||
sourceMaterial: any; //素材库对应所有原件
|
||||
Original: any; //选中的原件
|
||||
OriginalIndex: any = null; //选中的原件index
|
||||
isshow = true; //左侧列表的显示隐藏
|
||||
|
||||
//收起左侧列表
|
||||
showlist(){ |
||||
this.isshow = !this.isshow |
||||
//收起左侧列表
|
||||
showlist() { |
||||
this.isshow = !this.isshow; |
||||
} |
||||
//获取所有素材库
|
||||
getMaterialBank () { |
||||
this.http.get('/api/AssetLibraries').subscribe(data=>{ |
||||
this.allMaterialBank = data |
||||
this.material = data[this.materialIndex] |
||||
}) |
||||
getMaterialBank() { |
||||
this.http.get("/api/AssetLibraries").subscribe((data) => { |
||||
this.allMaterialBank = data; |
||||
this.material = data[this.materialIndex]; |
||||
}); |
||||
} |
||||
|
||||
//获得指定素材库所有原件
|
||||
getSourceMaterial () { |
||||
this.sourceMaterial = null |
||||
getSourceMaterial() { |
||||
this.sourceMaterial = null; |
||||
if (this.material) { |
||||
let data = { |
||||
libraryId:this.material.id |
||||
} |
||||
this.http.get('/api/Assets',{ |
||||
params:data |
||||
}).subscribe(data=>{ |
||||
this.sourceMaterial = data |
||||
this.Original = data[this.OriginalIndex] |
||||
}) |
||||
libraryId: this.material.id, |
||||
}; |
||||
this.http |
||||
.get("/api/Assets", { |
||||
params: data, |
||||
}) |
||||
.subscribe((data) => { |
||||
this.sourceMaterial = data; |
||||
this.Original = data[this.OriginalIndex]; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
//选中素材库
|
||||
add (e,index) { |
||||
this.Original = null |
||||
this.OriginalIndex = null |
||||
add(e, index) { |
||||
this.Original = null; |
||||
this.OriginalIndex = null; |
||||
if (this.materialIndex != index) { |
||||
this.material = e |
||||
this.materialIndex = index |
||||
this.getSourceMaterial() |
||||
this.material = e; |
||||
this.materialIndex = index; |
||||
this.getSourceMaterial(); |
||||
} |
||||
} |
||||
|
||||
//选中原件
|
||||
addOriginal (e,index) { |
||||
this.Original = e |
||||
this.OriginalIndex = index |
||||
addOriginal(e, index) { |
||||
this.Original = e; |
||||
this.OriginalIndex = index; |
||||
} |
||||
|
||||
//打开查看属性弹窗
|
||||
viewProperties () { |
||||
if(this.Original){ |
||||
let data = this.Original |
||||
const dialogRef = this.dialog.open(attributeComponent, |
||||
{width: '1000px',data}); |
||||
dialogRef.afterClosed().subscribe( |
||||
(data)=>{if(data){this.getSourceMaterial()}} |
||||
) |
||||
}else { |
||||
viewProperties() { |
||||
if (this.Original) { |
||||
let data = this.Original; |
||||
const dialogRef = this.dialog.open(attributeComponent, { |
||||
width: "1000px", |
||||
data, |
||||
}); |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.getSourceMaterial(); |
||||
} |
||||
}); |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择原件','确定',config); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("请选择原件", "确定", config); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
|
||||
//新增素材库
|
||||
addmatlibrary(){ |
||||
let data = this.allMaterialBank || [] |
||||
const dialogRef = this.dialog.open(AddMatLibrary, {//调用open方法打开对话框并且携带参数过去
|
||||
width: '260px', |
||||
data |
||||
addmatlibrary() { |
||||
let data = this.allMaterialBank || []; |
||||
const dialogRef = this.dialog.open(AddMatLibrary, { |
||||
//调用open方法打开对话框并且携带参数过去
|
||||
width: "260px", |
||||
data, |
||||
}); |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
this.getMaterialBank(); |
||||
}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
this.getMaterialBank () |
||||
} |
||||
); |
||||
} |
||||
|
||||
//编辑素材库
|
||||
editmatlibrary(){ |
||||
const dialogRef = this.dialog.open(EditMatLibrary, {//调用open方法打开对话框并且携带参数过去
|
||||
width: '260px', |
||||
data: {allMaterialBank:this.allMaterialBank,material:this.material} |
||||
editmatlibrary() { |
||||
const dialogRef = this.dialog.open(EditMatLibrary, { |
||||
//调用open方法打开对话框并且携带参数过去
|
||||
width: "260px", |
||||
data: { allMaterialBank: this.allMaterialBank, material: this.material }, |
||||
}); |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
this.getMaterialBank(); |
||||
}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
this.getMaterialBank () |
||||
} |
||||
); |
||||
} |
||||
|
||||
//删除素材库
|
||||
delete(){ |
||||
var isdeleted = confirm(`确定要删除${this.material.name}素材库吗?`) |
||||
if(isdeleted){ |
||||
delete() { |
||||
var isdeleted = confirm(`确定要删除${this.material.name}素材库吗?`); |
||||
if (isdeleted) { |
||||
//请求删除接口
|
||||
this.http.delete(`/api/AssetLibraries/${this.material.id}`).subscribe( data=>{
|
||||
this.materialIndex -= 1//删除之后焦点前移
|
||||
this.getMaterialBank () |
||||
}) |
||||
this.http |
||||
.delete(`/api/AssetLibraries/${this.material.id}`) |
||||
.subscribe((data) => { |
||||
this.materialIndex -= 1; //删除之后焦点前移
|
||||
this.getMaterialBank(); |
||||
}); |
||||
} |
||||
} |
||||
|
||||
//禁启用素材库
|
||||
disabled(){ |
||||
disabled() { |
||||
let newdate = new Date(); |
||||
let time = format(newdate, 'yyyy-MM-dd')
|
||||
if(this.material.enabled){ |
||||
this.http.put(`/api/AssetLibraries/${this.material.id}`,{ |
||||
id: this.material.id, |
||||
name: this.material.name, |
||||
order: this.material.order, |
||||
tag: this.material.tag, |
||||
enabled: false, |
||||
modifiedTime: time |
||||
}).subscribe(data=>{ |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('禁用成功','确定',config); |
||||
this.getMaterialBank () |
||||
}) |
||||
}else{ |
||||
this.http.put(`/api/AssetLibraries/${this.material.id}`,{ |
||||
id: this.material.id, |
||||
name: this.material.name, |
||||
order: this.material.order, |
||||
tag: this.material.tag, |
||||
enabled: true, |
||||
modifiedTime: time |
||||
}).subscribe(data=>{ |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('启用成功','确定',config); |
||||
this.getMaterialBank () |
||||
}) |
||||
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); |
||||
if (this.material.enabled) { |
||||
this.http |
||||
.put(`/api/AssetLibraries/${this.material.id}`, { |
||||
id: this.material.id, |
||||
name: this.material.name, |
||||
order: this.material.order, |
||||
tag: this.material.tag, |
||||
enabled: false, |
||||
modifiedTime: time, |
||||
}) |
||||
.subscribe((data) => { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("禁用成功", "确定", config); |
||||
this.getMaterialBank(); |
||||
}); |
||||
} else { |
||||
this.http |
||||
.put(`/api/AssetLibraries/${this.material.id}`, { |
||||
id: this.material.id, |
||||
name: this.material.name, |
||||
order: this.material.order, |
||||
tag: this.material.tag, |
||||
enabled: true, |
||||
modifiedTime: time, |
||||
}) |
||||
.subscribe((data) => { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("启用成功", "确定", config); |
||||
this.getMaterialBank(); |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
//新增素材原件
|
||||
addoriginalcopy(node){ |
||||
const dialogRef = this.dialog.open(AddOriginalCopy, {//调用open方法打开对话框并且携带参数过去
|
||||
addoriginalcopy(node) { |
||||
const dialogRef = this.dialog.open(AddOriginalCopy, { |
||||
//调用open方法打开对话框并且携带参数过去
|
||||
// height:"715px",
|
||||
width:"640px", |
||||
data: {allMaterialBank:this.allMaterialBank,node:node,sourceMaterial:this.sourceMaterial} |
||||
width: "640px", |
||||
data: { |
||||
allMaterialBank: this.allMaterialBank, |
||||
node: node, |
||||
sourceMaterial: this.sourceMaterial, |
||||
}, |
||||
}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
if(data){ |
||||
this.getSourceMaterial () |
||||
} |
||||
|
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.getSourceMaterial(); |
||||
} |
||||
); |
||||
}); |
||||
} |
||||
//修改素材原件
|
||||
editoriginalcopy(node){ |
||||
if(this.Original){ |
||||
const dialogRef = this.dialog.open(EditOriginalCopy, {//调用open方法打开对话框并且携带参数过去
|
||||
editoriginalcopy(node) { |
||||
if (this.Original) { |
||||
const dialogRef = this.dialog.open(EditOriginalCopy, { |
||||
//调用open方法打开对话框并且携带参数过去
|
||||
// height:"590px",
|
||||
width:"640px", |
||||
data: {allMaterialBank:this.allMaterialBank,node:node,Original:this.Original} |
||||
width: "640px", |
||||
data: { |
||||
allMaterialBank: this.allMaterialBank, |
||||
node: node, |
||||
Original: this.Original, |
||||
}, |
||||
}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
if(data){ |
||||
this.getSourceMaterial () |
||||
} |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.getSourceMaterial(); |
||||
} |
||||
); |
||||
}else{ |
||||
}); |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择原件','确定',config); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("请选择原件", "确定", config); |
||||
} |
||||
|
||||
} |
||||
|
||||
//禁启用原件
|
||||
disableoriginal(material){ |
||||
if(this.Original){ |
||||
this.http.put(`/api/Assets/${this.Original.id}`,{ |
||||
id:this.Original.id, |
||||
name:this.Original.name, |
||||
width: this.Original.width, |
||||
height: this.Original.height, |
||||
angle: this.Original.angle, |
||||
interactiveMode:this.Original.interactiveMode,//交互方式
|
||||
fixedSize: this.Original.fixedSize, |
||||
fillMode: this.Original.fillMode,//填充方式
|
||||
color: this.Original.color, |
||||
imageUrl:this.Original.imageUrl, |
||||
order: this.Original.order, |
||||
enabled: !this.Original.enabled, |
||||
propertyInfos: this.Original.propertyInfos, |
||||
fireElementId:this.Original.fireElementId |
||||
}).subscribe((data)=>{ |
||||
this.getSourceMaterial () |
||||
}) |
||||
}else{ |
||||
disableoriginal(material) { |
||||
if (this.Original) { |
||||
this.http |
||||
.put(`/api/Assets/${this.Original.id}`, { |
||||
id: this.Original.id, |
||||
name: this.Original.name, |
||||
width: this.Original.width, |
||||
height: this.Original.height, |
||||
angle: this.Original.angle, |
||||
interactiveMode: this.Original.interactiveMode, //交互方式
|
||||
fixedSize: this.Original.fixedSize, |
||||
fillMode: this.Original.fillMode, //填充方式
|
||||
color: this.Original.color, |
||||
imageUrl: this.Original.imageUrl, |
||||
order: this.Original.order, |
||||
enabled: !this.Original.enabled, |
||||
propertyInfos: this.Original.propertyInfos, |
||||
fireElementId: this.Original.fireElementId, |
||||
}) |
||||
.subscribe((data) => { |
||||
this.getSourceMaterial(); |
||||
}); |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择原件','确定',config); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("请选择原件", "确定", config); |
||||
} |
||||
} |
||||
|
||||
//删除原件
|
||||
deleteoriginal(material){ |
||||
if(this.Original){ |
||||
var isdeleted = confirm(`确定要删除当前原件吗?`) |
||||
if(isdeleted){ |
||||
deleteoriginal(material) { |
||||
if (this.Original) { |
||||
var isdeleted = confirm(`确定要删除当前原件吗?`); |
||||
if (isdeleted) { |
||||
//请求删除接口
|
||||
this.http.delete(`/api/Assets`,{ |
||||
params:{ |
||||
libraryId:material.id, |
||||
id:this.Original.id |
||||
} |
||||
}).subscribe( data=>{
|
||||
this.getSourceMaterial () |
||||
}) |
||||
this.http |
||||
.delete(`/api/Assets`, { |
||||
params: { |
||||
libraryId: material.id, |
||||
id: this.Original.id, |
||||
}, |
||||
}) |
||||
.subscribe((data) => { |
||||
this.getSourceMaterial(); |
||||
}); |
||||
} |
||||
}else{ |
||||
} else { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('请选择原件','确定',config); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("请选择原件", "确定", config); |
||||
} |
||||
} |
||||
|
||||
//选择原件素材 material为当前素材库的信息
|
||||
selectoriginal(material){ |
||||
const dialogRef = this.dialog.open(SelectOriginalCopy, {//调用open方法打开对话框并且携带参数过去
|
||||
selectoriginal(material) { |
||||
const dialogRef = this.dialog.open(SelectOriginalCopy, { |
||||
//调用open方法打开对话框并且携带参数过去
|
||||
// height:"525px",
|
||||
data: {allMaterialBank:this.allMaterialBank,material:material} |
||||
data: { allMaterialBank: this.allMaterialBank, material: material }, |
||||
}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
if(data){ |
||||
this.getSourceMaterial () |
||||
} |
||||
|
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.getSourceMaterial(); |
||||
} |
||||
); |
||||
}); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
//原件对应所有属性弹窗
|
||||
@Component({ |
||||
selector: 'app-attribute', |
||||
templateUrl: './attribute.html', |
||||
styleUrls: ['./material-bank.component.scss'] |
||||
selector: "app-attribute", |
||||
templateUrl: "./attribute.html", |
||||
styleUrls: ["./material-bank.component.scss"], |
||||
}) |
||||
export class attributeComponent { |
||||
|
||||
constructor(private http:HttpClient,public dialog: MatDialog, |
||||
public dialogRef: MatDialogRef<attributeComponent >, |
||||
@Inject(MAT_DIALOG_DATA) public data,public snackBar: MatSnackBar) { } |
||||
constructor( |
||||
private http: HttpClient, |
||||
public dialog: MatDialog, |
||||
public dialogRef: MatDialogRef<attributeComponent>, |
||||
@Inject(MAT_DIALOG_DATA) public data, |
||||
public snackBar: MatSnackBar |
||||
) {} |
||||
|
||||
ngOnInit(): void { |
||||
if (this.data.propertyInfos == null) { |
||||
this.data.propertyInfos = [] |
||||
this.data.propertyInfos = []; |
||||
} |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos) |
||||
} |
||||
|
||||
displayedColumns = ['checked', 'name', 'type', 'default','required','physicalUnit','operation']; |
||||
dataSource:any=[]; //当前原件属性渲染table
|
||||
dataSourceIndex:any=[]; //选中属性的index
|
||||
|
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
|
||||
displayedColumns = [ |
||||
"checked", |
||||
"name", |
||||
"type", |
||||
"default", |
||||
"required", |
||||
"physicalUnit", |
||||
"operation", |
||||
]; |
||||
dataSource: any = []; //当前原件属性渲染table
|
||||
dataSourceIndex: any = []; //选中属性的index
|
||||
|
||||
//封装函数每次更改,重新获取下标
|
||||
setIndex () { |
||||
setIndex() { |
||||
if (this.data.propertyInfos) { |
||||
this.data.propertyInfos.forEach((item,index)=>{ |
||||
item.index = index |
||||
}) |
||||
this.data.propertyInfos.forEach((item, index) => { |
||||
item.index = index; |
||||
}); |
||||
} |
||||
} |
||||
|
||||
//点击checked框获取当前属性index
|
||||
checkedChange (e,index) { |
||||
checkedChange(e, index) { |
||||
if (e.checked) { |
||||
this.dataSourceIndex.push(index) |
||||
this.dataSourceIndex.push(index); |
||||
} else { |
||||
this.dataSourceIndex.splice(this.dataSourceIndex.findIndex(item=>item==index),1) |
||||
this.dataSourceIndex.splice( |
||||
this.dataSourceIndex.findIndex((item) => item == index), |
||||
1 |
||||
); |
||||
} |
||||
} |
||||
|
||||
|
||||
//上移
|
||||
toTop () { |
||||
if(this.dataSourceIndex.length) { |
||||
let index = this.dataSourceIndex[this.dataSourceIndex.length-1] |
||||
toTop() { |
||||
if (this.dataSourceIndex.length) { |
||||
let index = this.dataSourceIndex[this.dataSourceIndex.length - 1]; |
||||
if (index != 0) { |
||||
let data = this.data.propertyInfos[index] |
||||
this.data.propertyInfos[index]=this.data.propertyInfos[index-1] |
||||
this.data.propertyInfos[index-1] = data |
||||
this.dataSourceIndex[this.dataSourceIndex.length-1] = index-1 |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos) |
||||
let data = this.data.propertyInfos[index]; |
||||
this.data.propertyInfos[index] = this.data.propertyInfos[index - 1]; |
||||
this.data.propertyInfos[index - 1] = data; |
||||
this.dataSourceIndex[this.dataSourceIndex.length - 1] = index - 1; |
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
} |
||||
} |
||||
|
||||
//下移
|
||||
toBottom () { |
||||
if(this.dataSourceIndex.length) { |
||||
let index = this.dataSourceIndex[this.dataSourceIndex.length-1] |
||||
if (index != this.data.propertyInfos.length-1) { |
||||
let data = this.data.propertyInfos[index] |
||||
this.data.propertyInfos[index]=this.data.propertyInfos[index+1] |
||||
this.data.propertyInfos[index+1] = data |
||||
this.dataSourceIndex[this.dataSourceIndex.length-1] = index+1 |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos) |
||||
toBottom() { |
||||
if (this.dataSourceIndex.length) { |
||||
let index = this.dataSourceIndex[this.dataSourceIndex.length - 1]; |
||||
if (index != this.data.propertyInfos.length - 1) { |
||||
let data = this.data.propertyInfos[index]; |
||||
this.data.propertyInfos[index] = this.data.propertyInfos[index + 1]; |
||||
this.data.propertyInfos[index + 1] = data; |
||||
this.dataSourceIndex[this.dataSourceIndex.length - 1] = index + 1; |
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
//新增属性弹窗
|
||||
add () { |
||||
add() { |
||||
const dialogRef = this.dialog.open(addAttributeComponent); |
||||
dialogRef.afterClosed().subscribe( |
||||
(data)=>{ |
||||
if (data) { |
||||
this.data.propertyInfos.push(data) |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos)} |
||||
}) |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.data.propertyInfos.push(data); |
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
//编辑属性弹窗
|
||||
edit (e) { |
||||
|
||||
let data = this.data.propertyInfos[e] |
||||
const dialogRef = this.dialog.open(editAttribute,{data}); |
||||
dialogRef.afterClosed().subscribe( |
||||
data=>{ |
||||
if (data) { |
||||
this.data.propertyInfos[data.index] = data |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos)} |
||||
}) |
||||
edit(e) { |
||||
let data = this.data.propertyInfos[e]; |
||||
const dialogRef = this.dialog.open(editAttribute, { data }); |
||||
dialogRef.afterClosed().subscribe((data) => { |
||||
if (data) { |
||||
this.data.propertyInfos[data.index] = data; |
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
}); |
||||
} |
||||
|
||||
//显示
|
||||
visible (e) { |
||||
this.data.propertyInfos[e].visible = true |
||||
visible(e) { |
||||
this.data.propertyInfos[e].visible = true; |
||||
} |
||||
//隐藏
|
||||
noVisible (e) { |
||||
this.data.propertyInfos[e].visible = false |
||||
noVisible(e) { |
||||
this.data.propertyInfos[e].visible = false; |
||||
} |
||||
//启用
|
||||
enabled (e) { |
||||
this.data.propertyInfos[e].enabled = true |
||||
enabled(e) { |
||||
this.data.propertyInfos[e].enabled = true; |
||||
} |
||||
//禁用
|
||||
noEnabled (e) { |
||||
this.data.propertyInfos[e].enabled = false |
||||
noEnabled(e) { |
||||
this.data.propertyInfos[e].enabled = false; |
||||
} |
||||
//删除
|
||||
delete (e) { |
||||
let isTrue = confirm('您确定要删除吗') |
||||
delete(e) { |
||||
let isTrue = confirm("您确定要删除吗"); |
||||
if (isTrue) { |
||||
this.data.propertyInfos.splice(e,1) |
||||
this.setIndex() |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos) |
||||
this.data.propertyInfos.splice(e, 1); |
||||
this.setIndex(); |
||||
this.dataSource = new MatTableDataSource<any>(this.data.propertyInfos); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
//原件属性保存
|
||||
preservation () { |
||||
preservation() { |
||||
if (this.data.propertyInfos.length) { |
||||
this.data.propertyInfos.forEach(item => { |
||||
delete item.index |
||||
this.data.propertyInfos.forEach((item) => { |
||||
delete item.index; |
||||
}); |
||||
this.submit() |
||||
this.submit(); |
||||
} else { |
||||
this.submit() |
||||
this.submit(); |
||||
} |
||||
} |
||||
|
||||
//提交保存
|
||||
submit () { |
||||
this.http.put(`/api/Assets/${this.data.id}`,{ |
||||
id:this.data.id, |
||||
name:this.data.name, |
||||
width:this.data.width, |
||||
height:this.data.height, |
||||
angle:this.data.angle, |
||||
interactiveMode:this.data.interactiveMode, |
||||
isFromBuilding: this.data.isFromBuilding, |
||||
canConnect:this.data.canConnect, |
||||
holeMaxCount:this.data.holeMaxCount, |
||||
fixedSize:this.data.fixedSize, |
||||
fillMode:this.data.fillMode, |
||||
color:this.data.color, |
||||
imageUrl:this.data.imageUrl, |
||||
drawMode:this.data.drawMode, |
||||
border:this.data.border, |
||||
order:this.data.order, |
||||
enabled:this.data.enabled, |
||||
propertyInfos:this.data.propertyInfos, |
||||
fireElementId:this.data.fireElementId |
||||
}).subscribe(data=>{ |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = 'top'; |
||||
config.duration = 3000 |
||||
this.snackBar.open('保存成功','确定',config); |
||||
this.dialogRef.close('success') |
||||
}) |
||||
submit() { |
||||
this.http |
||||
.put(`/api/Assets/${this.data.id}`, { |
||||
id: this.data.id, |
||||
name: this.data.name, |
||||
width: this.data.width, |
||||
height: this.data.height, |
||||
angle: this.data.angle, |
||||
interactiveMode: this.data.interactiveMode, |
||||
isFromBuilding: this.data.isFromBuilding, |
||||
canConnect: this.data.canConnect, |
||||
holeMaxCount: this.data.holeMaxCount, |
||||
fixedSize: this.data.fixedSize, |
||||
fillMode: this.data.fillMode, |
||||
color: this.data.color, |
||||
imageUrl: this.data.imageUrl, |
||||
drawMode: this.data.drawMode, |
||||
border: this.data.border, |
||||
order: this.data.order, |
||||
enabled: this.data.enabled, |
||||
propertyInfos: this.data.propertyInfos, |
||||
fireElementId: this.data.fireElementId, |
||||
}) |
||||
.subscribe((data) => { |
||||
const config = new MatSnackBarConfig(); |
||||
config.verticalPosition = "top"; |
||||
config.duration = 3000; |
||||
this.snackBar.open("保存成功", "确定", config); |
||||
this.dialogRef.close("success"); |
||||
}); |
||||
} |
||||
|
||||
} |
||||
|
||||
|
||||
|
||||
//新增属性弹窗
|
||||
export interface Food { |
||||
value: number; |
||||
viewValue: string; |
||||
} |
||||
@Component({ |
||||
selector: 'app-addAttribute', |
||||
templateUrl: './addAttribute.html', |
||||
styleUrls: ['./material-bank.component.scss'] |
||||
selector: "app-addAttribute", |
||||
templateUrl: "./addAttribute.html", |
||||
styleUrls: ["./material-bank.component.scss"], |
||||
}) |
||||
export class addAttributeComponent { |
||||
|
||||
constructor(private http:HttpClient,public dialog: MatDialog, |
||||
public dialogRef: MatDialogRef<addAttributeComponent>,) { } |
||||
constructor( |
||||
private http: HttpClient, |
||||
public dialog: MatDialog, |
||||
public dialogRef: MatDialogRef<addAttributeComponent> |
||||
) {} |
||||
|
||||
ngOnInit(): void {} |
||||
|
||||
//定义属性数据
|
||||
propertyType:Food[]=[ |
||||
{value:0, viewValue: '单行文本'}, |
||||
{value:1, viewValue: '多行文本'}, |
||||
{value:2, viewValue: '数值'}, |
||||
{value:3, viewValue: '图片'}, |
||||
{value:4, viewValue: '图片数量'}, |
||||
{value:5, viewValue: '方向'}, |
||||
{value:6, viewValue: '布尔值'}, |
||||
{value:7, viewValue: '供给区域'}, |
||||
{value:8, viewValue: '供给类型'}] |
||||
propertyType: Food[] = [ |
||||
{ value: 0, viewValue: "单行文本" }, |
||||
{ value: 1, viewValue: "多行文本" }, |
||||
{ value: 2, viewValue: "数值" }, |
||||
{ value: 3, viewValue: "图片" }, |
||||
{ value: 4, viewValue: "图片数量" }, |
||||
{ value: 5, viewValue: "方向" }, |
||||
{ value: 6, viewValue: "布尔值" }, |
||||
{ value: 7, viewValue: "供给区域" }, |
||||
{ value: 8, viewValue: "供给类型" }, |
||||
]; |
||||
|
||||
//提交表单
|
||||
onSubmit (e) { |
||||
e.order = 0 |
||||
e.enabled = true |
||||
e.visible = true |
||||
e.required = e.required=='true'? true: false, |
||||
this.dialogRef.close(e) |
||||
} |
||||
|
||||
onSubmit(e) { |
||||
e.order = 0; |
||||
e.enabled = true; |
||||
e.visible = true; |
||||
(e.required = e.required == "true" ? true : false), this.dialogRef.close(e); |
||||
} |
||||
} |
||||
|
||||
|
||||
|
||||
//编辑属性弹窗
|
||||
@Component({ |
||||
selector: 'app-editAttribute', |
||||
templateUrl: './editAttribute.html', |
||||
styleUrls: ['./material-bank.component.scss'] |
||||
selector: "app-editAttribute", |
||||
templateUrl: "./editAttribute.html", |
||||
styleUrls: ["./material-bank.component.scss"], |
||||
}) |
||||
export class editAttribute { |
||||
|
||||
constructor(private http:HttpClient,public dialog: MatDialog, |
||||
constructor( |
||||
private http: HttpClient, |
||||
public dialog: MatDialog, |
||||
public dialogRef: MatDialogRef<editAttribute>, |
||||
@Inject(MAT_DIALOG_DATA) public data,) { } |
||||
@Inject(MAT_DIALOG_DATA) public data |
||||
) {} |
||||
|
||||
ngOnInit(): void { |
||||
this.propertyName = this.data.propertyName |
||||
this.propertyValue = this.data.propertyValue |
||||
this.propertyType = this.data.propertyType |
||||
this.required = String(this.data.required) |
||||
this.ruleName = this.data.ruleName |
||||
this.ruleValue = this.data.ruleValue |
||||
this.physicalUnit = this.data.physicalUnit |
||||
this.tag = this.data.tag} |
||||
|
||||
|
||||
propertyName:any |
||||
propertyValue:any; |
||||
propertyType:number; |
||||
required:any; |
||||
ruleName:any; |
||||
ruleValue:any; |
||||
physicalUnit:any; |
||||
tag:any; |
||||
this.propertyName = this.data.propertyName; |
||||
this.propertyValue = this.data.propertyValue; |
||||
this.propertyType = this.data.propertyType; |
||||
this.required = String(this.data.required); |
||||
this.ruleName = this.data.ruleName; |
||||
this.ruleValue = this.data.ruleValue; |
||||
this.physicalUnit = this.data.physicalUnit; |
||||
this.tag = this.data.tag; |
||||
} |
||||
|
||||
propertyName: any; |
||||
propertyValue: any; |
||||
propertyType: number; |
||||
required: any; |
||||
ruleName: any; |
||||
ruleValue: any; |
||||
physicalUnit: any; |
||||
tag: any; |
||||
|
||||
//定义属性数据
|
||||
type:Food[]=[ |
||||
{value:0, viewValue: '单行文本'}, |
||||
{value:1, viewValue: '多行文本'}, |
||||
{value:2, viewValue: '数值'}, |
||||
{value:3, viewValue: '图片'}, |
||||
{value:4, viewValue: '图片数量'}, |
||||
{value:5, viewValue: '方向'}, |
||||
{value:6, viewValue: '布尔值'}, |
||||
{value:7, viewValue: '供给区域'}, |
||||
{value:8, viewValue: '供给类型'}] |
||||
type: Food[] = [ |
||||
{ value: 0, viewValue: "单行文本" }, |
||||
{ value: 1, viewValue: "多行文本" }, |
||||
{ value: 2, viewValue: "数值" }, |
||||
{ value: 3, viewValue: "图片" }, |
||||
{ value: 4, viewValue: "图片数量" }, |
||||
{ value: 5, viewValue: "方向" }, |
||||
{ value: 6, viewValue: "布尔值" }, |
||||
{ value: 7, viewValue: "供给区域" }, |
||||
{ value: 8, viewValue: "供给类型" }, |
||||
]; |
||||
|
||||
//提交表单
|
||||
onSubmit (e) { |
||||
e.order = 0 |
||||
e.enabled = this.data.enabled |
||||
e.visible = this.data.visible |
||||
e.index = this.data.index |
||||
e.required = e.required=='true'? true: false, |
||||
this.dialogRef.close(e) |
||||
onSubmit(e) { |
||||
e.order = 0; |
||||
e.enabled = this.data.enabled; |
||||
e.visible = this.data.visible; |
||||
e.index = this.data.index; |
||||
(e.required = e.required == "true" ? true : false), this.dialogRef.close(e); |
||||
} |
||||
|
||||
|
||||
|
||||
} |
||||
} |
||||
|
Loading…
Reference in new issue