import {observable, action, toJS} from 'mobx'; import * as API from '../apis/apiSet'; import {message} from 'antd'; import {WeaForm } from 'comsMobx'; import {WeaLocaleProvider} from 'ecCom'; const getLabel = WeaLocaleProvider.getLabel; import weeosStore from './weeso'; class ApiSetStore { @observable form = new WeaForm(); @observable status = { fields: [], saveLoading: false, showDialog: false, } @observable apiSetRight = false; @action doInit = () =>{ this.status = { fields: [], saveLoading: false, }; this.getSearchSet(); } setState = (params = {}) => { let status = {...this.status}; Object.keys(params).forEach(key => { status[key] = params[key]; }); this.status = status; } //获取微搜接口设置信息 getSearchSet = () => { API.getSearchSet().then(result => { if(result.ret === "noright") { this.apiSetRight = false; } else { this.apiSetRight = true; this.form = new WeaForm(); this.form.initFormFields(result.fields); window.e9ChangedFormFieldKey = 'balalblallale'; this.status = {...this.status, fields: result.fields} } }) } // 保存微搜接口设置信息 saveSearchSet = (params) => { this.status.saveLoading = true; API.saveSearchSet(params).then(result => { this.status.saveLoading = false; if(result.ret){ this.status.showDialog = false; message.success(`${getLabel(18758,'保存成功')}`); this.getSearchSet(); weeosStore.getBaseData(); }else { message.error(`${getLabel(22620,'保存失败')}`); } }) } } const weesoSetStore = new ApiSetStore(); export default weesoSetStore;