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

fix: 确认转单

parent aa4772f6
......@@ -174,7 +174,7 @@ const AddProducts: React.FC<{}> = (props) => {
if(productInfoByEdit?.type === CommodityType.UPPER_SUPPORTER_COMMODITY) {
// @ 上游商品 直接取原信息中的品类品牌id
_bacsicForm.customerCategoryId = productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + '')
_bacsicForm.brandId = productInfoByEdit?.brand.id
_bacsicForm.brandId = productInfoByEdit?.brand?.id || null
}
_bacsicForm.customerCategoryId = _bacsicForm.customerCategoryId[_bacsicForm.customerCategoryId.length - 1]
// 移除描述中的空数组[]
......
......@@ -162,7 +162,8 @@ const addressSchema: ISchema = {
}
],
"x-component-props": {
placeholder: '输入你的手机号码'
placeholder: '输入你的手机号码',
style: { width: '100%' }
}
}
}
......@@ -183,4 +184,4 @@ const addressSchema: ISchema = {
}
}
export default addressSchema
\ No newline at end of file
export default addressSchema
......@@ -161,7 +161,8 @@ const addressSchema: ISchema = {
}
],
"x-component-props": {
placeholder: '输入你的手机号码'
placeholder: '输入你的手机号码',
style: { width: '100%' }
}
}
}
......
......@@ -153,11 +153,12 @@ export const useTransformOrderTable = (ctx: ISchemaFormActions | ISchemaFormAsyn
const { visible, setVisible } = useModalTable()
const handleDelete = (record) => {
console.log(record, '删除转单')
const orders = ctx.getFieldValue('orders')
const data = orders.filter(item => item.orderId !== record.orderId)
ctx.setFieldValue('orders', [...data])
}
const [orderColumns, setOrderColumns] = useState(() => {
const orderInfoColumns = [
{
title: '订单号',
......
......@@ -15,6 +15,7 @@ import { createFormActions, registerVirtualBox } from '@formily/antd'
import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import TableOperation from '@/components/TableOperation'
import { getAuth } from '@/utils/auth'
// 销售订单查询
......@@ -38,6 +39,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const { run: runPause, loading: loadingEnd } = useHttpRequest(PublicApi.postOrderVendorTerminate)
const { transformRef, orderColumns } = useTransformOrderTable(transformActions)
// const [transformLoading, setTransformLoading] = useState<boolean>(false)
const { roles } = getAuth() || {}
const serversRoles = roles.filter(item => item['roleType'] === 2)
// 提交取消
const handleSubmit = () => {
......@@ -97,19 +100,40 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
// 单个或批量转单
const handelTransformOrder = async (orderId?) => {
if(!serversRoles.length) {
return message.error('当前登录会员,无服务消费者角色,无法进行转单')
}
if(orderId) {
const { code, data } = await PublicApi.postOrderVendorTransferPreview([{ orderId }])
const { code, data } = await PublicApi.postOrderVendorTransferPreview([{ orderId }], { ctlType: 'none' })
if(code === 1000) {
transformRef.current.setVisible(true)
console.log(data, 'fdd')
transformActions.setFieldValue('orders', data)
transformActions.setFieldState('roleId', prevState => {
prevState.props.enum = serversRoles.map(item => ({
label: item.memberRoleName,
value: item.memberRoleId,
}))
})
transformActions.setFieldValue('roleId', serversRoles[0]['memberRoleId'])
transformActions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].number = 1
})
}
} else if(selectRef.current.length) {
const { code, data } = await PublicApi.postOrderVendorTransferPreview(selectRef.current.map(item => ({ orderId: item })))
const { code, data } = await PublicApi.postOrderVendorTransferPreview(selectRef.current.map(item => ({ orderId: item })), { ctlType: 'none' })
if(code === 1000) {
transformRef.current.setVisible(true)
console.log(data, 'fdd')
transformActions.setFieldValue('orders', data)
transformActions.setFieldState('roleId', prevState => {
prevState.props.enum = serversRoles.map(item => ({
label: item.memberRoleName,
value: item.memberRoleId,
}))
})
transformActions.setFieldValue('roleId', serversRoles[0]['memberRoleId'])
transformActions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].number = selectRef.current.length
})
}
} else {
return message.error('请选择需要转单的订单')
......@@ -118,11 +142,14 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const handleSubmitTransform = () => {
transformActions.submit(values => {
console.log(values)
transformRef.current.setVisible(false)
const { roleId, orders } = values
PublicApi.postOrderVendorTransfer({ roleId, orderIds: orders.map(item => item.orderId)}).then(res => {
if(res.code === 1000) {
ref.current.reload()
setSelectedRowKeys([])
setTimeout(() => {
ref.current.reload()
}, 800)
}
})
})
......@@ -167,8 +194,8 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
<Button type="primary" onClick={() => handelTransformOrder()}>转单</Button>
</Space>
registerVirtualBox("CustomTitle", ({ children, schema }) => {
return <p>当前勾运了<b> 3 </b>张订单进行转单,转单后生成的采购订单可通过会员角色<b> 采购商角色 </b>进行查看</p>
registerVirtualBox("CustomTitle", ({ props }) => {
return <p>当前勾运了<b> { props['x-component-props'].number } </b>张订单进行转单,转单后生成的采购订单可通过会员角色<b> {props['x-component-props'].roleName || serversRoles[0]['memberRoleName']} </b>进行查看</p>
})
return <PageHeaderWrapper>
......@@ -311,6 +338,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
roleId: {
type: 'number',
title: '会员角色(转单采购)',
required: true,
enum: [
{
label: '采购商(默认)',
......@@ -321,17 +349,19 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
value: 2
}
],
"x-component-props": {
require: true,
}
},
NOT_SUBMIT_TITLE: {
type: 'object',
"x-component": "CustomTitle",
"x-component-props": {
number: 0,
roleName: null,
}
},
orders: {
type: 'array',
"x-component": 'MultTable',
required: true,
"x-component-props": {
rowKey: 'id',
columns: "{{orderColumns}}",
......@@ -340,6 +370,14 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
},
}
}}
effects={($, actions) => {
$('onFieldInputChange', 'roleId').subscribe(state => {
actions.setFieldState
actions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].roleName = state.values[1].title
})
})
}}
expressionScope={{
orderColumns,
}}
......
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