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

fix: 处理品类属性树切换会调用两次接口的问题

parent 57d0f452
......@@ -88,6 +88,7 @@ const CategoryAttributes: React.FC<{}> = () => {
const [selectedTableRowKeys, setSelectedTableRowKeys] = useState<Array<number>>([]) //表格选择
const [linkTableRowData, setLinkTableRowData] = useState<any[]>([])
const [goodsRowSelection, goodsRowCtl] = useRowSelectionTable()
const flag = useRef<boolean>(false) // 标识 初始点击品类不执行effect的重载表格
const {
treeStatus,
......@@ -107,12 +108,17 @@ const CategoryAttributes: React.FC<{}> = () => {
// 获取选中项的关联属性列表
useEffect(() => {
if (selectKey)
if (selectKey && flag.current) {
ref.current.reload()
// ref.current.reload({ current: 1, pageSize: 10, name: '', categoryId: selectKey, isByCategory: true })
} else if(!selectKey) {
flag.current = false
} else {
flag.current = true
}
}, [selectKey])
const fetchLinkAttributeData = (params: any) => {
console.log(1)
return new Promise((resolve, reject) => {
getProductCustomerGetCustomerCategoryAttributeList({
...params,
......@@ -128,6 +134,7 @@ const CategoryAttributes: React.FC<{}> = () => {
// 获取所有属性列表
const fetchAttributeData = (params: any) => {
console.log(2)
return new Promise((resolve, reject) => {
getProductCustomerGetCustomerCategoryAttributeList({
...params,
......
......@@ -95,6 +95,7 @@ const PropertyValue: React.FC<{}> = () => {
// const [selectRow, setSelectRow] = useState<any[]>([]) // 模态框选择的行数据
// const [selectedRowKeys, setSelectedRowKeys] = useState<Array<string>>([])
const [rowSelection, rowSelectionCtl] = useRowSelectionTable({ customKey: 'id' })
const flag = useRef<boolean>(false) // 标识 初始点击品类不执行effect的重载表格
const {
treeData,
......@@ -119,8 +120,12 @@ const PropertyValue: React.FC<{}> = () => {
}, [])
useEffect(() => {
if (selectKey) {
if (selectKey && flag.current) {
ref.current.reload({ current: 1, pageSize: 10, name: '', customerAttributeId: selectKey })
} else if(!selectKey) {
flag.current = false
} else {
flag.current = true
}
}, [selectKey])
......@@ -217,7 +222,7 @@ const PropertyValue: React.FC<{}> = () => {
type='link'
onClick={() => history.push(`/memberCenter/commodityAbility/classAndProperty/propertyValue/edit?attrId=${selectKey}&attrName=${record.customerAttribute.name}&attrValueId=${record.id}`)}
>
{intl.formatMessage({ id: 'classAndProperty.propertyValue.columns.option.button.1' })}
{intl.formatMessage({ id: 'classAndProperty.propertyValue.columns.button.1' })}
</Button>
<Popconfirm
title={intl.formatMessage({ id: 'classAndProperty.propertyValue.columns.button.2.popconfirm.title' })}
......
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