refactor: Feedback CustomerDetail

feature/price_manager
Lei OT 1 year ago
parent c7f29f4999
commit 6ad342cb2e

@ -51,8 +51,8 @@ const router = createBrowserRouter([
{ path: "account/change-password", element: <ChangePassword />},
{ path: "account/profile", element: <AccountProfile />},
{ path: "feedback", element: <FeedbackIndex />},
{ path: "feedback/:GRI_SN/:RefNo", element: <FeedbackDetail />},
{ path: "feedback/:GRI_SN/:CII_SN/:RefNo", element: <FeedbackCustomerDetail />},
{ path: "feedback/:GRI_SN/:RefNo", element: <FeedbackDetail />},
{ path: "report", element: <ReportIndex />},
{ path: "notice", element: <NoticeIndex />},
{ path: "notice/:CCP_BLID", element: <NoticeDetail />},

@ -9,6 +9,62 @@ import { devtools } from 'zustand/middleware';
const { HT_HOST } = config;
export const getFeedbackDetail = async (VEI_SN, GRI_SN) => {
const { errcode, Result, Result1 } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/getFeedbackDetail`, { VEI_SN, GRI_SN });
return errcode !== 0 ? {} : { feedbackRate: Result, feedbackReview: Result1 };
};
export const getCustomerFeedbackDetail = async (VEI_SN, GRI_SN, CII_SN) => {
const json = await fetchJSON(`${HT_HOST}/service-CooperateSOA/get_feedback_service_item`, { VEI_SN, GRI_SN, city_sn: CII_SN, lgc: 1 });
const _feedbackItemList = json.feedbackItemList;
const itemGroup = groupBy(json.feedbackItemList, 'type');
const serviceItem = {
HWO_Guide: itemGroup?.W || [],
HWO_Driver: itemGroup?.Y || [],
HWO_Activity: [
...(itemGroup['7'] || []),
...(itemGroup.G || []),
...(itemGroup.C || []),
...(itemGroup.A || []).map((ele) => ({ ...ele, Describe: ele.name })),
],
};
const OtherThoughts = json.feedbackEvaluation[0]?.otherComments || '';
const PhotoPermission = json.feedbackEvaluation[0]?.usePhotos || '';
const signatureData = json.feedbackEvaluation[0]?.signatureDataUrl || '';
const cityName = json.group[0]?.cityName || '';
return { ...serviceItem, OtherThoughts, PhotoPermission, signatureData, cityName }; // feedbackServiceRate
};
export const getFeedbackImages = async (VEI_SN, GRI_SN) => {
const { errcode, result } = await fetchJSON(`${HT_HOST}/service-fileServer/ListFile`, { VEI_SN, GRI_SN });
return errcode !== 0 ? {} : result.map((data, index) => {
return {
uid: -index, //用负数,防止添加删除的时候错误
name: data.file_name,
status: "done",
url: data.file_url,
};
});
};
export const removeFeedbackImages = async (fileurl) => {
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-fileServer/FileDelete`, { fileurl });
return errcode !== 0 ? {} : Result;
};
export const getFeedbackInfo = async (VEI_SN, GRI_SN) => {
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/getVEIFeedbackInfo`, { VEI_SN, GRI_SN });
return errcode !== 0 ? {} : Result;
};
export const postFeedbackInfo = async (VEI_SN, GRI_SN, EOI_SN, info_content) => {
const postbody = { VEI_SN, GRI_SN, EOI_SN, FeedbackInfo: info_content };
const formData = new FormData();
Object.keys(postbody).forEach(key => {
formData.append(key, postbody[key]);
});
const { errcode, Result } = await postForm(`${HT_HOST}/service-CooperateSOA/FeedbackInfo`, formData);
return errcode !== 0 ? {} : Result;
};
const initialState = {
loading: false,
search_date_start: dayjs().subtract(2, 'M').startOf('M'),
@ -37,6 +93,7 @@ const useFeedbackStore = create(
async fetchFeedbackList(veisn, EOI_Group_Name, TimeStart, TimeEnd) {
const { setLoading, setFeedbackList } = get();
setLoading(true);
const searchParams = {
PageSize: 2000,
PageIndex: 1,

@ -70,8 +70,8 @@ export function fetchText(url) {
export function fetchJSON(url, data = {}) {
const initParams = getRequestInitParams();
Object.assign(data, initParams);
const params = data ? new URLSearchParams(data).toString() : '';
const params4get = Object.assign({}, initParams, data);
const params = params4get ? new URLSearchParams(params4get).toString() : '';
const ifp = url.includes('?') ? '&' : '?';
const headerObj = getRequestHeader();
const fUrl = params !== '' ? `${url}${ifp}${params}` : url;
@ -90,6 +90,12 @@ export function fetchJSON(url, data = {}) {
}
export function postForm(url, data) {
const initParams = getRequestInitParams();
Object.keys(initParams).forEach(key => {
if (! data.has(key)) {
data.append(key, initParams[key]);
}
});
const headerObj = getRequestHeader()
return fetch(url, {
method: 'POST',

@ -1,198 +1,207 @@
import { useParams, useNavigate } from "react-router-dom";
import { useEffect } from "react";
import { observer } from "mobx-react";
import { toJS, runInAction } from "mobx";
import { Row, Col, Space, Button, Divider, Form, Typography, Rate, Radio, Upload, Input, App, Card } from "antd";
import { useStore } from "../../stores/StoreContext.js";
import { PlusOutlined } from "@ant-design/icons";
import { useParams, useNavigate } from 'react-router-dom';
import { useEffect, useState } from 'react';
import { Row, Col, Space, Button, Divider, Form, Typography, Rate, Radio, Upload, Input, App, Card } from 'antd';
import { PlusOutlined } from '@ant-design/icons';
import * as config from '@/config';
import useAuthStore from '@/stores/Auth';
import { getFeedbackDetail, getCustomerFeedbackDetail, getFeedbackImages, getFeedbackInfo, removeFeedbackImages, postFeedbackInfo } from '@/stores/Feedback';
const { Title, Text, Paragraph } = Typography;
import * as config from "@/config";
function Detail() {
const navigate = useNavigate();
const { GRI_SN, RefNo, CII_SN } = useParams();
const { feedbackStore, authStore } = useStore();
const { feedbackReview, feedbackImages, feedbackInfo, feedbackServiceRate: feedbackRate } = feedbackStore;
const desc = ["none", "Unacceptable", "Poor", "Fair", "Very Good", "Excellent"];
const { notification } = App.useApp();
const [form] = Form.useForm();
useEffect(() => {
console.info("Detail.useEffect: " + GRI_SN);
feedbackStore.getFeedbackDetail(authStore.login.travelAgencyId, GRI_SN);
feedbackStore.getCustomerFeedbackDetail(authStore.login.travelAgencyId, GRI_SN, CII_SN);
feedbackStore.getFeedbackImages(authStore.login.travelAgencyId, GRI_SN);
feedbackStore.getFeedbackInfo(authStore.login.travelAgencyId, GRI_SN).then(v => {
form.setFieldsValue({ info_content: v.EEF_Content });
});
}, [GRI_SN]);
const HWO_Guide = feedbackRate && feedbackRate.HWO_Guide ? feedbackRate.HWO_Guide : [];
const HWO_Driver = feedbackRate && feedbackRate.HWO_Driver ? feedbackRate.HWO_Driver : [];
const HWO_Activity = feedbackRate && feedbackRate.HWO_Activity ? feedbackRate.HWO_Activity : [];
const OtherThoughts = feedbackRate && feedbackRate.OtherThoughts ? feedbackRate.OtherThoughts : "";
const signatureData = feedbackRate && feedbackRate.signatureData ? feedbackRate.signatureData : "";
const PhotoPermission = feedbackRate?.PhotoPermission === 1;
const cityName = feedbackRate.cityName;
const ECI_Content = feedbackReview && feedbackReview.ECI_Content ? feedbackReview.ECI_Content : "None";
const fileList = toJS(feedbackImages);
const handleChange = info => {
let newFileList = [...info.fileList];
newFileList = newFileList.map(file => {
if (file.response && file.response.result) {
file.url = file.response.result.file_url;
}
return file;
});
runInAction(() => {
feedbackStore.feedbackImages = newFileList;
});
};
const handRemove = info => {
return feedbackStore.removeFeedbackImages(info.url);
};
const onFinish = values => {
console.log("Success:", values);
if (values) {
feedbackStore.postFeedbackInfo(feedbackInfo.EEF_VEI_SN, feedbackInfo.EEF_GRI_SN, feedbackInfo.EEF_EOI_SN, values.info_content).then(() => {
notification.success({
message: `Notification`,
description: "Submit Successful",
placement: "top",
duration: 4,
});
});
}
};
return (
<Space direction="vertical" style={{ width: "100%" }}>
<Row gutter={16}>
<Col span={20}>
</Col>
<Col span={4}>
<Button type="link" onClick={() => navigate("/feedback")}>
Back
</Button>
</Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card type="inner" title={<Title level={4}>Post Survey {RefNo} in {cityName}</Title>}>
<Form labelCol={{ span: 5 }}>
<Divider orientation="left">How satisfied were you with your tour guide?</Divider>
{HWO_Guide.map(ele => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className="ant-rate-text">{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation="left">How about the Driver and Car/Van?</Divider>
{HWO_Driver.map(ele => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className="ant-rate-text">{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation="left">General Experience with:</Divider>
{HWO_Activity.map(ele => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className="ant-rate-text">{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation="left">Would you like to give us permission to use the photos taken by the tour guide(s) during your trip which contain your portrait?</Divider>
<Paragraph>
{PhotoPermission ? (
<>
<Radio checked>Yes</Radio>
<Radio disabled={true}>No</Radio>
</>
) : (
<>
<Radio disabled={true}>Yes</Radio>
<Radio checked>No</Radio>
</>
)}
</Paragraph>
<Divider orientation="left">Other thoughts you want to share with us:</Divider>
<Text>{OtherThoughts}</Text>
<Divider orientation="left">Signature:</Divider>
{signatureData ? <img id="signature-img" alt="customer signature" title="customer signature" src={signatureData} /> : null}
</Form></Card>
</Col>
<Col span={4}></Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card type="inner" title={<Title level={4}>External Reviews</Title>}>
<Text>{ECI_Content}</Text>
</Card>
</Col>
<Col span={4}></Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card type="inner" title={<Title level={4}>Feedback from local agent</Title>}>
<Form name="feedback_detail_from" onFinish={onFinish} labelCol={{ span: 5 }} form={form}>
<Form.Item>
<Upload
name="ghhfile"
// accept="image/*"
multiple={true}
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GRI_SN}&VEI_SN=${authStore.login.travelAgencyId}&token=${authStore.login.token}`}
fileList={fileList}
listType="picture-card"
onChange={handleChange}
onRemove={handRemove}>
<div>
<PlusOutlined />
<div style={{ marginTop: 8 }}>Upload photos</div>
</div>
</Upload>
</Form.Item>
<Form.Item
name="info_content"
rules={[
{
required: true,
message: "Please input your messages!",
},
]}>
<Input.TextArea rows={6} placeholder="Any feedback for this group you would like to send to Asia Highlights"></Input.TextArea>
</Form.Item>
<Form.Item>
<Button type="primary" htmlType="submit">
Submit
</Button>
</Form.Item>
</Form>
</Card>
</Col>
<Col span={4}></Col>
</Row>
</Space>
);
const navigate = useNavigate();
const { GRI_SN, RefNo, CII_SN } = useParams();
const [travelAgencyId, token] = useAuthStore((state) => [state.loginUser.travelAgencyId, state.loginUser.token]);
const desc = ['none', 'Unacceptable', 'Poor', 'Fair', 'Very Good', 'Excellent'];
const { notification } = App.useApp();
const [form] = Form.useForm();
const [feedbackRate, setFeedbackRate] = useState({});
const [feedbackReview, setFeedbackReview] = useState({});
const [feedbackImages, setFeedbackImages] = useState([]);
const [feedbackInfo, setFeedbackInfo] = useState({});
useEffect(() => {
console.info('Detail.useEffect: ' + GRI_SN);
getFeedbackDetail(travelAgencyId, GRI_SN).then((res) => {
setFeedbackRate(res.feedbackRate);
setFeedbackReview(res.feedbackReview);
});
getCustomerFeedbackDetail(travelAgencyId, GRI_SN, CII_SN).then((res) => setFeedbackRate(res));
getFeedbackImages(travelAgencyId, GRI_SN).then((res) => setFeedbackImages(res));
getFeedbackInfo(travelAgencyId, GRI_SN).then((v) => {
form.setFieldsValue({ info_content: v.EEF_Content });
setFeedbackInfo(v);
});
}, [GRI_SN]);
const HWO_Guide = feedbackRate && feedbackRate.HWO_Guide ? feedbackRate.HWO_Guide : [];
const HWO_Driver = feedbackRate && feedbackRate.HWO_Driver ? feedbackRate.HWO_Driver : [];
const HWO_Activity = feedbackRate && feedbackRate.HWO_Activity ? feedbackRate.HWO_Activity : [];
const OtherThoughts = feedbackRate && feedbackRate.OtherThoughts ? feedbackRate.OtherThoughts : '';
const signatureData = feedbackRate && feedbackRate.signatureData ? feedbackRate.signatureData : '';
const PhotoPermission = feedbackRate?.PhotoPermission === 1;
const cityName = feedbackRate?.cityName || '';
const ECI_Content = feedbackReview && feedbackReview.ECI_Content ? feedbackReview.ECI_Content : 'None';
const fileList = feedbackImages;
const handleChange = (info) => {
let newFileList = [...info.fileList];
newFileList = newFileList.map((file) => {
if (file.response && file.response.result) {
file.url = file.response.result.file_url;
}
return file;
});
setFeedbackImages(newFileList);
};
const handRemove = (info) => {
return removeFeedbackImages(info.url);
};
const onFinish = (values) => {
// console.log("Success:", values);
if (values) {
postFeedbackInfo(feedbackInfo.EEF_VEI_SN, feedbackInfo.EEF_GRI_SN, feedbackInfo.EEF_EOI_SN, values.info_content).then(() => {
notification.success({
message: `Notification`,
description: 'Submit Successful',
placement: 'top',
duration: 4,
});
});
}
};
return (
<Space direction='vertical' style={{ width: '100%' }}>
<Row gutter={16}>
<Col span={20}></Col>
<Col span={4}>
<Button type='link' onClick={() => navigate('/feedback')}>
Back
</Button>
</Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card
type='inner'
title={
<Title level={4}>
Post Survey {RefNo} in {cityName}
</Title>
}>
<Form labelCol={{ span: 5 }}>
<Divider orientation='left'>How satisfied were you with your tour guide?</Divider>
{HWO_Guide.map((ele) => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className='ant-rate-text'>{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation='left'>How about the Driver and Car/Van?</Divider>
{HWO_Driver.map((ele) => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className='ant-rate-text'>{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation='left'>General Experience with:</Divider>
{HWO_Activity.map((ele) => (
<Form.Item label={ele.Describe} key={ele.id}>
<Space>
<Rate disabled value={ele.rate} />
<span className='ant-rate-text'>{desc[ele.rate]}</span>
</Space>
</Form.Item>
))}
<Divider orientation='left'>Would you like to give us permission to use the photos taken by the tour guide(s) during your trip which contain your portrait?</Divider>
<Paragraph>
{PhotoPermission ? (
<>
<Radio checked>Yes</Radio>
<Radio disabled={true}>No</Radio>
</>
) : (
<>
<Radio disabled={true}>Yes</Radio>
<Radio checked>No</Radio>
</>
)}
</Paragraph>
<Divider orientation='left'>Other thoughts you want to share with us:</Divider>
<Text>{OtherThoughts}</Text>
<Divider orientation='left'>Signature:</Divider>
{signatureData ? <img id='signature-img' alt='customer signature' title='customer signature' src={signatureData} /> : null}
</Form>
</Card>
</Col>
<Col span={4}></Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card type='inner' title={<Title level={4}>External Reviews</Title>}>
<Text>{ECI_Content}</Text>
</Card>
</Col>
<Col span={4}></Col>
</Row>
<Row gutter={16}>
<Col span={4}></Col>
<Col span={18}>
<Card type='inner' title={<Title level={4}>Feedback from local agent</Title>}>
<Form name='feedback_detail_from' onFinish={onFinish} labelCol={{ span: 5 }} form={form}>
<Form.Item>
<Upload
name='ghhfile'
// accept="image/*"
multiple={true}
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GRI_SN}&VEI_SN=${travelAgencyId}&token=${token}`}
fileList={fileList}
listType='picture-card'
onChange={handleChange}
onRemove={handRemove}>
<div>
<PlusOutlined />
<div style={{ marginTop: 8 }}>Upload photos</div>
</div>
</Upload>
</Form.Item>
<Form.Item
name='info_content'
rules={[
{
required: true,
message: 'Please input your messages!',
},
]}>
<Input.TextArea rows={6} placeholder='Any feedback for this group you would like to send to Asia Highlights'></Input.TextArea>
</Form.Item>
<Form.Item>
<Button type='primary' htmlType='submit'>
Submit
</Button>
</Form.Item>
</Form>
</Card>
</Col>
<Col span={4}></Col>
</Row>
</Space>
);
}
export default observer(Detail);
export default Detail;

@ -1,9 +1,9 @@
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 useAuthStore from '@/stores/Auth';
import useFeedbackStore from '@/stores/Feedback';
import dayjs from 'dayjs';
@ -47,9 +47,9 @@ const feedbackListColumns = [
function Index() {
const { t } = useTranslation();
const { notification } = App.useApp();
const { feedbackStore, authStore } = useStore();
const [feedbackList, fetchFeedbackList] = useFeedbackStore((state) => [state.feedbackList, state.fetchFeedbackList]);
const travelAgencyId = useAuthStore((state) => state.loginUser.travelAgencyId)
const [loading, feedbackList, fetchFeedbackList] = useFeedbackStore((state) => [state.loading, state.feedbackList, state.fetchFeedbackList]);
const showTotal = (total) => `Total ${total} items`;
@ -78,12 +78,12 @@ function Index() {
},
}}
onSubmit={(err, formVal, filedsVal) => {
fetchFeedbackList(authStore.login.travelAgencyId, formVal.referenceNo, formVal.startdate, formVal.endtime);
fetchFeedbackList(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 }} />
<Table bordered={true} columns={feedbackListColumns} dataSource={feedbackList} pagination={{ defaultPageSize: 20, showTotal: showTotal }} loading={loading} />
</Col>
<Col md={24} lg={24} xxl={24}></Col>
</Row>

Loading…
Cancel
Save