// 商品信息管理
import { connect } from "umi";
import type { CurrentUser } from "umi";
import type { ConnectState } from "@/models/connect";
import React, { useRef, useState } from "react";
import ProCard from "@ant-design/pro-card";
import { MenuFoldOutlined, PlusOutlined } from "@ant-design/icons";
import type { FormInstance } from "antd";
import { Col, Drawer, Row } from "antd";
import { Avatar, Button, Menu, message, Modal, Popconfirm, Space, Spin, Tree } from "antd";
import useRequest from "@ahooksjs/use-request";
import {
  getFieldEnum,
  getFieldEnumTree,
  getServerpartOption,
  getServerpartTree,
  handleCallLogs
} from "@/services/options";
import type { ActionType } from "@ant-design/pro-table";
import ProTable from "@ant-design/pro-table";
import ReactHTMLTableToExcel from "react-html-table-to-excel";
import SubMenu from "antd/lib/menu/SubMenu";
import {
  handleDeleteCOMMODITY,
  handleGetCommodityList,
  handleGetNestingCOMMODITYTYPETree, handleGetServerpartShopTrade, handleSynchroCOMMODITY
} from "@/pages/reports/productControl/commodityInfo/service";
import ProForm, { ProFormDateTimePicker, ProFormDigit, ProFormSelect, ProFormText, ProFormTextArea, ProFormTreeSelect } from "@ant-design/pro-form";
import './style.less'
import moment from "moment";
import session from "@/utils/session";
import Detail from "@/pages/reports/productControl/components/detail";
import { handleGetUSERDEFINEDTYPEList } from "@/pages/reports/productControl/userDefinedType/service";
import PageTitleBox from "@/components/PageTitleBox";

const commodityInfo: React.FC<{ currentUser: CurrentUser }> = (props) => {
  const { currentUser } = props
  const downloadBtnRef = useRef<any>()
  const actionRef = useRef<ActionType>();
  const formRef = useRef<FormInstance>();
  const modalFormRef = useRef<any>();
  const [currentRow, setCurrentRow] = useState<any>()

  const [reqDetailList, setReqDetailList] = useState<any>(); // 合计项数据源
  const [printOut, setPrintOut] = useState<any>(); // 打印数据的内容
  const [collapsible, setCollapsible] = useState<boolean>(false)
  const [treeView, setTreeView] = useState<any>()
  const [allTreeView, setAllTreeView] = useState<any>()
  const [allTotal, setAllTotal] = useState<number>(20)
  // 加载服务区树
  const { loading: treeLoading, data: treeViews } = useRequest(async () => {
    const req = {
      PROVINCE_CODE: currentUser?.ProvinceCode,
      COMMODITYTYPE_VALID: 1,
      ShowCode: true
    }
    const data = await handleGetNestingCOMMODITYTYPETree(req)
    let list: any = data
    if (currentUser?.ProvinceCode === '734100') {
      list.unshift({
        label: "全部",
        value: 999999,
        key: '1-999999',
        type: 1
      })
      console.log('listlistlistlist', list);
    }
    setTreeView(list)
    setAllTreeView(list)
    return data
  })
  // 树相关的属性和方法
  const [selectedId, setSelectedId] = useState<string>()
  // 导出的加载效果
  const [showLoading, setShowLoading] = useState<boolean>(false)
  // 是否显示打印的表格
  const [showExportTable, setShowExportTable] = useState<boolean>(false)
  const [currenMenu, setCurrenMenu] = useState<any>(); // 当前选中左侧菜单的服务区节点
  const [showModal, setShowModal] = useState<boolean>(false)
  const [showDetail, setShowDetail] = useState<boolean>(false)
  const [selectBUSINESSTYPE, setSelectBUSINESSTYPE] = useState<any>()
  const [selectSERVERPARTID, setSelectSERVERPARTID] = useState<any>()
  // 商品类型 
  const [shopType, setShopType] = useState<any>()


  const ServerpartIdsList: any = session.get('ServerpartIdsList')
  console.log('ServerpartIdsListServerpartIdsList', ServerpartIdsList);

  const { loading: CommodityLoading, data: CommodityData } = useRequest(async () => {
    const data = await getFieldEnumTree({ FieldExplainField: 'CommodityTypeIds' })
    setShopType(data)
    const obj: any = {}
    if (data && data.length > 0) {
      data.forEach((item: any) => {
        obj[item.value] = item.label
        if (item.children && item.children.length > 0) {
          item.children.forEach((subItem: any) => {
            obj[subItem.value] = subItem.label
            if (subItem.children && subItem.children.length > 0) {
              subItem.children.forEach((thirdItem: any) => {
                obj[thirdItem.value] = thirdItem.label
              })
            }
          })
        }
      })
    }
    return obj
  })
  const [customClassList, setCustomClassList] = useState<any>()
  const columns: any = [
    {
      title: '服务区',
      dataIndex: 'ServerpartID',
      hideInTable: true,
      valueType: 'select',
      request: async () => {
        // const data = await getServerpartOption(340000)
        // return data
        const ServerpartIdsTree: any = session.get('ServerpartIdsTree')
        // let serverpartId: string = ''
        // if (serverpartList && serverpartList.length > 0) {
        //   serverpartList.forEach((item: any) => {
        //     if (serverpartId) {
        //       serverpartId += `,${item.value}`
        //     } else {
        //       serverpartId = item.value
        //     }
        //   })
        // }

        // serverpartList.unshift({
        //   label: "全部",
        //   value: ''
        // })
        return ServerpartIdsTree
      },
      fieldProps: {
        showSearch: true,
        filterOption: (input, option) => (option?.label ?? '').toLowerCase().includes(input.toLowerCase()),
      }
    },
    {
      title: '状态',
      dataIndex: 'CommodityState',
      hideInTable: true,
      valueType: 'select',
      valueEnum: {
        0: { text: '无效' },
        1: { text: '有效' }
      },
      initialValue: '1'
    },
    {
      dataIndex: 'searchText',
      title: '查询内容',
      hideInTable: true,
      fieldProps: {
        placeholder: "请输入商品名称/商品条码/商品类型"
      }
    },
    {
      title: <div style={{ textAlign: 'center' }}>序号</div>,
      dataIndex: 'index',
      width: 80,
      hideInSearch: true,
      align: 'center',
      valueType: 'index'
    },
    {
      title: <div style={{ textAlign: 'center' }}>服务区</div>,
      dataIndex: 'SERVERPART_NAME',
      width: 200,
      ellipsis: true,
      hideInSearch: true,
      align: 'center',
      render: (_, record) => {
        return record?.SERVERPART_ID ? ServerpartIdsList[record?.SERVERPART_ID] : '-'
      }
    },
    {
      title: <div style={{ textAlign: 'center' }}>商品业态</div>,
      width: 100,
      dataIndex: 'BUSINESSTYPE',
      hideInSearch: true,
      align: 'center',
      valueType: 'select',
      request: async () => {
        return await getFieldEnum({ FieldExplainField: 'BUSINESSTYPE', sessionName: 'SHOPTRADE', notformate: true })
      }
    },
    {
      title: <div style={{ textAlign: 'center' }}>商品类型</div>,
      width: 120,
      dataIndex: 'COMMODITY_TYPE',
      hideInSearch: true,
      align: 'center',
      valueEnum: CommodityData
    },
    {
      title: <div style={{ textAlign: 'center' }}>商品名称</div>,
      width: 300,
      ellipsis: true,
      dataIndex: 'COMMODITY_NAME',
      align: 'center',
      hideInSearch: true,
      render: (_, record) => {
        return <a onClick={() => {
          console.log('record', record)
          setCurrentRow(record)
          setShowDetail(true)
        }}>{record?.COMMODITY_NAME || '-'}</a>
      }
    },
    {
      title: <div style={{ textAlign: 'center' }}>商品条码</div>,
      width: 150,
      dataIndex: 'COMMODITY_BARCODE',
      align: 'center',
      hideInSearch: true,
    },
    {
      title: <div style={{ textAlign: 'center' }}>零售价</div>,
      width: 80,
      dataIndex: 'COMMODITY_RETAILPRICE',
      hideInSearch: true,
      align: 'right',
    },
    {
      title: <div style={{ textAlign: 'center' }}>进货价</div>,
      width: 80,
      dataIndex: 'COMMODITY_PURCHASEPRICE',
      align: 'right',
      hideInSearch: true,
    },
    {
      title: <div style={{ textAlign: 'center' }}>商品单位</div>,
      width: 80,
      dataIndex: 'COMMODITY_UNIT',
      align: 'center',
      hideInSearch: true,
    },
    {
      title: <div style={{ textAlign: 'center' }}>状态</div>,
      width: 80,
      dataIndex: 'COMMODITY_STATE',
      align: 'center',
      hideInSearch: true,
      valueType: 'select',
      valueEnum: { 0: { text: '无效', status: 'error' }, 1: { text: '有效', status: 'success' }, 2: { text: '不可选', status: 'default' } },
    },
    {
      title: <div style={{ textAlign: 'center' }}>审核时间</div>,
      width: 160,
      dataIndex: 'OPERATE_DATE',
      align: 'center',
      hideInSearch: true,
      sorter: (a, b) => new Date(a.OPERATE_DATE).getTime() - new Date(b.OPERATE_DATE).getTime(),
      defaultSortOrder: 'descend',
    },
    {
      title: <div style={{ textAlign: 'center' }}>操作</div>,
      width: 100,
      valueType: 'option',
      fixed: 'right',
      render: (_, record) => [
        <a style={{ marginRight: '8px' }} onClick={async () => {
          setCurrentRow({
            ...record,
            COMMODITY_GRADE: Number(record?.COMMODITY_GRADE),
            BUSINESSTYPE: record?.BUSINESSTYPE.toString(),
            ADDTIME: moment(record?.ADDTIME).format('YYYY-MM-DD HH:mm:ss')
          })
          setShowModal(true)

          console.log('record', record)
          await handleGetCommodity(record?.SERVERPART_ID)
          await handleGetCustomClassList(record?.SERVERPART_ID)

        }}>编辑</a>,
        <Popconfirm
          title="确认删除该商品？"
          onConfirm={async () => {
            const req: any = {
              COMMODITYId: record?.COMMODITY_ID
            }
            const data = await handleDeleteCOMMODITY(req)
            if (data.Result_Code === 100) {
              message.success(data.Result_Desc)
              actionRef.current?.reload()
            } else {
              message.error(data.Result_Desc)
            }
          }}
          okText="确定"
          cancelText="取消"
        >
          <a>删除</a>
        </Popconfirm>
      ]
    }
  ]

  // 查询的条件
  const [searchParams, setSearchParams] = useState<any>()
  // 商品业态的搜索框内容
  const [commodityList, setCommodityList] = useState<any>([])
  const getMenuDom = (data: any[], callback: (item: any) => void) => {
    return (data.map((element: any) => {
      // 绑定嵌套树的子节点
      if (element.children && element.children.length > 0) {
        return (
          <SubMenu title={<span>{element.label}</span>}
            icon={element.ico ? <Avatar src={element.ico} size={16} style={{ marginRight: 4 }} shape="square" /> : null}
            key={`${element.key || element.value}`}
            onTitleClick={(item) => {
              // 选中一级菜单
              if (!currenMenu || item.key !== `${currenMenu?.key}`) {
                callback.call(callback, item)
              }
              item.domEvent.stopPropagation();
            }}
          >
            {element.children && element.children.length > 0 && getMenuDom(element.children, callback)}
          </SubMenu>
        )
      }
      return (<Menu.Item icon={element.ico ? <Avatar src={element.ico} size={16} shape="square" /> : null}
        key={`${element.key || element.value}`}>{element.desc && element.desc !== '0/0' ? <><span>{element.label}</span>
          <span style={{ position: 'absolute', right: '10', top: '9px', lineHeight: '20px', padding: '2px 3px' }}>
            [<span style={{ color: 'red' }}>{element.desc.split('/')[0]}</span>/<span style={{ color: '#1890ff' }}>{element.desc.split('/')[1]}</span>]</span></> : element.label}</Menu.Item>)
    }))
  }

  const loadSelectedId = (item?: any) => {
    console.log('item', item)
    // 选中的子菜单key
    const [type, value] = item.key.split('-')

    if (value === '999999') {
      const serverpartList: any = session.get('serverpartList')
      let serverpartId: string = ''
      if (serverpartList && serverpartList.length > 0) {
        serverpartList.forEach((item: any) => {
          if (serverpartId) {
            serverpartId += `,${item.value}`
          } else {
            serverpartId = item.value
          }
        })
      }
      // formRef.current?.setFieldsValue({ ServerpartID: serverpartId })
    }

    if (type === '1') {
      setCurrenMenu(value)
      // actionRef?.current?.reload()
    } else {
      setCurrenMenu('')
    }
  }

  // 拿到对应的商品业态
  const handleGetCommodity = async (id: any) => {
    const req: any = {
      ProvinceCode: currentUser?.ProvinceCode,
      ServerpartId: id
    }
    const data = await handleGetServerpartShopTrade(req)
    console.log('data', data)
    setCommodityList(data)
  }

  // 请求自定义类的选择列表
  const handleGetCustomClassList = async (id: any) => {
    const req: any = {
      SearchParameter: {
        USERDEFINEDTYPE_STATE: 1,
        SERVERPART_ID: id,
        BUSINESSTYPE: selectBUSINESSTYPE
      },
      PageIndex: 1,
      PageSize: 999999,
      pageSize: 999999,
    }
    const data = await handleGetUSERDEFINEDTYPEList(req)
    if (data && data.length > 0) {
      const list: any = []
      data.forEach((item: any) => {
        list.push({ label: item.USERDEFINEDTYPE_NAME, value: item.USERDEFINEDTYPE_ID })
      })
      setCustomClassList(list)
    }
    console.log('data', data)
  }

  return (
    <div ref={(el) => {
      // 打印报表
      if (!reqDetailList || reqDetailList.length === 0) return;
      setPrintOut(el);
    }} >

      {
        showLoading ?
          <div
            style={{
              width: '100%',
              height: '100%',
              background: 'rgba(0,0,0,0.1)',
              position: 'fixed',
              zIndex: 5,
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'center'
            }}
          >
            <div style={{
              display: 'flex',
              alignItems: 'center',
              justifyContent: 'center',
              padding: '15px 20px 10px',
              background: '#fff',
              borderRadius: '8px',
              width: '200px'
            }}>
              <Spin />
              <span style={{ marginLeft: '5px' }}>数据导出中...</span>
            </div>
          </div> : ''
      }

      <div className={'saleReportHideBox'} style={{ position: 'fixed', zIndex: -1, top: 0, left: 0 }}>
        {
          showExportTable && reqDetailList && reqDetailList.length > 0 ?
            <ProTable
              columns={columns}
              dataSource={reqDetailList}
              pagination={false}
              expandable={{
                defaultExpandAllRows: true
              }}
            /> : ''
        }
      </div>
      <div id='hiddenBox' style={{ position: 'fixed', zIndex: -1, top: 0, left: 0 }} />

      <div style={{ backgroundColor: '#fff', display: 'flex' }}>
        <ProCard
          style={{ width: !collapsible ? "300px" : "60px" }}
          className="pageTable-leftnav"
          bodyStyle={{ padding: 0, paddingTop: 20, paddingLeft: 20, width: !collapsible ? "300px" : "60px" }}
          extra={<MenuFoldOutlined onClick={() => {
            setCollapsible(!collapsible)
          }} />}
          colSpan={!collapsible ? "300px" : "60px"}
          title={!collapsible ? "请选择商品类别" : ""}
          headerBordered
          collapsed={collapsible}
        >
          {!treeLoading && <Menu
            mode="inline"
            style={{ height: 'calc(100vh - 220px)', overflowY: 'auto', overflowX: 'hidden' }}
            selectedKeys={`1-${currenMenu}`}
            onSelect={(item) => {
              console.log('item', item)
              loadSelectedId(item)
            }}
          >
            {getMenuDom(treeViews, loadSelectedId)}
          </Menu>}
        </ProCard>
        <div style={{
          width: !collapsible ? 'calc(100% - 300px)' : 'calc(100% - 60px)',
          paddingTop: 0,
          paddingBottom: 0,
          paddingRight: 0
        }}>
          <ProTable
            actionRef={actionRef}
            formRef={formRef}
            columns={columns}
            bordered
            headerTitle={<PageTitleBox props={props} />}
            scroll={{ y: 'calc(100vh - 430px)' }}
            search={{ span: 6 }}
            request={async (params) => {
              if (!currenMenu) {
                return
              }

              const req: any = {
                ...params,
                SearchType: 3,
                ProvinceCode: currentUser?.ProvinceCode,
                CommodityTypeId: currenMenu === '999999' ? '' : currenMenu,
                // CommodityState: params?.COMMODITY_STATE,
                PageIndex: params.current,
                PageSize: params?.pageSize,
                pageSize: params?.pageSize,
                SearchKey: "COMMODITY_NAME,COMMODITY_BARCODE",
                SearchValue: params?.searchText || ""
                // PageSize: 20
              }
              console.log('req', req)
              handleCallLogs()
              setSearchParams(params)
              const data = await handleGetCommodityList(req)
              if (data.List && data.List.length > 0) {
                console.log('data', data)
                // setAllTotal(data.TotalCount)
                return { data: data.List, success: true, total: data.TotalCount }
              }
              return { data: [], success: true }
            }}
            toolbar={{
              actions: [
                <Button
                  key="new"
                  type="primary"
                  icon={<PlusOutlined />}
                  onClick={(e) => {
                    setShowModal(true)
                  }}
                >
                  添加商品
                </Button>
              ]
            }}
          />
        </div>
      </div>

      <Modal
        open={showModal}
        width={1200}
        wrapClassName={'shopModal'}
        destroyOnClose
        title={currentRow ? '编辑商品' : '添加商品'}
        onOk={() => {
          modalFormRef.current?.validateFields().then(async (res: any) => {
            console.log('res', res)
            if (res) {
              // setShowModal(false)
              let req: any = {}
              if (currentRow) {
                req = {
                  ...currentRow,
                  ...res,
                  OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
                }
              } else {
                req = {
                  ...res,
                  OPERATE_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
                }
              }
              console.log('req', req)
              const data = await handleSynchroCOMMODITY(req)
              console.log('data', data)
              if (data.Result_Code === 100) {
                message.success(data.Result_Desc)
                actionRef.current?.reload()
                setShowModal(false)
                setCurrentRow(undefined)
              } else {
                message.error(data.Result_Desc)
              }
            }
          })
        }}
        onCancel={() => {
          setShowModal(false)
          setCurrentRow(undefined)
          setCommodityList([])
          setCustomClassList([])
        }}
      >

        <ProForm
          formRef={modalFormRef}
          submitter={false}
          initialValues={currentRow}
        >
          <div className={'modalTitle'}>商品基本信息</div>
          <Row gutter={16}>
            <Col span={16}>
              <ProFormText
                name="COMMODITY_NAME"
                label="商品名称"
                placeholder="请输入商品名称"
                rules={[
                  {
                    required: true,
                    message: '请输入商品名称',
                  },
                ]}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="COMMODITY_EN"
                label="拼音简码"
              />
            </Col>

            <Col span={8}>
              <ProFormSelect
                name="SERVERPART_ID"
                label="服务区名"
                request={async () => {
                  const ServerpartIdsTree: any = session.get('ServerpartIdsTree')

                  // const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true)
                  // const list: any = []
                  // if (data && data.length > 0) {
                  //   data.forEach((item: any) => {
                  //     if (item.children && item.children.length > 0) {
                  //       item.children.forEach((subItem: any) => {
                  //         list.push({ label: subItem.label, value: subItem.value })
                  //       })
                  //     }
                  //   })
                  //   data.forEach((item: any) => {
                  //     list.push({ label: item.label, value: item.value })
                  //   })
                  // }
                  return ServerpartIdsTree
                }}
                rules={[
                  {
                    required: true,
                    message: '请选择服务区',
                  },
                ]}
                fieldProps={{
                  onChange: async (e: any) => {
                    console.log('e', e)
                    if (e) {
                      setSelectSERVERPARTID(e)
                      await handleGetCommodity(e)
                      if (selectBUSINESSTYPE) {
                        await handleGetCustomClassList(e)
                      }
                    } else {
                      setSelectSERVERPARTID(undefined)
                      setCommodityList([])
                      setCustomClassList([])
                    }
                  }
                }}
              />
            </Col>
            <Col span={8}>
              <ProFormSelect
                name="BUSINESSTYPE"
                label="商品业态"
                rules={[
                  {
                    required: true,
                    message: '请选择商品业态',
                  },
                ]}
                options={commodityList}
                fieldProps={{
                  onChange: async (e: any) => {
                    if (e) {
                      setSelectBUSINESSTYPE(e)
                      if (selectSERVERPARTID) {
                        await handleGetCustomClassList(e)
                      }
                    } else {
                      setSelectBUSINESSTYPE(undefined)
                    }
                  }
                }}
              />
            </Col>
            <Col span={8}>
              <ProFormTreeSelect
                name="COMMODITY_TYPE"
                label="商品类别"
                rules={[
                  {
                    required: true,
                    message: '请选择商品类别',
                  },
                ]}
                request={() => {
                  return treeView
                }}
                fieldProps={{
                  treeDefaultExpandAll: true
                }}
              />
            </Col>

            <Col span={8}>
              <ProFormText
                name="COMMODITY_BARCODE"
                label="商品条码"
                disabled={currentRow}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="COMMODITY_UNIT"
                label="商品单位"
                rules={[
                  {
                    required: true,
                    message: '请输入商品单位',
                  },
                ]}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="COMMODITY_RULE"
                label="商品规格"
                rules={[
                  {
                    required: true,
                    message: '请输入商品规格',
                  },
                ]}
              />
            </Col>

            <Col span={8}>
              <ProFormText
                name="COMMODITY_HOTKEY"
                label="快捷键值"
              />
            </Col>
            <Col span={8}>
              <ProFormSelect
                name="COMMODITY_GRADE"
                label="质量等级"
                rules={[
                  {
                    required: true,
                    message: '请选择质量等级',
                  },
                ]}
                initialValue={1000}
                options={[{ label: '一等品', value: 1000 }, { label: '二等品', value: 2000 }, { label: '三等品', value: 5000 }, { label: '优等品', value: 3000 }, { label: '合格品', value: 4000 },]}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="COMMODITY_ORI"
                label="商品产地"
                rules={[
                  {
                    required: true,
                    message: '请输入商品产地',
                  },
                ]}
              />
            </Col>

            <Col span={8}>
              <ProFormSelect
                name="USERDEFINEDTYPE_ID"
                label="自定义类"
                options={customClassList}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="PROVINCE_CODE"
                label="省份编码"
                disabled
              // initialValue={currentUser?.ProvinceCode}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="COMMODITY_CODE"
                label="商品编码"
                disabled
              />
            </Col>

            <Col span={24}>
              <ProFormTextArea
                name="COMMODITY_DESC"
                label="商品说明"
              />
            </Col>
          </Row>
          <div className={'modalTitle'}>商品状态信息</div>
          <Row gutter={16}>
            <Col span={8}>
              <ProFormSelect
                name="CANSALE"
                label="是否销售"
                rules={[
                  {
                    required: true,
                    message: '请选择是否销售',
                  },
                ]}
                initialValue={1}
                options={[{ label: '是', value: 1 }, { label: '否', value: 0 }]}
              />
            </Col>
            <Col span={8}>
              <ProFormSelect
                name="ISBULK"
                label="是否散装"
                rules={[
                  {
                    required: true,
                    message: '请选择是否散装',
                  },
                ]}
                initialValue={0}
                options={[{ label: '是', value: 1 }, { label: '否', value: 0 }]}
              />
            </Col>
            <Col span={8}>
              <ProFormSelect
                name="METERINGMETHOD"
                label="称重方式"
                rules={[
                  {
                    required: true,
                    message: '请选择称重方式',
                  },
                ]}
                initialValue={1}
                options={[{ label: '计价', value: 1 }, { label: '散装称重', value: 0 }]}
              />
            </Col>


            <Col span={8}>
              <ProFormSelect
                name="COMMODITY_STATE"
                label="审核状态"
                rules={[
                  {
                    required: true,
                    message: '请选择审核状态',
                  },
                ]}
                initialValue={1}
                options={[{ label: '有效', value: 1 }, { label: '审核中', value: 2 }, { label: '无效', value: 0 }]}
              />
            </Col>
            <Col span={8}>
              <ProFormText
                name="ADDTIME"
                label="添加时间"
                disabled
                initialValue={moment().format('YYYY-MM-DD HH:mm:ss')}
              />
            </Col>
            <Col span={8}>
              <ProFormDateTimePicker
                name="OPERATE_DATE"
                label="生效时间"
                initialValue={moment().format('YYYY-MM-DD HH:mm:ss')}
              />
            </Col>
          </Row>
          <div className={'modalTitle'}>商品价格信息</div>
          <Row gutter={16}>
            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_RETAILPRICE"
                label="零售价"
                rules={[
                  {
                    required: true,
                    message: '请输入零售价',
                  },
                ]}
              />
            </Col>
            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_CURRPRICE"
                label="当前价格"
                rules={[
                  {
                    required: true,
                    message: '请输入当前价格',
                  },
                ]}
              />
            </Col>
            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_MEMBERPRICE"
                label="会员价"
              />
            </Col>

            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_PURCHASEPRICE"
                label="进货价"
                rules={[
                  {
                    required: true,
                    message: '请输入进货价',
                  },
                ]}
              />
            </Col>
            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_MINPRICE"
                label="最低价"
              />
            </Col>
            <Col span={8}>
              <ProFormDigit
                name="COMMODITY_MAXPRICE"
                label="最高价"
              />
            </Col>
          </Row>
          <div className={'modalTitle'}>商品进销信息</div>
          <Row gutter={16}>
            <Col span={8}>
              <ProFormDigit
                name="DUTY_PARAGRAPH"
                label="进价税率"
              />
            </Col>
            <Col span={8}>
              <ProFormDigit
                name="RETAIL_DUTY"
                label="零售税率"
              />
            </Col>
            <Col span={8}>
              <ProFormSelect
                name="COMMODITY_FROZENCOUNT"
                label="采购状态"
                options={[{ label: '允许', value: 1000 }, { label: '禁止', value: 2000 }]}
              />
            </Col>
          </Row>
        </ProForm>
      </Modal>


      <Drawer
        width={1000}
        open={showDetail}
        onClose={() => {
          setCurrentRow(undefined)
          setShowDetail(false)
        }}
        closable={false}
        destroyOnClose
        bodyStyle={{ padding: '12px 24px' }}
      >
        <Detail currentRow={currentRow} currentUser={currentUser} treeView={treeView} />
      </Drawer>
    </div>
  )
}

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