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

fix: 添加转单

parent 75b1f865
...@@ -3,7 +3,6 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'; ...@@ -3,7 +3,6 @@ import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { useLinkageUtils } from '@/utils/formEffectUtils'; import { useLinkageUtils } from '@/utils/formEffectUtils';
import { fetchOrderApi } from '../apis'; import { fetchOrderApi } from '../apis';
import { PublicApi } from '@/services/api'; import { PublicApi } from '@/services/api';
import moment from 'moment';
// 异步填充表格字段 // 异步填充表格字段
...@@ -18,39 +17,20 @@ const asyncPadDataForProduct = async (ctx: ISchemaFormActions | ISchemaFormAsync ...@@ -18,39 +17,20 @@ const asyncPadDataForProduct = async (ctx: ISchemaFormActions | ISchemaFormAsync
ctx.setFieldState(productValue.path, state => { ctx.setFieldState(productValue.path, state => {
state.loading = true state.loading = true
}) })
// // 折扣请求
// const asyncPriceRequests: any[] = await Promise.all(productData.filter(v => v.memberPrice === undefined).map(async v => { const newData = productData.map((v, i) => {
// const {code, data} = await PublicApi.getMemberManageUpperCreditParamGet({ //@ b2b订单不考虑会员折扣 字段固定100
// parentMemberId: v.memberId, v.discount = 100
// parentMemberRoleId: v.memberRoleId return v
// }, {ttl: 60 * 1000, useCache: true}) })
// return code === 1000 ? { value: data.parameter, id: v.id } : { value: '', id: 0 } ctx.setFieldValue('products', newData)
// }
// ))
// // 存在需要异步请求的, 则进行赋值
// if (asyncPriceRequests.length > 0) {
const newData = productData.map((v, i) => {
// if (!v.memberPrice) {
// v.memberPrice = asyncPriceRequests.find(j => j.id === v.id)?.value || ''
// }
// // @ b2b订单不考虑会员折扣 字段固定100
v.discount = 100
return v
})
ctx.setFieldValue('products', newData)
// }
ctx.setFieldState(productValue.path, state => { ctx.setFieldState(productValue.path, state => {
state.loading = false state.loading = false
}) })
} }
export const createEffects = context => () => {
}
export const useModelTypeChange = (callback) => { export const useModelTypeChange = (callback) => {
const utils = useLinkageUtils()
// 下单模式发生改变时 // 下单模式发生改变时
FormEffectHooks.onFieldValueChange$('orderMode').subscribe(state => { FormEffectHooks.onFieldValueChange$('orderMode').subscribe(state => {
callback(state) callback(state)
...@@ -83,40 +63,37 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor ...@@ -83,40 +63,37 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if (value && value.length > 0 && !state.loading){ // 添加loading判断避免二次调用 if (value && value.length > 0 && !state.loading){ // 添加loading判断避免二次调用
// 请求一次并复制给支付信息 // 请求一次并复制给支付信息
const productItem = value[0] const productItem = value[0]
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现 if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
const shopId = ctx.getFieldValue('shopId')
} else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数 const products = value.map(item => ({ productId: item.commodityId, skuId: item.productId }))
const shopId = ctx.getFieldValue('shopId') if(shopId && products?.length) {
const products = value.map(item => ({ productId: item.commodityId, skuId: item.productId })) // 判断不存在物流 隐藏交付地址
if(shopId && products?.length) { if(!value.some(item => item.logistics.deliveryType === 1)) {
// 判断不存在物流 隐藏交付地址 ctx.setFieldState('deliveryAddresId', state => state.visible = false )
if(!value.some(item => item.logistics.deliveryType === 1)) { } else {
ctx.setFieldState('deliveryAddresId', state => state.visible = false ) ctx.setFieldState('deliveryAddresId', state => state.visible = true )
} else { }
ctx.setFieldState('deliveryAddresId', state => state.visible = true )
fetchOrderApi.getPayInfoList({
products: products,
memberId: productItem?.memberId,
roleId: productItem?.memberRoleId,
orderMode: orderMode,
shopId: shopId
}).then(data => {
ctx.setFieldValue('payments', data.map(item => ({
...item,
payPrice: (sumPrice * Number(item.payRate) / 100).toFixed(2)
})))
}).catch(err => { })
} }
console.log('2')
fetchOrderApi.getPayInfoList({
products: products,
memberId: productItem?.memberId,
roleId: productItem?.memberRoleId,
orderMode: orderMode,
shopId: shopId
}).then(data => {
ctx.setFieldValue('payments', data.map(item => ({
...item,
payPrice: (sumPrice * Number(item.payRate) / 100).toFixed(2)
})))
}).catch(err => {
})
}
} }
} }
// 确认后 需根据商品id请求会员折扣接口, 以及配送方式 // 确认后 需根据商品id请求会员折扣接口, 以及配送方式
// 由于商品存在多个, 需对接口做一定缓存 // 由于商品存在多个, 需对接口做一定缓存
asyncPadDataForProduct(ctx, state) asyncPadDataForProduct(ctx, state)
const numberInputs = document.getElementsByClassName("purchase_amount_input") const numberInputs = document.getElementsByClassName("purchase_amount_input")
if(numberInputs?.length) { if(numberInputs?.length) {
for(let i = 0; i < numberInputs.length; i++) { for(let i = 0; i < numberInputs.length; i++) {
...@@ -133,17 +110,14 @@ export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyn ...@@ -133,17 +110,14 @@ export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyn
// 写入收货地址数据 // 写入收货地址数据
useProductAddress(ctx) useProductAddress(ctx)
}) })
FormEffectHooks.onFieldValueChange$('hasInvoice').subscribe(state => { FormEffectHooks.onFieldValueChange$('hasInvoice').subscribe(state => {
if (state.value) { if (state.value) {
useInvoiceList(ctx) useInvoiceList(ctx)
} }
}) })
} }
export const useProductAddress = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => { export const useProductAddress = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
fetchOrderApi.getProductAddressAll().then(data => { fetchOrderApi.getProductAddressAll().then(data => {
ctx.setFieldState('deliveryAddresId', state => { ctx.setFieldState('deliveryAddresId', state => {
if (data.length > 0 && !state.value) { if (data.length > 0 && !state.value) {
...@@ -170,62 +144,6 @@ export const useInvoiceList = (ctx: ISchemaFormActions | ISchemaFormAsyncActions ...@@ -170,62 +144,6 @@ export const useInvoiceList = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
}) })
} }
// 编辑订单 地址和发票变动 触发订单更新
export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const { pageStatus, id } = usePageStatus()
FormEffectHooks.onFieldValueChange$('theInvoiceId').subscribe(state => {
const { value, path } = state
if(pageStatus === PageStatus.EDIT){
if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
ctx.submit((values) => {
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: value?.id || null,
hasInvoice: values.hasInvoice,
deliveryAddresId: values.deliveryAddresId,
id,
}, { ctlType: "none" })
}
})
} else {
ctx.setFieldState(path, _state => {
_state.loading = true
_state.props["x-component-props"].times++
})
}
}
})
FormEffectHooks.onFieldValueChange$('deliveryAddresId').subscribe(state => {
const { value, path } = state
if(pageStatus === PageStatus.EDIT){
if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
ctx.submit((values) => {
if(values){
PublicApi.postOrderProcurementOrderUpdate({
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: values.theInvoiceId,
hasInvoice: values.hasInvoice,
deliveryAddresId: value?.id ? value.id : value,
id,
}, { ctlType: "none" })
}
})
} else {
ctx.setFieldState(path, _state => {
_state.loading = true
_state.props["x-component-props"].times++
})
}
}
})
}
// 高级筛选schema中用于输入搜索商品品类的Effect // 高级筛选schema中用于输入搜索商品品类的Effect
/** /**
* @param ctx 外部表单action * @param ctx 外部表单action
......
...@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd ...@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd
import { SaveOutlined, LinkOutlined, PlusOutlined } from '@ant-design/icons' import { SaveOutlined, LinkOutlined, PlusOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { mergeAllSchemas } from './schema' import { mergeAllSchemas } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay, useOrderUpdateChangeOther } from './effects' import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay } from './effects'
import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant' import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant'
import { OrderModalType } from '@/constants/order' import { OrderModalType } from '@/constants/order'
import ProductModalTable from './components/productModalTable' import ProductModalTable from './components/productModalTable'
...@@ -378,28 +378,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -378,28 +378,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
]} ]}
> >
<ReadyAddOrderDetailContext.Provider value={providerValue}> <ReadyAddOrderDetailContext.Provider value={providerValue}>
{/* { pageStatus !== PageStatus.ADD && initFormValue && initFormValue.externalWorkflowFlowRecordLogResponses && <AuditProcess
customTitleKey='operationalProcess'
customKey='state'
outerVerifyCurrent={findLastIndexFlowState(initFormValue.externalWorkflowFlowRecordLogResponses)}
innerVerifyCurrent={findLastIndexFlowState(initFormValue.interiorWorkflowFlowRecordLogResponses)}
outerVerifySteps={
initFormValue.externalWorkflowFlowRecordLogResponses ?
initFormValue.externalWorkflowFlowRecordLogResponses.map(item => ({
...item,
status: item.isExecute ? 'finish' : 'wait',
})) :
[]
}
innerVerifySteps={
initFormValue.interiorWorkflowFlowRecordLogResponses ?
initFormValue.interiorWorkflowFlowRecordLogResponses.map(item => ({
...item,
status: item.isExecute ? 'finish' : 'wait',
})) :
[]
}
></AuditProcess> } */}
<Card className={styles.orderCollectCard} style={{marginTop: 24}}> <Card className={styles.orderCollectCard} style={{marginTop: 24}}>
<NiceForm <NiceForm
loading={formLoading} loading={formLoading}
...@@ -454,9 +432,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -454,9 +432,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 商品信息的改动 驱动支付信息变化 // 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update) useProductTableChangeForPay(ctx, update)
// 编辑 地址和发票信息变动 触发订单更新
useOrderUpdateChangeOther(ctx)
// 监听商品总价的变更, 支付比例计算 // 监听商品总价的变更, 支付比例计算
$('sumPrice').subscribe(payload => { $('sumPrice').subscribe(payload => {
const payment = addSchemaAction.getFieldValue('payments') const payment = addSchemaAction.getFieldValue('payments')
......
...@@ -74,63 +74,6 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor ...@@ -74,63 +74,6 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
}) })
} }
// 编辑订单 地址和发票变动 触发订单更新
export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
// const { pageStatus, id } = usePageStatus()
// FormEffectHooks.onFieldValueChange$('theInvoiceId').subscribe(state => {
// const { value, path } = state
// if(pageStatus === PageStatus.EDIT){
// if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
// ctx.submit((values) => {
// if(values){
// PublicApi.postOrderProcurementOrderUpdate({
// ...values,
// deliveryTime: moment(values.deliveryTime).valueOf(),
// theInvoiceId: value?.id || null,
// hasInvoice: Number(values.hasInvoice),
// deliveryAddresId: values.deliveryAddresId,
// id,
// }, { ctlType: "none" })
// }
// })
// } else {
// ctx.setFieldState(path, _state => {
// _state.loading = true
// _state.props["x-component-props"].times++
// })
// }
// }
// })
// FormEffectHooks.onFieldValueChange$('deliveryAddresId').subscribe(state => {
// const { value, path } = state
// if(pageStatus === PageStatus.EDIT){
// if(state?.dataSource?.length && state.loading && state.props["x-component-props"].times > 2) {
// ctx.submit((values) => {
// if(values){
// PublicApi.postOrderProcurementOrderUpdate({
// ...values,
// deliveryTime: moment(values.deliveryTime).valueOf(),
// theInvoiceId: values.theInvoiceId,
// hasInvoice: Number(values.hasInvoice),
// deliveryAddresId: value?.id ? value.id : value,
// id,
// }, { ctlType: "none" })
// }
// })
// } else {
// ctx.setFieldState(path, _state => {
// _state.loading = true
// _state.props["x-component-props"].times++
// })
// }
// }
// })
}
// 高级筛选schema中用于输入搜索商品品类的Effect // 高级筛选schema中用于输入搜索商品品类的Effect
/** /**
* @param ctx 外部表单action * @param ctx 外部表单action
......
...@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd ...@@ -8,7 +8,7 @@ import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd
import { SaveOutlined, LinkOutlined, PlusOutlined } from '@ant-design/icons' import { SaveOutlined, LinkOutlined, PlusOutlined } from '@ant-design/icons'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { mergeAllSchemas } from './schema' import { mergeAllSchemas } from './schema'
import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useOrderUpdateChangeOther, useProductTableChangeForPay } from './effects' import { useModelTypeChange, useEditHideField, useOrderFormInitEffect, useProductTableChangeForPay } from './effects'
import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant' import { orderCombination, orderTypeLabelMap, procurementProcessField, procurementRenderField, procurmentRenderInit } from './constant'
import CirculationRecord from '../components/circulationRecord' import CirculationRecord from '../components/circulationRecord'
import SelectAddress from './components/selectAddress' import SelectAddress from './components/selectAddress'
...@@ -16,11 +16,9 @@ import TheInvoiceList from './components/theInvoiceList' ...@@ -16,11 +16,9 @@ import TheInvoiceList from './components/theInvoiceList'
import styled from 'styled-components' import styled from 'styled-components'
import { useUpdate } from '@umijs/hooks' import { useUpdate } from '@umijs/hooks'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { findLastIndexFlowState } from '@/utils'
import { changeRouterTitleByStatus } from '../../_public/order/utils' import { changeRouterTitleByStatus } from '../../_public/order/utils'
import { help } from '../../common' import { help } from '../../common'
import { ReadyAddOrderDetailContext } from '../context' import { ReadyAddOrderDetailContext } from '../context'
import AuditProcess from '@/components/AuditProcess'
import styles from './index.less' import styles from './index.less'
import { useMaterialTable } from './model/useMaterialTable' import { useMaterialTable } from './model/useMaterialTable'
import ContractModalTable from './components/contractModalTable' import ContractModalTable from './components/contractModalTable'
...@@ -275,28 +273,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -275,28 +273,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
]} ]}
> >
<ReadyAddOrderDetailContext.Provider value={providerValue}> <ReadyAddOrderDetailContext.Provider value={providerValue}>
{/* { pageStatus !== PageStatus.ADD && initFormValue && initFormValue.externalWorkflowFlowRecordLogResponses && <AuditProcess
customTitleKey='operationalProcess'
customKey='state'
outerVerifyCurrent={findLastIndexFlowState(initFormValue.externalWorkflowFlowRecordLogResponses)}
innerVerifyCurrent={findLastIndexFlowState(initFormValue.interiorWorkflowFlowRecordLogResponses)}
outerVerifySteps={
initFormValue.externalWorkflowFlowRecordLogResponses ?
initFormValue.externalWorkflowFlowRecordLogResponses.map(item => ({
...item,
status: item.isExecute ? 'finish' : 'wait',
})) :
[]
}
innerVerifySteps={
initFormValue.interiorWorkflowFlowRecordLogResponses ?
initFormValue.interiorWorkflowFlowRecordLogResponses.map(item => ({
...item,
status: item.isExecute ? 'finish' : 'wait',
})) :
[]
}
></AuditProcess> } */}
<Card className={styles.orderCollectCard} style={{marginTop: 24}}> <Card className={styles.orderCollectCard} style={{marginTop: 24}}>
<NiceForm <NiceForm
loading={formLoading} loading={formLoading}
...@@ -336,9 +312,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -336,9 +312,6 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// 商品信息的改动 驱动支付信息变化 // 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update) useProductTableChangeForPay(ctx, update)
// 编辑 地址和发票信息变动 触发订单更新
useOrderUpdateChangeOther(ctx)
}} }}
expressionScope={{ expressionScope={{
orderContract, orderContract,
......
...@@ -57,7 +57,8 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio ...@@ -57,7 +57,8 @@ export const useMaterialTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActio
// 渲染单价 // 渲染单价
materialInfoColumns[7].render = (t, r) => <span style={{color: 'red'}}>{Number(r.price).toFixed(2)}</span> materialInfoColumns[7].render = (t, r) => <span style={{color: 'red'}}>{Number(r.price).toFixed(2)}</span>
materialInfoColumns[materialInfoColumns.length - 1].render = (t, r) => null // materialInfoColumns[materialInfoColumns.length - 1].render = (t, r) => null
materialInfoColumns.pop()
} }
return materialInfoColumns return materialInfoColumns
......
import React from 'react' import React, { useRef, useState } from 'react'
import { formatTimeString } from '@/utils' import { formatTimeString } from '@/utils'
import StatusColors from '@/pages/transaction/components/statusColors' import StatusColors from '@/pages/transaction/components/statusColors'
import EyePreview from '@/components/EyePreview' import EyePreview from '@/components/EyePreview'
import { history } from 'umi' import { history } from 'umi'
import { FORM_FILTER_PATH } from '@/formSchema/const'; import { FORM_FILTER_PATH } from '@/formSchema/const';
import { getSaleOrderAuditPageSelectOption } from '@/pages/transaction/effect'; import { getSaleOrderAuditPageSelectOption } from '@/pages/transaction/effect';
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 */ /** 订单审核各个页面 只有订单类型查询的Schema */
export const tableListSchema: any = (align?: String, colStyle?: Object) => { export const tableListSchema: any = (align?: String, colStyle?: Object) => {
...@@ -105,6 +110,7 @@ export const baseOrderListColumns: any = () => { ...@@ -105,6 +110,7 @@ export const baseOrderListColumns: any = () => {
align: 'center', align: 'center',
dataIndex: 'memberName', dataIndex: 'memberName',
key: 'memberName', key: 'memberName',
render: (t, r) => r.memberName ? t : r.buyerMemberName
}, },
{ {
title: '下单时间', title: '下单时间',
...@@ -141,3 +147,93 @@ export const baseOrderListColumns: any = () => { ...@@ -141,3 +147,93 @@ export const baseOrderListColumns: any = () => {
}, },
] ]
} }
// 转单适用
export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const transformRef = useRef<any>({})
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 => { })
}
const [orderColumns, setOrderColumns] = useState(() => {
const orderInfoColumns = [
{
title: '订单号',
align: 'center',
dataIndex: 'orderNo',
key: 'orderNo',
render: (text, record) => {
return (
<EyePreview url={`${history.location.pathname}/preview?id=${record.orderId}`}>
{text}
</EyePreview>
)
},
ellipsis: true,
},
{
title: '订单摘要',
align: 'center',
dataIndex: 'digest',
key: 'digest',
ellipsis: true,
},
{
title: '供应会员',
align: 'center',
dataIndex: 'vendorMemberName',
key: 'vendorMemberName',
ellipsis: true,
render: (t, r) => t ? t : r.memberName
},
{
title: '下单时间',
align: 'center',
dataIndex: 'createTime',
key: 'createTime',
render: (text) => formatTimeString(text)
},
{
title: '订单总额',
align: 'center',
dataIndex: 'amount',
key: 'amount',
ellipsis: true,
render: (t) => `¥${t}`
},
]
// 渲染操作
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>
</>
return orderInfoColumns
})
return {
transformRef,
orderColumns,
visible,
setVisible,
}
}
import React, { useCallback, useRef } from 'react' import React, { useRef } from 'react'
import { Card, Button, Dropdown, Menu } from 'antd' import { Card, Button, Space } 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'
import { baseOrderListColumns } from './constant' import { baseOrderListColumns, useTransformOrderTable } from './constant'
import { history } from 'umi' import { history } from 'umi'
import { PurchaseOrderOutWorkState } from '@/constants/order'
import { saleTableListSchema as tableListSchema } from '../_public/order/constant' import { saleTableListSchema as tableListSchema } from '../_public/order/constant'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch' import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const' import { FORM_FILTER_PATH } from '@/formSchema/const'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix' import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
import Submit from '@/components/NiceForm/components/Submit' import Submit from '@/components/NiceForm/components/Submit'
import NiceForm from '@/components/NiceForm' import NiceForm from '@/components/NiceForm'
import { createFormActions } from '@formily/antd' import { createFormActions, registerVirtualBox } from '@formily/antd'
import ModalForm from '@/components/ModalForm' import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest' import { useHttpRequest } from '@/hooks/useHttpRequest'
import { CaretDownOutlined } from '@ant-design/icons'
import TableOperation from '@/components/TableOperation' import TableOperation from '@/components/TableOperation'
// 销售订单查询 // 销售订单查询
...@@ -30,6 +28,7 @@ const fetchTableData = async (params) => { ...@@ -30,6 +28,7 @@ const fetchTableData = async (params) => {
const formActions = createFormActions(); const formActions = createFormActions();
const destroyActions = createFormActions(); const destroyActions = createFormActions();
const pauseActions = createFormActions(); const pauseActions = createFormActions();
const transformActions = createFormActions();
const SaleOrder: React.FC<SaleOrderProps> = (props) => { const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const ref = useRef<any>({}) const ref = useRef<any>({})
...@@ -38,6 +37,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -38,6 +37,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
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 handleSubmit = () => { const handleSubmit = () => {
destroyActions.submit().then(async ({values}: any) => { destroyActions.submit().then(async ({values}: any) => {
...@@ -80,14 +81,30 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -80,14 +81,30 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
pauseActions.setFieldValue('state', 1) pauseActions.setFieldValue('state', 1)
} }
// 单个转单
const handelTransformOrder = (r) => {
console.log(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 handleSubmitTransform = () => {
}
/** 参照后台数据生成 */ /** 参照后台数据生成 */
const renderOptionButton = (record: any) => { const renderOptionButton = (record: any) => {
const buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment } const buttonGroup = { '取消订单': record.showCancel, '中止': record.showTerminate, '评价': record.showComment, '转单': true }
const operationHandler = { const operationHandler = {
'取消订单': () => handleCancel(record), '取消订单': () => handleCancel(record),
'中止': () => handleSuspend(record), '中止': () => handleSuspend(record),
'评价': () => handleEvaluate(record.orderId), '评价': () => handleEvaluate(record.orderId),
'转单': () => handelTransformOrder(record),
} }
return ( return (
...@@ -113,7 +130,14 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -113,7 +130,14 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
} }
} }
const controllerBtns = <Button style={{width: 140}} onClick={() => {}} type='default'>导出</Button> const controllerBtns = <Space>
<Button style={{width: 140}} onClick={() => {}} type='default'>导出</Button>
<Button type="primary">转单</Button>
</Space>
registerVirtualBox("CustomTitle", ({ children, schema }) => {
return <p>当前勾运了3张订单进行转单,转单后生成的采购订单可通过账号“广州中石科技采购商角色”进行查看</p>
})
return <PageHeaderWrapper> return <PageHeaderWrapper>
<Card> <Card>
...@@ -148,6 +172,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -148,6 +172,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}} }}
/> />
</Card> </Card>
{/* 取消原因 */}
<ModalForm <ModalForm
modalTitle='取消原因' modalTitle='取消原因'
currentRef={destoryRef} currentRef={destoryRef}
...@@ -192,6 +217,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -192,6 +217,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}} }}
modalProps={{confirmLoading: loading}} modalProps={{confirmLoading: loading}}
/> />
{/* 中止原因 */}
<ModalForm <ModalForm
modalTitle='中止原因' modalTitle='中止原因'
currentRef={pauseRef} currentRef={pauseRef}
...@@ -241,6 +267,38 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => { ...@@ -241,6 +267,38 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}} }}
modalProps={{confirmLoading: loadingEnd}} modalProps={{confirmLoading: loadingEnd}}
/> />
{/* 确认转单 */}
<ModalForm
modalTitle='确认转单'
currentRef={transformRef}
confirm={handleSubmitTransform}
actions={transformActions}
schema={{
type: 'object',
properties: {
NOT_SUBMIT_TITLE: {
type: 'object',
"x-component": "CustomTitle",
},
orders: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
rowKey: 'id',
columns: "{{orderColumns}}",
pagination: false,
},
},
}
}}
expressionScope={{
orderColumns,
}}
// components={{
// CustomTitle
// }}
// modalProps={{confirmLoading: loadingTransform}}
/>
</PageHeaderWrapper> </PageHeaderWrapper>
} }
......
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