/*
 * @Author: cclu
 * @Date: 2021-12-13 11:01:23
 * @LastEditTime: 2024-09-13 16:23:40
 * @LastEditors: cclu 1106109051@qq.com
 * @Description: 数据校验管理
 * @FilePath: \cloud-platform\src\pages\DataVerification\list.tsx
 */
import { connect } from "umi";
import React, { useEffect, useRef, useState } from 'react';
import { PageContainer } from '@ant-design/pro-layout';
import { SubmitEndaccountState, recordSaleData, getServerpartOption, handleDateList, handleSynchroENDACCOUNT, handleDeleteENDACCOUNT } from './service'
import {
  Button,
  Drawer,
  Form,
  message,
  Select, DatePicker, Spin, Row, Col, Popconfirm
} from 'antd';
import { ActionType, ProTable } from '@ant-design/pro-table';
import type { CurrentUser } from '@/models/user';
import type { ConnectState } from "@/models/connect";
import type { EndaccountDetailModel, AuditInfoModel, ConnectStateModel, EndaccountChangeModel, EndaccountSaleModel, ImageType } from './data'
import './style.less'
import './newStyle.less'
import mobile from '@/assets/DataVerification/mobilePay.png'

import moment from 'moment';
import useRequest from "@ahooksjs/use-request";
import fixedIcon from '@/assets/DataVerification/fixedIcon.png'
import allMoney from '@/assets/DataVerification/allMoney.png'
import waitMe from '@/assets/DataVerification/waitMe.png'
import upLoadShop from '@/assets/DataVerification/upLoadShop.png'
import allRealMoney from '@/assets/DataVerification/allRealMoney.png'
import code from '@/assets/DataVerification/code.png'
import haveOwner from '@/assets/DataVerification/haveOwner.png'
import interfaceImg from '@/assets/DataVerification/interface.png'
import defaultIcon from '@/assets/brand/defaultIcon.png'
import ItemDetail from './components/ItemDetail'
import { dailyVerifyEndaccount, handleGetAccountList, handleGetServerpartShopList, handleGetServiceShopList, submitEndaccountState } from "@/pages/DataVerification/service";
import changeIcon from '../../../assets/versionChange.png'
import ProForm, { ProFormInstance, ProFormSelect } from "@ant-design/pro-form";
import UnUploadDetail from "./components/unUploadDetail";
import data from "@/pages/newDataAnalysis/areaVehicle/data";


const List: React.FC<{ currentUser?: CurrentUser }> = ({ currentUser }) => {
  const itemDetailRef = useRef()

  const UnUploadDetailRef = useRef<any>()

  const [currentRow, setCurrentRow] = useState<any>()
  // 切换页面版本
  const [pageVersion, setPageVersion] = useState<'new' | 'old'>('new')
  const [selectService, setSelectService] = useState<number>()// 页面选择的服务区
  const { RangePicker } = DatePicker;
  const [showDetail, setShowDetail] = useState<boolean>(false)// 显示详情的抽屉
  const [searchTime, setSearchTime] = useState<any>([moment().subtract(1, 'day'), moment().subtract(1, 'day')])
  const [showUpLoad, setShowUpLoad] = useState<boolean>(false)
  const [tableList, setTableList] = useState<any>()
  const [serviceDetail, setServiceDetail] = useState<any>()
  const [selectChildrenTab, setSelectChildrenTab] = useState<boolean>(true)

  // old选择的服务区
  const [selectServicePartId, setSelectServicePartId] = useState<any>('')
  // old选择的门店列表
  const [selectShopId, setSelectShopId] = useState<any>('')
  // old门店列表
  const [shopList, setShopList] = useState<any>()
  // old处理状态
  const [selectState, setSelectState] = useState<any>(0)
  // old查询时间
  const [selectTime, setSelectTime] = useState<any>([moment().subtract(1, 'day'), moment().subtract(1, 'day')])
  // old表格的加载效果
  const [tableLoading, setTableLoading] = useState<boolean>(false)
  // old表格数组
  const [tableData, setTableData] = useState<any>()
  // 没上传结账信息显示的抽屉
  const [unUploadDrawer, setUnUploadDrawer] = useState<boolean>(false)

  const columns: any = [
    {
      dataIndex: 'key',
      title: '序号',
      width: 50,
      align: 'center',
    },
    {
      dataIndex: 'Treatment_MarkState',
      title: '处理状态',
      width: 90,
      align: 'center',
      render: (_, record) => {
        return record?.Treatment_MarkState === 1 ? '待我校验' : record?.Treatment_MarkState > 1 ? '我已校验' : '待处理'
      }
    },
    {
      dataIndex: 'Serverpart_Name',
      title: '服务区名称',
      width: 120,
      ellipsis: true,
    },
    {
      dataIndex: 'ServerpartShop_Name',
      title: '门店名称',
      valueType: 'select',
      ellipsis: true,
      width: 200,
      render: (_, record) => {
        return <a onClick={() => {
          if (record?.Upload_State === 1) {
            setCurrentRow(record)
            setShowDetail(true)
          } else {
            setCurrentRow(record)
            setUnUploadDrawer(true)
          }
        }}>
          {record?.ServerpartShop_Name || ''}
        </a>
      }
    },
    {
      dataIndex: 'Description_Info',
      title: '日结校验',
      width: 400,
      ellipsis: true,
      hideInSearch: true,
      render: (_, record) => {
        return <div>{
          record.Description_Staff.indexOf('移') === -1 ?
            <span style={{ display: 'inline-block', width: '390px', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap' }}>{`${record.Description_Staff ? `${record.Description_Staff}:` : ''} ${record.Description_Info}`}</span>
            :
            <div style={{ display: 'flex', alignItems: 'center', width: '390px', textOverflow: 'ellipsis', overflow: 'hidden', whiteSpace: 'nowrap' }}>
              <img style={{ width: '16px', height: '16px' }} src={mobile} />
              <span>{`${record.Description_Staff.split('【')[0]}: ${record.Description_Info}`}</span>
            </div>

        }</div>
      }
    },
    {
      dataIndex: 'TotalSell_Amount',
      title: '总销售额',
      width: 100,
      align: 'right',
      hideInSearch: true,
      render: (_, record) => {
        return <span>{fmoney(record.TotalSell_Amount, 2)}</span>
      }
    },
    {
      dataIndex: 'Difference_Amount',
      title: '长短款',
      width: 80,
      align: 'right',
      hideInSearch: true,
      render: (_, record) => {
        return <span>{fmoney(record.Difference_Amount, 2)}</span>
      }
    },
    {
      dataIndex: '',
      title: '客单均价',
      width: 80,
      align: 'right',
      hideInTable: true,
      hideInSearch: true,
      render: (_, record) => {
        return <span>{record.Ticket_Count ? (record.TotalSell_Amount / record.Ticket_Count).toFixed(2) : '-'}</span>
      }
    },
    {
      dataIndex: 'Revenue_Amount',
      title: '实收金额',
      width: 100,
      align: 'right',
      hideInSearch: true,
      render: (_, record) => {
        return <span>{fmoney(record.Revenue_Amount, 2)}</span>
      }
    },
    {
      dataIndex: 'Endaccount_EndDate',
      title: '结账日期',
      width: 200,
      align: 'center',
    },
  ]
  // 加载蒙层是否显示
  const [showLoading, setShowLoading] = useState<boolean>(false)
  // 服务区列表
  const { loading, data: serviceList } = useRequest(async () => {
    const options = await getServerpartOption()
    const list: any = []
    if (options && options.length > 0) {
      options.forEach((item: any) => {
        if (item.value !== 424) {
          list.push(item)
        }
      })
      if (list && list.length > 0) {
        setSelectService(list[0].value)
        handleGetList(list[0].value)
      }
    }
    return list
  })
  const fmoney = (s: number, n?: number) => {
    /*
     * 参数说明：
     * s：要格式化的数字
     * n：保留几位小数
     * */
    n = n > 0 && n <= 20 ? n : s.toString().indexOf('.') === -1 ? 0 : s.toString().indexOf('.') > -1 ? s.toString().split('.')[1].length : 2;
    let fuhao = ''; // 如果数字小于零则值为-
    if (s < 0) {
      s = Math.abs(s);
      fuhao = '-'
    }
    s = `${parseFloat((`${s}`).replace(/[^\d\.-]/g, "")).toFixed(n)}`;
    const l = s.split(".")[0].split("").reverse();
    const r = s.split(".")[1];
    let t = "";
    for (let i = 0; i < l.length; i++) {
      t += l[i] + ((i + 1) % 3 == 0 && (i + 1) != l.length ? "," : "");
    }
    if (n === 0) {
      return s
    }
    return `${fuhao + [...t].reverse().join("")}.${r}`;

  }
  //  拿到表格数据
  const handleGetList = async (id?: any) => {
    setShowLoading(true)
    const req = {
      RoleType: 1,
      ProvinceCode: currentUser?.ProvinceCode,
      ServerpartId: id || selectService,
      StartDate: moment(searchTime[0]).format('YYYY-MM-DD'),
      EndDate: moment(searchTime[1]).format('YYYY-MM-DD')
    }
    const data = await handleDateList(req)
    console.log('data', data)
    if (data && data.List && data.List[0] && data.List.length > 0 && data.List[0].ShopDetailList && data.List[0].ShopDetailList.length > 0) {
      setTableList(data.List[0].ShopDetailList)
      setServiceDetail(data.List[0])
      setShowLoading(false)
    }
  }
  useEffect(() => {
    // handleGetList()
  }, []);
  const handleKnowChildrenTabChange = (e: number, listLength: number, disableBtn: boolean) => {
    if (disableBtn) {
      if (e !== 2 && listLength > 0) {
        setSelectChildrenTab(true)
      } else {
        setSelectChildrenTab(false)
      }
    } else {
      setSelectChildrenTab(false)
    }

  }

  // 数据校验
  const handleSubmitEndaccountState = async (desc: any, obj: any, list: any) => {
    const req = {
      ...obj,
      ...desc,
      AuditInfoList: list || []
    }
    const data = await dailyVerifyEndaccount(req)
    if (data.Result_Code === 100) {
      message.success('校验成功')
      // setShowDetail(false);
      const flag = itemDetailRef.current?.handleLeftListChange()
      if (flag) {
        setShowDetail(false)
      }
      handleGetList()
      itemDetailRef.current?.handleGetItemDetail()
    } else {
      message.error(data.Result_Desc)
    }
    itemDetailRef.current?.showDetailLoading(false)
  }

  // 切换页面的版本
  const handleChangePageVersion = () => {
    if (pageVersion === 'new') {
      setPageVersion('old')
    } else {
      setPageVersion('new')
    }
  }
  // old拿到表格数据的方法
  const handleGetTableList = async () => {
    setTableLoading(true)
    const req = {
      ServerpartIds: selectServicePartId || '',
      ServerpartShopCode: selectShopId || '',
      StartDate: moment(selectTime[0]).format('YYYY-MM-DD'),
      EndDate: moment(selectTime[1]).format('YYYY-MM-DD'),
      TreatmentMarkState: selectState || selectState === 0 ? selectState : '',
      EndaccountState: selectState || selectState === 0 ? 1 : '',
      PageIndex: 1,
      PageSize: 999999
    }
    const data = await handleGetAccountList(req)
    console.log('data23123', data);

    if (data && data.List && data.List.length > 0) {
      const list: any = []
      data.List.forEach((item: any, index: number) => {
        item.key = index + 1
        list.push(item)
        if (item.Endaccount_State === 0) {
          console.log(item);
        }
      })
      setTableData(list)
    } else {
      setTableData([])
    }
    setTableLoading(false)
  }

  return (
    <PageContainer header={{
      title: '',
      breadcrumb: {},
    }}>
      {
        pageVersion === 'new' ?
          <div className={'qualificationsData'}>
            <div className={'dataBox'}>
              <div className={'dataBoxTop'}>
                <div className={'dataBoxTopLeft'}>
                  <img className={'leftIcon'} src={fixedIcon} />
                  <Select
                    className={'pageSelect'}
                    options={serviceList}
                    value={selectService}
                    showSearch
                    filterOption={(input, option) =>
                      (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
                    }
                    onChange={(e: number) => {
                      setSelectService(e)
                    }}
                  ></Select>
                </div>
                <div className={'dataBoxTopRight'}>
                  <div className={'versionChangeBox'} onClick={() => {
                    handleChangePageVersion()
                  }}>
                    <img className={'changeIcon'} src={changeIcon} />
                    切换版本
                  </div>
                </div>
              </div>
              <div className={'dataBoxBottom'}>
                <div className={"dataBoxBottomLeft"}>
                  <div className={'bottomItem'}>
                    <img className={'typeIcon'} src={allMoney} />
                    <div className={'smallData'}>
                      <p className={'dataLabel'}>总营收</p>
                      <span className={'dataValue'}>{serviceDetail?.Revenue_Amount ? fmoney(serviceDetail?.Revenue_Amount, 2) : '-'}</span>
                    </div>
                  </div>

                  <div className={'bottomItem'}>
                    <img className={'typeIcon'} src={waitMe} />
                    <div className={'smallData'}>
                      <p className={'dataLabel'}>待我处理</p>
                      <span className={'dataValue'}>{serviceDetail?.Treatment_Count ? serviceDetail?.Treatment_Count : '0'}</span>
                    </div>
                  </div>

                  <div className={'bottomItem'}>
                    <img className={'typeIcon'} src={upLoadShop} />
                    <div className={'smallData'}>
                      <div className={'warningBoxs'}>
                        <p className={'dataLabel'}>上传门店</p>
                        <div style={{ cursor: 'pointer' }} onClick={() => {
                          setShowUpLoad(!showUpLoad)
                        }}>
                          {
                            serviceDetail?.UnUpLoadShopList && serviceDetail?.UnUpLoadShopList.length > 0 ?
                              <div className={'unUpload'}>
                                <span className={'text'}>⚠️</span>
                                <span className={'unUploadText'}>{`${serviceDetail?.UnUpLoadShopList.length}家未上传`}</span>
                              </div> : ''
                          }
                        </div>
                        {
                          showUpLoad ?
                            <div className={'uploadBox'} onClick={() => {
                              setShowUpLoad(!showUpLoad)
                            }}>
                              {
                                serviceDetail?.UnUpLoadShopList && serviceDetail?.UnUpLoadShopList.length > 0 ?
                                  serviceDetail?.UnUpLoadShopList.map((item: any) => {
                                    return <div>
                                      {`${item.Statistics_Date}  ${item.ServerpartShop_Name}`}
                                    </div>
                                  }) : ''
                              }
                            </div> : ''
                        }
                      </div>
                      <span className={'dataValue'}>{serviceDetail?.UploadShop_Count ? serviceDetail?.UploadShop_Count : '0'}</span>
                    </div>
                  </div>
                </div>
                <div className={"dataBoxBottomRight"}>
                  <RangePicker
                    value={searchTime}
                    onChange={(e: any) => {
                      if (e) {
                        setSearchTime([moment(e[0]._d), moment(e[1]._d)])
                      }
                    }}
                  />
                  <Button style={{ marginLeft: '8px' }} type={'primary'} onClick={() => {
                    handleGetList()
                    setShowUpLoad(false)
                  }}>查询</Button>
                </div>

              </div>
            </div>

            <div className={'dataList'}>
              {
                showLoading ?
                  <div className={'LoadingBox'}>
                    <div className={'loading'}>
                      <Spin />
                      <span style={{ marginLeft: '5px' }}>{'加载中'}</span>
                    </div>
                  </div> : ''
              }

              <div className={'listBox'}>
                {
                  tableList && tableList.length > 0 ?
                    tableList.map((item: any, index: number) => {
                      return <div className={'listItem'} style={{ marginRight: (index + 1) % 4 === 0 ? '' : '20px' }} onClick={() => {
                        if (item.Treatment_MarkState !== -1) {
                          setShowDetail(true)
                          setCurrentRow(item)
                        }
                      }}>

                        <div className={'itemTop'}>
                          <img className={'itemImg'} src={item.ServerpartShop_ICO || defaultIcon} />
                          <div className={'topBox'}>
                            <div className={'topText'}>{item.ServerpartShop_Name}</div>
                            <div className={'typeList'}>{item.Business_TypeName}</div>
                          </div>
                        </div>

                        <div className={'listItemCenter'}>
                          <div className={'realMoneyBox'}>
                            <div className={'moneyLeft'}>
                              <img className={'moneyIcon'} src={allRealMoney} />
                              <text className={'leftLabel'}>总实收金额/元</text>
                            </div>
                            <div className={'moneyRight'}>{item.Treatment_MarkState === -1 ? '0' : fmoney(item.Revenue_Amount, 2)}</div>
                          </div>
                          <div className={'progressBox'}>
                            <div className={'boxTop'}>
                              <span className={'boxTopLabel'}>{item.Treatment_MarkState === -1 ? '已完成：0%' : `已完成：${Number((item.Deal_Count / item.Total_Count).toFixed(2)) * 100}%`}</span>
                              <span className={'boxTopValue'}>{item.Treatment_MarkState === -1 ? '0/0' : `${item.Deal_Count}/${item.Total_Count}`}</span>
                            </div>
                            <div className={'progress'}>
                              <div className={'have'} style={{ width: item.Treatment_MarkState === -1 ? '0%' : `${Number((item.Deal_Count / item.Total_Count).toFixed(2)) * 100}%` }}></div>
                            </div>
                          </div>
                        </div>

                        <div className={'codeBox'}>
                          <div className={'codeLeft'}>
                            {/* haveOwner */}
                            <img className={'code'} src={item.Transfer_Type === 0 ? haveOwner : item.Transfer_Type === 1 ? code : interfaceImg} />
                            <span className={'text'}>{item.Transfer_Type === 0 ? '收银系统' : item.Transfer_Type === 1 ? '扫码传输' : item.Transfer_Type === 2 ? '接口传输' : ''}</span>
                          </div>
                          <div className={'codeRight'} style={{ background: item.Treatment_MarkState === -1 ? '#FFE4E4' : item.Treatment_MarkState === 1 ? '#EBEDEE' : '', color: item.Treatment_MarkState === -1 ? '#FF2F0D' : item.Treatment_MarkState === 1 ? '#686E75' : '' }}>
                            {item.Treatment_MarkState === -1 ? '未上传' : item.Treatment_MarkState === 0 ? '待处理' : item.Treatment_MarkState === 1 ? '已处理' : ''}</div>
                        </div>

                      </div>
                    })
                    : ''
                }
              </div>
            </div>
          </div> :
          <div className={"oldPageBox"}>
            <div className={'searchBox'}>
              <div style={{ width: '100%', display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
                <div className={'searchBoxLeft'}>
                  <div className={'searchItem'}>
                    <span className={'searchLabel'}>服务区：</span>
                    <Select
                      style={{ minWidth: '150px' }}
                      value={selectServicePartId}
                      options={[{ label: '全部', value: '' }, ...serviceList]}
                      allowClear
                      showSearch
                      filterOption={(input, option) =>
                        (option?.label ?? '').toLowerCase().includes(input.toLowerCase())
                      }
                      onChange={async (e) => {
                        setSelectServicePartId(e)
                        // const req = {
                        //   ProvinceCode: currentUser?.ProvinceCode,
                        //   ServerpartId: e,
                        //   ShowWholePower: true
                        // }
                        // const data = await handleGetServiceShopList(req)
                        // console.log('datadatadatadatadata', data);


                        const req = {
                          SearchParameter: {
                            SERVERPART_IDS: e,
                            ISVALID: 1
                          },
                          PageIndex: 1,
                          PageSize: 999999,
                          SortStr: "SHOPREGION,SHOPTRADE,SHOPSHORTNAME,SHOPCODE"
                        }
                        const data = await handleGetServerpartShopList(req)
                        console.log('shop', data);
                        let list: any = []
                        if (data && data.length > 0) {
                          data.forEach((item: any) => {
                            list.push({ label: item.SHOPNAME, value: item.SHOPCODE })
                          })
                        }

                        setSelectShopId(null)
                        // let list: any = data.List
                        list.unshift({ label: '全部', value: '' })
                        setShopList(list)
                      }}
                    ></Select>
                  </div>
                  <div className={'searchItem'}>
                    <span className={'searchLabel'}>门店：</span>
                    <Select
                      style={{ minWidth: '150px' }}
                      value={selectShopId}
                      allowClear
                      options={shopList}
                      onChange={(e) => {
                        setSelectShopId(e)
                      }}
                    ></Select>
                  </div>
                  <div className={'searchItem'}>
                    <span className={'searchLabel'}>校验状态：</span>
                    <Select
                      style={{ minWidth: '150px' }}
                      value={selectState}
                      allowClear
                      options={[{ label: '全部', value: '' }, { label: '待我校验', value: 0 }, { label: '我已校验', value: '1,2,3,4' }]}
                      onChange={(e) => {
                        setSelectState(e)
                      }}
                    ></Select>
                  </div>
                  <div className={'searchItem'}>
                    <span className={'searchLabel'}>时间：</span>
                    <RangePicker
                      value={selectTime}
                      onChange={(e) => {
                        setSelectTime([moment(e[0]._d), moment(e[1]._d)])
                      }}
                    />
                  </div>
                </div>
                <div className={'searchBoxRight'}>
                  <div className={'versionChangeBox'} style={{ marginRight: '8px' }} onClick={() => {
                    handleChangePageVersion()
                  }}>
                    <img className={'changeIcon'} src={changeIcon} />
                    切换版本
                  </div>
                  <Button type={'primary'} onClick={() => {
                    handleGetTableList()
                  }}>查询</Button>
                </div>
              </div>

            </div>
            <div className={'tableBox'}>
              <ProTable
                key={'Endaccount_Id'}
                rowKey={'Endaccount_Id'}
                loading={tableLoading}
                options={false}
                className={'proTableBox'}
                search={false}
                columns={columns}
                bordered
                dataSource={tableData}
                scroll={{ y: 'calc(100vh - 470px)' }}
                pagination={{ pageSize: 20 }}
                rowClassName={(record) => {
                  return record?.Endaccount_State === 0 ? 'greyRow' : ''
                }}
              >
              </ProTable>
            </div>
          </div>
      }


      {/* 上传结账信息显示的抽屉内容 */}
      <Drawer
        width={'80%'}
        closable={false}
        visible={showDetail}
        bodyStyle={{ padding: 0 }}
        destroyOnClose={true}
        onClose={() => {
          setShowDetail(false);
          setCurrentRow(null)
        }}
        footer={
          selectChildrenTab ?
            <div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
              <Button onClick={() => { setShowDetail(false) }}>取消</Button>
              <Button style={{ marginLeft: '8px' }} type={'primary'} onClick={async () => {
                let flag: boolean = false
                flag = await itemDetailRef.current?.handleForm()
                if (flag) {
                  // 出現加载框
                  itemDetailRef.current?.showDetailLoading(true)
                  const desc = itemDetailRef.current?.handleGetApprovedInfo()
                  console.log('desc', desc)
                  const detail = itemDetailRef.current?.currentDetail
                  const list = itemDetailRef.current?.auditTableData
                  handleSubmitEndaccountState(desc, detail, list)
                }
              }}>校验</Button>
            </div> : ''
        }
      >
        <ItemDetail onRef={itemDetailRef} currentUser={currentUser} showDetail={showDetail} currentRow={currentRow} searchTimeParent={searchTime} handleKnowChildrenTabChange={handleKnowChildrenTabChange} pageVersion={pageVersion} />
      </Drawer>

      {/* 没上传结账信息显示的抽屉 */}
      <Drawer
        width={'80%'}
        closable={false}
        visible={unUploadDrawer}
        bodyStyle={{ padding: 16 }}
        destroyOnClose={true}
        onClose={() => {
          setCurrentRow(undefined)
          setUnUploadDrawer(false);
        }}
        footer={<div style={{ width: '100%', display: 'flex', justifyContent: 'flex-end' }}>
          {/* <Popconfirm title={'确认删除？'} onConfirm={async () => {
            const data = await handleDeleteENDACCOUNT({ ENDACCOUNTId: currentRow?.Endaccount_Id })
            if (data.Result_Code === 100) {
              message.success(data.Result_Desc)
              setCurrentRow(undefined)
              setUnUploadDrawer(false);
              handleGetTableList()
            } else {
              message.error(data.Result_Desc)
            }
          }}>
            <Button type="primary" danger>
              删除
            </Button>
          </Popconfirm> */}
          <Button type="primary" style={{ marginLeft: '8px' }} onClick={() => {
            UnUploadDetailRef.current?.formRef.current?.validateFields().then(async (res: any) => {
              let detail: any = UnUploadDetailRef.current?.formDetail
              console.log('res', res);
              console.log('currentRow', currentRow);
              console.log('detail', detail);

              let [name, code]: any = res?.ENDPERSONCODE.split('-')
              const req: any = {
                ...detail,
                ...res,
                ENDACCOUNT_ID: detail?.ENDACCOUNT_ID,
                SERVERPART_ID: detail?.SERVERPART_ID,
                SERVERPART_NAME: detail?.SERVERPART_NAME,
                SHOPCODE: detail?.SHOPCODE,
                SHOPNAME: detail?.SHOPNAME,
                ENDACCOUNT_STARTDATE: res?.ENDACCOUNT_STARTDATE ? moment(res?.ENDACCOUNT_STARTDATE).format('YYYY-MM-DD') : '',
                ENDACCOUNT_DATE: res?.ENDACCOUNT_DATE ? moment(res?.ENDACCOUNT_DATE).format('YYYY-MM-DD') : '',
                DIFFERENT_PRICE: res?.CASHPAY_DOWNLORD - res?.CASH,
                DESCRIPTION_STAFF: currentUser?.Name + '【补】',
                DESCRIPTION_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
                DOWNLOAD_DATE: moment().format('YYYY-MM-DD HH:mm:ss'),
                CASHIER_NAME: res?.CASHIER_NAME && res?.CASHIER_NAME.length > 0 ? res?.CASHIER_NAME.toString() : '',
                ENDPERSONCODE: code,
                WORKER_NAME: name
              }
              console.log('req', req);

              const data = await handleSynchroENDACCOUNT(req)
              if (data.Result_Code === 100) {
                message.success(data.Result_Desc)
                setCurrentRow(undefined)
                setUnUploadDrawer(false);
                handleGetTableList()
              } else {
                message.error(data.Result_Desc)
              }

            })
          }}>保存</Button>
        </div>}
      >
        <UnUploadDetail currentRow={currentRow} onRef={UnUploadDetailRef} />
      </Drawer>
    </PageContainer >
  );
}

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