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

fix: 新增订单询价报价下单部分

parent 55560f3b
......@@ -143,8 +143,8 @@ export const upperCommodityColumns: ColumnType<any>[] = [
title: '商品名称',
dataIndex: 'name',
key: 'name',
// width: 240,
// ellipsis: true,
width: 240,
ellipsis: true,
},
{
title: '商品品类',
......
......@@ -99,7 +99,7 @@ export const GivenBidItem:React.FC<GivenBidItemProps> = ({
defaultValue={currentData[currentColumn.dataIndex]['awardRate']}
min={0}
max={100}
formatter={value => `${value}%`}
formatter={value => `${Math.floor(Number(value) * 100) / 100}%`}
parser={value => value.replace('%', '')}
onChange={onChangeInput}
style={{display: 'none'}}
......
......@@ -37,7 +37,7 @@ export const fetchOrderApi = {
},
/** 获取支付信息列表 */
async getPayInfoList(params) {
const { data } = await PublicApi.getOrderInitializationPaymentInformation(params)
const { data } = await PublicApi.postOrderBuyerCreateB2bPaymentFind(params)
return data
},
......
......@@ -32,7 +32,7 @@ const InquiryModalTable:React.FC<InquiryModalTableProps> = (props) => {
const handleConfirm = async () => {
const item = rowSelectionCtl.selectRow[0]
if (item) {
schemaAction.setFieldValue('quotationNo', item.quotationNo)
schemaAction.setFieldValue('quoteNo', item.quotationNo)
const data = await fetchOrderApi.getProductListByQuotationOrderId({
id: item.inquiryListId
})
......@@ -50,11 +50,11 @@ const InquiryModalTable:React.FC<InquiryModalTableProps> = (props) => {
})
// 把地址信息冗余给商品字段render
schemaAction.setFieldValue('products', await filterProductDataById([], newData))
schemaAction.setFieldValue('supplyMembersName', item.offerMemberName)
schemaAction.setFieldValue('supplyMembersId', item.offerMemberId)
schemaAction.setFieldValue('supplyMembersRoleId', item.offerMemberRoleId)
schemaAction.setFieldValue('vendorMemberName', item.offerMemberName)
schemaAction.setFieldValue('vendorMemberId', item.offerMemberId)
schemaAction.setFieldValue('vendorRoleId', item.offerMemberRoleId)
// 询价单回显订单明细
schemaAction.setFieldValue('orderThe', item.details)
schemaAction.setFieldValue('digest', item.details)
}
confirmModal && confirmModal()
setVisible(false)
......
import React, { useEffect } from 'react'
import ModalTable, { ModalTableProps } from '@/components/ModalTable'
import { fetchOrderApi } from '../../apis'
import { useModalTable } from '../../model/useModalTable'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd'
import { memberColumns } from '../../constant'
export interface MemberModalTableProps extends ModalTableProps {
type?: 'radio' | 'checkbox',
schemaAction: ISchemaFormActions | ISchemaFormAsyncActions,
currentRef?: any,
confirmModal?(),
productRef?: any,
}
const MemberModalTable:React.FC<MemberModalTableProps> = (props) => {
const { type = 'radio', schemaAction, confirmModal, currentRef, ...restProps } = props
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type, customKey: 'id'})
useEffect(() => {
if (currentRef) {
currentRef.current = {
setVisible,
visible,
rowSelectionCtl
}
}
}, [])
const handleConfirm = () => {
const rowItem = rowSelectionCtl.selectRow[0]
if (rowItem) {
schemaAction.setFieldValue('supplyMembersName', rowItem.name)
schemaAction.setFieldValue('supplyMembersId', rowItem.memberId)
schemaAction.setFieldValue('supplyMembersRoleId', rowItem.roleId)
}
confirmModal && confirmModal()
setVisible(false)
// 清空之前可能存在的商品支付信息数据
schemaAction.setFieldValue('orderProductRequests', [])
schemaAction.setFieldValue('paymentInformationResponses', [])
if(props?.productRef) {
props.productRef.current.rowSelectionCtl.setSelectRow([])
props.productRef.current.rowSelectionCtl.setSelectedRowKeys([])
}
}
return (
<ModalTable
modalTitle='选择供应会员'
columns={memberColumns}
visible={visible}
confirm={handleConfirm}
cancel={() => setVisible(false)}
fetchTableData={(params) => fetchOrderApi.getMemberListByModelType({...params, orderType: schemaAction.getFieldValue('orderMode')})}
rowSelection={rowSelection}
modalType='memberByDefault'
tableProps={{
rowKey: 'id'
}}
{...restProps}
/>
)
}
MemberModalTable.defaultProps = {}
export default MemberModalTable
......@@ -21,7 +21,6 @@ const EditableContext = React.createContext<any>({});
export const EditableRow: React.FC<any> = (props) => {
const [form] = Form.useForm();
// form.setFieldsValue()
const { options = [] } = props?.children[5]?.props.additionalProps.formItemProps || {}
const [childOptions, setChildOptions] = useState<any[]>(() => {
const { payType } = props?.children[5]?.props.record || {}
......@@ -66,7 +65,6 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
const formItemRef = useRef<any>();
const { form, childOptions, setChildOptions, originOptions } = useContext(EditableContext);
// fix: 没有childOptions 导致第一次进入编辑页面无法显示支付渠道
let _childOptions = null;
if(history.location.query?.id && title === "支付渠道") {
let payList = originOptions.filter(item => item.payType === record.payType) || []
......@@ -113,14 +111,14 @@ export const PayInfoCell:React.FC<PayInfoCellProps> = ({
const formId = dataIndex + colIndex
switch(type) {
case 'input': {
return <Input className="payRatio" ref={formItemRef} onPressEnter={save} onBlur={save} onChange={handleInputChange} {...formItemProps} id={formId}/>
return <Input className="payRate" ref={formItemRef} onPressEnter={save} onBlur={save} onChange={handleInputChange} {...formItemProps} id={formId}/>
}
case 'select': {
const { options, ...rest } = formItemProps
// 支付方式
if (dataIndex === 'payType') {
return <Select ref={formItemRef}
options={originOptions.map(v => ({label: v.payTypeName, value: v.payType, disabled: v?.disabled}))} // ?? 仅限线下支付下面只有一种方式
options={originOptions.map(v => ({label: v.payTypeName, value: v.payType, disabled: v?.disabled}))}
onChange={e => {
const result = originOptions.find(v => e === v.payType)
setChildOptions(result.payChannels.map(v => ({label: v.payChannelName, value: v.payChannel})))
......
......@@ -23,6 +23,71 @@ export const PriceComp = (props) => {
</div>
}
/** 修改合同下单 初始值转换 */
export const procurmentRenderInit = (initValue: any) => {
return {
...initValue.requirement.detail,
vendorMemberId: initValue.vendorMemberId,
vendorMemberName: initValue.vendorMemberName,
vendorRoleId: initValue.vendorRoleId,
product: initValue.product,
deliveryAddresId: initValue.consignee.consigneeId,
hasInvoice: initValue.hasInvoice,
orderId: initValue.orderId,
orderKind: initValue.orderKind,
orderMode: initValue.orderMode,
orderModeName: initValue.orderModeName,
type: initValue.orderTypeName,
digest: initValue.digest,
deliverDate: initValue.consignee.deliverDate,
theInvoiceId: initValue.invoice?.invoiceId || null,
hasContract: initValue.hasContract,
contractNo: initValue.contract.contractNo,
contract: {...initValue.contract},
}
}
/** 修改采购合同下单 回显商品字段转换 */
export const procurementRenderField = (data) => {
const _orderProductRequests = data.product.products
return _orderProductRequests.map(item => {
return {
...item,
// 此id为sukId
relevanceProductId: item.quotedSkuId,
// relevanceSkuId: item.quotedSkuId,
relevanceProductName: item.quotedName,
relevanceProductBrand: item.quotedBrand,
relevanceProductCategory: item.quotedCategory,
relevanceProductSpec: item.quotedSpec,
logistics: item.deliverType,
id: item.productId,
code: item.productNo,
type: item.spec,
// 冗余memberId memberRoleId查询自提地址使用
memberId: data.vendorMemberId,
memberRoleId: data.vendorRoleId,
}
})
}
/** B2B询价报价下单 字段转换 */
export const procurementProcessField = (value) => {
value.products = value.products.map(item => {
return {
...item,
productId: item.commodityId,
skuId: item.productId,
name: item.productName,
logo: item.imgUrl,
deliveryType: item.deliveryType.deliveryType,
quantity: item.purchaseCount,
}
})
return value
}
/***********控制订单模式联动其他字段的数组集合 *******/
export const orderCombination = {
......@@ -157,8 +222,8 @@ export const inquiryColumns: any[] = [
export const paymentInformationColumns: any[] = [
{
title: '支付次数',
dataIndex: 'payCount',
key: 'payCount'
dataIndex: 'batchNo',
key: 'batchNo'
},
{
title: '支付环节',
......@@ -167,18 +232,19 @@ export const paymentInformationColumns: any[] = [
},
{
title: '外部状态',
dataIndex: 'externalState',
key: 'externalState',
dataIndex: 'outerStatusName',
key: 'outerStatusName',
},
{
title: '支付比例',
dataIndex: 'payRatio',
key: 'payRatio',
dataIndex: 'payRate',
key: 'payRate',
editable: true,
forceEdit: true,
formItem: 'input',
formItemProps: {
addonAfter: '%'
addonAfter: '%',
disabled: true
},
width: 200,
render: text => text + '%'
......
......@@ -68,6 +68,11 @@ export const useEditHideField = () => {
export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFormAsyncActions, update) => {
const { pageStatus } = usePageStatus()
let sumPrice = 0;
FormEffectHooks.onFieldValueChange$('sumPrice').subscribe(state => {
sumPrice = state.value
})
FormEffectHooks.onFieldValueChange$('products').subscribe(state => {
const { value } = state
// 强制渲染一次, 用于触发金额总数
......@@ -79,14 +84,20 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
} else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
const shopId = ctx.getFieldValue('shopId')
const products = value.map(item => ({ productId: item.commodityId, skuId: item.productId }))
if(shopId && products?.length)
fetchOrderApi.getPayInfoList({
productId: productItem.productId,
memberId: productItem?.memberId || ctx.getFieldValue('supplyMembersId'),
memberRoleId: productItem?.memberRoleId || ctx.getFieldValue('supplyMembersRoleId'),
products: products,
memberId: productItem?.memberId,
roleId: productItem?.memberRoleId,
orderMode: orderMode,
shopId: ctx.getFieldValue('shopId')
shopId: shopId
}).then(data => {
ctx.setFieldValue('paymentInformationResponses', data)
ctx.setFieldValue('payments', data.map(item => ({
...item,
payPrice: (sumPrice * Number(item.payRate) / 100).toFixed(2)
})))
}).catch(err => {
})
......@@ -113,7 +124,7 @@ export const useOrderFormInitEffect = (ctx: ISchemaFormActions | ISchemaFormAsyn
useProductAddress(ctx)
})
FormEffectHooks.onFieldValueChange$('needTheInvoice').subscribe(state => {
FormEffectHooks.onFieldValueChange$('hasInvoice').subscribe(state => {
if (state.value) {
useInvoiceList(ctx)
}
......@@ -163,7 +174,7 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: value?.id || null,
needTheInvoice: Number(values.needTheInvoice),
hasInvoice: values.hasInvoice,
deliveryAddresId: values.deliveryAddresId,
id,
}, { ctlType: "none" })
......@@ -188,7 +199,7 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
...values,
deliveryTime: moment(values.deliveryTime).valueOf(),
theInvoiceId: values.theInvoiceId,
needTheInvoice: Number(values.needTheInvoice),
hasInvoice: values.hasInvoice,
deliveryAddresId: value?.id ? value.id : value,
id,
}, { ctlType: "none" })
......@@ -213,8 +224,8 @@ export const useOrderUpdateChangeOther = (ctx: ISchemaFormActions | ISchemaFormA
*/
export const searchCustomerCategoryOptionEffect = (ctx: any, mctx: any, fieldName: string) => {
const params: any = {}
params['memberId'] = ctx.getFieldValue('supplyMembersId')
params['memberRoleId'] = ctx.getFieldValue('supplyMembersRoleId')
params['memberId'] = ctx.getFieldValue('vendorMemberId')
params['memberRoleId'] = ctx.getFieldValue('vendorRoleId')
mctx.getFieldState(fieldName, state => {
PublicApi.getProductCustomerGetMemberCustomerCategoryTree(params).then(res => {
mctx.setFieldState(fieldName, state => {
......
......@@ -22,66 +22,52 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
}
}, [memberId])
useEffect(() => {
if(orderProducts?.length) {
restrictArrivalPay(columns, orderProducts)
const initPayWayList = (memberId, memberRoleId) => {
let result = []
PublicApi.getOrderBuyerCreateB2bPayTypes({vendorMemberId: memberId, vendorRoleId: memberRoleId}).then(res => {
const { data = [], code } = res
for (let item of data) {
result.push({
payTypeName: item.payTypeName,
payType: item.payType,
payChannels: [...item.payChannels]
})
}
})
return result
}
}, [orderProducts])
const getPayLists = (memberId, memberRoleId) => {
// PublicApi.getPayPayWayList({memberId, memberRoleId}).then(res => {
PublicApi.postOrderCreatePaymentFind({
const shopId = ctx.getFieldValue('shopId')
const products = ctx.getFieldValue('products').map(item => ({ productId: item.commodityId, skuId: item.productId }))
if(shopId && products?.lenght)
PublicApi.postOrderBuyerCreateB2bPaymentFind({
memberId,
roleId: memberRoleId,
shopId: ctx.getFieldValue('shopId'),
shopId: shopId,
orderMode: ctx.getFieldValue('orderMode'),
products: ctx.getFieldValue('products').map(item => ({ productId: item.commodityId, skuId: item.productId }))
products: products
}, { ctlType: 'none' }).then(res => {
const { code, data } = res
if (code === 1000) {
const newColumns = [...columns]
newColumns[5].formItemProps.options = data.payTypes
// newColumns[5].formItemProps.options = initPayWayList(data)
newColumns[5].formItemProps.options = initPayWayList(memberId, memberRoleId)
paywayData.current = data
// restrictArrivalPay(newColumns, orderProducts)
setColumns(newColumns)
}
})
}
// 限制使用到付(多次支付和商品仅有物流)
const restrictArrivalPay = (cols, pros) => {
if(pros?.length) {
const newColumns = [...cols]
let options = newColumns[5].formItemProps.options
setTimeout(() => {
let paymentDOM = document.getElementsByClassName("payRatio")
// 多次支付也要禁用到付
if((paymentDOM?.length > 1) || (pros.filter(item => item.deliveryType === 1).length !== pros.length)) {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = true
}
else {
if(options.filter(_item => _item.payType === 4).length)
options.filter(_item => _item.payType === 4)[0].disabled = false
}
}, 800)
setColumns(newColumns)
}
}
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('paymentInformationResponses')];
const newData = [...ctx.getFieldValue('payments')];
const index = newData.findIndex(item => row.payCount === item.payCount);
const item = newData[index];
newData.splice(index, 1, {
...item,
...row,
});
ctx.setFieldValue('paymentInformationResponses', newData)
ctx.setFieldValue('payments', newData)
resolve({item, newData})
})
......
......@@ -155,7 +155,7 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
row['money'] = getUnitPriceTotal(row)
// 通过下单模式判断 是否是手工或者渠道手工下单
let addModel = ctx.getFieldValue("orderMode")
row['productId'] = (pageStatus === PageStatus.ADD) ? row.id : row.productId
row['productId'] = row.productId
newData.splice(index, 1, {
...item,
...row,
......
import { ISchema } from '@formily/antd';
import { FORM_FILTER_PATH } from '@/formSchema/const';
import { GlobalConfig } from '@/global/config';
import moment from 'moment'
......@@ -42,13 +41,13 @@ const basicInfo: ISchema = {
// 联动显示单据字段
{
type: 'value:visible',
"target": "quotationNo",
"target": "quoteNo",
"condition": `{{orderCombination.showQuotationField.includes($value)}}`
},
// 联动显示单据按钮
{
type: "value:schema",
"target": "quotationNo",
"target": "quoteNo",
condition: `{{!!$value && orderCombination.showQuotationSelectBtn.includes($value)}}`,
schema: {
"x-component-props": {
......@@ -73,7 +72,7 @@ const basicInfo: ISchema = {
required: true,
// visible: false,
},
orderThe: {
digest: {
type: 'string',
title: '订单摘要',
"x-rules": [
......@@ -87,7 +86,7 @@ const basicInfo: ISchema = {
}
]
},
quotationNo: {
quoteNo: {
type: 'string',
title: '对应报价单号',
visible: false,
......@@ -108,7 +107,7 @@ const basicInfo: ISchema = {
}
],
},
supplyMembersName: {
vendorMemberName: {
type: 'string',
title: '供应会员',
"x-component-props": {
......@@ -116,11 +115,11 @@ const basicInfo: ISchema = {
},
required: true,
},
supplyMembersId: {
vendorMemberId: {
type: 'string',
display: false
},
supplyMembersRoleId: {
vendorRoleId: {
type: 'string',
display: false
},
......@@ -159,26 +158,16 @@ const basicInfo: ISchema = {
title: '外部状态',
visible: false
},
contractId: {
sumPrice: {
type: 'number',
title: '采购合同ID',
visible: false
},
contractNo: {
type: 'string',
title: '合同下单的合同编号',
visible: false
},
sourceType: {
type: 'number',
title: '合同下单的寻源类型',
visible: false
title: '总价',
visible: false,
},
purchaseType: {
freight: {
type: 'number',
title: '合同下单的是否有限制下单金额',
visible: false
},
title: '运费',
visible: false,
}
}
},
......@@ -218,7 +207,7 @@ export const payInfo: ISchema = {
tab: '支付信息',
},
properties: {
paymentInformationResponses: {
payments: {
type: 'array',
"x-component": 'MultTable',
"x-component-props": {
......@@ -262,7 +251,7 @@ const submitInfo: ISchema = {
type: 'object',
"x-component": 'mega-layout',
properties: {
deliveryTime: {
deliverDate: {
type: 'string',
"x-component": 'date',
title: '交付日期',
......@@ -318,8 +307,8 @@ const ortherInfo: ISchema = {
wrapperCol: 10
},
properties: {
needTheInvoice: {
type: 'number',
hasInvoice: {
type: 'boolean',
"x-component": 'CheckboxSingle',
"x-component-props": {
children: '需要发票',
......@@ -328,7 +317,7 @@ const ortherInfo: ISchema = {
}
},
title: '发票',
default: 0,
default: false,
"x-linkages": [
{
type: 'value:visible',
......
......@@ -300,7 +300,7 @@ export const materialInfoColumns: any[] = [
dataIndex: 'name',
align: 'center',
key: 'name',
render: (t, r) => `${t}/${r.spec}`
render: (t, r) => `${t}/${r.type}`
},
{
title: '品类',
......@@ -325,7 +325,7 @@ export const materialInfoColumns: any[] = [
dataIndex: 'relevanceProductId',
align: 'center',
key: 'relevanceProductId',
render: (t, r) => t ? `${t}/${r.relevanceProductName || ''}/${r.relevanceProductSpec || ''}/${r.relevanceProductCategory || ''}/${r.relevanceProductBrand || ''}` : ''
render: (t, r) => t ? `${t}/${r.relevanceProductName || ''}/${r.relevanceProductType || ''}/${r.relevanceProductCategory || ''}/${r.relevanceProductBrand || ''}` : ''
},
{
title: '单价',
......
......@@ -197,9 +197,10 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
}
// 交付地址数据字段转换拼接 查询省市区冗余
const { data: addressDetail} = await PublicApi.getLogisticsReceiverAddressGet({
const { data: addressDetail, code} = await PublicApi.getLogisticsReceiverAddressGet({
id: params.deliveryAddresId?.id || params.deliveryAddresId
})
if(code === 1000) {
params.consignee = {
deliverDate: params.deliverDate,
consigneeId: addressDetail.id,
......@@ -214,6 +215,9 @@ const PurchaseOrderDetail:React.FC<PurchaseOrderDetailProps> = (props) => {
telephone: addressDetail.tel,
defaultConsignee: addressDetail.isDefault,
}
} else {
throw new Error('交付地址异常')
}
// 其他需求
params.requirement = {
......
......@@ -249,7 +249,13 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
if(data.allProducts === false) {
const res = await getBindingProducts({id: id.toString(), current: '1', pageSize: '1000'})
addSchemaAction.setFieldState('products', state => {
state.value = res.data
state.value = res.data.map(item => ({
...item,
id: item.skuId,
commodityId: item.productId,
customerCategoryName: item.category,
brandName: item.brand,
}))
})
setProductsLength(res.totalCount)
}
......@@ -287,7 +293,13 @@ const RuleSetting:React.FC<RuleSettingProps> = (props) => {
const paginationChange = async (page: number, size: number) => {
if(id !== '') {
const result = await getBindingProducts({id, current: page.toString(), pageSize: size.toString()})
addSchemaAction.setFieldValue('products', result.data)
addSchemaAction.setFieldValue('products', result.data.map(item => ({
...item,
id: item.skuId,
commodityId: item.productId,
customerCategoryName: item.category,
brandName: item.brand,
})))
}
}
......
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