自定义设置页面接口对接

This commit is contained in:
Chengliang 2022-06-16 18:35:17 +08:00
parent 2d1c756985
commit 19e1d07e3c
4 changed files with 155 additions and 102 deletions

View File

@ -7,16 +7,12 @@ import {
* @param {Object} params [description]
* @return {[type]} [description]
*/
export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi('/api/bs/hrmorganization/fieldDefined/getTabInfo', 'GET', params)
export const getTabInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTabInfo`, 'GET', params)
export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/getFieldDefinedInfo?is_multilang_set=true`, 'GET', params)
export const getFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getFieldDefinedInfo`, 'GET', params)
export const saveFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/save`, 'POST', params)
export const removeFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/del`, 'POST', params)
export const saveGroupInfo = (moduleName,params) => {
return fetch('/api/bs/hrmorganization/fieldDefined/saveTitle', {
export const saveFieldDefinedInfo = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, {
method: 'POST',
mode: 'cors',
headers: {
@ -26,6 +22,30 @@ export const saveGroupInfo = (moduleName,params) => {
})
}
export const removeFieldDefinedInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/del`, 'POST', params)
export const saveGroupInfo = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTitle`, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const saveGroupSettingInfo = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveGroup`, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const changeTypeInfo = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/changeTree`, {
@ -38,13 +58,30 @@ export const changeTypeInfo = (moduleName,params) => {
})
}
export const removeGroupInfo = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/deleteTitle`, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const removeGroupInfo = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/delGroup`, 'POST', params)
export const getTree = (moduleName,params = {}) => WeaTools.callApi(`/api/bs/hrmorganization/fieldDefined/${moduleName}/getTree`, 'GET', params)
export const saveTree = (params = {}) => WeaTools.callApi(`/api/hrm/resourcefielddefined/saveTree`, 'POST', params)
export const saveTree = (moduleName,params) => {
return fetch(`/api/bs/hrmorganization/fieldDefined/${moduleName}/saveTree`, {
method: 'POST',
mode: 'cors',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(params)
})
}
export const changeGroup = (moduleName, params = {}) => WeaTools.callApi(`/api/hrm/${moduleName}/changeGroup`, 'POST', params)

View File

@ -56,20 +56,18 @@ export default class FieldDefined extends Component {
let moduleName, logSmallType;
if (moduleType === 'subCompany') {
moduleName = 'subcompanyfielddefined';
//logSmallType = 'HRM_ENGINE_SUBCOMPANYFIELDDEFINED';
} else if (moduleType === 'department') {
moduleName = 'departmentfielddefined';
//logSmallType = 'HRM_ENGINE_DEPARTMENTFIELDDEFINED';
} else if(moduleType === 'job') {
moduleName = 'jobfielddefined';
}else {
moduleName = 'resourcefielddefined';
//logSmallType = 'HRM_ENGINE_RESOURCEFIELDDEFINED';
}
// let callbackFunc = () => initData(false, true, moduleName);
// if (moduleType === 'resource')
let callbackFunc = () => initResourceData(moduleName);
checkAuthorized(moduleName, null, callbackFunc);
//let callbackFunc = () => initResourceData(moduleName);
//checkAuthorized(moduleName, null, callbackFunc);
initResourceData(moduleName);
this.setState({ logSmallType })
}
@ -87,7 +85,7 @@ export default class FieldDefined extends Component {
fieldDefined: store,
params
} = this.props, {
containerInitFinished,
//containerInitFinished,//权限验证
refreshMainTabComponent,
spinning
} = store, {
@ -145,7 +143,8 @@ export default class FieldDefined extends Component {
}
}
let children = [];
if (containerInitFinished.init && containerInitFinished.authorized) {
const hasRight = true;//todo
if (hasRight) {
const {
data,
onSelectedTreeNode,
@ -176,7 +175,7 @@ export default class FieldDefined extends Component {
</Spin>
)
]
} else if (containerInitFinished.init && !containerInitFinished.authorized) {
} else {
children = [
(
<WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@z0f4dh`}>

View File

@ -1,7 +1,7 @@
/**
* @Author: 程亮
* @Date: 2022-06-09 10:14:20
* @LastEditTime: 2022-06-13 14:50:36
* @LastEditTime: 2022-06-16 18:26:17
* @Description:
* @FilePath: /trunk/src4js/pc4mobx/organization/stores/baseStore.js
*/
@ -540,6 +540,7 @@ export default class HrmBaseStore {
return otherParams;
}
//重新计算列
convertData = (datas, target) => {
let tData = [],
selectedData = this.generateTableSelectedData(target);

View File

@ -1,7 +1,7 @@
/**
* @Author: 程亮
* @Date: 2022-06-09 10:16:00
* @LastEditTime: 2022-06-15 18:47:39
* @LastEditTime: 2022-06-16 18:34:18
* @Description:
* @FilePath: /trunk/src4js/pc4mobx/organization/stores/fieldDefined.js
*/
@ -648,10 +648,10 @@ export class FieldDefinedStore extends HrmBaseStore {
this.tabConfig.tabs = [...tabArr];
// this.setTableEditColTitle();
this.setActiveTab(this.tabConfig, init ? '1' : !create ? this.tabConfig.activeTabKey : `${tabArr.length}`);
this.containerInitFinished = {
...this.containerInitFinished,
init: true
}
// this.containerInitFinished = {
// ...this.containerInitFinished,
// init: true
// }
}
} else {
message.error(data.message);
@ -696,38 +696,38 @@ export class FieldDefinedStore extends HrmBaseStore {
if (this.selectedTreeNodeInfo != null)
params.groupType = this.selectedTreeNodeInfo.key
this.spinning = true;
api.getFieldDefinedInfo(this.moduleName, params).then(data => {
if (data.status === '1') {
api.getFieldDefinedInfo(this.moduleName, params).then(response => {
return response.json()
}).then(res => {
if (res.code === 200) {
const {
datas,
selectedData
} = this.convertData(data.data, 'fieldDef');
this.encryptEnable = data.encryptEnable;
} = this.convertData(res.data.data, 'fieldDef');
this.encryptEnable = res.data.encryptEnable;
this.tableEditConfig.fieldDef.datas = datas;
this.tableEditConfig.fieldDef.columns = this.getColumns();
//人员卡片字段定义columns是动态的因此需要重新计算得出selectedData
if (this.moduleName === 'resourcefielddefined') {
const {
selectedData
} = this.convertData(data.data, 'fieldDef');
this.tableEditConfig.fieldDef.selectedData = selectedData;
} else {
this.tableEditConfig.fieldDef.selectedData = selectedData;
}
this.tableEditConfig.fieldDef.selectedData = selectedData;
if (this.tabRecord.length > 0) {
this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (data.data.length === 0);
this.activeTabInfo.tabInfo.editable = (data.data.length === 0);
this.tabRecord[this.activeTabInfo.activeTabIndex].editable = (res.data.data.length === 0);
this.activeTabInfo.tabInfo.editable = (res.data.data.length === 0);
}
} else
message.error(data.message);
} else {
message.warning(res.msg);
}
this.spinning = false;
this.refreshMainTabComponent = new Date().getTime();
}, error => { this.spinning = false; })
}).catch(error => {
this.spinning = false;
message.warning(error.msg);
})
}
@action onTabEdit = (targetKey, action) => {
@action("分组tab删除") onTabEdit = (targetKey, action) => {
const tabIndex = this.getTabIndex(this.tabConfig.tabs, targetKey);
if (tabIndex < 0) return;
const tabInfo = this.tabConfig.tabs[tabIndex];
@ -741,18 +741,19 @@ export class FieldDefinedStore extends HrmBaseStore {
}
if (this.selectedTreeNodeInfo != null)
params.groupType = this.selectedTreeNodeInfo.key
api.removeGroupInfo(this.moduleName, params).then(data => {
if (data.status === '1') {
api.removeGroupInfo(this.moduleName, params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
message.success(i18n.message.deleteSuccess());
this.tabConfig.activeTabKey = '1';
// if (this.moduleName.indexOf('resource') >= 0)
// this.getTabInfoByTreeNode();
// else
// this.initData();
this.getTabInfoByTreeNode();
} else {
message.error(data.message);
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
}
});
@ -819,10 +820,10 @@ export class FieldDefinedStore extends HrmBaseStore {
this.formTarget.typeInfoFrom.updateFields({
name: { value: data.name }
});
}else {
} else {
this.selectedTreeNodeInfo.domid = null;
}
this.setDialogVisible('editTypeInfo', true, dialogTitle);
}
@ -877,7 +878,6 @@ export class FieldDefinedStore extends HrmBaseStore {
@action("保存类型") doSaveTypeInfo = () => {
this.formTarget.typeInfoFrom.validateForm().then(f => {
if (f.isValid) {
debugger
let params = {
... this.formTarget.typeInfoFrom.getFormParams(),
id: this.selectedTreeNodeInfo.domid
@ -1019,18 +1019,20 @@ export class FieldDefinedStore extends HrmBaseStore {
return;
}
api.saveFieldDefinedInfo(this.moduleName, params).then(data => {
if (data.status === '1') {
api.saveFieldDefinedInfo(this.moduleName, params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
message.success(i18n.message.saveSuccess());
// if (this.moduleName.indexOf('resource') >= 0)
this.getTabInfoByTreeNode();
// else
// this.initData();
} else {
message.error(data.message);
message.warning(data.msg);
}
this.spinning = false;
}, error => { this.spinning = false; })
}).catch(error => {
message.warning(error.msg);
})
} else {
message.error(i18n.confirm.displayOrDBFieldExist());
this.spinning = false;
@ -1243,7 +1245,7 @@ export class FieldDefinedStore extends HrmBaseStore {
return sel;
}
doSaveGroupSetting = () => {
@action("分组维护保存") doSaveGroupSetting = () => {
this.recordOP(this.editTable['groupSetting'], 'valid');
let groupNameArr = [],
tabArr = [];
@ -1270,26 +1272,27 @@ export class FieldDefinedStore extends HrmBaseStore {
}
params.data = dataObj;
api.saveGroupInfo(this.moduleName, params).then(data => {
if (data.status === '1') {
api.saveGroupSettingInfo(this.moduleName, params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
this.setDialogVisible('groupInfoSetting', false, '');
// if (this.moduleName.indexOf('resource') >= 0)
this.getTabInfoByTreeNode(false, true);
// else
// this.initData(false, true);
message.success(i18n.message.saveSuccess());
} else
message.error(data.message);
}, error => {
message.error(i18n.message.actionError());
});
} else {
message.warning(data.msg);
}
}).catch(error => {
message.warning(error.msg);
})
} else {
message.error(i18n.confirm.groupNameExist());
}
}
@action onGroupSettingDeleteOpr = (ks, ds, type) => {
@action("分组维护中删除") onGroupSettingDeleteOpr = (ks, ds, type) => {
debugger
let ids = [];
ds.map(d => {
if (has(d, 'id'))
@ -1315,7 +1318,7 @@ export class FieldDefinedStore extends HrmBaseStore {
} else { }
}
//人员卡片字段定义部分
//字段定义部分
@observable refreshTree = new Date().getTime();
@observable treeConfig = {
data: [],
@ -1330,7 +1333,7 @@ export class FieldDefinedStore extends HrmBaseStore {
this.getTabInfoByTreeNode(null, true);
}
}
//人员卡片字段定义-选中树节点的信息
//选中树节点的信息
@observable selectedTreeNodeInfo;
//计算【工作信息】树节点以及子节点的domid
@ -1378,10 +1381,10 @@ export class FieldDefinedStore extends HrmBaseStore {
this.treeConfig.treeExpandKeys.length = 0;
api.getTree(this.moduleName).then(res => {
if (res.code === 200) {
this.containerInitFinished = {
...this.containerInitFinished,
init: true
}
// this.containerInitFinished = {
// ...this.containerInitFinished,
// init: true
// }
if (res.data.length > 0) {
this.treeConfig.data = res.data;
this.treeConfig.selectedKeys = [res.data[0].key];
@ -1434,21 +1437,23 @@ export class FieldDefinedStore extends HrmBaseStore {
this.tableEditConfig.childInfoSetting.showAdd = true;
this.tableEditConfig.childInfoSetting.showDelete = true;
let domid = this.selectedTreeNodeInfo.domid;
//非基本类型()
(domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({
t.topButtonDef.push({
comType: 'button',
type: 'primary',
onClickHandle: this.doChildInfoSetting,
label: i18n.button.childInfoMaintain(),
icon: this.menuIconCollection.setting,
checkAction: 'childInfoOperability'
}) && t.topButtonDef.push({
icon: this.menuIconCollection.setting
//checkAction: 'childInfoOperability'
});
//非基本类型()
(domid != '-1' && domid != '-2' && domid != '-3' && domid != '-4') && t.topButtonDef.push({
comType: 'button',
type: 'primary',
onClickHandle: this.removeTypeInfo,
label: i18n.button.delete(),
icon: this.menuIconCollection.setting
});
} else {
this.tableEditConfig.childInfoSetting.showTitle = false;
this.tableEditConfig.childInfoSetting.showAdd = false;
@ -1462,6 +1467,8 @@ export class FieldDefinedStore extends HrmBaseStore {
})
}
if (this.selectedTreeNodeInfo.domid === '-1' || this.selectedTreeNodeInfo.addChild) {
this.tableEditConfig.fieldDef.columns[2].com[0].options = remove(this.tableEditConfig.fieldDef.columns[1].com[0].options, (v) => v != 'upload');
} else {
@ -1550,7 +1557,7 @@ export class FieldDefinedStore extends HrmBaseStore {
@action doSaveChildInfo = () => {
@action("编辑子信息保存(f)") doSaveChildInfo = () => {
this.formTarget.childInfoForm.validateForm().then(f => {
if (f.isValid) {
let record = {
@ -1625,7 +1632,8 @@ export class FieldDefinedStore extends HrmBaseStore {
}, error => {
message.error(i18n.message.actionError());
});
// }
} else {
f.showErrors();
this.showError = new Date().getTime();
@ -1633,7 +1641,7 @@ export class FieldDefinedStore extends HrmBaseStore {
});
}
@action doChildInfoSetting = () => {
@action("子信息维护") doChildInfoSetting = () => {
this.tableEditConfig.childInfoSetting.datas.length = 0;
let arr = [];
if (!this.selectedTreeNodeInfo.addChild) {
@ -1653,6 +1661,7 @@ export class FieldDefinedStore extends HrmBaseStore {
}
})
} else {
this.selectedTreeNodeInfo.childs = this.selectedTreeNodeInfo.childs ? this.selectedTreeNodeInfo.childs : [];
this.selectedTreeNodeInfo.childs.map(child => {
let viewAttr = child.viewAttr;
if (viewAttr != 1 && has(child, 'editable')) {
@ -1698,6 +1707,7 @@ export class FieldDefinedStore extends HrmBaseStore {
this.setDialogVisible('childInfoSetting', true, i18n.button.childInfoMaintain());
}
convertAttr = (cloneTree) => {
let arr = [];
cloneTree.map(root => {
@ -1763,7 +1773,8 @@ export class FieldDefinedStore extends HrmBaseStore {
});
}
doSaveChildInfoSetting = () => {
@action("保存子信息维护") doSaveChildInfoSetting = () => {
debugger
this.recordOP(this.editTable['childInfoSetting'], 'valid');
let infoNameArr = [],
infoArr = [];
@ -1772,7 +1783,7 @@ export class FieldDefinedStore extends HrmBaseStore {
infoArr.push({
id: group.id,
isShow: group.isShow == null ? '0' : group.isShow,
name: group.name
groupName: group.name
})
return group.name === '';
})
@ -1802,30 +1813,35 @@ export class FieldDefinedStore extends HrmBaseStore {
})
})
}
const params = {
data: JSON.stringify({
records: this.convertAttr(cloneTree)
}),
// data: JSON.stringify({
// records: this.convertAttr(cloneTree)
// }),
data: JSON.stringify(infoArr),
parentId
}
api.saveTree(params).then(data => {
if (data.status === '1') {
api.saveTree(this.moduleName, params).then(response => {
return response.json()
}).then(data => {
if (data.code === 200) {
this.setDialogVisible('childInfoSetting', false, '');
this.getTree();
this.getTabInfoByTreeNode(null, true);
message.success(i18n.message.saveSuccess());
} else
message.error(data.message);
}, error => {
} else {
message.warning(data.msg);
}
}).catch(error => {
message.error(i18n.message.actionError());
});
})
} else {
message.error(i18n.confirm.groupNameExist());
}
}
//移动到组
@action dropdownClick = (e) => {
@action("移动到组") dropdownClick = (e) => {
switch (e.key) {
case 'createAndMove':
this.editGroup(null, true);