import React, { useContext, useEffect } from "react"; import { Row, Col, Tabs, Table, Divider } from "antd"; import { ContainerOutlined } from "@ant-design/icons"; import { stores_Context } from "../config"; import { Line } from "@ant-design/charts"; import { observer } from "mobx-react"; import { NavLink, useParams } from "react-router-dom"; import * as comm from "../utils/commons"; import * as config from "../config"; import { utils, writeFileXLSX } from "xlsx"; import DateGroupRadio from '../components/DateGroupRadio'; import SearchForm from './../components/search/SearchForm'; const Orders_sub = () => { const { ordertype, ordertype_sub, ordertype_title } = useParams(); const { orders_store, date_picker_store } = useContext(stores_Context); useEffect(() => { orders_store.getOrderCount_type(ordertype, ordertype_sub); orders_store.getOrderCountByType_sub(ordertype, ordertype_sub, orders_store.active_tab_key_sub); }, []); // const data_source = orders_store.orderCountData_type; const data_source = orders_store.orderCountData_type ? orders_store.orderCountData_type : []; const avg_line_y = Math.round(orders_store.orderCount_type_dateRadio.avgLine1); // const avg_line_y = data_source.length ? Math.round(data_source.reduce((a, b) => a + b.yField, 0) / data_source.length) : 0; // 平均值,显示一条平均线 const line = { data: data_source, padding: "auto", xField: "xField", yField: "yField", seriesField: "seriesField", xAxis: { type: "cat", }, annotations: [ { type: "text", position: ["start", avg_line_y], content: avg_line_y, offsetX: -15, style: { fill: "#F4664A", textBaseline: "bottom", }, }, { type: "line", start: [-10, avg_line_y], end: ["max", avg_line_y], style: { stroke: "#F4664A", lineDash: [2, 2], }, }, ], tooltip: { customItems: (originalItems) => { return originalItems.map(ele => ({...ele, name: ele.data?.seriesField || ele.data?.xField})); }, title: (title, datum) => { return orders_store.orderCount_type_dateRadio.lineChartXGroup === 'day' ? `${title} ${comm.getWeek(datum.xField)}` : title; }, }, label: {}, // 显示标签 legend: { title: { text: ordertype_title, }, itemValue: { formatter: (text, item) => { const items = data_source.filter(d => d.seriesField === item.value); // 按站点筛选 return items.length ? items.reduce((a, b) => a + b.yField, 0) : ""; // 计算总数 }, }, }, smooth: true, }; const format_data = data => { const result = { dataSource: [], columns: [] }; if (!comm.empty(data)) { result.columns = [ { title: "页面", children: [ { title: "", dataIndex: "request_uri", }, ], }, { title: "访问量", children: [ { title: data.reduce((a, b) => a + b.viewCount, 0), dataIndex: "viewCount", }, ], }, ]; result.dataSource = data; } return result; }; const format_data_detail = data => { const result = { dataSource: [], columns: [] }; if (!comm.empty(data)) { result.columns = [ { title: "订单号", dataIndex: "COLI_ID", key: "COLI_ID", }, { title: "网站", dataIndex: "COLI_WebCode", key: "COLI_WebCode", }, { title: "成行", dataIndex: "COLI_Success", key: "COLI_Success", render: (text, record) => {text == 1 ? "是" : "否"}, sorter: (a, b) => b.COLI_Success - a.COLI_Success, }, // { // title: "人数(成/童/婴)", // dataIndex: "COLI_PersonNum", // key: "COLI_PersonNum", // render: (text, record) => ( // // {record.COLI_PersonNum}/{record.COLI_ChildNum}/{record.COLI_BabyNum} // // ), // }, { title: "预计利润", dataIndex: "CGI_YJLY", key: "CGI_YJLY", }, { title: "预定时间", dataIndex: "COLI_ApplyDate", key: "COLI_ApplyDate", }, { title: "出发日期", dataIndex: "COLI_OrderStartDate", key: "COLI_OrderStartDate", }, { title: "客人需求", dataIndex: "COLI_CustomerRequest", key: "COLI_CustomerRequest", ellipsis: true, }, { title: "订单内容", dataIndex: "COLI_OrderDetailText", key: "COLI_OrderDetailText", ellipsis: true, }, Table.EXPAND_COLUMN, ]; result.dataSource = data; } return result; }; const table_data = format_data_detail(orders_store.orderCountData_Form_sub.ordercount1); const table_data2 = format_data_detail(orders_store.orderCountData_Form_sub.ordercount2); const table_data_p = format_data(orders_store.orderCountData_Form_sub.ordercount1); const table_data2_p = format_data(orders_store.orderCountData_Form_sub.ordercount2); return (