Browse Source

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

master
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_Help': '帮助文档',
'Plugin-Redis_Keys_Pattern': '键值的正则表达式', 'Plugin-Redis_Keys_Pattern': '键值的正则表达式',
'Plugin-Redis_Keys_Pattern_Search': '搜索', '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_DB_Index': '数据库编号',
'Plugin-Redis_Index': '编号',
'Plugin-Redis_Preview': '预览', 'Plugin-Redis_Preview': '预览',
'Plugin-Redis_Refresh': '刷新', 'Plugin-Redis_Refresh': '刷新',
'Plugin-Redis_Formula': '公式', '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({ BI.createWidget({
type: RedisEdit.xtype, type: TableList.xtype,
element: '#wrapper', 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'); 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', { return requestGet('plugin/private/com.fr.solution.plugin.db.redis.v10/redis/keys', {
database, database,
pattern, 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[], connections: [] as string[],
tables: [] as string[], tables: [] as string[],
search: '', search: '',
orderValue: '',
selectedConnection: '', selectedConnection: '',
}; };
} }
@ -21,15 +22,16 @@ export class TableModelModel extends Model {
}, },
initTableList: () => { initTableList: () => {
if (this.model.selectedConnection) { 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 : []; this.model.tables = re ? re : [];
}); });
} else { } else {
this.model.tables = []; this.model.tables = [];
} }
}, },
setSearch(value: string) { setSearch(value: string, orderValue: string | number) {
this.model.search = value; this.model.search = value;
this.model.orderValue = orderValue;
}, },
setSelectedConnection(name: string) { setSelectedConnection(name: string) {
this.model.selectedConnection = name; 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 { 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 { ListItem } from './list_item';
import { TableModelModel } from './table_list.model'; import { TableModelModel } from './table_list.model';
import { fineServletURL } from '@constants/env'; import { fineServletURL } from '@constants/env';
import { DatabaseIndex } from '../components/database_index/database_index';
@shortcut() @shortcut()
@store(TableModelModel) @store(TableModelModel)
@ -12,12 +13,18 @@ export class TableList extends BI.Widget {
store: TableModelModel['store'] store: TableModelModel['store']
model: TableModelModel['model'] model: TableModelModel['model']
databaseIndex: DatabaseIndex;
buttonGroup: any; buttonGroup: any;
connectionTextValue: any; connectionTextValue: any;
searchText: any; searchText: any;
props = { props = {
database: '', database: '',
value: {
datasetData: {
orderValue: 0,
},
},
} }
watch = { watch = {
@ -27,7 +34,7 @@ export class TableList extends BI.Widget {
this.connectionTextValue.setValue(name); this.connectionTextValue.setValue(name);
this.store.setSelectedConnection(name); this.store.setSelectedConnection(name);
}, },
'selectedConnection || search': () => { 'selectedConnection || search || orderValue': () => {
this.store.initTableList(); this.store.initTableList();
}, },
tables: (tables: string[]) => { tables: (tables: string[]) => {
@ -36,6 +43,9 @@ export class TableList extends BI.Widget {
} }
render() { render() {
const { orderValue = 0 } = this.options.value.datasetData || {};
const inputType = typeof orderValue === 'string' ? 'formula' : 'int';
return { return {
type: VtapeXtype, type: VtapeXtype,
hgap: 10, hgap: 10,
@ -83,6 +93,22 @@ export class TableList extends BI.Widget {
el: { el: {
type: HtapeXtype, type: HtapeXtype,
items: [{ 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, type: TextEditorXtype,
height: 24, height: 24,
watermark: BI.i18nText('Plugin-Redis_Keys_Pattern'), watermark: BI.i18nText('Plugin-Redis_Keys_Pattern'),
@ -95,7 +121,7 @@ export class TableList extends BI.Widget {
minWidth: 50, minWidth: 50,
text: BI.i18nText('Plugin-Redis_Keys_Pattern_Search'), text: BI.i18nText('Plugin-Redis_Keys_Pattern_Search'),
handler: () => { handler: () => {
this.store.setSearch(this.searchText.getValue()); this.store.setSearch(this.searchText.getValue(), this.databaseIndex.getValue());
}, },
}, },
width: 50, width: 50,

Loading…
Cancel
Save