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