UNPKG

mutants-appfx

Version:

appfx module

55 lines (47 loc) 1.09 kB
import { action, computed, observable, } from 'mobx'; import SearchPlan from './SearchPlan'; import DataProviderManager from '../DataProviderManager'; export default class DataList { // 这里还需要做些数据优化处理,加载过多数据时释放部分数据 @observable items = []; @observable currentIndex; @observable searchPlanId; @observable maxCount; sysid; mid; constructor({ sysid, mid }) { this.sysid = sysid; this.mid = mid; } @computed get searchPlan() { if (!this.searchPlanId) { return null; } return new SearchPlan(this.searchPlanId); } @computed get current() { return this.items[this.currentIndex] || null; } @action setCurrent(index) { this.currentIndex = index; } @action setSearchPlan(id) { this.searchPlanId = id; } @action async load(index = 0, limit = 100) { this.items.splice(index, 0, ...await DataProviderManager.getDataList({ sysid: this.sysid, mid: this.mid, index, limit, searchPlanId: this.searchPlanId })); } }