Преглед на файлове

update: template dict model,api,page

dev
powersir преди 1 година
родител
ревизия
c04f570b63
променени са 4 файла, в които са добавени 86 реда и са изтрити 37 реда
  1. +0
    -1
      src/models/index.ts
  2. +8
    -0
      src/models/template.data.ts
  3. +61
    -34
      src/pages/custom/template/dict/index.tsx
  4. +17
    -2
      src/request/service/template-dict.ts

+ 0
- 1
src/models/index.ts Целия файл

@@ -16,7 +16,6 @@ export * from './category.data.ts'
export * from './material-classify.data.ts'
export * from './goods-classify.data.ts'
export * from './goods-attr.data.ts'
export * from './platform-template.data.ts'

export interface ResponseDTO<T>{
code: number;


+ 8
- 0
src/models/template.data.ts Целия файл

@@ -3,6 +3,7 @@ export interface DataDictVO{
description: string;
id: number;
name: string;
createTime?: number;
}

//数据字典详情
@@ -14,6 +15,13 @@ export interface DataDictDetailVO {
value: string;
}

export interface DataDictPageReqVO extends PageParam {
createTime?: string[];
description?: string;
name?: string;
}



/**
* TemplateInfoVO,模板数据


+ 61
- 34
src/pages/custom/template/dict/index.tsx Целия файл

@@ -1,4 +1,4 @@
import React, { useState, useRef } from 'react';
import React, { useState, useRef, useEffect } from 'react';
import { Space, Table, Button, Image, Divider, Card, Input } from 'antd';
import type { InputRef } from 'antd';
import type { ColumnType, ColumnsType } from 'antd/es/table';
@@ -6,27 +6,29 @@ import type { FilterConfirmProps, TableRowSelection } from 'antd/es/table/interf
import { t } from '@/utils/i18n';
import { PlusOutlined, ExclamationCircleFilled, DeleteOutlined, SearchOutlined } from '@ant-design/icons';
import { antdUtils } from '@/utils/antd';
import { useRequest } from '@/hooks/use-request';
import { DataDictVO, DataDictDetailVO } from '@/models';
import DictEditor from './dict-editor';
import DictDetailEditor from './dict-detail-editor';
import templateDictService from '@/request/service/template-dict';

const dataDicts: DataDictVO[] = [
{
"id": 43,
"name": "爆款词",
"description": "爆款词"
},
{
"id": 42,
"name": "T-T",
"description": "t-shirt"
},
{
"id": 41,
"name": "T-shirt Background",
"description": "T桖背景"
}
]
// const dataDicts: DataDictVO[] = [
// {
// "id": 43,
// "name": "爆款词",
// "description": "爆款词"
// },
// {
// "id": 42,
// "name": "T-T",
// "description": "t-shirt"
// },
// {
// "id": 41,
// "name": "T-shirt Background",
// "description": "T桖背景"
// }
// ]

const dictDetailsA: DataDictDetailVO[] = [
{
@@ -117,7 +119,9 @@ const dictDetailsC: DataDictDetailVO[] = [

export default () => {

const [dataDicts, setDataDicts] = useState<DataDictVO[]>();
const [dictDetail, setDictDetail] = useState<DataDictDetailVO[]>();
const [total, setTotal] = useState(0);

const [editorVisable, seEditorVisable] = useState<boolean>(false);
const [editData, seEditData] = useState<DataDictVO>();
@@ -125,6 +129,23 @@ export default () => {
const [detailEditorVisable, seEdtailEditorVisable] = useState<boolean>(false);
const [editDetailData, seEditDetailData] = useState<DataDictDetailVO>();

//获取字典分页数据
const { runAsync: getDictPageApi } = useRequest(templateDictService.getDictPageApi, { manual: true });
//删除字典数据
const { runAsync: deleteDictApi } = useRequest(templateDictService.deleteDictApi, { manual: true });

const load = async () => {
const [error, { data }] = await getDictPageApi();
if (!error) {
setDataDicts(data.list);
setTotal(data.total);
}
}

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

const showDeleteConfirm = (item: DataDictVO) => {
antdUtils.modal?.confirm({
title: `确认删除名称为: ${item.name} 的字典吗?`,
@@ -133,20 +154,14 @@ export default () => {
okText: '删除',
okType: 'danger',
cancelText: '取消',
onOk() {
return new Promise((resolve, reject) => {
setTimeout(() => {
antdUtils.message?.open({
type: 'success',
content: '删除成功',
});
resolve(null)
}, 1000);

}).catch(() => antdUtils.message?.open({
type: 'error',
content: '操作失败',
}));
onOk: async () => {
const [error, { code, msg }] = await deleteDictApi(item.id);
if (error || code !== 0) {
antdUtils.message?.open({ type: 'error', content: msg ?? '操作失败' })
} else {
antdUtils.message?.open({ type: 'success', content: '删除成功' })
}
await load();
},
onCancel() {
},
@@ -186,7 +201,7 @@ export default () => {
onClick={() => {
seEditDetailData(record)
seEdtailEditorVisable(true);
}}>
}}>
编辑
</a>
<a
@@ -256,7 +271,17 @@ export default () => {
return (
<>
<div className='flex flex-row'>
<Card className='basis-2/5 w-[100px] mb-[10px] dark:bg-[rgb(33,41,70)] bg-white roundle-lg px[12px]'>
<Card className='basis-2/5 w-[100px] mb-[10px] dark:bg-[rgb(33,41,70)] bg-white roundle-lg px[12px]' bodyStyle={{
paddingTop: 0,
paddingBottom: 0
}}>
<div className="py-[8px] flex flex-row-reverse">
<Button className="ml-5" type='primary' size='middle' icon={<PlusOutlined />}
onClick={() => {
seEditData(undefined);
seEditorVisable(true);
}}> 新增 </Button>
</div>
<Table rowKey="id" scroll={{ x: true }} columns={dictColumns} dataSource={dataDicts} className='bg-transparent'
onRow={(record) => {
return {
@@ -282,6 +307,8 @@ export default () => {
</div>
<DictEditor
onSave={() => {
load();
seEditorVisable(false);
}}
onCancel={() => { seEditorVisable(false) }}
visible={editorVisable}


+ 17
- 2
src/request/service/template-dict.ts Целия файл

@@ -1,10 +1,25 @@
import request from '@/request';
import { DataDictVO, DataDictDetailVO } from '@/models';
import { DataDictVO, DataDictDetailVO, DataDictPageReqVO, PageData } from '@/models';

const BASE_URL = '/admin-api/system/dict';
const BASE_URL = '/admin-api/template/dict';

export default {

//获取字典分页
getDictPageApi: (params: DataDictPageReqVO) => {
return request.get<PageData<DataDictVO>>(`${BASE_URL}/page`, { params });
},

//获取字典详情
getDictDetailApi: (id: number) => {
return request.get(`${BASE_URL}/get?id=${id}`);
},

//获取字典列表
getDictListApi: (ids: string[]) => {
return request.get(`${BASE_URL}/list?ids=${ids.join(",")}`);
},

createDictApi: (data: DataDictVO) => {
return request.post(`${BASE_URL}/create`, data);
},


Loading…
Отказ
Запис