diff --git a/src/stores/Feedback.js b/src/stores/Feedback.js index 17f5313..a9f40fe 100644 --- a/src/stores/Feedback.js +++ b/src/stores/Feedback.js @@ -1,31 +1,37 @@ -import { makeAutoObservable, runInAction } from "mobx"; -import { fetchJSON, postForm } from "@/utils/request"; -import { prepareUrl, groupBy } from "@/utils/commons"; -import * as config from "@/config"; -import dayjs from "dayjs"; +import { makeAutoObservable, runInAction } from 'mobx'; +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; -export const getFeedbackDetail = async (VEI_SN, GRI_SN) => { +/* 查询反馈表信息 + 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 }; }; -export const getCustomerFeedbackDetail = async (VEI_SN, GRI_SN, CII_SN) => { + +/** + * 客人填写的反馈 + * @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 _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 })), - ], + 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 || ''; @@ -36,21 +42,25 @@ export const getCustomerFeedbackDetail = async (VEI_SN, GRI_SN, CII_SN) => { }; 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, - }; - }); + 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) => { + +//获取供应商反馈信息 +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; }; @@ -58,7 +68,7 @@ export const getFeedbackInfo = async (VEI_SN, GRI_SN) => { 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 => { + Object.keys(postbody).forEach((key) => { formData.append(key, postbody[key]); }); const { errcode, Result } = await postForm(`${HT_HOST}/service-CooperateSOA/FeedbackInfo`, formData); @@ -67,14 +77,7 @@ export const postFeedbackInfo = async (VEI_SN, GRI_SN, EOI_SN, info_content) => const initialState = { loading: false, - search_date_start: dayjs().subtract(2, 'M').startOf('M'), - search_date_end: dayjs().endOf('M'), feedbackList: [], //反馈列表 - feedbackImages: [], //图片列表 - feedbackRate: [], //反馈评分 - feedbackReview: [], //站外好评 - feedbackInfo: [], //地接社反馈的信息 - feedbackServiceRate: {}, // 反馈评分, 含细项的版本 }; const useFeedbackStore = create( @@ -85,12 +88,12 @@ const useFeedbackStore = create( setState: (state) => set(state), setLoading: (loading) => set({ loading }), setFeedbackList: (feedbackList) => set({ feedbackList }), - setFeedbackImages: (feedbackImages) => set({ feedbackImages }), - setFeedbackRate: (feedbackRate) => set({ feedbackRate }), - setFeedbackReview: (feedbackReview) => set({ feedbackReview }), - setFeedbackInfo: (feedbackInfo) => set({ feedbackInfo }), - setFeedbackServiceRate: (feedbackServiceRate) => set({ feedbackServiceRate }), + /* 查询地接社的团列表 + 地接社sn + 团名 + 离团时间开始,结束 + */ async fetchFeedbackList(veisn, EOI_Group_Name, TimeStart, TimeEnd) { const { setLoading, setFeedbackList } = get(); setLoading(true); @@ -119,199 +122,3 @@ const useFeedbackStore = create( ); export default useFeedbackStore; - -export class Feedback { - constructor(root) { - makeAutoObservable(this, { rootStore: false }); - this.root = root; - } - - loading = false; - search_date_start = dayjs().subtract(2, "M").startOf("M"); - search_date_end = dayjs().endOf("M"); - feedbackList = []; //反馈列表 - feedbackImages = []; //图片列表 - feedbackRate = []; //反馈评分 - feedbackReview = []; //站外好评 - feedbackInfo = []; //地接社反馈的信息 - feedbackServiceRate = {}; // 反馈评分, 含细项的版本 - - onDateRangeChange = dates => { - console.log(dates); - this.search_date_start = dates[0]; - this.search_date_end = dates[1]; - }; - - /* 查询地接社的团列表 - 地接社sn - 团名 - 离团时间开始,结束 - */ - searchFeedbackList(veisn, EOI_Group_Name, TimeStart, TimeEnd) { - this.loading = true; - let url = `/service-Cooperate/Cooperate/SearchFeedbackList`; - url += `?PageSize=2000&PageIndex=1&PageTotal=0&veisn=${veisn}&GruopNo=${EOI_Group_Name}&TimeStart=${TimeStart}&TimeEnd=${TimeEnd}`; - url += `&token=${this.root.authStore.login.token}`; - return fetchJSON(config.HT_HOST + url).then(json => { - // 反馈表, 有新版就用新版 - const allGroup = groupBy(json.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_AsJOSN.map(rg => `${rg.GuideCity}: ${rg.GuideName}`).join(' ; ')})); - return r.concat(v2.length > 0 ? v2 : withAllGuide); - }, []) - runInAction(() => { - this.feedbackList = filterV; - this.loading = false; - }); - if (json.errcode !== 0) { - throw new Error(json.errmsg + ": " + json.errcode); - } - }); - } - - /* 查询反馈表信息 - GRI_SN 团SN - VEI_SN 供应商SN - */ - getFeedbackDetail(VEI_SN, GRI_SN) { - let url = `/service-Cooperate/Cooperate/getFeedbackDetail`; - url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}`; - url += `&token=${this.root.authStore.login.token}`; - fetch(config.HT_HOST + url) - .then(response => response.json()) - .then(json => { - console.log(json); - runInAction(() => { - this.feedbackRate = json.Result; - this.feedbackReview = json.Result1; - }); - }) - .catch(error => { - console.log("fetch data failed", error); - }); - } - - /** - * 客人填写的反馈 - * @param {number} VEI_SN 供应商 - * @param {number} GRI_SN 团 - * @author LYT - * 2024-01-04 - */ - getCustomerFeedbackDetail(VEI_SN, GRI_SN, CII_SN) { - let url = `/service-CooperateSOA/get_feedback_service_item`; - url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}&city_sn=${CII_SN}&lgc=1`; - url += `&token=${this.root.authStore.login.token}`; - fetch(config.HT_HOST + url) - .then((response) => response.json()) - .then((json) => { - 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 || ''; - - runInAction(() => { - this.feedbackServiceRate = { ...serviceItem, OtherThoughts, PhotoPermission, signatureData, cityName }; - }); - }) - .catch((error) => { - console.log('fetch data failed', error); - }); - } - - //获取供应商提交的图片 - getFeedbackImages(VEI_SN, GRI_SN) { - let url = `/service-fileServer/ListFile`; - url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}`; - url += `&token=${this.root.authStore.login.token}`; - fetch(config.HT_HOST + url) - .then(response => response.json()) - .then(json => { - console.log(json); - runInAction(() => { - this.feedbackImages = json.result.map((data, index) => { - return { - uid: -index, //用负数,防止添加删除的时候错误 - name: data.file_name, - status: "done", - url: data.file_url, - }; - }); - }); - }) - .catch(error => { - console.log("fetch data failed", error); - }); - } - - //获取供应商反馈信息 - getFeedbackInfo(VEI_SN, GRI_SN) { - let url = `/service-Cooperate/Cooperate/getVEIFeedbackInfo`; - url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}`; - url += `&token=${this.root.authStore.login.token}`; - return fetch(config.HT_HOST + url) - .then(response => response.json()) - .then(json => { - console.log(json); - runInAction(() => { - this.feedbackInfo = json.Result; - }); - return json.Result; - }) - .catch(error => { - console.log("fetch data failed", error); - }); - } - //删除照片 - removeFeedbackImages(fileurl) { - let url = `/service-fileServer/FileDelete`; - url += `?fileurl=${fileurl}`; - url += `&token=${this.root.authStore.login.token}`; - return fetch(config.HT_HOST + url) - .then(response => response.json()) - .then(json => { - console.log(json); - return json.Result; - }) - .catch(error => { - console.log("fetch data failed", error); - }); - } - - //提交供应商反馈信息 - postFeedbackInfo(VEI_SN, GRI_SN, EOI_SN, info_content) { - let url = `/service-CooperateSOA/FeedbackInfo`; - let formData = new FormData(); - formData.append("VEI_SN", VEI_SN); - formData.append("GRI_SN", GRI_SN); - formData.append("EOI_SN", EOI_SN); - formData.append("FeedbackInfo", info_content); - formData.append("token", this.root.authStore.login.token); - return fetch(config.HT_HOST + url, { - method: "POST", - body: formData, - }) - .then(response => response.json()) - .then(json => { - console.log(json); - runInAction(() => {}); - }) - .catch(error => { - console.log("fetch data failed", error); - }); - } -} - -// export default Feedback; diff --git a/src/stores/Root.js b/src/stores/Root.js index eeda414..2f75dd9 100644 --- a/src/stores/Root.js +++ b/src/stores/Root.js @@ -1,6 +1,5 @@ import { makeAutoObservable } from "mobx"; import { Reservation } from "./Reservation"; -import {Feedback} from "./Feedback"; import { Auth } from "./Auth"; import {Invoice} from "./Invoice"; import Report from "./Report"; @@ -8,7 +7,6 @@ import Report from "./Report"; class Root { constructor() { this.reservationStore = new Reservation(this); - this.feedbackStore = new Feedback(this); this.authStore = new Auth(this); this.invoiceStore = new Invoice(this); this.reportStore = new Report(this);