分类图片上传和用户等级图片上传
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Tag, Typography } from 'antd';
|
||||
import { Tag, Typography, Image } from 'antd';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type ICustomerLevel from '@/domain/iCustomerLevel.ts';
|
||||
@@ -25,6 +25,7 @@ const CustomerLevelPage: React.FC = () => {
|
||||
dataIndex: 'name',
|
||||
valueType: 'text',
|
||||
required: true,
|
||||
align: 'center',
|
||||
rules: [{ required: true, message: '请输入等级名称' }],
|
||||
},
|
||||
{
|
||||
@@ -32,8 +33,34 @@ const CustomerLevelPage: React.FC = () => {
|
||||
dataIndex: 'sort',
|
||||
valueType: 'digit',
|
||||
hideInSearch: true,
|
||||
initialValue: 0,
|
||||
fieldProps: { min: 0 },
|
||||
},
|
||||
{
|
||||
title: '图片等级',
|
||||
dataIndex: 'icon',
|
||||
valueType: 'image',
|
||||
fieldProps: {
|
||||
action: '/customer/level/upload',
|
||||
mode: 'single',
|
||||
maxCount: 1,
|
||||
changeType: "id"
|
||||
},
|
||||
render: (_, record: ICustomerLevel) => {
|
||||
const url = record.icon_url
|
||||
if (!url) return '-';
|
||||
return (
|
||||
<Image
|
||||
src={url}
|
||||
width={60}
|
||||
height={60}
|
||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '状态',
|
||||
dataIndex: 'status',
|
||||
@@ -51,11 +78,11 @@ const CustomerLevelPage: React.FC = () => {
|
||||
},
|
||||
},
|
||||
{
|
||||
title: '备注',
|
||||
dataIndex: 'remark',
|
||||
valueType: 'textarea',
|
||||
title: '创建时间',
|
||||
dataIndex: 'updated_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
fieldProps: { rows: 2 },
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
@@ -74,6 +101,7 @@ const CustomerLevelPage: React.FC = () => {
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: 20 },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 640 },
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { Button, Space, Tag, Typography } from 'antd';
|
||||
import { NodeExpandOutlined } from '@ant-design/icons';
|
||||
import React, { useState } from 'react';
|
||||
import {Button, Image, Tag, Typography} from 'antd';
|
||||
import {NodeExpandOutlined} from '@ant-design/icons';
|
||||
import XinTable from '@/components/XinTable';
|
||||
import type { XinTableColumn, XinTableProps } from '@/components/XinTable/typings.ts';
|
||||
import type IProductCategory from '@/domain/iProductCategory.ts';
|
||||
@@ -36,17 +36,6 @@ const ProductCategoryPage: React.FC = () => {
|
||||
const [allIds, setAllIds] = useState<number[]>([]);
|
||||
const [categoryTree, setCategoryTree] = useState<IProductCategory[]>([]);
|
||||
|
||||
const loadTree = async () => {
|
||||
const res = await getCategoryTable();
|
||||
const tree = res.data.data ?? [];
|
||||
setCategoryTree(tree);
|
||||
setAllIds(collectAllIds(tree));
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
loadTree();
|
||||
}, []);
|
||||
|
||||
const columns: XinTableColumn<IProductCategory>[] = [
|
||||
{
|
||||
title: '分类名称',
|
||||
@@ -95,6 +84,45 @@ const ProductCategoryPage: React.FC = () => {
|
||||
},
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '分类图标',
|
||||
dataIndex: 'icon',
|
||||
valueType: 'image',
|
||||
fieldProps: {
|
||||
action: '/product/category/upload',
|
||||
mode: 'single',
|
||||
maxCount: 1,
|
||||
changeType: "id"
|
||||
},
|
||||
render: (_, record: IProductCategory) => {
|
||||
const url = record.icon_url
|
||||
if (!url) return '-';
|
||||
return (
|
||||
<Image
|
||||
src={url}
|
||||
width={60}
|
||||
height={60}
|
||||
style={{ objectFit: 'cover', borderRadius: 4 }}
|
||||
/>
|
||||
);
|
||||
},
|
||||
align: 'center',
|
||||
hideInSearch: true,
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'updated_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
{
|
||||
title: '创建时间',
|
||||
dataIndex: 'created_at',
|
||||
hideInForm: true,
|
||||
hideInSearch: true,
|
||||
align: 'center',
|
||||
},
|
||||
];
|
||||
|
||||
const tableProps: XinTableProps<IProductCategory> = {
|
||||
@@ -115,9 +143,22 @@ const ProductCategoryPage: React.FC = () => {
|
||||
expandedRowKeys: expandedKeys,
|
||||
onExpandedRowsChange: (keys) => setExpandedKeys([...keys] as number[]),
|
||||
},
|
||||
actionBarRender: (dom) => [
|
||||
dom.add,
|
||||
<Button
|
||||
icon={<NodeExpandOutlined />}
|
||||
onClick={() =>
|
||||
setExpandedKeys(expandedKeys.length ? [] : allIds)
|
||||
}
|
||||
>
|
||||
{expandedKeys.length ? '全部收起' : '全部展开'}
|
||||
</Button>,
|
||||
dom.keywordSearch,
|
||||
],
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: 20 },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 640 },
|
||||
@@ -125,23 +166,11 @@ const ProductCategoryPage: React.FC = () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className="mb-5 flex items-start justify-between">
|
||||
<div>
|
||||
<Title level={3}>商品分类</Title>
|
||||
<Text type="secondary">
|
||||
多级分类(如蔬菜/水果/其他),采购单导出与对账筛选按分类归组;有子分类或挂载商品时不可删除。
|
||||
</Text>
|
||||
</div>
|
||||
<Space>
|
||||
<Button
|
||||
icon={<NodeExpandOutlined />}
|
||||
onClick={() =>
|
||||
setExpandedKeys(expandedKeys.length ? [] : allIds)
|
||||
}
|
||||
>
|
||||
{expandedKeys.length ? '全部收起' : '全部展开'}
|
||||
</Button>
|
||||
</Space>
|
||||
<div className={"mb-5"}>
|
||||
<Title level={3}>商品分类</Title>
|
||||
<Text type="secondary">
|
||||
多级分类(如蔬菜/水果/其他),采购单导出与对账筛选按分类归组;有子分类或挂载商品时不可删除。
|
||||
</Text>
|
||||
</div>
|
||||
<XinTable<IProductCategory> {...tableProps} />
|
||||
</>
|
||||
|
||||
@@ -344,6 +344,7 @@ const ProductGoodsPage: React.FC = () => {
|
||||
formProps: {
|
||||
grid: true,
|
||||
colProps: { span: 12 },
|
||||
rowProps: { gutter: 20 },
|
||||
layout: 'vertical',
|
||||
},
|
||||
modalProps: { width: 800 },
|
||||
@@ -363,7 +364,7 @@ const ProductGoodsPage: React.FC = () => {
|
||||
title="价格矩阵 · 批量调价"
|
||||
open={matrixOpen}
|
||||
onClose={() => setMatrixOpen(false)}
|
||||
width={matrixLevels.length * 150 + 260}
|
||||
size={800}
|
||||
extra={
|
||||
<Space>
|
||||
<Button onClick={() => loadMatrix()}>刷新</Button>
|
||||
|
||||
Reference in New Issue
Block a user