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

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

parent e16b20bb
......@@ -3,7 +3,7 @@ import {StandardTable} from 'god';
import NestTable from '@/components/NestTable';
import { IStandardTableProps } from 'god/dist/src/standard-table';
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 SearchSelect from '../NiceForm/components/SearchSelect';
import Submit from '../NiceForm/components/Submit';
......@@ -18,7 +18,7 @@ export interface ModalTableProps extends IStandardTableProps<any> {
cancel?(),
visible?: boolean,
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, // 是否使用嵌套表格
nestColumns?: any[],
nestTableProps?: any,
......@@ -76,6 +76,9 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
case 'demandNumberSchema': {
return demandNumberSchema
}
case 'addOrderModalSchema': {
return addOrderModalSchema
}
case 'none': {
return {}
}
......@@ -118,6 +121,7 @@ const ModalTable:React.FC<ModalTableProps> = (props) => {
searchName ? searchName : 'name',
FORM_FILTER_PATH,
);
}
}
}
......
......@@ -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 = {
......@@ -285,8 +354,8 @@ export const inquirySchema: ISchema = {
/**
* @description: 新增报价单 需求单查询
* @param {type}
* @return {type}
* @param {type}
* @return {type}
*/
export const enquirySchema: ISchema = {
type: 'object',
......@@ -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';
import { useDebounceFn } from '@umijs/hooks';
import { ISchemaFieldComponentProps, FormPath, useFormEffects, createFormActions, createAsyncFormActions } from '@formily/antd'
import pinyin from 'pinyin'
import { query } from 'express';
const SelectContent = (props) => {
const { handleChange, multiple, confirm, resetField } = props
......@@ -14,7 +15,7 @@ const SelectContent = (props) => {
</div>
{props.children}
{
multiple &&
multiple &&
<Row justify='end' style={{borderTop: '1px solid #eee'}}>
<Button type='link' onClick={resetField}>重置</Button>
<Button type='link' onClick={confirm}>确定</Button>
......@@ -31,7 +32,7 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
const pinyinRef = useRef<any[]>([])
// 可选参数 fetchSearch, select为search
// 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 [loading, setLoading] = useState(false)
const [openSelect, setOpenSelect] = useState(false)
......@@ -67,7 +68,8 @@ const SearchSelect = (props: ISchemaFieldComponentProps) => {
}
setLoading(true)
fetchSearch({
[fetchParams]: ''
[fetchParams]: '',
...queryParams
}).then(({data = []}) => {
const transformData = data.map(v => ({
label: v.name,
......@@ -149,4 +151,4 @@ SearchSelect.defaultProps = {}
SearchSelect.isFieldComponent = true;
export default SearchSelect
\ No newline at end of file
export default SearchSelect
......@@ -168,6 +168,7 @@ const AddUser: React.FC<{}> = () => {
initialValues={formData}
actions={userActions}
editable={pageStatus !== PageStatus.PREVIEW}
previewPlaceholder=" "
effects={($, { setFieldState }) => {
$('onFormInit').subscribe(() => {
if (id) {
......
......@@ -154,7 +154,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
}
}
const electronBtn = <Button style={{marginLeft: 24}} onClick={createElectron} loading={loading}>生成电子合同</Button>
const handleSubmit = async (value) => {
const params = {
......@@ -170,7 +170,7 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
const handleConfirm = () => {
schemaActions.submit()
}
return (
<ModalForm
modalTitle='确认提交审核'
......@@ -186,12 +186,23 @@ const CreateOrderElectronModal:React.FC<OrderElectronModalProps> = (props) => {
expressionScope={{
electronBtn
}}
effects={($, actions) => {
effects={async ($, actions) => {
// $('onFormInit').subscribe(() => {
if (data.isElectronicContract === 1) {
useAsyncSelect('contractTemplateId', async () => (await PublicApi.getOrderSelectListContractTemplate()).data, ['name', 'id']).then(()=>{
actions.setFieldValue("contractTemplateId", data.contractTemplateId)
// useAsyncSelect('contractTemplateId', async () => (await PublicApi.getOrderSelectListContractTemplate()).data, ['name', 'id']).then(()=>{
// 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 {
actions.setFieldState('usingElectronicContracts', state => {
state.value = 0
......@@ -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) => {
CreateOrderElectronModal.defaultProps = {}
export default CreateOrderElectronModal
\ No newline at end of file
export default CreateOrderElectronModal
......@@ -25,7 +25,6 @@ const OrderSaleRecord:React.FC<OrderSaleRecordProps> = (props) => {
const isDeleved = pathname.indexOf('readyConfirmDelevedOrder') !== -1
// 是否是确认回单页
const isReturn = pathname.indexOf('readyConfirmReturnOrder') !== -1
console.log(isPreview, isDeleved, isReturn)
// 用于储存已经修改过的订单id
const dataRef = useRef<any>([])
......
......@@ -8,6 +8,14 @@ import { DELIVERY_TYPE, OrderModalType } from '@/constants'
import { PublicApi } from '@/services/api'
import { EnvironmentOutlined } from '@ant-design/icons'
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 {
type?: 'radio' | 'checkbox',
......@@ -169,6 +177,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
return fetchOrderApi.getProductList(params)
}
return (
<ModalTable
modalTitle='选择订单商品'
......@@ -180,7 +189,7 @@ const ProductModalTable:React.FC<ProductModalTableProps> = (props) => {
fetchTableData={fetchProductList}
rowSelection={rowSelection}
resetModal={{destroyOnClose: true, forceRender: true}}
modalType='productByDefault'
modalType='none'
tableProps={{
rowKey: 'id',
onRow: (record) => ({
......@@ -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}
/>
)
......
......@@ -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 => {
const { value } = state
const payInfoData = ctx.getFieldValue('paymentInformationResponses')
......@@ -99,17 +101,20 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if (value && value.length > 0){
// 请求一次并复制给支付信息
const productItem = value[0]
console.log(productItem,'productItem')
fetchOrderApi.getPayInfoList({
// productId: productItem.id,
productId: productItem?.commodityId ? productItem.id : productItem.productId,
memberId: productItem.memberId,
memberRoleId: productItem.memberRoleId,
orderModel: ctx.getFieldValue('orderModel'),
}).then(data => {
ctx.setFieldValue('paymentInformationResponses', data)
}).catch(err => {
})
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
} else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
fetchOrderApi.getPayInfoList({
productId: productItem?.commodityId ? productItem.id : productItem.productId,
memberId: productItem.memberId,
memberRoleId: productItem.memberRoleId,
orderModel: ctx.getFieldValue('orderModel'),
}).then(data => {
ctx.setFieldValue('paymentInformationResponses', data)
}).catch(err => {
})
}
}
// 确认后 需根据商品id请求会员折扣接口, 以及配送方式
......
......@@ -4,7 +4,7 @@ import { PageHeaderWrapper } from '@ant-design/pro-layout'
import ReutrnEle from '@/components/ReturnEle'
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus'
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 NiceForm from '@/components/NiceForm'
import { orderDetailSchema, orderAddSchema, mergeAllSchemas } from './schema'
......@@ -204,6 +204,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// theInvoiceInfo: (value.typeof value.theInvoiceId === 'object' ? value.theInvoiceId : null
// theInvoiceInfo: value.theInvoiceInfo
}
console.log(params, 'params')
// 校验是否选择支付渠道
let judgementByPay = params.paymentInformationResponses.map(item => {
if(item.channel && item.payWay){
......@@ -370,6 +371,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
// }
})
}
console.log(initFormValue, 'init')
})
// 监听商品总价的变更, 此处逻辑需优化
$('sumPrice').subscribe(payload => {
......@@ -442,7 +444,7 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
})
useEditHideField()
// 商品信息的改动 驱动支付信息变化
useProductTableChangeForPay(ctx, update)
useProductTableChangeForPay(ctx, update, initFormValue)
}}
expressionScope={{
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