import { makeAutoObservable, runInAction } from "mobx"; import { fetchJSON, postForm } from "@/utils/request"; import { prepareUrl } 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().startOf("M"); search_date_end = dayjs().endOf("M"); feedbackList = []; //反馈列表 feedbackImages = []; //图片列表 feedbackRate = []; //反馈评分 feedbackReview = []; //站外好评 feedbackInfo = []; //地接社反馈的信息 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 => { runInAction(() => { this.feedbackList = json.Result; 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); }); } //获取供应商提交的图片 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;