/* * @Author: cclu * @Date: 2022-03-10 16:59:45 * @LastEditTime: 2024-01-23 18:45:00 * @LastEditors: cclu 1106109051@qq.com * @Description: 销售流水页面 * @FilePath: \cloud-platform\src\pages\merchantManagement\reports\SalesFlow\index.tsx */ import { connect } from 'umi'; import useRequest from '@ahooksjs/use-request'; import { PageContainer } from '@ant-design/pro-layout'; import ProTable from '@ant-design/pro-table'; import FlowDetail from './components/FlowDetail'; import ProCard from '@ant-design/pro-card'; import { MenuFoldOutlined } from '@ant-design/icons'; import { Button, Descriptions, message, Modal, Space, Tree, Typography } from 'antd'; import { useRef, useState } from 'react'; import type { ConnectState } from '@/models/connect'; import type { ProFormInstance } from '@ant-design/pro-form'; import type { ActionType, ProColumns } from '@ant-design/pro-table'; import type { YSSELLMASTERModel } from './data'; import type { CurrentUser } from '@/models/user'; import moment from 'moment'; import numeral from 'numeral'; import { exportExcel } from '@/utils/utils'; import { getYSSellMasterList } from './service'; import { getMoney, getUserShopTree } from '@/services/options'; import '../../style.less'; import './salesFlow.less' import { getYSSellMasterListAllData } from '@/pages/reports/BusinessAnalysis/saleFlow/service'; const { Text } = Typography; /** * @description: 商户销售流水查询 * @param {CurrentUser} CurrentUser 当前登录的用户信息 * @return {React.FC} 页面主题 */ const CommoditysaleTable: React.FC<{ currentUser: CurrentUser | undefined }> = (props) => { const { currentUser } = props const actionRef = useRef(); const formRef = useRef(); const [currentRow, setCurrentRow] = useState(); // 选中的流水 const [visible, setVisible] = useState(); // 流水明显弹出框 const [reqDetailList, setReqDetailList] = useState(); const [collapsible, setCollapsible] = useState(false) // 是否隐藏门店服务区筛选 const { loading: shopLoading, data: shopTree } = useRequest(() => { return getUserShopTree(currentUser?.ID) }) const defaultShops = currentUser?.ServerpartShopIds ? currentUser?.ServerpartShopIds.split(',').map(Number) : [] const [shopId, setShopId] = useState<[]>(); // 选择的门店 根据选择的门店筛选数据结果 const [otherData, setOtherData] = useState() const columns: ProColumns[] = [ { dataIndex: 'index', title: '序号', hideInSearch: true, // valueType: 'index', // fixed: true, align: 'center', width: 48, render: (_, reocrd) => { return reocrd.index } }, { dataIndex: 'SELLMASTER_DATE', valueType: "date", title: '销售时间', align: 'center', initialValue: moment().add(-1, 'day'), render: (_, record) => { return record?.SELLMASTER_DATE }, fieldProps: { disabledDate: (current: any) => current && current > moment().endOf('day').add(-1, 'day') } }, { dataIndex: 'TICKET_CODE', title: '小票编号', hideInSearch: true, align: 'center', }, { dataIndex: 'SELLMASTER_COUNT', title: '销售数量', hideInSearch: true, align: 'right', sorter: (a, b) => a.SELLMASTER_COUNT - b.SELLMASTER_COUNT }, { dataIndex: 'SELLMASTER_AMOUNT', title: '实收金额', hideInSearch: true, valueType: "money", align: 'right', sorter: (a, b) => a.SELLMASTER_AMOUNT - b.SELLMASTER_AMOUNT }, { dataIndex: 'SELLMASTER_OFFPRICE', title: '优惠金额', hideInSearch: true, valueType: "money", align: 'right', sorter: (a, b) => a.SELLMASTER_OFFPRICE - b.SELLMASTER_OFFPRICE }, { dataIndex: 'PAYMENT_TYPE_TEXT', title: '支付方式', hideInSearch: true, align: 'center', }, { dataIndex: 'SHOPNAME', hideInSearch: true, title: '门店名称', align: 'center', width: '12%', }, { dataIndex: 'MACHINECODE', hideInSearch: true, title: '收银机号', align: 'center', }, { dataIndex: 'SELLWORKER_NAME', hideInSearch: true, title: '收银人员', align: 'center', } ]; return ( { setCollapsible(!collapsible) }} />} colSpan={!collapsible ? "240px" : "60px"} title={!collapsible ? "可筛选门店" : ""} headerBordered collapsed={collapsible} > {shopTree && { if (checkedInfo.checkedNodes.length > 0) { const checkedPart = checkedInfo.checkedNodes.reduce((accumulator: any[], current: { type: number; value: any; }) => { if (current.type === 2) { accumulator.push(current.value) } return accumulator }, []) setShopId(checkedPart.toString()) } else { setShopId([]) } // actionRef.current?.reload() return checkedKeys }} > } rowKey="SELLMASTER_CODE" headerTitle={销售流水明细} formRef={formRef} actionRef={actionRef} search={{ span: 6 }} request={async (params) => { if (shopId && shopId.length > 0) { const data = await getYSSellMasterListAllData({ ...params, SERVERPARTSHOP_ID: shopId && shopId.length > 0 ? shopId.toString() : currentUser?.ServerpartShopIds, }); setReqDetailList(data.List); console.log('data', data); const list: any = JSON.parse(JSON.stringify(data.List)) if (list && list.length > 0) { list.forEach((item: any, index: number) => { item.index = index + 1 }) } console.log('list', list); data.List = list setOtherData(data.OtherData) return { data: data.List, success: true }; } return { data: [], success: true } }} rowClassName="saleflow-row" bordered columns={columns} toolbar={{ actions: [ ], }} tableExtraRender={ (_, data) => { if (data) { const devicesList: any = [] const reduceData = data.reduce(( p: { SELLMASTER_OFFPRICE: number, SELLMASTER_COUNT: number, SELLMASTER_AMOUNT: number, MACHINECODE: string[], payway: {}, mobilePay: {} }, currentValue: YSSELLMASTERModel) => { const previousValue = { ...p } previousValue.SELLMASTER_COUNT += currentValue.SELLMASTER_COUNT || 0; // 销售数量 previousValue.SELLMASTER_OFFPRICE += currentValue.SELLMASTER_OFFPRICE || 0; // 优惠金额 previousValue.SELLMASTER_AMOUNT += currentValue.SELLMASTER_AMOUNT || 0; // 实收金额 if (devicesList.indexOf(currentValue.MACHINECODE) === -1) { devicesList.push(currentValue.MACHINECODE) } if (currentValue.PAYMENT_TYPE === 1010 || currentValue.PAYMENT_TYPE === 1020) { previousValue.payway['移动'] += currentValue.SELLMASTER_AMOUNT if (!previousValue.mobilePay[currentValue.PAYMENT_TYPE_TEXT]) { // 移动支付方式 previousValue.mobilePay[currentValue.PAYMENT_TYPE_TEXT] = 0 } previousValue.mobilePay[currentValue.PAYMENT_TYPE_TEXT] += currentValue.SELLMASTER_AMOUNT } else { if (!previousValue.payway[currentValue.PAYMENT_TYPE_TEXT]) { // 支付方式 previousValue.payway[currentValue.PAYMENT_TYPE_TEXT] = 0 } previousValue.payway[currentValue.PAYMENT_TYPE_TEXT] += currentValue.SELLMASTER_AMOUNT } if (!previousValue.MACHINECODE.includes(currentValue.MACHINECODE)) { previousValue.MACHINECODE.push(currentValue.MACHINECODE); // 收银机号 } return previousValue }, { SELLMASTER_OFFPRICE: 0, SELLMASTER_COUNT: 0, SELLMASTER_AMOUNT: 0, MACHINECODE: [], payway: { '移动': 0, '现金': 0, }, mobilePay: {} }); return
合计信息} size="small" column={7} className="commity-sale-description" contentStyle={{ fontWeight: "bolder" }} labelStyle={{ color: "#00000073" }} > {numeral(data.length).format('0,0')} ¥{numeral(reduceData.SELLMASTER_AMOUNT).format('0,0.00')} ¥{numeral(reduceData.SELLMASTER_OFFPRICE).format('0,0.00')} ¥{numeral(reduceData.SELLMASTER_AMOUNT / data.length).format('0,0.00')} {numeral(reduceData.SELLMASTER_COUNT).format('0,0')} {devicesList && devicesList.length > 0 ? devicesList.length : '-'}台 {moment().format('YYYY-MM-DD')} 支付明细} size="small" column={7} className="commity-sale-description" contentStyle={{ fontWeight: "bolder" }} labelStyle={{ color: "#00000073" }} > {otherData?.CASH ? `¥${numeral(getMoney(otherData?.CASH)).format('0,0.00')}` : '¥0.00'} {otherData?.TICKETBILL ? `¥${numeral(getMoney(otherData?.TICKETBILL)).format('0,0.00')}` : '¥0.00'} {otherData?.OTHERPAY ? `¥${numeral(getMoney(otherData?.OTHERPAY)).format('0,0.00')}` : '¥0.00'} {otherData?.CREDITCARD ? `¥${numeral(getMoney(otherData?.CREDITCARD)).format('0,0.00')}` : '¥0.00'} {otherData?.YUNSHANFU ? `¥${numeral(getMoney(otherData?.YUNSHANFU)).format('0,0.00')}` : '¥0.00'} {otherData?.COUPONTYPE_2010 ? `¥${numeral(getMoney(otherData?.COUPONTYPE_2010)).format('0,0.00')}` : '¥0.00'} {otherData?.COUPONTYPE_2020 ? `¥${numeral(getMoney(otherData?.COUPONTYPE_2020)).format('0,0.00')}` : '¥0.00'} {otherData?.COUPONTYPE_2030 ? `¥${numeral(getMoney(otherData?.COUPONTYPE_2030)).format('0,0.00')}` : '¥0.00'} {otherData?.COUPONTYPE_2040 ? `¥${numeral(getMoney(otherData?.COUPONTYPE_2040)).format('0,0.00')}` : '¥0.00'} {otherData?.SELLMASTERTYPE_1010 ? `¥${numeral(getMoney(otherData?.SELLMASTERTYPE_1010)).format('0,0.00')}` : '¥0.00'} {otherData?.SELLMASTERTYPE_1020 ? `¥${numeral(getMoney(otherData?.SELLMASTERTYPE_1020)).format('0,0.00')}` : '¥0.00'} {otherData?.SELLMASTERTYPE_1030 ? `¥${numeral(getMoney(otherData?.SELLMASTERTYPE_1030)).format('0,0.00')}` : '¥0.00'} {otherData?.SELLMASTERTYPE_1040 ? `¥${numeral(getMoney(otherData?.SELLMASTERTYPE_1040)).format('0,0.00')}` : '¥0.00'}
} return <> } } onRow={(record) => { return { onClick: () => { setCurrentRow(record) setVisible(true) } } }} pagination={{ defaultPageSize: 10 }} />
setVisible(false)} onCancel={() => setVisible(false)} width={1024} bodyStyle={{ padding: 0 }} destroyOnClose > {currentRow && }
); }; export default connect(({ user }: ConnectState) => ({ currentUser: user.currentUser }))(CommoditysaleTable);