2023-02-24 11:05:52 +08:00
|
|
|
|
/*
|
|
|
|
|
|
* Author: 黎永顺
|
|
|
|
|
|
* name:字段管理
|
|
|
|
|
|
* Description:
|
|
|
|
|
|
* Date: 2023/2/24
|
|
|
|
|
|
*/
|
|
|
|
|
|
import React, { Component } from "react";
|
2023-03-01 10:11:11 +08:00
|
|
|
|
import { WeaCheckbox, WeaTable } from "ecCom";
|
2023-03-02 14:07:36 +08:00
|
|
|
|
import { Col, message, Row } from "antd";
|
2023-03-01 15:23:56 +08:00
|
|
|
|
import AttendanceCustomFieldsModal from "./attendanceCustomFieldsModal";
|
2023-03-02 14:07:36 +08:00
|
|
|
|
import { getAttendanceFieldList, updateAttendanceFieldStatus } from "../../../../apis/attendance";
|
2023-02-24 11:05:52 +08:00
|
|
|
|
import TipLabel from "../../../../components/TipLabel";
|
2023-03-03 16:29:52 +08:00
|
|
|
|
import { fieldsColumns } from "../columns";
|
2023-02-24 11:05:52 +08:00
|
|
|
|
|
|
|
|
|
|
class FieldMangComp extends Component {
|
|
|
|
|
|
constructor(props) {
|
|
|
|
|
|
super(props);
|
|
|
|
|
|
this.state = {
|
|
|
|
|
|
loading: {
|
|
|
|
|
|
query: false
|
|
|
|
|
|
},
|
2023-03-03 16:29:52 +08:00
|
|
|
|
dataSource: [{}],
|
|
|
|
|
|
columns: fieldsColumns,
|
2023-02-24 11:05:52 +08:00
|
|
|
|
pageInfo: {
|
|
|
|
|
|
current: 1,
|
|
|
|
|
|
pageSize: 10,
|
|
|
|
|
|
total: 0
|
2023-03-01 15:23:56 +08:00
|
|
|
|
},
|
|
|
|
|
|
addPayload: {
|
|
|
|
|
|
visible: false,
|
|
|
|
|
|
title: "新建考勤自定义字段"
|
2023-02-24 11:05:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
componentDidMount() {
|
|
|
|
|
|
this.getAttendanceFieldList();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2023-03-01 11:15:28 +08:00
|
|
|
|
getAttendanceFieldList = (extraPayload = {}) => {
|
2023-02-24 11:05:52 +08:00
|
|
|
|
const { loading, pageInfo } = this.state;
|
|
|
|
|
|
const module = { ...pageInfo, ...extraPayload };
|
|
|
|
|
|
this.setState({ loading: { ...loading, query: true } });
|
|
|
|
|
|
getAttendanceFieldList(module).then(({ status, data }) => {
|
|
|
|
|
|
this.setState({ loading: { ...loading, query: false } });
|
|
|
|
|
|
if (status) {
|
2023-03-02 14:07:36 +08:00
|
|
|
|
const { pageInfo: pageInfoData } = data;
|
|
|
|
|
|
const { list: dataSource, columns, pageNum: current, pageSize, total } = pageInfoData;
|
2023-02-24 11:05:52 +08:00
|
|
|
|
this.setState({
|
|
|
|
|
|
pageInfo: { ...pageInfo, current, pageSize, total },
|
2023-03-02 14:07:36 +08:00
|
|
|
|
dataSource, columns
|
2023-02-24 11:05:52 +08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}).catch(() => this.setState({ loading: { ...loading, query: false } }));
|
|
|
|
|
|
};
|
2023-03-01 15:23:56 +08:00
|
|
|
|
handleTriggerAttendFileds = () => {
|
|
|
|
|
|
const { addPayload } = this.state;
|
|
|
|
|
|
this.setState({ addPayload: { ...addPayload, visible: !addPayload.visible } });
|
|
|
|
|
|
};
|
2023-03-02 14:07:36 +08:00
|
|
|
|
handleAttendanceFieldSwitch = ({ id }, enableStatus) => {
|
|
|
|
|
|
const payload = { id, enableStatus: enableStatus === "1" };
|
|
|
|
|
|
updateAttendanceFieldStatus(payload).then(({ status, errormsg }) => {
|
|
|
|
|
|
if (status) {
|
|
|
|
|
|
message.success("操作成功");
|
|
|
|
|
|
this.getAttendanceFieldList();
|
|
|
|
|
|
} else {
|
|
|
|
|
|
message.error(errormsg || "操作失败");
|
|
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
};
|
2023-03-01 10:11:11 +08:00
|
|
|
|
getColumns = () => {
|
2023-03-02 14:07:36 +08:00
|
|
|
|
const { columns } = this.state;
|
2023-03-01 10:11:11 +08:00
|
|
|
|
const { showOperateBtn } = this.props;
|
2023-03-02 14:07:36 +08:00
|
|
|
|
return _.map(_.filter(columns, item => !!item.display), child => ({
|
2023-03-01 10:11:11 +08:00
|
|
|
|
...child,
|
|
|
|
|
|
render: (text, record) => {
|
|
|
|
|
|
switch (child.dataIndex) {
|
|
|
|
|
|
case "enableStatus":
|
|
|
|
|
|
return (
|
|
|
|
|
|
<WeaCheckbox
|
|
|
|
|
|
value={text} display="switch" disabled={!showOperateBtn}
|
2023-03-02 14:07:36 +08:00
|
|
|
|
onChange={value => this.handleAttendanceFieldSwitch(record, value)}
|
2023-03-01 10:11:11 +08:00
|
|
|
|
/>
|
|
|
|
|
|
);
|
|
|
|
|
|
default:
|
|
|
|
|
|
return <div dangerouslySetInnerHTML={{ __html: text }}/>;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}));
|
|
|
|
|
|
};
|
2023-02-24 11:05:52 +08:00
|
|
|
|
|
|
|
|
|
|
render() {
|
2023-03-01 15:23:56 +08:00
|
|
|
|
const { dataSource, pageInfo, loading, addPayload } = this.state;
|
2023-02-24 11:05:52 +08:00
|
|
|
|
const { fieldName } = this.props;
|
|
|
|
|
|
const pagination = {
|
|
|
|
|
|
...pageInfo,
|
|
|
|
|
|
showTotal: total => `共 ${total} 条`,
|
|
|
|
|
|
showQuickJumper: true,
|
2023-03-01 15:23:56 +08:00
|
|
|
|
showSizeChanger: true,
|
2023-02-24 11:05:52 +08:00
|
|
|
|
pageSizeOptions: ["10", "20", "50", "100"],
|
|
|
|
|
|
onShowSizeChange: (current, pageSize) => {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
pageInfo: { ...pageInfo, current, pageSize }
|
|
|
|
|
|
}, () => this.getAttendanceFieldList({ fieldName }));
|
|
|
|
|
|
},
|
|
|
|
|
|
onChange: current => {
|
|
|
|
|
|
this.setState({
|
|
|
|
|
|
pageInfo: { ...pageInfo, current }
|
|
|
|
|
|
}, () => this.getAttendanceFieldList({ fieldName }));
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
return (
|
|
|
|
|
|
<Row gutter={20}>
|
|
|
|
|
|
<Col xs={24} sm={24} md={16} lg={18}>
|
|
|
|
|
|
<WeaTable
|
2023-03-01 10:11:11 +08:00
|
|
|
|
columns={this.getColumns()}
|
2023-02-24 11:05:52 +08:00
|
|
|
|
dataSource={dataSource}
|
|
|
|
|
|
pagination={pagination}
|
|
|
|
|
|
loading={loading.query}
|
|
|
|
|
|
/>
|
2023-03-01 16:28:34 +08:00
|
|
|
|
<AttendanceCustomFieldsModal
|
|
|
|
|
|
{...addPayload} onCancel={this.handleTriggerAttendFileds}
|
|
|
|
|
|
onRefresh={this.getAttendanceFieldList}
|
|
|
|
|
|
/>
|
2023-02-24 11:05:52 +08:00
|
|
|
|
</Col>
|
|
|
|
|
|
<Col xs={24} sm={24} md={8} lg={6}>
|
|
|
|
|
|
<TipLabel
|
|
|
|
|
|
tipList={[
|
|
|
|
|
|
"1、考勤字段包含自定义字段和考勤模块的统计字段,所有字段不可重名;",
|
|
|
|
|
|
"2、停用自定义字段将影响其参与计算的账套核算;"
|
|
|
|
|
|
]}
|
|
|
|
|
|
/>
|
|
|
|
|
|
</Col>
|
|
|
|
|
|
</Row>
|
|
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
export default FieldMangComp;
|