forked from yoone/WEB
1
0
Fork 0

refactor(api): 简化API参数处理逻辑

fix(订单列表): 调整物流信息显示样式为垂直布局
feat(产品列表): 添加组合商品构成组件显示
refactor(产品编辑): 修改SKU查询逻辑并更新字段标签
style(产品同步): 调整SKU生成格式并添加调试日志
This commit is contained in:
tikkhun 2026-01-06 18:50:59 +08:00
parent 82c1bfa711
commit 4fd9cfee75
8 changed files with 132 additions and 123 deletions

View File

@ -275,9 +275,9 @@ const ListPage: React.FC = () => {
{(record as any)?.fulfillments?.map((item: any) => {
if (!item) return;
return (
<div style={{ display:"flex", alignItems:"center" }}>
{item.tracking_provider}
{item.tracking_number}
<div style={{ display:"flex", alignItems:"center",'flexDirection':'column' }}>
<span>: {item.shipping_provider}</span>
<span>: {item.tracking_number}</span>
</div>
);
})}

View File

@ -3,6 +3,7 @@ import {
productcontrollerGetcategoriesall,
productcontrollerGetcategoryattributes,
productcontrollerGetproductcomponents,
productcontrollerGetproductlist,
productcontrollerGetproductsiteskus,
productcontrollerUpdateproduct,
} from '@/servers/api/product';
@ -315,17 +316,17 @@ const EditForm: React.FC<{
<ProForm.Group>
<ProFormSelect
name="sku"
label="库存SKU"
label="单品SKU"
width="md"
showSearch
debounceTime={300}
placeholder="请输入库存SKU"
rules={[{ required: true, message: '请输入库存SKU' }]}
placeholder="请输入单品SKU"
rules={[{ required: true, message: '请输入单品SKU' }]}
request={async ({ keyWords }) => {
const params = keyWords
? { sku: keyWords, name: keyWords }
: { pageSize: 9999 };
const { data } = await getStocks(params as any);
? { where: {sku: keyWords, name: keyWords, type: 'single'} }
: { 'per_page': 9999 , where: {type: 'single'} };
const { data } = await productcontrollerGetproductlist(params);
if (!data || !data.items) {
return [];
}

View File

@ -95,14 +95,15 @@ const SyncToSiteModal: React.FC<SyncToSiteModalProps> = ({
}
}}
onFinish={async (values) => {
console.log(`values`,values)
if (!values.siteId) return false;
try {
const siteSkusMap = values.siteSkus || {};
const data = products.map((product) => ({
productId: product.id,
siteSku: siteSkusMap[product.id] || `${values.siteId}_${product.sku}`,
siteSku: siteSkusMap[product.id] || `${values.siteId}-${product.sku}`,
}));
console.log(`data`,data)
const result = await productcontrollerBatchsynctosite({
siteId: values.siteId,
data,
@ -130,7 +131,7 @@ const SyncToSiteModal: React.FC<SyncToSiteModalProps> = ({
<div style={{ display: 'flex', gap: 8, alignItems: 'center', marginBottom: 8 }}>
<div style={{ minWidth: 220 }}>SKU: {row.sku || '-'}</div>
<div style={{ minWidth: 150 }}>
SKU:{' '}
SKU:{' '}
{row.siteSkus && row.siteSkus.length > 0
? row.siteSkus.map((siteSku: string, idx: number) => (
<Tag key={idx} color="cyan">

View File

@ -0,0 +1,53 @@
import React from "react";
import { ProTable, ProColumns } from "@ant-design/pro-components";
interface ProductComponentListProps {
record: API.Product;
columns: ProColumns<API.Product>[];
dataSource?: API.Product[];
}
const ProductComponentList: React.FC<ProductComponentListProps> = ({ record, columns, dataSource }) => {
if (record.type !== "bundle" || !record.components || record.components.length === 0) {
return null;
}
const componentSkus = record.components.map(component => component.sku);
const includedProducts = [];
if (dataSource) {
includedProducts = dataSource
.filter(product => product.type === "single" && componentSkus.includes(product.sku));
}
if (includedProducts.length === 0) {
return (
<div style={{ padding: "16px", textAlign: "center", color: "#999" }}>
</div>
);
}
const componentColumns = columns.filter(col =>
[200~cd ../api"option", "siteSkus", "category", "type"].includes(col.dataIndex as string)
);
return (
<div style={{ padding: "8px 16px", backgroundColor: "#fafafa" }}>
<ProTable
dataSource={includedProducts}
columns={componentColumns}
pagination={false}
rowKey="id"
bordered
size="small"
scroll={{ x: "max-content" }}
headerTitle={null}
toolBarRender={false}
/>
</div>
);
};
export default ProductComponentList;

View File

@ -67,16 +67,7 @@ const AttributesCell: React.FC<{ record: any }> = ({ record }) => {
);
};
const ComponentsCell: React.FC<{ productId: number }> = ({ productId }) => {
const [components, setComponents] = React.useState<any[]>([]);
React.useEffect(() => {
(async () => {
const { data = [] } = await productcontrollerGetproductcomponents({
id: productId,
});
setComponents(data || []);
})();
}, [productId]);
const ComponentsCell: React.FC<{ components?: any[] }> = ({ components }) => {
return (
<div>
{components && components.length ? (
@ -163,7 +154,28 @@ const BatchEditModal: React.FC<{
</ModalForm>
);
};
const ProductList = ({ filter, columns }: { filter: { skus: string[] },columns: any[] }) => {
return (
<ProTable
request={async (pag) => {
const { data, success } = await productcontrollerGetproductlist({
where: filter
});
if (!success) return [];
return data || [];
}}
columns={columns}
pagination={false}
rowKey="id"
bordered
size="small"
scroll={{ x: "max-content" }}
headerTitle={null}
toolBarRender={false}
/>
);
};
const List: React.FC = () => {
const actionRef = useRef<ActionType>();
@ -282,7 +294,7 @@ const List: React.FC = () => {
title: '构成',
dataIndex: 'components',
hideInSearch: true,
render: (_, record) => <ComponentsCell productId={(record as any).id} />,
render: (_, record) => <ComponentsCell components={record.components} />,
},
{
@ -509,15 +521,16 @@ const List: React.FC = () => {
}}
columns={columns}
// expandable={{
// expandedRowRender: (record) => (
// <SiteProductInfo
// skus={(record.siteSkus as string[]) || []}
// record={record}
// parentTableRef={actionRef}
// />
// ),
// expandedRowRender: (record) => {
// return <ProductList filter={{
// skus: record.components?.map(component => component.sku) || [],
// }}
// columns={columns}
// ></ProductList>
// }
// ,
// rowExpandable: (record) =>
// !!(record.siteSkus && record.siteSkus.length > 0),
// !!(record.type==='bundle'),
// }}
editable={{
type: 'single',
@ -553,4 +566,5 @@ const List: React.FC = () => {
);
};
export default List;

View File

@ -588,10 +588,6 @@ export async function productcontrollerGetproductlist(
method: 'GET',
params: {
...params,
where: undefined,
...params['where'],
orderBy: undefined,
...params['orderBy'],
},
...(options || {}),
});

View File

@ -15,10 +15,6 @@ export async function siteapicontrollerGetcustomers(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
},
@ -74,10 +70,6 @@ export async function siteapicontrollerExportcustomers(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -127,10 +119,6 @@ export async function siteapicontrollerGetmedia(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -210,10 +198,6 @@ export async function siteapicontrollerExportmedia(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -230,10 +214,6 @@ export async function siteapicontrollerGetorders(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -313,10 +293,6 @@ export async function siteapicontrollerExportorders(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -354,10 +330,6 @@ export async function siteapicontrollerGetproducts(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
},
@ -438,10 +410,6 @@ export async function siteapicontrollerExportproducts(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -458,10 +426,6 @@ export async function siteapicontrollerExportproductsspecial(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -540,10 +504,6 @@ export async function siteapicontrollerGetreviews(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
},
@ -582,10 +542,6 @@ export async function siteapicontrollerGetsubscriptions(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
},
@ -603,10 +559,6 @@ export async function siteapicontrollerExportsubscriptions(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -623,10 +575,6 @@ export async function siteapicontrollerGetwebhooks(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
});
@ -720,10 +668,6 @@ export async function siteapicontrollerGetcustomerorders(
method: 'GET',
params: {
...queryParams,
where: undefined,
...queryParams['where'],
orderBy: undefined,
...queryParams['orderBy'],
},
...(options || {}),
},

View File

@ -1189,9 +1189,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
};
type productcontrollerGetproductsiteskusParams = {
@ -1717,9 +1717,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1735,9 +1735,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1753,9 +1753,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1771,9 +1771,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1789,9 +1789,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1807,9 +1807,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1830,9 +1830,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
customerId: number;
siteId: number;
};
@ -1854,9 +1854,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1876,9 +1876,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1904,9 +1904,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1932,9 +1932,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1950,9 +1950,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1968,9 +1968,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -1991,9 +1991,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
siteId: number;
};
@ -2942,9 +2942,9 @@ declare namespace API {
/** 搜索关键词 */
search?: string;
/** 过滤条件对象 */
where?: Record<string, any>;
where?: any;
/** 排序对象,例如 { "sku": "desc" } */
orderBy?: Record<string, any>;
orderBy?: any;
};
type UnifiedShippingLineDTO = {