136 lines
3.0 KiB
JavaScript
136 lines
3.0 KiB
JavaScript
import {
|
|
observable,
|
|
action
|
|
} from 'mobx';
|
|
import * as Api from '../apis/addgroup';
|
|
import {
|
|
WeaForm
|
|
} from 'comsMobx';
|
|
import {
|
|
message
|
|
} from 'antd'
|
|
import * as mobx from 'mobx';
|
|
import {WeaLocaleProvider} from 'ecCom';
|
|
const getLabel = WeaLocaleProvider.getLabel;
|
|
|
|
export class HrmAddGroup {
|
|
@observable condition = [];
|
|
@observable form = new WeaForm();
|
|
@observable hrmId = '';
|
|
@observable btnName1 = '添加';
|
|
@observable btnName2 = '常用组设置';
|
|
title = () => getLabel('386431',"我的常用组");
|
|
@observable columns1 = [];
|
|
@observable dataSource1 = [];
|
|
@observable columns2 = [];
|
|
@observable dataSource2 = [];
|
|
@observable groupid = '';
|
|
@observable key = '';
|
|
@observable authority = false;
|
|
|
|
@action
|
|
getForm() {
|
|
let params = {
|
|
cmd: 'hrmgroups'
|
|
};
|
|
|
|
Api.getSearchCondition(params).then((data) => {
|
|
this.setBtnName('1', data.btn1);
|
|
this.setBtnName('2', data.btn2);
|
|
this.condition = data.condition;
|
|
this.form.initFormFields(data.condition);
|
|
})
|
|
}
|
|
|
|
getTableInfo() {
|
|
let params = {
|
|
cmd: 'hrmCardGroup',
|
|
id: this.hrmId
|
|
};
|
|
|
|
Api.getSearchResult(params).then((data) => {
|
|
if (data.authority) this.setAuthorityStatus(data.authority);
|
|
if (data.groupName) this.setTitle(data.groupName);
|
|
if (data.priGroup && data.priGroup.columns) this.setColumns('1', data.priGroup.columns);
|
|
if (data.priGroup && data.priGroup.items) this.setDataSource('1', data.priGroup.items);
|
|
if (data.pubGroup && data.pubGroup.columns) this.setColumns('2', data.pubGroup.columns);
|
|
if (data.pubGroup && data.pubGroup.items) this.setDataSource('2', data.pubGroup.items);
|
|
})
|
|
}
|
|
|
|
add() {
|
|
let formParams = this.form.getFormParams();
|
|
if (!formParams.groupsid) {
|
|
message.warning(getLabel('386432',"请选择常用组!"));
|
|
return false;
|
|
}
|
|
let params = {
|
|
cmd: 'addGroups',
|
|
method: 'addGroups',
|
|
groupid: formParams.groupsid,
|
|
userid: this.hrmId
|
|
};
|
|
|
|
Api.save(params).then((data) => {
|
|
if (data.status == 1) {
|
|
message.success(data.message);
|
|
this.getTableInfo();
|
|
this.form.reset();
|
|
} else {
|
|
message.warning(data.message);
|
|
}
|
|
})
|
|
}
|
|
|
|
delete() {
|
|
let params = {
|
|
cmd: 'delGroup',
|
|
method: 'delGroup',
|
|
groupid: this.groupid,
|
|
userid: this.hrmId
|
|
};
|
|
|
|
Api.deleteTableRow(params).then((data) => {
|
|
if (data.status == '1') {
|
|
message.success(data.message);
|
|
} else {
|
|
message.warning(data.message);
|
|
}
|
|
})
|
|
}
|
|
|
|
setHrmId(hrmId) {
|
|
this.hrmId = hrmId;
|
|
}
|
|
|
|
setBtnName(arg, btnName) {
|
|
if (arg == '1') this.btnName1 = btnName;
|
|
if (arg == '2') this.btnName2 = btnName;
|
|
}
|
|
|
|
setColumns(arg, columns) {
|
|
if (arg == '1') this.columns1 = columns;
|
|
if (arg == '2') this.columns2 = columns;
|
|
}
|
|
|
|
setDataSource(arg, dataSource) {
|
|
if (arg == '1') this.dataSource1 = dataSource;
|
|
if (arg == '2') this.dataSource2 = dataSource;
|
|
}
|
|
|
|
setTitle(title) {
|
|
this.title = title;
|
|
}
|
|
|
|
setGroupId(groupid) {
|
|
this.groupid = groupid;
|
|
}
|
|
|
|
setKey(key) {
|
|
this.key = key;
|
|
}
|
|
|
|
setAuthorityStatus(bool) {
|
|
this.authority = bool;
|
|
}
|
|
} |