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

fix:商品筛选价格区间输入问题、新建货品品类问题、新建商品多级品类显示错误问题

parent 779c8859
......@@ -13,6 +13,7 @@ export interface IChannel {
export interface IChannelProductModule {
productSelectRowInStore: GetProductChannelCommodityGetCommodityListResponseDetail;
productSourceInStore: number;
priceType: number;
productName: string;
currentActiveKey: string;
......@@ -21,6 +22,7 @@ export interface IChannelProductModule {
tableDataInSetPrice: GetProductChannelCommodityGetCommodityUnitPriceResponse[];
setProductSelectRowInStore(data: GetProductChannelCommodityGetCommodityListResponseDetail): void;
setProductSourceInStore(data: number): void;
setPriceType(data: number): void;
setProductName(data: string): void;
setCurrentActiveKey(data: string): void;
......
import React, { useState, useEffect } from 'react';
import { Form, Input, Button, Select, Card, Tooltip, message, InputNumber, Popconfirm } from 'antd'
import { Form, Input, Button, Select, Card, Tooltip, message, InputNumber, Popconfirm, Spin, Cascader } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import { history } from 'umi';
import {
......@@ -8,6 +8,7 @@ import {
import ReutrnEle from '@/components/ReturnEle';
import styles from './index.less'
import { PublicApi } from '@/services/api';
import { GetProductCustomerGetCustomerCategoryTreeResponse } from '@/services';
const { Option } = Select;
const layout = {
......@@ -35,15 +36,30 @@ const AddGoods = () => {
const [unitValue, setUnitValue] = useState(undefined)
const [queryId, setQueryId] = useState<number>(null)
const [isSee, setIsSee] = useState(false)
const [customerCategoryTree, setCustomerCategoryTree] = useState<GetProductCustomerGetCustomerCategoryTreeResponse>()
const [formData, setFormData] = useState<any>()
useEffect(() => {
const { id, isSee } = history.location.query
// 获取品类树
PublicApi.getProductCustomerGetCustomerCategoryTree().then(res => {
if (res.code === 1000){
// 过滤children空数组
let { data } = res
data.map(item => {
if(!item.children.length)
delete item.children
})
setCustomerCategoryTree(data)
}
})
if(id){
setQueryId(id)
PublicApi.getProductSelectGetSelectCustomerCategory({name: ''}).then(res=>{
if(res.code === 1000)
setClassData(res.data)
})
// PublicApi.getProductSelectGetSelectCustomerCategory({name: ''}).then(res=>{
// if(res.code === 1000)
// setClassData(res.data)
// })
PublicApi.getProductSelectGetSelectCnUnit({name: ''}).then(res=>{
if(res.code === 1000)
setUnitData(res.data)
......@@ -53,12 +69,18 @@ const AddGoods = () => {
setBrandData(res.data)
})
PublicApi.getProductGoodsGetGoods({id: id}).then(res=>{
if(res.code===1000)
form.setFieldsValue(res.data)
if(res.code===1000){
const { data } = res
let initFormValue = { ...data }
// @ts-ignore
initFormValue.customerCategory.id = initFormValue.customerCategory.fullId.split('.').map(item => Number(item) + '')
form.setFieldsValue(initFormValue)
}
})
if(isSee)
setIsSee(isSee)
}
}, [])
const handleBrandSearch = (value?:any) => { // end value
......@@ -90,11 +112,13 @@ const AddGoods = () => {
}
const onFinish = (values:any) => {
let v = values.customerCategory.id
values.customerCategory = { id: v[v.length - 1] }
PublicApi.postProductGoodsSaveOrUpdateGoods({...values, id: queryId?queryId:null}).then(res => {
if(res.code === 1000)
history.goBack()
})
};
}
return (<PageHeaderWrapper
onBack={() => history.goBack()}
......@@ -150,7 +174,7 @@ const AddGoods = () => {
>
<Input placeholder="最长20个字符" maxLength={20} disabled={isSee} />
</Form.Item>
<Form.Item
{/* <Form.Item
name={['customerCategory', 'id']}
label="品类"
rules={[
......@@ -160,7 +184,6 @@ const AddGoods = () => {
},
]}
>
{/* <Input placeholder="最长24个字符、12个汉字" /> */}
<Select
showSearch={true}
showArrow={true}
......@@ -177,6 +200,23 @@ const AddGoods = () => {
>
{classData.map(d => <Option value={d.id} key={d.id}>{d.name}</Option>)}
</Select>
</Form.Item> */}
<Form.Item
name={['customerCategory', 'id']}
label="品类"
rules={[
{
required: true,
message: '请选择品类'
},
]}
>
<Cascader
options={customerCategoryTree}
fieldNames={{ label: 'title', value: 'id', children: 'children' }}
placeholder="请选择品类"
notFoundContent={<Spin size="small" />}
/>
</Form.Item>
<Form.Item
name={['brand', 'id']}
......
......@@ -61,8 +61,9 @@ const SelectChannel:React.FC<IProps> = (props) => {
const { ChannelProudctStore } = store
const {
priceType,
productName,
priceType,
productName,
productSourceInStore,
productSelectRowInStore,
setCurrentActiveKey,
setCurrentOperateChannel,
......@@ -194,6 +195,7 @@ const SelectChannel:React.FC<IProps> = (props) => {
status: item.status
})
})
params.source = productSourceInStore
params.memberList = _memberList
params.commodityId = productSelectRowInStore.id
params.channelMemberRoleName = selectedRole.children
......
......@@ -46,7 +46,7 @@ const SelectProduct:React.FC<IProps> = (props) => {
const [selectProduct, setSelectProduct] = useState<GetProductChannelCommodityGetCommodityListResponseDetail[]>()
const { ChannelProudctStore } = store
const { setProductSelectRowInStore, setPriceType, setProductName } = ChannelProudctStore
const { setProductSourceInStore, setProductSelectRowInStore, setPriceType, setProductName } = ChannelProudctStore
const productColumns: ColumnType<any>[] = [
{
......@@ -160,6 +160,7 @@ const SelectProduct:React.FC<IProps> = (props) => {
}
const handleSourceChange = (v:any) => {
setProductSourceInStore(v.target.value)
setSource(v.target.value)
setSelectProduct([])
}
......
import React, {useState, useRef, useEffect} from 'react'
import { history } from 'umi';
import { Button, Form, Card, Tabs } from 'antd'
import { Button, Form, Card, Tabs, Steps } from 'antd'
import { PageHeaderWrapper } from '@ant-design/pro-layout'
import {
PlusOutlined,
......@@ -20,6 +20,21 @@ import { PublicApi } from '@/services/api';
const { TabPane } = Tabs
const steps = [
{
title: 'First',
content: 'First-content',
},
{
title: 'Second',
content: 'Second-content',
},
{
title: 'Last',
content: 'Last-content',
},
];
const AddDirectChannel:React.FC<{}> = (props) => {
const [queryId, setQueryId] = useState<number>()
......@@ -44,8 +59,6 @@ const AddDirectChannel:React.FC<{}> = (props) => {
}
}, [])
const callback = (key: string) => {
console.log(key)
setCurrentActiveKey(key)
......@@ -105,6 +118,31 @@ const AddDirectChannel:React.FC<{}> = (props) => {
/>
</TabPane>
</Tabs>
{/* <Steps current={0}>
{steps.map(item => (
<Step key={item.title} title={item.title} />
))}
</Steps>
<div className="steps-content">{steps[current].content}</div>
<div className="steps-action">
{current < steps.length - 1 && (
<Button type="primary" onClick={() => this.next()}>
Next
</Button>
)}
{current === steps.length - 1 && (
<Button type="primary" onClick={() => message.success('Processing complete!')}>
Done
</Button>
)}
{current > 0 && (
<Button style={{ margin: '0 8px' }} onClick={() => this.prev()}>
Previous
</Button>
)}
</div> */}
</Card>
</PageHeaderWrapper>)
}
......
......@@ -135,8 +135,8 @@ const BasicInfoForm: React.FC<Iprops> = (props) => {
}
const onCustomerCategoryChange = (value: any) => {
let seletCategoryId = value[1] || value[0]
console.log(seletCategoryId, 'seleellele')
let seletCategoryId = value[value.length - 1]
// console.log(seletCategoryId, value, 'seleellele')
if (seletCategoryId) {
PublicApi.getProductCustomerGetCustomerCategoryById({ id: seletCategoryId }).then(res => {
const { data } = res
......
......@@ -286,27 +286,36 @@ const FastModifyPrice: React.FC<{}> = () => {
ref.current.reload(obj)
}
// 校验阶梯范围
const validatorNumberRange = (rule, value, callback) => {
try {
if(Array.isArray(value)){
let range = value.map(item => {
if(item)
return Object.values(item.numberRange)
}).reduce(
function(a, b) {
return a.concat(b);
},
[]
)
let result = range.reduce((a, b) => { if(a<b) return b })
if(!result) throw new Error('请正确输入阶梯数量范围');
callback()
}
} catch (err) {
callback(err)
// 校验阶梯范围
const validatorNumberRange = (rule, value, callback) => {
try {
if(Array.isArray(value)){
let range = value.map(item => {
if(item)
return Object.values(item.numberRange)
}).reduce(
function(a, b) {
return a.concat(b);
},
[]
)
let result = range.reduce((a, b) => { if(a<b) return b })
if(!result) throw new Error('请正确输入阶梯数量范围');
callback()
}
} catch (err) {
callback(err)
}
}
// 价格范围筛选处理
const onBlur = (v:any, param: string) => {
if(Number(v) < 0){
let _temp = {...filterParams}
_temp[param] = 0
setFilterParams(_temp)
}
}
return (
<PageHeaderWrapper>
......@@ -395,6 +404,7 @@ const FastModifyPrice: React.FC<{}> = () => {
value={filterParams.min}
placeholder="最低价格"
onChange={(e) => setFilterParams({ ...filterParams, min: +e.target.value })}
onBlur={(e)=>onBlur(e.target.value, 'min')}
/>
<Input
style={{
......@@ -419,6 +429,7 @@ const FastModifyPrice: React.FC<{}> = () => {
value={filterParams.max}
placeholder="最高价格"
onChange={(e) => setFilterParams({ ...filterParams, max: +e.target.value })}
onBlur={(e)=>onBlur(e.target.value, 'max')}
/>
</Input.Group>
</Col>
......
......@@ -551,6 +551,15 @@ const Products: React.FC<{}> = () => {
ref.current.reload(obj)
}
// 价格范围筛选处理
const onBlur = (v:any, param: string) => {
if(Number(v) < 0){
let _temp = {...filterParams}
_temp[param] = 0
setFilterParams(_temp)
}
}
const menuMore = (
<Menu onClick={(e) => handleMenuClick(e)}>
<Menu.Item key="1" icon={<DeleteOutlined />}>
......@@ -675,7 +684,8 @@ const Products: React.FC<{}> = () => {
style={{ width: '40%', textAlign: 'center' }}
min={0}
placeholder="最低价格"
onChange={(e)=>setFilterParams({...filterParams, min: +e.target.value})}
onChange={(e)=>setFilterParams({...filterParams, min: +e.target.value})}
onBlur={(e)=>onBlur(e.target.value, 'min')}
/>
<Input
style={{
......@@ -700,6 +710,7 @@ const Products: React.FC<{}> = () => {
min={0}
placeholder="最高价格"
onChange={(e)=>setFilterParams({...filterParams, max: +e.target.value})}
onBlur={(e)=>onBlur(e.target.value, 'max')}
/>
</Input.Group>
</Col>
......
......@@ -7,6 +7,7 @@ import { IChannelProductModule, IRole, IChannel } from '@/module/channelProductM
class ChannelProductStore implements IChannelProductModule {
// 选择商品区块
@observable public productSourceInStore: number = 1;
@observable public productSelectRowInStore: any = null;
@observable public priceType: number = null
@observable public productName: string = null
......@@ -25,6 +26,11 @@ class ChannelProductStore implements IChannelProductModule {
// }
@action.bound
public setProductSourceInStore(data: number) {
this.productSourceInStore = data;
}
@action.bound
public setProductSelectRowInStore(data: any) {
this.productSelectRowInStore = data;
}
......
......@@ -25,7 +25,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.parentId ? [this.productInfoByEdit?.customerCategory.parentId + '', this.productInfoByEdit?.customerCategory.id + ''] : [this.productInfoByEdit?.customerCategory.id + '']
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 + '']
}
}
......
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