提交 3fc7ed66 编写于 作者: ibizdev's avatar ibizdev

SYSTEM 发布系统代码

上级 e0110222
......@@ -10,6 +10,10 @@ const routes: Routes = [
path: 'module5_entity5main5editview',
loadChildren: '@pages/module5/entity5-main5-edit-view/entity5-main5-edit-view.module#Entity5Main5EditViewModule'
},
{
path: 'module4_entity4main7editview',
loadChildren: '@pages/module4/entity4-main7-edit-view/entity4-main7-edit-view.module#Entity4Main7EditViewModule'
},
{
path: 'exapmple_examplemain3editview',
loadChildren: '@pages/exapmple/example-main3-edit-view/example-main3-edit-view.module#ExampleMain3EditViewModule'
......@@ -30,6 +34,10 @@ const routes: Routes = [
path: 'module3_entity3editview',
loadChildren: '@pages/module3/entity3-edit-view/entity3-edit-view.module#Entity3EditViewModule'
},
{
path: 'exapmple_examplemain6editview',
loadChildren: '@pages/exapmple/example-main6-edit-view/example-main6-edit-view.module#ExampleMain6EditViewModule'
},
{
path: 'exapmple_examplemain2editview',
loadChildren: '@pages/exapmple/example-main2-edit-view/example-main2-edit-view.module#ExampleMain2EditViewModule'
......@@ -38,6 +46,10 @@ const routes: Routes = [
path: 'module4_entity4editview',
loadChildren: '@pages/module4/entity4-edit-view/entity4-edit-view.module#Entity4EditViewModule'
},
{
path: 'exapmple_examplemain7editview',
loadChildren: '@pages/exapmple/example-main7-edit-view/example-main7-edit-view.module#ExampleMain7EditViewModule'
},
{
path: 'module5_entity5editview',
loadChildren: '@pages/module5/entity5-edit-view/entity5-edit-view.module#Entity5EditViewModule'
......
......@@ -2,13 +2,16 @@
<nz-sider>
<ul nz-menu nzMode="inline" nzTheme="dark">
<li nz-menu-item (click)="onClick('module5_entity5main5editview')">表单5</li>
<li nz-menu-item (click)="onClick('module4_entity4main7editview')">111111</li>
<li nz-menu-item (click)="onClick('exapmple_examplemain3editview')">模拟</li>
<li nz-menu-item (click)="onClick('module_entityeditview')">实体编辑视图</li>
<li nz-menu-item (click)="onClick('exapmple_exampleeditortype')">基础编辑器</li>
<li nz-menu-item (click)="onClick('exapmple_exampleeditview')">基础表单项</li>
<li nz-menu-item (click)="onClick('module3_entity3editview')">实体3编辑视图</li>
<li nz-menu-item (click)="onClick('exapmple_examplemain6editview')">测试tree</li>
<li nz-menu-item (click)="onClick('exapmple_examplemain2editview')">业务</li>
<li nz-menu-item (click)="onClick('module4_entity4editview')">实体4编辑视图</li>
<li nz-menu-item (click)="onClick('exapmple_examplemain7editview')">表单7</li>
<li nz-menu-item (click)="onClick('module5_entity5editview')">实体5编辑视图</li>
<li nz-menu-item (click)="onClick('exapmple_exampledlfeditview')">表单项动态逻辑示例</li>
<li nz-menu-item (click)="onClick('exapmple_examplemain5editview')">表单5</li>
......
<div style="background: #fff;height: 100%;padding: 16px;overflow: auto;">
<main6-form (dataChangeEvent)="onFormDataChange($event)"></main6-form></div>
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditFormModule } from '@widgets/example/main6/main6.module';
import { ExampleMain6EditViewPage } from './example-main6-edit-view';
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: ExampleMain6EditViewPage,
data: { name: 'exapmple_examplemain6editview' }
}
])
],
exports: [ RouterModule ]
})
export class ExampleMain6EditViewRouteModule {}
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
ExampleMain6EditViewRouteModule,
EditFormModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ExampleMain6EditViewPage],
entryComponents: [ExampleMain6EditViewPage],
exports: [ExampleMain6EditViewPage]
})
export class ExampleMain6EditViewModule {}
import { Component } from '@angular/core';
import { Subject, Unsubscribable } from 'rxjs';
@Component({
selector: 'view-example-main6-edit-view',
templateUrl: './example-main6-edit-view.html',
styleUrls: ['./example-main6-edit-view.less']
})
export class ExampleMain6EditViewPage {
/**
* 表单数据变化
*
* @param {*} $event
* @memberof BookTestEditViewPage
*/
public onFormDataChange($event: any) {
console.log($event);
}
}
<div style="background: #fff;height: 100%;padding: 16px;overflow: auto;">
<main7-form (dataChangeEvent)="onFormDataChange($event)"></main7-form></div>
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditFormModule } from '@widgets/example/main7/main7.module';
import { ExampleMain7EditViewPage } from './example-main7-edit-view';
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: ExampleMain7EditViewPage,
data: { name: 'exapmple_examplemain7editview' }
}
])
],
exports: [ RouterModule ]
})
export class ExampleMain7EditViewRouteModule {}
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
ExampleMain7EditViewRouteModule,
EditFormModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [ExampleMain7EditViewPage],
entryComponents: [ExampleMain7EditViewPage],
exports: [ExampleMain7EditViewPage]
})
export class ExampleMain7EditViewModule {}
import { Component } from '@angular/core';
import { Subject, Unsubscribable } from 'rxjs';
@Component({
selector: 'view-example-main7-edit-view',
templateUrl: './example-main7-edit-view.html',
styleUrls: ['./example-main7-edit-view.less']
})
export class ExampleMain7EditViewPage {
/**
* 表单数据变化
*
* @param {*} $event
* @memberof BookTestEditViewPage
*/
public onFormDataChange($event: any) {
console.log($event);
}
}
<div style="background: #fff;height: 100%;padding: 16px;overflow: auto;">
<main7-form (dataChangeEvent)="onFormDataChange($event)"></main7-form></div>
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditFormModule } from '@widgets/entity4/main7/main7.module';
import { Entity4Main7EditViewPage } from './entity4-main7-edit-view';
@NgModule({
imports: [
RouterModule.forChild([
{
path: '',
component: Entity4Main7EditViewPage,
data: { name: 'module4_entity4main7editview' }
}
])
],
exports: [ RouterModule ]
})
export class Entity4Main7EditViewRouteModule {}
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
Entity4Main7EditViewRouteModule,
EditFormModule,
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [Entity4Main7EditViewPage],
entryComponents: [Entity4Main7EditViewPage],
exports: [Entity4Main7EditViewPage]
})
export class Entity4Main7EditViewModule {}
import { Component } from '@angular/core';
import { Subject, Unsubscribable } from 'rxjs';
@Component({
selector: 'view-entity4-main7-edit-view',
templateUrl: './entity4-main7-edit-view.html',
styleUrls: ['./entity4-main7-edit-view.less']
})
export class Entity4Main7EditViewPage {
/**
* 表单数据变化
*
* @param {*} $event
* @memberof BookTestEditViewPage
*/
public onFormDataChange($event: any) {
console.log($event);
}
}
<form nz-form nz-row class="app-form">
<div nz-row>
<nz-tabset>
</nz-tabset>
</div>
</form>
\ No newline at end of file
// this is less
.hidden {
display: none;
}
.app-form {
.app-form-group {
height: 100%;
/deep/ .ant-card-body {
height: calc(100% - 58px);
}
}
.no-error {
margin-bottom: 24px;
}
/deep/ .ant-tabs-tabpane {
padding: 0 16px;
}
}
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditForm } from './main7';
import { AppTimePickerModule } from '@components/app-time-picker/app-time-picker.module';
import { AppDatePickerModule } from '@components/app-date-picker/app-date-picker.module';
import { AppSelectModule } from '@components/app-select/app-select.module';
import { AppRadioModule } from '@components/app-radio/app-radio.module';
import { AppCheckboxListModule } from '@components/app-checkbox-list/app-checkbox-list.module';
import { AppCheckboxModule } from '@components/app-checkbox/app-checkbox.module';
import { AppImageUploadModule } from '@components/app-image-upload/app-image-upload.module';
import { AppFileUploadModule } from '@components/app-file-upload/app-file-upload.module';
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
AppDatePickerModule,
AppTimePickerModule,
AppSelectModule,
AppRadioModule,
AppCheckboxListModule,
AppCheckboxModule,
AppImageUploadModule,
AppFileUploadModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [EditForm],
exports: [EditForm]
})
export class EditFormModule { }
import { Component, OnInit, Input, Output, EventEmitter, ViewContainerRef, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { Subject, Subscription } from 'rxjs';
import { NzNotificationService } from 'ng-zorro-antd/notification';
import { Util } from '@global/util/util';
import { NzModalService } from 'ng-zorro-antd/modal';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@global/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
selector: 'main7-form',
templateUrl: './main7.html',
styleUrls: ['./main7.less'],
})
export class EditForm implements OnInit {
constructor(private $util: Util) {
}
/**
* 数据对象
*
* @type {*}
* @memberof EditForm
*/
@Input()
set formData(val: any) {
if (val) {
this.data = JSON.parse(JSON.stringify(val));
this.formLogic('', null, null);
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof EditForm
*/
public data: any = {};
/**
* 表单数据变化
*
* @type {Subject<any>}
* @memberof EditForm
*/
public formDataChange: Subject<any> = new Subject<any>();
/**
* 表单数据变化抛出事件
*
* @type {EventEmitter<any>}
* @memberof EditForm
*/
@Output() dataChangeEvent: EventEmitter<any> = new EventEmitter<any>();
/**
* 代码表模型
*
* @type {*}
* @memberof Main7
*/
public codelistModel: any = {
};
/**
* 属性值规则
*
* @type {*}
* @memberof Main7
*/
public rules: any = {
srfupdatedate: [
{ type: 'string', message: '更新时间 值必须为字符串类型' },
{ required: false, type: 'string', message: '更新时间 值不能为空' },
],
srforikey: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfkey: [
{ type: 'string', message: '实体4标识 值必须为字符串类型' },
{ required: false, type: 'string', message: '实体4标识 值不能为空' },
],
srfmajortext: [
{ type: 'string', message: '实体4名称 值必须为字符串类型' },
{ required: false, type: 'string', message: '实体4名称 值不能为空' },
],
srftempmode: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfuf: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfdeid: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfsourcekey: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
entity4id: [
{ type: 'string', message: '实体4标识 值必须为字符串类型' },
{ required: false, type: 'string', message: '实体4标识 值不能为空' },
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Main7
*/
public detailsModel: any = {
srfupdatedate: new FormItemModel({ caption: '更新时间', detailType: 'FORMITEM', name: 'srfupdatedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfkey: new FormItemModel({ caption: '实体4标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfmajortext: new FormItemModel({ caption: '实体4名称', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
entity4id: new FormItemModel({ caption: '实体4标识', detailType: 'FORMITEM', name: 'entity4id', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
form: new FormTabPanelModel({ caption: 'form', detailType: 'TABPANEL', name: 'form', visible: true, isShowCaption: true, form: this, tabPages: [] }),
};
/**
* 生命周期
*
* @memberof EditForm
*/
ngOnInit(): void {
this.formLogic('', null, null);
this.formDataChange.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe(data => {
this.dataChangeEvent.emit(JSON.parse(data.data));
const field = data.field;
if (field) {
this.formLogic(field.name, field.value, field.oldVal);
this.validateFormItem(field.name);
}
});
}
/**
* 表单项值变化事件
*
* @param {{name: string, value: any}} {name, value}
* @memberof EditForm
*/
public onFormDataChange(name: string, value: any): void {
if (Object.is(this.data[name], value)) {
return;
}
let oldVal: any = this.data[name];
this.data[name] = value;
this.formDataChange.next({ data: JSON.stringify(this.data), field: { name: name, value: value, oldVal: oldVal } });
}
/**
* 校验表单项
*
* @param {string} name
* @memberof EditForm
*/
public validateFormItem(name: string) {
if (!name) {
return;
}
const rule: any[] = this.rules[name];
let message = '';
let status = '';
const val: any = this.data[name];
rule.every((rule: any) => {
if (rule.required && (!val || Object.is(val, '')) ) {
message = rule.message;
status = 'error';
return false;
} else if (val && rule.pattern && !rule.pattern.test(val)) {
message = rule.message;
status = 'error';
return false;
}
return true;
});
this.detailsModel[name].error = message;
this.detailsModel[name].validateStatus = status;
}
/**
* 获取代码表集合
*
* @param {string} name
* @memberof EditForm
*/
public getCodeList(name: string) {
if (!name || !this.codelistModel[name]) {
return [];
}
return this.codelistModel[name];
}
/**
* 表单逻辑
*
* @param {string} name
* @param {*} newVal
* @param {*} oldVal
* @memberof EditForm
*/
public formLogic(name: string, newVal: any, oldVal: any) {
}
}
\ No newline at end of file
<form nz-form nz-row class="app-form">
<div nz-row>
<nz-tabset>
</nz-tabset>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem.validateStatus" [nzErrorTip]="detailsModel.formitem.error">
</nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem1.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem1.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem1[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem1.validateStatus" [nzErrorTip]="detailsModel.formitem1.error">
<input nz-input name="formitem1" [ngModel]="data.formitem1" [disabled]="detailsModel.formitem1.disabled" placeholder="请输入..." (ngModelChange)="onFormDataChange('formitem1', $event)" style=""/> </nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem2.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem2.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem2[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem2.validateStatus" [nzErrorTip]="detailsModel.formitem2.error">
<div style="">{{ data.formitem2 }}</div> </nz-form-control>
</nz-form-item >
</div>
</div>
</form>
\ No newline at end of file
......@@ -103,6 +103,18 @@ export class EditForm implements OnInit {
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
formitem: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
formitem1: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
formitem2: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
exampleid: [
{ type: 'string', message: '示例标识 值必须为字符串类型' },
{ required: false, type: 'string', message: '示例标识 值不能为空' },
......@@ -116,6 +128,8 @@ export class EditForm implements OnInit {
* @memberof Main5
*/
public detailsModel: any = {
formpage1: new FormPageModel({ caption: '表单分页', detailType: 'FORMPAGE', name: 'formpage1', visible: true, isShowCaption: true, form: this })
,
srfupdatedate: new FormItemModel({ caption: '更新时间', detailType: 'FORMITEM', name: 'srfupdatedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
......@@ -131,10 +145,15 @@ export class EditForm implements OnInit {
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
formitem: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'formitem', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
formitem1: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'formitem1', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
formitem2: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'formitem2', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
exampleid: new FormItemModel({ caption: '示例标识', detailType: 'FORMITEM', name: 'exampleid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
form: new FormTabPanelModel({ caption: 'form', detailType: 'TABPANEL', name: 'form', visible: true, isShowCaption: true, form: this, tabPages: [] }),
};
/**
......@@ -234,5 +253,9 @@ export class EditForm implements OnInit {
}
}
\ No newline at end of file
<form nz-form nz-row class="app-form">
<div nz-row>
<nz-tabset>
</nz-tabset>
</div>
</form>
\ No newline at end of file
// this is less
.hidden {
display: none;
}
.app-form {
.app-form-group {
height: 100%;
/deep/ .ant-card-body {
height: calc(100% - 58px);
}
}
.no-error {
margin-bottom: 24px;
}
/deep/ .ant-tabs-tabpane {
padding: 0 16px;
}
}
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditForm } from './main6';
import { AppTimePickerModule } from '@components/app-time-picker/app-time-picker.module';
import { AppDatePickerModule } from '@components/app-date-picker/app-date-picker.module';
import { AppSelectModule } from '@components/app-select/app-select.module';
import { AppRadioModule } from '@components/app-radio/app-radio.module';
import { AppCheckboxListModule } from '@components/app-checkbox-list/app-checkbox-list.module';
import { AppCheckboxModule } from '@components/app-checkbox/app-checkbox.module';
import { AppImageUploadModule } from '@components/app-image-upload/app-image-upload.module';
import { AppFileUploadModule } from '@components/app-file-upload/app-file-upload.module';
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
AppDatePickerModule,
AppTimePickerModule,
AppSelectModule,
AppRadioModule,
AppCheckboxListModule,
AppCheckboxModule,
AppImageUploadModule,
AppFileUploadModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [EditForm],
exports: [EditForm]
})
export class EditFormModule { }
import { Component, OnInit, Input, Output, EventEmitter, ViewContainerRef, ViewChild, OnDestroy, AfterViewInit } from '@angular/core';
import { Subject, Subscription } from 'rxjs';
import { NzNotificationService } from 'ng-zorro-antd/notification';
import { Util } from '@global/util/util';
import { NzModalService } from 'ng-zorro-antd/modal';
import { FormButtonModel, FormPageModel, FormItemModel, FormDRUIPartModel, FormPartModel, FormGroupPanelModel, FormIFrameModel, FormRowItemModel, FormTabPageModel, FormTabPanelModel, FormUserControlModel } from '@global/model/form-detail';
import { debounceTime, distinctUntilChanged } from 'rxjs/operators';
@Component({
selector: 'main6-form',
templateUrl: './main6.html',
styleUrls: ['./main6.less'],
})
export class EditForm implements OnInit {
constructor(private $util: Util) {
}
/**
* 数据对象
*
* @type {*}
* @memberof EditForm
*/
@Input()
set formData(val: any) {
if (val) {
this.data = JSON.parse(JSON.stringify(val));
this.formLogic('', null, null);
}
}
/**
* 表单数据对象
*
* @type {*}
* @memberof EditForm
*/
public data: any = {};
/**
* 表单数据变化
*
* @type {Subject<any>}
* @memberof EditForm
*/
public formDataChange: Subject<any> = new Subject<any>();
/**
* 表单数据变化抛出事件
*
* @type {EventEmitter<any>}
* @memberof EditForm
*/
@Output() dataChangeEvent: EventEmitter<any> = new EventEmitter<any>();
/**
* 代码表模型
*
* @type {*}
* @memberof Main6
*/
public codelistModel: any = {
};
/**
* 属性值规则
*
* @type {*}
* @memberof Main6
*/
public rules: any = {
srfupdatedate: [
{ type: 'string', message: '更新时间 值必须为字符串类型' },
{ required: false, type: 'string', message: '更新时间 值不能为空' },
],
srforikey: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfkey: [
{ type: 'string', message: '示例标识 值必须为字符串类型' },
{ required: false, type: 'string', message: '示例标识 值不能为空' },
],
srfmajortext: [
{ type: 'string', message: '示例名称 值必须为字符串类型' },
{ required: false, type: 'string', message: '示例名称 值不能为空' },
],
srftempmode: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfuf: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfdeid: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
srfsourcekey: [
{ type: 'string', message: ' 值必须为字符串类型' },
{ required: false, type: 'string', message: ' 值不能为空' },
],
exampleid: [
{ type: 'string', message: '示例标识 值必须为字符串类型' },
{ required: false, type: 'string', message: '示例标识 值不能为空' },
],
}
/**
* 详情模型集合
*
* @type {*}
* @memberof Main6
*/
public detailsModel: any = {
srfupdatedate: new FormItemModel({ caption: '更新时间', detailType: 'FORMITEM', name: 'srfupdatedate', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srforikey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srforikey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfkey: new FormItemModel({ caption: '示例标识', detailType: 'FORMITEM', name: 'srfkey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfmajortext: new FormItemModel({ caption: '示例名称', detailType: 'FORMITEM', name: 'srfmajortext', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srftempmode: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srftempmode', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfuf: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfuf', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfdeid: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfdeid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
srfsourcekey: new FormItemModel({ caption: '', detailType: 'FORMITEM', name: 'srfsourcekey', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
exampleid: new FormItemModel({ caption: '示例标识', detailType: 'FORMITEM', name: 'exampleid', visible: true, isShowCaption: true, form: this, disabled: false, enableCond: 3 })
,
form: new FormTabPanelModel({ caption: 'form', detailType: 'TABPANEL', name: 'form', visible: true, isShowCaption: true, form: this, tabPages: [] }),
};
/**
* 生命周期
*
* @memberof EditForm
*/
ngOnInit(): void {
this.formLogic('', null, null);
this.formDataChange.pipe(
debounceTime(300),
distinctUntilChanged()
).subscribe(data => {
this.dataChangeEvent.emit(JSON.parse(data.data));
const field = data.field;
if (field) {
this.formLogic(field.name, field.value, field.oldVal);
this.validateFormItem(field.name);
}
});
}
/**
* 表单项值变化事件
*
* @param {{name: string, value: any}} {name, value}
* @memberof EditForm
*/
public onFormDataChange(name: string, value: any): void {
if (Object.is(this.data[name], value)) {
return;
}
let oldVal: any = this.data[name];
this.data[name] = value;
this.formDataChange.next({ data: JSON.stringify(this.data), field: { name: name, value: value, oldVal: oldVal } });
}
/**
* 校验表单项
*
* @param {string} name
* @memberof EditForm
*/
public validateFormItem(name: string) {
if (!name) {
return;
}
const rule: any[] = this.rules[name];
let message = '';
let status = '';
const val: any = this.data[name];
rule.every((rule: any) => {
if (rule.required && (!val || Object.is(val, '')) ) {
message = rule.message;
status = 'error';
return false;
} else if (val && rule.pattern && !rule.pattern.test(val)) {
message = rule.message;
status = 'error';
return false;
}
return true;
});
this.detailsModel[name].error = message;
this.detailsModel[name].validateStatus = status;
}
/**
* 获取代码表集合
*
* @param {string} name
* @memberof EditForm
*/
public getCodeList(name: string) {
if (!name || !this.codelistModel[name]) {
return [];
}
return this.codelistModel[name];
}
/**
* 表单逻辑
*
* @param {string} name
* @param {*} newVal
* @param {*} oldVal
* @memberof EditForm
*/
public formLogic(name: string, newVal: any, oldVal: any) {
}
}
\ No newline at end of file
<form nz-form nz-row class="app-form">
<div nz-row>
<div nz-col [ngClass]="{ hidden: !detailsModel.grouppanel1.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<div nz-row>
<div nz-col [ngClass]="{ hidden: !detailsModel.grouppanel2.visible }" style='' [nzSm]="{ span: 8, offset: 0 }" [nzMd]="{ span: 8, offset: 0 }" [nzLg]="{ span: 8, offset: 0 }" [nzXl]="{ span: 8, offset: 0 }">
<div nz-row>
</div>
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.grouppanel3.visible }" style='' [nzSm]="{ span: 8, offset: 0 }" [nzMd]="{ span: 8, offset: 0 }" [nzLg]="{ span: 8, offset: 0 }" [nzXl]="{ span: 8, offset: 0 }">
<div nz-row>
</div>
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.grouppanel4.visible }" style='' [nzSm]="{ span: 8, offset: 0 }" [nzMd]="{ span: 8, offset: 0 }" [nzLg]="{ span: 8, offset: 0 }" [nzXl]="{ span: 8, offset: 0 }">
<div nz-row>
</div>
</div>
</div>
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.button1.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<button class="" nz-button nzType="primary" (click)="button1_click($event)" style="">
<span ></span>
</button>
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem.validateStatus" [nzErrorTip]="detailsModel.formitem.error">
<app-image-upload [value]="data.formitem" [disabled]="detailsModel.formitem.disabled" (onFormItemValueChange)="onFormDataChange('formitem', $event)" style="overflow: auto;"></app-image-upload> </nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.name.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.name.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.name[1].required" style="width: 130px;">名称</nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.name.validateStatus" [nzErrorTip]="detailsModel.name.error">
<input nz-input name="name" [ngModel]="data.name" [disabled]="detailsModel.name.disabled" placeholder="请输入..." (ngModelChange)="onFormDataChange('name', $event)" style=""/> </nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.age.visible }" style='' [nzMd]="{ span: 150, offset: 0 }" [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.age.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.age[1].required" style="width: 130px;">年龄</nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.age.validateStatus" [nzErrorTip]="detailsModel.age.error">
<input nz-input name="age" [ngModel]="data.age" [disabled]="detailsModel.age.disabled" placeholder="请输入..." (ngModelChange)="onFormDataChange('age', $event)" style=""/> </nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem1.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem1.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem1[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem1.validateStatus" [nzErrorTip]="detailsModel.formitem1.error">
<app-radio [value]="data.formitem1" [disabled]="detailsModel.formitem1.disabled" (onFormItemValueChange)="onFormDataChange('formitem1', $event)"></app-radio> </nz-form-control>
</nz-form-item >
</div>
<div nz-col [ngClass]="{ hidden: !detailsModel.formitem2.visible }" style='' [nzLg]="{ span: 24, offset: 0 }">
<nz-form-item [nzFlex]="true" [ngClass]="[(detailsModel.formitem2.validateStatus == 'error') ? '' : 'no-error']">
<nz-form-label [nzRequired]="rules.formitem2[1].required" style="width: 130px;"></nz-form-label>
<nz-form-control style="flex-grow: 1;" [nzValidateStatus]="detailsModel.formitem2.validateStatus" [nzErrorTip]="detailsModel.formitem2.error">
<app-file-upload [value]="data.formitem2" [disabled]="detailsModel.formitem2.disabled" (onFormItemValueChange)="onFormDataChange('formitem2', $event)" style="overflow: auto;"></app-file-upload> </nz-form-control>
</nz-form-item >
</div>
</div>
</form>
\ No newline at end of file
// this is less
.hidden {
display: none;
}
.app-form {
.app-form-group {
height: 100%;
/deep/ .ant-card-body {
height: calc(100% - 58px);
}
}
.no-error {
margin-bottom: 24px;
}
/deep/ .ant-tabs-tabpane {
padding: 0 16px;
}
}
\ No newline at end of file
import { NgZorroAntdModule } from 'ng-zorro-antd';
import { RouterModule } from '@angular/router';
import { NgModule, CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FormsModule } from '@angular/forms';
import { EditForm } from './main7';
import { AppTimePickerModule } from '@components/app-time-picker/app-time-picker.module';
import { AppDatePickerModule } from '@components/app-date-picker/app-date-picker.module';
import { AppSelectModule } from '@components/app-select/app-select.module';
import { AppRadioModule } from '@components/app-radio/app-radio.module';
import { AppCheckboxListModule } from '@components/app-checkbox-list/app-checkbox-list.module';
import { AppCheckboxModule } from '@components/app-checkbox/app-checkbox.module';
import { AppImageUploadModule } from '@components/app-image-upload/app-image-upload.module';
import { AppFileUploadModule } from '@components/app-file-upload/app-file-upload.module';
@NgModule({
imports: [
NgZorroAntdModule,
CommonModule,
FormsModule,
AppDatePickerModule,
AppTimePickerModule,
AppSelectModule,
AppRadioModule,
AppCheckboxListModule,
AppCheckboxModule,
AppImageUploadModule,
AppFileUploadModule
],
schemas: [CUSTOM_ELEMENTS_SCHEMA],
declarations: [EditForm],
exports: [EditForm]
})
export class EditFormModule { }
此差异已折叠。
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册