diff --git a/pc4mobx/organization/apis/resourceBasicInfo.js b/pc4mobx/organization/apis/resourceBasicInfo.js index f827f6d..fd06371 100644 --- a/pc4mobx/organization/apis/resourceBasicInfo.js +++ b/pc4mobx/organization/apis/resourceBasicInfo.js @@ -33,6 +33,44 @@ export const getAdvanceSearchCondition = (params) => { return WeaTools.callApi('/api/bs/hrmorganization/resourceBasicInfo/getSearchCondition', 'GET', params); } +export const addType = (params) => { + return fetch('/api/bs/hrmorganization/resourceBasicInfo/saveResourceItemClass', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const editType = (params) => { + return fetch('/api/bs/hrmorganization/resourceBasicInfo/updateResourceItemClass', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const deleteType = (params) => { + return fetch('/api/bs/hrmorganization/resourceBasicInfo/deleteResourceItemClass', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json' + }, + body: JSON.stringify(params) + }) +} + +export const getTypeForm = (params) => { + return WeaTools.callApi('/api/bs/hrmorganization/resourceBasicInfo/getItemClassForm', 'GET', params); +} + + export const add = (params) => { return fetch('/api/bs/hrmorganization/resourceBasicInfo/save', { method: 'POST', diff --git a/pc4mobx/organization/components/resource/ResourceBasicInfo.js b/pc4mobx/organization/components/resource/ResourceBasicInfo.js index 8be6c00..7d62222 100644 --- a/pc4mobx/organization/components/resource/ResourceBasicInfo.js +++ b/pc4mobx/organization/components/resource/ResourceBasicInfo.js @@ -73,23 +73,26 @@ export default class ResourceBasicInfo extends React.Component { resourceBasicInfo.initData(); } + getTopMenuBtns() { const { resourceBasicInfo } = this.props; const { topMenu, - tableStore + tableStore, + selectedTreeNodeInfo } = resourceBasicInfo; let btns = []; topMenu.map((item, i) => { - if (item.menuFun !== 'batchDelete') { - btns.push(); - } else { + if (item.menuFun === 'batchDelete') { btns.push(); + } else if (item.menuFun === 'delItemClass' || item.menuFun === 'editItemClass') { + btns.push(); + } else { + btns.push(); } - }); return btns; @@ -107,6 +110,17 @@ export default class ResourceBasicInfo extends React.Component { this[item.menuFun] && this[item.menuFun](); } + custom = () => { + const { + resourceBasicInfo + } = this.props, { + tableStore, + } = resourceBasicInfo; + + tableStore.setColSetVisible(true); + tableStore.tableColSet(true); + } + new() { const { resourceBasicInfo @@ -114,10 +128,53 @@ export default class ResourceBasicInfo extends React.Component { resourceBasicInfo.setNeDialogTitle(i18n.label.newResourceBasicInfo()); resourceBasicInfo.setIsNew(true); + resourceBasicInfo.setOperateType("1"); resourceBasicInfo.setVisible(true); resourceBasicInfo.getForm(); } + addItemClass() { + const { + resourceBasicInfo + } = this.props; + + resourceBasicInfo.setNeDialogTitle(i18n.label.newResourceBasicType()); + resourceBasicInfo.setVisible(true); + resourceBasicInfo.setOperateType("2") + resourceBasicInfo.getTypeForm(); + } + + editItemClass() { + const { + resourceBasicInfo + } = this.props; + + resourceBasicInfo.setNeDialogTitle(i18n.label.editResourceBasicType()); + resourceBasicInfo.setVisible(true); + resourceBasicInfo.setOperateType("4") + resourceBasicInfo.getTypeForm(); + } + + delItemClass() { + const { + resourceBasicInfo + } = this.props; + confirm({ + title: i18n.confirm.defaultTitle(), + content: "确认删除该类型吗!", + okText: i18n.button.ok(), + cancelText: i18n.button.cancel(), + onOk() { + resourceBasicInfo.deleteType(); + }, + onCancel() { + return false; + }, + }); + } + + + batchDelete() { const { resourceBasicInfo @@ -215,7 +272,7 @@ export default class ResourceBasicInfo extends React.Component { form2 } = resourceBasicInfo; - resourceBasicInfo.setLevelName(val); + resourceBasicInfo.setFName(val); !this.isEmptyObject(form2.getFormParams()) && resourceBasicInfo.updateFields(val); } @@ -225,7 +282,7 @@ export default class ResourceBasicInfo extends React.Component { columns.forEach((c, index) => { if (c.dataIndex == 'fdelete') { c.render = function (text, record) { - return record.fdelete == '0' ? 正常 : 停用 + return record.fdelete == '0' ? 正常 : 停用 } }; }) @@ -246,9 +303,10 @@ export default class ResourceBasicInfo extends React.Component { resourceBasicInfo } = this.props; - resourceBasicInfo.setNeDialogTitle(i18n.label.editJobLevel()); + resourceBasicInfo.setNeDialogTitle(i18n.label.editResourceBasicInfo()); resourceBasicInfo.setFId(id); resourceBasicInfo.setIsNew(false); + resourceBasicInfo.setOperateType("3") resourceBasicInfo.setVisible(true); resourceBasicInfo.getForm(); } @@ -294,11 +352,24 @@ export default class ResourceBasicInfo extends React.Component { resourceBasicInfo } = this.props; const { - isNew + isNew, + operateType } = resourceBasicInfo; - isNew && resourceBasicInfo.save(); - !isNew && resourceBasicInfo.edit(); + switch(operateType){ + case "1": + resourceBasicInfo.save(); + break; + case "2": + resourceBasicInfo.saveType(); + break; + case "3": + resourceBasicInfo.edit(); + break; + case "4": + resourceBasicInfo.editType(); + break; + } } getPanelComponents() { @@ -415,6 +486,19 @@ export default class ResourceBasicInfo extends React.Component { onDropMenuClick={(e) => this.handleMenuClick(e)} > + resourceBasicInfo.setPanelStatus(bool)} + hideSearchAd={() => resourceBasicInfo.setPanelStatus(false)} + searchsAd={isPanelShow ? this.getPanelComponents() :
} + advanceHeight={Math.ceil(conditionNum / 2) * 52 + 20} + hasMask={false} + buttonsAd={this.getTabBtn()} + onSearch={() => resourceBasicInfo.getTableInfo()} + onSearchChange={val => this.onSearchChange(val)} + /> getLabel(386246, '人员管理'), resourceBasicInfo: () => getLabel(386246, '人员信息'), newResourceBasicInfo: () => getLabel(386246, '新建人员资料'), - - + newResourceBasicType: () => getLabel(386246, '新建人员资料类型'), + editResourceBasicInfo: () => getLabel(386246, '编辑人员资料'), + editResourceBasicType: () => getLabel(386246, '编辑人员资料类型'), authorizationGroup: () => getLabel(492, '权限组'), allAuthorization: () => getLabel(33363, '全部权限'), diff --git a/pc4mobx/organization/stores/reserouseBasicInfo.js b/pc4mobx/organization/stores/reserouseBasicInfo.js index 5fa9ab0..f409350 100644 --- a/pc4mobx/organization/stores/reserouseBasicInfo.js +++ b/pc4mobx/organization/stores/reserouseBasicInfo.js @@ -30,7 +30,8 @@ export class ResourceBasicInfoStore { @observable condition = []; @observable searchCondition = []; @observable isEdit = true; - @observable isNew = true; + @observable isNew = false; + @observable operateType = '';//1 资料新增 2类型新增 3资料编辑 4类型编辑 @observable isPanelShow = false; //高级搜索面板 @observable form2 = new WeaForm(); //高级搜索 @observable form = new WeaForm(); //新增编辑 @@ -65,13 +66,17 @@ export class ResourceBasicInfoStore { @action initData = () => { this.selectedTreeNodeInfo = null; this.treeConfig.treeExpandKeys.length = 0; + this.getTree(); + } + + @action getTree(){ 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]; + this.treeConfig.selectedKeys = this.selectedTreeNodeInfo != null ? [this.selectedTreeNodeInfo.domid] : [res.data[0].key]; this.treeConfig.treeExpandKeys = "-1"; - this.selectedTreeNodeInfo = res.data[0]; + this.selectedTreeNodeInfo = this.selectedTreeNodeInfo != null ? this.selectedTreeNodeInfo : res.data[0]; this.getTableInfo(); this.setTreeLoading(false); } @@ -131,8 +136,25 @@ export class ResourceBasicInfoStore { }) } + //删除类型 + deleteType() { + Api.deleteType(this.selectedTreeNodeInfo.domid).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(i18n.message.deleteSuccess()); + this.getTree(); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } + + //恢复 - recover(id){ + recover(id) { let params = { ids: id }; @@ -176,6 +198,34 @@ export class ResourceBasicInfoStore { }); } + + saveType() { + let params = { + ...this.form.getFormParams() + }; + this.form.validateForm().then(f => { + if (f.isValid) { + Api.addType(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.getTree(); + 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(), fid: this.fId }; this.form.validateForm().then(f => { @@ -200,6 +250,29 @@ export class ResourceBasicInfoStore { }); } + editType() { + let params = { ...this.form.getFormParams(), fid: this.selectedTreeNodeInfo.domid }; + this.form.validateForm().then(f => { + if (f.isValid) { + Api.editType(params).then(response => { + return response.json() + }).then(data => { + if (data.code === 200) { + message.success(data.msg); + this.getTree(); + this.setVisible(false); + } else { + message.warning(data.msg); + } + }).catch(error => { + message.warning(error.msg); + }) + } else { + f.showErrors(); + this.setDate(new Date()); + } + }); + } getForm() { let params = this.isNew ? { @@ -219,7 +292,24 @@ export class ResourceBasicInfoStore { }, error => { message.warning(error.msg); }) + } + getTypeForm() { + let params = this.isNew ? {} : { + fid: this.selectedTreeNodeInfo.domid + } + this.setDialogLoadingStatus(true); + Api.getTypeForm(params).then(res => { + if (res.code === 200) { + this.setDialogLoadingStatus(false); + res.data && this.setCondition(res.data); + res.data && this.form.initFormFields(res.data); + } else { + message.warning(res.msg); + } + }, error => { + message.warning(error.msg); + }) } getSearchCondition() { @@ -227,8 +317,8 @@ export class ResourceBasicInfoStore { 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); + res.data && this.setSearchCondition(res.data); + res.data && this.form2.initFormFields(res.data); } else { message.warning(res.msg); } @@ -320,6 +410,9 @@ export class ResourceBasicInfoStore { setIsNew(bool) { this.isNew = bool; } + setOperateType(val) { + this.operateType = val; + } setCondition(condition) { this.condition = condition;