import React, { Fragment, PureComponent } from 'react';
import {
    DeleteOutlined,
    EditOutlined,
    PlusOutlined,
    SearchOutlined,
    RedoOutlined,
    DownOutlined,
    ExclamationCircleFilled,
    UpOutlined,
} from '@ant-design/icons';
import { connect, history } from '@umijs/max';
import { Button, Input, Card, Divider, Dropdown, message, Modal, Popconfirm, Space, Switch, Tag, Row, Col, Table } from 'antd';
import StandardTable from '@/components/StandardTable';

import { MyIcon } from "@/components/Icon"
import style from "@/global.less";
import TimeSheetCreateForm from './form/TimeSheetCreateForm'; //新增表单
import TimeSheetUpdateForm from './form/TimeSheetUpdateForm'; //修改表单
import TimeSheetViewForm from './form/TimeSheetViewForm'; //查看表单
import TimeSheetRenderSimpleForm from './form/TimeSheetRenderSimpleForm'; //简单查询表单
import TimeSheetRenderAdvancedForm from './form/TimeSheetRenderAdvancedForm'; //高级查询表单
import styles from './TimeSheetList.less';
import datadictionary from "@/utils/dataDictionary";
import { formatDate } from "@/utils/formatUtils";
import { formatDictText, checkButtonAuthority } from "@/utils/globalCommon"
import { request } from '@umijs/max';;

const { confirm } = Modal;

//预约类型
const sex_type = datadictionary.sex
const user_status = datadictionary.user_status
const sys_user_post = datadictionary.sys_user_post

const mockData = {
    list: [
        {
            ygh: "A00001",
            xm: "员工1",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A00002",
            xm: "员工2",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A00003",
            xm: "员工3",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A00004",
            xm: "员工4",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A00005",
            xm: "员工5",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A00006",
            xm: "员工6",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A00007",
            xm: "员工7",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A00008",
            xm: "员工8",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A00009",
            xm: "员工9",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A000010",
            xm: "员工10",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A000011",
            xm: "员工11",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A000012",
            xm: "员工12",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A000013",
            xm: "员工13",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A000014",
            xm: "员工14",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A000015",
            xm: "员工15",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A000016",
            xm: "员工16",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A000017",
            xm: "员工17",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        },
        {
            ygh: "A000018",
            xm: "员工18",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "康复科",
            kqsc: 8,
            zysc: 8,
            kxsc: 0,
        },
        {
            ygh: "A000019",
            xm: "员工19",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心内科",
            kqsc: 8,
            zysc: 7,
            kxsc: 1,
        },
        {
            ygh: "A000020",
            xm: "员工20",
            rq: "2025/6/10",
            dw: "清河中医院",
            bm: "心外科",
            kqsc: 8,
            zysc: 6,
            kxsc: 2,
        }
    ],
    pagination: {},
}
@connect(({ timesheet, globaldata, loading }) => ({
    timesheet,
    globaldata,
    loading: loading.models.timesheet,
}))

class TimeSheetList extends PureComponent {
    state = {
        modalVisible: false,
        updateModalVisible: false,
        viewModalVisible: false,
        expandForm: false,
        selectedRows: [],
        formValues: {},
        updateFormValues: {},
        viewFormValues: {},
        toggleExpand: false,
        // 应用的修改记录
        appliedChanges: [],
        // 文档对照数据 - 默认为空数组，避免显示默认内容
        documentComparisonData: []
    }

    columns = [
        {
            title: '序号',
            dataIndex: 'index',
            key: 'index',
            width: 50,
            fixed: 'left',
            render: (_, record, index) => index + 1,
        },
        {
            title: '员工号',
            dataIndex: 'ygh',
            key: 'ygh',
            width: 100,
            fixed: 'left',
        }, {
            title: '姓名',
            dataIndex: 'xm',
            key: 'xm',
            width: 100,
            fixed: 'left',
        }, {
            title: '日期',
            dataIndex: 'rq',
            key: 'rq',
            width: 100,
        }, {
            title: '单位',
            dataIndex: 'dw',
            key: 'dw',
            width: 150,
        }, {
            title: '部门',
            dataIndex: 'bm',
            key: 'bm',
            width: 150,
        }, {
            title: '考勤时长',
            dataIndex: 'kqsc',
            key: 'kqsc',
            width: 100,
        }, {
            title: '作业时长',
            dataIndex: 'zysc',
            key: 'zysc',
            width: 100,
        },
        {
            title: '空闲时长',
            dataIndex: 'kxsc',
            key: 'kxsc',
            width: 100,
        },
        {
            title: '比例图',
            dataIndex: 'blt',
            key: 'blt',
            width: 150,
            render: (text, record) => {
                let workRatio = record.zysc / (record.zysc + record.kxsc) * 100
                return (
                    <Fragment>
                        <div style={{ display: 'flex' }}>
                            <div style={{ height: 30, width: workRatio + '%', background: "#8ddd15" }}></div>
                            <div style={{ height: 30, width: 100 - workRatio + '%', background: "#cccccc" }}></div>
                        </div>
                    </Fragment>
                )
            },
        },
    ]

    componentDidMount() {
        // const { dispatch, timesheet: { params } } = this.props

        // dispatch({
        //     type: 'timesheet/query_page_for_prouser',
        // })

        // this.setState({
        //     expandForm: params?.expandForm || false,
        // })
        
        // 检查localStorage中是否有上次保存的文档修改数据
        const savedDocumentData = localStorage.getItem('document_update_data');
        if (savedDocumentData) {
            try {
                const parsedData = JSON.parse(savedDocumentData);
                this.setState({
                    documentComparisonData: parsedData
                });
                console.log('已从本地加载文档修改数据');
            } catch (error) {
                console.error('解析本地保存的文档修改数据失败:', error);
            }
        }
    }

    // 监听全局状态变化，同步文档审阅数据
    componentDidUpdate(prevProps) {
        const { globaldata } = this.props;
        // 检查全局状态中的文档审阅数据是否发生变化
        if (globaldata.documentReviewData && globaldata.documentReviewData !== prevProps.globaldata.documentReviewData) {
            try {
                // 解析文档审阅数据
                const reviewData = JSON.parse(globaldata.documentReviewData.data);
                // 转换为documentComparisonData所需的格式
                const comparisonData = reviewData.map(item => ({
                    original: item.context || '无原文',
                    modified: item.update || item.context || '无内容'
                }));
                
                // 更新组件状态
                this.setState({
                    documentComparisonData: comparisonData
                }, () => {
                    // 保存到localStorage
                    localStorage.setItem('document_update_data', JSON.stringify(comparisonData));
                    console.log('已从文档审阅页面同步数据并保存到本地:', comparisonData);
                    message.success('文档内容已从审阅页面更新');
                });
            } catch (error) {
                console.error('解析文档审阅数据失败:', error);
                message.error('同步文档数据失败');
            }
        }
    }

    handleStandardTableChange = (pagination, sorter) => {
        const { dispatch } = this.props
        const { formValues } = this.state

        const params = {
            currentPage: pagination.current,
            pageSize: pagination.pageSize,
            ...formValues
        }

        sorter.field && (params.sorter = `${sorter.field}_${sorter.order}`)

        // dispatch({
        //     type: 'prouser/query_page_for_prouser',
        //     payload: params
        // })
    }

    handleFormReset = () => {
        const { dispatch } = this.props
        this.setState({
            formValues: {}
        })

        // dispatch({
        //     type: 'prouser/query_page_for_prouser',
        //     payload: {
        //         resetFlag: true
        //     }
        // })
    }

    toggleForm = () => {
        const { expandForm } = this.state
        this.setState({
            expandForm: !expandForm
        })
    }

    handleSelectRows = rows => {
        this.setState({
            selectedRows: rows
        })
    }

    handleSearch = values => {
        const { dispatch } = this.props
        const { expandForm } = this.state

        this.setState({
            formValues: values
        })

        // dispatch({
        //     type: 'prouser/query_page_for_prouser',
        //     payload: {
        //         ...values,
        //         resetFlag: true,
        //         expandForm
        //     }
        // })
    }

    handleModalVisible = flag => {
        this.setState({
            modalVisible: !!flag
        })
    }

    handleUpdateModalVisible = (flag, record) => {
        this.setState({
            updateModalVisible: !!flag,
            updateFormValues: record || {}
        })
    }

    handleViewModalVisible = (flag, record) => {
        this.setState({
            viewModalVisible: !!flag,
            viewFormValues: record || {}
        })
    }

    handleAdd = fields => {
        const { dispatch } = this.props

        dispatch({
            type: 'prouser/insert_for_prouser',
            payload: {
                user_id: fields.user_id,
                user_name: fields.user_name,
                user_name_cn: fields.user_name_cn,
                user_name_en: fields.user_name_en,
                password: fields.password,
                email: fields.email,
                phone: fields.phone,
                landline: fields.landline,
                sex: fields.sex,
                avatar: fields.avatar,
                sign: fields.sign,
                tags: fields.tags,
                id_card: fields.id_card,
                birthday: fields.birthday,
                job_status: fields.job_status,
                hiredate: fields.hiredate,
                departure_time: fields.departure_time,
                user_type: fields.user_type,
                emp_no: fields.emp_no,
                access_card_no: fields.access_card_no,
                country: fields.country,
                province: fields.province,
                city: fields.city,
                address: fields.address,
                work_addr: fields.work_addr,
                floor: fields.floor,
                inprovince: fields.inprovince,
                // dept_code: fields.dept_code,
                // dept_name: fields.dept_name,
                inner_dept_code: fields.inner_dept_code,
                org_code: fields.org_code,
                org_name: fields.org_name,
                inner_org_code: fields.inner_org_code,
                posts: fields.posts,
                wx_openid: fields.wx_openid,
                wx_mpopenid: fields.wx_mpopenid,
                wx_miniopenid: fields.wx_miniopenid,
                wx_unionid: fields.wx_unionid,
                mobile_imei: fields.mobile_imei,
                device_num: fields.device_num,
                al_taobao: fields.al_taobao,
                al_alipay: fields.al_alipay,
                al_dingding: fields.al_dingding,
                is_system_user: fields.is_system_user,
                mgr_type: fields.mgr_type,
                pwd_security_level: fields.pwd_security_level,
                pwd_update_date: fields.pwd_update_date,
                last_login_ip: fields.last_login_ip,
                last_login_date: fields.last_login_date,
                freeze_date: fields.freeze_date,
                freeze_cause: fields.freeze_cause,
                zindex: fields.zindex,
                wx_msg: fields.wx_msg,
                email_msg: fields.email_msg,
                system_msg: fields.system_msg,
                remarks: fields.remarks,
                status: fields.status,
                creator: fields.creator,
                create_date: fields.create_date,
                updater: fields.updater,
                update_date: fields.update_date
            },
            callback: (res) => {
                if (res.success == true) {
                    message.success('添加成功')
                    this.handleModalVisible()
                }
            }
        })
    }

    handleDeleteRecord = record => {
        const { dispatch } = this.props

        dispatch({
            type: 'prouser/delete_by_primarykey_for_prouser',
            payload: {
                recordid: record.user_id
            },
            callback: res => {
                if (res.success) {
                    message.success('删除成功')

                    this.setState({
                        selectedRows: []
                    })
                }
            }
        })
    }

    handleUpdate = fields => {
        const { dispatch } = this.props

        dispatch({
            type: 'prouser/update_for_prouser',
            payload: {
                user_id: fields.user_id,
                user_name: fields.user_name,
                user_name_cn: fields.user_name_cn,
                user_name_en: fields.user_name_en,
                password: fields.password,
                email: fields.email,
                phone: fields.phone,
                landline: fields.landline,
                sex: fields.sex,
                avatar: fields.avatar,
                sign: fields.sign,
                tags: fields.tags,
                id_card: fields.id_card,
                birthday: fields.birthday,
                job_status: fields.job_status,
                hiredate: fields.hiredate,
                departure_time: fields.departure_time,
                user_type: fields.user_type,
                emp_no: fields.emp_no,
                access_card_no: fields.access_card_no,
                country: fields.country,
                province: fields.province,
                city: fields.city,
                address: fields.address,
                work_addr: fields.work_addr,
                floor: fields.floor,
                inprovince: fields.inprovince,
                // dept_code: fields.dept_code,
                // dept_name: fields.dept_name,
                inner_dept_code: fields.inner_dept_code,
                org_code: fields.org_code,
                org_name: fields.org_name,
                inner_org_code: fields.inner_org_code,
                posts: fields.posts,
                wx_openid: fields.wx_openid,
                wx_mpopenid: fields.wx_mpopenid,
                wx_miniopenid: fields.wx_miniopenid,
                wx_unionid: fields.wx_unionid,
                mobile_imei: fields.mobile_imei,
                device_num: fields.device_num,
                al_taobao: fields.al_taobao,
                al_alipay: fields.al_alipay,
                al_dingding: fields.al_dingding,
                is_system_user: fields.is_system_user,
                mgr_type: fields.mgr_type,
                pwd_security_level: fields.pwd_security_level,
                pwd_update_date: fields.pwd_update_date,
                last_login_ip: fields.last_login_ip,
                last_login_date: fields.last_login_date,
                freeze_date: fields.freeze_date,
                freeze_cause: fields.freeze_cause,
                zindex: fields.zindex,
                wx_msg: fields.wx_msg,
                email_msg: fields.email_msg,
                system_msg: fields.system_msg,
                remarks: fields.remarks,
                status: fields.status,
                creator: fields.creator,
                create_date: fields.create_date,
                updater: fields.updater,
                update_date: fields.update_date
            },
            callback: (res) => {
                if (res.success === true) {
                    message.success('修改成功')
                    this.handleUpdateModalVisible()
                }
            }
        })
    }

    // 修改用户状态
    handleUpdateUserStatus = (fields, status, msg) => {
        const { dispatch } = this.props

        confirm({
            title: `确定要 ${msg} 当前用户的吗?`,
            icon: <ExclamationCircleFilled />,
            onOk() {
                dispatch({
                    type: 'prouser/update_for_prouser',
                    payload: {
                        user_id: fields.user_id,
                        status: status,
                    },
                    callback: (res) => {
                        if (res.success === true) {
                            message.success('修改成功')
                        }
                    }
                })
            }
        })
    }

    // 修改用户密码
    handleUpdateUserPassword = fields => {
        const { dispatch } = this.props
        confirm({
            title: '确定要重置当前用户的密码吗?',
            icon: <ExclamationCircleFilled />,
            onOk() {
                dispatch({
                    type: 'prouser/resetpwd_for_prouser',
                    payload: {
                        user_id: fields.user_id
                    },
                    callback: (res) => {
                        if (res.success === true) {
                            message.success('重置成功')
                        }
                    }
                })
            }
        })
    }

    renderSimpleForm() {
        const { timesheet: { params } } = this.props
        const parentMethods = {
            handleSearch: this.handleSearch,
            handleFormReset: this.handleFormReset,
            toggleForm: this.toggleForm,
            params
        }

        return <TimeSheetRenderSimpleForm {...parentMethods} />
    }

    renderAdvancedForm() {
        const { dispatch, prouser: { selectDeptTree, selectOrganTree, params } } = this.props
        const parentMethods = {
            handleSearch: this.handleSearch,
            handleFormReset: this.handleFormReset,
            toggleForm: this.toggleForm,
            dispatch: dispatch,
            selectDeptTree: selectDeptTree,
            selectOrganTree: selectOrganTree,
            params
        }

        return <TimeSheetRenderAdvancedForm {...parentMethods} />
    }

    renderForm() {
        const { expandForm } = this.state
        return expandForm ? this.renderAdvancedForm() : this.renderSimpleForm()
    }

    handleCollapse = () => {
        const { toggleExpand } = this.state
        this.setState({
            toggleExpand: !toggleExpand
        })
    }

    // 处理单个修改的应用
    handleApplyChange = async (item) => {
        // 创建要发送的数据结构
        const requestData = {
            content: [{
                oldContent: item.original,
                newContent: item.modified
            }]
        };
        
        try {
            // 调用API - 使用代理解决跨域问题
            const response = await request('/api/doc/applymodify', {
                method: 'POST',
                data: requestData
            });
            
            // 如果API调用成功，更新状态
            this.setState(prevState => {
                // 创建一个新的修改记录对象
                const newChange = {
                    originalText: item.original,
                    modifiedText: item.modified,
                    appliedAt: new Date().toLocaleString()
                };
                
                // 添加到已应用的修改数组
                const updatedAppliedChanges = [...prevState.appliedChanges, newChange];
                
                return {
                    appliedChanges: updatedAppliedChanges
                };
            });
            
            // 显示成功消息
            message.success('修改已应用');
            console.log('API调用成功，响应数据:', response);
        } catch (error) {
            // 处理错误
            console.error('API调用失败:', error);
            message.error('应用修改失败，请重试');
        }
    }

    // 处理原文档下载
    handleDownloadOriginalDocument = () => {
        try {
            // 使用 window.open 打开下载链接，让浏览器处理文件下载
            window.open('/api/download', '_blank');
            console.log('开始下载原文档');
        } catch (error) {
            console.error('下载原文档失败:', error);
            message.error('下载失败，请重试');
        }
    }

    // 处理所有修改的应用
    handleApplyAllChanges = async () => {
        const { documentComparisonData } = this.state;
        
        // 筛选出所有有差异的句子
        const changesToApply = documentComparisonData.filter(item => item.original !== item.modified);
        
        if (changesToApply.length === 0) {
            message.info('没有需要应用的修改');
            return;
        }
        
        // 创建要发送的数据结构
        const requestData = {
            content: changesToApply.map(item => ({
                oldContent: item.original,
                newContent: item.modified
            }))
        };
        
        try {
            // 调用API - 使用代理解决跨域问题
            const response = await request('/api/doc/applymodify', {
                method: 'POST',
                data: requestData
            });
            
            // 创建新的修改记录数组
            const newAppliedChanges = changesToApply.map(item => ({
                originalText: item.original,
                modifiedText: item.modified,
                appliedAt: new Date().toLocaleString()
            }));
            
            this.setState({
                appliedChanges: newAppliedChanges
            }, () => {
                // 输出应用的修改到控制台
                console.log('应用的所有修改:', this.state.appliedChanges);
                message.success(`成功应用了 ${changesToApply.length} 处修改`);
                
                // 保存当前文档比较数据到localStorage
                localStorage.setItem('document_update_data', JSON.stringify(this.state.documentComparisonData));
                console.log('已保存文档修改数据到本地');
            });
            
            console.log('API调用成功，响应数据:', response);
        } catch (error) {
            // 处理错误
            console.error('API调用失败:', error);
            message.error('应用修改失败，请重试');
        }
    }

    render() {
        const {
            timesheet: {
                data,
                selectDeptTree,
                selectOrganTree
            },
            loading,
            dispatch
        } = this.props
        const {
            selectedRows,
            modalVisible,
            updateModalVisible,
            viewModalVisible,
            updateFormValues,
            viewFormValues,
            toggleExpand
        } = this.state

        const parentMethods = {
            handleAdd: this.handleAdd,
            handleModalVisible: this.handleModalVisible,
            dispatch: dispatch,
            loading,
            selectDeptTree: selectDeptTree,
            selectOrganTree: selectOrganTree
        }

        const updateMethods = {
            handleUpdateModalVisible: this.handleUpdateModalVisible,
            handleUpdate: this.handleUpdate,
            dispatch: dispatch,
            loading,
            selectDeptTree: selectDeptTree,
            selectOrganTree: selectOrganTree
        }

        const viewMethods = {
            handleViewModalVisible: this.handleViewModalVisible
        }

        return (
            <>
                <Card bordered={false} style={{ height: '100vh' }}>
                    <div style={{ padding: '15px', border: '1px solid #ddd', borderRadius: 5, marginBottom: 15 }}>
                        <h2 style={{ fontWeight: 600 }}>文档修改</h2>
                        <div className={styles.documentUploadSection}>
                            <Button type='primary' htmlType='submit' style={{ background: '#4CAF50' }} onClick={this.handleApplyAllChanges}>
                                应用所有修改
                            </Button>
                            <Button type='primary' htmlType='submit' onClick={this.handleDownloadOriginalDocument}>
                                下载修改后的文档
                            </Button>
                        </div>
                    </div>
                    {/* 对照文本框区域 */}
                    <div style={{ marginTop: '20px' }}>
                        <h3 style={{ marginBottom: '15px', fontWeight: 600 }}>文档内容对照</h3>
                        <Row gutter={[16, 16]}>
                            <Col span={12}>
                                <div style={{ background: '#f5f5f5', padding: '10px', borderRadius: '5px', fontWeight: 500 }}>
                                    原文内容
                                </div>
                            </Col>
                            <Col span={12}>
                                <div style={{ background: '#f5f5f5', padding: '10px', borderRadius: '5px', fontWeight: 500 }}>
                                    修改后内容
                                </div>
                            </Col>
                        </Row>

                        {/* 对照内容数组 */}
                        {this.state.documentComparisonData.length > 0 ? (
                            this.state.documentComparisonData.map((item, index) => (
                                <Row key={index} gutter={[16, 8]} style={{ marginTop: '8px' }}>
                                    <Col span={12}>
                                        <div
                                        style={{
                                            padding: '10px',
                                            border: '1px solid #ddd',
                                            borderRadius: '5px',
                                            background: item.original !== item.modified ? '#ffebee' : 'white'
                                        }}
                                    >
                                            {item.original}
                                        </div>
                                    </Col>
                                    <Col span={12}>
                                        <div
                                        style={{
                                            padding: '10px',
                                            border: '1px solid #ddd',
                                            borderRadius: '5px',
                                            background: item.original !== item.modified ? '#e8f5e9' : 'white',
                                            display: 'flex',
                                            justifyContent: 'space-between',
                                            alignItems: 'center'
                                        }}
                                    >
                                        <div>{item.modified}</div>
                                        {item.original !== item.modified && (
                                            <Button 
                                                size="small" 
                                                type="primary" 
                                                style={{background: '#4CAF50'}} 
                                                onClick={() => this.handleApplyChange(item)}
                                            >
                                                应用修改
                                            </Button>
                                        )}
                                    </div>
                                    </Col>
                                </Row>
                            ))
                        ) : (
                            <div style={{ 
                                padding: '40px 0', 
                                textAlign: 'center', 
                                color: '#999',
                                backgroundColor: '#f5f5f5',
                                borderRadius: '5px',
                                border: '1px solid #ddd'
                            }}>
                                未上传文档，请先上传文档！
                            </div>
                        )}
                    </div>

                    {/* <div className={styles.proUsertableList}>
                        <div className={styles.proUsertableListForm}>{this.renderForm()}</div>
                        <div style={{ fontWeight: 500 }}>汇总信息</div>
                        <Divider style={{ borderColor: '#cccccc', margin: 0 }}>
                            <div className={styles.summaryButton} onClick={() => this.handleCollapse()}>
                                {toggleExpand ? <><UpOutlined /> 收起</> : <><DownOutlined /> 展开</>}
                            </div>
                        </Divider>
                        <div style={{ display: toggleExpand ? 'block' : 'none' }}>
                            <Row gutter={{ md: 8, lg: 24, xl: 48 }} className={styles.summaryContent}>
                                <Col md={5} sm={24}>
                                    <div>
                                        <span>单位: </span>
                                        <span>清河中医院</span>
                                    </div>
                                </Col>

                                <Col md={5} sm={24}>
                                    <span>部门: </span>
                                    <span>心内科</span>
                                </Col>

                                <Col md={5} sm={24}>
                                    <div>
                                        <span>总人数: </span>
                                        <span>300</span>
                                    </div>
                                </Col>
                            </Row>
                            <Row gutter={{ md: 8, lg: 24, xl: 48 }} className={styles.summaryContent}>
                                <Col md={5} sm={24}>
                                    <span>总作业数量: </span>
                                    <span>600</span>
                                </Col>

                                <Col md={5} sm={24}>
                                    <span>总考勤工时: </span>
                                    <span>2300</span>
                                </Col>

                                <Col md={5} sm={24}>
                                    <span>总作业工时: </span>
                                    <span>2000</span>
                                </Col>
                                <Col md={5} sm={24}>
                                    <span>总空闲工时: </span>
                                    <span>200</span>
                                </Col>
                            </Row>
                            <Row gutter={{ md: 8, lg: 24, xl: 48 }} className={styles.summaryContent}>
                                <Col md={5} sm={24}>
                                    <span>直接作业占比: </span>
                                    <span>86.96%</span>
                                </Col>

                                <Col md={5} sm={24}>
                                    <span>空闲工时占比: </span>
                                    <span>13.04%</span>
                                </Col>
                            </Row>
                        </div>
                        <div style={{ display: 'flex', justifyContent: "space-between" }}>
                            <div>共20项</div>
                            <div style={{ marginRight: 30 }}>
                                图例：
                                <div style={{ display: 'inline-block', width: 65, height: 20, textAlign: 'center', background: '#8ddd15' }}>作业时长</div>
                                <div style={{ display: 'inline-block', width: 65, height: 20, textAlign: 'center', background: '#cccccc', }}>空闲时长</div>
                            </div>
                        </div>
                        <StandardTable
                            rowKey={'user_id'}
                            selectedRows={selectedRows}
                            loading={loading}
                            data={mockData}
                            columns={this.columns}
                            onSelectRow={this.handleSelectRows}
                            onChange={this.handleStandardTableChange}
                            scroll={{ x: 1000, y: 600 }}
                            showTotal={(total, range) => total}
                        />
                    </div> */}
                </Card>

                {modalVisible && <TimeSheetCreateForm {...parentMethods} modalVisible={modalVisible} />}

                {updateFormValues && Object.keys(updateFormValues).length ? (
                    <TimeSheetUpdateForm
                        {...updateMethods}
                        updateModalVisible={updateModalVisible}
                        values={updateFormValues}
                    />
                ) : null}

                {viewFormValues && Object.keys(viewFormValues).length ? (
                    <TimeSheetViewForm
                        {...viewMethods}
                        viewModalVisible={viewModalVisible}
                        values={viewFormValues}
                    />
                ) : null}
            </>
        )
    }
}

export default TimeSheetList
