90 lines
2.6 KiB
JavaScript
90 lines
2.6 KiB
JavaScript
import { observable, action } from 'mobx';
|
|
import { message, Modal, Button } from 'antd';
|
|
import { WeaTools, WeaLocaleProvider } from 'ecCom';
|
|
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
import objectAssign from 'object-assign';
|
|
import HrmImportCommon from '../hrm/importCommon.js';
|
|
|
|
class WeaPortalCustomSettingStore {
|
|
@observable state = {
|
|
loading: true,
|
|
hideLeftMenu: '0',
|
|
isRemeberTab: '0',
|
|
isShowLeftMenu: '0',
|
|
isSortTopByUsage: '0',
|
|
quickSearchShowMenu: '0',
|
|
hplist: [],
|
|
};
|
|
|
|
constructor() {
|
|
this.onSetState = this.onSetState.bind(this);
|
|
this.getButtons = this.getButtons.bind(this);
|
|
this.getRightMenu = this.getRightMenu.bind(this);
|
|
this.onRightMenuClick = this.onRightMenuClick.bind(this);
|
|
this.getPortalData = this.getPortalData.bind(this);
|
|
this.onSaveSetting = this.onSaveSetting.bind(this);
|
|
}
|
|
|
|
// 实例化【导入】对应的store
|
|
@observable hrmImportCommon = new HrmImportCommon();
|
|
|
|
// 向【导入】store中注入【人力资源】store
|
|
setSourceStore = (store) => {
|
|
this.hrmImportCommon.setSourceStore(store);
|
|
}
|
|
|
|
@action
|
|
onSetState(state) {
|
|
this.state = objectAssign({}, this.state, state);
|
|
}
|
|
|
|
@action
|
|
getButtons() {
|
|
let btns = [];
|
|
btns.push(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@f3lucn`} type="primary" onClick={this.onSaveSetting}>{getLabel(30986, '保存')}</Button>);
|
|
return btns;
|
|
}
|
|
|
|
@action
|
|
getRightMenu() {
|
|
let btns = [];
|
|
btns.push({
|
|
icon: <i className="icon-coms-Preservation" />,
|
|
content: getLabel(30986, '保存'),
|
|
});
|
|
return btns;
|
|
}
|
|
|
|
@action
|
|
onRightMenuClick(key) {
|
|
switch (key) {
|
|
case '0':
|
|
this.onSaveSetting();
|
|
break;
|
|
}
|
|
}
|
|
|
|
@action
|
|
getPortalData() {
|
|
WeaTools.callApi('/api/portal/customSetting/getCustomSettingData', 'GET', {}).then((result) => {
|
|
const { data } = result;
|
|
this.state = { ...data, loading: false };
|
|
});
|
|
}
|
|
|
|
@action
|
|
onSaveSetting() {
|
|
let params = { ...this.state };
|
|
delete params.hplist;
|
|
WeaTools.callApi('/api/portal/customSetting/saveCustomSettingData', 'POST', params).then((result) => {
|
|
if (result.api_status) {
|
|
message.success(getLabel(83551, '保存成功!'));
|
|
} else {
|
|
message.error(getLabel(84544, '保存失败!'));
|
|
}
|
|
});
|
|
}
|
|
}
|
|
module.exports = WeaPortalCustomSettingStore;
|