trunk/pc4mobx/organization/stores/logview.js

114 lines
2.6 KiB
JavaScript

import {
observable,
action
} from 'mobx';
import * as mobx from 'mobx';
import * as Api from '../apis/logview';
import {
WeaForm
} from 'comsMobx';
import {
WeaTableNew
} from 'comsMobx';
import {
Modal,
message,
} from 'antd'
import {
i18n
} from '../public/i18n';
const toJS = mobx.toJS;
const {
TableStore
} = WeaTableNew;
export class LogViewStore {
@observable tableStore = new TableStore();
@observable searchCondition = [];
@observable isPanelShow = false; //高级搜索面板
@observable form = new WeaForm();
@observable conditionNum = 20;
@observable searchConditionLoading = true;
@observable visible = false;
@observable dialogLoading = false;
@observable moduleType = ""; //模块类型
init(logMoudleType) {
this.setModuleType(logMoudleType);
this.getTableInfo();
this.getSearchCondition();
}
@action getTableInfo() {
let params = {
...this.form.getFormParams(),
moduleType:this.moduleType
}
this.tableStore = new TableStore();
Api.getLogList(params).then(res => {
if (res.code === 200) {
res.data.datas && this.tableStore.getDatas(res.data.datas, 1);
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
@action getSearchCondition() {
this.setDialogLoading(true);
Api.getAdvanceSearchCondition().then(res => {
if (res.code === 200) {
this.setDialogLoading(false);
res.data.conditions && this.setSearchCondition(res.data.conditions);
res.data.conditions && this.form.initFormFields(res.data.conditions);
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
setDialogLoading(bool) {
this.dialogLoading = bool;
}
setPanelStatus(bool) {
this.isPanelShow = bool;
bool && this.getSearchCondition();
if (!bool) {
this.scLoadingReset();
}
}
isEmptyObject(obj) {
for (let key in obj) {
return false;
}
return true;
}
setSearchCondition(searchCondition) {
this.searchCondition = searchCondition;
}
scLoadingReset() {
this.searchConditionLoading = true;
}
setVisable(bool) {
this.visible = bool;
}
setModuleType(moduleType) {
this.moduleType = moduleType;
}
}