Commit e9f5383b authored by XieZhiXiong's avatar XieZhiXiong

feat: 修改转单接口参数、添加切换角色重新调取预览转单接口逻辑

parent 7f7072bb
......@@ -11,11 +11,12 @@ import { FORM_FILTER_PATH } from '@/formSchema/const'
import DateRangePickerUnix from '@/components/NiceForm/components/DateRangePickerUnix'
import Submit from '@/components/NiceForm/components/Submit'
import NiceForm from '@/components/NiceForm'
import { createFormActions, registerVirtualBox } from '@formily/antd'
import { createFormActions, registerVirtualBox, FormPath } from '@formily/antd'
import ModalForm from '@/components/ModalForm'
import { useHttpRequest } from '@/hooks/useHttpRequest'
import TableOperation from '@/components/TableOperation'
import { getAuth } from '@/utils/auth'
import { MEMBER_ROLE_TYPE_SERVICE_CONSUMER } from '@/constants/member';
// 销售订单查询
......@@ -40,7 +41,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
const { transformRef, orderColumns } = useTransformOrderTable(transformActions)
// const [transformLoading, setTransformLoading] = useState<boolean>(false)
const { roles } = getAuth() || {}
const serversRoles = roles.filter(item => item['roleType'] === 2)
const serversRoles = roles.filter(item => item['roleType'] === MEMBER_ROLE_TYPE_SERVICE_CONSUMER)
// 提交取消
const handleSubmit = () => {
......@@ -103,8 +104,9 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
if(!serversRoles.length) {
return message.error('当前登录会员,无服务消费者角色,无法进行转单')
}
const firstRole = serversRoles[0];
if(orderId) {
const { code, data } = await PublicApi.postOrderVendorTransferPreview([{ orderId }], { ctlType: 'none' })
const { code, data } = await PublicApi.postOrderVendorTransferPreview({ roleId: firstRole.memberRoleId, orderIds: [orderId] }, { ctlType: 'none' })
if(code === 1000) {
transformRef.current.setVisible(true)
transformActions.setFieldValue('orders', data)
......@@ -114,13 +116,13 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
value: item.memberRoleId,
}))
})
transformActions.setFieldValue('roleId', serversRoles[0]['memberRoleId'])
transformActions.setFieldValue('roleId', firstRole.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 })), { ctlType: 'none' })
const { code, data } = await PublicApi.postOrderVendorTransferPreview({ roleId: firstRole.memberRoleId, orderIds: selectRef.current.map(item => item) }, { ctlType: 'none' })
if(code === 1000) {
transformRef.current.setVisible(true)
transformActions.setFieldValue('orders', data)
......@@ -130,7 +132,7 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
value: item.memberRoleId,
}))
})
transformActions.setFieldValue('roleId', serversRoles[0]['memberRoleId'])
transformActions.setFieldValue('roleId', firstRole.memberRoleId)
transformActions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].number = selectRef.current.length
})
......@@ -371,7 +373,26 @@ const SaleOrder: React.FC<SaleOrderProps> = (props) => {
}
}}
effects={($, actions) => {
$('onFieldInputChange', 'roleId').subscribe(state => {
$('onFieldInputChange', 'roleId').subscribe(async (state) => {
const ordersValue = actions.getFieldValue('orders');
actions.setFieldState('roleId', (fieldState) => {
FormPath.setIn(fieldState, 'props.x-props.hasFeedback', true);
FormPath.setIn(fieldState, 'loading', true);
});
const { code, data } = await PublicApi.postOrderVendorTransferPreview({ roleId: state.value, orderIds: ordersValue.map((item) => item.orderId) }, { ctlType: 'none' })
if (code === 1000) {
actions.setFieldValue('orders', data)
actions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].number = ordersValue.length
})
}
actions.setFieldState('roleId', (fieldState) => {
FormPath.setIn(fieldState, 'loading', false);
});
actions.setFieldState
actions.setFieldState('NOT_SUBMIT_TITLE', prevState => {
prevState.props['x-component-props'].roleName = state.values[1].title
......
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