// 同步检查项目的悬浮框 
import { ProForm, ProFormDateTimePicker, ProFormDigit, ProFormSelect, ProFormText, ProFormTimePicker } from "@ant-design/pro-components";
import { Col, FormInstance, Modal, Row } from "antd";
import moment from "moment";
import { useRef } from "react";
import { connect } from "umi";

type DetailProps = {
    onRef: any,
    onShow: boolean,
    setOnShow: (value: boolean) => void
    handleGetNewProjectData: (formRef: any) => void
    pageDataType: number // 页面类型  1000 是日常巡检  3000 是现场巡检
}

const AddInspectionItems = ({ onRef, onShow, setOnShow, handleGetNewProjectData, pageDataType }: DetailProps) => {
    const AddInspectionItemsFormRef = useRef<FormInstance>();


    return (
        <div>
            <Modal
                title={'同步检查项目'}
                destroyOnClose
                width={1200}
                open={onShow}
                onCancel={() => {
                    setOnShow(false)
                }}
                onOk={async () => { // 提交框内的数据
                    AddInspectionItemsFormRef.current?.validateFields().then((res: any) => {
                        console.log('resdasa', res);

                        if (handleGetNewProjectData) {
                            handleGetNewProjectData({
                                ...res,
                                INSPECTION_STARTTIME: res.INSPECTION_STARTTIME ? moment(res.INSPECTION_STARTTIME).format('YYYY-MM-DD HH:mm:ss') : "",
                                INSPECTION_ENDTIME: res.INSPECTION_ENDTIME ? moment(res.INSPECTION_ENDTIME).format('YYYY-MM-DD HH:mm:ss') : ""
                            })
                        }
                    })
                    setOnShow(false)
                }}
            >
                <ProForm
                    formRef={AddInspectionItemsFormRef}
                    submitter={false}
                    layout={'horizontal'}
                    labelCol={{ style: { width: 120 } }}
                >
                    <Row gutter={8}>
                        <Col span={8}>
                            <ProFormText
                                label={'巡检项目'}
                                name={'PATROL_POSITION'}
                                rules={[{ required: true, message: '请输入巡检项目!' }]}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                label={'责任单位编码'}
                                name={'DUTYUNIT_CODE'}
                                rules={[{ required: true, message: '请输入单位编码!' }]}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                label={'责任单位名称'}
                                name={'DUTYUNIT_NAME'}
                                rules={[{ required: true, message: '请输入单位名称!' }]}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormSelect
                                label={'状态'}
                                name={'PATROLDETAIL_STATE'}
                                options={[
                                    { label: "编辑中", value: 1 },
                                    { label: "巡查中", value: 2 },
                                    { label: "待跟进", value: 3 },
                                    { label: "整改中", value: 4 },
                                    { label: "已完成", value: 5 },
                                ]}
                                initialValue={1}
                                rules={[{ required: true, message: '请选择状态!' }]}
                            />
                        </Col>
                        {
                            pageDataType === 3000 ?
                                <>
                                    <Col span={8}>
                                        <ProFormText
                                            label={'检查人'}
                                            name={'INSPECTION_PERSON'}
                                        />
                                    </Col>
                                    <Col span={8}>
                                        <ProFormDateTimePicker
                                            width={'100%'}
                                            label={'检查开始时间'}
                                            name={'INSPECTION_STARTTIME'}
                                        />
                                    </Col>
                                    <Col span={8}>
                                        <ProFormDateTimePicker
                                            width={'100%'}
                                            label={'检查完成时间'}
                                            name={'INSPECTION_ENDTIME'}
                                        />
                                    </Col>
                                </> : ""
                        }
                        {/* <Col span={8}>
                            <ProFormSelect
                                label={'整改期限'}
                                name={'RECTIFICATION_PERIOD'}
                                options={[
                                    { label: "一小时内", value: '一小时内' },
                                    { label: "半天内", value: '半天内' },
                                    { label: "一天内", value: '一天内' },
                                    { label: "三天内", value: '三天内' },
                                    { label: "一周内", value: '一周内' },
                                ]}
                                initialValue={"一天内"}
                            />
                        </Col>
                        <Col span={8}>
                            <ProFormText
                                label={'巡检人员'}
                                name={'INSPECTION_PERSON'}
                            />
                        </Col> */}
                    </Row>
                </ProForm>

            </Modal>
        </div>
    )
}



export default connect(({ user }: ConnectState) => ({
    currentUser: user.data
}))(AddInspectionItems);