You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
GHHub/src/stores/Invoice.js

189 lines
5.7 KiB
JavaScript

import { makeAutoObservable,runInAction } from "mobx";
import { fetchJSON } from "@/utils/request";
import { prepareUrl,isNotEmpty } from '@/utils/commons';
import { HT_HOST } from "@/config";
import { json } from "react-router-dom";
class Invoice {
constructor(root) {
makeAutoObservable(this, { rootStore: false });
this.root = root;
}
invoiceList = []; //账单列表
invoicekImages = []; //图片列表
invoiceGroupInfo= {}; //账单详细
invocieProductList=[];//账单细项
invocieCurrencyList=[];//币种
fetchInvoiceList(current,OrderType,GroupNo,DateStart,DateEnd,Orderbytype){
this.invoicePage.current=current;
const totalNum = current == 1 ? 0 : this.invoicePage.total;
//组合param
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTSearchGMBPageList')
.append('VEI_SN', '628') //this.root.authStore.login.travelAgencyId
.append('OrderType',OrderType)
.append('GroupNo',GroupNo)
.append('DateStart',DateStart)
.append('DateEnd',DateEnd)
.append('Orderbytype',Orderbytype)
.append('TimeType',0)
.append('limitmarket',"")
.append('mddgroup',"")
.append('SecuryGroup',"")
.append('TotalNum', totalNum)
.append('PageSize', this.invoicePage.size)
.append('PageIndex', this.invoicePage.current)
.build();
return fetchJSON(fetchUrl)
.then(json => {
runInAction(()=>{
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,
VName : data.VName,
FKState:data.FKState
}
});
this.invoicePage.total = json.Result[0].TotalCount;
}
// else{
// this.invoiceList=[];
// this.invoicePage.total=0;
// }
}else{
throw new Error(json.errmsg + ': ' + json.errcode);
}
});
});
}
fetchInvoiceDetail(GMDSN,GSN){
const fetchUrl = prepareUrl(HT_HOST + '/service-cusservice/PTGetZDDetail')
.append('VEI_SN', '628') //this.root.authStore.login.travelAgencyId
.append('GRI_SN',GSN)
.append('GMD_SN',GMDSN)
.append('LGC',1)
.append('Bill',1)
.build();
return fetchJSON(fetchUrl)
.then(json=>{
runInAction(()=>{
if(json.errcode==0){
this.invoiceGroupInfo = json.GroupInfo[0];
this.invocieProductList = json.ProductList;
this.invocieCurrencyList = json.CurrencyList;
}else{
throw new Error(json.errmsg + ': ' + json.errcode);
}
})
});
}
//获取供应商提交的图片
getInvoicekImages(VEI_SN, GRI_SN) {
let url = `/service-fileServer/ListFile`;
url += `?GRI_SN=${GRI_SN}&VEI_SN=${VEI_SN}`;
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);
});
}
removeFeedbackImages(fileurl) {
let url = `/service-fileServer/FileDelete`;
url += `?fileurl=${fileurl}`;
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);
});
}
invoicePage = {
current:1,
size:10,
total:0
}
/* 测试数据 */
//账单列表范例数据
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,
"PersonNum":"1大1小",
"VName":""
}
]
}
export default Invoice;