import { makeAutoObservable, runInAction } from "mobx"; import { fetchJSON, postForm } from "@/utils/request"; import { prepareUrl, isNotEmpty } from "@/utils/commons"; import { HT_HOST } from "@/config"; import { json } from "react-router-dom"; import * as config from "@/config"; import dayjs from "dayjs"; class Report { constructor(root) { makeAutoObservable(this, { rootStore: false }); this.root = root; } vendorScoresData = []; //地接统计数据集,合计数据,每月数据,地接考核分数 productScoresData = []; //产品体验分析 常用酒店分析, 导游接待情况 commendScoresData = []; //表扬情况, 投诉情况, 评建议 loading = false; search_date_start = dayjs().month(0).startOf("month"); search_date_end = dayjs().month(11).endOf("month"); onDateRangeChange = dates => { this.search_date_start = dates == null ? null : dates[0].startOf("month"); this.search_date_end = dates == null ? null : dates[1].endOf("month"); }; getHWVendorScores(VEI_SN, StartDate, EndDate) { this.loading = true; const fetchUrl = prepareUrl(HT_HOST +"/service-cusservice/PTGetHWVendorScores") .append("VEI_SN", VEI_SN) .append("StartDate", StartDate) .append("EndDate", EndDate) .append("StrDEI_SN", "(,-1,)") .append("OrderType", "-1") .append("GroupType", "-1") .append("token", this.root.authStore.login.token) .build(); return fetchJSON(fetchUrl).then(json => { runInAction(() => { this.loading = false; if (json.errcode == 0) { if (isNotEmpty(json)) { this.vendorScoresData = json; } else { this.vendorScoresData = []; } } else { throw new Error(json.errmsg + ": " + json.errcode); } }); }); } getHWProductScores(VEI_SN, StartDate, EndDate) { this.loading = true; const fetchUrl = prepareUrl(HT_HOST +"/service-cusservice/PTGetHWProductScores") .append("VEI_SN", VEI_SN) .append("StartDate", StartDate) .append("EndDate", EndDate) .append("StrDEI_SN", "(,-1,)") .append("OrderType", "-1") .append("GroupType", "-1") .append("token", this.root.authStore.login.token) .build(); return fetchJSON(fetchUrl).then(json => { runInAction(() => { this.loading = false; if (json.errcode == 0) { if (isNotEmpty(json)) { this.productScoresData = json; } else { this.productScoresData = []; } } else { throw new Error(json.errmsg + ": " + json.errcode); } }); }); } getHWCommendScores(VEI_SN, StartDate, EndDate) { this.loading = true; const fetchUrl = prepareUrl(HT_HOST +"/service-cusservice/PTGetHWCommendScores") .append("VEI_SN", VEI_SN) .append("StartDate", StartDate) .append("EndDate", EndDate) .append("StrDEI_SN", "(,-1,)") .append("OrderType", "-1") .append("GroupType", "-1") .append("token", this.root.authStore.login.token) .build(); return fetchJSON(fetchUrl).then(json => { runInAction(() => { this.loading = false; if (json.errcode == 0) { if (isNotEmpty(json)) { this.commendScoresData = json; } else { this.commendScoresData = []; } } else { throw new Error(json.errmsg + ": " + json.errcode); } }); }); } } export default Report;