You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
123 lines
4.4 KiB
JavaScript
123 lines
4.4 KiB
JavaScript
import { fetchJSON, postForm } from '@/utils/request';
|
|
import { groupBy } from '@/utils/commons';
|
|
import * as config from '@/config';
|
|
import dayjs from 'dayjs';
|
|
|
|
import { create } from 'zustand';
|
|
import { devtools } from 'zustand/middleware';
|
|
|
|
const { HT_HOST } = config;
|
|
|
|
/* 查询反馈表信息
|
|
GRI_SN 团SN
|
|
VEI_SN 供应商SN
|
|
*/
|
|
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 };
|
|
};
|
|
|
|
/**
|
|
* 客人填写的反馈
|
|
* @param {number} VEI_SN 供应商
|
|
* @param {number} GRI_SN 团
|
|
* @author LYT
|
|
* 2024-01-04
|
|
*/
|
|
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 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,
|
|
feedbackList: [], //反馈列表
|
|
};
|
|
|
|
const useFeedbackStore = create(
|
|
devtools((set, get) => ({
|
|
...initialState,
|
|
reset: () => set(initialState),
|
|
|
|
setLoading: (loading) => set({ loading }),
|
|
setFeedbackList: (feedbackList) => set({ feedbackList }),
|
|
|
|
/* 查询地接社的团列表
|
|
地接社sn
|
|
团名
|
|
离团时间开始,结束
|
|
*/
|
|
async fetchFeedbackList(veisn, EOI_Group_Name, TimeStart, TimeEnd) {
|
|
const { setLoading, setFeedbackList } = get();
|
|
setLoading(true);
|
|
const searchParams = {
|
|
PageSize: 2000,
|
|
PageIndex: 1,
|
|
PageTotal: 0,
|
|
veisn: veisn,
|
|
GruopNo: EOI_Group_Name,
|
|
TimeStart,
|
|
TimeEnd,
|
|
};
|
|
const { errcode, Result } = await fetchJSON(`${HT_HOST}/service-Cooperate/Cooperate/SearchFeedbackList`, searchParams);
|
|
const _result = errcode !== 0 ? [] : Result;
|
|
// 反馈表, 有新版就用新版
|
|
const allGroup = groupBy(_result, 'EOI_GRI_SN');
|
|
const filterV = Object.keys(allGroup).reduce((r, gsn) => {
|
|
const v2 = allGroup[gsn].filter((v) => v.EOI_CII_SN);
|
|
const withAllGuide = allGroup[gsn].map((row) => ({ ...row, CityGuide: row.GriName.map((rg) => `${rg.GuideCity}: ${rg.GuideName}`).join(' ; ') }));
|
|
return r.concat(v2.length > 0 ? v2 : withAllGuide);
|
|
}, []);
|
|
setFeedbackList(filterV);
|
|
setLoading(false);
|
|
},
|
|
}), { name: 'feedbackStore'})
|
|
);
|
|
|
|
export default useFeedbackStore;
|