Commit 680e09e8 authored by GuanHua's avatar GuanHua

fix:商品类型筛选问题

parent b9e486a5
...@@ -34,9 +34,9 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -34,9 +34,9 @@ const Category: React.FC<CategoryPropsType> = (props) => {
setLastCategoryId(null) setLastCategoryId(null)
setSelectAttrbuteList([]) setSelectAttrbuteList([])
} else { } else {
let initKeys = [] const initKeys = []
// let initAttrKeys = [] // let initAttrKeys = []
for (let item of filterList) { for (const item of filterList) {
if (item.type === FILTER_TYPE.category) { if (item.type === FILTER_TYPE.category) {
initKeys.push(String(item.key)) initKeys.push(String(item.key))
} }
...@@ -50,7 +50,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -50,7 +50,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
useEffect(() => { useEffect(() => {
let getCategoryListFn let getCategoryListFn
let param: any = {} const param: any = {}
let headers = {} let headers = {}
/** /**
* 根据不通过的页面类型,请求不同的品类接口 * 根据不通过的页面类型,请求不同的品类接口
...@@ -105,7 +105,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -105,7 +105,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
useEffect(() => { useEffect(() => {
if (lastCategoryId) { if (lastCategoryId) {
let param: any = { const param: any = {
categoryId: lastCategoryId categoryId: lastCategoryId
} }
let getAttributeFn let getAttributeFn
...@@ -160,8 +160,8 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -160,8 +160,8 @@ const Category: React.FC<CategoryPropsType> = (props) => {
if (!list) { if (!list) {
return [] return []
} }
let initExpandKeys = [] const initExpandKeys = []
let result: any = list.map(item => { const result: any = list.map(item => {
initExpandKeys.push(item.id) initExpandKeys.push(item.id)
return { return {
title: item.title, title: item.title,
...@@ -200,7 +200,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -200,7 +200,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
setAttributeList([]) setAttributeList([])
onFilter({ onFilter({
type: FILTER_TYPE.attribute, type: FILTER_TYPE.attribute,
key: [], key: null,
title: `` title: ``
}) })
} }
...@@ -217,12 +217,12 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -217,12 +217,12 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const getDetailById = (attrId, attrValId, state = 2) => { const getDetailById = (attrId, attrValId, state = 2) => {
let detail = {} let detail = {}
for (let item of attributeList) { for (const item of attributeList) {
if (item.id === attrId) { if (item.id === attrId) {
if (state === 1) { if (state === 1) {
detail = item detail = item
} else { } else {
for (let childItem of item.attributeValueList) { for (const childItem of item.attributeValueList) {
if (childItem.value === attrValId) { if (childItem.value === attrValId) {
detail = childItem detail = childItem
} }
...@@ -235,7 +235,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -235,7 +235,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const getSelectAttributeList = (selectList) => { const getSelectAttributeList = (selectList) => {
let ids = [] let ids = []
for (let item of selectList) { for (const item of selectList) {
ids = [...ids, ...item.customerAttributeValueList.map(childItem => childItem.id)] ids = [...ids, ...item.customerAttributeValueList.map(childItem => childItem.id)]
} }
return ids return ids
...@@ -243,12 +243,12 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -243,12 +243,12 @@ const Category: React.FC<CategoryPropsType> = (props) => {
const handleChange = (attrId, checkedList) => { const handleChange = (attrId, checkedList) => {
let tempSelect = [...initSelectAttributeList] let tempSelect = [...initSelectAttributeList]
let attrInfo: any = getDetailById(attrId, attrId, 1) const attrInfo: any = getDetailById(attrId, attrId, 1)
let tempItem = { const tempItem = {
customerAttributeId: attrId, customerAttributeId: attrId,
customerAttributeName: attrInfo.name, customerAttributeName: attrInfo.name,
customerAttributeValueList: checkedList.map(item => { customerAttributeValueList: checkedList.map(item => {
let detail: any = getDetailById(attrId, item) const detail: any = getDetailById(attrId, item)
return { return {
id: detail.value, id: detail.value,
name: detail.label name: detail.label
...@@ -268,7 +268,7 @@ const Category: React.FC<CategoryPropsType> = (props) => { ...@@ -268,7 +268,7 @@ const Category: React.FC<CategoryPropsType> = (props) => {
tempSelect.push(tempItem) tempSelect.push(tempItem)
} }
let keys = getSelectAttributeList(tempSelect) const keys = getSelectAttributeList(tempSelect)
setSelectAttrbuteList(keys) setSelectAttrbuteList(keys)
tempSelect = tempSelect.filter(item => item.customerAttributeValueList.length > 0) tempSelect = tempSelect.filter(item => item.customerAttributeValueList.length > 0)
onFilter({ onFilter({
......
...@@ -27,8 +27,8 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => { ...@@ -27,8 +27,8 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => {
if (isEmpty(filterList)) { if (isEmpty(filterList)) {
setSelectKeys([]) setSelectKeys([])
} else { } else {
let initKeys = [] const initKeys = []
for (let item of filterList) { for (const item of filterList) {
if (item.type === FILTER_TYPE.commodityType) { if (item.type === FILTER_TYPE.commodityType) {
initKeys.push(Number(item.key)) initKeys.push(Number(item.key))
} }
...@@ -54,7 +54,7 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => { ...@@ -54,7 +54,7 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => {
} else { } else {
onFilter({ onFilter({
type: FILTER_TYPE.commodityType, type: FILTER_TYPE.commodityType,
key: [], key: false,
title: '' title: ''
}) })
} }
...@@ -62,7 +62,7 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => { ...@@ -62,7 +62,7 @@ const CommodityType: React.FC<CommodityTypePropsType> = (props) => {
const getItemText = (key: number) => { const getItemText = (key: number) => {
let result = "" let result = ""
for (let item of styleOptions) { for (const item of styleOptions) {
if (item.value === key) { if (item.value === key) {
result = item.label result = item.label
} }
......
...@@ -3,7 +3,7 @@ import { PublicApi } from '@/services/api' ...@@ -3,7 +3,7 @@ import { PublicApi } from '@/services/api'
import { FILTER_TYPE } from '@/constants' import { FILTER_TYPE } from '@/constants'
interface FilterValueType { interface FilterValueType {
key: string | string[] | number; key: any;
title: string; title: string;
type: FILTER_TYPE; type: FILTER_TYPE;
} }
......
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