Browse Source

fix: DEC-9068 数据连接复制

qufenxi
alan 5 years ago
parent
commit
9d65f64488
  1. 3
      src/modules/app.model.ts
  2. 22
      src/modules/pages/connection/list/list_item/list_item.model.ts
  3. 1
      src/modules/pages/connection/list/list_item/list_item.ts
  4. 6
      src/modules/pages/maintain/forms/form.model.ts
  5. 12
      src/modules/pages/maintain/forms/form.ts
  6. 3
      src/modules/pages/maintain/maintain.model.ts
  7. 2
      src/modules/pages/maintain/maintain.ts
  8. 6
      src/modules/title/title_maintain/title_maintain.model.ts
  9. 1
      src/modules/title/title_maintain/title_maintain.ts

3
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,
};
}

22
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 = '';

1
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: () => {

6
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;
},
}
}

12
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;
},

3
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) => {

2
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,

6
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;
},
}
}

1
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();
},

Loading…
Cancel
Save