Commit 0664eec9 authored by 前端-钟卫鹏's avatar 前端-钟卫鹏

fix:处理关联商品展开显示商品信息

parent e8eae9c6
......@@ -153,10 +153,14 @@ export const RelevanceGoodDrawer:React.FC<RelevanceGoodDrawerProps> = ({
await schemaAction.setFieldValue('code', selectRow[0]['code'])
await schemaAction.setFieldValue('name', selectRow[0]['name'])
await schemaAction.setFieldValue('type', selectRow[0]['type'])
await schemaAction.setFieldValue('categoryId', selectRow[0]['customerCategory']['fullId'].split('.').map(item => Number(item).toString()))
// await schemaAction.setFieldValue('categoryId', selectRow[0]['customerCategory']['fullId'].split('.').map(item => Number(item).toString()))
await schemaAction.setFieldValue('categoryName', selectRow[0]['customerCategory']['name'])
await schemaAction.setFieldValue('brandName', selectRow[0]['brand'] ? selectRow[0]['brand']['name'] : null)
await schemaAction.setFieldValue('unitId', selectRow[0]['unitId'])
// await schemaAction.setFieldValue('unitId', selectRow[0]['unitId'])
setTimeout(async () => {
await schemaAction.setFieldValue('categoryId', selectRow[0]['customerCategory']['fullId'].split('.').map(item => Number(item).toString()))
await schemaAction.setFieldValue('unitId', selectRow[0]['unitId'])
}, 200);
await schemaAction.setFieldValue('unitName', selectRow[0]['unitName'])
await schemaAction.setFieldValue('has', true)
setSelectRow([])
......
......@@ -197,16 +197,16 @@ export const RelevanceTenderProduct: React.FC<RelateProductDrawerProps> = ({
formActions.submit(v => {
// 点击确定 设置商品id和商品文件到对应物料行中
let submitMateriel = schemaAction.getFieldValue('submitTenderMateriel')
submitMateriel.map(item => {
if(item => item.id === currentMaterial[0]['id']) {
item.file = v['file']
item.commodityId = selectRow[0]['id']
item.productId = selectRow[0]['commodityId']
}
return item
})
console.log(v, submitMateriel)
console.log(v, submitMateriel, selectRow)
schemaAction.setFieldValue('submitTenderMateriel', submitMateriel)
})
}
......
import React, { useState } from 'react'
import { ISchemaFormActions, ISchemaFormAsyncActions } from '@formily/antd';
import { Button } from 'antd';
import { Button, message } from 'antd';
import { productInfoColumns } from '../constant';
import ProductTableCell, { ProductEditableRow } from '../components/productTableCell';
import { CaretDownOutlined, CaretRightOutlined } from '@ant-design/icons';
import { PublicApi } from '@/services/api';
import { Row, Col } from 'antd'
import style from '../index.less'
// 对象按key排序(运用于商城传过来的阶梯价格排序)
export const sortByKey = (params) => {
......@@ -92,6 +96,57 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
};
})
const renderDescription = async (record) => {
// 商品信息
let res = await PublicApi.getProductCommodityGetCommodity({id: record.productId})
// 商品规格信息
let spec = await PublicApi.getProductCommodityGetCommodityAttributeByUnitPriceAndPicId({ unitPriceAndPicId: record.commodityId })
const { code , data } = res
if(code === 1000) {
const newData = [...ctx.getFieldValue('submitTenderMateriel')];
const index = newData.findIndex(item => record.id === item.id);
const item = newData[index];
item.description = (<div className={style.childrenWrap}>
<Row>
<Col span={3}>
<div className={style.childrenTitle}>
<p>对应</p>
<p>招标商品</p>
</div>
</Col>
<Col span={6}>
<div className={style.childrenContent}>
<p><span>商品编号:</span>{data.code}</p>
<p><span>商品名称:</span>{data.name}</p>
</div>
</Col>
<Col span={6}>
<div className={style.childrenContent}>
<p><span>规格型号:</span>
{
spec.data.length && spec.data.map(item => item.customerAttributeValueList[0].value).join('/')
}
</p>
<p><span>品类:</span>{data.customerCategory.fullName}</p>
</div>
</Col>
<Col span={6}>
<div className={style.childrenContent}>
<p><span>品牌:</span>{data.brand.name}</p>
</div>
</Col>
{/* <Col span={3}>
<div className={style.childrenContent}>
<p><a>查看</a></p>
</div>
</Col> */}
</Row>
</div>)
ctx.setFieldValue('submitTenderMateriel', newData)
console.log(item, data)
}
}
// 嵌套子表格
const productChildren = {
expandedRowRender: record => <p style={{ margin: 0 }}>{record.description}</p>,
......@@ -104,6 +159,12 @@ export const useProductTable = (ctx: ISchemaFormActions | ISchemaFormAsyncAction
),
onExpand: (expanded, record) => {
console.log('通过商品Id 查询商品信息显示在嵌套中', record)
if(!record?.commodityId) {
return message.error('请先选择关联商品')
}
if(expanded) {
renderDescription(record)
}
}
}
......
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