Skip to content

Commit

Permalink
产品管理,属性管理,字段管理
Browse files Browse the repository at this point in the history
  • Loading branch information
wq1234wq committed Oct 14, 2022
1 parent 83c6b38 commit bc2a9d0
Show file tree
Hide file tree
Showing 22 changed files with 1,015 additions and 68 deletions.
3 changes: 3 additions & 0 deletions IoTSharp.Contracts/Enums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ public enum DeviceType
Device = 0,
Gateway = 1
}

[System.Text.Json.Serialization.JsonConverter(typeof(System.Text.Json.Serialization.JsonStringEnumConverter))]
[JsonConverter(typeof(StringEnumConverter))]
public enum GatewayType
{
Unknow=0,
Expand Down
6 changes: 4 additions & 2 deletions IoTSharp/ClientApp/src/app/routes/produce/produce.module.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { NgModule } from '@angular/core';
import { SharedModule } from '@shared';
import { ProduceRoutingModule } from './produce-routing.module';
import { ProducedatadictionaryformComponent } from './producedatadictionaryform/producedatadictionaryform.component';
import { ProducedataformComponent } from './producedataform/producedataform.component';


const COMPONENTS = [

ProducedataformComponent,ProducedatadictionaryformComponent
];

@NgModule({
imports: [ProduceRoutingModule, SharedModule],
providers: [],
declarations: COMPONENTS
})
export class SettingsModule {}
export class ProduceModule {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
<button nz-button [nzType]="'primary'" (click)="newRow()" acl [acl-ability]="102">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | i18n }}</span>
</button>

<button nz-button [nzType]="'primary'" nzDanger="true" (click)="saveRow()" acl [acl-ability]="102">
<i nz-icon nzType="save"></i>
<span>{{ 'button.save' | i18n }}</span>
</button>
<st #st [data]="dictionaryData" [columns]="columns">



<ng-template st-row="keyNameTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.keyName"
(ngModelChange)="st.setRow(index, { keyName: $event })" />
<ng-container *ngIf="!item.edit">{{ item.keyName }}</ng-container>
</ng-template>

<ng-template st-row="displayNameTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.displayName"
(ngModelChange)="st.setRow(index, { displayName: $event })" />
<ng-container *ngIf="!item.edit">{{ item.displayName }}</ng-container>
</ng-template>

<ng-template st-row="unitTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.unit"
(ngModelChange)="st.setRow(index, { unit: $event })" />
<ng-container *ngIf="!item.edit">{{ item.unit }}</ng-container>
</ng-template>

<ng-template st-row="unitExpressionTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.unitExpression"
(ngModelChange)="st.setRow(index, { unitExpression: $event })" />
<ng-container *ngIf="!item.edit">{{ item.unitExpression }}</ng-container>
</ng-template>


<ng-template st-row="unitConvertTpl" let-item let-index="index">
<nz-switch [ngModel]="item.unitConvert" *ngIf="item.edit"
(ngModelChange)="st.setRow(index, { unitConvert: $event })"></nz-switch>
<ng-container *ngIf="!item.edit">{{ item.unitConvert }}</ng-container>
</ng-template>



<ng-template st-row="keyDescTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.keyDesc"
(ngModelChange)="st.setRow(index, { keyDesc: $event })" />
<ng-container *ngIf="!item.edit">{{ item.keyDesc }}</ng-container>
</ng-template>
<ng-template st-row="defaultValueTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.defaultValue"
(ngModelChange)="st.setRow(index, { defaultValue: $event })" />
<ng-container *ngIf="!item.edit">{{ item.defaultValue }}</ng-container>
</ng-template>




<ng-template st-row="displayTpl" let-item let-index="index">
<nz-switch [ngModel]="item.display" *ngIf="item.edit"
(ngModelChange)="st.setRow(index, { display: $event })"></nz-switch>
<ng-container *ngIf="!item.edit">{{ item.display }}</ng-container>
</ng-template>


<ng-template st-row="place0Tpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.place0"
(ngModelChange)="st.setRow(index, { place0: $event })" />
<ng-container *ngIf="!item.edit">{{ item.place0 }}</ng-container>
</ng-template>



<ng-template st-row="tagtpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.tag"
(ngModelChange)="st.setRow(index, { tag: $event })" />
<ng-container *ngIf="!item.edit">{{ item.tag }}</ng-container>
</ng-template>


<ng-template st-row="dataTypeTpl" let-item let-index="index">
<nz-select *ngIf="item.edit" [ngModel]="item.dataType"
(ngModelChange)="st.setRow(index, { dataType: $event })">
<nz-option nzValue="Boolean" nzLabel="Boolean"></nz-option>
<nz-option nzValue="String" nzLabel="String"></nz-option>
<nz-option nzValue="Long" nzLabel="Long"></nz-option>
<nz-option nzValue="Double" nzLabel="Double"></nz-option>
<nz-option nzValue="Json" nzLabel="Json"></nz-option>
<nz-option nzValue="XML" nzLabel="XML"></nz-option>
<nz-option nzValue="Binary" nzLabel="Binary"></nz-option>
<nz-option nzValue="DateTime" nzLabel="DateTime"></nz-option>
</nz-select>

<ng-container *ngIf="!item.edit">{{ item.dataType}}</ng-container>
</ng-template>


</st>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ProducedatadictionaryformComponent } from './producedatadictionaryform.component';

describe('ProducedatadictionaryformComponent', () => {
let component: ProducedatadictionaryformComponent;
let fixture: ComponentFixture<ProducedatadictionaryformComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProducedatadictionaryformComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ProducedatadictionaryformComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
import { Component, Input, OnInit, ViewChild } from '@angular/core';
import { STComponent, STData, STColumn } from '@delon/abc/st';
import { _HttpClient } from '@delon/theme';
import { Guid } from 'guid-typescript';
import { NzMessageService } from 'ng-zorro-antd/message';
import { appmessage } from 'src/app/models/appmessage';

@Component({
selector: 'app-producedatadictionaryform',
templateUrl: './producedatadictionaryform.component.html',
styleUrls: ['./producedatadictionaryform.component.less']
})
export class ProducedatadictionaryformComponent implements OnInit {


@Input() id: string = Guid.EMPTY;
@ViewChild('st') private st!: STComponent;
dictionaryData: STData[] = []

columns: STColumn[] = [
{ title: 'id', index: 'id' },
{ title: '字段名称', index: 'keyName', render: 'keyNameTpl' },
{ title: '字段显示名称', index: 'displayName', render: 'displayNameTpl' },
{ title: '单位', index: 'unit', render: 'unitTpl' },
{ title: '单位转换表达式', index: 'unitExpression', render: 'unitExpressionTpl' },
{ title: 'UnitConvert', index: 'unitConvert', render: 'unitConvertTpl' },
{ title: '字段备注', index: 'keyDesc', render: 'keyDescTpl' },
{ title: '默认值', index: 'defaultValue', render: 'defaultValueTpl' },
{ title: '是否显示', index: 'display', render: 'displayTpl' },
{ title: '位置名称', index: 'place0', render: 'place0Tpl' },
{ title: 'Tag', index: 'tag', render: 'tagtpl' },

{ title: '数据类型', index: 'dataType', render: 'dataTypeTpl' },
{
title: '操作',
buttons: [
{
text: `编辑`,
iif: i => !i.edit,
click: i => this.updateEdit(i, true),
},
{
text: `删除`,
iif: i => !i.edit, pop: {
title: '确认删除属性?',
okType: 'danger',
icon: 'warning',
},
click: i => this.remove(i),
},
{
text: `保存`,
iif: i => i.edit,
click: (i, v) => {
console.log(i)
this.submit(i);
},
},
{
text: `取消`,
iif: i => i.edit,
click: i => this.updateEdit(i, false),
},
],
},
];
constructor(private msg: NzMessageService, private http: _HttpClient,) {



}

ngOnInit(): void {

this.http.get<appmessage<any>>('api/produces/getProduceDictionary?produceId=' + this.id).subscribe(next => {
this.dictionaryData = next.data;
}, error => {

}, () => { });
}

private submit(i: STData): void {
this.updateEdit(i, false)
this.dictionaryData = this.st.list;

}


private remove(i: STData) {
this.st.removeRow(i); this.dictionaryData = this.st.list;
}
private updateEdit(i: STData, edit: boolean): void {

this.st.setRow(i, { edit }, { refreshSchema: true });
}
_id = 0;
newRow() {
this.dictionaryData = [{ edit: true }, ...this.dictionaryData]
}

saveRow() {
this.http.post('api/produces/editProduceDictionary', { produceId: this.id, dictionProduceDictionaryDataaryData: this.dictionaryData }).subscribe(next => { }, error => { }, () => { });
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<button nz-button [nzType]="'primary'" (click)="newRow()" acl [acl-ability]="102">
<i nz-icon nzType="plus"></i>
<span>{{ 'button.new' | i18n }}</span>
</button>

<button nz-button [nzType]="'primary'" nzDanger="true" (click)="saveRow()" acl [acl-ability]="102">
<i nz-icon nzType="save"></i>
<span>{{ 'button.save' | i18n }}</span>
</button>
<st #st [data]="produceData" [columns]="columns">
<ng-template st-row="ColumnTitleTpl" let-item let-index="index">
<input *ngIf="item.edit" nz-input [ngModel]="item.keyName"
(ngModelChange)="st.setRow(index, { keyName: $event })" />
<ng-container *ngIf="!item.edit">{{ item.keyName }}</ng-container>
</ng-template>

<ng-template st-row="ColumnTypeTpl" let-item let-index="index">
<nz-select *ngIf="item.edit" [ngModel]="item.dataSide"
(ngModelChange)="st.setRow(index, { dataSide: $event })">
<nz-option nzValue="AnySide" nzLabel="AnySide"></nz-option>
<nz-option nzValue="ServerSide" nzLabel="ServerSide"></nz-option>
<nz-option nzValue="ClientSide" nzLabel="ClientSide"></nz-option>

</nz-select>

<ng-container *ngIf="!item.edit">{{ item.dataSide }}</ng-container>
</ng-template>

<ng-template st-row="ColumnDataTypeTpl" let-item let-index="index">
<nz-select *ngIf="item.edit" [ngModel]="item.dataType"
(ngModelChange)="st.setRow(index, { dataType: $event })">
<nz-option nzValue="Boolean" nzLabel="Boolean"></nz-option>
<nz-option nzValue="String" nzLabel="String"></nz-option>
<nz-option nzValue="Long" nzLabel="Long"></nz-option>
<nz-option nzValue="Double" nzLabel="Double"></nz-option>
<nz-option nzValue="Json" nzLabel="Json"></nz-option>
<nz-option nzValue="XML" nzLabel="XML"></nz-option>
<nz-option nzValue="Binary" nzLabel="Binary"></nz-option>
<nz-option nzValue="DateTime" nzLabel="DateTime"></nz-option>
</nz-select>

<ng-container *ngIf="!item.edit">{{ item.dataType}}</ng-container>
</ng-template>


</st>
Empty file.
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { ComponentFixture, TestBed } from '@angular/core/testing';

import { ProducedataformComponent } from './producedataform.component';

describe('ProducedataformComponent', () => {
let component: ProducedataformComponent;
let fixture: ComponentFixture<ProducedataformComponent>;

beforeEach(async () => {
await TestBed.configureTestingModule({
declarations: [ ProducedataformComponent ]
})
.compileComponents();
});

beforeEach(() => {
fixture = TestBed.createComponent(ProducedataformComponent);
component = fixture.componentInstance;
fixture.detectChanges();
});

it('should create', () => {
expect(component).toBeTruthy();
});
});
Loading

0 comments on commit bc2a9d0

Please sign in to comment.