1
0

feat(web): 更新数据市场展示逻辑

- 公开数据采用卡片模式展示,增加申请授权功能
- 后端增加 icon 字段,用于展示数据资源图标
This commit is contained in:
2024-12-18 09:49:58 +08:00
parent 3138539bc5
commit 608ab5f37e
3 changed files with 107 additions and 80 deletions

View File

@@ -7,9 +7,79 @@ import {
permissionStateMapping,
timeField
} from "../../components/constants.js";
import {authenticationAddDialog} from "../../components/permission/dialog-permission.js";
function listColumns() {
export function tabMarket() {
return {
title: '数据市场',
icon: 'fa fa-store',
reload: true,
body: [
{
type: 'tabs',
tabs: [
{
title: '公开数据',
body: {
type: 'crud',
api: {
...apiGet('${base}/ware/list_public'),
adaptor: (payload, response, api, context) => {
payload.data = payload.data.map(i => {
return {
...i,
targetId: i.id
}
})
console.log(payload, response, api, context)
return {
...payload
}
}
},
...crudCommonOptions(),
headerToolbar: [
'reload',
],
mode: 'cards',
card: {
header: {
title: '${name}',
subTitle: '${createdTime}',
description: '${description}',
avatar: '${icon}',
avatarClassName: 'pull-left thumb-md avatar b-3x m-r'
},
actions: [
{
type: 'action',
label: '查看',
...wareDetailDialog(),
},
{
type: 'action',
label: '申请授权',
...authenticationAddDialog(),
}
]
},
}
},
{
title: '我的数据',
body: {
type: 'crud',
api: apiGet('${base}/ware/list'),
...crudCommonOptions(),
headerToolbar: [
'reload',
{
type: 'action',
label: '',
icon: 'fa fa-plus',
...wareAddDialog()
},
],
columns: [
{
name: 'name',
@@ -20,10 +90,7 @@ function listColumns() {
name: 'description',
label: '描述',
},
{
visibleOn: '${!public}',
...mappingField('state', '状态', permissionStateMapping)
},
mappingField('state', '状态', permissionStateMapping),
timeField('createdTime', '创建时间'),
operationField('操作', undefined, [
{
@@ -81,49 +148,6 @@ function listColumns() {
]),
]
}
}
export function tabMarket() {
return {
title: '数据市场',
icon: 'fa fa-store',
reload: true,
body: [
{
type: 'tabs',
tabs: [
{
title: '公开数据',
body: {
type: 'crud',
api: apiGet('${base}/ware/list_public'),
...crudCommonOptions(),
headerToolbar: [
'reload',
],
data: {
public: true
},
...listColumns(),
}
},
{
title: '我的数据',
body: {
type: 'crud',
api: apiGet('${base}/ware/list'),
...crudCommonOptions(),
headerToolbar: [
'reload',
{
type: 'action',
label: '',
icon: 'fa fa-plus',
...wareAddDialog()
},
],
...listColumns(),
}
},
]
}

View File

@@ -77,6 +77,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
item.setId(entity.getId());
item.setName(entity.getName());
item.setDescription(entity.getDescription());
item.setIcon(StrUtil.format("{}/upload/download/{}", hostConfiguration.getPrefix(), entity.getIcon().getId()));
item.setState(entity.getState().name());
item.setCreatedTime(entity.getCreatedTime());
item.setCreatedUsername(entity.getCreatedUser().getUsername());
@@ -117,6 +118,7 @@ public class WareController extends SimpleControllerSupport<Ware, WareController
private String name;
private String description;
private String state;
private String icon;
}
@Data

View File

@@ -39,6 +39,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
@DynamicUpdate
@Table(name = Constants.TABLE_PREFIX + "ware")
@NamedEntityGraph(name = "ware.list", attributeNodes = {
@NamedAttributeNode(value = "icon"),
@NamedAttributeNode(value = "createdUser"),
})
@NamedEntityGraph(name = "ware.detail", attributeNodes = {