Browse Source

fix: 修复复制数据连接时的bug

master
alan 6 years ago
parent
commit
e4f19cff5e
  1. 60
      src/app/link_set/link-set.model.ts

60
src/app/link_set/link-set.model.ts

@ -14,20 +14,9 @@ const Model: ModelType = {
* @param name * @param name
*/ */
setLinkSelected(name: string) { setLinkSelected(name: string) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) { this.noSaveConfirm(() => {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(false);
});
} else {
this.setCancel();
}
this._setLinkSelected(name); this._setLinkSelected(name);
}); });
} else {
this._setLinkSelected(name);
}
}, },
_setLinkSelected(name: string) { _setLinkSelected(name: string) {
this.model.linkList.forEach((item: LinkType) => { this.model.linkList.forEach((item: LinkType) => {
@ -55,7 +44,9 @@ const Model: ModelType = {
this._textLink(id); this._textLink(id);
break; break;
case '复制': case '复制':
this.noSaveConfirm(() => {
this.copyLink(id); this.copyLink(id);
});
break; break;
default: default:
break; break;
@ -83,22 +74,21 @@ const Model: ModelType = {
data = item; data = item;
} }
}); });
this.model.linkList = [ const newCopy = {
{
...data, ...data,
isSelected: true, isSelected: true,
connectionName:name, connectionName:name,
}, connectionId: '',
};
this.model.linkList = [
newCopy,
...this.model.linkList, ...this.model.linkList,
]; ];
this.model.linkSelected = { this.model.linkSelected = {
...data, ...newCopy,
isSelected: true,
connectionName:name,
}; };
this.model.linkUpdate = { this.model.linkUpdate = {
...data, ...newCopy,
connectionName:name,
}; };
}, },
setLinkUpdate(value: any) { setLinkUpdate(value: any) {
@ -114,7 +104,6 @@ const Model: ModelType = {
setCancel() { setCancel() {
const linkSelected: LinkType = this.model.linkSelected; const linkSelected: LinkType = this.model.linkSelected;
const linkList: LinkType[] = this.model.linkList; const linkList: LinkType[] = this.model.linkList;
if (linkSelected.connectionId) { if (linkSelected.connectionId) {
this.setEdit(false); this.setEdit(false);
} else { } else {
@ -134,20 +123,9 @@ const Model: ModelType = {
} }
}, },
setNewLink(value: string) { setNewLink(value: string) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) { this.noSaveConfirm(() => {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(true);
});
} else {
this.setCancel();
}
this._setNewLink(value); this._setNewLink(value);
}); });
} else {
this._setNewLink(value);
}
}, },
_setNewLink(value: string) { _setNewLink(value: string) {
const name = getCnnectionName(this.model.linkList); const name = getCnnectionName(this.model.linkList);
@ -178,6 +156,22 @@ const Model: ModelType = {
setConnectionNameErr(err: string) { setConnectionNameErr(err: string) {
this.model.connectionNameErr = err; this.model.connectionNameErr = err;
}, },
noSaveConfirm(cb: Function) {
if (this.model.linkSelected && this.model.linkSelected.isSelected) {
dialog.confirm('当前设置尚未保存,是否保存?', (isConfirm: boolean) => {
if (isConfirm) {
saveConnection(this.model.linkUpdate).then(() => {
this.setEdit(true);
});
} else {
this.setCancel();
}
cb();
});
} else {
cb();
}
},
}, },
}; };
BI.model(className, BI.inherit(Fix.Model, Model)); BI.model(className, BI.inherit(Fix.Model, Model));

Loading…
Cancel
Save