import React, { useEffect } from 'react';
import { connect } from 'dva';
import {
  Row,
  Col,
  Form,
  Input,
  Button,
  Select,
  Switch,
  TreeSelect,
  message,
  Modal,
  Upload,
  InputNumber,
} from 'antd';
import { dispatchHandle } from '@/utils/publicHandle';
import useUpdateEffect from '@/useHooks/useUpdateEffect';
import UploadFile from '@/components/UploadFile';
import { _apiUrl_ } from '@/utils/common';
import { useState } from 'react';
import { UploadOutlined, PlusOutlined, CloseOutlined, LoadingOutlined } from '@ant-design/icons';
import utilsStyles from '@/utils/utils.less';
const { TextArea } = Input;
const { Option } = Select;
// import { dicFindUtils,DictBizType,ApproveType,convertFieldToNum, } from '@/utils/utils';
const ReMarksViewModal = (props) => {
  const [form] = Form.useForm();
  const {
    dispatch,
    modalVisible,
    addType,
    type,
    status,
    isView,
    dict: {
      dicTotalsList
    },
    currentInfo,
    reMarksInfoArr,
    setReMarksInfoArr,
    wareCheck: {
      wareCheckMaterList
    }
  } = props;
  const formItemLayout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 20 },
  };
   const formTailLayout = {
    labelCol: { span: 4 },
    wrapperCol: { span: 20 },
  };
  const [loading, setLoading] = useState(false);
  const [imageList, setImageList] = useState([]);
  const handleClose = () => {
    props.handleClose();
  };
  useEffect(() => {
    let picArr = currentInfo?.picture != '' && currentInfo?.picture?.split(",") || [];
    setImageList(picArr);
  }, [currentInfo?.id]);
  return (
    <Modal
      width={650}
      title={'备注'}
      visible={modalVisible}
      onCancel={handleClose}
      afterClose={handleClose}
      closable={false}
      footer={null}
      type={type}
      forceRender
    >
      <Form>
        <Row>
          <Col md={24}>
            <Form.Item
              {...formItemLayout}
              label="不合格数量"
              rules={[{ required: true, message: `请输入` }]}
            >
              {
                currentInfo?.unQualifiedQuantity || 0
               }
            </Form.Item>
          </Col>
         <Col md={24}>
            <Form.Item  {...formItemLayout} label="备注">
              {
                  currentInfo?.remarks || '暂无'
              }
            </Form.Item>
          </Col>
          <Col md={24}>
            <Form.Item
              label="上传图片"
              {...formTailLayout}
            >
              {
                imageList?.length > 0 && imageList.map((item,index) => (
                      <img key={index} src={ item || '' } className = { utilsStyles.previewImg } style={{marginRight:10}} /> || '暂无图片'
                )) || '暂无图片'
              }
            </Form.Item>
          </Col>
        </Row>
        <Row>
          <Col offset={4} span={12}>
            <Button onClick={handleClose} type='primary'>确 定</Button>
          </Col>
        </Row>
      </Form>
    </Modal>
  );
};

export default connect(({ setting, wareCheck, loading,dict}) => ({
  setting,
  wareCheck,
  dict,
  loading: loading.models.setting,
}))(ReMarksViewModal);