Browse Source

报表平台支持键值按编号搜索

pull/19/head
Jimmy.Chai 4 years ago
parent
commit
0d7c7f6deb
  1. 5
      src/web/private/i18n.ts
  2. 4
      src/web/src/index.edit.ts
  3. 3
      src/web/src/modules/crud/crud.request.ts
  4. 6
      src/web/src/modules/table_list/table_list.model.ts
  5. 32
      src/web/src/modules/table_list/table_list.ts

5
src/web/private/i18n.ts

@ -9,7 +9,12 @@ export const i18n = {
'Plugin-Redis_Help': '帮助文档',
'Plugin-Redis_Keys_Pattern': '键值的正则表达式',
'Plugin-Redis_Keys_Pattern_Search': '搜索',
'Plugin-Redis_Set_Parameter': '参数',
'Plugin-Redis_Set_Parameter_Name': '参数名',
'Plugin-Redis_Set_Parameter_Type': '参数类型',
'Plugin-Redis_Set_Parameter_Value': '参数值',
'Plugin-Redis_DB_Index': '数据库编号',
'Plugin-Redis_Index': '编号',
'Plugin-Redis_Preview': '预览',
'Plugin-Redis_Refresh': '刷新',
'Plugin-Redis_Formula': '公式',

4
src/web/src/index.edit.ts

@ -1,6 +1,6 @@
import { RedisEdit } from './modules/app.edit';
import { TableList } from './modules/table_list/table_list';
BI.createWidget({
type: RedisEdit.xtype,
type: TableList.xtype,
element: '#wrapper',
});

3
src/web/src/modules/crud/crud.request.ts

@ -4,10 +4,11 @@ export function getConnectionlist(): Promise<{data?: Connection[]}> {
return requestGet('/v10/config/connection/list');
}
export function getTableList(database: string, pattern = ''): Promise<string[]> {
export function getTableList(database: string, pattern = '', orderValue: string | number): Promise<string[]> {
return requestGet('plugin/private/com.fr.solution.plugin.db.redis.v10/redis/keys', {
database,
pattern,
orderValue,
});
}

6
src/web/src/modules/table_list/table_list.model.ts

@ -9,6 +9,7 @@ export class TableModelModel extends Model {
connections: [] as string[],
tables: [] as string[],
search: '',
orderValue: '',
selectedConnection: '',
};
}
@ -21,15 +22,16 @@ export class TableModelModel extends Model {
},
initTableList: () => {
if (this.model.selectedConnection) {
getTableList(this.model.selectedConnection, this.model.search).then(re => {
getTableList(this.model.selectedConnection, this.model.search, this.model.orderValue).then(re => {
this.model.tables = re ? re : [];
});
} else {
this.model.tables = [];
}
},
setSearch(value: string) {
setSearch(value: string, orderValue: string | number) {
this.model.search = value;
this.model.orderValue = orderValue;
},
setSelectedConnection(name: string) {
this.model.selectedConnection = name;

32
src/web/src/modules/table_list/table_list.ts

@ -1,8 +1,9 @@
import { shortcut, store } from '@core/core';
import { VtapeXtype, HtapeXtype, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype } from 'ui';
import { VtapeXtype, HtapeXtype, LabelXtype, IconButtonXtype, TextValueComboXtype, ButtonXtype, TextEditorXtype, ButtonGroupXtype, VerticalXtype } from 'ui';
import { ListItem } from './list_item';
import { TableModelModel } from './table_list.model';
import { fineServletURL } from '@constants/env';
import { DatabaseIndex } from '../components/database_index/database_index';
@shortcut()
@store(TableModelModel)
@ -12,12 +13,18 @@ export class TableList extends BI.Widget {
store: TableModelModel['store']
model: TableModelModel['model']
databaseIndex: DatabaseIndex;
buttonGroup: any;
connectionTextValue: any;
searchText: any;
props = {
database: '',
value: {
datasetData: {
orderValue: 0,
},
},
}
watch = {
@ -27,7 +34,7 @@ export class TableList extends BI.Widget {
this.connectionTextValue.setValue(name);
this.store.setSelectedConnection(name);
},
'selectedConnection || search': () => {
'selectedConnection || search || orderValue': () => {
this.store.initTableList();
},
tables: (tables: string[]) => {
@ -36,6 +43,9 @@ export class TableList extends BI.Widget {
}
render() {
const { orderValue = 0 } = this.options.value.datasetData || {};
const inputType = typeof orderValue === 'string' ? 'formula' : 'int';
return {
type: VtapeXtype,
hgap: 10,
@ -83,6 +93,22 @@ export class TableList extends BI.Widget {
el: {
type: HtapeXtype,
items: [{
el: {
type: LabelXtype,
text: BI.i18nText('Plugin-Redis_Index'),
textAlign: 'left',
},
width: 24,
}, {
type: DatabaseIndex.xtype,
value: orderValue,
inputType,
ref: (_ref: any) => {
this.databaseIndex = _ref;
},
width: 24,
height: 22,
}, {
type: TextEditorXtype,
height: 24,
watermark: BI.i18nText('Plugin-Redis_Keys_Pattern'),
@ -95,7 +121,7 @@ export class TableList extends BI.Widget {
minWidth: 50,
text: BI.i18nText('Plugin-Redis_Keys_Pattern_Search'),
handler: () => {
this.store.setSearch(this.searchText.getValue());
this.store.setSearch(this.searchText.getValue(), this.databaseIndex.getValue());
},
},
width: 50,

Loading…
Cancel
Save