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

fix: 对接现货采购下单新增修改

parent 111dc7e4
......@@ -376,6 +376,7 @@ const Products: React.FC<{}> = () => {
const { data } = await PublicApi.getTemplateWebMemberShopWebFindCurrMemberShop({ memberId: getAuth().memberId, memberRoleId: getAuth().memberRoleId })
if(data?.id) {
setShopId(data)
console.log(data, 'data')
setCheckedValues(values)
} else {
message.error('您还还未创建店铺,请先创建店铺!')
......@@ -411,7 +412,7 @@ const Products: React.FC<{}> = () => {
if(checkedValues.length > 0){
const fn = isBatch ? PublicApi.postProductCommodityPublishCommodityBatch : PublicApi.postProductCommodityPublishCommodity
// @ts-ignore
fn(isBatch ? {storeId: shopId['id'], storeName: shopId['name'], shopList: checkedValues, idList: currentRef.current} : {storeId: shopId?.id || null, storeName: shopId?.name|| null, ...params}).then(() => {
fn(isBatch ? {storeId: shopId['id'], storeName: shopId['name'], storeLogo: shopId['logo'], shopList: checkedValues, idList: currentRef.current} : {storeId: shopId?.id || null, storeName: shopId?.name|| null, storeLogo: shopId?.logo || null, ...params}).then(() => {
setUpDownModal(false)
ref.current.reload()
setIsDisabledOKbtn(false)
......
......@@ -2,15 +2,14 @@ import React, { useContext, useState } from 'react'
import { Row, Col, Tag, Modal } from 'antd'
import MellowCard from '@/components/MellowCard'
import { OrderDetailContext } from '../../_public/order/context'
import { formatTimeString } from '@/utils'
import { DELIVERY_TYPE, OrderKindType } from '@/constants/order'
import { OrderKindType } from '@/constants/order'
import style from './index.less'
import ContractList from '../contractList'
import cx from 'classnames'
export interface OrderMergeInfoProps { }
const payInfo = [
{ title: '交付日期:', name: 'deliverDate', render: (text) => formatTimeString(text, 'YYYY-MM-DD') },
{ title: '交付日期:', name: 'deliverDate' },
{
title: '交付地址:', name: 'areaName', render: (_, record) =>
<div>
......
......@@ -37,7 +37,7 @@ export const fetchOrderApi = {
},
/** 获取支付信息列表 */
async getPayInfoList(params) {
const { data } = await PublicApi.postOrderVendorCreateAgentPaymentFind(params, { ctlType: 'none' })
const { data } = await PublicApi.postOrderBuyerCreateB2bPaymentFind(params, { ctlType: 'none' })
return data
},
......@@ -55,7 +55,7 @@ export const fetchOrderApi = {
/** 根据商城类型 获取下单模式和类型 */
async getOrderModeOrderType(params) {
const { data } = await PublicApi.getOrderVendorGetOrderMode(params)
const { data } = await PublicApi.getOrderBuyerCreatePurchaseTypes(params)
return data
}
......
import React, { useRef, useEffect, useMemo } from 'react'
import React, { useRef, useMemo } from 'react'
import ModalForm from '@/components/ModalForm'
import { createFormActions, useValueLinkageEffect, ISchemaFormActions } from '@formily/antd'
import { createFormActions } from '@formily/antd'
import addressSchema from './schema'
import './index.less'
import { useAsyncSelect } from '@/formSchema/effects/useAsyncSelect'
......
import React, { useState, useRef, useContext, useEffect } from 'react'
import { Form, Input, Select } from 'antd';
import { has } from 'lodash';
import React, { useRef, useContext } from 'react'
import { Form, Input } from 'antd';
export interface ProductTableCellProps {
title: React.ReactNode;
editable: boolean;
......@@ -32,7 +30,6 @@ export const ProductEditableRow: React.FC<any> = ({...props }) => {
};
export const ProductTableCell:React.FC<ProductTableCellProps> = ({
title,
editable,
......@@ -47,6 +44,7 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
}) => {
const formItemRef = useRef<any>();
const { form } = useContext(EditableContext);
const save = async e => {
try {
const values = await form.validateFields();
......@@ -61,15 +59,6 @@ export const ProductTableCell:React.FC<ProductTableCellProps> = ({
switch(type) {
case 'input': {
// 用于判断是否是合并下单
let hasSelectMergeBtn = document.getElementsByClassName("selectMerge")
// 用于合并订单采购数量回显
if(hasSelectMergeBtn.length) {
let keyValue = {}
keyValue[dataIndex] = v
form.setFieldsValue(keyValue)
}
return <Input
style={{width: 140}}
type='number'
......
import React, { useState, useRef, useMemo } from 'react'
import { ISchemaFieldComponentProps, useFieldState, FormEffectHooks, createFormActions } from '@formily/antd'
import React, { useState, useRef } from 'react'
import { ISchemaFieldComponentProps, useFieldState } from '@formily/antd'
import { Button, Radio } from 'antd'
import { PlusOutlined, CaretUpOutlined, CaretDownOutlined } from '@ant-design/icons'
import cx from 'classnames'
......@@ -37,7 +37,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
})
}
} else if(pageStatus === PageStatus.EDIT){
// @bug todo 编辑情况下 默认显示有问题 固定第一个
// console.log(value, mode, dataSource, 'EDIT')
if(typeof value === 'object') {
// let target = (mode === 'add' || mode === 'delete') ? dataSource[0] : value
......@@ -52,7 +51,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
showMore,
useValue: target
})
// console.log('isObject', target)
mutators.change(target)
} else {
let target = dataSource.length ? dataSource.find(v => v.id === value) : value
......@@ -61,7 +59,6 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
showMore,
useValue: target
})
// console.log('notObject', target)
mutators.change(target)
}
}
......@@ -149,10 +146,8 @@ const TheInvoiceList = (props: ISchemaFieldComponentProps) => {
reload()
}
// @tofix bug 添加或删除发票后 useValue Radio默认值是操作的数据 导致无法选中
// console.log(useValue, 'useValue', dataSource, 'dataSource', mode, value, 'value')
return (
<div style={{width: '100%'}} className={styles.invoice}>
{ editable && <Button block onClick={handleAdd} icon={<PlusOutlined/>}>新增发票</Button> }
......
import React from 'react'
import { formatTimeString } from '@/utils'
import { Row } from 'antd'
import { DELIVERY_TYPE, OrderModalType } from '@/constants/order'
import { OrderModalType } from '@/constants/order'
import { AddressPop } from '@/pages/transaction/components/addressPop'
// 简单控制价格区间的组件
......@@ -23,10 +23,10 @@ export const PriceComp = (props) => {
</div>
}
/** 修改b2b询价报价下单 初始值转换 */
/** 修改现货采购下单 初始值转换 */
export const procurmentRenderInit = (initValue: any) => {
return {
let fields = {
...initValue.requirement.detail,
vendorMemberId: initValue.vendorMemberId,
vendorMemberName: initValue.vendorMemberName,
......@@ -47,15 +47,24 @@ export const procurmentRenderInit = (initValue: any) => {
shopId: initValue.shopId,
payments: initValue.payments,
}
if(initValue.consignee.deliverDate.length > 20) { // 有配置时间段
const timeArray = initValue.consignee.deliverDate.split(' ')
fields.deliverDate = timeArray[0]
fields.timeLine = timeArray[1]
}
return { ...fields}
}
/** 修改b2b询价报价下单 回显商品字段转换 */
/** 修改现货采购下单 回显商品字段转换 */
export const procurementRenderField = (data) => {
const _orderProductRequests = data.product.products
return _orderProductRequests.map(item => {
return {
...item,
commodityId: item.productId,
id: item.skuId,
productId: item.skuId,
productName: item.name,
logistics: item.deliverType,
......@@ -82,7 +91,7 @@ export const procurementRenderField = (data) => {
})
}
/** 代客下单提交 字段转换 */
/** 现货采购下单提交 字段转换 */
export const procurementProcessField = (value) => {
value.products = value.products.map(item => {
return {
......@@ -94,6 +103,9 @@ export const procurementProcessField = (value) => {
logisticsTemplateId: item.logistics.templateId,
weight: item.logistics.weight,
stock: item.stockCount,
discount: item.memberPrice,
price: item.money / item.purchaseCount / item.memberPrice,
tax: item.taxRate > 0,
vendorMemberId: item.memberId,
vendorRoleId: item.memberRoleId,
vendorMemberName: item.memberName,
......
......@@ -66,8 +66,10 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
const { value } = state
// 强制渲染一次, 用于触发金额总数
update()
const orderMode = ctx.getFieldValue('orderMode')
if (value && value.length > 0 && !state.loading){ // 添加loading判断避免二次调用
// 请求一次并复制给支付信息
const productItem = value[0]
if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
ctx.setFieldValue('payments', []) // 变动后先 清空支付信息
const shopId = ctx.getFieldValue('shopId')
......@@ -81,6 +83,9 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
}
fetchOrderApi.getPayInfoList({
products: products,
memberId: productItem?.memberId,
roleId: productItem?.memberRoleId,
orderMode: orderMode,
shopId: shopId
}).then(data => {
ctx.setFieldValue('payments', data.map(item => ({
......
......@@ -149,9 +149,13 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
const { data } = res
const _orderProductRequests = procurementRenderField(data)
setProducts(_orderProductRequests)
setInitFormValue(() => procurmentRenderInit(data))
const renderFiels = procurmentRenderInit(data)
setInitFormValue({...renderFiels})
setTimeout(() => {
addSchemaAction.setFieldValue('products', _orderProductRequests)
if(renderFiels?.timeLine) {
addSchemaAction.setFieldValue('timeLine', renderFiels.timeLine)
}
}, 1000)
setFormLoading(false)
})
......@@ -254,7 +258,7 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
id: params.deliveryAddresId?.id || params.deliveryAddresId
})
params.consignee = {
deliverDate: params.deliverDate,
// deliverDate: params.deliverDate,
consigneeId: addressDetail.id,
consignee: addressDetail.receiverName,
provinceCode: addressDetail.provinceCode,
......@@ -267,9 +271,11 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
telephone: addressDetail.tel,
defaultConsignee: !!addressDetail.isDefault,
}
// 组合配送时间字段
if(params?.timeLine) {
params.consignee.startTime = params.timeLine.split('-')[0]
params.consignee.endTime = params.timeLine.split('-')[1]
params.deliverDate = `${params.deliverDate} ${params.timeLine}`
} else {
params.deliverDate = params.deliverDate
}
}
......@@ -290,13 +296,13 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
params.shopName = shop['label']
if(id) {
// fnResult = await PublicApi.postOrderBuyerCreateB2bUpdate({..._params, orderId: id})
fnResult = await PublicApi.postOrderBuyerCreateUpdate({..._params, orderId: id})
} else {
fnResult = await PublicApi.postOrderVendorCreateAgentOrder(_params)
fnResult = await PublicApi.postOrderBuyerCreatePurchase(_params)
}
if (fnResult.code === 1000) {
setTimeout(() => {
history.push("/memberCenter/tranactionAbility/saleOrder/orderList")
history.push("/memberCenter/tranactionAbility/purchaseOrder/readyAddCashOrder")
}, 1000)
} else {
setBtnLoading(false)
......@@ -313,7 +319,7 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
memberRef.current.setVisible(true)
}
const orderMember = pageStatus !== PageStatus.PREVIEW && <div className='connectBtn' onClick={handleOrderMember}><LinkOutlined style={{marginRight: 4}}/>选择</div>
const orderMember = pageStatus === PageStatus.ADD ? <div className='connectBtn' onClick={handleOrderMember}><LinkOutlined style={{marginRight: 4}}/>选择</div> : null
// @todo 未实现金额合计
const couponAddButton = <Button onClick={() => productRef.current.setVisible(true)} block type='default' style={{margin: '24px auto'}}>选择优惠券</Button>
......@@ -382,16 +388,11 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
}}
effects={($, ctx) => {
$('onFormMount').subscribe(() => {
// if (id || modelType) {
// ctx.setFieldState('orderMode', state => {
// state.editable = false
// })
// }
// if (id) {
// ctx.setFieldState('shopId', state => {
// state.editable = false
// })
// }
if (id) {
ctx.setFieldState('shopId', state => {
state.editable = false
})
}
})
useOrderFormInitEffect(ctx)
useEditHideField()
......@@ -429,14 +430,16 @@ const AgentOrderDetail:React.FC<AgentOrderDetailProps> = () => {
console.log(state, 'shop')
// 初始化 配送时间段处理
useOrderDeliverTimeEffect(ctx, state.value)
const data = await fetchOrderApi.getOrderModeOrderType({shopType: state.values[1]['type']})
ctx.setFieldValue('orderMode', data.orderMode)
ctx.setFieldValue('orderModeName', data.orderModeName)
ctx.setFieldValue('type', data.orderTypeName)
ctx.reset({
validate: false,
selector: '*(products,payments)'
})
if(!id) {
const data = await fetchOrderApi.getOrderModeOrderType({shopType: state.values[1]['type']})
ctx.setFieldValue('orderMode', data.orderMode)
ctx.setFieldValue('orderModeName', data.orderModeName)
ctx.setFieldValue('type', data.orderTypeName)
ctx.reset({
validate: false,
selector: '*(products,payments)'
})
}
})
}}
......
......@@ -26,7 +26,7 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
const initPayWayList = (memberId, memberRoleId) => {
let result = []
PublicApi.getOrderVendorCreateAgentPayTypes({vendorMemberId: memberId, vendorRoleId: memberRoleId}).then(res => {
PublicApi.getOrderBuyerCreateB2bPayTypes({vendorMemberId: memberId, vendorRoleId: memberRoleId}).then(res => {
const { data = [], code } = res
for (let item of data) {
result.push({
......@@ -40,8 +40,11 @@ export const usePaymentInfo = (ctx: ISchemaFormActions | ISchemaFormAsyncActions
}
const getPayLists = (memberId, memberRoleId) => {
PublicApi.postOrderVendorCreateAgentPaymentFind({
PublicApi.postOrderBuyerCreateB2bPaymentFind({
memberId,
roleId: memberRoleId,
shopId: products[0]['shopId'],
orderMode: products[0]['orderMode'],
products: products.map(item => ({ productId: item.commodityId, skuId: item.id }))
}, { ctlType: 'none' }).then(res => {
const { code, data } = res
......
......@@ -7,8 +7,6 @@ import { useModalTable } from './useModalTable';
import { usePageStatus, PageStatus } from '@/hooks/usePageStatus';
import { OrderModalType } from '@/constants/order';
const { pageStatus } = usePageStatus()
let orderMode = null;
// 对象按key排序(运用于商城传过来的阶梯价格排序)
......@@ -22,6 +20,7 @@ export const sortByKey = (params) => {
}
export const getUnitPriceTotal = (record) => {
const { pageStatus } = usePageStatus()
const purchaseCount = Number(record['purchaseCount']) || 0
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
// fix 编辑订单取price
......@@ -71,6 +70,7 @@ export const getUnitPriceTotal = (record) => {
export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncActions) => {
const productRef = useRef<any>({})
const { visible, setVisible, rowSelection, rowSelectionCtl } = useModalTable({type: 'checkbox'})
const { pageStatus } = usePageStatus()
orderMode = ctx.getFieldValue('orderMode')
......@@ -113,6 +113,8 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
// }
}
productInfoColumns[7].formItemProps = { disabled: false }
} else {
// 渲染单价
productInfoColumns[5].render = (t, r) => <span style={{color: 'red'}}>{r.price}</span>
......@@ -120,6 +122,9 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
// 渲染商品ID
productInfoColumns[0].render = (t, r) => r.productId
// 禁用编辑
productInfoColumns[7].formItemProps = { disabled: true }
return [...productInfoColumns].slice(0, productInfoColumns.length - 1)
}
......@@ -134,7 +139,7 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
}
}
const productAddButton = <Button onClick={handleShowProduct} block type='default' style={{margin: '24px auto'}}>选择订单商品</Button>
const productAddButton = pageStatus === PageStatus.ADD ? <Button onClick={handleShowProduct} block type='default' style={{margin: '24px auto'}}>选择订单商品</Button> : null
const productComponents = {
body: {
row: ProductEditableRow,
......
......@@ -18,11 +18,11 @@ import '../index.less'
export interface ReadyAddCashOrderProps {}
const fetchTableData = async (params) => {
const { data } = await PublicApi.getOrderBuyerCreatePage(params)
const { data } = await PublicApi.getOrderBuyerCreatePurchasePage(params)
return data
}
const ReadyAddCashOrder:React.FC<ReadyAddCashOrderProps> = (props) => {
const ReadyAddCashOrder:React.FC<ReadyAddCashOrderProps> = () => {
const { run: deleteRun } = useHttpRequest(PublicApi.postOrderBuyerCreateDeleteBatch)
const { loading: submitLoading, run: submitRun } = useHttpRequest(PublicApi.postOrderBuyerCreateSubmitBatch)
const { columns, ref, rowSelection, rowSelectionCtl } = useSelfTable()
......
......@@ -21,9 +21,7 @@ export const useSelfTable = () => {
}
const handleEdit = (record: any) => {
const { orderType } = record
// orderType 询价报价/现货采购跳转b2b修改
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddOrder/${(orderType === 1 || orderType === 3) ? 'b2b' : 'srm'}/edit?id=${record.orderId}`)
history.push(`/memberCenter/tranactionAbility/purchaseOrder/readyAddCashOrder/edit?id=${record.orderId}`)
}
/** 参照后台数据生成 */
......
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