trunk/pc4mobx/organization/stores/jobgrade.js

333 lines
8.7 KiB
JavaScript

import {
observable,
action
} from 'mobx';
import * as mobx from 'mobx';
import * as Api from '../apis/jobgrade'; // 引入API接口文件
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 JobGradeStore {
@observable tableStore = new TableStore();
@observable topMenu = []
@observable rightMenu = [];
@observable condition = [];
@observable searchCondition = [];
@observable isEdit = true;
@observable isNew = true;
@observable isPanelShow = false; //高级搜索面板
@observable form2 = new WeaForm();
@observable form = new WeaForm();
@observable form1 = new WeaForm();
@observable gradeName = '';
@observable conditionNum = 2;
@observable ids = ''; //选择行id
@observable searchConditionLoading = true;
@observable nEdialogTitle = '';
@observable visible = false;
@observable dialogLoading = true;
@observable gradeId = '';
@observable date = '';
@observable selectedKey = 0;
@action
getTableInfo() {
let params;
this.tableStore = new TableStore();
// if (this.isEmptyObject(this.form2.getFormParams())) {
// params = {
// ...this.form2.getFormParams(),
// gradeName: this.gradeName
// };
// } else {
// params = {
// ...this.form2.getFormParams()
// };
// }
// Api.getSearchList(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);
// })
}
//删除
delete() {
let params = {
ids: this.ids
};
// Api.deleteTableData(params).then(response => {
// return response.json()
// }).then(data => {
// if (data.code === 200) {
// message.success(i18n.message.deleteSuccess());
// this.getTableInfo();
// } else {
// message.warning(data.msg);
// }
// }).catch(error => {
// message.warning(error.msg);
// })
}
save() {
let params = {
...this.form.getFormParams()
};
// this.form.validateForm().then(f => {
// if (f.isValid) {
// Api.add(params).then(response => {
// return response.json()
// }).then(data => {
// if (data.code === 200) {
// message.success(data.msg);
// this.getTableInfo();
// this.setVisible(false);
// } else {
// message.warning(data.msg);
// }
// }).catch(error => {
// message.warning(error.msg);
// })
// } else {
// f.showErrors();
// this.setDate(new Date());
// }
// });
}
edit() {
let params = { ...this.form.getFormParams(), id: this.gradeId };
// this.form.validateForm().then(f => {
// if (f.isValid) {
// Api.edit(params).then(response => {
// return response.json()
// }).then(data => {
// if (data.code === 200) {
// message.success(data.msg);
// this.getTableInfo();
// this.setVisible(false);
// } else {
// message.warning(data.msg);
// }
// }).catch(error => {
// message.warning(error.msg);
// })
// } else {
// f.showErrors();
// this.setDate(new Date());
// }
// });
}
updateForbiddenTag(checked, id) {
let params = {
forbiddenTag: checked,
id: id
}
// Api.updateForbiddenTag(params).then(response => {
// return response.json()
// }).then(data => {
// if (data.code === 200) {
// message.success(data.msg);
// } else {
// message.warning(data.msg);
// }
// }).catch(error => {
// message.warning(error.msg);
// })
}
getForm() {
let params = this.isNew ? {} : {
id: this.gradeId
}
this.setDialogLoadingStatus(true);
// Api.getSchemeForm(params).then(res => {
// if (res.code === 200) {
// this.setDialogLoadingStatus(false);
// res.data.condition && this.setCondition(res.data.condition);
// res.data.condition && this.form.initFormFields(res.data.condition);
// } else {
// message.warning(res.msg);
// }
// }, error => {
// message.warning(error.msg);
// })
}
getSearchCondition() {
this.setScLoadingStatus(false);
// Api.getAdvanceSearchCondition().then(res => {
// if (res.code === 200) {
// this.setScLoadingStatus(false);
// res.data.conditions && this.setSearchCondition(res.data.conditions);
// res.data.conditions && this.form2.initFormFields(res.data.conditions);
// } else {
// message.warning(res.msg);
// }
// }, error => {
// message.warning(error.msg);
// })
}
@action
getHasRight() {
this.topMenu = [
{
"isBatch": "1",
"isTop": "1",
"menuFun": "new",
"menuIcon": "icon-coms-New-Flow",
"menuName": "新建",
"type": "BTN_Addnew"
},
{
"isBatch": "1",
"isTop": "1",
"menuFun": "batchDelete",
"menuIcon": "icon-coms-Batch-delete",
"menuName": "批量删除",
"type": "BTN_BatchDelete"
}
];
this.rightMenu = [
{
"isBatch": "0",
"isTop": "1",
"menuFun": "new",
"menuIcon": "icon-coms-New-Flow",
"menuName": "新建",
"type": "BTN_Addnew"
},
{
"isBatch": "0",
"isTop": "0",
"menuFun": "log",
"menuIcon": "icon-coms-Print-log",
"menuName": "日志",
"type": "BTN_log"
},
{
"isBatch": "0",
"isTop": "0",
"menuFun": "custom",
"menuIcon": "icon-coms-task-list",
"menuName": "显示列定制",
"type": "BTN_COLUMN"
}
]
}
updateFields(val) {
this.form2.updateFields({
gradeName: {
value: val
}
});
}
setSearchCondition(condition) {
this.searchCondition = condition;
}
setScLoadingStatus(bool) {
this.searchConditionLoading = bool;
}
setPanelStatus(bool) {
this.isPanelShow = bool;
bool && this.getSearchCondition();
if (!bool) {
this.scLoadingReset();
}
}
setGradeName(val) {
this.gradeName = val;
}
isEmptyObject(obj) {
for (let key in obj) {
return false;
}
return true;
}
setIds(ids) {
this.ids = ids;
}
scLoadingReset() {
this.searchConditionLoading = true;
}
formReset() {
this.form = new WeaForm();
}
dialogLoadingReset() {
this.dialogLoading = true;
}
setVisible(bool) {
this.visible = bool;
this.formReset();
!bool && this.dialogLoadingReset();
}
setDialogLoadingStatus(bool) {
this.dialogLoading = bool;
}
setNeDialogTitle(title) {
this.nEdialogTitle = title;
}
setIsNew(bool) {
this.isNew = bool;
}
setCondition(condition) {
this.condition = condition;
}
setGradeId(gradeId) {
this.gradeId = gradeId;
}
setDate(date) {
this.date = date;
}
setSelectedKey(selectedKey) {
this.selectedKey = selectedKey;
}
}