From 9d65f64488dc06aaf0ec9b81ba06afeb1e6f6e18 Mon Sep 17 00:00:00 2001 From: alan Date: Fri, 30 Aug 2019 10:49:05 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20DEC-9068=20=E6=95=B0=E6=8D=AE=E8=BF=9E?= =?UTF-8?q?=E6=8E=A5=E5=A4=8D=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/modules/app.model.ts | 3 ++- .../list/list_item/list_item.model.ts | 22 +++++++++++-------- .../connection/list/list_item/list_item.ts | 1 + .../pages/maintain/forms/form.model.ts | 6 ++++- src/modules/pages/maintain/forms/form.ts | 12 ++++++++-- src/modules/pages/maintain/maintain.model.ts | 3 ++- src/modules/pages/maintain/maintain.ts | 2 +- .../title_maintain/title_maintain.model.ts | 6 ++++- .../title/title_maintain/title_maintain.ts | 1 + 9 files changed, 40 insertions(+), 16 deletions(-) diff --git a/src/modules/app.model.ts b/src/modules/app.model.ts index 3286f68..a6f5968 100644 --- a/src/modules/app.model.ts +++ b/src/modules/app.model.ts @@ -6,7 +6,7 @@ export const AppModelXtype = 'dec.dcm.model.main'; @model(AppModelXtype) export class AppModel extends Model { - childContext = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent']; + childContext = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'filter', 'connections', 'connectionSelected', 'connectionSelectedOne', 'saveEvent', 'testEvent', 'isCopy']; state() { return { @@ -17,6 +17,7 @@ export class AppModel extends Model { connectionSelected: '', saveEvent: '', testEvent: '', + isCopy: false, }; } diff --git a/src/modules/pages/connection/list/list_item/list_item.model.ts b/src/modules/pages/connection/list/list_item/list_item.model.ts index 946d63e..0058840 100644 --- a/src/modules/pages/connection/list/list_item/list_item.model.ts +++ b/src/modules/pages/connection/list/list_item/list_item.model.ts @@ -1,5 +1,5 @@ import { model, Model } from '@core/core'; -import { ConnectionModel } from '../../connection.model'; +import { AppModel } from '../../../../app.model'; import { ApiFactory } from 'src/modules/crud/apiFactory'; const api = new ApiFactory().create(); @@ -7,15 +7,16 @@ export const ListItemModelXtype = 'dec.dcm.model.connection.list_item'; @model(ListItemModelXtype) export class ListItemModel extends Model<{ context : { - connectionSelected: ConnectionModel['$$childContext']['connectionSelected']; - connectionSelectedOne: ConnectionModel['$$childContext']['connectionSelectedOne']; - datebaseTypeSelectedOne: ConnectionModel['$$childContext']['datebaseTypeSelectedOne']; - connections: ConnectionModel['$$childContext']['connections']; - pageIndex: ConnectionModel['$$childContext']['pageIndex']; - datebaseTypeSelected: ConnectionModel['$$childContext']['datebaseTypeSelected']; + connectionSelected: AppModel['$$childContext']['connectionSelected']; + connectionSelectedOne: AppModel['$$childContext']['connectionSelectedOne']; + datebaseTypeSelectedOne: AppModel['$$childContext']['datebaseTypeSelectedOne']; + connections: AppModel['$$childContext']['connections']; + pageIndex: AppModel['$$childContext']['pageIndex']; + datebaseTypeSelected: AppModel['$$childContext']['datebaseTypeSelected']; + isCopy: AppModel['$$childContext']['isCopy'] } }> { - context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected']; + context = ['connectionSelected', 'connections', 'pageIndex', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'datebaseTypeSelected', 'isCopy']; state() { return { @@ -63,6 +64,9 @@ export class ListItemModel extends Model<{ return api.updateConnection(connections); }, + setIsCopy(isCopy: boolean) { + this.model.isCopy = isCopy; + }, } removeConnection(name: string) { api.deleteConnection(name).then(re => api.getConnectionlist()) @@ -70,7 +74,7 @@ export class ListItemModel extends Model<{ this.model.connections = connections.data; this.model.connections.forEach(item => { // 后端传过来的是字符串,转为对象 - item.connectionData = JSON.parse(item.connectionData); + item.connectionData = JSON.parse(item.connectionData as string); }); if (name === this.model.connectionSelected) { this.model.connectionSelected = ''; diff --git a/src/modules/pages/connection/list/list_item/list_item.ts b/src/modules/pages/connection/list/list_item/list_item.ts index 973f05d..879c454 100644 --- a/src/modules/pages/connection/list/list_item/list_item.ts +++ b/src/modules/pages/connection/list/list_item/list_item.ts @@ -231,6 +231,7 @@ export class ListItem extends BI.BasicButton { }, copy: () => { this.store.setConnectionSelected(name); + this.store.setIsCopy(true); this.store.setPageIndex(PAGE_INDEX.MAINTAIN); }, delete: () => { diff --git a/src/modules/pages/maintain/forms/form.model.ts b/src/modules/pages/maintain/forms/form.model.ts index 9db3704..e0071c8 100644 --- a/src/modules/pages/maintain/forms/form.model.ts +++ b/src/modules/pages/maintain/forms/form.model.ts @@ -15,9 +15,10 @@ export class MaintainFormModel extends Model<{ testEvent: AppModel['$$childContext']['testEvent']; pageIndex: AppModel['$$childContext']['pageIndex']; connections: AppModel['$$childContext']['connections']; + isCopy: AppModel['$$childContext']['isCopy']; } }> { - context = ['datebaseTypeSelected', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'saveEvent', 'pageIndex', 'testEvent', 'connections']; + context = ['datebaseTypeSelected', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'saveEvent', 'pageIndex', 'testEvent', 'connections', 'isCopy']; actions = { addConnection: (data: Connection) => { @@ -32,5 +33,8 @@ export class MaintainFormModel extends Model<{ }); }, testConnection: (connection: Connection) => api.testConnection(connection), + setIsCopy(isCopy: boolean) { + this.model.isCopy = isCopy; + }, } } diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index c735242..43b42b2 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -29,11 +29,12 @@ export class MaintainForm extends BI.Widget { if (!this.testValue()) { return; } - if (this.connectionName) { + if (this.connectionName && !this.model.isCopy) { this.store.updateConnection(this.connectionName, this.form.getSubmitValue()); } else { this.store.addConnection(this.form.getSubmitValue()); } + this.store.setIsCopy(false); }, testEvent: () => { if (!this.testValue()) { @@ -100,9 +101,16 @@ export class MaintainForm extends BI.Widget { } render() { + const formData = BI.clone(this.getFormData()); + if (this.model.isCopy) { + formData.connectionName = `${formData.connectionName}-${BI.i18nText('Dec-Dcm_Copy')}`; + this.isEdit = false; + this.connectionName = ''; + } + return { type: this.getFormType(), - formData: this.getFormData(), + formData, ref: (_ref: any) => { this.form = _ref; }, diff --git a/src/modules/pages/maintain/maintain.model.ts b/src/modules/pages/maintain/maintain.model.ts index 6ed2554..1eb12e5 100644 --- a/src/modules/pages/maintain/maintain.model.ts +++ b/src/modules/pages/maintain/maintain.model.ts @@ -9,9 +9,10 @@ export class MaintainModel extends Model<{ datebaseTypeSelected: AppModel['$$childContext']['datebaseTypeSelected']; datebaseTypeSelectedOne: AppModel['$$childContext']['datebaseTypeSelectedOne']; connectionSelectedOne: AppModel['$$childContext']['connectionSelectedOne']; + isCopy: AppModel['$$childContext']['isCopy']; } }> { - context = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'connectionSelectedOne']; + context = ['pageIndex', 'datebaseTypeSelected', 'datebaseTypeSelectedOne', 'connectionSelectedOne', 'isCopy']; actions = { setPageIndex:(index: string) => { diff --git a/src/modules/pages/maintain/maintain.ts b/src/modules/pages/maintain/maintain.ts index 3980102..b097c47 100644 --- a/src/modules/pages/maintain/maintain.ts +++ b/src/modules/pages/maintain/maintain.ts @@ -39,7 +39,7 @@ export class Maintain extends BI.Widget { }, { type: Label, - text, + text: this.model.isCopy ? `${text}-${BI.i18nText('Dec-Dcm_Copy')}` : text, }, ], height: 40, diff --git a/src/modules/title/title_maintain/title_maintain.model.ts b/src/modules/title/title_maintain/title_maintain.model.ts index 6e091c3..ca0a8ed 100644 --- a/src/modules/title/title_maintain/title_maintain.model.ts +++ b/src/modules/title/title_maintain/title_maintain.model.ts @@ -10,9 +10,10 @@ export class TitleMaintainModel extends Model<{ saveEvent: AppModel['$$childContext']['saveEvent']; connectionSelected: AppModel['$$childContext']['connectionSelected']; testEvent: AppModel['$$childContext']['testEvent']; + isCopy: AppModel['$$childContext']['isCopy']; } }> { - context = ['pageIndex', 'saveEvent', 'testEvent', 'connectionSelected']; + context = ['pageIndex', 'saveEvent', 'testEvent', 'connectionSelected', 'isCopy']; actions = { setPageIndex: (index: string) => { @@ -25,5 +26,8 @@ export class TitleMaintainModel extends Model<{ this.model.testEvent = BI.UUID(); }, shutdownConnectionStatus: () => api.shutdownConnectionStatus(this.model.connectionSelected), + setIsCopy(isCopy: boolean) { + this.model.isCopy = isCopy; + }, } } diff --git a/src/modules/title/title_maintain/title_maintain.ts b/src/modules/title/title_maintain/title_maintain.ts index 6f6d4d4..24b2b12 100644 --- a/src/modules/title/title_maintain/title_maintain.ts +++ b/src/modules/title/title_maintain/title_maintain.ts @@ -22,6 +22,7 @@ export class TitleMaintainWidget extends BI.Widget { text: BI.i18nText('BI-Basic_Cancel'), level: 'ignore', handler: () => { + this.store.setIsCopy(false); this.store.setPageIndex(PAGE_INDEX.CONNECTION); this.store.shutdownConnectionStatus(); },