@@ -402,13 +404,14 @@ const DictPage: React.FC = () => {
}
}}
>
-
} disabled={!selectedDict}>
+
} disabled={!selectedDict}>
导入字典项
@@ -418,6 +421,7 @@ const DictPage: React.FC = () => {
columns={dictItemColumns}
rowKey="id"
loading={loadingDictItems}
+ size="small"
/>
diff --git a/src/pages/Product/Attribute/consts.ts b/src/pages/Product/Attribute/consts.ts
new file mode 100644
index 0000000..fd4af07
--- /dev/null
+++ b/src/pages/Product/Attribute/consts.ts
@@ -0,0 +1,2 @@
+// 中文注释:限定允许管理的字典名称集合
+export const allowedDictNames = new Set(['brand', 'strength', 'flavor', 'size', 'humidity']);
\ No newline at end of file
diff --git a/src/pages/Product/Attribute/index.tsx b/src/pages/Product/Attribute/index.tsx
index fc1dae5..8c4d9dc 100644
--- a/src/pages/Product/Attribute/index.tsx
+++ b/src/pages/Product/Attribute/index.tsx
@@ -6,8 +6,7 @@ import React, { useEffect, useState } from 'react';
const { Sider, Content } = Layout;
-// 中文注释:限定允许管理的字典名称集合
-const allowedDictNames = new Set(['brand', 'strength', 'flavor', 'size', 'humidity']);
+import { allowedDictNames } from './consts';
const AttributePage: React.FC = () => {
// 中文注释:左侧字典列表状态
diff --git a/src/pages/Product/List/index.tsx b/src/pages/Product/List/index.tsx
index 889f1ba..c23ee0f 100644
--- a/src/pages/Product/List/index.tsx
+++ b/src/pages/Product/List/index.tsx
@@ -1,5 +1,6 @@
import {
productcontrollerCreateproduct,
+ productcontrollerCompatsizeall,
productcontrollerDeleteproduct,
productcontrollerCompatbrandall,
productcontrollerCompatflavorsall,
@@ -27,7 +28,8 @@ import {
ProFormTextArea,
ProTable,
} from '@ant-design/pro-components';
-import { App, Button, Popconfirm } from 'antd';
+import { App, Button, Popconfirm, Tag } from 'antd';
+import { allowedDictNames } from '@/pages/Product/Attribute/consts';
import React, { useRef, useState } from 'react';
const capitalize = (s: string) => s.charAt(0).toLocaleUpperCase() + s.slice(1);
// TODO
@@ -67,6 +69,50 @@ const NameCn: React.FC<{
/>
);
};
+
+const AttributesCell: React.FC<{ record: any }> = ({ record }) => {
+ const items: { key: string; value: string }[] = [];
+ // 中文注释:按允许的属性集合收集展示值
+ if (allowedDictNames.has('brand') && record?.brand?.name) items.push({ key: '品牌', value: record.brand.name });
+ if (allowedDictNames.has('strength') && record?.strength?.name) items.push({ key: '强度', value: record.strength.name });
+ if (allowedDictNames.has('flavor') && record?.flavors?.name) items.push({ key: '口味', value: record.flavors.name });
+ if (allowedDictNames.has('size') && record?.size?.name) items.push({ key: '规格', value: record.size.name });
+ if (allowedDictNames.has('humidity') && record?.humidity) items.push({ key: '湿度', value: record.humidity });
+ return (
+
+ {items.length ? items.map((it, idx) => (
+
+ {it.key}: {it.value}
+
+ )) : -}
+
+ );
+};
+
+
+const ComponentsCell: React.FC<{ productId: number }> = ({ productId }) => {
+ const [items, setItems] = React.useState
([]);
+ React.useEffect(() => {
+ (async () => {
+ const { data = [] } = await productcontrollerGetproductcomponents({ id: productId });
+ setItems(data || []);
+ })();
+ }, [productId]);
+ return (
+
+ {items && items.length ? (
+ items.map((c: any) => (
+
+ {(c.stock && c.stock.productSku) || `#${c.stockId}`} × {c.quantity}(库存:{c.stock ? c.stock.quantity : '-'})
+
+ ))
+ ) : (
+ -
+ )}
+
+ );
+};
+
const List: React.FC = () => {
const actionRef = useRef();
// 状态:存储当前选中的行
@@ -102,32 +148,23 @@ const List: React.FC = () => {
hideInSearch: true,
},
{
- title: '库存',
- dataIndex: 'stock',
+ title: '属性',
+ dataIndex: 'attributes',
hideInSearch: true,
+ render: (_, record) => ,
},
+ {
+ title: '构成',
+ dataIndex: 'components',
+ hideInSearch: true,
+ render: (_, record) => ,
+ },
+
{
title: '描述',
dataIndex: 'description',
hideInSearch: true,
},
- {
- title: '品牌',
- dataIndex: 'brand.name',
- },
- {
- title: '强度',
- dataIndex: 'strength.name',
- },
- {
- title: '口味',
- dataIndex: 'flavors.name',
- },
- {
- title: '湿度',
- dataIndex: 'humidity',
- },
-
{
title: '更新时间',
dataIndex: 'updatedAt',
@@ -163,7 +200,7 @@ const List: React.FC = () => {
}
}}
>
-