非系统人员管理-新功能开发

This commit is contained in:
黎永顺 2023-03-13 14:40:19 +08:00
parent a6cf191c29
commit eb207921cd
4 changed files with 300 additions and 108 deletions

View File

@ -0,0 +1,27 @@
import { postFetch } from "../util/request";
import { WeaTools } from "ecCom";
//非系统人员-保存
export const save = (params) => {
return postFetch("/api/bs/hrmsalary/extEmp/save", params);
};
//非系统人员-修改
export const update = (params) => {
return postFetch("/api/bs/hrmsalary/extEmp/update", params);
};
//非系统人员-列表
export const listPage = (params) => {
return postFetch("/api/bs/hrmsalary/extEmp/listPage", params);
};
//非系统人员-删除
export const deleteExtEmp = (params) => {
return postFetch("/api/bs/hrmsalary/extEmp/delete", params);
};
//非系统人员-详情
export const detail = params => {
return WeaTools.callApi("/api/bs/hrmsalary/extEmp/detail", "get", params);
};

View File

@ -6,11 +6,86 @@
*/
import React, { Component } from "react";
import { WeaSlideModal } from "ecCom";
import { message } from "antd";
import { getSearchs } from "../../../util";
import SlideModalTitle from "../../../components/slideModalTitle";
import { detail, save, update } from "../../../apis/externalPersonManage";
class ExternalPersonManageEditSlide extends Component {
constructor(props) {
super(props);
this.state = {
date: "",
loading: false
};
}
componentWillReceiveProps(nextProps, nextContext) {
if (nextProps.visible !== this.props.visible && nextProps.visible) this.detail(nextProps);
}
detail = (props) => {
const { form, id } = props;
detail({ id }).then(({ status, data }) => {
if (status) {
const {
departmentName, departmentId, subcompanyName, subcompanyId,
jobtitleName, jobtitleId, ...extraFormfields
} = data;
form.updateFields({
"departmentId": {
value: departmentId,
valueSpan: departmentName,
valueObj: [{ id: departmentId, name: departmentName }]
}
});
form.updateFields({
"subcompanyId": {
value: subcompanyId,
valueSpan: departmentName,
valueObj: [{ id: subcompanyId, name: subcompanyName }]
}
});
form.updateFields({
"jobtitleId": {
value: jobtitleId,
valueSpan: jobtitleName,
valueObj: [{ id: jobtitleId, name: jobtitleName }]
}
});
_.map(_.keys(extraFormfields), item => {
form.updateFields({ [item]: { value: extraFormfields[item] } }, false);
});
}
});
};
handleSubmit = () => {
const { form, id, onCancel } = this.props;
form.validateForm().then(f => {
if (f.isValid) {
const payload = _.omitBy(form.getFormParams(), _.isEmpty);
this.setState({ loading: true });
const APIFOX = !id ? save : update;
APIFOX(id ? { ...payload, id } : payload).then(({ status, errormsg }) => {
this.setState({ loading: false });
if (status) {
message.success("创建成功");
onCancel(true);
} else {
message.error(errormsg || "创建失败");
}
}).catch(() => this.setState({ loading: false }));
} else {
f.showErrors();
this.setState({ date: new Date() });
}
});
};
render() {
const { visible, title, onCancel, showOperateBtn } = this.props;
const { loading } = this.state;
const { visible, title, onCancel, showOperateBtn, form, condition } = this.props;
return (
<WeaSlideModal
className="slideOuterWrapper"
@ -26,11 +101,12 @@ class ExternalPersonManageEditSlide extends Component {
<SlideModalTitle
subtitle={title}
editable={true}
loading={loading}
showOperateBtn={showOperateBtn}
onSave={() => console.log(111)}
onSave={this.handleSubmit}
/>
}
content={null}
content={getSearchs(form, condition, 1)}
onClose={onCancel}
/>
);

View File

@ -29,96 +29,96 @@ export const condition = [
value: "",
viewAttr: 3,
},
{
browserConditionParam: {
completeParams: {},
conditionDataParams: {},
dataParams: {},
destDataParams: {},
hasAddBtn: false,
hasAdvanceSerach: false,
idSeparator: ",",
isAutoComplete: 1,
isDetail: 0,
isMultCheckbox: false,
isSingle: true,
icon: "icon-coms-hrm",
linkUrl: "",
pageSize: 10,
quickSearchName: "",
replaceDatas: [],
title: "部门",
type: "57",
viewAttr: 2,
},
colSpan: 1,
conditionType: "BROWSER",
domkey: ["departmentId"],
fieldcol: 18,
label: "部门",
labelcol: 6,
viewAttr: 2,
},
{
browserConditionParam: {
completeParams: {},
conditionDataParams: {},
dataParams: {},
destDataParams: {},
hasAddBtn: false,
hasAdvanceSerach: false,
idSeparator: ",",
isAutoComplete: 1,
isDetail: 0,
isMultCheckbox: false,
isSingle: true,
icon: "icon-coms-hrm",
linkUrl: "",
pageSize: 10,
quickSearchName: "",
replaceDatas: [],
title: "分部",
type: "164",
viewAttr: 2,
},
colSpan: 1,
conditionType: "BROWSER",
domkey: ["subcompanyId"],
fieldcol: 18,
label: "分部",
labelcol: 6,
viewAttr: 2,
},
{
browserConditionParam: {
completeParams: {},
conditionDataParams: {},
dataParams: {},
destDataParams: {},
hasAddBtn: false,
hasAdvanceSerach: false,
idSeparator: ",",
isAutoComplete: 1,
isDetail: 0,
isMultCheckbox: false,
isSingle: true,
icon: "icon-coms-hrm",
linkUrl: "",
pageSize: 10,
quickSearchName: "",
replaceDatas: [],
title: "岗位",
type: "24",
viewAttr: 2,
},
colSpan: 1,
conditionType: "BROWSER",
domkey: ["jobtitleId"],
fieldcol: 18,
label: "岗位",
labelcol: 6,
viewAttr: 2,
},
// {
// browserConditionParam: {
// completeParams: {},
// conditionDataParams: {},
// dataParams: {},
// destDataParams: {},
// hasAddBtn: false,
// hasAdvanceSerach: false,
// idSeparator: ",",
// isAutoComplete: 1,
// isDetail: 0,
// isMultCheckbox: false,
// isSingle: true,
// icon: "icon-coms-hrm",
// linkUrl: "",
// pageSize: 10,
// quickSearchName: "",
// replaceDatas: [],
// title: "部门",
// type: "57",
// viewAttr: 2,
// },
// colSpan: 1,
// conditionType: "BROWSER",
// domkey: ["departmentId"],
// fieldcol: 18,
// label: "部门",
// labelcol: 6,
// viewAttr: 2,
// },
// {
// browserConditionParam: {
// completeParams: {},
// conditionDataParams: {},
// dataParams: {},
// destDataParams: {},
// hasAddBtn: false,
// hasAdvanceSerach: false,
// idSeparator: ",",
// isAutoComplete: 1,
// isDetail: 0,
// isMultCheckbox: false,
// isSingle: true,
// icon: "icon-coms-hrm",
// linkUrl: "",
// pageSize: 10,
// quickSearchName: "",
// replaceDatas: [],
// title: "分部",
// type: "164",
// viewAttr: 2,
// },
// colSpan: 1,
// conditionType: "BROWSER",
// domkey: ["subcompanyId"],
// fieldcol: 18,
// label: "分部",
// labelcol: 6,
// viewAttr: 2,
// },
// {
// browserConditionParam: {
// completeParams: {},
// conditionDataParams: {},
// dataParams: {},
// destDataParams: {},
// hasAddBtn: false,
// hasAdvanceSerach: false,
// idSeparator: ",",
// isAutoComplete: 1,
// isDetail: 0,
// isMultCheckbox: false,
// isSingle: true,
// icon: "icon-coms-hrm",
// linkUrl: "",
// pageSize: 10,
// quickSearchName: "",
// replaceDatas: [],
// title: "岗位",
// type: "24",
// viewAttr: 2,
// },
// colSpan: 1,
// conditionType: "BROWSER",
// domkey: ["jobtitleId"],
// fieldcol: 18,
// label: "岗位",
// labelcol: 6,
// viewAttr: 2,
// },
{
colSpan: 1,
conditionType: "DATEPICKER",
@ -132,7 +132,7 @@ export const condition = [
{
colSpan: 1,
conditionType: "INPUT",
domkey: ["mobil"],
domkey: ["mobile"],
fieldcol: 18,
label: "手机",
labelcol: 6,
@ -181,5 +181,6 @@ export const condition = [
},
],
defaultshow: true,
title: "基本信息"
},
];

View File

@ -8,9 +8,11 @@ import React, { Component } from "react";
import { inject, observer } from "mobx-react";
import { WeaTab, WeaTop } from "ecCom";
import ExternalPersonManageEditSlide from "./components/externalPersonManageEditSlide";
import { Button } from "antd";
import { Button, message, Modal } from "antd";
import { getSearchs } from "../../util";
import { condition, searchCondition } from "./conditions";
import UnifiedTable from "../../components/UnifiedTable";
import { deleteExtEmp, listPage } from "../../apis/externalPersonManage";
import "./index.less";
@inject("externalPersonManageStore", "taxAgentStore")
@ -19,9 +21,12 @@ class Index extends Component {
constructor(props) {
super(props);
this.state = {
loading: false,
selectedRowKeys: [],
pageInfo: { current: 1, pageSize: 10, total: 0 },
showSearchAd: false,
externalPersonManagePayload: {
visible: false, title: "新建"
visible: false, title: "新建", id: ""
}
};
}
@ -30,33 +35,92 @@ class Index extends Component {
const { externalPersonManageStore: { form, addForm } } = this.props;
form.initFormFields(searchCondition);
addForm.initFormFields(condition);
this.listPage();
}
handleCancel = () => {
listPage = () => {
const { pageInfo } = this.state;
const { externalPersonManageStore: { form } } = this.props;
const payload = { ...pageInfo, ...form.getFormParams() };
listPage(payload).then(({ status, data }) => {
if (status) {
const { list: dataSource, columns, pageNum: current, pageSize, total } = data;
this.setState({
dataSource, columns,
pageInfo: { ...pageInfo, current, pageSize, total }
});
}
});
};
deleteExtEmp = (ids) => {
deleteExtEmp(ids).then(({ status, errormsg }) => {
if (status) {
message.success("删除成功");
this.listPage();
} else {
message.error(errormsg || "删除失败");
}
});
};
handleDelete = (id) => {
Modal.confirm({
title: "信息确认",
content: "确定删除吗",
onOk: () => this.deleteExtEmp([id])
});
};
handleCancel = (isRefresh) => {
const { externalPersonManagePayload } = this.state;
const { externalPersonManageStore: { addForm } } = this.props;
addForm.resetForm();
this.setState({
externalPersonManagePayload: {
...externalPersonManagePayload,
visible: false, title: "新建"
visible: false, title: "新建", id: ""
}
});
}, () => isRefresh && this.listPage());
};
handleAdd = () => {
handleAdd = (id = "") => {
const { externalPersonManagePayload } = this.state;
this.setState({
externalPersonManagePayload: {
...externalPersonManagePayload,
visible: true
visible: true, id, title: id ? "编辑" : "新建"
}
});
};
getColumns = () => {
const { columns } = this.state;
return _.map(_.filter(columns, item => !!item.display), child => ({
...child,
render: (text) => {
return <span className="ellipsis" title={text}>{text}</span>;
}
}));
};
render() {
const { showSearchAd, externalPersonManagePayload } = this.state;
const { showSearchAd, externalPersonManagePayload, loading, pageInfo, selectedRowKeys, dataSource } = this.state;
const { externalPersonManageStore: { form, addForm }, taxAgentStore: { showOperateBtn } } = this.props;
const pagination = {
current: pageInfo.current,
pageSize: pageInfo.pageSize,
total: pageInfo.total,
showTotal: total => `${total}`,
showQuickJumper: true,
showSizeChanger: true,
pageSizeOptions: ["10", "20", "50", "100"],
onShowSizeChange: (current, pageSize) => {
this.setState({ pageInfo: { ...pageInfo, current, pageSize } }, () => this.listPage());
},
onChange: current => {
this.setState({ pageInfo: { ...pageInfo, current } }, () => this.listPage());
}
};
const rowSelection = {
selectedRowKeys,
onChange: selectedRowKeys => this.setState({ selectedRowKeys })
};
return (
<div className="externalPerWrapper">
<WeaTop
@ -65,18 +129,42 @@ class Index extends Component {
>
<div className="externalPerCont">
<WeaTab
buttons={[
<Button type="primary" onClick={this.handleAdd}>新建</Button>
]}
buttons={showOperateBtn ? [
<Button type="primary" onClick={() => this.handleAdd()}>新建</Button>
] : []}
searchType={["base", "advanced"]} showSearchAd={showSearchAd}
setShowSearchAd={(showSearchAd) => this.setState({ showSearchAd })}
searchsAd={getSearchs(form, searchCondition, 2)}
searchsBasePlaceHolder="请输入姓名"
searchsBasePlaceHolder="请输入姓名" onSearch={this.listPage}
onSearchChange={username => form.updateFields({ username })}
searchsBaseValue={form.getFormParams().username}
onAdSearch={() => this.setState({ showSearchAd: false }, () => this.listPage())}
onAdReset={() => form.resetForm()} onAdCancel={() => this.setState({ showSearchAd: false })}
/>
<UnifiedTable
rowKey="id"
loading={loading}
columns={showOperateBtn ? [
...this.getColumns(),
{
dataIndex: "operate",
title: "操作",
render: (_, { id }) => (
<React.Fragment>
<a href="javascript: void(0);" onClick={() => this.handleAdd(id)}
style={{ paddingRight: 8 }}>编辑</a>
<a href="javascript: void(0);" onClick={() => this.handleDelete(id)}>删除</a>
</React.Fragment>
)
}
] : []}
dataSource={dataSource}
pagination={pagination}
rowSelection={rowSelection}
xWidth={this.getColumns().length * 120}
/>
<ExternalPersonManageEditSlide
showOperateBtn={showOperateBtn} form={addForm}
showOperateBtn={showOperateBtn} form={addForm} condition={condition}
onCancel={this.handleCancel} {...externalPersonManagePayload}
/>
</div>