Browse Source

fix: 使用loadingbar

qufenxi
alan 5 years ago
parent
commit
3281ec04cf
  1. 9
      src/modules/pages/connection/list/list.model.ts
  2. 41
      src/modules/pages/connection/list/list.ts
  3. 2
      src/ui/fineui.ts
  4. 2
      webpack/webpack.dev.js
  5. 733
      yarn.lock

9
src/modules/pages/connection/list/list.model.ts

@ -12,12 +12,6 @@ export class ConnectionListModel extends Model<{
}> { }> {
context = ['connections', 'connectionSelected']; context = ['connections', 'connectionSelected'];
state() {
return {
showItemNum: 50,
};
}
actions = { actions = {
setConnections: ():Promise<void> => api.getConnectionlist().then(data => { setConnections: ():Promise<void> => api.getConnectionlist().then(data => {
this.model.connections = data.data; this.model.connections = data.data;
@ -30,8 +24,5 @@ export class ConnectionListModel extends Model<{
resolve(); resolve();
}); });
}), }),
setItemNum: (num: number) => {
this.model.showItemNum = num;
},
} }
} }

41
src/modules/pages/connection/list/list.ts

@ -1,5 +1,5 @@
import { shortcut, store } from '@core/core'; import { shortcut, store } from '@core/core';
import { ButtonGroup, Vertical, CenterAdapt, Label, Layout, Vtape, LoadingBar } from 'ui'; import { CenterAdapt, Label, Layout, Vtape, Loader } from 'ui';
import { ListItemXtype } from './list_item/list_item'; import { ListItemXtype } from './list_item/list_item';
import { ConnectionListModel, ConnectionListModelXtype } from './list.model'; import { ConnectionListModel, ConnectionListModelXtype } from './list.model';
import { Connection } from '../../../crud/crud.typings'; import { Connection } from '../../../crud/crud.typings';
@ -61,42 +61,17 @@ export class ConnectionList extends BI.LoadingPane {
} }
return { return {
type: Vertical, type: Loader,
items: [{ itemsCreator: (options: {times: number}, populate) => {
type: ButtonGroup, populate(this.renderList((options.times - 1) * 50, options.times * 50));
layouts: [{ },
type: Vertical, hasNext: options => options.times * 50 < BI.size(this.model.connections),
}],
items: this.renderList(),
ref: (_ref: any) => {
this.groupWidget = _ref;
},
}, {
type: LoadingBar,
ref: (_ref: any) => {
this.loadingBar = _ref;
},
handler: () => {
this.loadingBar.setLoading();
this.store.setItemNum(this.model.showItemNum + 50);
},
}],
}; };
} }
created() { private renderList(start = 0, end = 0) {
if (this.model.showItemNum) { return this.model.connections.slice(start, end).map((item: Connection) => {
BI.size(this.model.connections) > this.model.showItemNum ?
this.loadingBar.setLoaded() :
null;
}
}
private renderList(start = 0) {
const itemNum = Math.min(this.model.connections.length, this.model.showItemNum);
return this.model.connections.slice(start, itemNum).map((item: Connection) => {
return { return {
type: ListItemXtype, type: ListItemXtype,
name: item.connectionName, name: item.connectionName,

2
src/ui/fineui.ts

@ -50,7 +50,7 @@ export const Img = 'bi.img';
export const BubbleCombo = 'bi.bubble_combo'; export const BubbleCombo = 'bi.bubble_combo';
export const TextBubblePopupBarView = 'bi.text_bubble_bar_popup_view'; export const TextBubblePopupBarView = 'bi.text_bubble_bar_popup_view';
export const TextValueCombo = 'bi.text_value_combo'; export const TextValueCombo = 'bi.text_value_combo';
export const LoadingBar = 'bi.loading_bar'; export const Loader = 'bi.loader';
// 布局 // 布局
export const VerticalAdapt = 'bi.vertical_adapt'; export const VerticalAdapt = 'bi.vertical_adapt';

2
webpack/webpack.dev.js

@ -44,7 +44,7 @@ module.exports = merge(common, {
}, },
devServer: { devServer: {
contentBase: path.join(__dirname, '..'), contentBase: path.join(__dirname, '..'),
port: 10002, port: 10003,
liveReload: true, liveReload: true,
proxy: { proxy: {
'/webroot/decision/v10': { '/webroot/decision/v10': {

733
yarn.lock

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save