ソースを参照

update:category model

dev
powersir 11ヶ月前
コミット
8a2dbd09b9
4個のファイルの変更246行の追加2行の削除
  1. +90
    -0
      src/models/category.data.ts
  2. +2
    -0
      src/pages/custom/product/sample/components/attr-editor.tsx
  3. +152
    -0
      src/pages/goods/main/category/index.tsx
  4. +2
    -2
      src/request/service/category.ts

+ 90
- 0
src/models/category.data.ts ファイルの表示

@@ -37,6 +37,96 @@ export interface CategoryVO {
remark?: string;
}

/**
* CategoryTreeVO,管理后台 - 类目 Response VO
*/
export interface CategoryTreeVO {
attrVO?: CategoryAdditionalAttrVO;
/**
* 类目名称,最大长度不能超过125
*/
categoryName: string;
/**
* 类目英文名称,最大长度255
*/
categoryNameEn: string;
/**
* 子节点
*/
childrens?: CategoryTreeVO[];
/**
* 创建时间
*/
createTime?: Date;
/**
* 主键
*/
id: number;
/**
* 是否叶子节点,(1: 是, 2:不是)
*/
isLeaf?: string;
/**
* 目录级别
*/
level?: string;
/**
* 父类目id
*/
parentId?: number;
/**
* 备注,最大长度255
*/
remark?: string;
}

/**
* CategoryAdditionalAttrVO,管理后台 - 类目附加属性 Response VO
*/
export interface CategoryAdditionalAttrVO {
/**
* 类目Id
*/
categoryId: number;
/**
* 创建时间
*/
createTime: Date;
/**
* 海关编码,最大长度100
*/
customsName?: string;
/**
* 申报名称,最大长度125
*/
declareName?: string;
/**
* 申报名称_英文,最大长度125
*/
declareNameEn?: string;
/**
* 申报价格
*/
declarePrice?: number;
/**
* 申报重量
*/
declareWeight?: number;
/**
* 主键
*/
id: number;
/**
* 是否上传尺码表(1:是, 2:否)
*/
isSizeTable: string;
/**
* 包材id
*/
packingId: number;
}



export interface CategoryPageReqVO extends PageParam {
/**


+ 2
- 0
src/pages/custom/product/sample/components/attr-editor.tsx ファイルの表示

@@ -51,6 +51,8 @@ const SampleAttrEditor: React.FC<CreateSampleAttrProps> = (props) => {
const [previewTitle, setPreviewTitle] = useState('');
const [form] = Form.useForm();

const isEdit = !!editData;

useEffect(() => {
if (visible) {
setInitValue();


+ 152
- 0
src/pages/goods/main/category/index.tsx ファイルの表示

@@ -0,0 +1,152 @@
import { Space, Table, Button, Input, Select, Divider, Tag, Card, Badge, Form, InputRef } from 'antd';
import type { TableColumnsType } from 'antd';
import { t } from '@/utils/i18n';
import React, { useState, useEffect, useRef } from 'react';
import { PlusOutlined, ExclamationCircleFilled, SearchOutlined, UndoOutlined } from '@ant-design/icons';
import type { CategoryPageReqVO, CategoryVO } from '@/models'
import { antdUtils } from '@/utils/antd';
import { useRequest } from '@/hooks/use-request';
import platformShopService from '@/request/service/category';
import { formatDate } from '@/utils/formatTime';
import { useSetState } from 'ahooks';

export default () => {

const [editorVisable, seEditorVisable] = useState<boolean>(false);
const [editData, seEditData] = useState<CategoryVO>();
const [dataSource, setDataSource] = useState<CategoryVO[]>([]);
const [searchFrom] = Form.useForm();

const [searchState, setSearchState] = useSetState<CategoryPageReqVO>({
pageNo: 1,
pageSize: 10
});
const [total, setTotal] = useState(0)
const searchInput = useRef<InputRef>(null);
const [onSearching, setOnSearching] = useState(false);

const { runAsync: getPageApi } = useRequest(platformShopService.getCategoryPageApi, { manual: true });
const { runAsync: deleteApi } = useRequest(platformShopService.deleteCategoryApi, { manual: true });

const load = async () => {
const [error, { data }] = await getPageApi(searchFrom.getFieldsValue());
if (!error) {
setDataSource(data.list);
}
};

const showDeleteConfirm = (data: CategoryVO) => {
antdUtils.modal?.confirm({
title: '确认要将该分类删除吗?',
icon: <ExclamationCircleFilled />,
content: '请注意删除以后不可恢复!',
okText: '删除',
okType: 'danger',
cancelText: '取消',
onOk() {
return new Promise(async (resolve) => {
const [error, { code, msg }] = await deleteApi(data.id);
if (error || code !== 0) {
antdUtils.message?.open({ type: 'error', content: msg ?? '操作失败' })
} else {
antdUtils.message?.open({ type: 'success', content: '删除成功' })
}
await load();
resolve('')
}).catch(() => antdUtils.message?.open({
type: 'error',
content: '操作失败',
}));
},
onCancel() {
},
});
};

const columns: TableColumnsType<CategoryVO> = [
{
title: '类目名称(CN)',
dataIndex: 'categoryName',
key: 'categoryName',
align: 'right',
width: 200,
},
{
title: '类目名称(EN)',
dataIndex: 'categoryNameEn',
key: 'categoryNameEn',
align: 'center',
width: 200,
},
{
title: '敦煌类目',
dataIndex: '',
key: '',
align: 'center',
width: 200,
},
{
title: 'sds类目',
dataIndex: '',
key: '',
align: 'center',
width: 200
},
{
title: '虾皮类目',
dataIndex: '',
key: '',
align: 'center',
width: 200
},
{
title: t("QkOmYwne" /* 操作 */),
key: 'action',
render: (value: CategoryVO, record) => (
<Space size="small" split={(<Divider type='vertical' />)}>
<a onClick={() => {
seEditData(value);
seEditorVisable(true);
}}>
编辑
</a>
<a onClick={() => {
showDeleteConfirm(value)
}}>
删除
</a>
</Space>
),
},
];

useEffect(() => {
load();
}, []);

const onReset = () => {
searchFrom.resetFields()
load()
}

return (
<>
<div>
<Card className='mt-[4px] dark:bg-[rgb(33,41,70)] bg-white roundle-lg px[12px]'>
<Table rowKey="id"
scroll={{ x: true }}
columns={columns}
dataSource={dataSource}
className='bg-transparent'
pagination={{
position: ['bottomRight'],
current: searchState.pageNo,
pageSize: searchState.pageSize,
total
}} />
</Card>
</div>
</>
);
};


+ 2
- 2
src/request/service/category.ts ファイルの表示

@@ -1,5 +1,5 @@
import request from '@/request';
import { CategoryVO, CategoryPageReqVO, PageData } from '@/models';
import { CategoryVO, CategoryPageReqVO, CategoryTreeVO, PageData } from '@/models';

const BASE_URL = '/admin-api/main/category';

@@ -23,7 +23,7 @@ export default {

// 获得所有类目(树结构)
getCategoryTreeApi: (params: CategoryPageReqVO) => {
return request.get<CategoryVO[]>(`${BASE_URL}/categoryAllTree`, { params })
return request.get<CategoryTreeVO[]>(`${BASE_URL}/categoryAllTree`, { params })
},

// 查询类目详情


読み込み中…
キャンセル
保存