import { connect } from "umi"; import type { ConnectState } from "@/models/connect"; import { FormInstance, Modal } from "antd"; import { useRef, useState } from "react"; import React from "react"; import Draggable from "react-draggable"; import ProTable, { ActionType } from "@ant-design/pro-table"; import { handleGetShopInventoryList } from "../../service"; import InventoryDetailModal from "../../InventoryDetails/components/InventoryDetailModal"; type DetailProps = { onShow: any onCancel: any parentRow: any currentUser: any ServerpartId: any // 服务区id shopId: any // 门店id } const inventoryDetail = ({ onShow, onCancel, parentRow, currentUser, ServerpartId, shopId }: DetailProps) => { const actionRef = useRef(); const formRef = useRef(); const draggleRef = React.createRef() // 弹出框拖动效果 const [bounds, setBounds] = useState<{ left: number, right: number, top: number, bottom: number }>() // 移动的位置 const [disabled, setDraggleDisabled] = useState() // 是否拖动 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), }); }; // 行数据 const [currentRow, setCurrentRow] = useState() // 显示详情 const [showDetail, setShowDetail] = useState() const columns: any = [ { title: "序号", dataIndex: "index", valueType: 'index', align: 'center', width: 80, ellipsis: true, hideInSearch: true, }, { title:
服务区名称
, dataIndex: "Serverpart_Name", align: 'center', width: 120, ellipsis: true, hideInSearch: true, }, { title:
门店名称
, dataIndex: "ServerpartShop_Name", align: 'left', width: 150, ellipsis: true, hideInSearch: true, }, { title:
商品名称
, dataIndex: "COMMODITY_NAME", align: 'left', width: 250, ellipsis: true, hideInSearch: true, render: (_, record) => { return record?.COMMODITY_NAME ? { console.log('record', record); setCurrentRow(record) setShowDetail(true) }}> {record?.COMMODITY_NAME} : "" } }, { title:
商品条码
, dataIndex: "COMMODITY_BARCODE", align: 'center', width: 120, ellipsis: true, hideInSearch: true, }, { title:
规格
, dataIndex: "COMMODITY_RULE", align: 'center', width: 120, ellipsis: true, hideInSearch: true, }, { title:
剩余数量
, dataIndex: "OVERPLUSCOUNT", align: 'right', width: 120, valueType: 'digit', ellipsis: true, hideInSearch: true, }, { title:
含税进价
, dataIndex: "OVERPLUS_AMOUNT", align: 'right', width: 120, valueType: 'digit', ellipsis: true, hideInSearch: true, }, { title:
除税进价
, dataIndex: "OVERPLUS_PRICE", align: 'right', width: 120, valueType: 'digit', ellipsis: true, hideInSearch: true, }, { title:
含税售价
, dataIndex: "OVERPLUS_XS_AMOUNT", align: 'right', width: 120, valueType: 'digit', ellipsis: true, hideInSearch: true, }, ] const handleModalCancel = () => { setCurrentRow(null) setShowDetail(false) } return (
{ if (disabled) { setDraggleDisabled(false) } }} onMouseOut={() => { setDraggleDisabled(true) }} onFocus={() => { }} onBlur={() => { }} >进销存信息
} destroyOnClose={true} width={'80%'} bodyStyle={{ height: '700px', // 你可以根据需要调整高度 overflowY: 'auto', }} visible={onShow} onCancel={() => { if (onCancel) { onCancel() } }} footer={false} modalRender={(modal) => { return onDraggaleStart(event, uiData)} handle=".COMMODITYINFOTitle" >
{modal}
}} > { console.log('parentRowparentRowparentRowparentRow', parentRow); const req: any = { ProvinceCode: currentUser?.ProvinceCode, ServerpartId: ServerpartId ? ServerpartId.toString() : "", ServerpartShopId: shopId || "", CommodityBarcode: parentRow?.COMMODITY_BARCODE, } const data = await handleGetShopInventoryList(req) console.log('datadatadatadata', data); if (data && data.length > 0) { return { data, success: true } } return { data: [], success: true } }} /> {/* 进销存明细的悬浮框 */} ) } export default connect(({ user, }: ConnectState) => ({ currentUser: user.currentUser, }))(inventoryDetail);