feat: 办事大厅前端源码首次入库(事项列表/详情/申报/管理端)
build / build (push) Successful in 1m55s

This commit is contained in:
chenxing
2026-09-15 11:00:57 +08:00
parent 7a2ea27f1e
commit 22dfb70377
328 changed files with 26089 additions and 0 deletions
+26
View File
@@ -0,0 +1,26 @@
import { Method } from "alova";
import { alovaInstance } from "@/utils/alova/alova-iview";
import type { SchoolTreeNode } from "@/types/svc";
/**
* 基础平台接口(Notice baseApi 平移):用户信息与已授权模块列表(菜单渲染数据源)。
* 模块清单在 UserBase 按本应用 appKey 配置(app_module),按登录人过滤下发。
*/
const BASE = "/api/base";
function get<T = any>(url: string, params?: Record<string, any>): Method<T> {
return new Method<T>("GET", alovaInstance, url, { params });
}
class BaseApi {
/** 当前登录用户信息 */
getUserInfo() {
return get<SchoolTreeNode>(`${BASE}/GetUserInfo`);
}
/** 当前用户已授权的模块列表(左侧菜单数据源) */
getUserMod() {
return get<SchoolTreeNode[]>(`${BASE}/GetUserMod`);
}
}
export const baseApi = new BaseApi();
+192
View File
@@ -0,0 +1,192 @@
import { Method } from "alova";
import { alovaInstance } from "@/utils/alova/alova-iview";
import type {
ApplySubmitRequest,
ApplyVo,
FlowSummary,
PageResult,
SiteOption,
SvcDeptVo,
SvcDictSaveRequest,
SvcDictVo,
SvcFormSaveRequest,
SvcFormVo,
SvcItemAttachmentVo,
SvcItemEditVo,
SvcItemPageItem,
SvcItemSaveRequest,
} from "@/types/svc";
/**
* 办事大厅接口封装(V2.0 Part B 契约)。
* siteCode 为一切管理面/用户面定位键;conf.serviceHost 本地为空(走 vite 代理)。
*/
const SVC = "/api/svc";
const APPLY = "/api/apply";
const FILE = "/api/file";
/** GET 请求 */
function get<T = any>(url: string, params?: Record<string, any>): Method<T> {
return new Method<T>("GET", alovaInstance, url, { params });
}
/** POST JSON body */
function postJSON<T = any>(url: string, data?: Record<string, any> | any[]): Method<T> {
return new Method<T>(
"POST",
alovaInstance,
url,
{ headers: { "Content-Type": "application/json;charset=UTF-8" } },
data ? JSON.stringify(data) : undefined
);
}
/** POST 表单(@RequestParam) */
function postForm<T = any>(url: string, data?: Record<string, any>): Method<T> {
const form = data
? Object.entries(data)
.filter(([, v]) => v !== undefined && v !== null)
.map(([k, v]) => `${encodeURIComponent(k)}=${encodeURIComponent(String(v))}`)
.join("&")
: undefined;
return new Method<T>(
"POST",
alovaInstance,
url,
{ headers: { "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8" } },
form
);
}
class SiteApi {
/** 管理端站点选择器(CMS 站点目录代理) */
options() {
return get<SiteOption[]>(`${SVC}/site/options`);
}
}
class SvcItemApi {
page(params: Record<string, any>) {
return get<PageResult<SvcItemPageItem>>(`${SVC}/item/page`, params);
}
get(siteCode: string, id: number) {
return get<SvcItemEditVo>(`${SVC}/item/get`, { siteCode, id });
}
save(data: SvcItemSaveRequest) {
return postJSON<number>(`${SVC}/item/save`, data);
}
publish(siteCode: string, id: number) {
return postForm<void>(`${SVC}/item/publish/${id}`, { siteCode });
}
offline(siteCode: string, id: number) {
return postForm<void>(`${SVC}/item/offline/${id}`, { siteCode });
}
delete(siteCode: string, id: number) {
return postJSON<void>(`${SVC}/item/delete`, { siteCode, id });
}
sort(siteCode: string, items: { id: number; sortNo: number }[]) {
return postJSON<void>(`${SVC}/item/sort?siteCode=${encodeURIComponent(siteCode)}`, items);
}
syncDeptName(siteCode: string) {
return postForm<{ updated: number }>(`${SVC}/item/syncDeptName`, { siteCode });
}
attList(siteCode: string, id: number) {
return get<SvcItemAttachmentVo[]>(`${SVC}/item/attList`, { siteCode, id });
}
}
class SvcDictApi {
list(siteCode: string, dictType?: string) {
return get<SvcDictVo[]>(`${SVC}/dict/list`, { siteCode, dictType });
}
save(data: SvcDictSaveRequest) {
return postJSON<number>(`${SVC}/dict/save`, data);
}
delete(siteCode: string, id: number) {
return postJSON<void>(`${SVC}/dict/delete`, { siteCode, id });
}
deptTree(siteCode: string) {
return get<SvcDeptVo[]>(`${SVC}/dept/tree`, { siteCode });
}
}
class SvcFormApi {
list(siteCode: string) {
return get<SvcFormVo[]>(`${SVC}/form/list`, { siteCode });
}
versions(siteCode: string, code: string) {
return get<SvcFormVo[]>(`${SVC}/form/versions`, { siteCode, code });
}
get(siteCode: string, id: number) {
return get<SvcFormVo>(`${SVC}/form/get`, { siteCode, id });
}
save(siteCode: string, data: SvcFormSaveRequest) {
return postJSON<number>(`${SVC}/form/save?siteCode=${encodeURIComponent(siteCode)}`, data);
}
publish(siteCode: string, id: number) {
return postForm<void>(`${SVC}/form/publish/${id}`, { siteCode });
}
delete(siteCode: string, code: string) {
return postForm<void>(`${SVC}/form/delete`, { siteCode, code });
}
}
class SvcFlowApi {
/** 已发布流程列表(流程中心未接入时后端报业务错,页面降级提示) */
list(siteCode: string) {
return get<FlowSummary[]>(`${SVC}/flow/list`, { siteCode });
}
}
class ApplyApi {
/** 发起(用户面) */
submit(data: ApplySubmitRequest) {
return postJSON<ApplyVo>(`${APPLY}`, data);
}
retry(id: number) {
return postForm<ApplyVo>(`${APPLY}/${id}/retry`);
}
/** 一键重提(仅驳回/撤回态;同 bizId,flow-center R4 重启推进) */
resubmit(id: number) {
return postForm<ApplyVo>(`${APPLY}/${id}/resubmit`);
}
my(params?: Record<string, any>) {
return get<PageResult<ApplyVo>>(`${APPLY}/my`, params);
}
/** 发起页数据(事项要点+表单 schema) */
item(siteCode: string, itemCode: string) {
return get<Record<string, any>>(`${APPLY}/item`, { siteCode, itemCode });
}
detail(id: number) {
return get<ApplyVo>(`${APPLY}/${id}`);
}
adminPage(params: Record<string, any>) {
return get<PageResult<ApplyVo>>(`${SVC}/apply/page`, params);
}
}
class FileApi {
/** 上传(返回完整 URL 与附件行 id;绑定在保存/提交动作完成) */
upload(file: File, type: "image" | "file", siteCode?: string) {
const form = new FormData();
form.append("file", file);
form.append("type", type);
if (siteCode) form.append("siteCode", siteCode);
return new Method<{ id: number; fileName: string; fileUrl: string; fileSize: number }>(
"POST",
alovaInstance,
`${FILE}/upload`,
{ headers: {} },
form
);
}
}
export const siteApi = new SiteApi();
export const svcItemApi = new SvcItemApi();
export const svcDictApi = new SvcDictApi();
export const svcFormApi = new SvcFormApi();
export const svcFlowApi = new SvcFlowApi();
export const applyApi = new ApplyApi();
export const fileApi = new FileApi();