56 lines
1.0 KiB
JavaScript
56 lines
1.0 KiB
JavaScript
import {
|
|
observable,
|
|
action,
|
|
} from 'mobx';
|
|
|
|
export default class RadioGroupStore {
|
|
constructor(api, rootStore) {
|
|
this.api = api;
|
|
this.rootStore = rootStore
|
|
}
|
|
|
|
//搜索参数
|
|
radioGroupParams = {};
|
|
|
|
@observable config = [];
|
|
|
|
@action fetchRadioGroupConfig = () => {
|
|
return new Promise((resolve, reject) => {
|
|
this.config = [];
|
|
|
|
this.api().then(datas => {
|
|
const conditions = this.getCondition(datas);
|
|
|
|
const {
|
|
items
|
|
} = conditions[0];
|
|
|
|
this.config = this.rootStore.processRadioGroupConfig(items);
|
|
|
|
resolve();
|
|
});
|
|
})
|
|
}
|
|
|
|
handleRadioGroupChange = (params) => {
|
|
this.radioGroupParams = Object.assign({}, params, this.moreParams);
|
|
|
|
this.rootStore.handleRadioGroupChange && this.rootStore.handleRadioGroupChange();
|
|
}
|
|
|
|
setRadioGroupMoreParams = (moreParams) => {
|
|
this.moreParams = moreParams;
|
|
|
|
Object.assign(this.radioGroupParams, moreParams);
|
|
}
|
|
|
|
getCondition = (datas) => {
|
|
let c = [];
|
|
Object.keys(datas).forEach(key => {
|
|
if (key.includes('condition')) {
|
|
c = datas[key];
|
|
}
|
|
})
|
|
return c;
|
|
}
|
|
} |