From 948b12ad33c4d51980de8c46cca7220d21e1e7e9 Mon Sep 17 00:00:00 2001 From: YCC Date: Thu, 25 May 2023 15:01:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B4=A6=E5=8D=95=E5=88=97=E8=A1=A8=E9=A1=B5?= =?UTF-8?q?=E6=98=BE=E7=A4=BA=E9=87=91=E9=A2=9D=E5=92=8C=E5=B8=81=E7=A7=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/stores/Invoice.js | 2 + src/views/invoice/Detail.jsx | 637 +++++++++++++++++------------------ src/views/invoice/Index.jsx | 18 +- 3 files changed, 305 insertions(+), 352 deletions(-) diff --git a/src/stores/Invoice.js b/src/stores/Invoice.js index a426288..7ed600b 100644 --- a/src/stores/Invoice.js +++ b/src/stores/Invoice.js @@ -70,6 +70,7 @@ class Invoice { GroupName: data.GroupName, AllMoney: data.AllMoney, PersonNum: data.PersonNum, + GMD_Currency: data.GMD_Currency, VName: data.VName, FKState: data.FKState, }; @@ -239,6 +240,7 @@ class Invoice { GMD_FillWorkers_Name: "", GroupName: " 中华游230501-CA230402033", AllMoney: 3539, + GMD_Currency: "", PersonNum: "1大1小", VName: "", }, diff --git a/src/views/invoice/Detail.jsx b/src/views/invoice/Detail.jsx index 6423deb..fdf9db8 100644 --- a/src/views/invoice/Detail.jsx +++ b/src/views/invoice/Detail.jsx @@ -1,5 +1,5 @@ -import { useParams, useNavigate } from "react-router-dom"; -import { useEffect, useState ,useRef } from "react"; +import { useParams, useNavigate, NavLink } from "react-router-dom"; +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"; @@ -13,341 +13,304 @@ const { Title } = Typography; const { TextArea } = Input; function Detail() { - const navigate = useNavigate(); - const { GMDSN, GSN } = useParams(); - const { invoiceStore, authStore } = useStore(); - const { invoicekImages, invoiceGroupInfo, invoiceProductList, invoiceCurrencyList, invoiceZDDetail } = invoiceStore; - const [form] = Form.useForm(); - const [dataLoading, setDataLoading] = useState(false); - const { formCurrency, onCurrencyChange } = useState(); - const { notification } = App.useApp(); - - const [invoicePicList,setInvoicePicList] = useState([]); - - - useEffect(() => { - console.info("Detail.useEffect: " + GMDSN + "/" + GSN); - defaultShow(); - - }, [GMDSN, GSN]); - - - function defaultShow(){ - setDataLoading(true); - invoiceStore.fetchInvoiceDetail(GMDSN, GSN) - .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):'','info_gmdsn':data.GMD_SN}; - }); - return {'info_money':data.GMD_Cost,'info_Currency':data.GMD_Currency,'info_date':isNotEmpty(data.GMD_PayDate)?dayjs(data.GMD_PayDate):'','info_gmdsn':data.GMD_SN}; - } - }); - - if (form){ - 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; - - }) - setInvoicePicList(arrPicList); - }) - .catch(ex => { - notification.error({ - message: `Notification`, - description: ex.message, - placement: 'top', - duration: 4, - }); - }) - .finally(() => { - setDataLoading(false); - }); - } - - const fileList = toJS(invoicekImages); - //图片列表 - let arrimg = []; - if (isNotEmpty(fileList)) { - arrimg = fileList.map((data, index) => { - return { - url: data.url - } - }); - } - const onFinish = 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.postEditInvoiceDetail(fieldVaule.info_gmdsn, fieldVaule.info_Currency, fieldVaule.info_money, fieldVaule.info_date, fieldVaule.info_images, "").then((data) => { - console.log(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, - }); - } - }); - } - - }; - - - - const handleChange = info => { - console.log(info); - let newFileList = [...info.fileList]; - newFileList = newFileList.map(file => { - if (file.response && file.response.result) { - file.url = file.response.result.file_url; - } - return file; - }); - runInAction(() => { - invoiceStore.invoicekImages = newFileList; - }); - }; - - const handRemove = info => { - console.log(info); - invoiceStore.removeFeedbackImages(info.url); - return true; - }; - - //币种 - function bindCurrency() { - let arr = []; - arr = invoiceCurrencyList.map((data, index) => { - return { - value: data.CRI_Code, - label: data.CRI_Name - }; - }); - - return arr; - } - - function addInvoice(){ - invoiceStore.postAddInvoice(GSN, "", 0, "", "[]", "").then((data) => { - }).finally(()=>{ - defaultShow(); - }) - } - - function addButton(check) { - if (check) { - return ( - - - - - - - - ) - } - } - - //循环生成多次报账信息 - function bindSubmitForm() { - let submitForm = invoiceZDDetail.map((data, index) => { - if (data.GMD_Dealed) { //已审核的直接显示信息即可,无需表单 - return ( - - - - Invoice {index + 1} - -
- -
Click to Upload
-
-
- Details - - - - - - Currency: - - - - - - {addButton(index + 1 == invoiceZDDetail.length)} - - - -
- - ) - } else { - // 一个团只能有一个未审核的账单记录 - return ( - - - -
- Invoice {index + 1} - - -
- -
Click to Upload
-
-
-
- Details - - - - - - - - - - - - - - - - - - -
- - -
- ) - } - - }) - return submitForm; - } - - - - return ( - <> - - - - - Reference Number: {invoiceGroupInfo.VGroupInfo} - - - - - - - {bindSubmitForm()} - - - ); - - - - + const navigate = useNavigate(); + const { GMDSN, GSN } = useParams(); + const { invoiceStore, authStore } = useStore(); + const { invoicekImages, invoiceGroupInfo, invoiceProductList, invoiceCurrencyList, invoiceZDDetail } = invoiceStore; + const [form] = Form.useForm(); + const [dataLoading, setDataLoading] = useState(false); + const { formCurrency, onCurrencyChange } = useState(); + const { notification } = App.useApp(); + + const [invoicePicList, setInvoicePicList] = useState([]); + + useEffect(() => { + console.info("Detail.useEffect: " + GMDSN + "/" + GSN); + defaultShow(); + }, [GMDSN, GSN]); + + function defaultShow() { + setDataLoading(true); + invoiceStore + .fetchInvoiceDetail(GMDSN, GSN) + .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) : "", info_gmdsn: data.GMD_SN }; + }); + return { info_money: data.GMD_Cost, info_Currency: data.GMD_Currency, info_date: isNotEmpty(data.GMD_PayDate) ? dayjs(data.GMD_PayDate) : "", info_gmdsn: data.GMD_SN }; + } + }); + + if (form) { + 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; + }); + setInvoicePicList(arrPicList); + }) + .catch(ex => { + notification.error({ + message: `Notification`, + description: ex.message, + placement: "top", + duration: 4, + }); + }) + .finally(() => { + setDataLoading(false); + }); + } + + const fileList = toJS(invoicekImages); + //图片列表 + let arrimg = []; + if (isNotEmpty(fileList)) { + arrimg = fileList.map((data, index) => { + return { + url: data.url, + }; + }); + } + const onFinish = 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.postEditInvoiceDetail(fieldVaule.info_gmdsn, fieldVaule.info_Currency, fieldVaule.info_money, fieldVaule.info_date, fieldVaule.info_images, "").then(data => { + console.log(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, + }); + } + }); + } + }; + + const handleChange = info => { + console.log(info); + let newFileList = [...info.fileList]; + newFileList = newFileList.map(file => { + if (file.response && file.response.result) { + file.url = file.response.result.file_url; + } + return file; + }); + runInAction(() => { + invoiceStore.invoicekImages = newFileList; + }); + }; + + const handRemove = info => { + console.log(info); + invoiceStore.removeFeedbackImages(info.url); + return true; + }; + + //币种 + function bindCurrency() { + let arr = []; + arr = invoiceCurrencyList.map((data, index) => { + return { + value: data.CRI_Code, + label: data.CRI_Name, + }; + }); + + return arr; + } + + function addInvoice() { + invoiceStore + .postAddInvoice(GSN, "", 0, "", "[]", "") + .then(data => {}) + .finally(() => { + defaultShow(); + }); + } + + function addButton(check) { + if (check) { + return ( + + + + + ); + } + } + + //循环生成多次报账信息 + function bindSubmitForm() { + let submitForm = invoiceZDDetail.map((data, index) => { + if (data.GMD_Dealed) { + //已审核的直接显示信息即可,无需表单 + return ( + + + + Invoice {index + 1} + +
+ +
Click to Upload
+
+
+ Details + + + + + + Currency: + + + + + + {addButton(index + 1 == invoiceZDDetail.length)} + + +
+ ); + } else { + // 一个团只能有一个未审核的账单记录 + return ( + + + +
+ Invoice {index + 1} + + +
+ +
Click to Upload
+
+
+
+ Details + + + {" "} + + + + + + + + + + + + + + + + + + + +
+ + +
+ ); + } + }); + return submitForm; + } + + return ( + <> + + + + Reference Number: {invoiceGroupInfo.VGroupInfo} + + + Back + + + + {bindSubmitForm()} + + + ); } - export default observer(Detail); - diff --git a/src/views/invoice/Index.jsx b/src/views/invoice/Index.jsx index 4f6bccf..a5b4097 100644 --- a/src/views/invoice/Index.jsx +++ b/src/views/invoice/Index.jsx @@ -26,14 +26,15 @@ function Index() { }, { title: "Arrival Date", - key: "LeftGDate", - dataIndex: "LeftGDate", + key: "GetGDate", + dataIndex: "GetGDate", render: (text, record) => (isNotEmpty(text) ? formatDate(new Date(text)) : ""), }, { title: "Total Amount", key: "AllMoney", dataIndex: "AllMoney", + render: (text, record) => (isNotEmpty(record.GMD_Currency) ? record.GMD_Currency + " " + text : text), }, { title: "Status", @@ -43,15 +44,6 @@ function Index() { ]; function BillStatus(text, record) { - // if (record.GMD_Dealed){ - // return "已审核"; - // }else if (record.GMDFillworkers_SN<1){ - // return "未填写"; - // }else if (record.VRequestVerify){ - // return "未审核"; - // }else{ - // return "未提交"; - // } let FKState = record.FKState - 1; return ( , }, { title: "Travel Advisor", - // status: 'finish', icon: , }, { title: "Finance Dept", - //status: 'process', icon: , }, { title: "Paid", - //status: 'wait', icon: , }, ]}