import React, { useEffect, useRef, useState } from "react";

import Draggable from "react-draggable";
import ProForm, {
  ProFormDigit,
  ProFormSelect,
  ProFormText,
  ProFormTextArea,
  ProFormUploadButton
} from "@ant-design/pro-form";
import type { BrandModel } from "@/pages/basicManage/Brand/data";
import type { FormInstance } from "antd";
import { Button, Col, Form, Image, message, Modal, Row, Switch, TreeSelect } from "antd";
import { getFieldEnum } from "@/services/options";
import { uploadAHYDFile, uploadFile } from "@/pages/busniess/PaymentConfirm/service";
import { ExclamationCircleOutlined } from "@ant-design/icons";
import { getList, updateBrand } from "@/pages/basicManage/Brand/service";

import { getBase64 } from '@/utils/utils';
import { getPictureList, deletePicture, uploadPicture, uploadAHYDPicture } from '@/services/picture';
import type { UploadFile } from 'antd/es/upload/interface';
import type { PictureModel } from '@/services/options/typings';

// 更新品牌
const handleAddUpdate = async (fields: BrandModel) => {
  const hide = message.loading('正在提交...');

  const result = await updateBrand(fields);
  hide();
  if (result.Result_Code !== 100) {
    message.error(`${result.Result_Desc}` || `${result.Result_Code}:提交失败`);
    return false;
  }
  message.success(fields.BRAND_ID ? '更新成功！' : '新建成功！');
  return result.Result_Data;
};

// 上传附件
const customUploadRequest = async (fileList: UploadFile[], tableId: string, imageType: number) => {
  if (!fileList.length) {
    message.error("您上传的附件不存在.")
    return false
  }
  const formData = new FormData();
  fileList.forEach(file => {
    if (!file.ImageName) {
      formData.append('files[]', file);
    }
  });
  formData.append('ImageType', imageType);
  formData.append('TableType', '1125');
  formData.append('TableId', tableId);
  // const success = await uploadAHYDPicture(formData)
  const success = await uploadAHYDPicture(formData)
  if (success) {
    return true
  }
  return false
}
// clickType 判断是点击新增还是编辑
// modalVisible  是否显示弹出框
// handleCloseAddEdit 关闭弹出框的方法
// currentRow 当前选中的内容
// handleTableList 显示的表格数据 但是现在好像没用了
// brandTreeData 品牌树形数据
// loading 加载效果
// fileList 图片列表
// licenseList 文件列表
// handlePreview 预览方法
// handleChangeFieldList 改变图片的方法
// imagePreviewVisible 是否预览图片
// handleChangePreview  图片的预览

const AddEdit = ({ clickType, modalVisible, handleCloseAddEdit, currentRow, handleTableList, size, actionRef,
  brandTreeData, loading, fileList, licenseList, handlePreview, handleChangeFieldList, imagePreviewVisible, handleChangePreview }: any) => {
  const { confirm } = Modal;
  const formRef = useRef<FormInstance>();
  const draggleRef = React.createRef<any>()
  const [confirmLoading, handleConfirmLoading] = useState<boolean>(false) // 弹出框的内容表单是否在提交
  const [addTrade, setAddTrade] = useState<boolean>() // 是否新增业态操作
  const [businessLicenseList, setBusinessLicenseList] = useState<UploadFile[]>([])// 营业执照文件列表
  const [priviewImage, setPriviewImage] = useState<string>(); // 预览的文件地址
  const [managerForm, setManagerForm] = useState<number>()// 经营形式的类型 1000 品牌直营  2000 品牌加盟
  const [disabled, setDraggleDisabled] = useState<boolean>() // 是否拖动
  const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置
  const [list1001, setList1001] = useState<any>()// 1001的附件列表
  const [list1002, setList1002] = useState<any>()// 1002的附件列表
  const [list1003, setList1003] = useState<any>()// 1003的附件列表
  const [list1004, setList1004] = useState<any>()// 1004的附件列表
  const [list1005, setList1005] = useState<any>()// 1005的附件列表
  const beforeUpload = (file: any) => {
    const isJpgOrPng = file.type === 'image/jpeg' || file.type === 'image/png';
    if (!isJpgOrPng) {
      message.error('请上传JPEG、jpg、png格式的图片文件!');
    }
    const isLt2M = file.size / 1024 / 1024 < 2;
    if (!isLt2M) {
      message.error('图片大小不超过 2MB!');
    }
    return isJpgOrPng && isLt2M;
  }

  const onDraggaleStart = (event, uiData) => {
    const { clientWidth, clientHeight } = window.document.documentElement;
    const targetRect = draggleRef.current?.getBoundingClientRect();
    if (!targetRect) {
      return;
    }
    setBounds({
      left: -targetRect.left + uiData.x,
      right: clientWidth - (targetRect.right - uiData.x),
      top: -targetRect.top + uiData.y,
      bottom: clientHeight - (targetRect.bottom - uiData.y),
    });
  };

  useEffect(() => {
    const type1001: UploadFile[] = []
    const type1002: UploadFile[] = []
    const type1003: UploadFile[] = []
    const type1004: UploadFile[] = []
    const type1005: UploadFile[] = []
    if (licenseList && licenseList.length > 0) {
      licenseList.forEach((item: any) => {
        if (item.ImageType === 1001) {
          item.name = item.ImageName
          item.url = item.ImageUrl
          type1001.push(item)
        } else if (item.ImageType === 1002) {
          item.name = item.ImageName
          item.url = item.ImageUrl
          type1002.push(item)
        } else if (item.ImageType === 1003) {
          item.name = item.ImageName
          item.url = item.ImageUrl
          type1003.push(item)
        } else if (item.ImageType === 1004) {
          item.name = item.ImageName
          item.url = item.ImageUrl
          type1004.push(item)
        } else if (item.ImageType === 1005) {
          item.name = item.ImageName
          item.url = item.ImageUrl
          type1005.push(item)
        }
      })

    }
    setList1001(type1001)
    setList1002(type1002)
    setList1003(type1003)
    setList1004(type1004)
    setList1005(type1005)
  }, [licenseList])

  useEffect(() => {
    setManagerForm(currentRow?.MANAGE_TYPE)
  }, [currentRow])
  return (
    <Modal
      title={
        <div
          style={{
            width: '100%',
            cursor: 'move',
          }}
          onMouseOver={() => {
            if (disabled) {
              setDraggleDisabled(false)
            }
          }}
          onMouseOut={() => {
            setDraggleDisabled(true)
          }}
          onFocus={() => {
          }}
          onBlur={() => {
          }}
        >
          {clickType === 'edit' ? '更新品牌' : '新建品牌'}
        </div>
      }
      destroyOnClose={true}
      confirmLoading={confirmLoading}
      width={900}
      bodyStyle={{ height: '70vh', overflowY: 'scroll' }}
      visible={modalVisible}
      afterClose={() => {
        formRef.current?.resetFields();
      }}
      onCancel={() => {
        handleCloseAddEdit()
        setList1001([])
        setList1002([])
        setList1003([])
        setList1004([])
        setList1005([])
      }}
      onOk={async (value) => { // 提交框内的数据
        handleConfirmLoading(true)
        formRef?.current?.submit();
      }}
      modalRender={(modal) => {
        return <Draggable
          disabled={disabled}
          bounds={bounds}
          onStart={(event, uiData) => onDraggaleStart(event, uiData)}
        >
          <div ref={draggleRef}>{modal}</div>
        </Draggable>
      }}
      footer={
        <div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
          <div>
            <Button onClick={() => {
              handleCloseAddEdit()
            }}>取消</Button>
            <Button type={"primary"} onClick={() => {
              setAddTrade(false)
              handleConfirmLoading(true)
              // const formData = formRef.current?.getFieldValue()
              // console.log('formData',formData)
              // if (formData.businessLicense && formData.businessLicense.length>0){
              //   uploadFileFunction(formData.businessLicense[0])
              // }


              formRef?.current?.submit();
            }}>{clickType === 'edit' ? '更新' : '确认'}</Button>
            {clickType === 'edit' ? <Button type={"primary"} onClick={() => {
              setAddTrade(true)
              handleConfirmLoading(true)
              formRef?.current?.submit();
            }}>新增业态</Button> : ''}
          </div>
        </div>
      }
    >
      <ProForm<BrandModel>
        layout={'horizontal'}
        wrapperCol={{ span: 16 }} // 表单项 填写部分所占的栅格数
        labelCol={{ span: 6 }} // 表单项 标题所占的栅格数
        formRef={formRef}
        autoFocusFirstInput
        submitter={false}
        preserve={false}
        initialValues={currentRow}
        onFinish={async (values) => {
          let newValue: BrandModel = { ...values, BRAND_PID: values.BRAND_PID || -1 };
          if (currentRow) {
            // 编辑数据
            newValue = {
              ...values, BRAND_ID: addTrade ? null : currentRow.BRAND_ID,
              BRAND_PID: values.BRAND_PID || -1,
            };
          }
          newValue.BRAND_STATE = values.BRAND_STATE ? 1 : 0
          newValue.BRAND_INTRO = fileList.map(n => n.url).toString()

          const success = await handleAddUpdate(newValue as BrandModel);
          handleConfirmLoading(false)
          if (success) {
            const type1001 = list1001.filter(n => n.status !== 'done')
            const type1002 = list1002.filter(n => n.status !== 'done')
            const type1003 = list1003.filter(n => n.status !== 'done')
            const type1004 = list1004.filter(n => n.status !== 'done')
            const type1005 = list1005.filter(n => n.status !== 'done')
            if (type1001.length > 0) {
              await customUploadRequest(type1001, success?.BRAND_ID, 1001)
            }
            if (type1002.length > 0) {
              await customUploadRequest(type1002, success?.BRAND_ID, 1002)
            }
            if (type1003.length > 0) {
              await customUploadRequest(type1003, success?.BRAND_ID, 1003)
            }
            if (type1004.length > 0) {
              await customUploadRequest(type1004, success?.BRAND_ID, 1004)
            }
            if (type1005.length > 0) {
              await customUploadRequest(type1005, success?.BRAND_ID, 1005)
            }
            handleTableList(size)
            if (actionRef.current) {
              actionRef.current.reload();
            }
            handleCloseAddEdit()
          }
        }}
      >
        <Row>
          <Col span={12}>
            <ProFormText
              name="BRAND_NAME"
              label="品牌名称"
              placeholder="请输入名称"
              rules={[
                {
                  required: true,
                  message: '请输入名称',
                },
              ]}
            />
          </Col>
          <Col span={12}>
            <Form.Item
              name="BRAND_INDUSTRY"
              label="经营业态"
              rules={[
                {
                  required: true,
                  message: '请选择经营业态',
                },
              ]}
            >
              <TreeSelect
                placeholder="请选择经营业态"
                dropdownStyle={{ maxHeight: 300, overflow: 'auto' }}
                treeDefaultExpandedKeys={currentRow ? [currentRow?.BRAND_INDUSTRY] : [-1]}
                showArrow={false}
                loading={loading}
                treeData={brandTreeData}
                fieldNames={{
                  label: 'AUTOSTATISTICS_NAME',
                  value: 'AUTOSTATISTICS_ID'
                }}
              />
            </Form.Item>
          </Col>
          <Col span={12}>
            <ProFormSelect
              name="BRAND_TYPE"
              label="品牌类型"
              placeholder="请选择品牌类型"
              rules={[
                {
                  required: true,
                  message: '请选择品牌类型',
                },
              ]}
              request={async () => {
                return await getFieldEnum({ FieldExplainField: "BRAND_TYPE" });
              }}
            />
          </Col>
          <Col span={12}>
            <ProFormDigit
              name="BRAND_INDEX"
              label="显示索引"
              placeholder="请输入显示索引"
              rules={[
                {
                  required: true,
                  message: '请输入显示索引',
                },
              ]}
            />
          </Col>
          <Col span={12}>
            <ProFormText
              name="COMMISSION_RATIO"
              label="建议提成"
              placeholder="请输入建议提成"
            />
          </Col>
          <Col span={12}>
            <ProFormSelect
              name="MANAGE_TYPE"
              label="经营形式"
              placeholder="请选择经营形式"
              rules={[
                {
                  required: true,
                  message: '请选择经营形式',
                },
              ]}
              request={async () => {
                return await getFieldEnum({ FieldExplainField: "MANAGE_TYPE" });
              }}
              fieldProps={{
                onChange: (val: any) => {
                  setManagerForm(val)
                }
              }}
            />
          </Col>
          <Col span={12}>
            {/* 当前依赖包动画过渡有问题 临时采用 Form.Item 方式进行Switch交互 */}
            <Form.Item
              name="BRAND_STATE"
              label="是否有效"
            >
              <Switch
                checkedChildren="有"
                unCheckedChildren="无"
                defaultChecked={currentRow ? !!currentRow.BRAND_STATE : true}
              />
            </Form.Item>
          </Col>
          <Col span={24}>
            <ProFormUploadButton
              name="files"
              label="品牌图标"
              fileList={fileList}
              listType="picture-card"
              fieldProps={{
                beforeUpload,
                maxCount: 1,
                onPreview: handlePreview,
                customRequest: async (info) => {
                  const formData = new FormData();
                  formData.append('files', info.file);
                  formData.append('TableName', 'BRAND');
                  formData.append('ImageName', typeof info.file !== 'string' ? info.file?.name : '');
                  if (info.filename) {
                    // const success = await uploadFile(formData)
                    const success = await uploadAHYDFile(formData)
                    if (success) {
                      const list = [{
                        uid: `${success.ImageId}`, // 注意，这个uid一定不能少，否则上传失败
                        name: success.ImageName,
                        status: 'done',
                        url: success.ImageUrl, // url 是展示在页面上的绝对链接
                        imgUrl: success.ImagePath  // + success.ImageUrl,
                      }]
                      handleChangeFieldList(list)
                    }
                  } else {
                    message.error("您上传的图片不存在.")
                  }
                },
                onChange: async (info: any) => {
                  if (info.file.status === 'removed') {
                    confirm({
                      title: '确认删除该图片吗？',
                      icon: <ExclamationCircleOutlined />,
                      // content: 'When clicked the OK button, this dialog will be closed after 1 second',
                      async onOk() {
                        const deleteLoading = message.loading('正在删除...')
                        try {

                          const deleteIndex = fileList?.findIndex((n: any) => n.uid === info.file.uid)
                          if (deleteIndex !== -1) {
                            const files = [...fileList]
                            files.splice(deleteIndex, 1)
                            handleChangeFieldList(files)
                          }

                          deleteLoading()
                          return true
                        } catch (error) {
                          deleteLoading()
                          message.error("删除失败")
                          return false
                        }
                      },
                      onCancel() { },
                    });
                  }
                }
              }}
              labelCol={{ span: 3 }}
              wrapperCol={{ span: 20 }}
            />
            {/* 图片预览组件 */}
            {fileList && fileList.length > 0 && <div style={{ display: 'none' }}>
              <Image.PreviewGroup
                preview={{
                  visible: imagePreviewVisible,
                  onVisibleChange: vis => {
                    handleChangePreview(vis)
                  }
                }}>
                {
                  fileList.map((n) => <Image src={n.url} key={n.url} />)
                }
              </Image.PreviewGroup>
            </div>}
          </Col>
          <Col span={24}>
            <ProFormTextArea
              name="BRAND_DESC"
              label="备注说明"
              labelCol={{ span: 3 }}
              wrapperCol={{ span: 20 }}
            />
          </Col>
          <Col span={12}>
            <ProFormUploadButton
              name={'businessLicense'}
              title={'营业执照'}
              label={'上传营业执照'}
              fieldProps={{
                name: 'files',
                className: 'upload-list-inline',
                fileList: list1001,
                multiple: true,
                onPreview: async (file) => {
                  if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的
                    if (!file.url && !file.preview) {
                      setPriviewImage(await getBase64(file.lastModifiedDate))
                    } else {
                      setPriviewImage(file?.url)
                    }
                  } else {
                    const filenameSplitPointArr = file.fileName?.split('.') || []
                    if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) {
                      setPriviewImage(file?.url)
                    }
                    else if (file?.url) {
                      window.open(file?.url)
                    }
                  }
                },
                beforeUpload: (file, files) => {
                  setList1001([...list1001, ...files])
                  return false
                },
                onChange: async (info: any) => {
                  if (info.file.status === 'removed') {
                    // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除
                    const index = list1001.findIndex(n => n.uid === info.file.uid);
                    // if (!info.file?.deletepath) {
                    //   const newFileList = list1001.slice();
                    //   newFileList.splice(index, 1);
                    //   setList1001(newFileList)
                    //   return
                    // }
                    confirm({
                      title: '确认删除该文件吗？',
                      icon: <ExclamationCircleOutlined />,
                      async onOk() {
                        const deleteLoading = message.loading('正在删除...')
                        // const success = await deletePicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        const success = await deleteAHYDPicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        deleteLoading()
                        if (success) {
                          const files = [...list1001]
                          files.splice(index, 1)
                          setList1001(files)
                        }
                        else {
                          message.error("删除失败")
                        }
                      },
                      onCancel() {
                      },
                    });
                  }
                }
              }}
            >
            </ProFormUploadButton>
          </Col>
          <Col span={12}>
            <ProFormUploadButton
              name={'iconRegister'}
              title={'商标注册证'}
              label={'上传商标注册证'}
              fieldProps={{
                fileList: list1004,
                onPreview: async (file) => {
                  if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的
                    if (!file.url && !file.preview) {
                      setPriviewImage(await getBase64(file.lastModifiedDate))
                    } else {
                      setPriviewImage(file?.url)
                    }
                  } else {
                    const filenameSplitPointArr = file.fileName?.split('.') || []
                    if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) {
                      setPriviewImage(file?.url)
                    }
                    else if (file?.url) {
                      window.open(file?.url)
                    }
                  }
                },
                beforeUpload: (file, files) => {
                  setList1004([...list1004, ...files])
                  return false
                },
                onChange: async (info: any) => {
                  if (info.file.status === 'removed') {
                    // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除
                    const index = list1004.findIndex(n => n.uid === info.file.uid);
                    // if (!info.file?.deletepath) {
                    //   const newFileList = list1001.slice();
                    //   newFileList.splice(index, 1);
                    //   setList1001(newFileList)
                    //   return
                    // }
                    confirm({
                      title: '确认删除该文件吗？',
                      icon: <ExclamationCircleOutlined />,
                      async onOk() {
                        const deleteLoading = message.loading('正在删除...')
                        // const success = await deletePicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        const success = await deleteAHYDPicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        deleteLoading()
                        if (success) {
                          const files = [...list1004]
                          files.splice(index, 1)
                          setList1004(files)
                        }
                        else {
                          message.error("删除失败")
                        }
                      },
                      onCancel() {
                      },
                    });
                  }
                }
              }}
            >
            </ProFormUploadButton>
          </Col>

          <Col span={12}>
            <ProFormUploadButton
              name={'credit'}
              title={'信用记录'}
              label={'上传信用记录'}
              fieldProps={{
                fileList: list1005,
                onPreview: async (file) => {
                  if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的
                    if (!file.url && !file.preview) {
                      setPriviewImage(await getBase64(file.lastModifiedDate))
                    } else {
                      setPriviewImage(file?.url)
                    }
                  } else {
                    const filenameSplitPointArr = file.fileName?.split('.') || []
                    if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) {
                      setPriviewImage(file?.url)
                    }
                    else if (file?.url) {
                      window.open(file?.url)
                    }
                  }
                },
                beforeUpload: (file, files) => {
                  setList1005([...list1005, ...files])
                  return false
                },
                onChange: async (info: any) => {
                  if (info.file.status === 'removed') {
                    // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除
                    const index = list1005.findIndex(n => n.uid === info.file.uid);
                    // if (!info.file?.deletepath) {
                    //   const newFileList = list1001.slice();
                    //   newFileList.splice(index, 1);
                    //   setList1001(newFileList)
                    //   return
                    // }
                    confirm({
                      title: '确认删除该文件吗？',
                      icon: <ExclamationCircleOutlined />,
                      async onOk() {
                        const deleteLoading = message.loading('正在删除...')
                        // const success = await deletePicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        const success = await deleteAHYDPicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                        deleteLoading()
                        if (success) {
                          const files = [...list1005]
                          files.splice(index, 1)
                          setList1005(files)
                        }
                        else {
                          message.error("删除失败")
                        }
                      },
                      onCancel() {
                      },
                    });
                  }
                }
              }}
            >
            </ProFormUploadButton>
          </Col>
          {
            managerForm === 2000 ?
              <Col span={12}>
                <ProFormUploadButton
                  name={'cooperate'}
                  title={'合作授权书'}
                  label={'上传合作授权书'}
                  fieldProps={{
                    fileList: list1002,
                    onPreview: async (file) => {
                      if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的
                        if (!file.url && !file.preview) {
                          setPriviewImage(await getBase64(file.lastModifiedDate))
                        } else {
                          setPriviewImage(file?.url)
                        }
                      } else {
                        const filenameSplitPointArr = file.fileName?.split('.') || []
                        if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) {
                          setPriviewImage(file?.url)
                        }
                        else if (file?.url) {
                          window.open(file?.url)
                        }
                      }
                    },
                    beforeUpload: (file, files) => {
                      setList1002([...list1002, ...files])
                      return false
                    },
                    onChange: async (info: any) => {
                      if (info.file.status === 'removed') {
                        // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除
                        const index = list1002.findIndex(n => n.uid === info.file.uid);
                        // if (!info.file?.deletepath) {
                        //   const newFileList = list1001.slice();
                        //   newFileList.splice(index, 1);
                        //   setList1001(newFileList)
                        //   return
                        // }
                        confirm({
                          title: '确认删除该文件吗？',
                          icon: <ExclamationCircleOutlined />,
                          async onOk() {
                            const deleteLoading = message.loading('正在删除...')
                            // const success = await deletePicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                            const success = await deleteAHYDPicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                            deleteLoading()
                            if (success) {
                              const files = [...list1002]
                              files.splice(index, 1)
                              setList1002(files)
                            }
                            else {
                              message.error("删除失败")
                            }
                          },
                          onCancel() {
                          },
                        });
                      }
                    }
                  }}
                >
                </ProFormUploadButton>
              </Col> : ''
          }
          {
            managerForm === 2000 ?
              <Col span={12}>
                <ProFormUploadButton
                  name={'permit'}
                  title={'经营许可证'}
                  label={'上传经营许可证'}
                  fieldProps={{
                    fileList: list1003,
                    onPreview: async (file) => {
                      if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的
                        if (!file.url && !file.preview) {
                          setPriviewImage(await getBase64(file.lastModifiedDate))
                        } else {
                          setPriviewImage(file?.url)
                        }
                      } else {
                        const filenameSplitPointArr = file.fileName?.split('.') || []
                        if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) {
                          setPriviewImage(file?.url)
                        }
                        else if (file?.url) {
                          window.open(file?.url)
                        }
                      }
                    },
                    beforeUpload: (file, files) => {
                      setList1003([...list1003, ...files])
                      return false
                    },
                    onChange: async (info: any) => {
                      if (info.file.status === 'removed') {
                        // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除
                        const index = list1003.findIndex(n => n.uid === info.file.uid);
                        // if (!info.file?.deletepath) {
                        //   const newFileList = list1001.slice();
                        //   newFileList.splice(index, 1);
                        //   setList1001(newFileList)
                        //   return
                        // }
                        confirm({
                          title: '确认删除该文件吗？',
                          icon: <ExclamationCircleOutlined />,
                          async onOk() {
                            const deleteLoading = message.loading('正在删除...')
                            // const success = await deletePicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                            const success = await deleteAHYDPicture(info.file?.ImagePath, info.file?.ImageId, 'BRAND', '6000')
                            deleteLoading()
                            if (success) {
                              const files = [...list1003]
                              files.splice(index, 1)
                              setList1003(files)
                            }
                            else {
                              message.error("删除失败")
                            }
                          },
                          onCancel() {
                          },
                        });
                      }
                    }
                  }}
                >
                </ProFormUploadButton>
              </Col> : ''
          }
          {/* <Col span={24}> */}
          {/*   /!* 上传文件组件 *!/ */}
          {/*   <ProFormUploadButton */}
          {/*     name="ImgList" */}
          {/*     title="选择营业执照、加盟合作授权书、经营许可证、商标注册证、信用记录" */}
          {/*     label="上传品牌附件" */}
          {/*     wrapperCol={{ span: 20 }} */}
          {/*     labelCol={{ span: 3 }} */}
          {/*     fieldProps={{ */}
          {/*       name: 'files', */}
          {/*       // listType: 'picture-card', */}
          {/*       className: 'upload-list-inline', */}
          {/*       // defaultFileList: priviewFileList, */}
          {/*       fileList: licenseList, */}
          {/*       multiple: true, */}
          {/*       onPreview: async (file) => { */}
          {/*         if (file.type && file.type?.indexOf('image/') > -1) { // 未上传的文件 如果是图片类型的 */}
          {/*           if (!file.url && !file.preview) { */}
          {/*             setPriviewImage(await getBase64(file.lastModifiedDate)) */}
          {/*           } else { */}
          {/*             setPriviewImage(file?.url) */}
          {/*           } */}
          {/*         } else { */}
          {/*           const filenameSplitPointArr = file.fileName?.split('.') || [] */}
          {/*           if (['png', 'jpg', 'jpeg'].indexOf(filenameSplitPointArr[filenameSplitPointArr?.length - 1]) > -1) { */}
          {/*             setPriviewImage(file?.url) */}
          {/*           } */}
          {/*           else if (file?.url) { */}
          {/*             window.open(file?.url) */}
          {/*           } */}
          {/*         } */}
          {/*       }, */}
          {/*       beforeUpload: (file, files) => { */}
          {/*         setLicenseList([...licenseList, ...files]) */}
          {/*         return false */}
          {/*       }, */}
          {/*       onChange: async (info: any) => { */}
          {/*         if (info.file.status === 'removed') { */}
          {/*           // 如果在待上传列表中找到，则说明当前图片没有上传服务器，可直接删除 */}
          {/*           const index = licenseList.findIndex(n => n.uid === info.file.uid); */}
          {/*           if (!info.file?.deletepath) { */}
          {/*             const newFileList = licenseList.slice(); */}
          {/*             newFileList.splice(index, 1); */}
          {/*             setLicenseList(newFileList) */}
          {/*             return */}
          {/*           } */}
          {/*           confirm({ */}
          {/*             title: '确认删除该文件吗？', */}
          {/*             icon: <ExclamationCircleOutlined />, */}
          {/*             async onOk() { */}
          {/*               const deleteLoading = message.loading('正在删除...') */}
          {/*               const success = await deletePicture(info.file?.deletepath, info.file?.uid, '', '3000') */}
          {/*               deleteLoading() */}
          {/*               if (success) { */}
          {/*                 const files = [...licenseList] */}
          {/*                 files.splice(index, 1) */}
          {/*                 setLicenseList(files) */}
          {/*               } */}
          {/*               else { */}
          {/*                 message.error("删除失败") */}
          {/*               } */}
          {/*             }, */}
          {/*             onCancel() { */}
          {/*             }, */}
          {/*           }); */}
          {/*         } */}
          {/*       } */}
          {/*     }} */}
          {/*   /> */}
          {/*   /!* 查看文件组件 *!/ */}
          {/*   <div style={{ display: 'none' }}> */}
          {/*     <Image width={100} height={100} src={priviewImage} style={{ objectFit: "contain", display: 'none' }} */}
          {/*            preview={{ */}
          {/*              visible: !!priviewImage, */}
          {/*              onVisibleChange: (value: any) => { */}
          {/*                if (!value) { */}
          {/*                  setPriviewImage(''); */}
          {/*                } */}
          {/*              }, */}
          {/*            }} /> */}
          {/*   </div> */}
          {/* </Col> */}
          <Col span={12} style={{ display: "none" }}>
            <ProFormSelect
              name="BRAND_CATEGORY"
              label="品牌分类"
              placeholder="请选择品牌分类"
              initialValue={"1000"}
              valueEnum={{ 1000: { text: "经营品牌" }, 2000: { text: "商城品牌" } }}
              rules={[
                {
                  required: true,
                  message: '请选择品牌分类',
                },
              ]}
            />
          </Col>
          <Col span={12} style={{ display: "none" }}>
            <ProFormText
              name="WECHATAPPSIGN_ID"
              label="品牌标识"
            />
          </Col>
        </Row>
      </ProForm>
    </Modal >
  )
}
export default AddEdit
