Commit 7f01a4a5 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix: 对上游导入商品品类品牌无法关联特殊处理,处理修改询价报价订单异常问题

parent fb3e7b16
......@@ -5,6 +5,7 @@ export interface IBasicFormParam {
brandName: string;
commodityAreaList: string[][];
customerCategoryId: string[];
customerCategoryName: string;
name: string;
sellingPoint: string[];
slogan: string;
......
......@@ -18,6 +18,7 @@ import ProductDescFormCloud from './addProductsItem/productDescFormCloud'
import { useLocalStore, observer } from 'mobx-react'
import { store } from '@/store'
import { PublicApi } from '@/services/api'
import { CommodityType } from './constant';
const { TabPane } = Tabs
......@@ -90,6 +91,7 @@ const AddProducts: React.FC<{}> = (props) => {
title: data.title,
keywords: data.keywords,
description: data.description,
type: data.type,
})
setProductName(data?.name)
setProductPriceType(data?.priceType)
......@@ -169,6 +171,11 @@ const AddProducts: React.FC<{}> = (props) => {
}
}
}
if(productInfoByEdit?.type === CommodityType.UPPER_SUPPORTER_COMMODITY) {
// @ 上游商品 直接去原信息中的品类品牌id
_bacsicForm.customerCategoryId = productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + '')
_bacsicForm.brandId = productInfoByEdit?.brand.id
}
_bacsicForm.customerCategoryId = _bacsicForm.customerCategoryId[_bacsicForm.customerCategoryId.length - 1]
// 移除描述中的空数组[]
let _productDescription = { ...productDescription }
......
......@@ -13,7 +13,7 @@ import { store } from '@/store'
import { validatorByte } from '@/utils/regExp';
import { GetProductCustomerGetCustomerCategoryTreeResponse } from '@/services/ProductApi';
import { GetManageAreaAllResponse } from '@/services/PassApi';
import { customerCategoryTypeLabel } from '../constant';
import { CommodityType, customerCategoryTypeLabel } from '../constant';
const { Option } = Select
const layout = {
......@@ -198,7 +198,76 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
ref={basicFormRef}
autoComplete="off"
>
<Form.Item
{/* 对来自于上游的商品 品类品牌仅做显示处理 */}
{
productInfoByEdit?.type === CommodityType.UPPER_SUPPORTER_COMMODITY
?
<Form.Item
name="customerCategoryName"
label="商品品类"
rules={[
{
required: true,
message: '请选择商品品类'
},
]}
>
<Input placeholder="请选择品类" disabled={history.location.query?.id} defaultValue={productInfoByEdit.customerCategory.fullName} />
</Form.Item>
:
<Form.Item
name="customerCategoryId"
label="商品品类"
rules={[
{
required: true,
message: '请选择商品品类'
},
]}
>
<Cascader
allowClear={false}
disabled={history.location.query?.id}
options={customerCategoryTree}
fieldNames={{ label: 'title', value: 'id', children: 'children' }}
onChange={onCustomerCategoryChange}
placeholder="请选择品类"
/>
</Form.Item>
}
{
productInfoByEdit?.type === CommodityType.UPPER_SUPPORTER_COMMODITY
?
<Form.Item
name="brandName"
label="商品品牌"
>
<Input placeholder="请选择商品品牌" disabled={!isUpdateAttribute} defaultValue={productInfoByEdit.brand.name} />
</Form.Item>
:
<Form.Item
name="brandId"
label="商品品牌"
>
<Select
disabled={!isUpdateAttribute}
showSearch={true}
showArrow={true}
placeholder="请输入或选择商品品牌"
allowClear
value={brandValue}
defaultActiveFirstOption={false}
filterOption={false}
onSearch={handleBrandSearch}
onChange={handleBrandChange}
onFocus={()=>handleBrandSearch(null)}
style={{ width: '100%' }}
>
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item>
}
{/* <Form.Item
name="customerCategoryId"
label="商品品类"
rules={[
......@@ -237,7 +306,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
>
{brandData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item>
</Form.Item> */}
<Form.Item
name="name"
label={
......
......@@ -52,6 +52,16 @@ export const carriageTypeLabel = [
'买家承担运费',
]
/** 商品类型枚举 */
export enum CommodityType {
/** 自营商品 */
SELF_SUPPORT_COMMODITY = 1,
/** 上游商品 */
UPPER_SUPPORTER_COMMODITY = 2,
/** 代销商品 */
AGENT_SALE_COMMODITY = 3,
}
/** 查看商品 审核历史列 */
export const columns: ColumnType<any>[] = [
{
......
......@@ -130,7 +130,8 @@ const Products: React.FC<{}> = () => {
{
title: '供应会员',
dataIndex: 'upperMemberName',
key: 'upperMemberName'
key: 'upperMemberName',
render: t => t ? t : '—'
},
{
title: '价格',
......
......@@ -26,7 +26,11 @@ export const useOrderDetail = (options: OrderDetailHookProps) => {
const { orderNo } = history.location.query
const { type } = options
const dataRef = useRef<any>([
{ label: '对应报价单号', name: 'quoteNo', span: 8, render: text => <Link to={'/'}>{text}</Link> },
{ label: '对应报价单号', name: 'quoteNo', span: 8, render: (text, record) => <Link
to={type[0] === 's' ? `/memberCenter/tranactionAbility/inquiryOffer/offerSearch/offer/preview?id=${record?.quoteId}` : `/memberCenter/tranactionAbility/confirmOffer/offerSearch/offer/preview?id=${record?.quoteId}`}>
{text}
</Link>
},
{ label: '订单摘要', name: 'digest', span: 8 },
{ label: type[0] === 's' ? '采购会员' : '供应会员', name: type[0] === 's' ? 'buyerMemberName' : 'vendorMemberName', span: 8 },
{ label: '下单模式', name: 'orderModeName', span: 8 },
......
......@@ -4,7 +4,7 @@ import { Popover, Row, Space } from 'antd'
export const AddressPop = (props) => {
const { pickInfo = null, children } = props
return pickInfo && pickInfo.deliverType === 2 ? <Space>
return pickInfo && pickInfo.deliveryType === 2 ? <Space>
<EnvironmentOutlined style={{marginRight: 8}}/>
<Popover content={
<Row>
......
......@@ -18,7 +18,8 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
const handleSave = row => {
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('products')];
const index = newData.findIndex(item => row.productId === item.productId);
// srm订单已productId为唯一key b2b订单以skuId为唯一
const index = newData.findIndex(item => row.skuId ? row.skuId === item.skuId : row.productId === item.productId);
const item = newData[index];
newData.splice(index, 1, {
...item,
......
......@@ -24,12 +24,14 @@ const OrderPayTabs:React.FC<OrderPayTabsProps> = () => {
// 简单流程为24
const processEnum = data.processEnum
const payments = data.payments.sort((a, b) => a.batchNo - b.batchNo)
useEffect(() => {
// 过滤支付信息 取第一个待支付或者未到账的id
if(data?.payments?.length) {
let payments = data.payments.sort((a, b) => a.batchNo - b.batchNo).filter(item => item.showPayment)
if(payments.length) {
ctl.setPayId(payments[0].paymentId)
if(payments.length) {
let payment = payments.filter(item => item.showPayment)
if(payment.length) {
ctl.setPayId(payment[0].paymentId)
}
}
}, [])
......@@ -61,7 +63,7 @@ const OrderPayTabs:React.FC<OrderPayTabsProps> = () => {
// const canCtlData = data.payments.find(v => v.showView) || {} //@todo 需后端提供showView字段支持
const canCtlData = data.payments.find(v => v.vouchers.length) || {}
const canCtlData = payments.find(v => v.vouchers.length) || {}
const urlsDatas = canCtlData.vouchers || []
return (
......@@ -71,9 +73,9 @@ const OrderPayTabs:React.FC<OrderPayTabsProps> = () => {
<MellowCard bordered={false} fullHeight>
<Tabs defaultActiveKey='1'>
{
data.payments.length
payments.length
?
data.payments.map(v => <TabPane key={v.paymentId} tab={<TabHeader dataSource={v}/>}>
payments.map(v => <TabPane key={v.paymentId} tab={<TabHeader dataSource={v}/>}>
<Row>
<Col className={style.fontGray} span={4}>支付环节: </Col>
<Col>{v.payNode}</Col>
......
......@@ -87,13 +87,13 @@ export const filterProductDataById = (data, targetData) => {
const { code, data } = await PublicApi.getLogisticsShipperAddressGet({
id: logistics.sendAddress
}, { ttl: 60 * 1000, useCache: true })
logistics.render = {...data, deliverType: logistics.deliveryType}
logistics.render = {...data, deliveryType: logistics.deliveryType}
} else {
logistics.render = DELIVERY_TYPE[logistics.deliveryType]
}
// 配送方式外置, 用于接口字段冗余
next.deliverType = logistics.deliveryType
next.deliveryType = logistics.deliveryType
// id 存在集合中, 采用target中的数据, 否则采用data中的数据
const findResult = data.find(v => v.id === next.id)
......
......@@ -59,6 +59,7 @@ export const procurementRenderField = (data) => {
productId: item.skuId,
productName: item.name,
logistics: item.deliverType,
deliveryType: item.deliverType,
unitPrice: item.price,
purchaseCount: item.quantity,
taxInclusive: item.tax,
......@@ -351,11 +352,10 @@ export const productInfoColumns: any[] = [
// 接口调用
{
title: '配送方式',
dataIndex: 'deliverType',
dataIndex: 'deliveryType',
align: 'center',
key: 'deliverType',
key: 'deliveryType',
render: (t, r) => {
console.log(r, 'rr')
if(t === 1)
return "物流(默认)"
else if(t === 2)
......
......@@ -81,9 +81,9 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
if (value && value.length > 0 && !state.loading){ // 添加loading判断避免二次调用
// 请求一次并复制给支付信息
const productItem = value[0]
// if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
if(pageStatus === PageStatus.EDIT) { // 编辑下 支付信息联动实现
// } else if(pageStatus === PageStatus.ADD) { // 新增下 需要支付信息生成支付次数
} 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) {
......@@ -108,7 +108,7 @@ export const useProductTableChangeForPay = (ctx: ISchemaFormActions | ISchemaFor
})
}
// }
}
}
// 确认后 需根据商品id请求会员折扣接口, 以及配送方式
......
......@@ -23,46 +23,7 @@ export const sortByKey = (params) => {
export const getUnitPriceTotal = (record) => {
const purchaseCount = Number(record['purchaseCount']) || 0
// fix 当没有传递unitPrice字段时 自动容错, 单价显示为0
// fix 编辑订单取price
record.unitPrice = pageStatus === PageStatus.EDIT ? record.price : record.unitPrice || record.price || 0
if (typeof record.unitPrice === 'number') {
return record.isMemberPrice ?
Number((record.unitPrice * purchaseCount * record.memberPrice).toFixed(2))
:
Number((record.unitPrice * purchaseCount).toFixed(2))
}
if(record.unitPrice) {
record.unitPrice = sortByKey(record.unitPrice)
}
// fix 当没有传递unitPrice字段时 但有price字段时 补全unitPrice字段
if(record.price && JSON.stringify(record.unitPrice) === "{}") {
record.unitPrice = {'0-0': record.price}
}
// fix 当有unitPrice字段时 没有price字段时 补全price字段
if(!record?.price && JSON.stringify(record.unitPrice) !== "{}") {
if(Object.keys(record.unitPrice)[0] === '0-0') record.price = record.unitPrice['0-0']
}
let unitPrice = 0
Object.entries(record.unitPrice).forEach(([key, value]) => {
const [min, max] = key.split('-').map(v => Number(v))
if (min === 0 && max === 0) {
unitPrice = Number(value)
return false
}
if ((purchaseCount >= min && purchaseCount <= max) || (purchaseCount > max)) {
// 处于该区间或者大于该区间
unitPrice = Number(value)
return false
}
})
// 考虑会员折扣
let memberPrice = record.memberPrice
if(record.isMemberPrice) {
return Number((unitPrice * purchaseCount * memberPrice).toFixed(2))
} else {
return Number((unitPrice * purchaseCount).toFixed(2))
}
return Number((record.price * purchaseCount).toFixed(2))
}
/**
......@@ -150,11 +111,10 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
}
return new Promise((resolve, reject) => {
const newData = [...ctx.getFieldValue('products')];
const index = newData.findIndex(item => row.id === item.id);
console.log(newData, row)
const index = newData.findIndex(item => row.productId === item.productId);
const item = newData[index];
row['money'] = getUnitPriceTotal(row)
// 通过下单模式判断 是否是手工或者渠道手工下单
let addModel = ctx.getFieldValue("orderMode")
row['productId'] = row.productId
newData.splice(index, 1, {
...item,
......
......@@ -231,7 +231,6 @@ export const payInfo: ISchema = {
}
}
// 交付信息
const submitInfo: ISchema = {
"x-index": 1,
......@@ -249,7 +248,7 @@ const submitInfo: ISchema = {
labelAlign: 'left',
grid: true,
columns: 2,
full: true
// full: true
},
properties: {
FLEX_LAYOUT_LEFT: {
......@@ -264,7 +263,8 @@ const submitInfo: ISchema = {
"x-component-props": {
disabledDate: current => {
return current && current < moment().startOf('day')
}
},
style: { width: 400 }
}
},
}
......@@ -272,11 +272,11 @@ const submitInfo: ISchema = {
deliveryAddresId: {
type: 'string',
"x-component": 'SelectAddress',
"x-mega-props": {
style: {
full: true
}
},
// "x-mega-props": {
// style: {
// full: true
// }
// },
"x-component-props": {
dataSource: [],
times: 0,
......
......@@ -43,8 +43,8 @@ class ProductStore implements IProductModule {
slogan: this.productInfoByEdit?.slogan,
sellingPoint: this.productInfoByEdit?.sellingPoint,
commodityAreaList: this.productInfoByEdit?.commodityAreaList.map(item => [item.provinceCode, item.cityCode]),
customerCategoryId: this.productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + '')
// customerCategoryId: this.productInfoByEdit?.customerCategory.parentId ? [this.productInfoByEdit?.customerCategory.parentId + '', this.productInfoByEdit?.customerCategory.id + ''] : [this.productInfoByEdit?.customerCategory.id + '']
customerCategoryId: this.productInfoByEdit?.customerCategory.fullId.split('.').map(item => Number(item) + ''),
customerCategoryName: this.productInfoByEdit?.customerCategory.fullName
}
}
......
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