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 } from "@ant-design/icons"; import type { FormInstance } from "antd"; import { Button, message, Space, Spin, Tree, Drawer } from "antd"; import useRequest from "@ahooksjs/use-request"; import { 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 moment from "moment"; import { handleGetCheckAccountReport } from "./service"; import upload from "@/assets/upload.png"; import { handleGetCHECKACCOUNTList } from "@/pages/reports/audit/feedback/service"; import PageTitleBox from "@/components/PageTitleBox"; const checkAccountReport: React.FC<{ currentUser: CurrentUser }> = (props) => { const { currentUser } = props const downloadBtnRef = useRef() const actionRef = useRef(); const actionDrawerRef = useRef(); const formRef = useRef(); const formDrawerRef = useRef(); const [reqDetailList, setReqDetailList] = useState(); // 合计项数据源 const [printOut, setPrintOut] = useState(); // 打印数据的内容 const [collapsible, setCollapsible] = useState(false) const [treeView, setTreeView] = useState() // 加载服务区树 const { loading: treeLoading, data: treeViews } = useRequest(async () => { const data = await getServerpartTree(currentUser?.ProvinceCode, currentUser?.CityAuthority, true, true, true) setTreeView(data) return data }) // 树相关的属性和方法 const [selectedId, setSelectedId] = useState() // 导出的加载效果 const [showLoading, setShowLoading] = useState(false) // 是否显示打印的表格 const [showExportTable, setShowExportTable] = useState(false) // 行详情 const [currentRow, setCurrentRow] = useState() // 显示抽屉 const [showDetail, setShowDetail] = useState(false) const columns: any = [ { title: '统计时间', dataIndex: 'search_date', valueType: 'dateRange', hideInTable: true, hideInDescriptions: true, initialValue: [moment().subtract(7, 'days'), moment().add(-1, 'day')], search: { transform: (value) => { return { startDate: value[0], endDate: value[1], }; }, }, fieldProps: { disabledDate: (current: any) => current && current > moment().endOf('day') } }, { title: '稽查类型', dataIndex: 'checkType', hideInTable: true, hideInDescriptions: true, valueEnum: { 1: "现场稽查", 2: "区域稽查", 3: "公司稽查", 4: "指令稽查", }, initialValue: "1" }, { title: '统计口径', dataIndex: 'ShowShop', hideInTable: true, hideInDescriptions: true, valueType: 'select', valueEnum: { "1": "服务区", "2": "门店", }, initialValue: "1" }, { title: '服务区信息', hideInSearch: true, dataIndex: 'basicInfo', align: 'center', children: [ // { // title:'序号', // dataIndex:'index', // }, { title: '服务区名称', width: 200, ellipsis: true, dataIndex: 'Name', align: 'center', render: (_, record) => { return record?.ServerpartId ? { setCurrentRow(record) setShowDetail(true) }}>{record?.Name} : {record?.Name} } }, { title: '稽查点位', width: 120, align: 'center', dataIndex: 'TypePoint', }, ] }, { title: '异常信息(误差率大于0.2%)', hideInSearch: true, align: 'center', dataIndex: 'errorInfo', children: [ { title:
稽核次数
, width: 120, align: 'right', valueType: 'digit', dataIndex: 'ExauditCount', }, { title:
异常占比
, width: 120, align: 'right', dataIndex: 'ExauditRate', }, { title:
异常回馈率
, width: 120, align: 'right', dataIndex: 'FeedbackRate', }, ] }, { title: '稽核信息', dataIndex: 'reportInfo', hideInSearch: true, children: [ { title:
稽核次数
, width: 120, dataIndex: 'TypeCount', align: 'right', valueType: 'digit', }, { title:
金额误差率
, width: 120, align: 'right', dataIndex: 'PricePercent', render: (_, record) => { return record?.PricePercent ? `${record?.PricePercent}‰` : '-' } }, { title:
长款
, width: 120, align: 'right', valueType: 'digit', dataIndex: 'PriceMore' }, { title:
短款
, width: 120, align: 'right', valueType: 'digit', dataIndex: 'PriceLess' }, { title:
稽核天数
, width: 120, align: 'right', valueType: 'digit', dataIndex: 'TypeDays' }, { title:
天数占比
, width: 120, align: 'right', dataIndex: 'DaysCpercent' }, ] } ] const drawerColumns: any = [ { title: '处理状态', hideInTable: true, dataIndex: 'TREATMENT_MARKSTATE', valueType: 'select', valueEnum: { 0: '全部', 1: '未反馈', 2: '未冲正' }, initialValue: '0' }, { title: '统计时间', dataIndex: 'search_date', valueType: 'dateRange', hideInTable: true, hideInDescriptions: true, colSize: 1, initialValue: [moment().add(-1, 'month').format('YYYY-MM-DD'), moment().add(-1, "day").format('YYYY-MM-DD')], search: { transform: (value) => { return { CHECK_STARTDATE: value[0], CHECK_ENDDATE: value[1], }; }, }, fieldProps: { disabledDate: (current: any) => current && current > moment() } }, { title: '稽查类型', hideInTable: true, dataIndex: 'CHECK_TYPE', valueType: 'select', valueEnum: { "": "全部", "现场稽查": "现场稽查", "区域稽查": "区域稽查", "公司稽查": "公司稽查", }, initialValue: "" }, { title: '图片上传', hideInTable: true, hideInSearch: true, dataIndex: '' }, { title: '稽核误差率', hideInTable: true, dataIndex: 'ERROR_RATE', valueType: 'select', valueEnum: { 0: '全部', 1: '大于0.2%' }, initialValue: '1' }, { title: '上传标识', hideInTable: true, dataIndex: 'HasImage', valueType: 'select', valueEnum: { "0": '全部', "1": '支持', "2": '不支持' }, initialValue: "0" }, { title:
{'序号'}
, hideInSearch: true, width: 70, valueType: 'index', dataIndex: '' }, { title:
{'服务区名称'}
, hideInSearch: true, width: 120, dataIndex: 'SERVERPART_NAME', // render:(_,record)=>{ // return
// {record?.SERVERPART_NAME ||''} // { // record?.HasImage ? // // :'' // } //
// } }, { title:
{'门店名称'}
, hideInSearch: true, width: 150, dataIndex: 'SHOPNAME', render: (_, record) => { return
{ record?.HasImage ? : '' } {record?.SHOPNAME || ''}
} }, { title:
{'稽核反馈'}
, width: 200, ellipsis: true, hideInSearch: true, dataIndex: 'CHECKACCOUNT_DESC' }, { title:
{'稽核误差率'}
, width: 140, hideInSearch: true, align: 'right', dataIndex: 'ERROR_RATE', render: (_, record) => { return record?.ERROR_RATE ? {`${record?.ERROR_RATE}%`} : '-' } }, { title:
{'长短款/冲正流水'}
, width: 160, hideInSearch: true, align: 'right', dataIndex: 'DIFFERENT_PRICE', render: (_, record) => { return 0 || record?.REPLENISH_AMOUNT > 0 ? '#008000' : '', fontWeight: 'bold' }}> {`${record.DIFFERENT_PRICE || '0'}/${record?.REPLENISH_AMOUNT || '0'}`} } }, { title:
{'稽核现金/对客现金'}
, width: 160, hideInSearch: true, dataIndex: 'CASH', align: 'right', render: (_, record) => { return `${record.CASHPAY || ''}/${record?.CASH || ''}` } }, { title:
{'对客营收'}
, width: 120, hideInSearch: true, align: 'right', dataIndex: 'TOTALSELLAMOUNT' }, { title:
{'稽查时间'}
, width: 160, hideInSearch: true, align: 'right', dataIndex: 'CHECK_ENDDATE', render: (_, record) => { return record?.CALIBRATOR_DATE ? moment(record?.CHECK_ENDDATE).format('YYYY-MM-DD HH:mm:ss') : '-' } } ] const exportTable = (e) => { e.stopPropagation(); // 防止Collapse组件收起 const main = document.getElementsByClassName('checkAccountReportHideBox')[0] const thead = main.querySelector('thead').cloneNode(true); // 深克隆DOM节点 const tbody = main.querySelector('tbody').cloneNode(true); // 深克隆DOM节点 const container = document.querySelector('#hiddenBox'); const tempTable = document.createElement('table'); tempTable.appendChild(thead); tempTable.appendChild(tbody); tempTable.setAttribute('id', 'table-to-xls-checkAccountReport'); // 给table添加id,值与按钮上的table字段对应 container.appendChild(tempTable); // 把创建的节点添加到页面容器中 setShowLoading(false) downloadBtnRef.current.handleDownload(); setShowExportTable(false) tempTable.remove() // 防止重复打印一个内容 } // 查询的条件 const [searchParams, setSearchParams] = useState() return (
{ // 打印报表 if (!reqDetailList || reqDetailList.length === 0) return; setPrintOut(el); }} > { showLoading ?
数据导出中...
: '' }
{ showExportTable && reqDetailList && reqDetailList.length > 0 ? : '' }
{ setCollapsible(!collapsible) }} />} colSpan={!collapsible ? "300px" : "60px"} title={!collapsible ? "请选择服务区" : ""} headerBordered collapsed={collapsible} > {treeView && treeView.length > 0 ? { const selectedIds = info.checkedNodes.filter(n => n?.type === 1) setSelectedId(selectedIds.map(n => n?.value)?.toString() || '') // actionRef?.current?.reload() // getData(selectedIds.map(n => n?.value)?.toString() || '') }} // switcherIcon={} /> : ''}
record?.index + record?.Id} bordered headerTitle={} search={{ span: 6 }} scroll={{ y: 'calc(100vh - 470px)' }} pagination={false} request={async (params) => { if (!selectedId) { return } const req = { ...params, ServerpartIds: selectedId || '', ShowShop: params?.ShowShop === '1' ? false : params?.ShowShop === '2' ? true : '' } handleCallLogs() setSearchParams(params) console.log('req', req) const data = await handleGetCheckAccountReport(req) console.log('data', data) let list: any = [] if (data && data.length > 0) { list = JSON.parse(JSON.stringify(data)) list.forEach((item: any, index: number) => { item.index = index + 1 if (item.children && item.children.length > 0) { item.children.forEach((subItem: any, subIndex: number) => { subItem.index = `${index + 1}.${subIndex + 1}` if (subItem.children && subItem.children.length > 0) { subItem.children.forEach((thirdItem: any, thirdIndex: number) => { thirdItem.index = `${index + 1}.${subIndex + 1}.${thirdIndex + 1}` }) } }) } }) } console.log('list', list) setReqDetailList(list) return { data: list, success: true } }} toolbar={{ actions: [ , ] }} />
{ setCurrentRow(undefined); setShowDetail(false); }} bodyStyle={{ backgroundColor: "#f9f9f9", padding: 16 }} destroyOnClose closable={false} >
{ console.log('currentRow', currentRow) if (!currentRow?.ServerpartId) { return } const req = { SearchParameter: { ...params, TREATMENT_MARKSTATE: params.TREATMENT_MARKSTATE === '0' ? '' : params.TREATMENT_MARKSTATE, SERVERPART_IDS: currentRow?.ServerpartId, // SERVERPARTSHOP_ID: currentRow?.Id ?, HasImage: params.HasImage === '0' ? null : params.HasImage === '1' ? true : params.HasImage === '2' ? false : '', VALID: 1,// 有效 }, PageIndex: 1, PageSize: 99999 } handleCallLogs() const data = await handleGetCHECKACCOUNTList(req) if (data && data.length > 0) { return { data, success: true } } return { data: [], success: true } }} />
) } export default connect(({ user }: ConnectState) => ({ currentUser: user.currentUser }))(checkAccountReport);