trunk/pc4mobx/organization/stores/jobgrade.js

444 lines
12 KiB
JavaScript
Raw Normal View History

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 = '';
2022-05-12 14:57:36 +08:00
@observable selectedKey = -1;
@observable topTab = [];
@observable topTabCount = {};
2022-07-12 16:45:03 +08:00
@observable lastime = '';//
2022-08-18 17:42:15 +08:00
@observable hasRight = '';
2022-06-22 17:19:28 +08:00
@observable treeLoading = true;
2022-07-05 18:54:56 +08:00
@observable treeConfig = {
data: [],
selectedKeys: [],
treeExpandKeys: [],
onExpand: (keys) => {
this.treeConfig.treeExpandKeys = keys;
},
onSelectedTreeNode: (key, count, countType) => {
this.treeConfig.selectedKeys = [key];
this.selectedTreeNodeInfo = countType.node.props.data;
this.getTableInfo();
}
}
//选中树节点的信息
@observable selectedTreeNodeInfo;
2022-06-22 17:19:28 +08:00
@action initData = () => {
this.selectedTreeNodeInfo = null;
2022-07-05 18:54:56 +08:00
this.treeConfig.treeExpandKeys.length = 0;
Api.getTree().then(res => {
if (res.code === 200) {
if (res.data.length > 0) {
this.treeConfig.data = res.data;
this.treeConfig.selectedKeys = [res.data[0].key];
2022-06-22 17:19:28 +08:00
this.treeConfig.treeExpandKeys = "-1";
2022-07-05 18:54:56 +08:00
this.selectedTreeNodeInfo = res.data[0];
this.getTableInfo();
2022-06-22 17:19:28 +08:00
this.setTreeLoading(false);
2022-07-05 18:54:56 +08:00
}
} else {
message.error(res.msg);
}
}, error => { })
2022-06-22 17:19:28 +08:00
}
@action
2022-09-02 11:00:27 +08:00
getTableInfo(isOnChange = false) {
2022-06-22 17:19:28 +08:00
let params = {
schemeId: this.selectedTreeNodeInfo && this.selectedTreeNodeInfo.domid,
}
2022-09-02 11:00:27 +08:00
const {current} = this.tableStore;
2022-05-12 14:57:36 +08:00
if (this.isEmptyObject(this.form2.getFormParams())) {
params = {
2022-06-22 17:19:28 +08:00
...params,
2022-05-12 14:57:36 +08:00
gradeName: this.gradeName,
};
} else {
params = {
2022-06-22 17:19:28 +08:00
...params,
2022-05-12 14:57:36 +08:00
...this.form2.getFormParams(),
};
}
Api.getSearchList(params).then(res => {
if (res.code === 200) {
2022-06-07 16:52:12 +08:00
this.setHasRight(res.data.hasRight);
2022-09-02 11:00:27 +08:00
isOnChange ? this.tableStore.getDatas(res.data.datas, current) : this.tableStore.getDatas(res.data.datas,1);
2022-05-12 14:57:36 +08:00
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
2022-05-12 14:57:36 +08:00
@action
getTabInfo() {
Api.getTabInfo().then(res => {
if (res.code === 200) {
res.data.topTabs && this.setTopTab(res.data.topTabs);
res.data.topTabCount && this.setTopTabCount(res.data.topTabCount);
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
//删除
delete() {
let params = {
ids: this.ids
};
2022-05-12 14:57:36 +08:00
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()
};
2022-05-12 14:57:36 +08:00
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 };
2022-05-12 14:57:36 +08:00
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);
2022-09-02 11:00:27 +08:00
this.getTableInfo(true);
2022-05-12 14:57:36 +08:00
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
}
2022-05-12 14:57:36 +08:00
Api.updateForbiddenTag(params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
message.success(data.msg);
2022-09-02 11:00:27 +08:00
this.getTableInfo(true);
2022-05-12 14:57:36 +08:00
} else {
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
}
getForm() {
2022-09-02 16:17:54 +08:00
let params = this.isNew ? {
schemeId:this.selectedTreeNodeInfo.domid
} : {
id: this.gradeId
}
this.setDialogLoadingStatus(true);
2022-05-12 14:57:36 +08:00
Api.getGradeForm(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);
2022-09-02 16:17:54 +08:00
this.updateConditions(this.selectedTreeNodeInfo.domid);
2022-05-12 14:57:36 +08:00
} else {
message.warning(res.msg);
}
}, error => {
message.warning(error.msg);
})
}
getSearchCondition() {
this.setScLoadingStatus(false);
2022-05-12 14:57:36 +08:00
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
2022-07-05 18:54:56 +08:00
getHasRight() {
2022-05-12 14:57:36 +08:00
Api.getHasRight().then(res => {
if (res.code === 200) {
res.data.rightMenu && this.setRightMenu(res.data.rightMenu);
res.data.topMenu && this.setTopMenu(res.data.topMenu);
} else {
message.warning(res.msg);
}
2022-05-12 14:57:36 +08:00
}, error => {
message.warning(error.msg);
})
}
updateFields(val) {
this.form2.updateFields({
gradeName: {
value: val
}
});
}
2022-05-13 16:56:52 +08:00
updateConditions(val) {
2022-07-12 16:45:03 +08:00
let currenttime = Date.now();
2022-07-05 18:54:56 +08:00
let key = `scheme_id_${currenttime}`;
2022-07-12 16:45:03 +08:00
let id_key = `level_id_${currenttime}`;
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.completeParams, `scheme_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.conditionDataParams, `scheme_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.dataParams, `scheme_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.destDataParams, `scheme_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.completeParams, `level_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.conditionDataParams, `level_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.dataParams, `level_id_${this.lastime}`);
Reflect.deleteProperty(this.condition[0].items[4].browserConditionParam.destDataParams, `level_id_${this.lastime}`);
this.setLastTime(currenttime);
2022-07-05 18:54:56 +08:00
this.condition[0].items[4].browserConditionParam.completeParams = {
...this.condition[0].items[4].browserConditionParam.completeParams,
2022-07-12 16:45:03 +08:00
[key]: val,
2022-07-08 13:31:40 +08:00
currenttime: currenttime,
[id_key]:"''"
2022-07-05 18:54:56 +08:00
}
this.condition[0].items[4].browserConditionParam.conditionDataParams = {
...this.condition[0].items[4].browserConditionParam.conditionDataParams,
2022-07-12 16:45:03 +08:00
[key]: val,
2022-07-08 13:31:40 +08:00
currenttime: currenttime,
[id_key]:"''"
2022-07-05 18:54:56 +08:00
}
2022-08-05 09:22:29 +08:00
this.condition[0].items[4].browserConditionParam.dataParams = {
...this.condition[0].items[4].browserConditionParam.dataParams,
[key]: val,
currenttime: currenttime,
[id_key]:"''"
}
2022-07-05 18:54:56 +08:00
this.condition[0].items[4].browserConditionParam.destDataParams = {
...this.condition[0].items[4].browserConditionParam.destDataParams,
2022-07-12 16:45:03 +08:00
[key]: val,
2022-07-08 13:31:40 +08:00
currenttime: currenttime,
[id_key]:"''"
2022-07-05 18:54:56 +08:00
}
2022-05-13 16:56:52 +08:00
this.form.updateFields({
levelId: {
value: ''
}
});
this.setCondition(this.condition);
}
2022-05-12 14:57:36 +08:00
changeData(key) {
this.setSelectedKey(key);
this.getTableInfo();
}
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;
}
2022-05-12 14:57:36 +08:00
setTopTab(topTab) {
this.topTab = topTab;
}
setTopTabCount(topTabCount) {
this.topTabCount = topTabCount;
}
setTopMenu(topMenu) {
this.topMenu = topMenu;
}
setRightMenu(rightMenu) {
this.rightMenu = rightMenu;
}
2022-07-05 18:54:56 +08:00
setKey(key) {
2022-05-13 16:56:52 +08:00
this.key = key;
}
2022-07-12 16:45:03 +08:00
setLastTime(time) {
this.lastime = time;
}
2022-06-07 16:52:12 +08:00
setHasRight(bool) {
this.hasRight = bool;
}
2022-06-22 17:19:28 +08:00
setTreeLoading(bool) {
this.treeLoading = bool;
}
}