refactor: Feedback index
parent
66c7ba9574
commit
65eaf11d42
@ -1,109 +1,94 @@
|
||||
import { NavLink } from "react-router-dom";
|
||||
import { useEffect, useState } from "react";
|
||||
import { observer } from "mobx-react";
|
||||
import { toJS } from "mobx";
|
||||
import { Row, Col, Space, Button, Table, Input, Typography, DatePicker, App } from "antd";
|
||||
import { useStore } from "@/stores/StoreContext.js";
|
||||
import * as config from "@/config";
|
||||
import usePresets from '@/hooks/usePresets';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { useEffect } from 'react';
|
||||
import { Row, Col, Space, Table, App } from 'antd';
|
||||
import { useStore } from '@/stores/StoreContext.js';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import SearchForm from '@/components/SearchForm';
|
||||
import useFeedbackStore from '@/stores/Feedback';
|
||||
import dayjs from 'dayjs';
|
||||
|
||||
const { Title } = Typography;
|
||||
const feedbackListColumns = [
|
||||
{
|
||||
title: "Ref.No",
|
||||
dataIndex: "EOI_Group_Name",
|
||||
render: (text, record) => <NavLink to={record.EOI_CII_SN ? `/feedback/${record.EOI_GRI_SN}/${record.EOI_CII_SN}/${record.EOI_Group_Name}` : `/feedback/${record.EOI_GRI_SN}/${record.EOI_Group_Name}`}>{text}</NavLink>,
|
||||
},
|
||||
{
|
||||
title: "Arrival Date",
|
||||
dataIndex: "EOI_Date",
|
||||
render: (text, record) => text,
|
||||
sorter: (a, b) => b.EOI_Date - a.EOI_Date,
|
||||
},
|
||||
{
|
||||
title: "Cities",
|
||||
key: "City",
|
||||
dataIndex: "City",
|
||||
},
|
||||
{
|
||||
title: "Guides",
|
||||
dataIndex: "CityGuide",
|
||||
},
|
||||
{
|
||||
title: "Post Survey",
|
||||
dataIndex: "Average",
|
||||
render: (text, record) => `${(record.EOI_CII_SN && record.feedback_Filled ? "✔" : "")} ${(text ? text : "")}`, //为0显示为空
|
||||
sorter: (a, b) => b.Average - a.Average,
|
||||
},
|
||||
{
|
||||
title: "External Reviews",
|
||||
dataIndex: "TAGood",
|
||||
},
|
||||
{
|
||||
title: 'Ref.No',
|
||||
dataIndex: 'EOI_Group_Name',
|
||||
render: (text, record) => (
|
||||
<NavLink to={record.EOI_CII_SN ? `/feedback/${record.EOI_GRI_SN}/${record.EOI_CII_SN}/${record.EOI_Group_Name}` : `/feedback/${record.EOI_GRI_SN}/${record.EOI_Group_Name}`}>
|
||||
{text}
|
||||
</NavLink>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: 'Arrival Date',
|
||||
dataIndex: 'EOI_Date',
|
||||
render: (text, record) => text,
|
||||
sorter: (a, b) => b.EOI_Date - a.EOI_Date,
|
||||
},
|
||||
{
|
||||
title: 'Cities',
|
||||
key: 'City',
|
||||
dataIndex: 'City',
|
||||
},
|
||||
{
|
||||
title: 'Guides',
|
||||
dataIndex: 'CityGuide',
|
||||
},
|
||||
{
|
||||
title: 'Post Survey',
|
||||
dataIndex: 'Average',
|
||||
render: (text, record) => `${record.EOI_CII_SN && record.feedback_Filled ? '✔' : ''} ${text ? text : ''}`, //为0显示为空
|
||||
sorter: (a, b) => b.Average - a.Average,
|
||||
},
|
||||
{
|
||||
title: 'External Reviews',
|
||||
dataIndex: 'TAGood',
|
||||
},
|
||||
];
|
||||
|
||||
function Index() {
|
||||
const { notification } = App.useApp();
|
||||
const { feedbackStore, authStore } = useStore();
|
||||
const { feedbackList, search_date_start, search_date_end } = feedbackStore;
|
||||
const [referenceNo, onNumberChange] = useState("");
|
||||
const showTotal = total => `Total ${feedbackList.length} items`;
|
||||
const { t } = useTranslation();
|
||||
const { notification } = App.useApp();
|
||||
const { feedbackStore, authStore } = useStore();
|
||||
|
||||
useEffect(() => {
|
||||
// feedbackStore.searchFeedbackList(authStore.login.travelAgencyId, referenceNo, search_date_start.format(config.DATE_FORMAT), search_date_end.format(config.DATE_FORMAT) + " 23:59").catch(ex => {
|
||||
// // notification.error({
|
||||
// // message: `Error`,
|
||||
// // description: ex.message,
|
||||
// // placement: 'top',
|
||||
// // duration: 4,
|
||||
// // });
|
||||
// console.log(ex.message);
|
||||
// });
|
||||
}, []);
|
||||
const [feedbackList, fetchFeedbackList] = useFeedbackStore((state) => [state.feedbackList, state.fetchFeedbackList]);
|
||||
|
||||
return (
|
||||
<Space direction="vertical" style={{ width: "100%" }}>
|
||||
<Title level={3}></Title>
|
||||
const showTotal = (total) => `Total ${total} items`;
|
||||
|
||||
<Row gutter={16}>
|
||||
<Col md={24} lg={6} xxl={4}>
|
||||
<Input
|
||||
placeholder="Reference Number"
|
||||
onChange={e => {
|
||||
onNumberChange(e.target.value);
|
||||
}}
|
||||
/>
|
||||
</Col>
|
||||
<Col md={24} lg={8} xxl={6}>
|
||||
<Space direction="horizontal">
|
||||
Arrival Date
|
||||
<DatePicker.RangePicker
|
||||
format={config.DATE_FORMAT}
|
||||
allowClear={false}
|
||||
style={{ width: "100%" }}
|
||||
value={[search_date_start, search_date_end]}
|
||||
presets={usePresets()}
|
||||
onChange={feedbackStore.onDateRangeChange}
|
||||
/>
|
||||
</Space>
|
||||
</Col>
|
||||
<Col md={24} lg={4} xxl={4}>
|
||||
<Button
|
||||
type="primary"
|
||||
loading={feedbackStore.loading}
|
||||
onClick={() => feedbackStore.searchFeedbackList(authStore.login.travelAgencyId, referenceNo, search_date_start.format(config.DATE_FORMAT), search_date_end.format(config.DATE_FORMAT) + " 23:59")}>
|
||||
Search
|
||||
</Button>
|
||||
</Col>
|
||||
</Row>
|
||||
<Title level={3}></Title>
|
||||
<Row>
|
||||
<Col md={24} lg={24} xxl={24}>
|
||||
<Table bordered={true} columns={feedbackListColumns} dataSource={toJS(feedbackList)} pagination={{ defaultPageSize: 20, showTotal: showTotal }} />
|
||||
</Col>
|
||||
<Col md={24} lg={24} xxl={24}></Col>
|
||||
</Row>
|
||||
</Space>
|
||||
);
|
||||
useEffect(() => {
|
||||
// feedbackStore.searchFeedbackList(authStore.login.travelAgencyId, referenceNo, search_date_start.format(config.DATE_FORMAT), search_date_end.format(config.DATE_FORMAT) + " 23:59").catch(ex => {
|
||||
// // notification.error({
|
||||
// // message: `Error`,
|
||||
// // description: ex.message,
|
||||
// // placement: 'top',
|
||||
// // duration: 4,
|
||||
// // });
|
||||
// console.log(ex.message);
|
||||
// });
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<Space direction='vertical' style={{ width: '100%' }}>
|
||||
<SearchForm
|
||||
initialValue={{
|
||||
dates: [dayjs().subtract(2, 'M').startOf('M'), dayjs().endOf('M')],
|
||||
}}
|
||||
defaultValue={{
|
||||
shows: ['referenceNo', 'dates'],
|
||||
fieldProps: {
|
||||
dates: { label: t('group:ArrivalDate') },
|
||||
},
|
||||
}}
|
||||
onSubmit={(err, formVal, filedsVal) => {
|
||||
fetchFeedbackList(authStore.login.travelAgencyId, formVal.referenceNo, formVal.startdate, formVal.endtime);
|
||||
}}
|
||||
/>
|
||||
<Row>
|
||||
<Col md={24} lg={24} xxl={24}>
|
||||
<Table bordered={true} columns={feedbackListColumns} dataSource={feedbackList} pagination={{ defaultPageSize: 20, showTotal: showTotal }} />
|
||||
</Col>
|
||||
<Col md={24} lg={24} xxl={24}></Col>
|
||||
</Row>
|
||||
</Space>
|
||||
);
|
||||
}
|
||||
|
||||
export default observer(Index);
|
||||
export default Index;
|
||||
|
Loading…
Reference in New Issue