Commit 08fcd55f authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 销售订单转单

parent 0a1b0a61
import React, { useState, useEffect } from 'react' import React, { useState, useEffect } from 'react'
import { IAntdSchemaFormProps } from '@formily/antd' import { IAntdSchemaFormProps } from '@formily/antd'
import { Modal } from 'antd' import { Modal } from 'antd'
import NiceForm from '../NiceForm' import NiceForm, { NiceFormProps } from '../NiceForm'
import { ModalProps } from 'antd/es/modal' import { ModalProps } from 'antd/es/modal'
export interface ModalFormProps extends IAntdSchemaFormProps { export interface ModalFormProps extends IAntdSchemaFormProps, NiceFormProps {
confirm?(), confirm?(),
cancel?(), cancel?(),
closeabled?: boolean closeabled?: boolean
......
...@@ -242,7 +242,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => { ...@@ -242,7 +242,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
name="brandName" name="brandName"
label="商品品牌" label="商品品牌"
> >
<Input placeholder="请选择商品品牌" disabled={!isUpdateAttribute} defaultValue={productInfoByEdit.brand.name} /> <Input placeholder="请选择商品品牌" disabled={!isUpdateAttribute} defaultValue={productInfoByEdit.brand?.name} />
</Form.Item> </Form.Item>
: :
<Form.Item <Form.Item
......
...@@ -156,10 +156,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -156,10 +156,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
spec: item.type, spec: item.type,
quotedSpec: item.relevanceProductType, quotedSpec: item.relevanceProductType,
deliveryType: item.logistics, deliveryType: item.logistics,
addressId: address.id || null, addressId: address?.id || null,
address: address.fullAddress || null, address: address?.fullAddress || null,
receiver: address.shipperName || null, receiver: address?.shipperName || null,
phone: address.phone || null, phone: address?.phone || null,
} }
}) })
......
...@@ -9,7 +9,6 @@ import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd' ...@@ -9,7 +9,6 @@ import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useModalTable } from '../../purchaseOrder/orderCollectB2b/model/useModalTable' import { useModalTable } from '../../purchaseOrder/orderCollectB2b/model/useModalTable'
import { Button } from 'antd' import { Button } from 'antd'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { setAuth, setRouters } from '@/utils/auth'
/** 订单审核各个页面 只有订单类型查询的Schema */ /** 订单审核各个页面 只有订单类型查询的Schema */
export const tableListSchema: any = (align?: String, colStyle?: Object) => { export const tableListSchema: any = (align?: String, colStyle?: Object) => {
...@@ -154,26 +153,11 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn ...@@ -154,26 +153,11 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
const { visible, setVisible } = useModalTable() const { visible, setVisible } = useModalTable()
const handleDelete = (record) => { const handleDelete = (record) => {
console.log(record, '删除转单')
}
const handleModify = (record) => {
alert('转单修改')
// PublicApi.postMemberLoginSwitchrole({
// memberRoleId: 11,
// }).then(res => {
// if (res.code === 1000) {
// // @ts-ignore
// setAuth(res.data);
// setRouters(res.data.urls);
// setTimeout(() => {
// window.location.replace(`/memberCenter/tranactionAbility/productInquiry/waitAddInquiry/two?id=${record.order}`);
// }, 800);
// }
// }).catch(err => { })
} }
const [orderColumns, setOrderColumns] = useState(() => { const [orderColumns, setOrderColumns] = useState(() => {
const orderInfoColumns = [ const orderInfoColumns = [
{ {
title: '订单号', title: '订单号',
...@@ -199,17 +183,9 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn ...@@ -199,17 +183,9 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
{ {
title: '供应会员', title: '供应会员',
align: 'center', align: 'center',
dataIndex: 'vendorMemberName', dataIndex: 'supplyMemberName',
key: 'vendorMemberName', key: 'supplyMemberName',
ellipsis: true, ellipsis: true,
render: (t, r) => t ? t : r.memberName
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
render: (text) => formatTimeString(text)
}, },
{ {
title: '订单总额', title: '订单总额',
...@@ -221,10 +197,7 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn ...@@ -221,10 +197,7 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
}, },
] ]
// 渲染操作 // 渲染操作
orderInfoColumns[orderInfoColumns.length - 1].render = (text, record) => <> orderInfoColumns[orderInfoColumns.length - 1].render = (text, record) => <Button type='link' size="small" onClick={() => handleDelete(record)}>删除</Button>
<Button type='link' size="small" onClick={() => handleModify(record)}>修改</Button>
<Button type='link' size="small" onClick={() => handleDelete(record)}>删除</Button>
</>
return orderInfoColumns return orderInfoColumns
}) })
......
import React, { useRef } from 'react' import React, { useRef, useState } from 'react'
import { Card, Button, Space } from 'antd' import { Card, Button, Space, message } from 'antd'
import { StandardTable } from 'god' import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout' import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
...@@ -36,8 +36,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -36,8 +36,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const pauseRef = useRef<any>({}) const pauseRef = useRef<any>({})
const { run, loading } = useHttpRequest(PublicApi.postOrderVendorCancel) const { run, loading } = useHttpRequest(PublicApi.postOrderVendorCancel)
const { run: runPause, loading: loadingEnd } = useHttpRequest(PublicApi.postOrderVendorTerminate) const { run: runPause, loading: loadingEnd } = useHttpRequest(PublicApi.postOrderVendorTerminate)
const { transformRef, orderColumns } = useTransformOrderTable(transformActions) const { transformRef, orderColumns } = useTransformOrderTable(transformActions)
// const [transformLoading, setTransformLoading] = useState<boolean>(false)
// 提交取消 // 提交取消
const handleSubmit = () => { const handleSubmit = () => {
...@@ -81,29 +81,62 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -81,29 +81,62 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
pauseActions.setFieldValue('state', 1) pauseActions.setFieldValue('state', 1)
} }
// 单个转单 const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([])
const handelTransformOrder = (r) => { const selectRef = useRef([])
const rowSelection = {
selectedRowKeys: selectedRowKeys,
onChange: (selectedRowKeys) => {
setSelectedRowKeys(selectedRowKeys)
selectRef.current = selectedRowKeys
},
getCheckboxProps: (record) => ({
disabled: !record.showTransfer,
name: record.name,
}),
}
// 单个或批量转单
const handelTransformOrder = async (orderId?) => {
if(orderId) {
const { code, data } = await PublicApi.postOrderVendorTransferPreview([{ orderId }])
if(code === 1000) {
transformRef.current.setVisible(true) transformRef.current.setVisible(true)
transformActions.setFieldValue('orders', [ console.log(data, 'fdd')
{ id: 1, orderNo: 'TYBHU', digest: '666', vendorMemberName: '999', createTime: '2015-12-20 20:15:12', amount: '123'}, transformActions.setFieldValue('orders', data)
{ id: 2, orderNo: 'IYGUIH', digest: '56', vendorMemberName: '651', createTime: '2015-02-15 20:15:12', amount: '123'} }
]) } else if(selectRef.current.length) {
const { code, data } = await PublicApi.postOrderVendorTransferPreview(selectRef.current.map(item => ({ orderId: item })))
if(code === 1000) {
transformRef.current.setVisible(true)
console.log(data, 'fdd')
transformActions.setFieldValue('orders', data)
}
} else {
return message.error('请选择需要转单的订单')
}
} }
// 批量转单
const handleSubmitTransform = () => { const handleSubmitTransform = () => {
alert('批量转单') transformActions.submit(values => {
console.log(values)
const { roleId, orders } = values
PublicApi.postOrderVendorTransfer({ roleId, orderIds: orders.map(item => item.orderId)}).then(res => {
if(res.code === 1000) {
ref.current.reload()
}
})
})
} }
/** 参照后台数据生成 */ /** 参照后台数据生成 */
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment, '转单': true } const buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment, '转单': record.showTransfer }
const operationHandler = { const operationHandler = {
'取消订单': () => handleCancel(record), '取消订单': () => handleCancel(record),
'中止': () => handleSuspend(record), '中止': () => handleSuspend(record),
'评价': () => handleEvaluate(record.orderId), '评价': () => handleEvaluate(record.orderId),
'转单': () => handelTransformOrder(record), '转单': () => handelTransformOrder(record.orderId),
} }
return ( return (
...@@ -131,7 +164,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -131,7 +164,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const controllerBtns = <Space> const controllerBtns = <Space>
<Button style={{width: 140}} onClick={() => {}} type='default'>导出</Button> <Button style={{width: 140}} onClick={() => {}} type='default'>导出</Button>
<Button type="primary">转单</Button> <Button type="primary" onClick={() => handelTransformOrder()}>转单</Button>
</Space> </Space>
registerVirtualBox("CustomTitle", ({ children, schema }) => { registerVirtualBox("CustomTitle", ({ children, schema }) => {
...@@ -143,7 +176,9 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -143,7 +176,9 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
<StandardTable <StandardTable
fetchTableData={params => fetchTableData(params)} fetchTableData={params => fetchTableData(params)}
columns={secondColumns()} columns={secondColumns()}
rowSelection={rowSelection}
currentRef={ref} currentRef={ref}
rowKey="orderId"
controlRender={ controlRender={
<NiceForm <NiceForm
actions={formActions} actions={formActions}
...@@ -166,9 +201,6 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -166,9 +201,6 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}} }}
/> />
} }
tableProps={{
rowKey: 'orderNo',
}}
/> />
</Card> </Card>
{/* 取消原因 */} {/* 取消原因 */}
...@@ -272,10 +304,11 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -272,10 +304,11 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
currentRef={transformRef} currentRef={transformRef}
confirm={handleSubmitTransform} confirm={handleSubmitTransform}
actions={transformActions} actions={transformActions}
// loading={transformLoading}
schema={{ schema={{
type: 'object', type: 'object',
properties: { properties: {
roleType: { roleId: {
type: 'number', type: 'number',
title: '会员角色(转单采购)', title: '会员角色(转单采购)',
enum: [ enum: [
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment