From d438adde67015fb189d561e723715056a275e579 Mon Sep 17 00:00:00 2001 From: LiaoYijun Date: Wed, 16 Nov 2022 11:27:20 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8A=8A=20Class=20=E7=BB=84=E4=BB=B6=E8=BD=AC?= =?UTF-8?q?=E6=8D=A2=E4=B8=BA=20Function=20=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/CustomerServices.js | 40 ++++++--- src/views/AgentList.js | 144 +++++++++++++++------------------ 2 files changed, 94 insertions(+), 90 deletions(-) diff --git a/src/stores/CustomerServices.js b/src/stores/CustomerServices.js index f11c355..746b8e1 100644 --- a/src/stores/CustomerServices.js +++ b/src/stores/CustomerServices.js @@ -1,6 +1,6 @@ import {makeAutoObservable, runInAction} from "mobx" import moment from "moment"; -import { NavLink, useParams } from "react-router-dom"; +import { NavLink } from "react-router-dom"; import * as config from "../config"; import * as req from '../utils/request'; @@ -123,18 +123,25 @@ class CustomerServices { } fetchGroupListByAgentId(agentId) { - console.info('agentId: ' + agentId); + this.selectedAgent = {VendorName: '...'}; req.fetchJSON(config.HT_HOST + '/service-web/QueryData/GetAgentGroupInfo?VEI_SN=' + agentId + '&DateType=' + this.dateType + '&Date1=' + this.startDateString + '&Date2=' + this.endDateString + '&OldDate1=' + this.startDateString + '&OldDate2=' + this.endDateString) .then(json => { if (json.errcode === 0) { runInAction(() => { this.groupList = json.result1; - this.selectedAgent = {VendorName: json.result1[0].VendorName}; + if (json.result1.length > 0) { + this.selectedAgent = {VendorName: json.result1[0].VendorName}; + } const total1 = json.total1; this.groupListColumns = [ { title: '团名', - dataIndex: 'GRI_Name' + dataIndex: 'GRI_Name', + children: [{ + title: '', + dataIndex: 'GRI_Name' + } + ] }, { title: '人数', @@ -158,15 +165,21 @@ class CustomerServices { }, { title: '经过城市', - dataIndex: 'PassCity' - }, - { - title: '地接社名称', - dataIndex: 'VendorName' + dataIndex: 'PassCity', + children: [{ + title: '-', + dataIndex: 'PassCity' + } + ] }, { title: '导游', - dataIndex: 'GuideName' + dataIndex: 'GuideName', + children: [{ + title: '-', + dataIndex: 'PassCity' + } + ] }, { title: '好评', @@ -190,7 +203,12 @@ class CustomerServices { }, { title: '评论内容', - dataIndex: 'ECI_Content' + dataIndex: 'ECI_Content', + children: [{ + title: '-', + dataIndex: 'PassCity' + } + ] }, { title: '交易额', diff --git a/src/views/AgentList.js b/src/views/AgentList.js index 43c20ab..7593c91 100644 --- a/src/views/AgentList.js +++ b/src/views/AgentList.js @@ -1,101 +1,87 @@ -import React, {Component} from 'react'; -import {Row, Col, Typography, Space, DatePicker, Button, Select, Table} from 'antd'; +import React, {useContext} from 'react'; +import { Row, Col, Typography, Space, DatePicker, Button, Select, Table } from 'antd'; import { SearchOutlined, } from '@ant-design/icons'; -import {stores_Context} from '../config' +import { stores_Context } from '../config' import * as config from "../config"; -import {observer} from 'mobx-react'; +import { observer } from 'mobx-react'; import 'moment/locale/zh-cn'; import moment from "moment"; import zhCNlocale from 'antd/es/date-picker/locale/zh_CN'; -class AgentList extends Component { +const AgentList = () => { - static contextType = stores_Context; + const { customerServicesStore } = useContext(stores_Context); + const agentList = customerServicesStore.agentList; + const agentListColumns = customerServicesStore.agentListColumns; + const { startDate, endDate, dateType } = customerServicesStore; - constructor(props) { - super(props); - } - - componentDidMount() { - } - - handleSearchClick() { - const {customerServicesStore} = this.context; - customerServicesStore.fetchAgentList(); - } - - render() { - const {customerServicesStore} = this.context; - const agentList = customerServicesStore.agentList; - const agentListColumns = customerServicesStore.agentListColumns; - const groupList = customerServicesStore.groupList; - const groupListColumns = customerServicesStore.groupListColumns; - const {startDate, endDate, dateType} = customerServicesStore; + const handleSearchClick = () => { + customerServicesStore.fetchAgentList(); + } - return ( - <> - - - - - - - {customerServicesStore.selectDateRange(dates[0], dates[1])}} - ranges={{ - '本周': [moment().startOf('week'), moment().endOf('week')], - '上周': [moment().startOf('week').subtract(7, 'days'), moment().endOf('week').subtract(7, 'days')], - '本月': [moment().startOf('month'), moment().endOf('month')], - '上个月': [moment().subtract(1, 'months').startOf('month'), moment(new Date()).subtract(1, 'months').endOf('month')], - '近30天': [moment().subtract(30, 'days'), moment()], - '近三个月': [moment().subtract(2, 'month').startOf('month'), moment().endOf('month')], - '今年': [moment().startOf('year').subtract(1, 'month'), moment().endOf('year').subtract(1, 'month')], - '去年': [moment().subtract(1, 'year').startOf('year').subtract(1, 'month'), moment().subtract(1, 'year').endOf('year').subtract(1, 'month')], - }} - /> - - - - + return ( + <> + + + + + + + { customerServicesStore.selectDateRange(dates[0], dates[1]) }} + ranges={{ + '本周': [moment().startOf('week'), moment().endOf('week')], + '上周': [moment().startOf('week').subtract(7, 'days'), moment().endOf('week').subtract(7, 'days')], + '本月': [moment().startOf('month'), moment().endOf('month')], + '上个月': [moment().subtract(1, 'months').startOf('month'), moment(new Date()).subtract(1, 'months').endOf('month')], + '近30天': [moment().subtract(30, 'days'), moment()], + '近三个月': [moment().subtract(2, 'month').startOf('month'), moment().endOf('month')], + '今年': [moment().startOf('year').subtract(1, 'month'), moment().endOf('year').subtract(1, 'month')], + '去年': [moment().subtract(1, 'year').startOf('year').subtract(1, 'month'), moment().subtract(1, 'year').endOf('year').subtract(1, 'month')], + }} + /> + + + + 地接社团信息 - record.key} - loading={false} - pagination={false} +
record.key} + loading={false} + pagination={false} scroll={{ x: "100%" }} /> - - - ); - } + + + ); } export default observer(AgentList); \ No newline at end of file