579 lines
14 KiB
JavaScript
579 lines
14 KiB
JavaScript
import {
|
|
observable,
|
|
action
|
|
} from 'mobx';
|
|
import * as mobx from 'mobx';
|
|
import * as Api from '../apis/job'; // 引入API接口文件
|
|
import {
|
|
WeaForm
|
|
} from 'comsMobx';
|
|
import {
|
|
WeaTableNew
|
|
} from 'comsMobx';
|
|
import {
|
|
Modal,
|
|
message,
|
|
} from 'antd'
|
|
import {
|
|
i18n
|
|
} from '../public/i18n';
|
|
import {
|
|
findIndex
|
|
} from 'lodash';
|
|
|
|
const toJS = mobx.toJS;
|
|
const {
|
|
TableStore
|
|
} = WeaTableNew;
|
|
|
|
|
|
export class JobStore {
|
|
@observable tableStore = new TableStore();
|
|
@observable topMenu = []
|
|
@observable rightMenu = [];
|
|
@observable dataSource = [];
|
|
@observable columns = [];
|
|
@observable loading = true;
|
|
@observable dialogLoading = true;
|
|
@observable isEdit = true;
|
|
@observable nEdialogTitle = '';
|
|
@observable searchCondition = [];
|
|
@observable condition = [];
|
|
@observable copyCondition = [];
|
|
@observable mergeCondition = [];
|
|
@observable isPanelShow = false; //高级搜索面板
|
|
@observable form = new WeaForm();
|
|
@observable form1 = new WeaForm(); //新增主表表单
|
|
@observable form2 = new WeaForm(); //复制表单 合并表单
|
|
@observable jobName = '';
|
|
@observable conditionNum = 12;
|
|
@observable ids = ''; //选择行id
|
|
@observable id = ''; //页面跳转参数id
|
|
@observable searchConditionLoading = true;
|
|
@observable visible = false;
|
|
@observable newVisible = false; //新增弹窗
|
|
@observable jobId = '';
|
|
@observable selectedRowKeys = [];
|
|
@observable date = '';
|
|
@observable init = true; //是否首次加载
|
|
@observable total = '';
|
|
@observable current = 1;
|
|
@observable pageSize = 10;
|
|
@observable sortParams = [];
|
|
@observable defaultShowLeft = true;
|
|
@observable companysId = 1
|
|
@observable hasRight = '';
|
|
@observable key = '';
|
|
@observable key1 = '';
|
|
@observable selectTreeNodeInfo;
|
|
saveAndSetting = false;
|
|
|
|
@action initData() {
|
|
this.getTableInfo();
|
|
this.getHasRight();
|
|
this.getCopyForm();
|
|
this.getMergeForm();
|
|
}
|
|
|
|
@action
|
|
getTableInfo() {
|
|
this.setLoading(true);
|
|
let params = {
|
|
...this.selectTreeNodeInfo,
|
|
current: this.current,
|
|
pageSize: this.pageSize,
|
|
sortParams: this.sortParams
|
|
}
|
|
if (this.isEmptyObject(this.form.getFormParams())) {
|
|
params = {
|
|
...params,
|
|
jobName: this.jobName,
|
|
};
|
|
} else {
|
|
params = {
|
|
...params,
|
|
...this.form.getFormParams(),
|
|
};
|
|
}
|
|
Api.getSearchList(params).then(response => {
|
|
return response.json()
|
|
}).then(res => {
|
|
if (res.code === 200) {
|
|
this.setHasRight(res.data.hasRight);
|
|
res.data.pageInfo.columns && this.setColumns(res.data.pageInfo.columns);
|
|
this.setTotal(res.data.pageInfo.total);
|
|
res.data.pageInfo.list && this.setDataSource(res.data.pageInfo.list);
|
|
this.setLoading(false);
|
|
this.setInit(false);
|
|
} else {
|
|
message.warning(res.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
@action("leftTree事件")
|
|
doSearch(params) {
|
|
this.selectTreeNodeInfo = params;
|
|
this.setCurrent(1);
|
|
this.setPageSize(10);
|
|
this.setInit(true);
|
|
this.getTableInfo();
|
|
}
|
|
|
|
@action("联查人员")
|
|
getHrmTable(id) {
|
|
let params = {
|
|
jobId: id
|
|
}
|
|
this.tableStore = new TableStore();
|
|
Api.getHrmListByJobId(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.setSelectedRowKeys([]);
|
|
this.getTableInfo();
|
|
} else {
|
|
message.warning(data.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
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, 1);
|
|
this.getTableInfo();
|
|
} else {
|
|
message.warning(data.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
getSearchCondition() {
|
|
this.setScLoadingStatus(true);
|
|
Api.getAdvanceSearchCondition().then(res => {
|
|
if (res.code === 200) {
|
|
this.setScLoadingStatus(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);
|
|
})
|
|
}
|
|
|
|
|
|
getJobForm() {
|
|
this.setDialogLoadingStatus(true);
|
|
Api.getJobForm(this.selectTreeNodeInfo).then(res => {
|
|
if (res.code === 200) {
|
|
this.setDialogLoadingStatus(false);
|
|
res.data.condition && this.setCondition(res.data.condition);
|
|
res.data.condition && this.form1.initFormFields(res.data.condition);
|
|
} else {
|
|
message.warning(res.msg);
|
|
}
|
|
}, error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
@action("复制表单")
|
|
getCopyForm() {
|
|
let params = {};
|
|
Api.getCopyForm(params).then(res => {
|
|
if (res.code === 200) {
|
|
res.data && this.setCopyCondition(res.data);
|
|
} else {
|
|
message.warning(res.msg);
|
|
}
|
|
}, error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
@action("合并表单")
|
|
getMergeForm() {
|
|
Api.getMergeForm().then(res => {
|
|
if (res.code === 200) {
|
|
res.data && this.setMergeCondition(res.data);
|
|
} else {
|
|
message.warning(res.msg);
|
|
}
|
|
}, error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
|
|
save() {
|
|
let params = {
|
|
...this.form1.getFormParams()
|
|
};
|
|
this.form1.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.setNewVisible(false);
|
|
this.saveAndSetting && window.open(`/spa/organization/static/index.html#/main/organization/jobExtend/${data.data}`, "_blank")
|
|
} else {
|
|
message.warning(data.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
} else {
|
|
f.showErrors();
|
|
this.setDate(new Date());
|
|
}
|
|
});
|
|
}
|
|
|
|
copy() {
|
|
let params = {
|
|
ids: this.ids,
|
|
...this.form2.getFormParams()
|
|
};
|
|
Api.copy(params).then(response => {
|
|
return response.json()
|
|
}).then(data => {
|
|
if (data.code === 200) {
|
|
message.success(data.msg);
|
|
this.getTableInfo();
|
|
this.setSelectedRowKeys([]);
|
|
} else {
|
|
message.error(data.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
merge(id) {
|
|
let params = {
|
|
id: id,
|
|
...this.form2.getFormParams()
|
|
};
|
|
Api.merge(params).then(response => {
|
|
return response.json()
|
|
}).then(data => {
|
|
if (data.code === 200) {
|
|
message.success(data.msg);
|
|
this.getTableInfo();
|
|
} else {
|
|
message.error(data.msg);
|
|
}
|
|
}).catch(error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
updateConditions(data) {
|
|
if (data.sequence_id) {
|
|
if (data.sequence_id.valueObj.length > 0) {
|
|
let label = "等级方案"
|
|
const index = findIndex(this.condition[1].items, { label });
|
|
const schemeId = data.sequence_id.valueObj[0].scheme_values;
|
|
this.condition[1].items[index].browserConditionParam.replaceDatas = [{ name: data.sequence_id.valueObj[0].scheme_ids, id: schemeId }];
|
|
//清空职级并限制范围
|
|
label = "职级"
|
|
const index1 = findIndex(this.condition[1].items, { label });
|
|
let currenttime = 1657247378274
|
|
let key = `scheme_id_${currenttime}`;
|
|
// Object.defineProperty(this.condition[1].items[index1].browserConditionParam.completeParams, [key], {
|
|
// value: schemeId,
|
|
// })
|
|
this.condition[1].items[index1].browserConditionParam.completeParams = {
|
|
...this.condition[1].items[index1].browserConditionParam.completeParams,
|
|
[key]: schemeId,
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index1].browserConditionParam.conditionDataParams = {
|
|
...this.condition[1].items[index1].browserConditionParam.conditionDataParams,
|
|
[key]: schemeId,
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index1].browserConditionParam.dataParams = {
|
|
...this.condition[1].items[index1].browserConditionParam.dataParams,
|
|
[key]: schemeId,
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index1].browserConditionParam.destDataParams = {
|
|
...this.condition[1].items[index1].browserConditionParam.destDataParams,
|
|
[key]: schemeId,
|
|
currenttime: currenttime
|
|
}
|
|
}
|
|
this.form1.updateFields({
|
|
scheme_id: {
|
|
value: ''
|
|
},
|
|
level_id: {
|
|
value: ''
|
|
},
|
|
grade_id: {
|
|
value: ''
|
|
}
|
|
});
|
|
} else if (data.grade_id) {
|
|
if (data.grade_id.valueObj.length > 0) {
|
|
//清空职等并限制范围
|
|
let label = "职等"
|
|
const index2 = findIndex(this.condition[1].items, { label });
|
|
let currenttime = 1657247378274;
|
|
let key1 = `level_id_${currenttime}`;
|
|
let key2 = `scheme_id_${currenttime}`;
|
|
let params = {
|
|
id: data.grade_id.value
|
|
};
|
|
Api.getLevelId(params).then(res => {
|
|
if (res.code === 200) {
|
|
const levelId = res.data;
|
|
this.condition[1].items[index2].browserConditionParam.completeParams = {
|
|
...this.condition[1].items[index2].browserConditionParam.completeParams,
|
|
[key1]: levelId,
|
|
[key2]: "''",
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index2].browserConditionParam.conditionDataParams = {
|
|
...this.condition[1].items[index2].browserConditionParam.conditionDataParams,
|
|
[key1]: levelId,
|
|
[key2]: "''",
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index2].browserConditionParam.dataParams = {
|
|
...this.condition[1].items[index2].browserConditionParam.dataParams,
|
|
[key1]: levelId,
|
|
[key2]: "''",
|
|
currenttime: currenttime
|
|
}
|
|
this.condition[1].items[index2].browserConditionParam.destDataParams = {
|
|
...this.condition[1].items[index2].browserConditionParam.destDataParams,
|
|
[key]: levelId,
|
|
[key2]: "''",
|
|
currenttime: currenttime
|
|
}
|
|
} else {
|
|
message.warning(res.msg);
|
|
}
|
|
}, error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
this.form1.updateFields({
|
|
level_id: {
|
|
value: ''
|
|
}
|
|
});
|
|
}
|
|
this.setCondition(this.condition);
|
|
this.form1.initFormFields(this.condition);
|
|
}
|
|
|
|
|
|
@action
|
|
getHasRight() {
|
|
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);
|
|
}
|
|
}, error => {
|
|
message.warning(error.msg);
|
|
})
|
|
}
|
|
|
|
updateFields(val) {
|
|
this.form.updateFields({
|
|
jobName: {
|
|
value: val
|
|
}
|
|
});
|
|
}
|
|
|
|
setSearchCondition(condition) {
|
|
this.searchCondition = condition;
|
|
}
|
|
|
|
setScLoadingStatus(bool) {
|
|
this.searchConditionLoading = bool;
|
|
}
|
|
|
|
setPanelStatus(bool) {
|
|
this.isPanelShow = bool;
|
|
bool && this.getSearchCondition();
|
|
if (!bool) {
|
|
this.scLoadingReset();
|
|
}
|
|
}
|
|
|
|
setJobName(val) {
|
|
this.jobName = val;
|
|
}
|
|
|
|
isEmptyObject(obj) {
|
|
for (let key in obj) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
setIds(ids) {
|
|
this.ids = ids;
|
|
}
|
|
|
|
setId(id) {
|
|
this.id = id;
|
|
}
|
|
|
|
scLoadingReset() {
|
|
this.searchConditionLoading = true;
|
|
}
|
|
|
|
|
|
formReset() {
|
|
this.form1 = new WeaForm();
|
|
}
|
|
|
|
|
|
setVisible(bool) {
|
|
this.visible = bool;
|
|
}
|
|
|
|
setDialogLoadingStatus(bool) {
|
|
this.dialogLoading = bool;
|
|
}
|
|
|
|
|
|
setSearchCondition(searchCondition) {
|
|
this.searchCondition = searchCondition;
|
|
}
|
|
|
|
setJobId(jobId) {
|
|
this.jobId = jobId;
|
|
}
|
|
|
|
setDate(date) {
|
|
this.date = date;
|
|
}
|
|
|
|
setTopMenu(topMenu) {
|
|
this.topMenu = topMenu;
|
|
}
|
|
|
|
setRightMenu(rightMenu) {
|
|
this.rightMenu = rightMenu;
|
|
}
|
|
|
|
setDataSource(dataSource) {
|
|
this.dataSource = dataSource;
|
|
}
|
|
|
|
setColumns(columns) {
|
|
this.columns = columns
|
|
}
|
|
|
|
|
|
setSelectedRowKeys(selectedRowKeys) {
|
|
this.selectedRowKeys = selectedRowKeys;
|
|
}
|
|
|
|
setLoading(bool) {
|
|
this.loading = bool;
|
|
}
|
|
|
|
setNeDialogTitle(title) {
|
|
this.nEdialogTitle = title
|
|
}
|
|
|
|
setCondition(condition) {
|
|
this.condition = condition;
|
|
}
|
|
|
|
setCopyCondition(copyCondition) {
|
|
this.copyCondition = copyCondition;
|
|
}
|
|
|
|
setNewVisible(bool) {
|
|
this.formReset();
|
|
this.newVisible = bool;
|
|
}
|
|
|
|
setTotal(total) {
|
|
this.total = total;
|
|
}
|
|
|
|
setCurrent(current) {
|
|
this.current = current;
|
|
}
|
|
|
|
setPageSize(pageSize) {
|
|
this.pageSize = pageSize;
|
|
}
|
|
|
|
setInit(bool) {
|
|
this.init = bool;
|
|
}
|
|
|
|
setHasRight(bool) {
|
|
this.hasRight = bool;
|
|
}
|
|
|
|
setSortParams(sorter) {
|
|
this.sortParams = [];
|
|
sorter.order && this.sortParams.push({
|
|
orderkey: sorter.field,
|
|
sortOrder: sorter.order
|
|
})
|
|
}
|
|
|
|
setSaveAndSetting(bool) {
|
|
this.saveAndSetting = bool;
|
|
}
|
|
|
|
setMergeCondition(mergeCondition) {
|
|
this.mergeCondition = mergeCondition;
|
|
}
|
|
|
|
setKey(key) {
|
|
this.key = key;
|
|
}
|
|
|
|
} |