Commit 945ed31e1a6d4a4568de870f295c27e367dc4bf3

Authored by zhongnanhuang
1 parent f677cef7

feat: update 申请开票

src/pages/Order/components/ApplyForInvoicingModal.tsx 0 → 100644
  1 +import { RESPONSE_CODE } from '@/constants/enum';
  2 +import { postServiceOrderApplyInvoicing } from '@/services';
  3 +import {
  4 + ModalForm,
  5 + ProFormTextArea,
  6 + ProFormUploadDragger,
  7 +} from '@ant-design/pro-components';
  8 +import { Form, message } from 'antd';
  9 +export default ({ setCheckVisible, subOrders, onClose }) => {
  10 + const [form] = Form.useForm<{
  11 + applyInvoicingNotes: string;
  12 + filePaths: any;
  13 + subIds: any[];
  14 + }>();
  15 + let subOrderIds = subOrders?.map((subOrder) => subOrder.id);
  16 +
  17 + return (
  18 + <ModalForm<{
  19 + applyInvoicingNotes: string;
  20 + filePaths: any;
  21 + subIds: any[];
  22 + }>
  23 + width={500}
  24 + open
  25 + title="申请开票"
  26 + form={form}
  27 + autoFocusFirstInput
  28 + modalProps={{
  29 + okText: '确认',
  30 + cancelText: '取消',
  31 + destroyOnClose: true,
  32 + onCancel: () => {
  33 + setCheckVisible(false);
  34 + },
  35 + }}
  36 + submitter={{
  37 + render: (props, defaultDoms) => {
  38 + return defaultDoms;
  39 + },
  40 + }}
  41 + submitTimeout={2000}
  42 + onFinish={async (values) => {
  43 + values.subIds = subOrderIds;
  44 + //附件处理
  45 + values.filePaths = values.filePaths?.map((item) => {
  46 + return { url: item.response.data[0] };
  47 + });
  48 +
  49 + const res = await postServiceOrderApplyInvoicing({ data: values });
  50 + if ((res.result = RESPONSE_CODE.SUCCESS)) {
  51 + message.success(res.message);
  52 + onClose();
  53 + }
  54 + }}
  55 + onOpenChange={setCheckVisible}
  56 + >
  57 + <div>如果需要合并订单,请将需要合并的订单id写在备注中。</div>
  58 + <ProFormTextArea
  59 + width="lg"
  60 + name="applyInvoicingNotes"
  61 + placeholder="请输入备注"
  62 + />
  63 + <ProFormUploadDragger
  64 + key="2"
  65 + label="附件"
  66 + name="filePaths"
  67 + action="/api/service/order/fileProcess"
  68 + fieldProps={{
  69 + headers: { Authorization: localStorage.getItem('token') },
  70 + }}
  71 + />
  72 + </ModalForm>
  73 + );
  74 +};
src/pages/Order/index.tsx
@@ -41,6 +41,7 @@ import { cloneDeep } from &#39;lodash&#39;; @@ -41,6 +41,7 @@ import { cloneDeep } from &#39;lodash&#39;;
41 import { Key, useRef, useState } from 'react'; 41 import { Key, useRef, useState } from 'react';
42 import OrderPrintModal from '../OrderPrint/OrderPrintModal'; 42 import OrderPrintModal from '../OrderPrint/OrderPrintModal';
43 import AfterSalesDrawer from './components/AfterSalesDrawer'; 43 import AfterSalesDrawer from './components/AfterSalesDrawer';
  44 +import ApplyForInvoicingModal from './components/ApplyForInvoicingModal';
44 import AttachmentModal from './components/AttachmentModal'; 45 import AttachmentModal from './components/AttachmentModal';
45 import CheckModal from './components/CheckModal'; 46 import CheckModal from './components/CheckModal';
46 import ConfirmReceiptModal from './components/ConfirmReceiptModal'; 47 import ConfirmReceiptModal from './components/ConfirmReceiptModal';
@@ -89,6 +90,8 @@ const OrderPage = () =&gt; { @@ -89,6 +90,8 @@ const OrderPage = () =&gt; {
89 const [isSendProduct, setIsSendProduct] = useState<boolean>(false); 90 const [isSendProduct, setIsSendProduct] = useState<boolean>(false);
90 const [isMainOrder, setIsMainOrder] = useState<boolean>(false); 91 const [isMainOrder, setIsMainOrder] = useState<boolean>(false);
91 const [importModalVisible, setImportModalVisible] = useState<boolean>(false); 92 const [importModalVisible, setImportModalVisible] = useState<boolean>(false);
  93 + const [applyForInvoicingVisible, setApplyForInvoicingVisible] =
  94 + useState<boolean>(false);
92 const [procureCheckModalVisible, setProcureCheckModalVisible] = 95 const [procureCheckModalVisible, setProcureCheckModalVisible] =
93 useState<boolean>(false); 96 useState<boolean>(false);
94 const [confirmReceiptVisible, setConfirmReceiptVisible] = 97 const [confirmReceiptVisible, setConfirmReceiptVisible] =
@@ -687,6 +690,22 @@ const OrderPage = () =&gt; { @@ -687,6 +690,22 @@ const OrderPage = () =&gt; {
687 ) : ( 690 ) : (
688 '' 691 ''
689 )} 692 )}
  693 +
  694 + {optRecord.subPath?.includes('applyInvoicing') ? (
  695 + <Button
  696 + className="p-0"
  697 + type="link"
  698 + onClick={() => {
  699 + setApplyForInvoicingVisible(true);
  700 + setSelectedRows([optRecord]);
  701 + }}
  702 + >
  703 + 申请开票
  704 + </Button>
  705 + ) : (
  706 + ''
  707 + )}
  708 +
690 {optRecord.subPath?.includes('checkOrder') ? ( 709 {optRecord.subPath?.includes('checkOrder') ? (
691 <Button 710 <Button
692 className="p-0" 711 className="p-0"
@@ -1218,6 +1237,40 @@ const OrderPage = () =&gt; { @@ -1218,6 +1237,40 @@ const OrderPage = () =&gt; {
1218 ) : ( 1237 ) : (
1219 '' 1238 ''
1220 )} 1239 )}
  1240 +
  1241 + {record.mainPath?.includes('applyInvoicing') ? (
  1242 + <Button
  1243 + type="link"
  1244 + className="p-0"
  1245 + onClick={() => {
  1246 + let selectedSubOrders = selectedRowObj[record.id];
  1247 + if (selectedSubOrders === undefined) {
  1248 + selectedSubOrders = record.subOrderInformationLists;
  1249 + }
  1250 +
  1251 + setSelectedRows(selectedSubOrders);
  1252 + for (let i = 0; i < selectedSubOrders.length; i++) {
  1253 + if (
  1254 + selectedSubOrders[i].invoicingStatus ===
  1255 + 'UN_INVOICE' ||
  1256 + selectedSubOrders[i].afterInvoicingStatus ===
  1257 + 'APPLY_FOR_INVOICING'
  1258 + ) {
  1259 + message.error(
  1260 + '请选择需要开票且未申请开票的子订单进行申请',
  1261 + );
  1262 + return;
  1263 + }
  1264 + }
  1265 + setApplyForInvoicingVisible(true);
  1266 + }}
  1267 + >
  1268 + 申请开票
  1269 + </Button>
  1270 + ) : (
  1271 + ''
  1272 + )}
  1273 +
1221 {record.mainPath?.includes('updateOrder') ? ( 1274 {record.mainPath?.includes('updateOrder') ? (
1222 <Button 1275 <Button
1223 className="p-0" 1276 className="p-0"
@@ -1811,6 +1864,18 @@ const OrderPage = () =&gt; { @@ -1811,6 +1864,18 @@ const OrderPage = () =&gt; {
1811 /> 1864 />
1812 )} 1865 )}
1813 1866
  1867 + {applyForInvoicingVisible && (
  1868 + <ApplyForInvoicingModal
  1869 + setCheckVisible={setApplyForInvoicingVisible}
  1870 + subOrders={selectedRows}
  1871 + onClose={() => {
  1872 + setApplyForInvoicingVisible(false);
  1873 + setSelectedRows({});
  1874 + refreshTable();
  1875 + }}
  1876 + />
  1877 + )}
  1878 +
1814 {notesEditVisible && ( 1879 {notesEditVisible && (
1815 <OrderNotesEditModal 1880 <OrderNotesEditModal
1816 setNotesEditVisible={setNotesEditVisible} 1881 setNotesEditVisible={setNotesEditVisible}