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

fix:处理新增/编辑采购订单支付方式渠道提交异常,处理新增/编辑采购订单商品区块高级筛选品类品牌异常

parent e16b20bb
...@@ -3,7 +3,7 @@ import {StandardTable} from 'god'; ...@@ -3,7 +3,7 @@ import {StandardTable} from 'god';
import NestTable from '@/components/NestTable'; import NestTable from '@/components/NestTable';
import { IStandardTableProps } from 'god/dist/src/standard-table'; import { IStandardTableProps } from 'god/dist/src/standard-table';
import { Row, Col, Modal } from 'antd'; import { Row, Col, Modal } from 'antd';
import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema } from './schema'; import { productModalSchema, productModalByMemberSchema, memberModalSchema, inquirySchema, demandSchema, enquirySchema, mergeOrderSchema, goodsModalSchema, demandNumberSchema, addOrderModalSchema } from './schema';
import Search from '../NiceForm/components/Search'; import Search from '../NiceForm/components/Search';
import SearchSelect from '../NiceForm/components/SearchSelect'; import SearchSelect from '../NiceForm/components/SearchSelect';
import Submit from '../NiceForm/components/Submit'; import Submit from '../NiceForm/components/Submit';
...@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> { ...@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> {
cancel?(), cancel?(),
visible?: boolean, visible?: boolean,
resetModal?: object, resetModal?: object,
modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'none' , modalType?: 'productByDefault' | 'productByMember' | 'memberByDefault' | 'inquiryByDefault' | 'demandByDefault' | 'enquiryModel' | 'MergeOrderByDefault' | 'goodsModalSchema' | 'demandNumberSchema' | 'addOrderModalSchema' | 'none' ,
useNestTable?: boolean, // 是否使用嵌套表格 useNestTable?: boolean, // 是否使用嵌套表格
nestColumns?: any[], nestColumns?: any[],
nestTableProps?: any, nestTableProps?: any,
...@@ -76,6 +76,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => { ...@@ -76,6 +76,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
case 'demandNumberSchema': { case 'demandNumberSchema': {
return demandNumberSchema return demandNumberSchema
} }
case 'addOrderModalSchema': {
return addOrderModalSchema
}
case 'none': { case 'none': {
return {} return {}
} }
...@@ -118,6 +121,7 @@ const ModalTable:React.FC<ModalTableProps> = (props) => { ...@@ -118,6 +121,7 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
searchName ? searchName : 'name', searchName ? searchName : 'name',
FORM_FILTER_PATH, FORM_FILTER_PATH,
); );
} }
} }
} }
......
...@@ -129,6 +129,75 @@ export const productModalSchema: ISchema = { ...@@ -129,6 +129,75 @@ export const productModalSchema: ISchema = {
} }
/** /**
* 新增采购订单选择商品的高级筛选
* 获取供应商的品类和品牌
*/
export const addOrderModalSchema: ISchema = {
type: 'object',
properties: {
name: {
type: 'string',
'x-component': 'ModalSearch',
'x-component-props': {
placeholder: '请输入商品名称',
align: 'flex-left',
},
},
[FORM_FILTER_PATH]: {
type: 'object',
'x-component': 'flex-layout',
'x-component-props': {
rowStyle: {
flexWrap: 'nowrap',
style: {
marginRight: 0
}
},
colStyle: {
marginTop: 20,
},
},
properties: {
customerCategoryId: {
type: 'string',
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: '请选择品类',
className: 'fixed-ant-selected-down',
fetchSearch: PublicApi.getProductSelectGetMemberCategory,
style: {
width: 160
},
queryParams: {},
}
},
brandId: {
type: 'string',
"x-component": 'SearchSelect',
"x-component-props": {
placeholder: '请选择品牌',
fetchSearch: PublicApi.getProductSelectGetMemberBrand,
style: {
width: 160
},
queryParams: {},
}
},
submit: {
"x-component": 'Submit',
"x-mega-props": {
span: 1
},
"x-component-props": {
children: '查询'
}
}
}
}
}
}
/**
* 货品列表筛选 * 货品列表筛选
*/ */
export const goodsModalSchema: ISchema = { export const goodsModalSchema: ISchema = {
...@@ -285,8 +354,8 @@ export const inquirySchema: ISchema = { ...@@ -285,8 +354,8 @@ export const inquirySchema: ISchema = {
/** /**
* @description: 新增报价单 需求单查询 * @description: 新增报价单 需求单查询
* @param {type} * @param {type}
* @return {type} * @return {type}
*/ */
export const enquirySchema: ISchema = { export const enquirySchema: ISchema = {
type: 'object', type: 'object',
...@@ -526,4 +595,4 @@ export const demandNumberSchema: ISchema = { ...@@ -526,4 +595,4 @@ export const demandNumberSchema: ISchema = {
} }
} }
} }
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ import { Select, Input, Row, Button } from 'antd'; ...@@ -3,6 +3,7 @@ import { Select, Input, Row, Button } from 'antd';
import { useDebounceFn } from '@umijs/hooks'; import { useDebounceFn } from '@umijs/hooks';
import { ISchemaFieldComponentProps, FormPath, useFormEffects, createFormActions, createAsyncFormActions } from '@formily/antd' import { ISchemaFieldComponentProps, FormPath, useFormEffects, createFormActions, createAsyncFormActions } from '@formily/antd'
import pinyin from 'pinyin' import pinyin from 'pinyin'
import { query } from 'express';
const SelectContent = (props) => { const SelectContent = (props) => {
const { handleChange, multiple, confirm, resetField } = props const { handleChange, multiple, confirm, resetField } = props
...@@ -14,7 +15,7 @@ const SelectContent = (props) => { ...@@ -14,7 +15,7 @@ const SelectContent = (props) => {
</div> </div>
{props.children} {props.children}
{ {
multiple && multiple &&
<Row justify='end' style={{borderTop: '1px solid #eee'}}> <Row justify='end' style={{borderTop: '1px solid #eee'}}>
<Button type='link' onClick={resetField}>重置</Button> <Button type='link' onClick={resetField}>重置</Button>
<Button type='link' onClick={confirm}>确定</Button> <Button type='link' onClick={confirm}>确定</Button>
...@@ -31,7 +32,7 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => { ...@@ -31,7 +32,7 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
const pinyinRef = useRef<any[]>([]) const pinyinRef = useRef<any[]>([])
// 可选参数 fetchSearch, select为search // 可选参数 fetchSearch, select为search
// multiple 是否开启多选 // multiple 是否开启多选
const { fetchSearch, fetchParams = 'name', fetchFormat, multiple = false, ...resetProps } = schema.getExtendsComponentProps() const { fetchSearch, fetchParams = 'name', fetchFormat, multiple = false, queryParams = {}, ...resetProps } = schema.getExtendsComponentProps()
const [dataSource, setDataSource] = useState<any[]>([]) const [dataSource, setDataSource] = useState<any[]>([])
const [loading, setLoading] = useState(false) const [loading, setLoading] = useState(false)
const [openSelect, setOpenSelect] = useState(false) const [openSelect, setOpenSelect] = useState(false)
...@@ -67,7 +68,8 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => { ...@@ -67,7 +68,8 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
} }
setLoading(true) setLoading(true)
fetchSearch({ fetchSearch({
[fetchParams]: '' [fetchParams]: '',
...queryParams
}).then(({data = []}) => { }).then(({data = []}) => {
const transformData = data.map(v => ({ const transformData = data.map(v => ({
label: v.name, label: v.name,
...@@ -149,4 +151,4 @@ SearchSelect.defaultProps = {} ...@@ -149,4 +151,4 @@ SearchSelect.defaultProps = {}
SearchSelect.isFieldComponent = true; SearchSelect.isFieldComponent = true;
export default SearchSelect export default SearchSelect
\ No newline at end of file
...@@ -168,6 +168,7 @@ const AddUser: React.FC<{}> = () => { ...@@ -168,6 +168,7 @@ const AddUser: React.FC<{}> = () => {
initialValues={formData} initialValues={formData}
actions={userActions} actions={userActions}
editable={pageStatus !== PageStatus.PREVIEW} editable={pageStatus !== PageStatus.PREVIEW}
previewPlaceholder=" "
effects={($, { setFieldState }) => { effects={($, { setFieldState }) => {
$('onFormInit').subscribe(() => { $('onFormInit').subscribe(() => {
if (id) { if (id) {
......
...@@ -154,7 +154,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => { ...@@ -154,7 +154,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
} }
} }
const electronBtn = <Button style={{marginLeft: 24}} onClick={createElectron} loading={loading}>生成电子合同</Button> const electronBtn = <Button style={{marginLeft: 24}} onClick={createElectron} loading={loading}>生成电子合同</Button>
const handleSubmit = async (value) => { const handleSubmit = async (value) => {
const params = { const params = {
...@@ -170,7 +170,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => { ...@@ -170,7 +170,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
const handleConfirm = () => { const handleConfirm = () => {
schemaActions.submit() schemaActions.submit()
} }
return ( return (
<ModalForm <ModalForm
modalTitle='确认提交审核' modalTitle='确认提交审核'
...@@ -186,12 +186,23 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => { ...@@ -186,12 +186,23 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
expressionScope={{ expressionScope={{
electronBtn electronBtn
}} }}
effects={($, actions) => { effects={async ($, actions) => {
// $('onFormInit').subscribe(() => { // $('onFormInit').subscribe(() => {
if (data.isElectronicContract === 1) { if (data.isElectronicContract === 1) {
useAsyncSelect('contractTemplateId', async () => (await PublicApi.getOrderSelectListContractTemplate()).data, ['name', 'id']).then(()=>{ // useAsyncSelect('contractTemplateId', async () => (await PublicApi.getOrderSelectListContractTemplate()).data, ['name', 'id']).then(()=>{
actions.setFieldValue("contractTemplateId", data.contractTemplateId) // actions.setFieldValue("contractTemplateId", data.contractTemplateId)
// })
const { data } = await PublicApi.getOrderSelectListContractTemplate()
let options = data.map(item => ({
label: item.name,
value: item.id,
}))
actions.setFieldState('contractTemplateId', state => {
state.props.enum = options
}) })
if(options?.length && options.filter(_i => _i.value === data.contractTemplateId).length) {
actions.setFieldValue("contractTemplateId", data.contractTemplateId)
}
} else { } else {
actions.setFieldState('usingElectronicContracts', state => { actions.setFieldState('usingElectronicContracts', state => {
state.value = 0 state.value = 0
...@@ -200,6 +211,9 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => { ...@@ -200,6 +211,9 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
} }
}) })
} }
$('onFieldValueChange', 'contractTemplateId').subscribe(state => {
console.log(state.props)
})
// }) // })
}} }}
/> />
...@@ -208,4 +222,4 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => { ...@@ -208,4 +222,4 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
CreateOrderElectronModal.defaultProps = {} CreateOrderElectronModal.defaultProps = {}
export default CreateOrderElectronModal export default CreateOrderElectronModal
\ No newline at end of file
...@@ -25,7 +25,6 @@ const OrderSaleRecord:React.FC<OrderSaleRecordProps> = (props) => { ...@@ -25,7 +25,6 @@ const OrderSaleRecord:React.FC<OrderSaleRecordProps> = (props) => {
const isDeleved = pathname.indexOf('readyConfirmDelevedOrder') !== -1 const isDeleved = pathname.indexOf('readyConfirmDelevedOrder') !== -1
// 是否是确认回单页 // 是否是确认回单页
const isReturn = pathname.indexOf('readyConfirmReturnOrder') !== -1 const isReturn = pathname.indexOf('readyConfirmReturnOrder') !== -1
console.log(isPreview, isDeleved, isReturn)
// 用于储存已经修改过的订单id // 用于储存已经修改过的订单id
const dataRef = useRef<any>([]) const dataRef = useRef<any>([])
......
...@@ -8,6 +8,14 @@ import { DELIVERY_TYPE, OrderModalType } from '@/constants' ...@@ -8,6 +8,14 @@ import { DELIVERY_TYPE, OrderModalType } from '@/constants'
import { PublicApi } from '@/services/api' import { PublicApi } from '@/services/api'
import { EnvironmentOutlined } from '@ant-design/icons' import { EnvironmentOutlined } from '@ant-design/icons'
import { Popover, Space, Row, message } from 'antd' import { Popover, Space, Row, message } from 'antd'
import { useStateFilterSearchLinkageEffect } from '@/formSchema/effects/useFilterSearch'
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { addOrderModalSchema } from '@/components/ModalTable/schema'
import Search from '@/components/NiceForm/components/Search'
import SearchSelect from '@/components/NiceForm/components/SearchSelect';
import Submit from '@/components/NiceForm/components/Submit';
import DateSelect from '@/components/NiceForm/components/DateSelect';
import { action } from 'mobx'
export interface ProductModalTableProps extends ModalTableProps { export interface ProductModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox', type?: 'radio' | 'checkbox',
...@@ -169,6 +177,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -169,6 +177,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
return fetchOrderApi.getProductList(params) return fetchOrderApi.getProductList(params)
} }
return ( return (
<ModalTable <ModalTable
modalTitle='选择订单商品' modalTitle='选择订单商品'
...@@ -180,7 +189,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -180,7 +189,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
fetchTableData={fetchProductList} fetchTableData={fetchProductList}
rowSelection={rowSelection} rowSelection={rowSelection}
resetModal={{destroyOnClose: true, forceRender: true}} resetModal={{destroyOnClose: true, forceRender: true}}
modalType='productByDefault' modalType='none'
tableProps={{ tableProps={{
rowKey: 'id', rowKey: 'id',
onRow: (record) => ({ onRow: (record) => ({
...@@ -190,6 +199,32 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => { ...@@ -190,6 +199,32 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
}, },
}) })
}} }}
formilyProps={{
ctx: {
schema: addOrderModalSchema,
components: { ModalSearch: Search, SearchSelect, Submit, DateSelect },
effects: ($, actions) => {
useStateFilterSearchLinkageEffect(
$,
actions,
'name',
FORM_FILTER_PATH,
);
actions.setFieldState('customerCategoryId', state => {
state.props['x-component-props'].queryParams = {
memberId: schemaAction.getFieldValue('supplyMembersId'),
memberRoleId: schemaAction.getFieldValue('supplyMembersRoleId')
}
})
actions.setFieldState('brandId', state => {
state.props['x-component-props'].queryParams = {
memberId: schemaAction.getFieldValue('supplyMembersId'),
memberRoleId: schemaAction.getFieldValue('supplyMembersRoleId')
}
})
}
}
}}
{...restProps} {...restProps}
/> />
) )
......
...@@ -86,7 +86,9 @@ export const useEditHideField = () => { ...@@ -86,7 +86,9 @@ export const useEditHideField = () => {
}) })
} }
export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => { export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update, editData) => {
const { pageStatus } = usePageStatus()
FormEffectHooks.onFieldValueChange$('orderProductRequests').subscribe(state => { FormEffectHooks.onFieldValueChange$('orderProductRequests').subscribe(state => {
const { value } = state const { value } = state
const payInfoData = ctx.getFieldValue('paymentInformationResponses') const payInfoData = ctx.getFieldValue('paymentInformationResponses')
...@@ -99,17 +101,20 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor ...@@ -99,17 +101,20 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if (value && value.length > 0){ if (value && value.length > 0){
// 请求一次并复制给支付信息 // 请求一次并复制给支付信息
const productItem = value[0] const productItem = value[0]
console.log(productItem,'productItem') if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
fetchOrderApi.getPayInfoList({
// productId: productItem.id, } else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
productId: productItem?.commodityId ? productItem.id : productItem.productId, fetchOrderApi.getPayInfoList({
memberId: productItem.memberId, productId: productItem?.commodityId ? productItem.id : productItem.productId,
memberRoleId: productItem.memberRoleId, memberId: productItem.memberId,
orderModel: ctx.getFieldValue('orderModel'), memberRoleId: productItem.memberRoleId,
}).then(data => { orderModel: ctx.getFieldValue('orderModel'),
ctx.setFieldValue('paymentInformationResponses', data) }).then(data => {
}).catch(err => { ctx.setFieldValue('paymentInformationResponses', data)
}) }).catch(err => {
})
}
} }
// 确认后 需根据商品id请求会员折扣接口, 以及配送方式 // 确认后 需根据商品id请求会员折扣接口, 以及配送方式
......
...@@ -4,7 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout' ...@@ -4,7 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ReutrnEle from '@/components/ReturnEle' import ReutrnEle from '@/components/ReturnEle'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus' import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
import { Button, Card, Row, Col, Drawer, message } from 'antd' import { Button, Card, Row, Col, Drawer, message } from 'antd'
import { createFormActions, registerVirtualBox, useFormSpy } from '@formily/antd' import { createFormActions, registerVirtualBox, useFormSpy, createAsyncFormActions } 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 { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema' import { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema'
...@@ -204,6 +204,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -204,6 +204,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// theInvoiceInfo: (value.typeof value.theInvoiceId === 'object' ? value.theInvoiceId : null // theInvoiceInfo: (value.typeof value.theInvoiceId === 'object' ? value.theInvoiceId : null
// theInvoiceInfo: value.theInvoiceInfo // theInvoiceInfo: value.theInvoiceInfo
} }
console.log(params, 'params')
// 校验是否选择支付渠道 // 校验是否选择支付渠道
let judgementByPay = params.paymentInformationResponses.map(item => { let judgementByPay = params.paymentInformationResponses.map(item => {
if(item.channel && item.payWay){ if(item.channel && item.payWay){
...@@ -370,6 +371,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -370,6 +371,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// } // }
}) })
} }
console.log(initFormValue, 'init')
}) })
// 监听商品总价的变更, 此处逻辑需优化 // 监听商品总价的变更, 此处逻辑需优化
$('sumPrice').subscribe(payload => { $('sumPrice').subscribe(payload => {
...@@ -442,7 +444,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => { ...@@ -442,7 +444,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}) })
useEditHideField() useEditHideField()
// 商品信息的改动 驱动支付信息变化 // 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update) useProductTableChangeForPay(ctx, update, initFormValue)
}} }}
expressionScope={{ expressionScope={{
orderNoPrice, orderNoPrice,
......
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