diff --git a/src/config.js b/src/config.js index 6e0a1d8..99b5036 100644 --- a/src/config.js +++ b/src/config.js @@ -3,6 +3,7 @@ import dayjs from "dayjs"; export const HT_HOST = process.env.NODE_ENV == "production" ? "https://p9axztuwd7x8a7.mycht.cn" : "http://202.103.68.144:890"; export const DATE_FORMAT = "YYYY-MM-DD"; +export const DATE_FORMAT_MONTH = "YYYY-MM"; export const DATE_PRESETS = [ { label: "This Week", diff --git a/src/main.jsx b/src/main.jsx index 89f22af..21fee95 100644 --- a/src/main.jsx +++ b/src/main.jsx @@ -20,6 +20,7 @@ import AccountProfile from "@/views/account/Profile"; import FeedbackIndex from "@/views/feedback/Index"; import FeedbackDetail from "@/views/feedback/Detail"; import FeedbackCustomerDetail from "@/views/feedback/CustomerDetail"; +import ReportIndex from "@/views/report/Index"; import NoticeIndex from "@/views/notice/Index"; import NoticeDetail from "@/views/notice/Detail"; import InvoiceIndex from "@/views/invoice/Index"; @@ -52,6 +53,7 @@ const router = createBrowserRouter([ { path: "feedback", element: }, { path: "feedback/:GRI_SN/:RefNo", element: }, { path: "feedback/:GRI_SN/:CII_SN/:RefNo", element: }, + { path: "report", element: }, { path: "notice", element: }, { path: "notice/:CCP_BLID", element: }, { path: "invoice",element:}, diff --git a/src/stores/Report.js b/src/stores/Report.js new file mode 100644 index 0000000..add4e7a --- /dev/null +++ b/src/stores/Report.js @@ -0,0 +1,370 @@ +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; + } + + invoiceList = []; //账单列表 + invoicekImages = []; //图片列表 + invoiceGroupInfo = {}; //账单详细 + invoiceProductList = []; //账单细项 + invoiceZDDetail = []; //报账信息 + invoiceCurrencyList = []; //币种 + invoicePicList = []; //多账单图片列表数组 + invoiceFormData = { info_money: 0, info_Currency: "", info_date: "" }; //存储form数据 + + invoicePaid = [] ; //支付账单列表 + invoicePaidDetail = []; //每期账单详细 + + loading = false; + search_date_start = dayjs().month(0); + search_date_end = dayjs().month(11); + + onDateRangeChange = dates => { + console.log(dates); + this.search_date_start = dates==null? null: dates[0]; + this.search_date_end = dates==null? null: dates[1]; + }; + + fetchInvoiceList(VEI_SN, GroupNo, DateStart, DateEnd,OrderType) { + this.loading = true; + const fetchUrl = prepareUrl(HT_HOST + "/service-cusservice/PTSearchGMBPageList") + .append("VEI_SN", VEI_SN) + .append("OrderType", 0) + .append("GroupNo", GroupNo.trim()) + .append("DateStart", DateStart) + .append("DateEnd", DateEnd) + .append("Orderbytype", 1) + .append("TimeType", 0) + .append("limitmarket", "") + .append("mddgroup", "") + .append("SecuryGroup", "") + .append("TotalNum", 0) + .append("PageSize", 2000) + .append("PageIndex", 1) + .append("PayState",OrderType) + .append("token",this.root.authStore.login.token) + .build(); + + return fetchJSON(fetchUrl).then(json => { + runInAction(() => { + this.loading = false; + if (json.errcode == 0) { + if (isNotEmpty(json.Result)) { + this.invoiceList = json.Result.map((data, index) => { + return { + key: data.GMDSN, + gmd_gri_sn: data.GMD_GRI_SN, + gmd_vei_sn: data.GMD_VEI_SN, + GetGDate: data.GetGDate, + GMD_FillWorkers_SN: data.GMD_FillWorkers_SN, + GMD_FWks_LastEditTime: data.GMD_FWks_LastEditTime, + GMD_VerifyUser_SN: data.GMD_VerifyUser_SN, + GMD_Dealed: data.GMD_Dealed, + GMD_VRequestVerify: data.GMD_VRequestVerify, + LeftGDate: data.LeftGDate, + GMD_FillWorkers_Name: data.GMD_FillWorkers_Name, + GroupName: data.GroupName, + AllMoney: data.AllMoney, + PersonNum: data.PersonNum, + GMD_Currency: data.GMD_Currency, + VName: data.VName, + FKState: data.FKState, + }; + }); + } else { + this.invoiceList = []; + } + } else { + throw new Error(json.errmsg + ": " + json.errcode); + } + }); + }); + } + + fetchInvoiceDetail(GMDSN, GSN) { + const fetchUrl = prepareUrl(HT_HOST + "/service-cusservice/PTGetZDDetail") + .append("VEI_SN", this.root.authStore.login.travelAgencyId) + .append("GRI_SN", GSN) + .append("GMD_SN", GMDSN) + .append("LGC", 1) + .append("Bill", 1) + .append("token",this.root.authStore.login.token) + .build(); + + return fetchJSON(fetchUrl).then(json => { + runInAction(() => { + if (json.errcode == 0) { + this.invoiceGroupInfo = json.GroupInfo[0]; + this.invoiceProductList = json.ProductList; + this.invoiceCurrencyList = json.CurrencyList; + this.invoiceZDDetail = json.ZDDetail; + } else { + throw new Error(json.errmsg + ": " + json.errcode); + } + }); + return json; + }); + } + + //获取供应商提交的图片 + getInvoicekImages(VEI_SN, GRI_SN) { + let url = `/service-fileServer/ListFile`; + url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}&FilePathName=invoice`; + url += `&token=${this.root.authStore.login.token}`; + fetch(config.HT_HOST + url) + .then(response => response.json()) + .then(json => { + console.log(json); + runInAction(() => { + this.invoicekImages = 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); + }); + } + + //从数据库获取图片列表 + getInvoicekImages_fromData(jsonData) { + let arrLen = jsonData.length; + let arrPicList = jsonData.map((data, index) => { + const GMD_Pic = data.GMD_Pic; + let picList = []; + if (isNotEmpty(GMD_Pic)) { + let js_Pic = JSON.parse(GMD_Pic); + picList = js_Pic.map((picData, pic_Index) => { + return { + uid: -pic_Index, //用负数,防止添加删除的时候错误 + name: "", + status: "done", + url: picData.url, + }; + }); + } + if (data.GMD_Dealed == false && arrLen == index + 1) { + this.invoicekImages = picList; + } + return picList; + }); + + runInAction(() => { + this.invoicePicList = arrPicList; + }); + } + + //获取数据库的表单默认数据回填。 + getFormData(jsonData) { + let arrLen = jsonData.length; + return jsonData.map((data, index) => { + if (data.GMD_Dealed == false && arrLen == index + 1) { + //只有最后一条账单未审核通过才显示 + runInAction(() => { + this.invoiceFormData = { info_money: data.GMD_Cost, info_Currency: data.GMD_Currency, info_date: isNotEmpty(data.GMD_PayDate) ? dayjs(data.GMD_PayDate) : "" }; + }); + } + }); + } + + 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); + }); + } + + postEditInvoiceDetail(GMD_SN, Currency, Cost, PayDate, Pic, Memo) { + let postUrl = HT_HOST + "/service-cusservice/EditSupplierFK"; + let formData = new FormData(); + formData.append("LMI_SN", this.root.authStore.login.userId); + formData.append("GMD_SN", GMD_SN); + formData.append("Currency", Currency); + formData.append("Cost", Cost); + formData.append("PayDate", isNotEmpty(PayDate) ? PayDate : ""); + formData.append("Pic", Pic); + formData.append("Memo", Memo); + formData.append("token",this.root.authStore.login.token); + + return postForm(postUrl, formData).then(json => { + console.info(json); + return json; + }); + } + + postAddInvoice(GRI_SN, Currency, Cost, PayDate, Pic, Memo) { + let postUrl = HT_HOST + "/service-cusservice/AddSupplierFK"; + let formData = new FormData(); + formData.append("LMI_SN", this.root.authStore.login.userId); + formData.append("VEI_SN", this.root.authStore.login.travelAgencyId); + formData.append("GRI_SN", GRI_SN); + formData.append("Currency", Currency); + formData.append("Cost", Cost); + formData.append("PayDate", isNotEmpty(PayDate) ? PayDate : ""); + formData.append("Pic", Pic); + formData.append("Memo", Memo); + formData.append("token",this.root.authStore.login.token); + return postForm(postUrl, formData).then(json => { + console.info(json); + return json; + }); + } + + //账单状态 + invoiceStatus(FKState) { + switch (FKState - 1) { + case 1: + return "Submitted"; + break; + case 2: + return "Travel Advisor"; + break; + case 3: + return "Finance Dept"; + break; + case 4: + return "Paid"; + break; + default: + return ""; + break; + } + } + + fetchInvoicePaid(VEI_SN, GroupNo, DateStart, DateEnd) { + this.loading = true; + const fetchUrl = prepareUrl(HT_HOST + "/service-Cooperate/Cooperate/GetInvoicePaid") + .append("VEI_SN", VEI_SN) + .append("GroupNo", GroupNo) + .append("DateStart", DateStart) + .append("DateEnd", DateEnd) + .append("token",this.root.authStore.login.token) + .build(); + + return fetchJSON(fetchUrl).then(json => { + runInAction(() => { + this.loading = false; + if (json.errcode == 0) { + if (isNotEmpty(json.Result)) { + this.invoicePaid = json.Result.map((data, index) => { + return { + key: data.fl_id, + fl_finaceNo: data.fl_finaceNo, + fl_vei_sn: data.fl_vei_sn, + fl_year: data.fl_year, + fl_month: data.fl_month, + fl_memo: data.fl_memo, + fl_adddate: data.fl_adddate, + fl_addUserSn: data.fl_addUserSn, + fl_updateUserSn: data.fl_updateUserSn, + fl_updatetime: data.fl_updatetime, + fl_state: data.fl_state, + fl_paid: data.fl_paid, + fl_pic: data.fl_pic, + fcount: data.fcount, + pSum: data.pSum, + }; + }); + } else { + this.invoicePaid = []; + } + } else { + throw new Error(json.errmsg + ": " + json.errcode); + } + }); + }); + + } + + + fetchInvoicePaidDetail(VEI_SN,FLID){ + this.loading = true; + const fetchUrl = prepareUrl(HT_HOST + "/service-Cooperate/Cooperate/GetInvoicePaidDetail") + .append("VEI_SN", VEI_SN) + .append("fl_id", FLID) + .append("token",this.root.authStore.login.token) + .build(); + + return fetchJSON(fetchUrl).then(json => { + runInAction(() => { + this.loading = false; + if (json.errcode == 0) { + if (isNotEmpty(json.Result)) { + this.invoicePaidDetail = json.Result.map((data, index) => { + return { + key: data.fl2_id, + fl2_fl_id: data.fl2_fl_id, + fl2_GroupName: data.fl2_GroupName, + fl2_gri_sn: data.fl2_gri_sn, + fl2_gmd_sn: data.fl2_gmd_sn, + fl2_wl: data.fl2_wl, + fl2_ArriveDate: data.fl2_ArriveDate, + fl2_price: data.fl2_price, + fl2_state: data.fl2_state, + fl2_updatetime: data.fl2_updatetime, + fl2_updateUserSn: data.fl2_updateUserSn, + fl2_memo: data.fl2_memo, + fl2_memo2: data.fl2_memo2, + fl2_paid: data.fl2_paid, + fl2_pic: data.fl2_pic, + }; + }); + } else { + this.invoicePaidDetail = []; + } + } else { + throw new Error(json.errmsg + ": " + json.errcode); + } + }); + }); + } + + /* 测试数据 */ + //账单列表范例数据 + testData = [ + { + GSMSN: 449865, + gmd_gri_sn: 334233, + gmd_vei_sn: 628, + GetDate: "2023-04-2 00:33:33", + GMD_FillWorkers_SN: 8617, + GMD_FWks_LastEditTime: "2023-04-26 12:33:33", + GMD_VerifyUser_SN: 8928, + GMD_Dealed: 1, + GMD_VRequestVerify: 1, + TotalCount: 22, + LeftGDate: "2023-03-30 00:00:00", + GMD_FillWorkers_Name: "", + GroupName: " 中华游230501-CA230402033", + AllMoney: 3539, + FKState: 1, + GMD_Currency: "", + PersonNum: "1大1小", + VName: "", + }, + ]; +} + +export default Report; diff --git a/src/stores/Root.js b/src/stores/Root.js index f165325..50d3e12 100644 --- a/src/stores/Root.js +++ b/src/stores/Root.js @@ -4,6 +4,7 @@ import Feedback from "./Feedback"; import Notice from "./Notice"; import Auth from "./Auth"; import Invoice from "./Invoice"; +import Report from "./Report"; class Root { constructor() { @@ -12,6 +13,7 @@ class Root { this.noticeStore = new Notice(this); this.authStore = new Auth(this); this.invoiceStore = new Invoice(this); + this.reportStore = new Report(this); makeAutoObservable(this); } diff --git a/src/views/App.jsx b/src/views/App.jsx index 946ac52..c8b8cd6 100644 --- a/src/views/App.jsx +++ b/src/views/App.jsx @@ -170,6 +170,7 @@ function App() { { key: "reservation", label: Reservation }, { key: "invoice", label: Invoice }, { key: "feedback", label: Feedback }, + { key: "report", label: Report }, { key: "notice", label: ( diff --git a/src/views/report/Index.jsx b/src/views/report/Index.jsx new file mode 100644 index 0000000..ef81e49 --- /dev/null +++ b/src/views/report/Index.jsx @@ -0,0 +1,66 @@ +import { NavLink } from "react-router-dom"; +import { useEffect, useState } from "react"; +import { observer } from "mobx-react"; +import { toJS } from "mobx"; +import { Row, Col, Space, Button, Table, Input, Typography, Badge, List, DatePicker } from "antd"; +import { useStore } from "@/stores/StoreContext.js"; +import * as config from "@/config"; +import * as comm from "@/utils/commons"; +import dayjs from "dayjs"; + +const { Title, Paragraph, Text } = Typography; + +function Index() { + const { reportStore, authStore } = useStore(); + const { search_date_start, search_date_end } = reportStore; + + useEffect(() => { + + }, []); + + return ( + + + + + + Select Date + + + + + + + + + + + + + + ); +} + +export default observer(Index);