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

fix:修改渠道商品

parent 6e2de4c1
......@@ -32,6 +32,7 @@ interface InnerAttributeValueList {
}
export interface IProductSelectAttribute {
customerAttribute: { id: number; };
attributeName: string;
customerAttributeId: number;
customerAttributeValueList: InnerAttributeValueList[]
......
......@@ -3,7 +3,7 @@ import { history } from 'umi';
import { Button, Card, Tabs, message } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
SaveOutlined,
SaveOutlined, EditFilled,
} from '@ant-design/icons'
import ReutrnEle from '@/components/ReturnEle'
......@@ -11,14 +11,14 @@ import BasicInfoForm from './addProductsItem/basicInfoForm'
import SelectGoodsForm from './addProductsItem/selectGoodsForm'
import ProductAttributeForm from './addProductsItem/productAttributeForm'
import PriceAttributeForm from './addProductsItem/priceAttributeForm'
import LogisticsForm from './addProductsItem/logisticsForm';
import OtherForm from './addProductsItem/otherForm';
import ProductImageForm from './addProductsItem/productImageForm';
import ProductDescFormOne from './addProductsItem/productDescFormOne';
import LogisticsForm from './addProductsItem/logisticsForm'
import OtherForm from './addProductsItem/otherForm'
import ProductImageForm from './addProductsItem/productImageForm'
import ProductDescFormOne from './addProductsItem/productDescFormOne'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
import { PublicApi } from '@/services/api';
import { PublicApi } from '@/services/api'
const { TabPane } = Tabs
......@@ -75,8 +75,10 @@ const AddProducts: React.FC<{}> = (props) => {
// 提交的数据进行处理
console.log(values, productSelectAttribute, productAttributeAndImageParams, '所有数据')
productSelectAttribute.length>0 && productSelectAttribute.map(_itme => {
_itme.customerAttribute = {id: _itme.customerAttributeId }
delete _itme.attributeName
delete _itme.isPrice
delete _itme.customerAttributeId
})
let _bacsicForm = {...values[0]}
_bacsicForm.customerCategoryId = _bacsicForm.customerCategoryId[_bacsicForm.customerCategoryId.length-1]
......@@ -127,10 +129,11 @@ const AddProducts: React.FC<{}> = (props) => {
delete __item.customerAttributeName
// __item.customerAttributeValueId = __item.id
// **** 新字段结构变更
__item.customerAttribute = { id: __item.id }
__item.customerAttributeValue = { id: __item.customerAttributeValueId, value: __item.value }
__item.customerAttribute = { id: __item.customerAttributeId }
__item.customerAttributeValue = { id: __item.id, value: __item.value }
delete __item.id
delete __item.value
delete __item.customerAttributeId
delete __item.customerAttributeValueId
})
}
if(_item.commodityPic.length>0){
......
......@@ -162,6 +162,7 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
const onChangeName = (value: any) => {
setProductName(value)
}
return (<>
<Form
{...layout}
......
......@@ -58,7 +58,7 @@ const ProductAttributeForm: React.FC<Iprops> = (props) => {
*/
const onChange = (value, attrItem) => {
let params = { customerAttributeId: attrItem.id, attributeName: attrItem.name, isPrice: attrItem.isPrice, customerAttributeValueList: [] }
console.log(params, 'params')
console.log(params, attributesData, 'params')
if(attrItem.type!==3){
for(let item of attrItem?.customerAttributeValueList){
if(value?.length){
......
......@@ -828,7 +828,7 @@ const Products: React.FC<{}> = () => {
<Form.Item label={
<span>
请选择需要{isUp ? '上架' : '下架'}的商城&nbsp;
<Tooltip title="这是一段描述?">
<Tooltip title="已上架的商城为已勾选的商城,不可选择,只可以选择未勾选的商城。">
<QuestionCircleOutlined />
</Tooltip>
</span>}>
......
import React, { useState } from 'react'
import React, { useState, useEffect } from 'react'
import { history } from 'umi'
import { Card, Space, Radio, Row, Col, Descriptions, Table, Avatar } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
......@@ -9,9 +9,93 @@ import {
import { ColumnType } from 'antd/lib/table/interface'
import ReutrnEle from '@/components/ReturnEle'
import styles from "./index.less"
import { PublicApi } from '@/services/api'
import { GetProductChannelCommodityGetChannelCommodityResponse } from '@/services'
const ViewDriectChannel: React.FC<{}> = () => {
const [memberType, setMemberType] = useState(1)
const [channelDetails, setChannelDetails] = useState<GetProductChannelCommodityGetChannelCommodityResponse>()
const [priceTableData, setPriceTableData] = useState<any[]>([])
const [priceTableDataColumn, setPrcieTableColumn] = useState<any[]>([])
useEffect(() => {
const { id } = history.location.query
PublicApi.getProductChannelCommodityGetChannelCommodity({id: id}).then(res => {
const { data } = res
setChannelDetails(data)
constructTable(data)
})
}, [])
const constructTable = (param: GetProductChannelCommodityGetChannelCommodityResponse) => {
const { unitPriceAndPicList, priceType } = param
if(unitPriceAndPicList.length > 0){
let col: any = []
let temp: any = []
unitPriceAndPicList[0].attributeAndValueList.map(_item => {
temp.push({title: _item.customerAttribute.name, dataIndex: [_item.customerAttribute.name, 'value'], key: _item.customerAttribute.name})
})
col.push({
title: 'ID',
dataIndex: 'id',
key: 'id'
},
{
title: 'GoodsId',
dataIndex: 'goodsId',
key: 'id',
className: 'commonHide'
},
{
title: '索引',
dataIndex: '索引',
key: '索引',
className: 'commonHide'
},
{
title: '商品名称',
dataIndex: '商品名称',
key: '商品名称'
},
{
title: '对应货品',
dataIndex: '对应货品',
key: '对应货品'
},
...temp,
{
title: priceType === 3 ? '积分' : '单价',
dataIndex: '单价',
key: '单价',
render: (text, record) => {
if (!text || JSON.stringify(text)==='{}') return null
return Object.keys(text).map((v, i) => {
return <><span key={i}>{v==='0-0'?'':`${v}:`} <span style={{color:'red'}}>{text[v]}</span></span><br /></>
})
}
})
setPrcieTableColumn(col)
// 构建table 数据Data
let _tableData: any = []
unitPriceAndPicList.map((item, index) => {
let temp: any = {}
item.attributeAndValueList.map(_item => {
temp[_item.customerAttribute.name] = {value: _item.customerAttributeValue.value, vId: _item.customerAttributeValue.id, id: _item.customerAttribute.id }
})
_tableData.push({
"id": item.id, // 行数据id
"goodsId": item.goods.id, // 货品ID
"索引": index,
"商品名称": param.name,
"对应货品": item.goods.name,
...temp,
"单价": item.unitPrice
})
})
console.log(col, 'col', _tableData)
setPriceTableData(_tableData)
}
}
const dataSourcePrice = [
{
......@@ -123,17 +207,28 @@ const ViewDriectChannel: React.FC<{}> = () => {
},
]
const renderStatus = (status: any) => {
if(status === 5)
return <span className={styles.pruductStatus}>已上架</span>
if(status === 6)
return <span style={{padding:'2px 5px',background:'rgba(244,245,247,1)',borderRadius:'4px'}}>已下架</span>
if(status === 4)
return <span style={{color:'#E63F3B',padding:'2px 5px',background:'rgba(255,235,230,1)',borderRadius:'4px'}}>未上架</span>
}
const content = <>
<Descriptions colon={true}>
<Descriptions.Item label="商品状态"><span className={styles.pruductStatus}>已上架</span></Descriptions.Item>
<Descriptions colon={true} style={{marginTop:50}}>
<Descriptions.Item label="商品状态">{renderStatus(channelDetails?.status)}</Descriptions.Item>
<Descriptions.Item label="上级渠道">经销5S店</Descriptions.Item>
<Descriptions.Item label="上架商城"><Avatar size="small" icon={<UserOutlined />} />&nbsp;<Avatar size="small" icon={<UserOutlined />} /></Descriptions.Item>
<Descriptions.Item label="商品品类">牛皮</Descriptions.Item>
<Descriptions.Item label="商品品牌">APPLE</Descriptions.Item>
<Descriptions.Item label="单位"></Descriptions.Item>
<Descriptions.Item label="商品ID">10086</Descriptions.Item>
<Descriptions.Item label="上架商城">
{
channelDetails?.commodityShopList?.length>0 && channelDetails.commodityShopList.map((item, index)=><span key={index}>{item.name}&nbsp;</span>)
}
</Descriptions.Item>
<Descriptions.Item label="商品品类">{channelDetails?.customerCategory?.fullName}</Descriptions.Item>
<Descriptions.Item label="商品品牌">{channelDetails?.brand?.name}</Descriptions.Item>
<Descriptions.Item label="单位">{channelDetails?.unitName}</Descriptions.Item>
<Descriptions.Item label="商品ID">{channelDetails?.id}</Descriptions.Item>
</Descriptions>
</>
......@@ -146,9 +241,9 @@ const ViewDriectChannel: React.FC<{}> = () => {
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="商品信息">
<p>
<Avatar size={48} shape="square" src="https://avatars1.githubusercontent.com/u/8186664?s=460&v=4" />
<span style={{color:'rgba(23,43,77,1)',fontSize:20,fontWeight:500,marginLeft:16}}>进口头层牛皮荔枝纹</span>
<span style={{color:'#E63F3B',padding:'2px 5px',background:'rgba(255,235,230,1)',borderRadius:'4px',marginLeft:16,marginRight:16}}>上级渠道</span>
<Avatar size={48} shape="square" src={channelDetails?.unitPriceAndPicList[0]?.commodityPic && channelDetails.unitPriceAndPicList[0].commodityPic[0]} />
<span style={{color:'rgba(23,43,77,1)',fontSize:20,fontWeight:500,marginLeft:16}}>{channelDetails?.name}</span>
<span style={{color:'#E63F3B',padding:'2px 5px',background:'rgba(255,235,230,1)',borderRadius:'4px',marginLeft:16,marginRight:16}}>{channelDetails?.source === 1 ? "上级渠道" : "渠道自有"}</span>
<a>去查看 &gt;</a>
</p>
{content}
......@@ -156,7 +251,15 @@ const ViewDriectChannel: React.FC<{}> = () => {
</Space>
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title="单价设置">
<Table dataSource={dataSourcePrice} columns={columnsPrice} pagination={false} />
<Row>
<Col span={3}>
<p>会员折扣:</p>
</Col>
<Col span={21}>
<p>{channelDetails?.isMemberPrice ? '允许使用会员折扣价购买' : '不允许使用会员折扣价购买'}</p>
</Col>
</Row>
<Table dataSource={priceTableData} columns={priceTableDataColumn} pagination={false} />
</Card>
</Space>
<Space direction="vertical" style={{width:'100%'}}>
......@@ -166,10 +269,10 @@ const ViewDriectChannel: React.FC<{}> = () => {
<p>使用渠道会员:</p>
</Col>
<Col span={21}>
<p>{memberType ? <Radio checked>指定渠道会员</Radio> : <Radio checked>所有渠道会员(默认)</Radio>}</p>
<p>{channelDetails?.isAllMember ? '所有渠道会员(默认)': '指定渠道会员'}</p>
</Col>
</Row>
{memberType ? <Table dataSource={dataMember} columns={columnsMember} /> : ''}
{channelDetails?.isAllMember ? '' : <Table dataSource={dataMember} columns={columnsMember} />}
</Card>
</Space>
</PageHeaderWrapper>
......
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