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

fix:品牌相关问题

parent 1a6ee92a
import { GetProductChannelCommodityGetCommodityListResponseDetail } from '@/services';
import { GetProductChannelCommodityGetCommodityListResponseDetail, GetProductChannelCommodityGetCommodityUnitPriceResponse } from '@/services';
export interface IChannelProductModule {
productSelectRowInStore: GetProductChannelCommodityGetCommodityListResponseDetail;
priceType: number;
productName: string;
currentActiveKey: number;
currentActiveKey: string;
currentOperateChannel: string;
tableDataInSetPrice: GetProductChannelCommodityGetCommodityUnitPriceResponse[];
setProductSelectRowInStore(data: GetProductChannelCommodityGetCommodityListResponseDetail): void;
setPriceType(data: number): void;
setProductName(data: string): void;
setCurrentActiveKey(data: string): void;
setCurrentOperateChannel(data: string): void;
setTableDataInSetPrice(data: GetProductChannelCommodityGetCommodityUnitPriceResponse[]): void;
}
\ No newline at end of file
......@@ -74,6 +74,7 @@ const AddPropertyValue: React.FC<{}> = () => {
const handleSubmitAllSetting = () => {
attrValueForm.validateFields().then(values => {
const { attrId, attrName } = history.location.query
let pararms = {...values}
delete pararms.attributeName
if(JSON.stringify(pararms.attributeValue)==='{}')
......@@ -82,7 +83,7 @@ const AddPropertyValue: React.FC<{}> = () => {
PublicApi.postProductCustomerSaveOrUpdateCustomerAttributeValue(pararms).then(res => {
if(res.code === 1000)
// history.goBack()
history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue?before=${history.location.query.attrId}`)
history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue?attrId=${attrId}&attrName=${attrName}`)
})
}).catch(error => {
......
......@@ -51,8 +51,8 @@ const PropertyValue: React.FC<{}> = () => {
useEffect(() => {
let prefix = sessionStorage.getItem('beforeKeyPrefix')
let beforeKey = history.location.query.before
console.log(prefix, beforeKey)
let beforeKey = history.location.query.attrId
if(beforeKey){ // 展开之前的选择项
setSelectKey(beforeKey)
treeActions.setExpandedKeys([`${prefix}_${beforeKey}`]) // 拼接不正常的key
......@@ -240,7 +240,9 @@ const PropertyValue: React.FC<{}> = () => {
<Button
type="primary"
icon={<PlusOutlined />}
onClick={() => { history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey}&attrName=${selectNode._title}`) }}
onClick={() => {
history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/addPropertyValue?attrId=${selectKey||history.location.query.attrId}&attrName=${selectNode?._title||history.location.query.attrName}`)
}}
>
新建
</Button>
......
import React, {useState, useRef, useEffect} from 'react'
import { history } from 'umi';
import { Button, Form, Card, Tabs, Input, Radio, Table, message, Row, Col } from 'antd'
import { Button, Form, Card, Tabs, Input, Radio, Table, message, Row, Col, Select } from 'antd'
import {
PlusOutlined, SettingOutlined,
} from '@ant-design/icons'
......@@ -14,6 +14,7 @@ import { store } from '@/store'
import { inject, observer } from 'mobx-react'
const { Search } = Input
const { Option } = Select
const layout = {
labelCol: {
......@@ -24,6 +25,12 @@ const layout = {
},
}
interface IOption {
key: string;
value: number;
children: string;
}
interface IProps {
onRef: (refs: any) => void;
}
......@@ -37,6 +44,7 @@ const SelectChannel:React.FC<IProps> = (props) => {
const [memberRoleList, setMemberRoleList] = useState<any[]>([])
const [selectedMemberRowKeys, setSelectedMemberRowKeys] = useState<any>([])
const [selectMemberRow, setSelectMemberRow] = useState<any[]>([]) // 选中的会员弹框数据
const [selectedOption ,setSelectedOption] = useState<IOption>()
const { ChannelProudctStore } = store
const {
......@@ -117,12 +125,25 @@ const SelectChannel:React.FC<IProps> = (props) => {
useEffect(() => {
onRef(formMember)
// 获取所有的会员角色
PublicApi.getMemberManageRoleList().then(res => {
const { data } = res
setMemberRoleList(data)
if(data.length > 0){
let initSelectOption = {
key: '0',
value: data[0].roleId,
children: data[0].roleName
}
setSelectedOption(initSelectOption)
}
})
}, [])
// 获取渠道会员
const fetchMemberData = (params: any) => {
return new Promise((resolve, reject) => {
PublicApi.getMemberManageChannelLowerPage(params).then(res => {
PublicApi.getMemberManageChannelLowerPage({ memberIds: [], name: selectedOption.children, roleId: selectedOption.value ,...params }).then(res => {
const { data } = res
resolve(data)
})
......@@ -170,68 +191,79 @@ const SelectChannel:React.FC<IProps> = (props) => {
setCurrentOperateChannel('所有渠道会员')
}
const roleChange = (value: number, option: IOption) => {
setSelectedOption(option)
}
return (<>
<Row>
<Col span={18}>
<Form
{...layout}
form={formMember}
name="add-channel-merchant"
labelAlign="left"
>
{/* {
memberRoleList.length>0 && <Form.Item name="channelMemberRoleId">
<Radio.Group buttonStyle="solid" className={styles.customizeRadio}>
{
memberRoleList.map((item, index) => (
<Radio.Button key={index} value={item.roleId}>{item.roleName}</Radio.Button>
))
}
</Radio.Group>
</Form.Item>
} */}
<Form.Item name="channelMemberRoleId">
<Radio.Group buttonStyle="solid" defaultValue={1} className={styles.customizeRadio}>
<Radio.Button key={1} value={1}>渠道采购商</Radio.Button>
<Radio.Button key={2} value={2}>渠道自有采购商</Radio.Button>
</Radio.Group>
</Form.Item>
<Form.Item
name="isAllMember"
label="选择渠道会员"
rules={[{
required: true,
message: '请选择渠道会员'
}]}
initialValue={isAllMember}
{
memberRoleList.length>0 && <>
<Col span={18}>
<Form
{...layout}
form={formMember}
name="add-channel-merchant"
labelAlign="left"
colon={false}
initialValues={{channelMemberRoleId: memberRoleList[0].roleId}}
>
<Radio.Group onChange={handleIsAllMemberChange}>
<Radio value={true}>所有渠道会员(默认)</Radio>
<Radio value={false}>指定渠道会员</Radio>
</Radio.Group>
</Form.Item>
</Form>
</Col>
<Col span={6} style={{display: 'flex', justifyContent: 'flex-end', flexWrap: 'wrap'}}>
<div>
<p>
<Search
placeholder="渠道会员名称"
onSearch={value => console.log(value)}
style={{ width: 256 }}
/>
</p>
</div>
<div>
<p>
<Button
type="text"
icon={<SettingOutlined />}
onClick={clickBatchSetting}
>批量设置渠道商品</Button>
</p>
</div>
</Col>
{/* <Form.Item name="channelMemberRoleId">
<Radio.Group buttonStyle="solid" defaultValue={1} className={styles.customizeRadio}>
<Radio.Button key={1} value={1}>渠道采购商</Radio.Button>
<Radio.Button key={2} value={2}>渠道自有采购商</Radio.Button>
</Radio.Group>
</Form.Item> */}
<Form.Item
label="选择渠道角色"
name="channelMemberRoleId"
>
<Select onChange={roleChange} placeholder="选择渠道会员角色">
{
memberRoleList.map((item, index) => (
<Option key={index} value={item.roleId}>{item.roleName}</Option>
))
}
</Select>
</Form.Item>
<Form.Item
name="isAllMember"
label="选择渠道会员"
rules={[{
required: true,
message: '请选择渠道会员'
}]}
initialValue={isAllMember}
>
<Radio.Group onChange={handleIsAllMemberChange}>
<Radio value={true}>所有渠道会员(默认)</Radio>
<Radio value={false}>指定渠道会员</Radio>
</Radio.Group>
</Form.Item>
</Form>
</Col>
<Col span={6} style={{display: 'flex', justifyContent: 'flex-end', flexWrap: 'wrap'}}>
<div>
<p>
<Search
placeholder="渠道会员名称"
onSearch={value => console.log(value)}
style={{ width: 256 }}
/>
</p>
</div>
<div>
<p>
<Button
type="text"
icon={<SettingOutlined />}
onClick={clickBatchSetting}
>批量设置渠道商品</Button>
</p>
</div>
</Col>
</>
}
</Row>
{
!isAllMember ? <>
......
......@@ -116,7 +116,7 @@ const SelectProduct:React.FC<IProps> = (props) => {
]
useEffect(() => {
onRef(productFormRef)
onRef(formProduct)
formProduct.setFieldsValue({source: source})
// 获取会员角色列表
......
......@@ -69,11 +69,12 @@ const SetPrice:React.FC<IProps> = (props) => {
priceType,
productName,
productSelectRowInStore,
currentOperateChannel
currentOperateChannel,
setTableDataInSetPrice
} = ChannelProudctStore
useEffect(() => {
onRef(formPrice)
}, [])
......@@ -93,6 +94,7 @@ const SetPrice:React.FC<IProps> = (props) => {
}
const structureTable = (data: any, name?: string) => {
console.log(data, 'structureTableData')
// 构建table 列columns
let col: any = []
let temp: any = []
......@@ -148,11 +150,11 @@ const SetPrice:React.FC<IProps> = (props) => {
})
_tableData.push({
"id": item.id, // 行数据id
"goodsId": item.goods.id, // 货品ID
"goodsId": item.goods?.id || '', // 货品ID 可能为null
"索引": index,
// "商品名称": productRowCtl.selectRow[0].name,
"商品名称": name || productName,
"对应货品": item.goods.name,
"对应货品": item.goods?.name || '',
...temp,
"单价": item.unitPrice
})
......@@ -322,6 +324,7 @@ const SetPrice:React.FC<IProps> = (props) => {
newTabeData[curretSetPriceRow['索引']] = _row
}
setPriceTableData(newTabeData)
console.log(newTabeData, '价格修改之后的tableData')
})
}
......@@ -398,9 +401,9 @@ const SetPrice:React.FC<IProps> = (props) => {
</Button>
{
priceTableData.length > 0 && priceType != 2 &&
<Button
type="text"
style={{float: 'right'}}
<Button
type="text"
style={{float: 'right'}}
onClick={clickBatchSetPrice}
>
<SettingOutlined />
......
......@@ -35,7 +35,10 @@ const AddDirectChannel:React.FC<{}> = (props) => {
} = ChannelProudctStore
useEffect(() => {
console.log('初始化')
return () => {
setCurrentActiveKey('1')
}
}, [])
......@@ -47,6 +50,7 @@ const AddDirectChannel:React.FC<{}> = (props) => {
const onSave = () => {
let data = formRefs.map(async __ => {
console.log(__, '____')
return (
await __.validateFields()
)
......
......@@ -14,11 +14,15 @@ 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 ProductDescFormDefualt from './addProductsItem/productDescFormDefault'
import ProductDescFormCloud from './addProductsItem/productDescFormCloud'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
import { PublicApi } from '@/services/api'
import { render } from '@/app';
const demoFetch = require('../../../../demo').fetchConfig
const { TabPane } = Tabs
......@@ -28,6 +32,7 @@ const AddProducts: React.FC<{}> = (props) => {
const [attributeList, setAttributeList] = useState<any[]>([])
const [clickTabIndex, setClickTabIndex] = useState<string[]>(['1'])
const [isDisableSaveBtn, setIsDisableSaveBtn] = useState<boolean>(false)
const [currentTemplateName, setCurrentTemplateName] = useState<string>()
let [formRefs, setFormRefs] = useState([]) //子form的ref数组
const { ProductStore } = store
const {
......@@ -45,6 +50,8 @@ const AddProducts: React.FC<{}> = (props) => {
} = ProductStore
useEffect(()=>{
productDescriptionTemplate()
const { id } = history.location.query
if(id){
const makeRequest = async () => {
......@@ -60,10 +67,30 @@ const AddProducts: React.FC<{}> = (props) => {
return () => {
clearData([])
console.log('添加商品组件卸载')
}
}, [])
// useEffect(() => {
// renderTemplate(currentTemplateName)
// }, [currentTemplateName])
// 获取页面使用模板
const productDescriptionTemplate = async () => {
let globalData = await demoFetch()
PublicApi.getTemplateGoodsFindUseGoodsTemplate({siteId: globalData.global.siteId}).then(res => {
if(res.code === 1000)
setCurrentTemplateName(res.data.fileName)
})
}
// 切换模板
const renderTemplate = () => {
// if(currentTemplateName === 'science')
// return <ProductDescFormDefualt />
// else if(currentTemplateName === 'cloud')
return <ProductDescFormCloud />
}
const onSave = () => {
setIsDisableSaveBtn(true)
const { id } = history.location.query
......@@ -296,7 +323,10 @@ const AddProducts: React.FC<{}> = (props) => {
<ProductImageForm />
</TabPane>
<TabPane tab="商品描述" key="6">
<ProductDescFormOne />
{/* <ProductDescFormDefualt /> */}
{
renderTemplate()
}
</TabPane>
<TabPane tab="物流信息" key="7">
<LogisticsForm
......
......@@ -46,4 +46,60 @@
position: absolute;
bottom: 0;
}
}
// productDescFormCloud
.cloud-container{
width: 790px;
}
.cloud-media-content-box{
width: 790px;
margin: 24px 0;
height: auto !important;
}
.cloud-descript-box{
position: relative;
width: 790px;
margin: 24px 0;
border:1px solid rgba(235,236,240,1);
text-align: center;
color:rgba(151,160,175,1);
height: 148px;
p{
height: 128px;
line-height: 128px;
}
.cloudPVideo, .cloudMiddleAddBtn{
height: 44px;
line-height: 1.5;
position: absolute;
top:50%;
left:50%;
transform: translate(-50%, -50%);
}
.cloudDivVideo, .cloudDivImage{
margin: 24px auto;
height: auto;
img{
width: 320px;
height: 240px;
}
}
.cloud-right-btn{
position: absolute;
top: 0;
right: 0;
Button{
display: block;
width:36px;
height:36px;
background:rgba(250,251,252,1);
border-color: #ebecf0;
border-radius: 0px;
border-top: none;
border-right: none;
}
}
}
\ No newline at end of file
......@@ -72,6 +72,7 @@ const PriceAttributeForm: React.FC<Iprops> = (props) => {
if(history.location.query?.id){ // 编辑情况下 用于判断价格类型和显示单位
setPlanPrice(productInfoByEdit?.priceType)
handleUnitSearch(getPriceAttributeFormParamsByEdit.unitName)
setMinOrderNumber(productInfoByEdit?.minOrder) // 先设置最小起订数 便于后续价格校验
}
return ()=>{
console.log('价格属性组件卸载')
......
import React, { useState, useEffect } from 'react'
import {history} from 'umi'
import { Button, message, Upload, Input } from 'antd'
import cx from 'classnames'
import styles from './index.less'
import { PlusOutlined, DeleteOutlined } from '@ant-design/icons'
import { UPLOAD_TYPE } from '@/constants'
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
const ProductDescFormCloud: React.FC<{}> = (props) => {
const [fileImageList, setFileImageList] = useState<any>([])
const { ProductStore } = store
const { productInfoByEdit, setProductDescription } = ProductStore
useEffect(()=>{
}, [])
const uploadImgProps = {
name: 'file',
action: '/api/file/file/upload',
showUploadList: false,
data: { fileType: UPLOAD_TYPE },
onChange(info) {
if (info.file.status !== 'uploading') {
console.log(info.file, info.fileList, 'image files');
}
if (info.file.status === 'done') {
message.success(`${info.file.name} 文件上传成功`);
console.log(info.file.response)
if(Array.isArray(fileImageList)){
setFileImageList([...fileImageList, info.file.response.data])
// 设置传输数据
setProductDescription({
video: [],
image: [...fileImageList, info.file.response.data],
word: []
})
}else{
setFileImageList([info.file.response.data])
// 设置传输数据
setProductDescription({
video: [],
image: [info.file.response.data],
word: []
})
}
} else if (info.file.status === 'error') {
message.error(`${info.file.name} 文件上传失败`);
}
},
}
const handleDeleteImage = (_index: number) => {
console.log(_index, '删除的图片索引')
let imageArr = [...fileImageList]
imageArr.splice(_index, 1)
setFileImageList(imageArr)
}
return (<>
<div className={styles.cloudContainer}>
<h3 className="commonPanelTitle" style={{marginBottom: 16}}>商品特色</h3>
<Input placeholder="原产地描述" />
{
fileImageList?.length > 0
?
fileImageList.map((item, index)=> <div key={index} className={cx(styles.cloudDescriptBox, styles.cloudMediaContentBox)}>
<p className={styles.cloudDivImage}><img src={item} /></p>
<div className={styles.cloudRightBtn}>
<Button size="small" onClick={()=>handleDeleteImage(index)} icon={<DeleteOutlined />} />
</div>
</div>
)
:
<div className={styles.cloudDescriptBox}>
<div className={styles.cloudMiddleAddBtn}>
<Upload {...uploadImgProps}>
<Button size="small" type="text">
<PlusOutlined />
</Button>
<br/>
<span>添加图片</span>
</Upload>
</div>
</div>
}
</div>
</>)
}
export default observer(ProductDescFormCloud)
\ No newline at end of file
......@@ -15,7 +15,7 @@ export interface Iprops {
import { inject, observer } from 'mobx-react'
import { store } from '@/store'
const ProductDescFormOne: React.FC<Iprops> = (props) => {
const ProductDescFormDefualt: React.FC<Iprops> = (props) => {
const [fileImageList, setFileImageList] = useState<any>([])
const [videoList, setVideoList] = useState<any>([])
......@@ -180,4 +180,4 @@ const ProductDescFormOne: React.FC<Iprops> = (props) => {
</>)
}
export default observer(ProductDescFormOne)
\ No newline at end of file
export default observer(ProductDescFormDefualt)
\ No newline at end of file
......@@ -149,7 +149,7 @@ const AddBrand: React.FC<{}> = () => {
//@ts-ignore
PublicApi.postProductBrandApplyCheckBrand({id: responseId}).then(res=>{
setCurrentStep(1)
setTimeout(()=>{
setTimeout(() => {
history.goBack()
},1000)
})
......@@ -263,10 +263,10 @@ const AddBrand: React.FC<{}> = () => {
<Space direction="vertical" style={{width:'100%'}}>
<Card headStyle={{borderBottom:'none'}} title={tips}>
<Row>
<Col span={2}>
{/* <Col span={2}>
<div>横版</div>
</Col>
<Col span={22}>
</Col> */}
<Col span={24}>
<Form.Item
name="proveUrl"
// valuePropName="fileList"
......
......@@ -142,12 +142,14 @@ const Trademark: React.FC<{}> = () => {
const handelDelete = (record: any) => {
PublicApi.postProductBrandDeleteBrand({ id: record.id }).then(res => {
if(res.code === 1000)
ref.current.reload()
})
}
const handleApplyCheck = (record:any) => {
PublicApi.postProductBrandApplyCheckBrand({id: record.id}).then(res=>{
ref.current.reload()
ref.current.reload()
})
}
......
import {action, computed, observable, runInAction} from 'mobx'
import { IChannelProductModule } from '@/module/channelProductModule'; // mobx要用到的数据类型
import { GetProductChannelCommodityGetCommodityListResponseDetail, GetProductChannelCommodityGetCommodityUnitPriceResponse } from '@/services';
/**
* 渠道直采商品
......@@ -7,12 +8,13 @@ import { IChannelProductModule } from '@/module/channelProductModule'; // mobx
class ChannelProductStore implements IChannelProductModule {
// 选择商品区块
@observable public productSelectRowInStore: any = null;
@observable public productSelectRowInStore: GetProductChannelCommodityGetCommodityListResponseDetail = null;
@observable public priceType: number = null
@observable public productName: string = null
@observable public currentActiveKey: string = '1'
@observable public currentOperateChannel: string = null
@observable public tableDataInSetPrice: GetProductChannelCommodityGetCommodityUnitPriceResponse[] = null
// 加工接口返回的数据,用户编辑回显数据
// @computed
......@@ -23,7 +25,7 @@ class ChannelProductStore implements IChannelProductModule {
// }
@action.bound
public setProductSelectRowInStore(data: any) {
public setProductSelectRowInStore(data: GetProductChannelCommodityGetCommodityListResponseDetail) {
this.productSelectRowInStore = data;
}
......@@ -47,6 +49,11 @@ class ChannelProductStore implements IChannelProductModule {
this.currentOperateChannel = data;
}
@action.bound
public setTableDataInSetPrice(data: GetProductChannelCommodityGetCommodityUnitPriceResponse[]){
this.tableDataInSetPrice = data;
}
}
export default ChannelProductStore
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