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"; 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;