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

fix: 代客下单操作采购商发票信息,采购订单列表调整配送时间

parent 9b46a3c5
...@@ -218,7 +218,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => { ...@@ -218,7 +218,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
return current && current < moment().startOf('day') return current && current < moment().startOf('day')
} }
} }
if(!_data.deliveryTime) { // 有时间段 时间控件不显示时分 if(_data.deliveryTime) { // 有时间段 时间控件不显示时分
state.props['x-component-props'].showTime = false state.props['x-component-props'].showTime = false
state.props['x-component-props'].format = 'YYYY-MM-DD' state.props['x-component-props'].format = 'YYYY-MM-DD'
} else { } else {
...@@ -244,9 +244,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => { ...@@ -244,9 +244,7 @@ const PurchaseOrder: React.FC<PurchaseOrderProps> = (props) => {
adjustActions.submit().then(async ({values}: any) => { adjustActions.submit().then(async ({values}: any) => {
let params = {...values} let params = {...values}
if(values?.timeLine) { if(values?.timeLine) {
const timeLineArray = values.timeLine.split('-') params.deliverPeriod = `${params.deliverDate} ${params.timeLine}`
params.startTime = timeLineArray[0]
params.endTime = timeLineArray[1]
} }
const result = await PublicApi.postOrderBuyerUpdateDeliveryTime(params) const result = await PublicApi.postOrderBuyerUpdateDeliveryTime(params)
if (result.code === 1000) { if (result.code === 1000) {
......
...@@ -31,8 +31,8 @@ export const fetchOrderApi = { ...@@ -31,8 +31,8 @@ export const fetchOrderApi = {
return data return data
}, },
/** 获取发票列表 */ /** 获取发票列表 */
async getInvoicesList() { async getInvoicesList(params) {
const { data } = await PublicApi.getSettleAccountsInvoiceMessageList() const { data } = await PublicApi.getSettleAccountsAgentInvoiceMessageList(params)
return data return data
}, },
/** 获取支付信息列表 */ /** 获取支付信息列表 */
......
...@@ -9,7 +9,8 @@ export interface InvoiceModalProps { ...@@ -9,7 +9,8 @@ export interface InvoiceModalProps {
mode: 'add' | 'edit' | 'preview' | 'default' | 'delete', mode: 'add' | 'edit' | 'preview' | 'default' | 'delete',
currentRef?: any, currentRef?: any,
formInitValue?: any, formInitValue?: any,
reload?() reload?(),
ctx: any,
} }
const schemaActions = createFormActions() const schemaActions = createFormActions()
...@@ -20,7 +21,7 @@ const modelTitle = { ...@@ -20,7 +21,7 @@ const modelTitle = {
} }
const InvoiceModal:React.FC<InvoiceModalProps> = (props) => { const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
const { mode, formInitValue } = props const { mode, formInitValue, ctx } = props
const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue]) const selfInitValue = useMemo(() => mode === 'add' ? null : formInitValue, [mode, formInitValue])
// 由于默认是number类型, 但switch组件只接收boolean // 由于默认是number类型, 但switch组件只接收boolean
...@@ -40,8 +41,12 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => { ...@@ -40,8 +41,12 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
} }
const handleSubmit = async (value) => { const handleSubmit = async (value) => {
const subMemberId = ctx.getFieldValue('buyerMemberId')
const subRoleId = ctx.getFieldValue('buyerRoleId')
const params = { const params = {
...value, ...value,
subMemberId,
subRoleId,
isDefault: value?.isDefault ? 1 : 0 isDefault: value?.isDefault ? 1 : 0
} }
const fn = mode === 'edit' ? PublicApi.postSettleAccountsInvoiceMessageUpdate : PublicApi.postSettleAccountsInvoiceMessageAdd const fn = mode === 'edit' ? PublicApi.postSettleAccountsInvoiceMessageUpdate : PublicApi.postSettleAccountsInvoiceMessageAdd
...@@ -61,6 +66,7 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => { ...@@ -61,6 +66,7 @@ const InvoiceModal:React.FC<InvoiceModalProps> = (props) => {
editable={mode !== 'preview'} editable={mode !== 'preview'}
effects={($, { setFieldState }) => { effects={($, { setFieldState }) => {
$('onFormMount').subscribe(() => { $('onFormMount').subscribe(() => {
}) })
}} }}
currentRef={props.currentRef} currentRef={props.currentRef}
......
import React, { useState, useRef, useMemo } from 'react' import React, { useState, useRef } from 'react'
import { ISchemaFieldComponentProps, useFieldState, FormEffectHooks, createFormActions } from '@formily/antd' import { ISchemaFieldComponentProps, useFieldState } from '@formily/antd'
import { Button, Radio } from 'antd' import { Button, Radio } from 'antd'
import { PlusOutlined, CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons' import { PlusOutlined, CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import cx from 'classnames' import cx from 'classnames'
...@@ -37,8 +37,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -37,8 +37,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
}) })
} }
} else if(pageStatus === PageStatus.EDIT){ } else if(pageStatus === PageStatus.EDIT){
// @bug todo 编辑情况下 默认显示有问题 固定第一个
// console.log(value, mode, dataSource, 'EDIT')
if(typeof value === 'object') { if(typeof value === 'object') {
// let target = (mode === 'add' || mode === 'delete') ? dataSource[0] : value // let target = (mode === 'add' || mode === 'delete') ? dataSource[0] : value
let target = value; let target = value;
...@@ -52,7 +50,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -52,7 +50,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
showMore, showMore,
useValue: target useValue: target
}) })
// console.log('isObject', target)
mutators.change(target) mutators.change(target)
} else { } else {
let target = dataSource.length ? dataSource.find(v => v.id === value) : value let target = dataSource.length ? dataSource.find(v => v.id === value) : value
...@@ -61,7 +58,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -61,7 +58,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
showMore, showMore,
useValue: target useValue: target
}) })
// console.log('notObject', target)
mutators.change(target) mutators.change(target)
} }
} }
...@@ -91,7 +87,9 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -91,7 +87,9 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
} }
const reload = () => { const reload = () => {
fetchOrderApi.getInvoicesList().then(data => { const subMemberId = form.getFieldValue('buyerMemberId')
const subRoleId = form.getFieldValue('buyerRoleId')
fetchOrderApi.getInvoicesList({subMemberId, subRoleId}).then(data => {
if(!data.length) { if(!data.length) {
form.setFieldValue("needTheInvoice", 0) form.setFieldValue("needTheInvoice", 0)
} }
...@@ -125,7 +123,9 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -125,7 +123,9 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
const handleDelete = async (id, e) => { // 选中当前的删除 const handleDelete = async (id, e) => { // 选中当前的删除
e.stopPropagation() e.stopPropagation()
try { try {
const result = await PublicApi.postSettleAccountsInvoiceMessageDelete({id}) const subMemberId = form.getFieldValue('buyerMemberId')
const subRoleId = form.getFieldValue('buyerRoleId')
const result = await PublicApi.postSettleAccountsAgentInvoiceMessageDelete({id, subMemberId, subRoleId})
if(result.code === 1000) { if(result.code === 1000) {
reload() reload()
setMode('delete') setMode('delete')
...@@ -145,14 +145,12 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -145,14 +145,12 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
const handleSetDefault = async (item, e) => { const handleSetDefault = async (item, e) => {
e.stopPropagation() e.stopPropagation()
const { data } = await PublicApi.postSettleAccountsInvoiceMessageUpdate({...item, isDefault: item.isDefault ? 0 : 1}) const subMemberId = form.getFieldValue('buyerMemberId')
const subRoleId = form.getFieldValue('buyerRoleId')
const { data } = await PublicApi.postSettleAccountsAgentInvoiceMessageUpdate({...item, subMemberId, subRoleId, isDefault: item.isDefault ? 0 : 1})
reload() reload()
} }
// @tofix bug 添加或删除发票后 useValue Radio默认值是操作的数据 导致无法选中
// console.log(useValue, 'useValue', dataSource, 'dataSource', mode, value, 'value')
return ( return (
<div style={{width: '100%'}} className={styles.invoice}> <div style={{width: '100%'}} className={styles.invoice}>
{ editable && <Button block onClick={handleAdd} icon={<PlusOutlined/>}>新增发票</Button> } { editable && <Button block onClick={handleAdd} icon={<PlusOutlined/>}>新增发票</Button> }
...@@ -199,7 +197,7 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => { ...@@ -199,7 +197,7 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
</div> </div>
} }
<InvoiceModal mode={mode} formInitValue={formInitValue} currentRef={modalRef} reload={reload}/> <InvoiceModal mode={mode} formInitValue={formInitValue} currentRef={modalRef} reload={reload} ctx={form} />
</div> </div>
) )
......
...@@ -145,20 +145,17 @@ export const useOrderDeliverTimeEffect = async (ctx: ISchemaFormActions | ISchem ...@@ -145,20 +145,17 @@ export const useOrderDeliverTimeEffect = async (ctx: ISchemaFormActions | ISchem
// 表单初始化时,对应操作 // 表单初始化时,对应操作
export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => { export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
// FormEffectHooks.onFormMount$().subscribe(async () => {
// // 写入收货地址数据
// useProductAddress(ctx)
// })
FormEffectHooks.onFieldValueChange$('hasInvoice').subscribe(state => { FormEffectHooks.onFieldValueChange$('hasInvoice').subscribe(state => {
if (state.value) { if (state.value) {
useInvoiceList(ctx) useInvoiceList(ctx)
} }
}) })
// 采购会员变动 获取收货地址 // 采购会员变动 获取收货地址 和发票
FormEffectHooks.onFieldValueChange$('buyerMemberMajorId').subscribe(state => { FormEffectHooks.onFieldValueChange$('buyerMemberMajorId').subscribe(state => {
if (state.value) { if (state.value) {
const member = state.values[1] const member = state.values[1]
useProductAddress(ctx, member['memberId'], member['roleId']) useProductAddress(ctx, member['memberId'], member['roleId'])
// useInvoiceList(ctx)
} }
}) })
} }
...@@ -178,16 +175,20 @@ export const useProductAddress = (ctx: ISchemaFormActions | ISchemaFormAsyncActi ...@@ -178,16 +175,20 @@ export const useProductAddress = (ctx: ISchemaFormActions | ISchemaFormAsyncActi
// 获取发票信息 // 获取发票信息
export const useInvoiceList = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => { export const useInvoiceList = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
fetchOrderApi.getInvoicesList().then(data => { const subMemberId = ctx.getFieldValue('buyerMemberId')
ctx.setFieldState('theInvoiceId', state => { const subRoleId = ctx.getFieldValue('buyerRoleId')
if (data.length > 0 && !state.value) { if(subMemberId && subRoleId) {
// 初始化时存在数据, 默认帮用户选中第一个 fetchOrderApi.getInvoicesList({ subMemberId, subRoleId }).then(data => {
state.value = data[0] ctx.setFieldState('theInvoiceId', state => {
} if (data.length > 0 && !state.value) {
state.dataSource = data // 初始化时存在数据, 默认帮用户选中第一个
state.showMore = data.length > 3 state.value = data[0]
}
state.dataSource = data
state.showMore = data.length > 3
})
}) })
}) }
} }
// 高级筛选schema中用于输入搜索商品品类的Effect // 高级筛选schema中用于输入搜索商品品类的Effect
......
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