From c902c32140bba03d4106d4306c098c3c048be19e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=8E=E6=B0=B8=E9=A1=BA?= <971387674@qq.com> Date: Thu, 2 Mar 2023 14:07:36 +0800 Subject: [PATCH] =?UTF-8?q?=E8=80=83=E5=8B=A4=E5=BC=95=E7=94=A8=E6=A8=A1?= =?UTF-8?q?=E5=9D=97=E9=A1=B5=E9=9D=A2=E9=87=8D=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/attendanceDataComp.js | 37 +++++++++++++++++-- .../attendance/components/fieldMangComp.js | 32 +++++++++------- .../pages/dataAcquisition/attendance/index.js | 5 +-- pc4mobx/hrmSalary/stores/attendanceStore.js | 4 +- 4 files changed, 55 insertions(+), 23 deletions(-) diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataComp.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataComp.js index 89b28cdf..9f3d4a43 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataComp.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/attendanceDataComp.js @@ -6,7 +6,9 @@ */ import React, { Component } from "react"; import { WeaTable } from "ecCom"; -import { getAttendanceList } from "../../../../apis/attendance"; +import { message, Modal } from "antd"; +import { deleteAttendance, getAttendanceList } from "../../../../apis/attendance"; +import moment from "moment"; class AttendanceDataComp extends Component { constructor(props) { @@ -40,11 +42,35 @@ class AttendanceDataComp extends Component { this.setState({ pageInfo: { ...pageInfo, current, pageSize, total }, dataSource, - columns + columns: _.map(columns, item => { + if (item.dataIndex === "salaryYearMonth") { + return { + ...item, + render: (text) => {moment(text).format("YYYY-MM")} + }; + } + return { ...item }; + }) }); } }).catch(() => this.setState({ loading: { ...loading, query: false } })); }; + handleDeleteAttendanceData = ({ id }) => { + Modal.confirm({ + title: "信息确认", + content: "确认要删除吗?", + onOk: () => { + deleteAttendance([id]).then(({ status, errormsg }) => { + if (status) { + message.success("删除成功"); + this.getAttendanceList(); + } else { + message.error(errormsg || "删除失败"); + } + }); + } + }); + }; render() { const { dataSource, columns, pageInfo, loading } = this.state; @@ -53,6 +79,7 @@ class AttendanceDataComp extends Component { ...pageInfo, showTotal: total => `共 ${total} 条`, showQuickJumper: true, + showSizeChanger: true, pageSizeOptions: ["10", "20", "50", "100"], onShowSizeChange: (current, pageSize) => { this.setState({ @@ -73,11 +100,13 @@ class AttendanceDataComp extends Component { title: "操作", width: 120, dataIndex: "operate", - render: (text, record) => { + render: (_, record) => { return (
); } diff --git a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/fieldMangComp.js b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/fieldMangComp.js index 487a0775..9a1cb904 100644 --- a/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/fieldMangComp.js +++ b/pc4mobx/hrmSalary/pages/dataAcquisition/attendance/components/fieldMangComp.js @@ -5,11 +5,10 @@ * Date: 2023/2/24 */ import React, { Component } from "react"; -import { toJS } from "mobx"; import { WeaCheckbox, WeaTable } from "ecCom"; -import { Col, Row } from "antd"; +import { Col, message, Row } from "antd"; import AttendanceCustomFieldsModal from "./attendanceCustomFieldsModal"; -import { getAttendanceFieldList } from "../../../../apis/attendance"; +import { getAttendanceFieldList, updateAttendanceFieldStatus } from "../../../../apis/attendance"; import TipLabel from "../../../../components/TipLabel"; class FieldMangComp extends Component { @@ -38,20 +37,17 @@ class FieldMangComp extends Component { } getAttendanceFieldList = (extraPayload = {}) => { - const { fieldTableStore } = this.props; 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) { - const { dataKey, pageInfo: pageInfoData } = data; - const { datas } = dataKey; - const { list: dataSource, pageNum: current, pageSize, total } = pageInfoData; - fieldTableStore.getDatas(datas); + const { pageInfo: pageInfoData } = data; + const { list: dataSource, columns, pageNum: current, pageSize, total } = pageInfoData; this.setState({ pageInfo: { ...pageInfo, current, pageSize, total }, - dataSource + dataSource, columns }); } }).catch(() => this.setState({ loading: { ...loading, query: false } })); @@ -60,9 +56,21 @@ class FieldMangComp extends Component { const { addPayload } = this.state; this.setState({ addPayload: { ...addPayload, visible: !addPayload.visible } }); }; + handleAttendanceFieldSwitch = ({ id }, enableStatus) => { + const payload = { id, enableStatus: enableStatus === "1" }; + updateAttendanceFieldStatus(payload).then(({ status, errormsg }) => { + if (status) { + message.success("操作成功"); + this.getAttendanceFieldList(); + } else { + message.error(errormsg || "操作失败"); + } + }); + }; getColumns = () => { + const { columns } = this.state; const { showOperateBtn } = this.props; - return _.map(_.filter(toJS(this.props.fieldTableStore.columns), item => !!item.hide), child => ({ + return _.map(_.filter(columns, item => !!item.display), child => ({ ...child, render: (text, record) => { switch (child.dataIndex) { @@ -70,9 +78,7 @@ class FieldMangComp extends Component { return (