// import { useState } from 'react'
import { Button, Form, Upload, message, } from "antd"
import { uploadFileUrl } from '../../../../request/request'
import { UploadOutlined } from '@ant-design/icons';
import './edit-app-files.css'
export default function EditAppFiles(props: any) {
    const token = sessionStorage.getItem('token')
    const height = window.innerHeight - 460;
    const [form] = Form.useForm();
    const handleSubmit = () => {
        // console.log(form);
        props.setEditProcess(4);
        // 调用表单实例的 submit 方法
        form.submit();

    };
    const submitInfo = (values: any) => {
        message.success('提交成功');
        console.log(values);
        props.setEditProcess(3);


    }
    const onFinish = (values: any) => {
        // 处理表单提交逻辑
        console.log('表单提交成功', values);
        submitInfo(values)
    };
    return (
        <div>
            <div className='bigLine'></div>
            <div className='appInfoFormBox' style={{
                height: height,
                justifyContent: 'flex-start',
                flexDirection: 'column',
                marginLeft: '100px',
                paddingBottom: '0'
            }}>
                <div style={{
                    height: '80px',
                }}>
                    <Form form={form} onFinish={onFinish}
                        onFinishFailed={() => {
                            message.error('请完善信息')
                        }}
                    >
                        <div style={{
                            display: 'flex',
                            justifyContent: 'space-between',
                            width: '600px',
                            // background: 'pink'
                        }}>
                            <div className='appInfoFormInput' style={{
                                position: 'relative',
                            }}>
                                <div className='FormInputTitle' style={{
                                }}>源码文档：</div>
                                <div style={{
                                    maxWidth: '200px',
                                }}>
                                    <Form.Item name="ym" label="" rules={[{ required: true, message: '请选上传文件' },
                                        // { validator: validateFileUpload }
                                    ]}>
                                        <Upload
                                            name="file"
                                            action={uploadFileUrl()}
                                            // onChange={handleUploadChange}
                                            headers={{ 'Auth': `Bearer ${token}` }}
                                        >
                                            <Button icon={<UploadOutlined />} style={{
                                                marginTop: '4px'
                                            }}>上传附件</Button>
                                        </Upload>
                                    </Form.Item>
                                </div>
                                <a style={{
                                    position: 'absolute',
                                    top: '10px',
                                    left: '240px',
                                    textWrap: 'nowrap'
                                }}>[ 下载 ]</a>
                            </div>
                            <div className='appInfoFormInput' style={{
                                position: 'relative',
                            }}>
                                <div className='FormInputTitle' style={{
                                }}>软件文档：</div>
                                <div style={{
                                    maxWidth: '200px',
                                }}>
                                    <Form.Item name="file" label="" rules={[{ required: true, message: '请上传文件' },
                                        // { validator: validateFileUpload }
                                    ]}>
                                        <Upload
                                            name="file"
                                            action={uploadFileUrl()}
                                            // onChange={handleUploadChange}
                                            headers={{ 'Auth': `Bearer ${token}` }}

                                        >
                                            <Button icon={<UploadOutlined />} style={{
                                                marginTop: '4px'
                                            }}>上传附件</Button>
                                        </Upload>
                                    </Form.Item>
                                </div>
                                <a style={{
                                    position: 'absolute',
                                    top: '10px',
                                    left: '240px',
                                    textWrap: 'nowrap'
                                }}>[ 下载 ]</a>
                            </div>
                        </div>



                    </Form>
                </div>
                <div className="fileTextBox">
                    {/* 循环100次 */}
                    {Array.from({ length: 100 }).map((_, index) => (
                        <span style={{
                            lineHeight: '30px',
                            fontSize: '14px',
                        }}

                            key={index}>
                            说明:1嘻嘻嘻啊司机大佬觉得拉家带口垃圾狄拉克
                        </span>
                    ))}

                </div>
            </div>

            <div className='bigLine'></div>
            <div className='nextBtnBxo'>
                <Button
                    style={{
                        width: '235px',
                        height: '46px',
                        borderRadius: '5px',
                    }}
                    onClick={() => {
                        props.setEditProcess(2)
                    }}>上一步</Button>
                <Button
                    style={{
                        width: '235px',
                        height: '46px',
                        borderRadius: '5px',
                        marginLeft: '10px',
                    }}
                    type='primary'
                    onClick={() => {
                        handleSubmit()
                    }}>下一步</Button>

            </div>
        </div>
    )
}
