Skip to content

Commit

Permalink
图片组件弹窗attach(待验证)
Browse files Browse the repository at this point in the history
  • Loading branch information
EnTrouble committed Jun 21, 2023
1 parent 2e5f8c8 commit b748c23
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 15 deletions.
2 changes: 2 additions & 0 deletions src/app/base/attach-select/attach-select.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<iframe src="/app/attachment/list"
frameborder="0"></iframe>
Empty file.
10 changes: 10 additions & 0 deletions src/app/base/attach-select/attach-select.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Component } from '@angular/core';

@Component({
selector: 'app-attach-select',
templateUrl: './attach-select.component.html',
styleUrls: ['./attach-select.component.scss']
})
export class AttachSelectComponent {

}
3 changes: 3 additions & 0 deletions src/app/base/base.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,21 @@ import {NzInputModule} from "ng-zorro-antd/input";
import {NzButtonModule} from "ng-zorro-antd/button";
import {ColorInputComponent} from './color-input/color-input.component';
import { HtmlPipe } from './html.pipe';
import { AttachSelectComponent } from './attach-select/attach-select.component';

@NgModule({
declarations: [
EditTableComponent,
ColorInputComponent,
HtmlPipe,
AttachSelectComponent,

],
exports: [
EditTableComponent,
ColorInputComponent,
HtmlPipe,
AttachSelectComponent
],
providers: [HtmlPipe],
imports: [
Expand Down
20 changes: 20 additions & 0 deletions src/app/editor/property-input/property-input.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,26 @@
<!-- <input nz-input nzSize="small" *ngSwitchCase="'boolean'" type="checkbox"-->
<!-- [value]="cell.getPropByPath(property.path)"-->
<!-- (change)="inputChange($event)">-->
<nz-input-group [nzSuffix]="suffixIconSearch"
nzSize="small"
*ngSwitchCase="'image'"
style="padding-right: 0;">
<input type="text"
nz-input
placeholder=""
[value]="cell.getPropByPath(property.path) || ''"
(change)="inputChange($event)" />
</nz-input-group>
<ng-template #suffixIconSearch>
<button nz-button
nzSize="small"
nzType="primary"
nzSearch>
<span nz-icon
nzType="search"
(click)="handleSelectImage()"></span>
</button>
</ng-template>
<input nz-input
nzSize="small"
*ngSwitchCase="'color'"
Expand Down
31 changes: 27 additions & 4 deletions src/app/editor/property-input/property-input.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import {Component, Input} from '@angular/core';
import {Cell} from "@antv/x6";
import {HmiProperty} from 'src/hmi/hmi';

import { Component, Input } from '@angular/core';
import { Cell } from "@antv/x6";
import { HmiProperty } from 'src/hmi/hmi';
import { AttachSelectComponent } from 'src/app/base/attach-select/attach-select.component';
import { NzModalService } from 'ng-zorro-antd/modal';
import { NzMessageService } from 'ng-zorro-antd/message';
@Component({
selector: 'app-property-input',
templateUrl: './property-input.component.html',
Expand All @@ -11,6 +13,18 @@ export class PropertyInputComponent {
@Input() property!: HmiProperty;
@Input() cell!: Cell

constructor(
private ms: NzModalService,
private msg: NzMessageService,
) {
const that = this;
window.onload = () => {
window.top!.onmessage = function ({ data }) { // 监听 message 事件
that.msg.success('选择成功!');
that.cell.setPropByPath('attrs/image/xlink:href', data);
};
}
}
inputChange($event: any) {
//console.log("property input change", this.property.path, $event);
this.cell.setPropByPath(this.property.path, $event.target.value);
Expand Down Expand Up @@ -51,4 +65,13 @@ export class PropertyInputComponent {
clearColor() {
this.cell.setPropByPath(this.property.path, 'none')
}

handleSelectImage() {
this.ms.create({
nzTitle: `选择图片`,
nzContent: AttachSelectComponent,
nzComponentParams: {},
nzFooter: null
})
}
}
2 changes: 1 addition & 1 deletion src/hmi/base/image.embed.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// !!! Generated by svg2ts.mjs
// From src\hmi\base\image.svg
// From .\src\hmi\base/image.svg
export const ImageSvg = `<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1681075199984" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="11565" xmlns:xlink="http://www.w3.org/1999/xlink" width="200" height="200"><path d="M896 626.592a16 16 0 0 0-7.68-13.664l-172.448-105.088a16 16 0 0 0-20.704 3.52l-76 92.608-1.024 1.152a16 16 0 0 1-22.624 0.032l-252.832-252.064a16.032 16.032 0 0 0-22.08-0.512l-187.36 170.656a15.936 15.936 0 0 0-5.248 11.84V800h768v-173.408z" p-id="11566"></path><path d="M800 320m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z" p-id="11567"></path><path d="M32 128v768h960V128H32z m896 704H96V192h832v640z" p-id="11568"></path></svg>`
5 changes: 3 additions & 2 deletions src/hmi/base/image.meta.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
//!!! Generated by svg2meta.mjs
// From src\hmi\base\image.svg
// From .\src\hmi\base/image.svg
export const ImageMeta = {
"width": 200,
"height": 200,
Expand Down Expand Up @@ -34,5 +34,6 @@ export const ImageMeta = {
"path3": {
"refD": "M32 128v768h960V128H32z m896 704H96V192h832v640z"
}
}
},
"path": "M896 626.592a16 16 0 0 0-7.68-13.664l-172.448-105.088a16 16 0 0 0-20.704 3.52l-76 92.608-1.024 1.152a16 16 0 0 1-22.624 0.032l-252.832-252.064a16.032 16.032 0 0 0-22.08-0.512l-187.36 170.656a15.936 15.936 0 0 0-5.248 11.84V800h768v-173.408z,M800 320m-64 0a64 64 0 1 0 128 0 64 64 0 1 0-128 0Z,M32 128v768h960V128H32z m896 704H96V192h832v640z,"
}
13 changes: 8 additions & 5 deletions src/hmi/base/image.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
import {HmiComponent} from "../hmi";
import {ImageSvg} from "./image.embed";
import { HmiComponent } from "../hmi";
import { ImageSvg } from "./image.embed";

export const BaseImage: HmiComponent = {
name: '图片',
id: 'image',
svg: ImageSvg,
type: "shape", internal:true,
type: "shape", internal: true,
extends: {
inherit: 'image'
},
meta: {
width: 100, height: 80,
imageUrl: '/app/scada/assets/image.svg',
imageUrl: "./image.svg",
},
properties: [
{name: "图片", path: "attrs/image/xlink:href", type: "text"},
{ name: "图片", path: "attrs/image/xlink:href", type: "image" },
]
}
2 changes: 1 addition & 1 deletion src/hmi/creator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function createImageComponent(cmp: HmiImageComponent): HmiComponent {
icon: cmp.url,
type: "shape",
extends: { inherit: "image" },
meta: { width: 100, height: 80, imageUrl: cmp.url },
meta: { width: 100, height: 80 },
collection: cmp.collection
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/hmi/hmi.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Cell, Edge, Node} from "@antv/x6";
import { Cell, Edge, Node } from "@antv/x6";

export declare interface HmiComponent {

Expand Down Expand Up @@ -79,7 +79,7 @@ export declare interface HmiProperty {
name: string
path: string
type: "number" | "text" | "color" | "select" |
"boolean" | "font" | "font-size" | "font-style" | "stroke"
"boolean" | "font" | "font-size" | "font-style" | "stroke" | "image"
default?: any
options?: HmiPropertyOption[]
max?: number
Expand Down

0 comments on commit b748c23

Please sign in to comment.