|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
import { useParams, useNavigate } from "react-router-dom";
|
|
|
|
|
import { useEffect, useState } from "react";
|
|
|
|
|
import { useEffect, useState ,useRef } from "react";
|
|
|
|
|
import { observer } from "mobx-react";
|
|
|
|
|
import { toJS, runInAction } from "mobx";
|
|
|
|
|
import { Row, Col, Space, Button, Typography, Card, Form, Upload, Input, Divider, DatePicker, Select, App, Modal } from "antd";
|
|
|
|
@ -16,7 +16,7 @@ function Detail() {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const { GMDSN, GSN } = useParams();
|
|
|
|
|
const { invoiceStore, authStore } = useStore();
|
|
|
|
|
const { invoicekImages, invoiceGroupInfo, invoiceProductList, invoiceCurrencyList, invoiceZDDetail, invoicePicList } = invoiceStore;
|
|
|
|
|
const { invoicekImages, invoiceGroupInfo, invoiceProductList, invoiceCurrencyList, invoiceZDDetail } = invoiceStore;
|
|
|
|
|
const [form] = Form.useForm();
|
|
|
|
|
const [dataLoading, setDataLoading] = useState(false);
|
|
|
|
|
const { formCurrency, onCurrencyChange } = useState();
|
|
|
|
@ -25,25 +25,67 @@ function Detail() {
|
|
|
|
|
const [isModalOpen, setIsModalOpen] = useState(false);
|
|
|
|
|
const [confirmLoading, setConfirmLoading] = useState(false);
|
|
|
|
|
|
|
|
|
|
const [invoicePicList,setInvoicePicList] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
console.info("Detail.useEffect: " + GMDSN + "/" + GSN);
|
|
|
|
|
setDataLoading(true);
|
|
|
|
|
invoiceStore.fetchInvoiceDetail(GMDSN, GSN)
|
|
|
|
|
.then(() => {
|
|
|
|
|
form.setFieldsValue(invoiceStore.invoiceFormData); //{'info_money':'111','info_Currency':'THB','info_date':''}
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
.then((json) => {
|
|
|
|
|
let ZDDetail = json.ZDDetail;
|
|
|
|
|
let arrLen = ZDDetail.length;
|
|
|
|
|
const formData = ZDDetail.map((data,index)=>{
|
|
|
|
|
if (data.GMD_Dealed == false && arrLen == (index+1)){ //只有最后一条账单未审核通过才显示
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
invoiceStore.invoiceFormData = {'info_money':data.GMD_Cost,'info_Currency':data.GMD_Currency,'info_date':isNotEmpty(data.GMD_PayDate)?dayjs(data.GMD_PayDate):''};
|
|
|
|
|
});
|
|
|
|
|
return {'info_money':data.GMD_Cost,'info_Currency':data.GMD_Currency,'info_date':isNotEmpty(data.GMD_PayDate)?dayjs(data.GMD_PayDate):''};
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
form.setFieldsValue(formData[arrLen-1]); //{'info_money':'111','info_Currency':'THB','info_date':''}
|
|
|
|
|
|
|
|
|
|
//图片列表
|
|
|
|
|
let arrPicList = ZDDetail.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)){
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
//invoiceStore.invoicekImages = picList;
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
return picList;
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setDataLoading(false);
|
|
|
|
|
setInvoicePicList(arrPicList);
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
.catch(ex => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: ex.message,
|
|
|
|
|
placement: 'top',
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
})
|
|
|
|
|
.finally(() => {
|
|
|
|
|
setDataLoading(false);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// if (invoiceStore.invoiceFormData){
|
|
|
|
|
// form.setFieldsValue(invoiceStore.invoiceFormData);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
}, [GMDSN, GSN]);
|
|
|
|
|
|
|
|
|
@ -72,11 +114,51 @@ function Detail() {
|
|
|
|
|
let param = { 'info_money': fieldVaule.info_money, 'info_Currency': fieldVaule.info_Currency, 'info_date': fieldVaule.info_date };
|
|
|
|
|
invoiceStore.invoiceFormData = param;
|
|
|
|
|
})
|
|
|
|
|
if (data.errcode == 0 ){
|
|
|
|
|
notification.success({
|
|
|
|
|
message: `Notification`,
|
|
|
|
|
description: "Success Submit!",
|
|
|
|
|
placement: "top",
|
|
|
|
|
duration: 4,
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const onAddFinish = values => {
|
|
|
|
|
const fieldVaule = {
|
|
|
|
|
...values,
|
|
|
|
|
'info_date': isNotEmpty(values['info_date']) ? values['info_date'].format('YYYY-MM-DD') : null,
|
|
|
|
|
'info_images': JSON.stringify(arrimg),
|
|
|
|
|
}
|
|
|
|
|
console.log("Success:", fieldVaule);
|
|
|
|
|
//入库
|
|
|
|
|
if (fieldVaule) {
|
|
|
|
|
invoiceStore.postAddInvoice(GSN, fieldVaule.info_Currency, fieldVaule.info_money, fieldVaule.info_date, fieldVaule.info_images, "").then((data) => {
|
|
|
|
|
console.log("return:",data);
|
|
|
|
|
runInAction(() => {
|
|
|
|
|
let param = { 'info_money': fieldVaule.info_money, 'info_Currency': fieldVaule.info_Currency, 'info_date': fieldVaule.info_date };
|
|
|
|
|
invoiceStore.invoiceFormData = param;
|
|
|
|
|
})
|
|
|
|
|
if (data.errcode == 0 ){
|
|
|
|
|
// notification.success({
|
|
|
|
|
// message: `Notification`,
|
|
|
|
|
// description: "Success Submit!",
|
|
|
|
|
// placement: "top",
|
|
|
|
|
// duration: 4,
|
|
|
|
|
// });
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleChange = info => {
|
|
|
|
|
console.log(info);
|
|
|
|
|
let newFileList = [...info.fileList];
|
|
|
|
@ -140,7 +222,7 @@ function Detail() {
|
|
|
|
|
accept="image/*"
|
|
|
|
|
multiple={true}
|
|
|
|
|
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GSN}&VEI_SN=${authStore.login.travelAgencyId}&FilePathName=invoice`}
|
|
|
|
|
fileList={invoiceStore.invoicePicList[index]}
|
|
|
|
|
fileList={invoicePicList[index]}
|
|
|
|
|
listType="picture-card"
|
|
|
|
|
>
|
|
|
|
|
<div>
|
|
|
|
@ -186,7 +268,7 @@ function Detail() {
|
|
|
|
|
name="ghhfile"
|
|
|
|
|
accept="image/*"
|
|
|
|
|
multiple={true}
|
|
|
|
|
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GSN}&VEI_SN=${authStore.login.travelAgencyId}&FilePathName=invoice`}
|
|
|
|
|
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GSN}&VEI_SN=${authStore.login.travelAgencyId}&FilePathName=invoice&token=${authStore.login.token}`}
|
|
|
|
|
fileList={fileList}
|
|
|
|
|
listType="picture-card"
|
|
|
|
|
onChange={handleChange}
|
|
|
|
@ -252,9 +334,6 @@ function Detail() {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
// console.info(invoiceStore.invoiceFormData)
|
|
|
|
|
|
|
|
|
|
return submitForm;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -262,17 +341,20 @@ function Detail() {
|
|
|
|
|
//#region Modal
|
|
|
|
|
const showConfirmModal = (confirm) => {
|
|
|
|
|
setIsModalOpen(true);
|
|
|
|
|
// setConfirmText(confirm.PCI_ConfirmText);
|
|
|
|
|
//reservationStore.editConfirmation(confirm);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const fromRef = useRef()
|
|
|
|
|
const handleOk = () => {
|
|
|
|
|
setConfirmLoading(true);
|
|
|
|
|
// reservationStore.submitConfirmation(confirmText)
|
|
|
|
|
// .finally(() => {
|
|
|
|
|
// setIsModalOpen(false);
|
|
|
|
|
// setConfirmLoading(false);
|
|
|
|
|
// });
|
|
|
|
|
try{
|
|
|
|
|
fromRef.current?.submit();
|
|
|
|
|
//onAddFinish;
|
|
|
|
|
//setIsModalOpen(false);
|
|
|
|
|
} finally{
|
|
|
|
|
|
|
|
|
|
setConfirmLoading(false);
|
|
|
|
|
navigate("/invoice/detail/"+GMDSN+"/"+GSN)
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const handleCancel = () => {
|
|
|
|
|
setIsModalOpen(false);
|
|
|
|
@ -291,7 +373,7 @@ function Detail() {
|
|
|
|
|
width={1000}
|
|
|
|
|
>
|
|
|
|
|
<Title level={4}>Add New Invoice</Title>
|
|
|
|
|
<Form name="invoice_submit" onFinish={onFinish} labelCol={{ span: 5 }} form={form}>
|
|
|
|
|
<Form name="invoice_add" onFinish={onAddFinish} labelCol={{ span: 5 }} form={form} ref={fromRef}>
|
|
|
|
|
<Divider orientation="left">上传照片</Divider>
|
|
|
|
|
<Form.Item
|
|
|
|
|
labelCol={{
|
|
|
|
@ -305,7 +387,7 @@ function Detail() {
|
|
|
|
|
name="ghhfile"
|
|
|
|
|
accept="image/*"
|
|
|
|
|
multiple={true}
|
|
|
|
|
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GSN}&VEI_SN=${authStore.login.travelAgencyId}&FilePathName=invoice`}
|
|
|
|
|
action={config.HT_HOST + `/service-fileServer/FileUpload?GRI_SN=${GSN}&VEI_SN=${authStore.login.travelAgencyId}&FilePathName=invoice&token=${authStore.login.token}`}
|
|
|
|
|
fileList={fileList}
|
|
|
|
|
listType="picture-card"
|
|
|
|
|
onChange={handleChange}
|
|
|
|
@ -316,8 +398,7 @@ function Detail() {
|
|
|
|
|
</div>
|
|
|
|
|
</Upload>
|
|
|
|
|
</Form.Item>
|
|
|
|
|
<Divider orientation="left">提交信息</Divider>
|
|
|
|
|
|
|
|
|
|
<Divider orientation="left">提交信息</Divider>
|
|
|
|
|
|
|
|
|
|
<Form.Item
|
|
|
|
|
name="info_money"
|
|
|
|
|