diff --git a/src/pages/Order/components/ApplyForInvoicingModal.tsx b/src/pages/Order/components/ApplyForInvoicingModal.tsx index 8fbabc2..0eded06 100644 --- a/src/pages/Order/components/ApplyForInvoicingModal.tsx +++ b/src/pages/Order/components/ApplyForInvoicingModal.tsx @@ -1,5 +1,8 @@ import { RESPONSE_CODE } from '@/constants/enum'; -import { postServiceOrderApplyInvoicing } from '@/services'; +import { + postServiceOrderApplyInvoicing, + postServiceOrderMergeApplyInvoicing, +} from '@/services'; import { getAliYunOSSFileNameFromUrl } from '@/utils'; import { ModalForm, @@ -8,20 +11,34 @@ import { } from '@ant-design/pro-components'; import { Form, message } from 'antd'; import { cloneDeep } from 'lodash'; -export default ({ setCheckVisible, isEdit, subOrders, onClose }) => { - const subOrder = cloneDeep(subOrders[0]); - let newListAnnex = subOrder.afterAnnexList?.map((path) => { - let i = 0; - return { - uid: i++, - name: getAliYunOSSFileNameFromUrl(path), - status: 'uploaded', - url: path, - response: { data: [path] }, - }; - }); +export default ({ setCheckVisible, isEdit, data, isMainOrder, onClose }) => { + console.log(data); + let ids = data?.map((item) => item.id); + let newListAnnex = []; + let subOrder = {}; + + //回显,子订单可以编辑备注跟附件 + if (!isMainOrder) { + if (isEdit) { + subOrder = cloneDeep(data[0]); + newListAnnex = subOrder.afterAnnexList?.map((path) => { + let i = 0; + return { + uid: i++, + name: getAliYunOSSFileNameFromUrl(path), + status: 'uploaded', + url: path, + response: { data: [path] }, + }; + }); + subOrder.filePaths = newListAnnex; + } + } - subOrder.filePaths = newListAnnex; + //拼接主订单id + if (isMainOrder) { + subOrder.applyInvoicingNotes = ids.join(','); + } const [form] = Form.useForm<{ applyInvoicingNotes: string; @@ -29,7 +46,6 @@ export default ({ setCheckVisible, isEdit, subOrders, onClose }) => { subIds: any[]; afterInvoicingUpdate: boolean; }>(); - let subOrderIds = subOrders?.map((subOrder) => subOrder.id); return ( <ModalForm<{ @@ -59,23 +75,36 @@ export default ({ setCheckVisible, isEdit, subOrders, onClose }) => { }} submitTimeout={2000} onFinish={async (values) => { - values.subIds = subOrderIds; + values.subIds = ids; //附件处理 values.filePaths = values.filePaths?.map((item) => { return { url: item.response.data[0] }; }); - if (isEdit) { - values.afterInvoicingUpdate = true; + if (isMainOrder) { + const res = await postServiceOrderMergeApplyInvoicing({ + data: { + ...values, + mainOrderIds: ids, + }, + }); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } } else { - values.afterInvoicingUpdate = false; - } + if (isEdit) { + values.afterInvoicingUpdate = true; + } else { + values.afterInvoicingUpdate = false; + } - const res = await postServiceOrderApplyInvoicing({ data: values }); + const res = await postServiceOrderApplyInvoicing({ data: values }); - if (res.result === RESPONSE_CODE.SUCCESS) { - message.success(res.message); - onClose(); + if (res.result === RESPONSE_CODE.SUCCESS) { + message.success(res.message); + onClose(); + } } }} onOpenChange={setCheckVisible} diff --git a/src/pages/Order/components/FinancialEditDrawer.tsx b/src/pages/Order/components/FinancialEditDrawer.tsx index b26cf58..54fdace 100644 --- a/src/pages/Order/components/FinancialEditDrawer.tsx +++ b/src/pages/Order/components/FinancialEditDrawer.tsx @@ -12,7 +12,7 @@ import { Form, message } from 'antd'; import { useEffect, useState } from 'react'; import { INVOCING_STATUS_OPTIONS_OLD } from '../constant'; -export default ({ mainOrder, subOrders, setVisible, onClose }) => { +export default ({ mainOrder, subOrders, setVisible, isMainOrder, onClose }) => { const [invoicingStatus, setInvoicingStatus] = useState(''); useEffect(() => { setInvoicingStatus(subOrders[0]?.invoicingStatus); @@ -33,7 +33,7 @@ export default ({ mainOrder, subOrders, setVisible, onClose }) => { subIds: []; }> open - title="收款时间" + title={isMainOrder ? '编辑开票信息' : '编辑收款时间'} resize={{ onResize() { console.log('resize!'); @@ -41,7 +41,7 @@ export default ({ mainOrder, subOrders, setVisible, onClose }) => { maxWidth: window.innerWidth * 0.8, minWidth: 400, }} - initialValues={subOrders[0]} + initialValues={mainOrder} form={form} autoFocusFirstInput drawerProps={{ @@ -65,17 +65,22 @@ export default ({ mainOrder, subOrders, setVisible, onClose }) => { return !val && setVisible(val); }} > - <ProFormSelect - placeholder="选择是否需要开票" - name="invoicingStatus" - width="lg" - label="是否需要开票" - options={enumToSelect(INVOCING_STATUS_OPTIONS_OLD)} - onChange={setInvoicingStatus} - initialValue={subOrders[0]?.invoicingStatus} - // disabled={mainInfoDisbled} - rules={[{ required: true, message: '是否需要开票必填' }]} - /> + {isMainOrder ? ( + <ProFormSelect + placeholder="选择是否需要开票" + name="invoicingStatus" + width="lg" + label="是否需要开票" + options={enumToSelect(INVOCING_STATUS_OPTIONS_OLD)} + onChange={setInvoicingStatus} + initialValue={subOrders[0]?.invoicingStatus} + // disabled={mainInfoDisbled} + rules={[{ required: true, message: '是否需要开票必填' }]} + /> + ) : ( + '' + )} + {invoicingStatus !== 'UN_INVOICE' ? ( <> <ProFormText @@ -112,7 +117,7 @@ export default ({ mainOrder, subOrders, setVisible, onClose }) => { label="开收据时间" rules={[ { - required: invoicingStatus === 'UN_INVOICE', + required: !isMainOrder && invoicingStatus === 'UN_INVOICE', message: '开收据时间必填', }, ]} @@ -124,7 +129,7 @@ export default ({ mainOrder, subOrders, setVisible, onClose }) => { label="收款时间" rules={[ { - required: invoicingStatus === 'UN_INVOICE', + required: !isMainOrder && invoicingStatus === 'UN_INVOICE', message: '收款时间必填', }, ]} diff --git a/src/pages/Order/components/OrderDrawer.tsx b/src/pages/Order/components/OrderDrawer.tsx index 7bae935..e65a1ff 100644 --- a/src/pages/Order/components/OrderDrawer.tsx +++ b/src/pages/Order/components/OrderDrawer.tsx @@ -3,6 +3,7 @@ import { postServiceOrderAddOrder, postServiceOrderQueryCustomerNameInformation, postServiceOrderQueryProductInformation, + postServiceOrderQuerySalesCode, postServiceOrderUpdateOrder, } from '@/services'; import { @@ -31,11 +32,11 @@ import { PAYMENT_CHANNEL_OPTIONS, PAYMENT_METHOD_OPTIONS, PRODUCT_BELONG_DEPARTMENT_OPTIONS, - SALES_CODE_OPTIONS, } from '../constant'; export default ({ onClose, data, subOrders, orderOptType }) => { const [invoicingStatus, setInvoicingStatus] = useState(''); + const [salesCodeOptions, setSalesCodeOptions] = useState([]); let originSubOrders = cloneDeep(subOrders); /** * 获取当前的操作类型boolean值 @@ -58,12 +59,25 @@ export default ({ onClose, data, subOrders, orderOptType }) => { const fileList: any = []; + const getSalesCodeOptions = async () => { + const { data } = await postServiceOrderQuerySalesCode(); + let options = data?.map((item) => { + return { label: item.userName, value: item.userName }; + }); + setSalesCodeOptions(options); + }; + + useEffect(() => { + getSalesCodeOptions(); + }, []); + useEffect(() => { // 在组件挂载或数据变化时,更新组件状态 if (data) { setInvoicingStatus(data.invoicingStatus); } }, [data]); + // let mainInfoDisbled = optType('edit'); if (optType('edit') || optType('copy')) { //如果是复制,需要开票,不回显是否需要开票字段 @@ -135,6 +149,7 @@ export default ({ onClose, data, subOrders, orderOptType }) => { }, ]; }>(); + const actionRef = useRef< FormListActionType<{ name: string; @@ -143,6 +158,10 @@ export default ({ onClose, data, subOrders, orderOptType }) => { useEffect(() => { form.setFieldsValue({ ...data }); + //如果是新建,需要清空list + if (optType('add')) { + form.resetFields(['list']); + } }, [data]); /** @@ -217,13 +236,6 @@ export default ({ onClose, data, subOrders, orderOptType }) => { open width="35%" title={optType('add') || optType('copy') ? '新建订单' : '修改订单'} - initialValues={() => { - //编辑和复制回显数据 - if (optType('edit') || optType('copy')) { - return data; - } - return {}; - }} resize={{ onResize() { console.log('resize!'); @@ -300,8 +312,8 @@ export default ({ onClose, data, subOrders, orderOptType }) => { showSearch label="销售代表" placeholder="请输入销售代表" - options={SALES_CODE_OPTIONS} rules={[{ required: true, message: '销售代表必填' }]} + options={salesCodeOptions} // disabled={mainInfoDisbled} /> <ProFormSelect diff --git a/src/pages/Order/index.tsx b/src/pages/Order/index.tsx index 7abf724..5cf3d12 100644 --- a/src/pages/Order/index.tsx +++ b/src/pages/Order/index.tsx @@ -84,10 +84,12 @@ const OrderPage = () => { const [orderDrawerVisible, setOrderDrawerVisible] = useState<boolean>(false); const [checkVisible, setCheckVisible] = useState<boolean>(false); const [orderPrintVisible, setOrderPrintVisible] = useState<boolean>(false); + const [allMainChecked, setAllMainChecked] = useState(false); const [ subOrderConfirmReceiptImagesVisible, setSubOrderConfirmReceiptImagesVisible, ] = useState<boolean>(false); + const [data, setData] = useState([]); //列表数据 const [notesEditVisible, setNotesEditVisible] = useState<boolean>(false); const [attachmentModalVisible, setAttachmentModalVisible] = useState<boolean>(false); @@ -294,11 +296,39 @@ const OrderPage = () => { setExpandedRowKeys(mainOrderIds); }; + const allMainCheckBoxChange = () => { + let checked = !allMainChecked; + setAllMainChecked(checked); + if (checked) { + let mainOrderIds = data?.map((item) => { + return item.id; + }); + + let rowObjs = data?.map((item) => { + let id = item.id; + let rowObj: any = {}; + rowObj[id] = item; + return rowObj; + }); + setSelectedItems(mainOrderIds); + setSelectedRowObj(rowObjs); + } else { + setSelectedItems([]); + setSelectedRowObj([]); + } + }; + //表头渲染 const OrderTableHeader = () => { return ( <Flex className="w-full"> - <Flex className="w-[29%] ml-[4%]"> + <Flex className="w-[1%] ml-[7px]"> + <Checkbox + onChange={allMainCheckBoxChange} + checked={allMainChecked} + ></Checkbox> + </Flex> + <Flex className="w-[30%] ml-[1%]"> <span className="font-medium">商品信息</span> </Flex> <Flex className="w-[13%]"> @@ -526,7 +556,10 @@ const OrderPage = () => { title={optRecord.quantity} > <span className="text-[#8C8C8C]">数量:</span> - <span className="text-slate-700">x{optRecord.quantity}</span> + <span className="text-slate-700"> + x{optRecord.quantity + ' '} + </span> + <span className="text-[#8C8C8C]">{optRecord.unit}</span> </div> <div className="overflow-hidden whitespace-no-wrap overflow-ellipsis" @@ -874,6 +907,7 @@ const OrderPage = () => { setApplyForInvoicingVisible(true); setSelectedRows([optRecord]); setIsEdit(false); + setIsMainOrder(false); }} > 申请开票 @@ -1641,6 +1675,24 @@ const OrderPage = () => { '' )} + {record.mainPath?.includes('noNeedInvoicingEdit') ? ( + <Button + className="p-0" + type="link" + onClick={() => { + let selectedSubOrders = record.subOrderInformationLists; + setFinancialEditVisible(true); + setSelectedRows(selectedSubOrders); + setOrderRow(record); + setIsMainOrder(true); + }} + > + 财务编辑 + </Button> + ) : ( + '' + )} + {record.mainPath?.includes('checkOrder') ? ( <Button className="p-0" @@ -2106,6 +2158,28 @@ const OrderPage = () => { onClick: () => {}, }; + if (rolePath?.includes('mergeApplyInvoicing')) { + toolBtns.push( + <Button + type="primary" + key="out" + onClick={() => { + setApplyForInvoicingVisible(true); + //选中订单 + let rows = selectedRowObj?.map((item) => { + return Object.values(item)[0]; + }); + setSelectedRows(rows); + setIsEdit(false); + setIsMainOrder(true); + }} + disabled={selectedItems?.length === 0} + > + 合并开票 + </Button>, + ); + } + if (rolePath?.includes('addOrder')) { toolBtns.push( <Button @@ -2120,6 +2194,7 @@ const OrderPage = () => { </Button>, ); } + if (rolePath?.includes('importExcel')) { toolBtns.push( <Button @@ -2276,6 +2351,7 @@ const OrderPage = () => { } setRolePath(data.specialPath); handleTableExpand(mainOrderIds); + setData(data?.data); return { data: data?.data || [], total: data?.total || 0, @@ -2319,7 +2395,8 @@ const OrderPage = () => { {applyForInvoicingVisible && ( <ApplyForInvoicingModal setCheckVisible={setApplyForInvoicingVisible} - subOrders={selectedRows} + data={selectedRows} + isMainOrder={isMainOrder} isEdit={isEdit} onClose={() => { setApplyForInvoicingVisible(false); @@ -2385,6 +2462,7 @@ const OrderPage = () => { <FinancialEditDrawer mainOrder={orderRow} subOrders={selectedRows} + isMainOrder={isMainOrder} setVisible={() => { setFinancialEditVisible(false); setIsMainOrder(false); diff --git a/src/pages/OrderReport/index.tsx b/src/pages/OrderReport/index.tsx index bf56f16..0e407e2 100644 --- a/src/pages/OrderReport/index.tsx +++ b/src/pages/OrderReport/index.tsx @@ -144,6 +144,7 @@ const OrderReportPage = () => { split className="!p-0 order-statistic-search" labelWidth="auto" + defaultCollapsed={false} form={form} onFinish={async () => { loadData(); diff --git a/src/services/definition.ts b/src/services/definition.ts index dd8191d..c49c399 100644 --- a/src/services/definition.ts +++ b/src/services/definition.ts @@ -834,6 +834,13 @@ export interface QueryMainOrderDto { export interface QueryReportFormsDto { /** * @description + * 最大金额 + * @example + * 2343 + */ + maxAccount?: number; + /** + * @description * 所属部门 */ productBelongBusiness?: string; diff --git a/src/services/request.ts b/src/services/request.ts index 390c448..a26b677 100644 --- a/src/services/request.ts +++ b/src/services/request.ts @@ -5854,6 +5854,82 @@ export const postServiceOrderInvoicing = /* #__PURE__ */ (() => { return request; })(); +/** @description request parameter type for postServiceOrderMergeApplyInvoicing */ +export interface PostServiceOrderMergeApplyInvoicingOption { + /** + * @description + * 销售发起开票备注 + */ + query?: { + /** + @description + 销售发起开票备注 */ + applyInvoicingNotes?: string; + 'filePaths[0].url'?: string; + /** + @description + 主订单id集合 */ + mainOrderIds?: Array<number>; + }; +} + +/** @description response type for postServiceOrderMergeApplyInvoicing */ +export interface PostServiceOrderMergeApplyInvoicingResponse { + /** + * @description + * OK + */ + 200: ServerResult; + /** + * @description + * Created + */ + 201: any; + /** + * @description + * Unauthorized + */ + 401: any; + /** + * @description + * Forbidden + */ + 403: any; + /** + * @description + * Not Found + */ + 404: any; +} + +export type PostServiceOrderMergeApplyInvoicingResponseSuccess = + PostServiceOrderMergeApplyInvoicingResponse[200]; +/** + * @description + * 合并申请开票 + * @tags 内部订单 + * @produces * + * @consumes application/json + */ +export const postServiceOrderMergeApplyInvoicing = /* #__PURE__ */ (() => { + const method = 'post'; + const url = '/service/order/mergeApplyInvoicing'; + function request( + option?: PostServiceOrderMergeApplyInvoicingOption, + ): Promise<PostServiceOrderMergeApplyInvoicingResponseSuccess> { + return requester(request.url, { + method: request.method, + ...option, + }) as unknown as Promise<PostServiceOrderMergeApplyInvoicingResponseSuccess>; + } + + /** http method */ + request.method = method; + /** request url */ + request.url = url; + return request; +})(); + /** @description request parameter type for postServiceOrderNoNeedInvoicingEdit */ export interface PostServiceOrderNoNeedInvoicingEditOption { /** @@ -7487,6 +7563,60 @@ export const postServiceOrderQueryReportFormsInformation = return request; })(); +/** @description response type for postServiceOrderQuerySalesCode */ +export interface PostServiceOrderQuerySalesCodeResponse { + /** + * @description + * OK + */ + 200: ServerResult; + /** + * @description + * Created + */ + 201: any; + /** + * @description + * Unauthorized + */ + 401: any; + /** + * @description + * Forbidden + */ + 403: any; + /** + * @description + * Not Found + */ + 404: any; +} + +export type PostServiceOrderQuerySalesCodeResponseSuccess = + PostServiceOrderQuerySalesCodeResponse[200]; +/** + * @description + * 查询销售代码 + * @tags 内部订单 + * @produces * + * @consumes application/json + */ +export const postServiceOrderQuerySalesCode = /* #__PURE__ */ (() => { + const method = 'post'; + const url = '/service/order/querySalesCode'; + function request(): Promise<PostServiceOrderQuerySalesCodeResponseSuccess> { + return requester(request.url, { + method: request.method, + }) as unknown as Promise<PostServiceOrderQuerySalesCodeResponseSuccess>; + } + + /** http method */ + request.method = method; + /** request url */ + request.url = url; + return request; +})(); + /** @description request parameter type for postServiceOrderQueryServiceOrder */ export interface PostServiceOrderQueryServiceOrderOption { /** @@ -7825,60 +7955,6 @@ export const postServiceOrderSupplierSendOrder = /* #__PURE__ */ (() => { return request; })(); -/** @description response type for postServiceOrderTest */ -export interface PostServiceOrderTestResponse { - /** - * @description - * OK - */ - 200: ServerResult; - /** - * @description - * Created - */ - 201: any; - /** - * @description - * Unauthorized - */ - 401: any; - /** - * @description - * Forbidden - */ - 403: any; - /** - * @description - * Not Found - */ - 404: any; -} - -export type PostServiceOrderTestResponseSuccess = - PostServiceOrderTestResponse[200]; -/** - * @description - * 测试 - * @tags 内部订单 - * @produces * - * @consumes application/json - */ -export const postServiceOrderTest = /* #__PURE__ */ (() => { - const method = 'post'; - const url = '/service/order/test'; - function request(): Promise<PostServiceOrderTestResponseSuccess> { - return requester(request.url, { - method: request.method, - }) as unknown as Promise<PostServiceOrderTestResponseSuccess>; - } - - /** http method */ - request.method = method; - /** request url */ - request.url = url; - return request; -})(); - /** @description request parameter type for postServiceOrderUpdateAnnex */ export interface PostServiceOrderUpdateAnnexOption { /**