feat: complete platform administration pages
This commit is contained in:
@@ -3,7 +3,7 @@ import { resourceApi } from './resource';
|
||||
|
||||
/** 平台角色、菜单、账号和工作台接口。 */
|
||||
export type PlatformRole = { identity: string; role_code: string; name: string; data_scope: string; is_system: boolean; status: string };
|
||||
export type PlatformMenu = { id: number; identity: string; parent_id: number; menu_code: string; name: string; icon: string; path: string; sort_no: number };
|
||||
export type PlatformMenu = { identity: string; parent_identity?: string; menu_code: string; name: string; icon: string; path: string; sort_no: number };
|
||||
|
||||
export const platformApi = {
|
||||
overview: () => request<Record<string, number>>('/dashboard/overview'),
|
||||
|
||||
@@ -2,7 +2,10 @@ import { request, type PageResult } from './http';
|
||||
|
||||
/** 所有标准 CRUD 资源共享的调用方法。 */
|
||||
export const resourceApi = {
|
||||
list: <T>(resource: string, page = 1, size = 20) => request<PageResult<T>>(`${resource}?page=${page}&size=${size}`),
|
||||
list: <T>(resource: string, page = 1, size = 20, filters: Record<string, string> = {}) => {
|
||||
const query = new URLSearchParams({ page: String(page), size: String(size), ...filters });
|
||||
return request<PageResult<T>>(`${resource}?${query.toString()}`);
|
||||
},
|
||||
detail: <T>(resource: string, identity: string) => request<T>(`${resource}/${identity}`),
|
||||
create: <T>(resource: string, data: Record<string, unknown>) => request<T>(resource, { method: 'POST', body: JSON.stringify(data) }),
|
||||
update: <T>(resource: string, identity: string, data: Record<string, unknown>) => request<T>(`${resource}/${identity}`, { method: 'PUT', body: JSON.stringify(data) }),
|
||||
|
||||
39
frontend/platform_admin/src/api/resources.ts
Normal file
39
frontend/platform_admin/src/api/resources.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
export type ResourceMode = 'writable' | 'readonly' | 'append_only';
|
||||
export type ResourcePageKind = 'list' | 'tree' | 'dashboard';
|
||||
export type ResourceField = { key: string; label: string; required?: boolean };
|
||||
export type ResourceUiDefinition = {
|
||||
key: string;
|
||||
resource: string;
|
||||
title: string;
|
||||
mode: ResourceMode;
|
||||
pageKind: ResourcePageKind;
|
||||
fields: ResourceField[];
|
||||
};
|
||||
|
||||
const fields: ResourceField[] = [{ key: 'name', label: '名称' }, { key: 'status', label: '状态' }];
|
||||
const resource = (domain: string, name: string, title: string, mode: ResourceMode = 'writable', pageKind: ResourcePageKind = 'list'): ResourceUiDefinition => ({
|
||||
key: name.replace(/_/g, '-'), resource: `/${domain}/${name}`, title, mode, pageKind, fields,
|
||||
});
|
||||
|
||||
/** The single UI catalogue mirrors the backend ExpectedResources contract. */
|
||||
export const resources: ResourceUiDefinition[] = [
|
||||
resource('gas', 'gas_basic', '气站管理'), resource('gas', 'gas_account', '气站账户'),
|
||||
resource('delivery', 'delivery_basic', '配送点管理'), resource('delivery', 'delivery_account', '配送账户'), resource('delivery', 'delivery_task', '配送任务'), resource('delivery', 'delivery_track', '配送轨迹'), resource('delivery', 'delivery_track_point', '轨迹点'),
|
||||
resource('staff', 'staff_account', '服务人员'), resource('staff', 'staff_credential', '人员资质'),
|
||||
resource('user', 'user_account', '用户账户'), resource('user', 'user_address', '用户地址'), resource('user', 'user_service_relation', '用户服务关系'),
|
||||
resource('device', 'dev_smart_cylinder_valve', '智能钢瓶阀'), resource('device', 'dev_device_binding', '设备绑定'), resource('device', 'dev_telemetry', '设备遥测', 'readonly'), resource('device', 'saf_rule', '安全规则'), resource('device', 'saf_event', '安全事件'), resource('device', 'saf_event_disposal', '事件处置记录', 'append_only'), resource('device', 'saf_inspection', '安全检查'),
|
||||
resource('commerce', 'ec_category', '商品分类'), resource('commerce', 'ec_product', '商品'), resource('commerce', 'ec_product_attribute', '商品属性'), resource('commerce', 'ec_product_image', '商品图片'), resource('commerce', 'ec_cart', '购物车'), resource('commerce', 'ec_order', '订单'), resource('commerce', 'ec_review', '评价'),
|
||||
resource('finance', 'fin_payment', '支付记录'), resource('finance', 'fin_settlement', '结算记录'), resource('finance', 'fin_reconciliation', '对账记录'),
|
||||
resource('content', 'cnt_content', '内容管理'), resource('notification', 'ntf_template', '通知模板'), resource('customer_service', 'cs_ticket', '客服工单'),
|
||||
resource('platform', 'platfrom_account', '平台账户'), resource('platform', 'platform_role', '平台角色'), resource('platform', 'platform_menu', '平台菜单', 'writable', 'tree'),
|
||||
resource('wallet', 'wallet', '钱包', 'readonly'), resource('wallet', 'wallet_ledger', '钱包流水', 'readonly'), resource('wallet', 'wallet_recharge', '钱包充值', 'readonly'), resource('wallet', 'wallet_withdrawal', '钱包提现', 'readonly'),
|
||||
resource('report', 'report', '报表', 'readonly'), resource('report', 'report_item', '报表项目', 'readonly'), resource('report', 'report_metric_snapshot', '指标快照', 'readonly'),
|
||||
resource('audit', 'aud_operation_log', '操作审计', 'readonly'), resource('audit', 'aud_export_log', '导出审计', 'readonly'), resource('audit', 'aud_approval', '审批审计', 'readonly'),
|
||||
];
|
||||
|
||||
export const resourceByName = Object.fromEntries(resources.map((definition) => [definition.resource, definition])) as Record<string, ResourceUiDefinition>;
|
||||
export function getResource(resourcePath: string): ResourceUiDefinition {
|
||||
const definition = resourceByName[resourcePath];
|
||||
if (!definition) throw new Error(`Unknown resource: ${resourcePath}`);
|
||||
return definition;
|
||||
}
|
||||
@@ -2,4 +2,4 @@ import { resourceApi } from './resource';
|
||||
|
||||
/** 服务人员管理接口。 */
|
||||
export type Staff = { identity: string; name: string; phone: string; role_code: string; work_status: string; status: string };
|
||||
export const staffApi = { list: () => resourceApi.list<Staff>('/staff/staff'), create: (data: Record<string, unknown>) => resourceApi.create<Staff>('/staff/staff', data) };
|
||||
export const staffApi = { list: () => resourceApi.list<Staff>('/staff/staff_account'), create: (data: Record<string, unknown>) => resourceApi.create<Staff>('/staff/staff_account', data) };
|
||||
|
||||
@@ -2,4 +2,4 @@ import { resourceApi } from './resource';
|
||||
|
||||
/** 业主客户管理接口。 */
|
||||
export type User = { identity: string; name: string; phone: string; real_name: string; status: string };
|
||||
export const userApi = { list: () => resourceApi.list<User>('/user/user'), create: (data: Record<string, unknown>) => resourceApi.create<User>('/user/user', data) };
|
||||
export const userApi = { list: () => resourceApi.list<User>('/user/user_account'), create: (data: Record<string, unknown>) => resourceApi.create<User>('/user/user_account', data) };
|
||||
|
||||
Reference in New Issue
Block a user