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

fix: 销售订单转单

parent 0a1b0a61
import React, { useState, useEffect } from 'react'
import { IAntdSchemaFormProps } from '@formily/antd'
import { Modal } from 'antd'
import NiceForm from '../NiceForm'
import NiceForm, { NiceFormProps } from '../NiceForm'
import { ModalProps } from 'antd/es/modal'
export interface ModalFormProps extends IAntdSchemaFormProps {
export interface ModalFormProps extends IAntdSchemaFormProps, NiceFormProps {
confirm?(),
cancel?(),
closeabled?: boolean
......@@ -26,7 +26,7 @@ const ModalForm:React.FC<ModalFormProps> = (props) => {
}
}
}, [])
const handleConfirm = () => {
// 是否需要关闭弹窗, 默认关闭
confirm && confirm()
......@@ -55,4 +55,4 @@ const ModalForm:React.FC<ModalFormProps> = (props) => {
ModalForm.defaultProps = {}
export default ModalForm
\ No newline at end of file
export default ModalForm
......@@ -242,7 +242,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
name="brandName"
label="商品品牌"
>
<Input placeholder="请选择商品品牌" disabled={!isUpdateAttribute} defaultValue={productInfoByEdit.brand.name} />
<Input placeholder="请选择商品品牌" disabled={!isUpdateAttribute} defaultValue={productInfoByEdit.brand?.name} />
</Form.Item>
:
<Form.Item
......
......@@ -156,10 +156,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
spec: item.type,
quotedSpec: item.relevanceProductType,
deliveryType: item.logistics,
addressId: address.id || null,
address: address.fullAddress || null,
receiver: address.shipperName || null,
phone: address.phone || null,
addressId: address?.id || null,
address: address?.fullAddress || null,
receiver: address?.shipperName || null,
phone: address?.phone || null,
}
})
......
......@@ -9,7 +9,6 @@ import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { useModalTable } from '../../purchaseOrder/orderCollectB2b/model/useModalTable'
import { Button } from 'antd'
import { PublicApi } from '@/services/api'
import { setAuth, setRouters } from '@/utils/auth'
/** 订单审核各个页面 只有订单类型查询的Schema */
export const tableListSchema: any = (align?: String, colStyle?: Object) => {
......@@ -154,26 +153,11 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
const { visible, setVisible } = useModalTable()
const handleDelete = (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 => { })
console.log(record, '删除转单')
}
const [orderColumns, setOrderColumns] = useState(() => {
const orderInfoColumns = [
{
title: '订单号',
......@@ -199,17 +183,9 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
{
title: '供应会员',
align: 'center',
dataIndex: 'vendorMemberName',
key: 'vendorMemberName',
dataIndex: 'supplyMemberName',
key: 'supplyMemberName',
ellipsis: true,
render: (t, r) => t ? t : r.memberName
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
render: (text) => formatTimeString(text)
},
{
title: '订单总额',
......@@ -221,10 +197,7 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
},
]
// 渲染操作
orderInfoColumns[orderInfoColumns.length - 1].render = (text, record) => <>
<Button type='link' size="small" onClick={() => handleModify(record)}>修改</Button>
<Button type='link' size="small" onClick={() => handleDelete(record)}>删除</Button>
</>
orderInfoColumns[orderInfoColumns.length - 1].render = (text, record) => <Button type='link' size="small" onClick={() => handleDelete(record)}>删除</Button>
return orderInfoColumns
})
......
import React, { useRef } from 'react'
import { Card, Button, Space } from 'antd'
import React, { useRef, useState } from 'react'
import { Card, Button, Space, message } from 'antd'
import { StandardTable } from 'god'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { PublicApi } from '@/services/api'
......@@ -36,8 +36,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const pauseRef = useRef<any>({})
const { run, loading } = useHttpRequest(PublicApi.postOrderVendorCancel)
const { run: runPause, loading: loadingEnd } = useHttpRequest(PublicApi.postOrderVendorTerminate)
const { transformRef, orderColumns } = useTransformOrderTable(transformActions)
// const [transformLoading, setTransformLoading] = useState<boolean>(false)
// 提交取消
const handleSubmit = () => {
......@@ -81,29 +81,62 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
pauseActions.setFieldValue('state', 1)
}
// 单个转单
const handelTransformOrder = (r) => {
transformRef.current.setVisible(true)
transformActions.setFieldValue('orders', [
{ id: 1, orderNo: 'TYBHU', digest: '666', vendorMemberName: '999', createTime: '2015-12-20 20:15:12', amount: '123'},
{ id: 2, orderNo: 'IYGUIH', digest: '56', vendorMemberName: '651', createTime: '2015-02-15 20:15:12', amount: '123'}
])
const [selectedRowKeys, setSelectedRowKeys] = useState<Array<number>>([])
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)
console.log(data, 'fdd')
transformActions.setFieldValue('orders', data)
}
} 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 = () => {
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 buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment, '转单': true }
const buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment, '转单': record.showTransfer }
const operationHandler = {
'取消订单': () => handleCancel(record),
'中止': () => handleSuspend(record),
'评价': () => handleEvaluate(record.orderId),
'转单': () => handelTransformOrder(record),
'转单': () => handelTransformOrder(record.orderId),
}
return (
......@@ -131,7 +164,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const controllerBtns = <Space>
<Button style={{width: 140}} onClick={() => {}} type='default'>导出</Button>
<Button type="primary">转单</Button>
<Button type="primary" onClick={() => handelTransformOrder()}>转单</Button>
</Space>
registerVirtualBox("CustomTitle", ({ children, schema }) => {
......@@ -143,7 +176,9 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
<StandardTable
fetchTableData={params => fetchTableData(params)}
columns={secondColumns()}
rowSelection={rowSelection}
currentRef={ref}
rowKey="orderId"
controlRender={
<NiceForm
actions={formActions}
......@@ -166,9 +201,6 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}}
/>
}
tableProps={{
rowKey: 'orderNo',
}}
/>
</Card>
{/* 取消原因 */}
......@@ -272,10 +304,11 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
currentRef={transformRef}
confirm={handleSubmitTransform}
actions={transformActions}
// loading={transformLoading}
schema={{
type: 'object',
properties: {
roleType: {
roleId: {
type: 'number',
title: '会员角色(转单采购)',
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