forked from fanruan/demo-tabledata-redis
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
1.3 KiB
40 lines
1.3 KiB
import { model, Model } from '@core/core'; |
|
import { getConnectionlist, getTableList } from '../crud/crud.request'; |
|
@model() |
|
export class TableModelModel extends Model { |
|
static xtype = 'dec.model.dcm.connection.plugin.redis.table_list'; |
|
|
|
state() { |
|
return { |
|
connections: [] as string[], |
|
tables: [] as string[], |
|
search: '', |
|
orderValue: '', |
|
selectedConnection: '', |
|
}; |
|
} |
|
|
|
actions = { |
|
initData: () => { |
|
getConnectionlist().then(re => { |
|
this.model.connections = re.data.filter(item => item.connectionType === 'Redis').map(item => item.connectionName); |
|
}); |
|
}, |
|
initTableList: () => { |
|
if (this.model.selectedConnection) { |
|
getTableList(this.model.selectedConnection, this.model.search, this.model.orderValue).then(re => { |
|
this.model.tables = re ? re : []; |
|
}); |
|
} else { |
|
this.model.tables = []; |
|
} |
|
}, |
|
setSearch(value: string, orderValue: string | number) { |
|
this.model.search = value; |
|
this.model.orderValue = orderValue; |
|
}, |
|
setSelectedConnection(name: string) { |
|
this.model.selectedConnection = name; |
|
}, |
|
} |
|
}
|
|
|