Initial project source
这个提交包含在:
@@ -0,0 +1,32 @@
|
||||
---
|
||||
name: frontend-api-types
|
||||
description: 前端 API 与类型定义专家。用于 aixun-ui 前端项目中的 src/api 层、types.ts、返回结构、Query/Form/VO/InfoVO 定义,以及前后端接口映射任务;默认基线为 Gitee 仓库 AiXunKeJi/aixun-ui 的 6.X-Vue 分支。
|
||||
---
|
||||
|
||||
你负责 aixun-ui 前端项目中的 API 层和类型定义。
|
||||
|
||||
基线仓库:`https://gitee.com/AiXunKeJi/aixun-ui`
|
||||
默认分支:`6.X-Vue`
|
||||
远端引用必须同时标记仓库、分支和文件路径;不要写本机绝对路径。
|
||||
|
||||
## 核心原则
|
||||
|
||||
1. 先看当前模块已有 `src/api/<module>/<business>`。
|
||||
2. API 路径、返回类型、命名风格与当前模块保持一致。
|
||||
3. 能明确写出类型时,不要偷懒用 `any`。
|
||||
4. 如果当前模块已有 `export default { ... }`,继续保持一致。
|
||||
|
||||
## 重点关注
|
||||
|
||||
- `Query`
|
||||
- `VO`
|
||||
- `Form`
|
||||
- `InfoVO`
|
||||
- `AxiosPromise<PageResult<T>>`
|
||||
- 详情接口与列表接口返回结构
|
||||
|
||||
## 自检
|
||||
|
||||
- API 路径是否与后端一致
|
||||
- 类型是否覆盖接口真实结构
|
||||
- 是否不必要地把类型写宽了
|
||||
@@ -0,0 +1,22 @@
|
||||
---
|
||||
name: frontend-crud-coding
|
||||
description: 前端总入口。用于 aixun-ui 前端项目中的标准 CRUD 页面、新增 API/types、复杂列表页增强、树筛选、导入导出、权限按钮与弹窗表单等任务,并根据任务类型选择合适的前端子 agent;默认基线为 Gitee 仓库 AiXunKeJi/aixun-ui 的 6.X-Vue 分支。
|
||||
---
|
||||
|
||||
你是 aixun-ui 前端项目的总入口 agent。
|
||||
|
||||
基线仓库:`https://gitee.com/AiXunKeJi/aixun-ui`
|
||||
默认分支:`6.X-Vue`
|
||||
远端引用必须同时标记仓库、分支和文件路径;不要在 agent 文档中写本机绝对路径。
|
||||
|
||||
先判断任务类型,再按下面规则处理:
|
||||
|
||||
1. 如果是新增标准 CRUD 页面、补 `src/api`、`types.ts`、`index.vue`,优先使用 `frontend-crud-page.md`。
|
||||
2. 如果是修改已有列表页、增强导入导出、树筛选、更多菜单、状态切换,优先使用 `frontend-page-enhancement.md`。
|
||||
3. 如果只改接口层和类型定义,优先使用 `frontend-api-types.md`。
|
||||
|
||||
通用要求:
|
||||
|
||||
- 先读当前目录下最近似页面和 API,再动代码。
|
||||
- 冲突时优先相信当前项目真实页面,其次是公共组件和工具,再其次才是 aixun-ui Gitee 仓库 `6.X-Vue` 分支的 `gen` 模板。
|
||||
- 默认直接产出可落地代码,而不是只给抽象建议。
|
||||
@@ -0,0 +1,41 @@
|
||||
---
|
||||
name: frontend-crud-page
|
||||
description: 前端标准 CRUD 页面专家。用于 aixun-ui 前端项目中的新建列表页、弹窗表单页、标准 API/types/index.vue 骨架,以及 gen 模板到项目风格的落地任务;默认参考 Gitee 仓库 AiXunKeJi/aixun-ui 的 6.X-Vue 分支。
|
||||
---
|
||||
|
||||
你负责 aixun-ui 前端项目中的标准 CRUD 页面实现。
|
||||
|
||||
基线仓库:`https://gitee.com/AiXunKeJi/aixun-ui`
|
||||
默认分支:`6.X-Vue`
|
||||
远端模板引用必须同时标记仓库、分支和路径,例如 `branch=6.X-Vue, path=gen/index.vue.ftl`;不要写本机绝对路径。
|
||||
|
||||
## 核心原则
|
||||
|
||||
1. 先看当前模块最近似页面。
|
||||
2. 再参考 aixun-ui Gitee 仓库 `6.X-Vue` 分支中的 `gen` 模板。
|
||||
3. 默认同时维护:
|
||||
`src/api/<module>/<business>/index.ts`
|
||||
`src/api/<module>/<business>/types.ts`
|
||||
`src/views/<module>/<business>/index.vue`
|
||||
|
||||
## 页面规则
|
||||
|
||||
- 页面优先使用 `<script setup name="Xxx" lang="ts">`
|
||||
- 标准结构通常包含:
|
||||
搜索区、表格区、工具栏、分页、编辑弹窗
|
||||
- 常见状态:
|
||||
`loading`、`showSearch`、`ids`、`single`、`multiple`、`total`
|
||||
- 查询与表单优先使用 `reactive<PageData<Form, Query>>({...})`
|
||||
|
||||
## API / types 规则
|
||||
|
||||
- 请求统一通过 `@/utils/request`
|
||||
- 同目录维护 `index.ts` 与 `types.ts`
|
||||
- 标准 CRUD 通常包含:列表、详情、新增、修改、删除
|
||||
- 列表接口通常返回 `AxiosPromise<PageResult<XxxVO>>`
|
||||
|
||||
## 自检
|
||||
|
||||
- API 路径是否与后端一致
|
||||
- `index.ts` 与 `types.ts` 是否同步补齐
|
||||
- 页面是否只是模板裸输出,如果是要继续补强到当前项目风格
|
||||
@@ -0,0 +1,31 @@
|
||||
---
|
||||
name: frontend-page-enhancement
|
||||
description: 复杂前端页面增强专家。用于修改 aixun-ui 前端项目中已经存在的列表页、树筛选页、带导入导出和更多菜单的页面,强调增量修改和保留现有交互能力;默认基线为 Gitee 仓库 AiXunKeJi/aixun-ui 的 6.X-Vue 分支。
|
||||
---
|
||||
|
||||
你负责 aixun-ui 前端项目中已有页面的增强,不是重写页面。
|
||||
|
||||
基线仓库:`https://gitee.com/AiXunKeJi/aixun-ui`
|
||||
默认分支:`6.X-Vue`
|
||||
远端引用必须同时标记仓库、分支和文件路径;不要写本机绝对路径。
|
||||
|
||||
## 核心原则
|
||||
|
||||
1. 优先阅读当前页面完整实现。
|
||||
2. 增量修改,不重写整页。
|
||||
3. 保留已有树筛选、导入导出、列显隐、更多菜单、状态切换、路由跳转、SCSS 页面壳。
|
||||
4. 不要把复杂页面退化成 generator 式基础列表页。
|
||||
|
||||
## 常见任务
|
||||
|
||||
- 调整工具栏和更多菜单
|
||||
- 增加筛选条件和日期范围
|
||||
- 增加导入导出能力
|
||||
- 增加状态切换、快捷操作、确认弹窗
|
||||
- 补复杂页面的小型子功能
|
||||
|
||||
## 自检
|
||||
|
||||
- 是否破坏了原页面结构和样式
|
||||
- 是否误删了已有权限控制或交互能力
|
||||
- 是否应该拆成子组件而不是继续堆主页面
|
||||
@@ -0,0 +1,151 @@
|
||||
---
|
||||
name: frontend-crud-coding
|
||||
description: 在 aixun-ui 前端项目中按真实 Vue 3 + TypeScript + Element Plus + oxlint/oxfmt 代码风格生成或修改页面、API、types、hooks 接入和样式壳。用于新增或修改标准 CRUD 列表页、树表页、系统管理页、监控页、workflow 页面、demo 页面,补齐与后端接口对应的 src/api、types 和 src/views 代码;默认参考 Gitee 仓库 AiXunKeJi/aixun-ui 的 6.X-Vue 分支,触发后应先读取适用 references,再阅读目标模块真实代码和项目内 gen 代码生成模板。
|
||||
---
|
||||
|
||||
# 前端编码规范
|
||||
|
||||
先对齐当前前端项目里的真实实现,再参考项目内 `gen` 目录下的代码生成模板。不要只套通用 Vue 模板,也不要把 generator 模板原样复制进来而忽略当前项目已经演进出的 hooks、页面壳、类型入口和下载方式。
|
||||
|
||||
## 项目基线
|
||||
|
||||
- 基线仓库:`https://gitee.com/AiXunKeJi/aixun-ui`
|
||||
- 默认分支:`6.X-Vue`
|
||||
- 远端引用必须同时标记仓库、分支和文件路径,例如 `https://gitee.com/AiXunKeJi/aixun-ui/blob/6.X-Vue/gen/index.vue.ftl` 或 `branch=6.X-Vue, path=gen/index.vue.ftl`。
|
||||
- 不要在 skill、reference 或 agent 文档中写本机绝对路径;本地文件读取以运行时工作目录为准。
|
||||
- 如果用户指定其他分支,先按用户分支读取同一仓库的对应文件,并在结果中说明使用的分支。
|
||||
|
||||
## 执行流程
|
||||
|
||||
1. 判断任务类型:新增标准 CRUD、树表、已有页面增强、复杂业务页、只补 API/types。
|
||||
2. 按“文档读取规则”读取必要 reference,不一次性展开所有资料。
|
||||
3. 阅读目标目录下最近似的真实代码:
|
||||
- 标准单表优先看 `src/views/demo/demo/index.vue`、`src/api/demo/demo/*`。
|
||||
- 树表优先看 `src/views/demo/tree/index.vue`、`src/views/workflow/category/index.vue`。
|
||||
- 系统复杂页优先看 `src/views/system/user/index.vue`、`system/role`、`system/post`、`system/config`。
|
||||
- workflow 业务页优先看 `src/views/workflow/*` 同类页面。
|
||||
4. 新增标准页面前,对照项目内模板确认基础骨架:
|
||||
- API 模板:`gen/api.ts.ftl`
|
||||
- types 模板:`gen/types.ts.ftl`
|
||||
- 标准单表页模板:`gen/index.vue.ftl`
|
||||
- 树表页模板:`gen/index-tree.vue.ftl`
|
||||
5. 新增代码时通常同步维护 `src/api/<module>/<business>/index.ts`、`types.ts`、`src/views/<module>/<business>/index.vue`。
|
||||
6. 增强已有页面时只做增量修改,保留原页面的树筛选、导入导出、列显隐、权限、字典、弹窗和路由跳转能力。
|
||||
7. 修改完成后按影响范围运行验证:优先 `pnpm exec vue-tsc --noEmit`,改动页面或导入时再跑 `pnpm lint`,大范围变更再跑 `pnpm build`。
|
||||
|
||||
## 文档读取规则
|
||||
|
||||
- 前端 API、types、页面、hooks、样式和验证规则,先读 [references/frontend.md](references/frontend.md)。
|
||||
- 不确定任务边界、需要标准用例或提问方式时,再读 [references/examples.md](references/examples.md)。
|
||||
- reference 只约束实现方式和自检范围;发生冲突时,以当前模块真实代码和实际调用点为准。
|
||||
|
||||
## 优先级规则
|
||||
|
||||
发生冲突时按下面顺序决策:
|
||||
|
||||
1. 目标目录下最近似页面、API、types 的真实实现。
|
||||
2. 当前项目公共 hooks、组件、工具和样式约定。
|
||||
3. 项目内 `gen` 代码生成模板。
|
||||
4. 通用 Vue 3 / Element Plus 习惯。
|
||||
|
||||
也就是说:
|
||||
|
||||
- 同模块已有页面怎么写,优先怎么写。
|
||||
- 没有现成页面时,使用项目内 `gen` 模板作为骨架,再改成当前项目风格。
|
||||
- 复杂模块不能为了“标准 CRUD”退化成裸模板页。
|
||||
|
||||
## 仓库通用规则
|
||||
|
||||
- 遵循 [`.editorconfig`](../../../.editorconfig):UTF-8、LF、2 空格缩进;Markdown 例外。
|
||||
- 当前仓库没有 `.prettierrc`,格式脚本是 `pnpm run fmt` 调用 `oxfmt .`,lint 脚本是 `pnpm lint` 调用 `oxlint src`。
|
||||
- 页面优先使用 `<script setup name="Xxx" lang="ts">`。
|
||||
- API 返回类型优先从 `@/utils/api-types` 引入 `AxiosPromise`,分页结果从 `@/api/types` 引入 `PageResult`。
|
||||
- 请求统一通过 `@/utils/request`,导出下载使用 `import { download as requestDownload } from '@/utils/request';`。
|
||||
- 标准列表页优先复用 `useLoading`、`useSearchToggle`、`useSearchReset`、`useTableSelection`、`useFormDialog`、`useDateRangeQuery`。
|
||||
- 页面壳优先使用 `p-2 app-container <module>-<business>-page`、`search-panel`、`toolbar-shell`、`data-table`、`right-toolbar`、`pagination`。
|
||||
- 新页面不要无故引入另一套状态管理、请求封装、样式体系或权限写法。
|
||||
|
||||
## 目录映射规则
|
||||
|
||||
通常按下面关系组织代码:
|
||||
|
||||
- 后端 `/system/user/*` 对应 `src/api/system/user/*` 与 `src/views/system/user/*`
|
||||
- 后端 `/monitor/xxx/*` 对应 `src/api/monitor/xxx/*` 与 `src/views/monitor/xxx/*`
|
||||
- 后端 `/workflow/xxx/*` 对应 `src/api/workflow/xxx/*` 与 `src/views/workflow/xxx/*`
|
||||
- 后端 `/demo/xxx/*` 对应 `src/api/demo/xxx/*` 与 `src/views/demo/xxx/*`
|
||||
|
||||
标准新增通常至少包含:
|
||||
|
||||
- `src/api/<module>/<business>/index.ts`
|
||||
- `src/api/<module>/<business>/types.ts`
|
||||
- `src/views/<module>/<business>/index.vue`
|
||||
|
||||
按业务复杂度,可能继续补:
|
||||
|
||||
- 导入弹窗
|
||||
- 详情抽屉或详情页
|
||||
- 树筛选面板
|
||||
- 列显隐配置
|
||||
- 分配/授权子页面
|
||||
- 自定义 SCSS 样式
|
||||
|
||||
## 任务分型
|
||||
|
||||
### 1. 标准单表 CRUD
|
||||
|
||||
以 `gen/index.vue.ftl`、`gen/api.ts.ftl`、`gen/types.ts.ftl` 和 `src/views/demo/demo/index.vue` 为主要起点,补齐列表、搜索、分页、新增、编辑、删除、导出、权限、类型和验证。
|
||||
|
||||
### 2. 树表 CRUD
|
||||
|
||||
以 `src/views/demo/tree/index.vue`、`src/views/workflow/category/index.vue` 为主要起点。列表接口通常返回数组而不是 `PageResult`,页面使用 `handleTree`、`useTreeTableExpand`,`Query` 通常不继承 `PageQuery`。
|
||||
|
||||
### 3. 强业务页面
|
||||
|
||||
如果页面包含树筛选、导入导出、更多菜单、状态切换、角色分配、详情抽屉、复杂校验、联动选择或独立路由,优先增量修改现有页面。不要重写成简单 CRUD。
|
||||
|
||||
### 4. 工作流页面
|
||||
|
||||
workflow 目录优先参考 `src/views/workflow/*`。流程定义、流程实例、任务列表、请假申请等页面通常有业务按钮、弹窗和路由跳转,不要硬套 system 模块。
|
||||
|
||||
### 5. 只补 API 和 types
|
||||
|
||||
只维护 `src/api/<module>/<business>/index.ts` 与 `types.ts`,但仍要与后端路由、返回结构、当前模块导入方式和类型入口一致。
|
||||
|
||||
## 输出要求
|
||||
|
||||
使用本 skill 时,默认期望产出应满足:
|
||||
|
||||
- 类型完整,不把页面逻辑大量写成 `any`。
|
||||
- API 路径、函数名、权限标识与后端接口保持一致。
|
||||
- 标准页查询、重置、分页、弹窗、提交、删除、导出流程闭环完整。
|
||||
- 复杂页面保留原有交互能力和业务约束。
|
||||
- 代码体现当前项目 hooks、页面壳和下载方式,而不是 `gen` 模板裸输出。
|
||||
- 交付前说明运行过的验证命令;如果无法验证,说明原因。
|
||||
|
||||
## 快速检查清单
|
||||
|
||||
- `AxiosPromise` 是否来自 `@/utils/api-types`。
|
||||
- `PageResult` 是否来自 `@/api/types`。
|
||||
- API `params` 和 `data` 是否与后端方法一致。
|
||||
- 日期范围是否通过 `useDateRangeQuery` 或附近页面现有方式处理。
|
||||
- 列表 loading 是否通过 `useLoading` 或原页面方式维护。
|
||||
- 弹窗是否通过 `useFormDialog` 或原页面方式维护。
|
||||
- 多选状态是否通过 `useTableSelection` 或原页面方式维护。
|
||||
- 权限指令是否保持同文件一致,默认使用当前项目主流 `v-hasPermi`。
|
||||
- 导出是否使用 `requestDownload('<module>/<business>/export', { ...queryParams.value }, '<name>_<time>.xlsx')`。
|
||||
- 页面壳是否保留 `search-panel`、`table-panel`、`toolbar-shell`、`data-table`、`right-toolbar`、`pagination`。
|
||||
|
||||
## 推荐提问方式
|
||||
|
||||
推荐把请求描述到下面粒度:
|
||||
|
||||
- 目标模块和业务名
|
||||
- 后端接口前缀
|
||||
- 是新增页面、修改页面,还是只补 API/types
|
||||
- 是否需要导入、导出、树筛选、树表、状态切换、字典、权限按钮
|
||||
- 希望参考哪个现有页面
|
||||
|
||||
例如:
|
||||
|
||||
- 使用 `$frontend-crud-coding` 为 `/system/client` 补一套标准 CRUD 页面,参考 `gen` 模板、`demo/demo` 和 `system/client`。
|
||||
- 使用 `$frontend-crud-coding` 修改 `workflow/category` 列表页,增加导出按钮和状态筛选,保持当前 workflow 风格。
|
||||
@@ -0,0 +1,7 @@
|
||||
interface:
|
||||
display_name: "前端编码"
|
||||
short_description: "按 aixun-ui 6.X-Vue 真实代码和 gen 模板编写前端 CRUD"
|
||||
default_prompt: "使用 $frontend-crud-coding 先读取适用 reference,再按 aixun-ui Gitee 仓库 6.X-Vue 分支的真实页面、hooks、API/types 约定和项目内 gen 模板实现前端修改。"
|
||||
|
||||
policy:
|
||||
allow_implicit_invocation: true
|
||||
@@ -0,0 +1,126 @@
|
||||
# 使用案例
|
||||
|
||||
## 案例 1:新增标准 CRUD 页面
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 为 system/client 补一套前端 CRUD 页面。
|
||||
后端接口已经有 /system/client/list、/system/client/{id}、POST /system/client、PUT /system/client、DELETE /system/client/{ids}。
|
||||
请参考 aixun-ui Gitee 仓库 6.X-Vue 分支的项目内 gen 模板、src/views/demo/demo/index.vue 和现有 system/client 风格实现。
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- 先看 `src/api/system/client/*` 和 `src/views/system/client/index.vue` 是否已存在。
|
||||
- 再看 `src/views/demo/demo/index.vue` 的标准 hooks 版 CRUD 骨架。
|
||||
- 对照项目内 `gen/api.ts.ftl`、`gen/types.ts.ftl`、`gen/index.vue.ftl`。
|
||||
- 生成或修改 `api/index.ts`、`types.ts`、`views/.../index.vue`。
|
||||
- 使用 `AxiosPromise` from `@/utils/api-types`、`PageResult` from `@/api/types`、`useLoading`、`useFormDialog`、`useSearchReset`、`useTableSelection`。
|
||||
|
||||
## 案例 2:新增树表页面
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 为 demo/tree2 新增树表 CRUD,接口返回数组,字段包含 id、parentId、name、orderNum。
|
||||
参考 src/views/demo/tree/index.vue 和 workflow/category。
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- 优先判断这是树表,不生成分页 `PageResult` 页面。
|
||||
- API 列表返回 `AxiosPromise<Tree2VO[]>`。
|
||||
- `Query` 不继承 `PageQuery`。
|
||||
- 页面使用 `handleTree`、`row-key`、`tree-props`、`useTreeTableExpand`、`el-tree-select`。
|
||||
- 新增子节点时从当前行带入 `parentId`。
|
||||
|
||||
## 案例 3:修改已有复杂列表页
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 修改 system/user 页面:
|
||||
1. 新增一个创建时间快捷筛选
|
||||
2. 导出按钮保留在更多菜单中
|
||||
3. 保持现有树筛选、导入、列显隐、详情抽屉和角色分配不变
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- 判断这是“已有复杂页面增强”,不是重新生成 CRUD。
|
||||
- 优先阅读 `src/views/system/user/index.vue`。
|
||||
- 保留 `TreePanel`、导入弹窗、`right-toolbar` 列显隐、`UserViewDrawer`、角色分配路由、权限控制。
|
||||
- 只增量修改搜索和查询参数处理。
|
||||
|
||||
## 案例 4:修改 workflow 页面
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 为 workflow/category 增加状态筛选和导出按钮,保持 workflow 模块自己的树表风格。
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- 优先看 `src/views/workflow/category/index.vue` 和 `src/api/workflow/category/*`。
|
||||
- 判断是否需要后端新增导出接口;前端导出路径保持 `workflow/category/export`。
|
||||
- 不迁移 system/user 的用户专属逻辑。
|
||||
- 保留树表、`useTreeTableExpand`、`handleTree` 和分类弹窗逻辑。
|
||||
|
||||
## 案例 5:只补 API 和 types
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 为 monitor/cache 补全前端 API 和 types,页面先不改。
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- 只维护 `src/api/monitor/cache/index.ts` 和 `src/api/monitor/cache/types.ts`。
|
||||
- 仍然检查同目录 monitor API 的 `export function` / `export const` 风格。
|
||||
- 返回类型使用 `AxiosPromise` from `@/utils/api-types`。
|
||||
- 不创建页面,不改路由。
|
||||
|
||||
## 案例 6:接入后端新增状态切换接口
|
||||
|
||||
### 用户提问示例
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 给 system/client 页面接入 PUT /system/client/changeStatus,状态字段 status,参考 gen 模板。
|
||||
```
|
||||
|
||||
### 期望执行方式
|
||||
|
||||
- API 增加 `changeClientStatus(id, status)`。
|
||||
- types 确认 `status` 类型是 string、number 还是 boolean。
|
||||
- 表格列用 `el-switch`,active/inactive 值跟后端字段类型一致。
|
||||
- 切换失败时回滚原状态。
|
||||
- 权限使用 `system:client:edit` 或后端实际权限。
|
||||
|
||||
## 推荐的高质量任务描述
|
||||
|
||||
```text
|
||||
使用 $frontend-crud-coding 在当前前端项目中新增 `/system/notice` 列表页增强:
|
||||
1. 保留现有页面
|
||||
2. 新增状态筛选和导出
|
||||
3. API 路径沿用后端接口
|
||||
4. 参考 system/config 的工具栏与导出交互
|
||||
5. 参考 aixun-ui Gitee 仓库 6.X-Vue 分支的 gen 模板补齐缺失 types
|
||||
```
|
||||
|
||||
## 不推荐的任务描述
|
||||
|
||||
```text
|
||||
帮我写个后台页面
|
||||
```
|
||||
|
||||
更好的写法至少补充:
|
||||
|
||||
- 模块名
|
||||
- 业务名
|
||||
- 后端接口前缀
|
||||
- 是新增还是修改
|
||||
- 是否需要分页、导出、树表、字典、权限
|
||||
- 想参考哪个现有页面
|
||||
@@ -0,0 +1,156 @@
|
||||
# 前端约定
|
||||
|
||||
## 优先参考的代码来源
|
||||
|
||||
- 默认远端基线:`https://gitee.com/AiXunKeJi/aixun-ui`,分支 `6.X-Vue`。引用远端文件时必须同时写明 `branch=6.X-Vue` 和仓库内路径。
|
||||
- 当前目标目录下最近似页面、API、types。
|
||||
- 标准单表:`src/views/demo/demo/index.vue`、`src/api/demo/demo/index.ts`、`src/api/demo/demo/types.ts`。
|
||||
- 树表:`src/views/demo/tree/index.vue`、`src/views/workflow/category/index.vue`。
|
||||
- 复杂系统页:`src/views/system/user/index.vue`、`src/views/system/role/index.vue`、`src/views/system/post/index.vue`、`src/views/system/config/index.vue`。
|
||||
- workflow 页:`src/views/workflow/*`、`src/api/workflow/*`。
|
||||
- 监控页:`src/views/monitor/*`、`src/api/monitor/*`。
|
||||
- 公共 hooks:`src/hooks/async/useLoading.ts`、`src/hooks/dialog/*`、`src/hooks/form/*`、`src/hooks/table/*`、`src/hooks/tree/*`。
|
||||
- 项目内 generator 模板:
|
||||
`gen/api.ts.ftl`
|
||||
`gen/types.ts.ftl`
|
||||
`gen/index.vue.ftl`
|
||||
`gen/index-tree.vue.ftl`
|
||||
|
||||
## 基础栈与格式
|
||||
|
||||
- 技术栈是 Vue 3 + TypeScript + Element Plus + Vite + Pinia。
|
||||
- 包管理按仓库现状使用 pnpm。
|
||||
- `.editorconfig` 要求 UTF-8、LF、2 空格缩进。
|
||||
- 当前仓库没有 `.prettierrc`;格式化使用 `pnpm run fmt`,lint 使用 `pnpm lint`。
|
||||
- 不要在一个页面里混入与仓库不一致的格式和写法。
|
||||
- 不要把本机绝对路径写进 skill 输出或参考文档;跨环境参考统一使用 Gitee 仓库 URL、分支和仓库内相对路径。
|
||||
|
||||
## API 文件规则
|
||||
|
||||
- 标准 API 文件放在 `src/api/<module>/<business>/index.ts`,同目录维护 `types.ts`。
|
||||
- import 顺序优先跟随附近文件,标准生成页常见形式:
|
||||
`import type { XxxForm, XxxQuery, XxxVO } from '@/api/<module>/<business>/types';`
|
||||
`import type { PageResult } from '@/api/types';`
|
||||
`import type { AxiosPromise } from '@/utils/api-types';`
|
||||
`import request from '@/utils/request';`
|
||||
- 不要从 `axios` 引入 `AxiosPromise`。
|
||||
- 列表分页接口通常返回 `AxiosPromise<PageResult<XxxVO>>`。
|
||||
- 树表列表接口通常返回 `AxiosPromise<XxxVO[]>`。
|
||||
- 详情接口返回 `AxiosPromise<XxxVO>`;复杂详情返回单独的 `InfoVO`。
|
||||
- 标准函数命名:
|
||||
`listXxx` -> `GET /<module>/<business>/list`
|
||||
`getXxx` -> `GET /<module>/<business>/{id}`
|
||||
`addXxx` -> `POST /<module>/<business>`
|
||||
`updateXxx` -> `PUT /<module>/<business>`
|
||||
`delXxx` -> `DELETE /<module>/<business>/{id or ids}`
|
||||
`changeXxxStatus` -> `PUT /<module>/<business>/changeStatus`
|
||||
- query string 用 `params`,请求体用 `data`。
|
||||
- 加密、防重复提交等 headers 直接写在请求配置里,例如用户重置密码中的 `isEncrypt`、`repeatSubmit`。
|
||||
- 当前仓库有些 API 使用 `export const`,有些使用 `export function`;新增标准 CRUD 优先跟随 `gen/api.ts.ftl` 和相邻模块。
|
||||
- 只有相邻模块已有 `export default { ... }` 聚合时才新增默认导出。
|
||||
|
||||
## 类型文件规则
|
||||
|
||||
- 标准类型定义 `VO`、`Form`、`Query`,必要时补 `InfoVO`、`TreeVO`、`ResetPwdForm` 等扩展类型。
|
||||
- `Form` 通常继承 `BaseEntity`。
|
||||
- 非树表 `Query` 通常继承 `PageQuery`。
|
||||
- 树表 `Query` 通常不继承 `PageQuery`。
|
||||
- ID 字段通常使用 `string | number`,批量删除参数使用 `string | number | Array<string | number>`。
|
||||
- Java 数值类型映射为 `number`,Boolean 映射为 `boolean`,日期/文本默认 `string`。
|
||||
- 日期范围查询保留 `params?: any`,不要因为它看起来宽松就删掉。
|
||||
- 列表对象、表单对象、查询对象职责分开;字段不一致时不要强行复用一个接口。
|
||||
- 能明确写出类型时不要用 `any`;组件库、字典或历史接口确实无法收窄时再保留。
|
||||
|
||||
## Vue 页面结构规则
|
||||
|
||||
- 页面优先使用 `<script setup name="Xxx" lang="ts">`。
|
||||
- 标准根节点使用 `class="p-2 app-container <module>-<business>-page"`;已有页面是特殊布局时保持原样。
|
||||
- 标准列表页结构:
|
||||
搜索卡片 `search-panel`
|
||||
表格卡片 `table-panel`
|
||||
工具栏 `toolbar-shell`
|
||||
表格 `data-table`
|
||||
`right-toolbar`
|
||||
`pagination`
|
||||
新增/编辑 `el-dialog`
|
||||
- 搜索区通过 `useSearchToggle` 控制 `showSearch`,头部点击切换。
|
||||
- 列表 loading 通过 `useLoading(true)` 和 `withLoading`。
|
||||
- 选择状态通过 `useTableSelection<XxxVO>(item => item.id)` 返回 `ids`、`single`、`multiple`、`handleSelectionChange`。
|
||||
- 表单弹窗优先使用 `useFormDialog({ form, formRef, initialFormData })`,返回 `dialog`、`resetForm`、`openDialog`、`showDialog`、`closeDialog`。
|
||||
- 仅需要简单弹窗状态或一个页面多个弹窗时使用 `useDialogState`。
|
||||
- 日期范围查询优先使用 `useDateRangeQuery()`;带后端参数名时使用 `useDateRangeQuery('CreateTime')` 等相邻页面模式。
|
||||
- 查询和表单状态通常放在 `reactive<PageData<Form, Query>>({ form, queryParams, rules })`,再 `toRefs(data)`。
|
||||
|
||||
## 页面行为规则
|
||||
|
||||
- `getList` 负责设置 loading、调用列表接口、回填列表和 `total`。
|
||||
- `handleQuery` 先把 `queryParams.value.pageNum = 1`,再调用 `getList()`;树表无分页时只调用 `getList()`。
|
||||
- `resetQuery` 使用 `useSearchReset`,分页页传 `pageNumKey: 'pageNum'`,需要时传 `pageSizeKey` 和 `resetExtras`。
|
||||
- `handleAdd` 使用 `openDialog('添加xxx')`;如果有树/联动选项,打开前后按现有页面加载选项。
|
||||
- `handleUpdate` 先 `reset()`,再按行或 `ids.value[0]` 查详情,`Object.assign(form.value, res.data)`,最后 `showDialog('修改xxx')`。
|
||||
- `submitForm` 表单校验通过后设置 `buttonLoading`,根据主键判断新增或修改,成功后 `modal.msgSuccess('操作成功')`、关闭弹窗、刷新列表。
|
||||
- `handleDelete` 使用 `modal.confirm(...)` 二次确认,再调用删除接口,成功提示并刷新。
|
||||
- `handleExport` 使用 `requestDownload('<module>/<business>/export', { ...queryParams.value }, '<business>_<timestamp>.xlsx')`。
|
||||
- 状态切换失败时要把 switch 值回滚,参考 generator 模板和现有 `system/user`、`system/role`。
|
||||
- 导入上传使用 `globalHeaders()`、`import.meta.env.VITE_APP_BASE_API`、`ElUpload`,优先参考 `system/user` 或流程定义页面。
|
||||
|
||||
## 字典、权限与公共工具
|
||||
|
||||
- 字典使用 `useDict`:
|
||||
`const { sys_normal_disable } = toRefs<any>(useDict('sys_normal_disable'));`
|
||||
- 新增代码默认使用当前项目主流 `v-hasPermi`。
|
||||
- 如果正在修改的文件已经混用或使用 `v-has-permi`,保持同文件现状,不为统一写法而重排无关代码。
|
||||
- `el-dropdown-item` 延迟加载导致权限指令不可靠时,使用 `v-if="checkPermi([...])"`,参考 `system/user`。
|
||||
- 常用工具:
|
||||
`modal` from `@/plugins/modal`
|
||||
`download as requestDownload` from `@/utils/request`
|
||||
`useDict` from `@/utils/dict`
|
||||
`checkPermi` from `@/utils/permission`
|
||||
`handleTree`、`parseStrEmpty` from `@/utils/aixun`
|
||||
|
||||
## 组件与样式规则
|
||||
|
||||
- 优先复用公共组件:`right-toolbar`、`pagination`、`DictTag` / `dict-tag`、`ImageUpload` / `image-upload`、`ImagePreview` / `image-preview`、`FileUpload` / `file-upload`、`Editor` / `editor`、`TreePanel`。
|
||||
- 标准页面尽量使用已有页面壳类,不堆大量内联样式。
|
||||
- 复杂页面需要 scoped SCSS 时优先复用:
|
||||
`@use '@/assets/styles/components/page-shell' as pageShell;`
|
||||
再按现有 mixin 使用。
|
||||
- 不要为了单页需求修改全局组件样式。
|
||||
- 类名保持模块语义:`system-client-page`、`workflow-category-page`、`demo-demo-page`。
|
||||
|
||||
## 树表规则
|
||||
|
||||
- 树表列表接口通常返回数组,页面通过 `handleTree<T>(res.data, 'id', 'parentId')` 组树。
|
||||
- 使用 `row-key`、`:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"`。
|
||||
- 展开/折叠使用 `useTreeTableExpand`。
|
||||
- 表单中上级节点使用 `el-tree-select`。
|
||||
- 新增子节点时从当前行回填 `parentId`。
|
||||
- 删除确认文案优先使用业务名称,而不是批量 ID 文案。
|
||||
|
||||
## 与 gen 模板的关系
|
||||
|
||||
- `gen` 是 aixun-ui 前端项目内的生成模板;默认远端位置是 `https://gitee.com/AiXunKeJi/aixun-ui/tree/6.X-Vue/gen`,分支必须标记为 `6.X-Vue`。
|
||||
- 本地仓库存在对应文件时优先读本地 `gen`,但不要把本地绝对路径写入 skill 或交付内容。
|
||||
- 新增标准单表页面时读取 `gen/index.vue.ftl`、`gen/api.ts.ftl`、`gen/types.ts.ftl`。
|
||||
- 新增树表页面时读取 `gen/index-tree.vue.ftl`、`gen/api.ts.ftl`、`gen/types.ts.ftl`。
|
||||
- `gen` 模板是标准骨架,不是最终答案;落地时仍要对照目标模块真实页面和公共 hooks。
|
||||
- 当前前端项目已经把生成页升级为 hooks 版:`useLoading`、`useFormDialog`、`useSearchReset`、`useTableSelection`、`useDateRangeQuery`。
|
||||
- 新增标准 CRUD 时,先从 `gen` 确认字段、权限、导出、状态切换、排序、日期范围等,再落成当前项目的实际页面壳。
|
||||
- 修改已有页面时,不要把现有强业务逻辑替换回 `gen` 的简化逻辑。
|
||||
|
||||
## 验证规则
|
||||
|
||||
- 只改文档或 skill:运行 skill 基础校验即可。
|
||||
- 改前端 TS/Vue/API/types:优先运行 `pnpm exec vue-tsc --noEmit`。
|
||||
- 改页面模板、import、权限或较多文件:再运行 `pnpm lint`。
|
||||
- 改公共 hooks、组件、构建相关或大范围页面:再运行 `pnpm build`。
|
||||
- 如果验证因为环境、依赖或权限失败,交付时说明失败命令和原因。
|
||||
|
||||
## 避免事项
|
||||
|
||||
- 不要从 `axios` 引入 `AxiosPromise`。
|
||||
- 不要绕开 `request` 或 `requestDownload` 自造请求/下载封装。
|
||||
- 不要跳过 `types.ts`,把类型全写在页面里。
|
||||
- 不要删除日期范围 `params`、权限指令、导出、导入、树筛选、列显隐等现有能力。
|
||||
- 不要为了“更整洁”重写复杂页面的大块业务逻辑。
|
||||
- 不要在新增标准页里使用与仓库不一致的 UI 壳或状态管理方式。
|
||||
@@ -0,0 +1,4 @@
|
||||
**
|
||||
!dist/**
|
||||
!nginx.conf
|
||||
!Dockerfile
|
||||
@@ -0,0 +1,21 @@
|
||||
# 告诉EditorConfig插件,这是根文件,不用继续往上查找
|
||||
root = true
|
||||
|
||||
# 匹配全部文件
|
||||
[*]
|
||||
# 缩进风格,可选space、tab
|
||||
indent_style = space
|
||||
# 缩进的空格数
|
||||
indent_size = 2
|
||||
# 设置字符集
|
||||
charset = utf-8
|
||||
# 结尾换行符,可选lf、cr、crlf
|
||||
end_of_line = lf
|
||||
# 在文件结尾插入新行
|
||||
trim_trailing_whitespace = true
|
||||
# 删除一行中的前后空格
|
||||
insert_final_newline = true
|
||||
|
||||
[*.md]
|
||||
insert_final_newline = false
|
||||
trim_trailing_whitespace = false
|
||||
@@ -0,0 +1,29 @@
|
||||
.DS_Store
|
||||
.history
|
||||
node_modules/
|
||||
dist/
|
||||
npm-debug.log*
|
||||
yarn-debug.log*
|
||||
yarn-error.log*
|
||||
**/*.log
|
||||
|
||||
tests/**/coverage/
|
||||
tests/e2e/reports
|
||||
selenium-debug.log
|
||||
|
||||
# Editor directories and files
|
||||
.idea
|
||||
.vscode
|
||||
*.iml
|
||||
*.suo
|
||||
*.ntvs*
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.local
|
||||
|
||||
package-lock.json
|
||||
yarn.lock
|
||||
|
||||
# 编译生成的文件
|
||||
auto-imports.d.ts
|
||||
components.d.ts
|
||||
@@ -0,0 +1,35 @@
|
||||
<template><main class="review-shell"><header class="review-header"><div><strong>数据治理 · 可视化工作台</strong><small>真实组件 / 合成数据 / 无业务写入</small></div><el-button @click="theme">切换亮暗</el-button></header><el-tabs v-model="view"><el-tab-pane name="completion" label="更多业务观察" /><el-tab-pane name="profile" label="数据剖析" /><el-tab-pane name="remediation" label="整改闭环" /><el-tab-pane name="quality-overview" label="质量总览" /><el-tab-pane name="catalog-overview" label="资产总览" /><el-tab-pane name="model" label="模型设计" /><el-tab-pane name="quality" label="质量观测" /><el-tab-pane name="catalog" label="资产地图" /><el-tab-pane name="lifecycle" label="治理流程" /></el-tabs><el-card shadow="never">
|
||||
<CompletionReview v-if="view === 'completion'" /><template v-if="view === 'profile'"><div class="mb-4"><el-radio-group v-model="profileScene"><el-radio-button value="normal">常规画像</el-radio-button><el-radio-button value="empty">空表画像</el-radio-button><el-radio-button value="invalid">异常统计</el-radio-button><el-radio-button value="none">无快照</el-radio-button></el-radio-group><el-checkbox v-model="profileUnknown">当前请求未知</el-checkbox></div><ProfileWorkspace :snapshot="profileScene === 'none' ? undefined : profileScene === 'empty' ? emptyProfileSnapshot : profileScene === 'invalid' ? invalidProfileSnapshot : profileSnapshot" :request-status="profileUnknown ? 'UNKNOWN' : 'SUCCEEDED'" target="commerce.customer_orders" /></template>
|
||||
<template v-if="view === 'remediation'"><RemediationWorkspace v-if="remediationSelected" :plan-id="remediationSelected" @close="remediationSelected = ''" @manage="remediationManage = true" /><RemediationBoard v-else :rows="remediationPlans" :total="37" @select="remediationSelected = String($event.planId)" /><div class="mt-3"><el-button @click="remediationScenario.failPlan = true">模拟计划读取失败</el-button><el-button @click="remediationScenario.failAttempts = true">模拟尝试读取失败</el-button><el-checkbox v-model="remediationScenario.delayAttempts">延迟执行观测</el-checkbox><el-checkbox v-model="remediationScenario.noRepairs">空修复请求</el-checkbox></div><el-dialog v-model="remediationManage" title="处理入口联动" width="min(500px, 100vw)"><p>合成预览已收到所选计划;正式页面打开原有整改详情及处理表单。这里不提交业务操作。</p></el-dialog></template>
|
||||
<QualityOverview v-if="view === 'quality-overview'" @close="view = 'quality'" /><CatalogOverview v-if="view === 'catalog-overview'" @close="view = 'catalog'" />
|
||||
<div v-if="view === 'catalog-overview'" class="mt-3"><el-select v-model="identityScenario.state" style="width:160px" aria-label="合成身份核验状态"><el-option v-for="state in ['MAPPED', 'UNMAPPED', 'AMBIGUOUS', 'UNKNOWN', 'FORBIDDEN']" :key="state" :label="state" :value="state" /></el-select><el-checkbox v-model="identityScenario.delay">延迟身份响应</el-checkbox><el-checkbox v-model="identityScenario.shortExpiry">6 秒证据有效期</el-checkbox><el-button @click="identityScenario.failRead = true">模拟登记读取失败</el-button></div>
|
||||
<ModelWorkspace v-if="view === 'model'" :design-id="design.designId" />
|
||||
<template v-if="view === 'quality'"><el-button class="mb-4" @click="empty = !empty">切换空数据</el-button><QualityObservation :rule="rule" :rows="empty ? [] : validations" :loading="false" error="" @close="view = 'model'" /></template>
|
||||
<template v-if="view === 'catalog'"><CatalogAtlas v-if="!catalogSelected" :tree="tree" @select="catalogSelected = true" /><template v-else><el-button class="mb-4" @click="catalogSelected = false">返回目录地图</el-button><CatalogPortfolio :detail="portfolio" /></template></template>
|
||||
<template v-if="view === 'lifecycle'"><el-button class="mb-4" @click="history = !history">{{ history ? '仅看当前' : '读取历史' }}</el-button><LifecycleJourney :detail="history ? lifecycle : { ...lifecycle, reviews:[], trajectories:[], impacts:[], notifications:[] }" :history-loaded="history" /></template>
|
||||
</el-card><div v-if="view === 'model'" class="mt-3"><el-button @click="scenario.fail = true">模拟下次字段读取失败</el-button><el-button @click="scenario.loseSaveReply = true">模拟下次保存响应丢失</el-button><span>合成接口保存 {{ scenario.modelSaves }} 次</span></div><div v-if="view.endsWith('overview')" class="mt-3"><el-button @click="aggregateScenario.fail = true">模拟下次总览读取失败</el-button><el-button @click="aggregateScenario.empty = !aggregateScenario.empty">切换总览空数据</el-button><span>已读取 {{ aggregateScenario.reads }} 次;切换场景后点击刷新</span></div></main></template>
|
||||
<script setup lang="ts">
|
||||
import { ref } from 'vue';
|
||||
import CompletionReview from './CompletionReview.vue';
|
||||
import ProfileWorkspace from '@/views/datagov/governance/data-profile/ProfileWorkspace.vue';
|
||||
import { profileSnapshot, emptyProfileSnapshot, invalidProfileSnapshot } from './profile';
|
||||
const profileScene = ref('normal'), profileUnknown = ref(false);
|
||||
import RemediationBoard from '@/views/datagov/governance/quality-remediation/RemediationBoard.vue';
|
||||
import RemediationWorkspace from '@/views/datagov/governance/quality-remediation/RemediationWorkspace.vue';
|
||||
import { remediationPlans, remediationScenario } from './remediation';
|
||||
const remediationSelected = ref(''); const remediationManage = ref(false);
|
||||
import QualityOverview from '@/views/datagov/governance/quality-rule/QualityOverview.vue';
|
||||
import CatalogOverview from '@/views/datagov/governance/asset-catalog/CatalogOverview.vue';
|
||||
import { aggregateScenario } from './aggregates';
|
||||
import { identityScenario } from './catalogIdentities';
|
||||
import ModelWorkspace from '@/views/datagov/governance/model-design/ModelWorkspace.vue';
|
||||
import QualityObservation from '@/views/datagov/governance/quality-rule/QualityObservation.vue';
|
||||
import CatalogAtlas from '@/views/datagov/governance/asset-catalog/CatalogAtlas.vue';
|
||||
import CatalogPortfolio from '@/views/datagov/governance/asset-catalog/CatalogPortfolio.vue';
|
||||
import LifecycleJourney from '@/views/datagov/governance/asset-lifecycle/LifecycleJourney.vue';
|
||||
import { design, rule, validations, tree, portfolio, lifecycle } from './data';
|
||||
import { scenario } from './api';
|
||||
const view = ref('completion'); const empty = ref(false); const catalogSelected = ref(false); const history = ref(false);
|
||||
function theme() { document.documentElement.classList.toggle('dark'); }
|
||||
</script>
|
||||
<style>.review-shell{padding:20px;max-width:1680px;margin:auto}.review-header{display:flex;justify-content:space-between;gap:16px;align-items:center}.review-header strong{font-size:20px}.review-header small{display:block;margin-top:6px;color:var(--el-text-color-secondary)}@media(max-width:600px){.review-shell{padding:10px}.review-header strong{font-size:16px}.el-card__body{padding:12px}}</style>
|
||||
@@ -0,0 +1,59 @@
|
||||
<template>
|
||||
<section>
|
||||
<div class="completion-controls"><el-select v-model="scene" aria-label="观察场景"><el-option v-for="item in scenes" :key="item[0]" :value="item[0]" :label="item[1]" /></el-select><el-checkbox v-model="empty">空数据</el-checkbox><el-checkbox v-model="unknown">未知或过期</el-checkbox></div>
|
||||
<StandardObservation v-if="scene==='standard'" :detail="standard" />
|
||||
<ClassificationMatrix v-if="scene==='classification'" :candidates="empty?[]:candidates" :labels="labels" @review="notice='已连接原候选复核入口'" />
|
||||
<PolicyMatrix v-if="scene==='policy'" :context="policy" />
|
||||
<IngestionTopology v-if="scene==='ingestion'" :detail="ingestion" />
|
||||
<NodeObservation v-if="scene==='node'" :detail="node" />
|
||||
<TransformationMapping v-if="scene==='transformation'" :rules="rules" scope-key="fixture-transformation" />
|
||||
<BatchMappingMap v-if="scene==='batch'" :mappings="empty?[]:mappings" source="业务库 · 订单明细" target="数仓 · 标准订单" scope-key="fixture-batch" />
|
||||
<FormulaDependencyMap v-if="scene==='formula'" :nodes="empty?[]:formula" :labels="formulaLabels" scope-key="fixture-formula" />
|
||||
<AlertObservation v-if="scene==='alert'" :detail="alert" />
|
||||
<AssetEvidenceMap v-if="scene==='asset'" :detail="asset" />
|
||||
<InventoryDifferences v-if="scene==='inventory'" :candidates="inventoryCandidates" :differences="empty?[]:differences" @resolve="notice='已连接原盘点差异处理入口'" />
|
||||
<MetricDependencyMap v-if="scene==='metric'" :lineage="empty?undefined:lineage" :labels="metricLabels" :impact="impact" impact-mode />
|
||||
<ApiDependencyMap v-if="scene==='api'" :dependencies="empty?[]:dependencies" management-id="101" label="订单分析接口" />
|
||||
<el-alert v-if="notice" :title="notice" type="info" :closable="false" />
|
||||
</section>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import StandardObservation from '@/views/datagov/governance/standard-operation/StandardObservation.vue';
|
||||
import ClassificationMatrix from '@/views/datagov/governance/security-classification/ClassificationMatrix.vue';
|
||||
import PolicyMatrix from '@/views/datagov/governance/security-policy-review/PolicyMatrix.vue';
|
||||
import IngestionTopology from '@/views/datagov/governance/metadata-ingestion/IngestionTopology.vue';
|
||||
import NodeObservation from '@/views/datagov/integration/collection-nodes/NodeObservation.vue';
|
||||
import TransformationMapping from '@/views/datagov/dataops/transformation-cleaning/TransformationMapping.vue';
|
||||
import BatchMappingMap from '@/views/datagov/dataops/batch-ingestion/BatchMappingMap.vue';
|
||||
import FormulaDependencyMap from '@/views/datagov/dataproduct/metric-calculation/FormulaDependencyMap.vue';
|
||||
import AlertObservation from '@/views/datagov/dataops/alert-events/AlertObservation.vue';
|
||||
import AssetEvidenceMap from '@/views/datagov/governance/asset-detail/AssetEvidenceMap.vue';
|
||||
import InventoryDifferences from '@/views/datagov/governance/asset-inventory/InventoryDifferences.vue';
|
||||
import MetricDependencyMap from '@/views/datagov/dataproduct/metric-lineage/MetricDependencyMap.vue';
|
||||
import ApiDependencyMap from '@/views/datagov/dataproduct/api-management/ApiDependencyMap.vue';
|
||||
const scenes = [['standard','标准覆盖与版本'],['classification','分类复核矩阵'],['policy','策略对照'],['ingestion','采集拓扑'],['node','采集节点能力'],['transformation','清洗字段映射'],['batch','同步字段映射'],['formula','公式依赖'],['alert','告警处置'],['asset','资产证据关联'],['inventory','盘点差异'],['metric','指标血缘与影响'],['api','接口消费依赖']];
|
||||
const scene=ref('batch'), empty=ref(false), unknown=ref(false), notice=ref('');
|
||||
watch(scene,()=>{empty.value=false;unknown.value=false;notice.value='';});
|
||||
const now=new Date().toISOString(), later=new Date(Date.now()+3600000).toISOString(), earlier=new Date(Date.now()-3600000).toISOString(), sha='a'.repeat(64);
|
||||
// These fixtures contain no real business data or credentials; this preview makes no writes.
|
||||
const standard=computed(()=>({publications:empty.value?[]:[{publicationId:1,publicationVersion:1,publishedAt:'2026-10-20 09:00',contentSnapshot:'客户编号:统一采用客户主键\n联系邮箱:允许为空\n地域:使用行政区划代码'},{publicationId:2,publicationVersion:2,publishedAt:now,contentSnapshot:'客户编号:统一采用客户主键\n联系邮箱:采用小写格式\n地域:使用行政区划代码\n订单金额:精确到两位小数'}],coverageAnalyses:empty.value?[]:[{analysisId:1,sourceType:'订单主题',sourceRef:'orders',observedAt:now,status:unknown.value?'UNKNOWN':'COMPLETED',referenceCoverageRate:85,adoptionRate:72,exemptionRate:8,issueRate:3},{analysisId:2,sourceType:'客户主题',sourceRef:'customers',observedAt:now,status:'UNKNOWN'}],effectEvaluations:empty.value?[]:[{evaluationId:1,createTime:now,status:unknown.value?'UNKNOWN':'PARTIAL',weightedScore:76,reason:'客户邮箱格式仍存在待复核问题'}]}));
|
||||
const candidates=[{candidateId:1,resourceRef:'customer.email',classificationCode:'个人联系信息',levelCode:'L2',status:'PENDING_REVIEW'},{candidateId:2,resourceRef:'customer.email',classificationCode:'个人联系信息',levelCode:'L2',status:'CONFIRMED'},{candidateId:3,resourceRef:'order.customer_id',classificationCode:'客户标识',levelCode:'L1',status:'CONFIRMED'},{candidateId:4,resourceRef:'customer.mobile',classificationCode:'个人联系信息',levelCode:'L2',status:'PENDING_REVIEW'},{candidateId:5,resourceRef:'customer.name',classificationCode:'客户标识',levelCode:'L1',status:'REJECTED'}];
|
||||
const labels={'customer.email':'客户 · 邮箱','order.customer_id':'订单 · 客户编号','customer.mobile':'客户 · 手机号码','customer.name':'客户 · 姓名'};
|
||||
const policy=computed(()=>({tableLabel:'客户信息表',action:'READ',observedAt:now,policies:empty.value?[]:[{key:'a',policy:{name:'分析人员只读',version:3}},{key:'b',policy:{name:'联系信息保护',version:2}}],facts:empty.value?[]:[{key:'f1',summary:'联系信息字段',fields:['email','mobile'],policyKeys:['b']},{key:'f2',summary:'客户标识读取范围',fields:['customer_id'],policyKeys:['a','b']},{key:'f3',summary:'集合范围存在交集',fields:[],policyKeys:[]}]}));
|
||||
const ingestion=computed(()=>({connector:{connectorId:1,name:'订单业务元数据采集',connectorType:'MYSQL',bindingMode:'DATA_SOURCE',sourceDataSourceName:'业务库 · commerce',sourceDataSourceVersion:4,version:3,status:'ACTIVE',updatedAt:now},policy:{version:4,enabled:true},recentRuns:empty.value?[]:[{runId:1,policyId:2,status:'SUCCEEDED',startedAt:earlier,finishedAt:now,snapshotSha256:sha},{runId:2,policyId:3,status:unknown.value?'UNKNOWN':'RUNNING',startedAt:now,snapshotSha256:sha}]}));
|
||||
const node=computed(()=>({node:{observationStale:unknown.value||empty.value},latestObservation:empty.value?undefined:{status:unknown.value?'UNKNOWN':'ONLINE',stale:unknown.value,observedAt:now,totalSlot:24,unassignedSlot:8,runningJobs:6,workers:4},capabilities:empty.value?[]:[{connectorType:'JDBC',runMode:'BATCH',direction:'SOURCE',status:'SUPPORTED',stale:unknown.value},{connectorType:'DORIS',runMode:'BATCH',direction:'SINK',status:'SUPPORTED',stale:unknown.value},{connectorType:'MYSQL',runMode:'STREAM',direction:'SOURCE',status:'UNKNOWN',stale:false}]}));
|
||||
const rules=computed(()=>({standardizationRules:empty.value?[]:[{ruleCode:'normalize_email',sourceField:'Email',targetField:'email',operation:'TEXT_LOWER'},{ruleCode:'amount_format',sourceField:'amount',targetField:'amount',operation:'NUMBER_FORMAT'}],completionRules:empty.value?[]:[{ruleCode:'region_default',field:'region',operation:'DEFAULT_VALUE'}],deduplicationRules:empty.value?[]:[{ruleCode:'order_key',keyFields:['order_id'],matchMode:'EXACT',keepPriority:'FIRST'}],dirtyIsolationRules:empty.value?[]:[{ruleCode:'invalid_amount',field:'amount',disposition:'ISOLATE'}]}));
|
||||
const mappings=[{sourceField:'order_id',targetField:'order_id',sourceType:'BIGINT',targetType:'BIGINT',transform:'NONE',filterValues:[]},{sourceField:'Email',targetField:'email',sourceType:'VARCHAR(128)',targetType:'STRING',transform:'LOWER',filterValues:[]},{sourceField:'amount',targetField:'amount',sourceType:'DECIMAL(18,2)',targetType:'DECIMAL(18,2)',transform:'NONE',filterValues:[]},{sourceField:'created_at',targetField:'created_at',sourceType:'DATETIME',targetType:'DATETIME',transform:'CAST',filterValues:[]}];
|
||||
const formula=computed(()=>[{nodeKey:'sales',nodeType:'METRIC',dependencies:[]},{nodeKey:'orders',nodeType:'METRIC',dependencies:[]},{nodeKey:'model',nodeType:'SEMANTIC_MODEL',dependencies:[]},{nodeKey:'aggregate',nodeType:'AGGREGATE',aggregateOperator:'SUM',dependencies:['sales','model']},{nodeKey:'average',nodeType:'ARITHMETIC',arithmeticOperator:'DIVIDE',dependencies:unknown.value?['absent']:['aggregate','orders']}]);
|
||||
const formulaLabels={sales:'订单销售金额',orders:'有效订单数量',model:'订单分析模型',aggregate:'销售金额求和',average:'平均客单价'};
|
||||
const alert=computed(()=>({summary:{status:unknown.value?'UNKNOWN':'PROCESSING',ruleName:'订单采集失败告警',metric:'FAILED_COUNT'},occurrences:empty.value?[]:[{occurrenceId:1,observedFrom:'2026-10-22 08:00',observedTo:'2026-10-22 09:00',metricValue:3,sampleCount:20,evidenceSha256:sha},{occurrenceId:2,observedFrom:'2026-10-22 09:00',observedTo:'2026-10-22 10:00',metricValue:2,sampleCount:18,evidenceSha256:sha}],timeline:empty.value?[]:[{timelineId:1,action:'创建事件',toStatus:'OPEN',createdAt:earlier,reasonSummary:'已记录采集失败观测'},{timelineId:2,action:'分派处理',toStatus:'PROCESSING',createdAt:now,reasonSummary:'由数据运营组检查来源连接'}],notifications:empty.value?[]:[{notificationId:1,recipientUserName:'示例处理人',contentSummary:'请核对订单采集状态',recordedAt:now,status:'RECORDED'}]}));
|
||||
const asset=computed(()=>({asset:{assetDetailId:1,assetFqn:'数仓 · 标准订单',version:2},sections:empty.value?[]:['SCHEMA','LINEAGE','QUALITY','SECURITY','USAGE'].map((sectionType,i)=>({sectionSnapshotId:i+1,snapshotVersion:2,sectionType,sourceType:'已登记章节观测',observedAt:now,reliable:!unknown.value&&i<3,evidenceState:i<3?'KNOWN':'UNKNOWN',payloadSha256:sha})),relations:empty.value?[]:[{relationRecordId:1,relationType:'加工任务',targetRef:'订单清洗任务',evidenceRef:'task:1',observedAt:now},{relationRecordId:2,relationType:'消费指标',targetRef:'订单销售金额',evidenceRef:'metric:1',observedAt:now},{relationRecordId:3,relationType:'所属模型',targetRef:'订单分析模型',evidenceRef:'model:1',observedAt:now}]}));
|
||||
const inventoryCandidates=[{candidateId:1,fqn:'commerce.orders'},{candidateId:2,fqn:'commerce.customers'},{candidateId:3,fqn:'warehouse.order_daily'}];
|
||||
const differences=[{differenceId:1,candidateId:1,differenceType:'NEW',status:'OPEN'},{differenceId:2,candidateId:1,differenceType:'OWNER_CONFLICT',status:'OPEN'},{differenceId:3,candidateId:2,differenceType:'DUPLICATE',status:'RESOLVED'},{differenceId:4,candidateId:3,differenceType:'MISSING',status:'OPEN'}];
|
||||
const metricLabels={source:'标准订单表',calculation:'订单销售额计算',metric:'订单销售金额',dashboard:'经营分析看板'};
|
||||
const lineage=computed(()=>({snapshotId:'101',state:unknown.value?'UNKNOWN':'RELIABLE',reliable:!unknown.value,observedAt:now,nodes:Object.entries(metricLabels).map(([nodeId])=>({nodeId,nodeType:nodeId.toUpperCase(),sourceId:nodeId,sourceSha256:sha})),edges:[['source','calculation'],['calculation','metric'],['metric','dashboard']].map(([fromNodeId,toNodeId],i)=>({edgeId:`e${i}`,fromNodeId,toNodeId,sourceId:'fixture',sourceSha256:sha}))}));
|
||||
const impact={lineageSnapshotId:'101',state:'RELIABLE',paths:[{nodeIds:['calculation','metric','dashboard']}]};
|
||||
const dependencies=computed(()=>[{dependencyId:1,snapshotId:1,status:unknown.value?'UNKNOWN':'RELIABLE',sourceType:'API_VERSION_SNAPSHOT',sourceRef:'api-version-snapshot:1',sourceSha256:sha,observedAt:now,expiresAt:unknown.value?earlier:later,createTime:now,callers:['经营分析看板','销售查询应用'],downstreamSystems:['管理驾驶舱','经营报告'],impacts:['接口字段调整需要核对两个调用方的请求响应模型']}]);
|
||||
</script>
|
||||
<style scoped>.completion-controls{display:flex;align-items:center;gap:16px;flex-wrap:wrap;margin-bottom:20px}.completion-controls .el-select{width:min(320px,100%)}</style>
|
||||
@@ -0,0 +1,34 @@
|
||||
import { reactive } from 'vue';
|
||||
import type { QualityOverviewData, ObservationState } from '@/api/datagov/quality-rule/observations';
|
||||
import type { CatalogOverviewData } from '@/api/datagov/asset-catalog/overview';
|
||||
export const aggregateScenario = reactive({ fail: false, empty: false, reads: 0 });
|
||||
const names = ['订单主键唯一性', '客户编号完整性', '订单金额取值范围', '每日订单量', '商品编号唯一性', '支付时间完整性', '退款金额范围', '渠道编码完整性', '客户维度重复校验', '库存数量范围', '物流单号完整性', '商品日快照行数'];
|
||||
export async function getQualityOverview(params: { from?: string; to?: string; after?: string }) {
|
||||
aggregateScenario.reads++; if (aggregateScenario.fail) { aggregateScenario.fail = false; throw new Error('合成场景:读取失败,请刷新重试'); }
|
||||
const from = params.from || '2026-10-08', to = params.to || '2026-10-21';
|
||||
const base = params.after && params.after !== '0' ? 12 : 0;
|
||||
const rules = aggregateScenario.empty ? [] : (base ? ['会员等级完整性', '成本中心唯一性', '营销转化范围'] : names).map((ruleName, i) => ({ ruleId: String(9007199254740993n + BigInt(base + i)), ruleName, currentTarget: ['dwd.fact_orders', 'dim.customer', 'dwd.fact_payment', 'dws.inventory_daily'][i % 4], currentDataSourceId: '9007199254741001', currentColumn: i === 3 ? undefined : 'id', version: 3 }));
|
||||
const cells: QualityOverviewData['cells'] = [];
|
||||
rules.forEach((rule, i) => { const start = Date.parse(from + 'T00:00:00Z'), end = Date.parse(to + 'T00:00:00Z'); for (let time = start, d = 0; time <= end && d < 31; time += 86400000, d++) {
|
||||
if ((i === 10 && d < 5) || (i === 11 && d > 10)) continue;
|
||||
const state: ObservationState = i === 1 && d === 13 ? 'UNKNOWN' : i === 8 && d < 4 ? 'LEGACY' : i === 5 && d === 12 ? 'EXECUTION_FAILED' : (i === 2 || i === 6) && d > 8 ? 'THRESHOLD_FAILED' : 'PASSED';
|
||||
const date = new Date(time).toISOString().slice(0, 10);
|
||||
const latest = { validationId: String(100000 + i * 100 + d), snapshotId: '9007199254741999', configSha256: (d > 8 ? 'a' : 'b').repeat(64), state, attempts: d === 13 ? 3 : 1, method: i === 3 ? 'ROW_COUNT' : 'NOT_NULL', unit: i === 3 ? '行数' : '违规记录数', value: state === 'UNKNOWN' || state === 'EXECUTION_FAILED' ? undefined : i === 3 ? 12843 : state === 'THRESHOLD_FAILED' ? 27 : 0, evidenceRef: state === 'UNKNOWN' ? undefined : 'fixture/validation/semantics/v1', errorCode: state === 'THRESHOLD_FAILED' ? 'QUALITY_RULE_THRESHOLD_NOT_MET' : state === 'EXECUTION_FAILED' ? 'SOURCE_UNAVAILABLE' : undefined, observedAt: state === 'UNKNOWN' ? undefined : date + ' 09:30:00', requestedAt: date + ' 09:29:00' };
|
||||
if (i === 8 && d < 4) { latest.value = undefined; latest.method = 'UNKNOWN'; latest.unit = '单位未声明'; latest.evidenceRef = 'fixture/legacy'; }
|
||||
const configurations = [latest];
|
||||
if (d === 9) configurations.push({ ...latest, validationId: String(80000 + i), snapshotId: '9007199254741998', configSha256: 'b'.repeat(64), state: 'PASSED', attempts: 2, value: 0, errorCode: undefined, observedAt: date + ' 08:30:00', requestedAt: date + ' 08:29:00' });
|
||||
const unverified = i === 8 && d < 4, historical = i === 0 && d < 8;
|
||||
const cell: QualityOverviewData['cells'][number] = { ...latest, ruleId: rule.ruleId, date, attempts: configurations.reduce((sum, item) => sum + item.attempts, 0), versionChanged: d === 9, targetKey: unverified ? 'unverified' : historical ? 'old-orders' : 'current-' + i, targetStatus: unverified ? 'UNVERIFIED' : 'VERIFIED', target: unverified ? undefined : historical ? 'ods.order_archive' : rule.currentTarget, targetDataSourceId: unverified ? undefined : rule.currentDataSourceId, targetColumn: unverified ? undefined : rule.currentColumn, configurations };
|
||||
cells.push(cell);
|
||||
if (i === 0 && d === 8) {
|
||||
const prior = { ...latest, validationId: '79999', snapshotId: '9007199254741997', state: 'THRESHOLD_FAILED' as const, value: 18, observedAt: date + ' 08:00:00', requestedAt: date + ' 07:59:00', errorCode: 'QUALITY_RULE_THRESHOLD_NOT_MET' };
|
||||
cells.push({ ...cell, ...prior, targetKey: 'old-orders', target: 'ods.order_archive', configurations: [prior] });
|
||||
}
|
||||
} });
|
||||
return { data: { scopeHash: 'c'.repeat(64), from, to, dateBasis: 'OBSERVED_AT_ELSE_REQUESTED_AT', timezone: 'UNDECLARED', aggregationBasis: 'RULE_FROZEN_TARGET_DAY_V1', readAt: '2026-10-22T02:00:00Z', rules, cells, nextCursor: base || aggregateScenario.empty ? undefined : rules.at(-1)?.ruleId, truncated: !base && !aggregateScenario.empty } satisfies QualityOverviewData };
|
||||
}
|
||||
export async function getCatalogOverview() {
|
||||
aggregateScenario.reads++; if (aggregateScenario.fail) { aggregateScenario.fail = false; throw new Error('合成场景:读取失败,请刷新重试'); }
|
||||
const groups = aggregateScenario.empty ? [] : ['交易域', '客户域', '商品域', '财务域', '营销域', '供应链域', '运营指标', '共享维度', '待建设目录'].map((name, i) => ({ catalogId: String(9007199254740993n + BigInt(i)), name, status: i < 6 ? 'PUBLISHED' : 'DRAFT', types: i === 8 ? [] : ['TABLE', 'DATASET', 'FILE', 'REPORT', 'API', 'MODEL'].map((type, j) => ({ type, reliable: Math.max(0, 140 - i * 14 - j * 18), uncertain: (i + j) % 4 === 0 ? 8 : 0 })) }));
|
||||
return { data: { scopeHash: 'd'.repeat(64), readAt: '2026-10-21T02:00:00Z', lastRegistrationUpdate: '2026-10-21 09:42:00', countKind: 'REGISTRATION', truncated: false, groups } satisfies CatalogOverviewData };
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
import { reactive } from 'vue';
|
||||
import { design } from './data';
|
||||
import type { LogicalSnapshot } from '@/api/datagov/model-design/types';
|
||||
export const scenario = reactive({ fail: false, loseSaveReply: false, modelSaves: 0 });
|
||||
let savedDesign = structuredClone(design);
|
||||
const receipts = new Map<string, string>();
|
||||
const blocked = async () => { throw new Error('此检查环境不执行业务写入'); };
|
||||
export const getModelDesign = async () => ({ data: structuredClone(savedDesign) });
|
||||
export const saveLogicalModel = async (id: string, command: { snapshot: LogicalSnapshot; version: string | number }, key: string) => {
|
||||
const body = JSON.stringify(command);
|
||||
if (receipts.has(key)) { if (receipts.get(key) !== body) throw new Error('合成接口:原键载荷变化'); return { data: { result: structuredClone(savedDesign) } }; }
|
||||
if (String(id) !== String(savedDesign.designId) || String(command.version) !== String(savedDesign.version)) throw { response: { status: 409 } };
|
||||
savedDesign = { ...savedDesign, logical: JSON.parse(JSON.stringify(command.snapshot)), version: String(BigInt(savedDesign.version) + 1n), currentVersionNo: String(BigInt(savedDesign.currentVersionNo) + 1n) };
|
||||
receipts.set(key, body); scenario.modelSaves++;
|
||||
if (scenario.loseSaveReply) { scenario.loseSaveReply = false; throw new Error('合成接口:已保存但响应丢失'); }
|
||||
return { data: { result: structuredClone(savedDesign) } };
|
||||
};
|
||||
export const getModelLayout = async (_id: string, layer: string) => ({ data: { designId: design.designId, layer: layer.toUpperCase(), layoutVersion:'0',snapshotSha256:'a'.repeat(64),positions:[],viewport:null,stale:false,updatedAt:null,droppedNodeIds:[] } });
|
||||
export const pageModelDesignVersions = async () => { const old = structuredClone(design); old.physical.tables[0].fields[2].nullable = true; old.physical.tables[0].fields[2].dataType = 'DOUBLE'; return { data: { rows: [{ ...old, versionNo:'7',versionId:'v7',changeSummary:'调整金额类型与非空约束',createTime:'2026-10-20T09:00:00' }], total:1 } }; };
|
||||
export const sourceCandidates = async () => ({ data: [{ tableId:'fixture-table',label:'交易库 / orders',engineType:'MYSQL' }] });
|
||||
export const sourceStructure = async (id: string) => { if (scenario.fail) { scenario.fail = false; throw new Error('模拟字段读取失败'); } return {data: { tableId:id,sourceVersion:'12',revision:'3',observedAt:'2026-10-21T08:30:00',engineType:'MYSQL',fields:[{name:'id',dataType:'BIGINT',nullable:false,restricted:false},{name:'customer_id',dataType:'BIGINT',nullable:null,restricted:false},{name:'amount',dataType:'DOUBLE',nullable:true,restricted:false}],uniqueKeys:[['id']] }}; };
|
||||
export const saveModelLayout=blocked,saveConceptualModel=blocked,savePhysicalModel=blocked,saveModelDefinition=blocked,structureContext=blocked,generateStructure=blocked,reviewStructure=blocked,prepareStructure=blocked;
|
||||
@@ -0,0 +1,82 @@
|
||||
import { reactive } from 'vue';
|
||||
import type { CatalogIdentityCommand, CatalogIdentityInspection, CatalogIdentityLink, CatalogIdentityRequestReceipt } from '@/api/datagov/asset-catalog/identity';
|
||||
export { getCatalogOverview } from './aggregates';
|
||||
export const identityScenario = reactive({ state: 'MAPPED', failRead: false, delay: false, shortExpiry: false });
|
||||
const catalogs = ['交易域', '客户域', '商品域', '财务域', '营销域', '供应链域', '运营指标', '共享维度', '待建设目录'].map((name, i) => ({ catalogId: String(9007199254740993n + BigInt(i)), name, status: 'PUBLISHED' }));
|
||||
const fixtures = [
|
||||
['asset:orders:daily', '每日交易订单', [0, 1, 3, 6]],
|
||||
['asset:customer:profile', '客户统一画像', [1, 6, 7]],
|
||||
['asset:product:master', '商品主数据', [0, 7]],
|
||||
['asset:revenue:monthly', '月度营收指标', [3, 6]],
|
||||
['asset:Orders:daily', '每日交易订单', [0]],
|
||||
['asset:city:dimension', '城市维度', [7]]
|
||||
] as const;
|
||||
const rows = fixtures.flatMap(([assetRef, name, positions], fi) => positions.map((c, i) => ({ registrationId: String(9107199254740993n + BigInt(fi * 10 + i)), catalogId: catalogs[c].catalogId, assetRef, name: fi === 0 && i === 2 ? '订单收入基础表' : name, type: fi === 0 && i === 3 ? 'DATASET' : 'TABLE', reliable: i !== 1, version: '1' })));
|
||||
export async function getCatalogRegistrations(catalogId?: string) {
|
||||
if (identityScenario.failRead) { identityScenario.failRead = false; throw new Error('合成场景:当前目录读取失败,请重试'); }
|
||||
return { data: { scopeHash: 'e'.repeat(64), readAt: new Date().toISOString(), catalogs: catalogs.filter(c => !catalogId || c.catalogId === catalogId), rows: rows.filter(r => !catalogId || r.catalogId === catalogId) } };
|
||||
}
|
||||
export async function resolveIdentityReference(assetRef: string) {
|
||||
const state = identityScenario.state; const shortExpiry = identityScenario.shortExpiry;
|
||||
if (identityScenario.delay) await new Promise(resolve => setTimeout(resolve, 4000));
|
||||
if (state === 'FORBIDDEN') throw new Error('合成场景:无权读取资产详情或生命周期');
|
||||
if (state !== 'MAPPED') return { data: { state, identity: null, error: state === 'AMBIGUOUS' ? 'SOURCE_CONFLICT' : 'OWNER_UNKNOWN' } };
|
||||
return { data: { state, error: null, identity: { assetId: '9007199254741237', assetRef, businessVersion: '4', sourceEvidence: [{ observedAt: new Date(Date.now() - 1000).toISOString(), expiresAt: new Date(Date.now() + (shortExpiry ? 6000 : 300000)).toISOString() }] } } };
|
||||
}
|
||||
const links = new Map<string, CatalogIdentityLink>();
|
||||
const linkReceipts = new Map<string, { command: string; link: CatalogIdentityLink }>();
|
||||
const canceledRequests = new Set<string>();
|
||||
const requestScope = (id: string, key: string) => JSON.stringify([id, key]);
|
||||
export async function inspectCatalogIdentity(id: string): Promise<{ data: CatalogIdentityInspection }> {
|
||||
const row = rows.find(value => value.registrationId === id);
|
||||
if (!row) throw new Error('合成场景:登记不存在');
|
||||
const resolution = row.type === 'TABLE' ? (await resolveIdentityReference(row.assetRef)).data : { state: 'UNKNOWN', identity: null };
|
||||
const candidate = resolution.identity ? { assetId: String(resolution.identity.assetId), businessVersion: '4', evidenceSha256: 'a'.repeat(64), expiresAt: resolution.identity.sourceEvidence[0].expiresAt } : null;
|
||||
const link = links.get(id) || null;
|
||||
return { data: { registrationId: id, registrationVersion: row.version, assetRef: row.assetRef, readAt: new Date().toISOString(),
|
||||
resolutionState: resolution.state as CatalogIdentityInspection['resolutionState'], candidate, link,
|
||||
associationState: !link ? 'UNLINKED' : Date.parse(link.expiresAt) <= Date.now() ? 'STALE' : candidate ? 'CURRENT' : 'UNKNOWN', unavailableReason: row.type === 'TABLE' ? undefined : '当前已有身份来源只支持表;其他登记类型需先建立对应来源证明' } };
|
||||
}
|
||||
export async function saveCatalogIdentity(id: string, command: CatalogIdentityCommand, key: string) {
|
||||
if (canceledRequests.has(requestScope(id, key))) throw { response: { status: 409 } };
|
||||
const receipt = linkReceipts.get(key);
|
||||
if (receipt) { if (receipt.command !== JSON.stringify(command) || receipt.link.registrationId !== id) throw { response: { status: 409 } }; return { data: receipt.link }; }
|
||||
const current = (await inspectCatalogIdentity(id)).data;
|
||||
if (canceledRequests.has(requestScope(id, key))) throw { response: { status: 409 } };
|
||||
if (!current.candidate || command.assetId !== current.candidate.assetId || command.registrationVersion !== current.registrationVersion || command.expectedLinkVersion !== (current.link?.version || '0')) throw { response: { status: 409 } };
|
||||
const link = { linkId: String(9207199254740993n + BigInt(links.size)), registrationId: id, version: String(BigInt(command.expectedLinkVersion) + 1n), ...current.candidate, linkedAt: new Date().toISOString(), requestId: `SYNTHETIC-${key}` };
|
||||
links.set(id, link); linkReceipts.set(key, { command: JSON.stringify(command), link }); return { data: link };
|
||||
}
|
||||
export async function readCatalogIdentityRequest(id: string, key: string): Promise<{ data: CatalogIdentityRequestReceipt }> {
|
||||
const link = linkReceipts.get(key)?.link;
|
||||
return { data: { state: link?.registrationId === id ? 'COMPLETED' : canceledRequests.has(requestScope(id, key)) ? 'CANCELED_NO_WRITE' : 'NOT_OBSERVED', registrationId: id, requestKey: key, link: link?.registrationId === id ? link : null } };
|
||||
}
|
||||
export async function cancelCatalogIdentityRequest(id: string, key: string): Promise<{ data: CatalogIdentityRequestReceipt }> {
|
||||
if (!rows.some(row => row.registrationId === id)) throw { response: { status: 404 } };
|
||||
const result = await readCatalogIdentityRequest(id, key);
|
||||
if (result.data.state === 'COMPLETED') return result;
|
||||
canceledRequests.add(requestScope(id, key));
|
||||
return readCatalogIdentityRequest(id, key);
|
||||
}
|
||||
export async function getCatalogIdentitySummary(catalogId?: string) {
|
||||
const registrations = (await getCatalogRegistrations(catalogId)).data;
|
||||
let expires: number | undefined;
|
||||
const stats = { registrations: registrations.rows.length, tableRegistrations: 0, verifiedRegistrations: 0, distinctIdentities: 0, duplicateRegistrations: 0, unlinked: 0, stale: 0, unknown: 0, unsupported: 0 };
|
||||
const distinct = new Set<string>();
|
||||
for (const row of registrations.rows) {
|
||||
if (row.type !== 'TABLE') { stats.unsupported++; continue; }
|
||||
stats.tableRegistrations++;
|
||||
if (!row.reliable) { stats.unknown++; continue; }
|
||||
const value = (await inspectCatalogIdentity(row.registrationId)).data;
|
||||
if (value.associationState === 'CURRENT' && value.link && value.candidate) {
|
||||
stats.verifiedRegistrations++; distinct.add(value.link.assetId);
|
||||
expires = Math.min(expires ?? Infinity, Date.parse(value.link.expiresAt), Date.parse(value.candidate.expiresAt));
|
||||
}
|
||||
else if (value.associationState === 'UNLINKED') stats.unlinked++;
|
||||
else if (value.associationState === 'STALE') stats.stale++;
|
||||
else stats.unknown++;
|
||||
}
|
||||
if (expires !== undefined && expires <= Date.now()) throw new Error('合成场景:核验证据已过期,请重新核验');
|
||||
stats.distinctIdentities = distinct.size; stats.duplicateRegistrations = stats.verifiedRegistrations - distinct.size;
|
||||
return { data: { scopeHash: registrations.scopeHash, readAt: new Date().toISOString(), expiresAt: expires === undefined ? undefined : new Date(expires).toISOString(), countKind: 'DISTINCT_CURRENT_LINKED_TABLE_IDENTITY', ...stats } };
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { DesignView } from '@/api/datagov/model-design/types';
|
||||
import type { RuleVO, ValidationHistory } from '@/api/datagov/quality-rule/types';
|
||||
import type { AssetCatalogDetail, AssetCatalogTreeNode } from '@/api/datagov/asset-catalog/types';
|
||||
import type { AssetLifecycleDetail } from '@/api/datagov/asset-lifecycle/types';
|
||||
const entities = [{ code: 'ORDER', name: '订单', conceptualEntityCode: 'BUSINESS_ORDER', attributes: [{ code: 'ID', name: '订单编号', dataType: 'BIGINT', nullable: false, conceptualEntityCode: 'BUSINESS_ORDER', conceptualAttributeCode: 'ORDER_NUMBER' }, { code: 'CUSTOMER_ID', name: '客户编号', dataType: 'BIGINT', nullable: false }, { code: 'AMOUNT', name: '订单金额', dataType: 'DECIMAL', nullable: false }] }, { code: 'CUSTOMER', name: '客户', conceptualEntityCode: 'BUSINESS_CUSTOMER', attributes: [{ code: 'ID', name: '客户编号', dataType: 'BIGINT', nullable: false, conceptualEntityCode: 'BUSINESS_CUSTOMER', conceptualAttributeCode: 'CUSTOMER_NUMBER' }, { code: 'NAME', name: '客户名称', dataType: 'VARCHAR', nullable: false, conceptualEntityCode: 'BUSINESS_CUSTOMER', conceptualAttributeCode: 'CUSTOMER_NAME' }] }];
|
||||
export const design = { designId: '9007199254740997', designCode: 'ORDER_DOMAIN', designName: '交易主题模型', ownerType: 'USER', ownerId: '9007199254740993', ownerName: '演示负责人', status: 'DRAFT', currentVersionNo: '8', version: '8', contentSha256: 'a'.repeat(64), createDept: 'fixture-org', conceptual: { entities: [{ code: 'BUSINESS_ORDER', name: '业务订单', attributes: [{ code: 'ORDER_NUMBER', name: '订单号' }, { code: 'ORDER_AMOUNT', name: '订单金额' }] }, { code: 'BUSINESS_CUSTOMER', name: '业务客户', attributes: [{ code: 'CUSTOMER_NUMBER', name: '客户号' }, { code: 'CUSTOMER_NAME', name: '客户名称' }] }], relations: [{ code: 'CUSTOMER_ORDER', name: '客户下单', sourceEntityCode: 'BUSINESS_CUSTOMER', targetEntityCode: 'BUSINESS_ORDER', cardinality: 'ONE_TO_MANY' }] }, logical: { entities, relations: [], keys: [], businessRules: [] }, physical: { tables: entities.map(e => ({ code: e.code === 'ORDER' ? 'ORDERS' : 'CUSTOMERS', name: e.name + '明细表', engineType: 'MYSQL', logicalEntityCode: e.code, fields: e.attributes.map(f => ({ code: f.code, name: f.name, dataType: f.dataType, nullable: f.nullable, logicalEntityCode: e.code, logicalAttributeCode: f.code })), partitions: [], indexes: [], constraints: [] })) }, sourceEvidence: { grains: [], fields: [] } } as DesignView;
|
||||
export const rule = { ruleId: '9007199254740997', ruleName: '订单金额完整性', objectFqn: 'demo.trade.orders', targetColumn: 'amount' } as unknown as RuleVO;
|
||||
export const validations = Array.from({ length: 16 }, (_, i) => ({ validationId: String(9000 + i), requestId: 'fixture-' + i, ruleId: rule.ruleId, snapshotId: i < 9 ? '4' : '5', configSha256: (i < 9 ? 'a' : 'b').repeat(64), status: i === 15 ? 'UNKNOWN' : i === 11 ? 'FAILED' : i === 6 || i === 8 ? 'FAILED' : 'SUCCEEDED', observedValue: i === 15 || i === 11 ? undefined : [0, 0, 1, 0, 2, 1, 8, 1, 9, 0, 1, 0, 0, 1, 0, 0][i], thresholdOperator: 'LE', thresholdValue: 2, violationCount: i === 6 || i === 8 ? 1 : 0, evidenceRef: i === 15 ? undefined : 'fixture-evidence-' + i, errorCode: i === 11 ? 'SOURCE_TIMEOUT' : i === 6 || i === 8 ? 'QUALITY_RULE_THRESHOLD_NOT_MET' : undefined, observedAt: i === 15 ? undefined : `2026-10-${String(14 + Math.floor(i / 2)).padStart(2, '0')}T${i % 2 ? '16' : '09'}:00:00`, createdAt: `2026-10-${String(14 + Math.floor(i / 2)).padStart(2, '0')}T${i % 2 ? '16' : '09'}:00:00` })).toReversed() as unknown as ValidationHistory[];
|
||||
export const tree = [{ catalogId: '101', catalogName: '企业数据资产', catalogCode: 'ENTERPRISE', status: 'PUBLISHED', children: [{ catalogId: '102', parentId: '101', catalogName: '交易域', catalogCode: 'TRADE', status: 'PUBLISHED', children: [{ catalogId: '105', parentId: '102', catalogName: '订单主题', catalogCode: 'ORDER', status: 'PUBLISHED' }, { catalogId: '106', parentId: '102', catalogName: '支付主题', catalogCode: 'PAYMENT', status: 'DRAFT' }] }, { catalogId: '103', parentId: '101', catalogName: '客户域', catalogCode: 'CUSTOMER', status: 'PUBLISHED' }, { catalogId: '104', parentId: '101', catalogName: '经营分析', catalogCode: 'ANALYTICS', status: 'DRAFT' }] }] as unknown as AssetCatalogTreeNode[];
|
||||
export const portfolio = { node: { catalogId: '102', catalogName: '交易域', description: '交易数据、分析报表与服务接口的统一资产目录' }, assets: ['TABLE','TABLE','TABLE','DATASET','REPORT','API','MODEL','FILE'].map((type,i)=>({catalogAssetId:String(i),assetName:['订单明细','支付流水','订单归档','交易分析数据集','交易日报','订单查询服务','交易主题模型','对账文档'][i],assetType:type,assetFqn:'demo.trade.asset_'+i,assetRef:'asset-'+i,reliable:i!==2,observedAt:'2026-10-21T08:30:00'})), publications:[],permissions:[],trajectories:[] } as unknown as AssetCatalogDetail;
|
||||
export const lifecycle = { asset: { lifecycleId:'9007199254740997',name:'订单明细数据资产',assetRef:'demo.trade.orders',status:'ACTIVE',currentBusinessVersion:3 }, currentSnapshot: { name:'订单明细数据资产',assetRef:'demo.trade.orders',responsibilities:[],governanceAttributes:[] }, versions:[],snapshots:[],reviews:[{reviewId:'r2',reviewType:'CHANGE',decision:'APPROVED',reason:'已补充责任人及质量规则,批准变更',snapshotId:'s3',snapshot:{name:'订单明细数据资产',assetRef:'demo.trade.orders'},producedBusinessVersion:3,createTime:'2026-10-21T10:00:00'},{reviewId:'r1',reviewType:'CHANGE',decision:'REJECTED',reason:'质量证据尚不完整,请补充后重新提交',snapshotId:'s2',snapshot:{name:'订单明细数据资产',assetRef:'demo.trade.orders'},createTime:'2026-10-20T09:30:00'}],impacts:[],notifications:[],trajectories:[{trajectoryId:'t2',summary:'变更审核通过',beforeStatus:'ACTIVE',afterStatus:'ACTIVE',createTime:'2026-10-21T10:00:00'},{trajectoryId:'t1',summary:'首次发布生效',beforeStatus:'DRAFT',afterStatus:'ACTIVE',createTime:'2026-10-19T09:30:00'}] } as unknown as AssetLifecycleDetail;
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>治理可视化 · 合成数据检查</title></head><body><div id="app"></div><script type="module" src="/main.ts"></script></body></html>
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createApp } from 'vue';
|
||||
import ElementPlus from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/assets/styles/index.scss';
|
||||
import App from './App.vue';
|
||||
createApp(App).use(ElementPlus).directive('hasPermi', {}).component('Pagination', { render: () => null }).mount('#app');
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { ProfileDetail, ColumnProfile } from '@/api/datagov/data-profile/types';
|
||||
const field = (column: string, dataType: string, nulls: number, distinct: number, extra: Partial<ColumnProfile> = {}): ColumnProfile => ({ column, dataType, nullCount: String(nulls), nullRate: nulls / 128000, distinctCount: String(distinct), distinctRate: distinct / 128000, topValues: [], patterns: [], ...extra });
|
||||
export const profileSnapshot: NonNullable<ProfileDetail['snapshot']> = {
|
||||
snapshotId: 5001, requestId: 4001, attemptId: 6001, rowCount: '128000', observedAt: '2026-10-22T10:42:18',
|
||||
columns: [
|
||||
field('customer_email', 'VARCHAR', 24320, 98240, { minimum: 'sample-a@example.invalid', maximum: 'sample-z@example.invalid', topValues: [{ value: 'service@example.invalid', count: '3200' }, { value: 'guest@example.invalid', count: '2100' }, { value: '', count: '1400' }, { value: 'sales@example.invalid', count: '680' }, { value: 'support@example.invalid', count: '420' }], patterns: [{ pattern: 'EMAIL', count: 760 }, { pattern: 'NULL', count: 190 }, { pattern: 'EMPTY', count: 35 }, { pattern: 'TEXT', count: 15 }] }),
|
||||
field('region', 'VARCHAR', 6400, 8, { minimum: '东北', maximum: '西部', topValues: [{ value: '华东', count: 46000 }, { value: '华南', count: 32000 }, { value: '华北', count: 21000 }, { value: '西南', count: 11200 }, { value: '华中', count: 6400 }, { value: '东北', count: 2800 }, { value: '西北', count: 1800 }, { value: '其他', count: 400 }], patterns: [{ pattern: 'TEXT', count: 950 }, { pattern: 'NULL', count: 50 }] }),
|
||||
field('order_amount', 'DECIMAL', 1280, 85432, { minimum: '0.00', maximum: '26840.50', average: '684.52', standardDeviation: '1253.18', topValues: [{ value: '99.00', count: 8240 }, { value: '199.00', count: 3860 }, { value: '299.00', count: 2140 }, { value: '59.90', count: 1580 }], patterns: [{ pattern: 'DECIMAL', count: 990 }, { pattern: 'NULL', count: 10 }] }),
|
||||
field('order_id', 'BIGINT', 0, 128000, { minimum: '100000', maximum: '227999', patterns: [{ pattern: 'INTEGER', count: 1000 }] }),
|
||||
field('created_at', 'TIMESTAMP', 0, 121600, { patterns: [{ pattern: 'TIMESTAMP', count: 1000 }] }),
|
||||
field('is_active', 'BOOLEAN', 0, 2, { topValues: [{ value: 'true', count: 116800 }, { value: 'false', count: 11200 }], patterns: [{ pattern: 'BOOLEAN', count: 1000 }] })
|
||||
]
|
||||
};
|
||||
export const emptyProfileSnapshot = { ...profileSnapshot, snapshotId: 5002, rowCount: 0, columns: [field('empty_field', 'VARCHAR', 0, 0)] };
|
||||
export const invalidProfileSnapshot = { ...profileSnapshot, snapshotId: 5003, columns: [field('inconsistent_count', 'VARCHAR', 200000, 10, { topValues: [{ value: 'invalid', count: '-2' }], patterns: [{ pattern: 'TEXT', count: 1001 }] })] };
|
||||
@@ -0,0 +1,27 @@
|
||||
import { reactive } from 'vue';
|
||||
import type { PlanVO, RepairVO, AttemptVO, TimelineVO } from '../src/api/datagov/quality-remediation/types';
|
||||
export const remediationScenario = reactive({ failPlan: false, failAttempts: false, delayAttempts: false, noRepairs: false });
|
||||
const labels = ['订单手机号空值修复', '客户证件格式规范', '交易金额重复记录', '客户归属字段缺失', '指标口径修正', '商品编码重复', '账期字段一致性'];
|
||||
export const remediationPlans: PlanVO[] = labels.map((title, i) => ({ planId: String(9007199254741101n + BigInt(i)), planNo: `ZG-20261022-00${i + 1}`, issueLogicalId: `issue:${i + 1}`, issueDisplaySnapshot: title, rootCauseLogicalId: `root:${i + 1}`, rootCauseDisplaySnapshot: '增量任务字段映射遗漏,历史分区未覆盖', rootCauseEvidenceSha: 'a'.repeat(64), cause: '业务字段已新增,但旧增量任务仍使用早期映射。', measure: '校正字段映射并补录历史分区\n重新执行质量规则,保留修复前后和验证快照', ownerLogicalId: 'user:fixture', dueDate: '2026-10-28', verificationMethod: '按同一目标与冻结配置复测,核对修复后和验证证据', status: (['OPEN', 'ASSIGNED', 'PROCESSING', 'PROCESSING', 'RESOLVED', 'VERIFIED', 'CLOSED'] as const)[i], version: 4, updateTime: '2026-10-22T08:40:00' }));
|
||||
const slicePage = <T>(rows: T[], params: { pageNum?: number; pageSize?: number }) => ({ data: { rows: rows.slice(((params.pageNum || 1) - 1) * (params.pageSize || 20), (params.pageNum || 1) * (params.pageSize || 20)), total: rows.length } });
|
||||
export async function getPlan(id: string | number) { if (remediationScenario.failPlan) { remediationScenario.failPlan = false; throw new Error('合成场景:计划读取失败'); } const plan = remediationPlans.find(p => p.planId === String(id)); if (!plan) throw new Error('合成场景:计划不可见'); return { data: { ...plan } }; }
|
||||
export async function pageRepairs(planId: string | number, params: { pageNum?: number; pageSize?: number }) {
|
||||
const rows: RepairVO[] = [0, 1].map(i => ({ repairRequestId: String(9007199254742101n + BigInt(i)), planId, repairType: i ? 'MANUAL' : 'DATAOPS_JOB', targetLogicalId: 'table:order-detail', actionReference: i ? 'manual:historical-partition' : 'job:order-field-repair', attemptStatus: 'NOT_SUBMITTED', beforeSourceId: 'validation:before', beforeSha: 'a'.repeat(64), afterState: 'RELIABLE', afterSourceId: 'validation:after', afterSha: 'b'.repeat(64), verificationState: i ? 'RELIABLE' : 'UNKNOWN', verificationSourceId: i ? 'validation:verify' : undefined, verificationSha: i ? 'c'.repeat(64) : undefined, version: 3, createTime: '2026-10-22T08:30:00' }));
|
||||
return slicePage(remediationScenario.noRepairs ? [] : rows, params);
|
||||
}
|
||||
export async function pageRepairAttempts(_planId: string | number, repairId: string | number, params: { pageNum?: number; pageSize?: number }) {
|
||||
if (remediationScenario.delayAttempts) await new Promise(resolve => setTimeout(resolve, 3500));
|
||||
if (remediationScenario.failAttempts) { remediationScenario.failAttempts = false; throw new Error('合成场景:执行尝试读取失败'); }
|
||||
const rows: AttemptVO[] = String(repairId).endsWith('2102') ? [] : ['UNKNOWN', 'SUCCEEDED'].map((status, i) => ({ attemptId: String(9007199254743102n - BigInt(i)), repairRequestId: repairId, repairType: 'DATAOPS_JOB', actionReference: 'job:order-field-repair', status: status as AttemptVO['status'], fresh: false, platformRunId: String(9007199254744102n - BigInt(i)), sourceStatus: i ? 'SUCCESS' : 'UNKNOWN', errorCode: i ? undefined : 'OBSERVATION_UNAVAILABLE', observedAt: i ? '2026-10-21T17:20:00' : undefined, version: 2, createdAt: i ? '2026-10-21T17:00:00' : '2026-10-22T08:35:00' }));
|
||||
return slicePage(rows, params);
|
||||
}
|
||||
export async function pagePlanTimeline(planId: string | number, params: { pageNum?: number; pageSize?: number }) {
|
||||
const rows: TimelineVO[] = [
|
||||
{ eventType: 'REVIEWED', beforeStatus: 'RESOLVED', afterStatus: 'PROCESSING', summary: '验证证据仍缺失,复核退回补充;保留此前修复结果。' },
|
||||
{ eventType: 'STATUS_CHANGED', beforeStatus: 'PROCESSING', afterStatus: 'RESOLVED', summary: '责任人提交复核。' },
|
||||
{ eventType: 'SNAPSHOT_ADDED', summary: '修复后快照已登记,验证来源暂不可用。' },
|
||||
{ eventType: 'REPAIR_REQUESTED', beforeStatus: 'ASSIGNED', afterStatus: 'PROCESSING', summary: '登记数据开发任务修复请求。' },
|
||||
{ eventType: 'CREATED', afterStatus: 'OPEN', summary: '计划已关联质量问题与已确认根因。' }
|
||||
].map((r, i) => ({ ...r, timelineId: String(9007199254745105n - BigInt(i)), planId, actorId: '9007199254746101', createTime: `2026-10-22T0${8 - i}:00:00` }));
|
||||
return slicePage(rows, params);
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
import { reactive } from 'vue';
|
||||
const user = reactive({ userId: '9007199254740101', deptId: '9007199254740102', permissions: ['*:*:*'], roles: [] });
|
||||
export const useUserStore = () => user;
|
||||
@@ -0,0 +1,14 @@
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
const root = process.cwd();
|
||||
export default { root: root + '/.governance-review', plugins: [vue()], resolve: { alias: [
|
||||
{ find: /^@\/api\/datagov\/quality-remediation$/, replacement: root + '/.governance-review/remediation.ts' },
|
||||
{ find: /^@\/api\/datagov\/quality-rule\/observations$/, replacement: root + '/.governance-review/aggregates.ts' },
|
||||
{ find: /^@\/api\/datagov\/asset-catalog\/overview$/, replacement: root + '/.governance-review/catalogIdentities.ts' },
|
||||
{ find: /^@\/api\/datagov\/asset-catalog\/identity$/, replacement: root + '/.governance-review/catalogIdentities.ts' },
|
||||
{ find: /^@\/api\/datagov\/asset-catalog\/summary$/, replacement: root + '/.governance-review/catalogIdentities.ts' },
|
||||
{ find: /^@\/api\/datagov\/asset-identity$/, replacement: root + '/.governance-review/catalogIdentities.ts' },
|
||||
{ find: /^@\/store\/modules\/user$/, replacement: root + '/.governance-review/user.ts' },
|
||||
{ find: /^@\/api\/datagov\/model-design\/assist$/, replacement: root + '/.governance-review/api.ts' },
|
||||
{ find: /^@\/api\/datagov\/model-design$/, replacement: root + '/.governance-review/api.ts' },
|
||||
{ find: '@', replacement: root + '/src' }
|
||||
] }, server: { host: '127.0.0.1', port: 59645, strictPort: true, fs: { allow: [root] } } };
|
||||
@@ -0,0 +1,31 @@
|
||||
{
|
||||
"$schema": "./node_modules/oxfmt/configuration_schema.json",
|
||||
"ignorePatterns": [
|
||||
"src/types/components.d.ts",
|
||||
"src/types/auto-imports.d.ts",
|
||||
".ai_state",
|
||||
".claude",
|
||||
".codex",
|
||||
"doc"
|
||||
],
|
||||
"printWidth": 120,
|
||||
"singleQuote": true,
|
||||
"trailingComma": "none",
|
||||
"arrowParens": "avoid",
|
||||
"htmlWhitespaceSensitivity": "ignore",
|
||||
"experimentalSortPackageJson": {
|
||||
"sortScripts": true
|
||||
},
|
||||
"sortImports": {
|
||||
"newlinesBetween": false,
|
||||
"groups": [
|
||||
"type-import",
|
||||
["value-builtin", "value-external"],
|
||||
"type-internal",
|
||||
"value-internal",
|
||||
["type-parent", "type-sibling", "type-index"],
|
||||
["value-parent", "value-sibling", "value-index"],
|
||||
"unknown"
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"$schema": "https://raw.githubusercontent.com/oxc-project/oxc/main/npm/oxlint/configuration_schema.json",
|
||||
"plugins": ["eslint", "typescript", "unicorn", "oxc", "import", "vue"],
|
||||
"rules": {
|
||||
"typescript/no-empty-function": "off",
|
||||
"typescript/no-explicit-any": "off",
|
||||
"typescript/no-unused-vars": "off",
|
||||
"typescript/no-this-alias": "off",
|
||||
"typescript/no-empty-object-type": "off",
|
||||
"typescript/no-unused-expressions": "off",
|
||||
"prefer-rest-params": "off",
|
||||
"import/no-unassigned-import": "off",
|
||||
"import/no-named-as-default-member": "off",
|
||||
"import/no-named-as-default": "off",
|
||||
"no-shadow": "off",
|
||||
"unicorn/prefer-add-event-listener": "off",
|
||||
"unicorn/consistent-function-scoping": "off",
|
||||
"unicorn/no-instanceof-builtins": "off"
|
||||
},
|
||||
"categories": {
|
||||
"correctness": "error",
|
||||
"suspicious": "error"
|
||||
},
|
||||
"ignorePatterns": [".ai_state", ".claude", ".codex", "doc", "dist/**", "dist-ssr/**", "coverage/**"]
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
<template><main style="padding: 12px 20px"><header style="display:flex;gap:12px;align-items:center;flex-wrap:wrap;margin-bottom:12px"><strong>数据开发 / 运行观测</strong><small style="flex:1">真实页面 · 合成证据 · 不连接业务 API</small><el-button @click="theme">切换亮暗</el-button><el-button @click="interrupt">模拟提交响应中断</el-button><el-button @click="notSent">模拟请求未送达</el-button><el-button @click="missing">模拟快照读取失败</el-button></header><router-view /></main></template>
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus';
|
||||
function theme() { document.documentElement.classList.toggle('dark'); }
|
||||
function interrupt() { sessionStorage.setItem('run-review-interrupt', '1'); ElMessage.info('下一次执行在模拟服务记录后丢失响应'); }
|
||||
function missing() { sessionStorage.setItem('run-review-missing', '1'); ElMessage.info('下一次快照读取将失败'); }
|
||||
function notSent() { sessionStorage.setItem('run-review-unsent', '1'); ElMessage.info('下一次请求不会到达模拟服务'); }
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<template><span /></template>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>运行画布验证</title></head><body><div id="app"></div><script type="module" src="/main.ts"></script></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
export async function listTaskLogLines(_source, _run, params) { return { data: { state: 'AVAILABLE', rows: [{ sequence: params.cursor ? 2 : 1, level: 'INFO', content: params.cursor ? '合成日志第二页 · 无真实任务执行' : '合成日志 · 敏感字段 [REDACTED]', contentSha256: 'a'.repeat(64) }], nextCursor: params.cursor ? undefined : 'page-2', truncated: false, byteCount: 100 } }; }
|
||||
@@ -0,0 +1,11 @@
|
||||
import { createApp } from 'vue';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import ElementPlus from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/assets/styles/index.scss';
|
||||
import Index from '@/views/datagov/dataops/scheduling/index.vue';
|
||||
import App from './App.vue';
|
||||
import Empty from './Empty.vue';
|
||||
const router = createRouter({ history: createWebHistory(), routes: [{ path: '/:pathMatch(.*)*', component: Index }] });
|
||||
createApp(App).use(router).use(ElementPlus).directive('hasPermi', {}).component('RightToolbar', Empty).component('Pagination', Empty).mount('#app');
|
||||
@@ -0,0 +1,50 @@
|
||||
import type { ScheduleDefinition, RunView, NodeExecutionEvidence } from '@/api/datagov/schedules/types';
|
||||
const id = '9007199254740993'; const snapshotId = '9007199254740995'; const runId = '9007199254740997';
|
||||
const definition: ScheduleDefinition = {
|
||||
name: '订单数据日结流程', description: '冻结的历史运行版本',
|
||||
nodes: [{ nodeKey: 'clean', name: '订单标准化清洗', type: 'TRANSFORMATION', referenceId: '9007199254740991' },
|
||||
{ nodeKey: 'dependency', name: '等待客户维表', type: 'DEPENDENT', dependency: { scheduleId: '9200000000000001', businessDateOffsetDays: 0 } },
|
||||
{ nodeKey: 'quality', name: '订单完整性检查', type: 'QUALITY_RULE', referenceId: '9007199254740992' },
|
||||
{ nodeKey: 'condition', name: '质量结果分流', type: 'CONDITION', condition: { field: 'PARENT_STATUS', operator: 'EQ', values: ['SUCCEEDED'] } },
|
||||
{ nodeKey: 'mart', name: '汇总经营指标', type: 'TRANSFORMATION', referenceId: '9007199254740994' },
|
||||
{ nodeKey: 'repair', name: '异常订单整理', type: 'TRANSFORMATION', referenceId: '9007199254740996' }],
|
||||
edges: [{ edgeKey: 'c-q', sourceNodeKey: 'clean', targetNodeKey: 'quality', branchOutcome: 'DEFAULT' }, { edgeKey: 'd-q', sourceNodeKey: 'dependency', targetNodeKey: 'quality', branchOutcome: 'DEFAULT' }, { edgeKey: 'q-if', sourceNodeKey: 'quality', targetNodeKey: 'condition', branchOutcome: 'DEFAULT' }, { edgeKey: 'if-m', sourceNodeKey: 'condition', targetNodeKey: 'mart', branchOutcome: 'TRUE' }, { edgeKey: 'if-r', sourceNodeKey: 'condition', targetNodeKey: 'repair', branchOutcome: 'FALSE' }],
|
||||
triggers: [], parameters: [], calendar: { timeZone: 'Asia/Shanghai', includedDates: [], excludedDates: [] }, strategy: { maxConcurrency: 1, priority: 'MEDIUM', timeoutMinutes: 60, retryCount: 0, retryIntervalSeconds: 30, failureStrategy: 'END' }
|
||||
};
|
||||
const rows: NodeExecutionEvidence[] = ['2026-10-19', '2026-10-20'].flatMap(date => definition.nodes.slice(0, date.endsWith('20') ? 3 : 5).map(n => ({ nodeKey: n.nodeKey, nodeType: n.type, referenceId: n.referenceId, status: n.nodeKey === 'quality' && date.endsWith('20') ? 'FAILED' : 'SUCCEEDED', evidenceKind: 'OBSERVATION', businessDate: date, externalInstanceId: date.endsWith('20') ? '8202' : '8201', externalTaskInstanceId: `t-${n.nodeKey}`, sourceStatus: n.nodeKey === 'quality' && date.endsWith('20') ? 'FAILURE' : 'SUCCESS', evidenceRef: `fixture:${date}:${n.nodeKey}`, observedAt: `${date}T03:05:00` })));
|
||||
rows.push({ ...rows.find(e => e.nodeKey === 'quality' && e.businessDate === '2026-10-20')!, evidenceKind: 'CALLBACK', externalInstanceId: undefined, ownerVersion: '5', ownerSha256: 'b'.repeat(64), errorCode: 'QUALITY_RULE_THRESHOLD_NOT_MET', errorSummary: '合成规则证据:订单完整性未达冻结阈值。', sourceStatus: 'CALLBACK_FAILED' });
|
||||
const original: RunView = { runId, scheduleId: id, snapshotId, action: 'BACKFILL', status: 'FAILED', businessDateFrom: '2026-10-19', businessDateTo: '2026-10-20', externalInstanceId: '8202', externalDefinitionCode: '8100', sourceStatus: 'FAILURE', errorSummary: '10 月 20 日质量节点失败,请查看节点证据。', nodeEvidence: rows, externalInstances: [{ externalInstanceId: '8201', businessDate: '2026-10-19', status: 'SUCCEEDED', sourceStatus: 'SUCCESS', observedAt: '2026-10-19T03:10:00' }, { externalInstanceId: '8202', businessDate: '2026-10-20', status: 'FAILED', sourceStatus: 'FAILURE', observedAt: '2026-10-20T03:05:00' }], lastSyncAt: '2026-10-20T03:06:00', createdAt: '2026-10-20T03:00:00', updatedAt: '2026-10-20T03:06:00' };
|
||||
const summary = { scheduleId: id, name: '订单数据日结流程(当前定义)', orgId: '1', status: 'READY', version: 8, currentSnapshotId: snapshotId, createdAt: '', updatedAt: '2026-10-21T10:00:00' };
|
||||
const receiptRows = () => JSON.parse(sessionStorage.getItem('run-review-receipts') || '{}') as Record<string, RunView>;
|
||||
export async function listSchedules() { return { data: { rows: [summary], total: 1 } }; }
|
||||
export async function getSchedule() { return { data: { ...definition, nodes: [...definition.nodes, { nodeKey: 'new-draft', name: '后来的节点不应出现在旧运行中', type: 'TRANSFORMATION', referenceId: '9001' }], summary, definitionSha256: 'c'.repeat(64) } }; }
|
||||
export async function listScheduleRuns() { return { data: [original, ...Object.values(receiptRows())] }; }
|
||||
export async function getScheduleRunCanvas(value) {
|
||||
if (sessionStorage.getItem('run-review-missing')) { sessionStorage.removeItem('run-review-missing'); throw new Error('synthetic snapshot unavailable'); }
|
||||
const run = (await listScheduleRuns()).data.find(r => String(r.runId) === String(value)); if (!run) throw new Error('not found');
|
||||
return { data: { run, definition, snapshot: { snapshotId, scheduleId: id, definitionVersion: 7, snapshotSha256: 'a'.repeat(64), createdAt: '2026-10-18T18:00:00' }, layout: null } };
|
||||
}
|
||||
async function record(action, key, data) {
|
||||
const identity = JSON.stringify({ action, key, data });
|
||||
if (sessionStorage.getItem('run-review-unsent')) {
|
||||
sessionStorage.removeItem('run-review-unsent'); sessionStorage.setItem('run-review-frozen', identity);
|
||||
throw new Error('synthetic request never reached server');
|
||||
}
|
||||
const frozen = sessionStorage.getItem('run-review-frozen');
|
||||
if (frozen && frozen !== identity) throw new Error('retry changed original key or payload');
|
||||
sessionStorage.removeItem('run-review-frozen');
|
||||
const receipts = receiptRows();
|
||||
if (receipts[key]) return { data: receipts[key] };
|
||||
const result: RunView = { ...original, runId: '9007199254740998', action, status: 'UNKNOWN', parentRunId: data.parentRunId, nodeEvidence: [], externalInstances: [], sourceStatus: 'SYNTHETIC_UNKNOWN', errorSummary: '合成未知结果,没有执行外部任务。' };
|
||||
receipts[key] = result; sessionStorage.setItem('run-review-receipts', JSON.stringify(receipts));
|
||||
if (sessionStorage.getItem('run-review-interrupt')) { sessionStorage.removeItem('run-review-interrupt'); throw new Error('synthetic connection lost after reservation'); }
|
||||
return { data: result };
|
||||
}
|
||||
export const submitSchedule = (_id, version, reason, key) => record('SUBMIT', key, { version, reason });
|
||||
export const backfillSchedule = (_id, data, key) => record('BACKFILL', key, data);
|
||||
export const rerunSchedule = (_id, data, key) => record('RERUN', key, data);
|
||||
export async function getScheduleRunReceipt(_id, _action, key) { return { data: receiptRows()[key] || null }; }
|
||||
export async function syncScheduleRun(value) { return { data: (await listScheduleRuns()).data.find(r => String(r.runId) === String(value)) }; }
|
||||
export async function getScheduleLayout() { return { data: { layoutVersion: '0', stale: false } }; }
|
||||
export async function readySchedule() { throw new Error('fixture ready disabled'); }
|
||||
export async function validateSchedule() { return { data: { valid: false, issues: [] } }; }
|
||||
@@ -0,0 +1 @@
|
||||
export const useUserStore = () => ({ userId: 'fixture-user', deptId: 'fixture-org' });
|
||||
@@ -0,0 +1,10 @@
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
const root = process.cwd();
|
||||
export default { root: root + '/.run-review', plugins: [vue()], resolve: { alias: [
|
||||
{ find: '@/components/WorkbenchOrigin/index.vue', replacement: root + '/.run-review/Empty.vue' },
|
||||
{ find: /^@\/store\/modules\/user$/, replacement: root + '/.run-review/user.ts' },
|
||||
{ find: /^@\/api\/datagov\/schedules$/, replacement: root + '/.run-review/schedules.ts' },
|
||||
{ find: /^@\/api\/datagov\/task-logs$/, replacement: root + '/.run-review/logs.ts' },
|
||||
{ find: /^@\/api\/datagov\/(batch-jobs|code-developments|transformation-cleanings|quality-rule)$/, replacement: root + '/.schedule-review/candidates.ts' },
|
||||
{ find: '@', replacement: root + '/src' }
|
||||
] }, server: { host: '127.0.0.1', port: 59644, strictPort: true, fs: { allow: [root] } } };
|
||||
@@ -0,0 +1,7 @@
|
||||
<template><div style="padding: 12px 20px"><header style="display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px"><div><strong>数据开发 / 调度编排</strong><p style="margin: 6px 0; font-size: 12px; color: var(--el-text-color-secondary)">真实编辑器 · 合成数据验证 · 不连接业务 API</p></div><div><el-button @click="theme">切换亮暗</el-button><el-button @click="interrupt">模拟布局响应中断</el-button><el-button @click="reopen">重开已存流程</el-button></div></header><router-view /></div></template>
|
||||
<script setup lang="ts">
|
||||
import { ElMessage } from 'element-plus';
|
||||
function theme() { document.documentElement.classList.toggle('dark'); }
|
||||
function interrupt() { sessionStorage.setItem('schedule-review-interrupt', '1'); ElMessage.info('下一次布局保存会在模拟服务器提交后丢失响应'); }
|
||||
function reopen() { location.reload(); }
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<template><div /></template>
|
||||
@@ -0,0 +1,4 @@
|
||||
export async function listBatchJobs() { return { data: { rows: [{ jobId: '101', name: '订单明细采集', status: 'READY' }] } }; }
|
||||
export async function listCodeDevelopments() { return { data: { rows: [{ codeId: '102', name: '异常记录归档', status: 'ENABLED' }] } }; }
|
||||
export async function listTransformationPlans() { return { data: { rows: [{ planId: '103', name: '订单标准化清洗', status: 'ACTIVE' }] } }; }
|
||||
export async function pageRules() { return { data: { rows: [] } }; }
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>调度画布组件验证</title></head><body><div id="app"></div><script type="module" src="/.schedule-review/main.ts"></script></body></html>
|
||||
@@ -0,0 +1,10 @@
|
||||
import { createApp } from 'vue';
|
||||
import { createRouter, createWebHistory } from 'vue-router';
|
||||
import ElementPlus from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/assets/styles/index.scss';
|
||||
import Editor from '@/views/datagov/dataops/scheduling/editor.vue';
|
||||
import App from './App.vue';
|
||||
const router = createRouter({ history: createWebHistory(), routes: [{ path: '/:pathMatch(.*)*', component: Editor }] });
|
||||
createApp(App).use(router).use(ElementPlus).directive('hasPermi', {}).mount('#app');
|
||||
@@ -0,0 +1,49 @@
|
||||
import { arrangeSchedule, definitionIssues, scheduleNodeTypes } from '@/views/datagov/dataops/scheduling/canvas';
|
||||
const store = 'schedule-review-state';
|
||||
const fixture = {
|
||||
summary: { scheduleId: '9007199254740993', name: '交易数据 · 每日质量分流', orgId: '2', status: 'DRAFT', version: 1 },
|
||||
description: '合成数据验证',
|
||||
nodes: [
|
||||
{ nodeKey: 'clean', name: '订单标准化清洗', type: 'TRANSFORMATION', referenceId: '103' },
|
||||
{ nodeKey: 'condition', name: '检查上游处理状态', type: 'CONDITION', condition: { field: 'PARENT_STATUS', operator: 'EQ', values: ['SUCCEEDED'] } },
|
||||
{ nodeKey: 'quality', name: '订单金额完整性', type: 'QUALITY_RULE', referenceId: '104' },
|
||||
{ nodeKey: 'code', name: '异常记录归档', type: 'CODE_OBJECT', referenceId: '102' },
|
||||
{ nodeKey: 'batch', name: '订单明细采集', type: 'BATCH_JOB', referenceId: '101' },
|
||||
{ nodeKey: 'dependency', name: '等待客户维度更新', type: 'DEPENDENT', dependency: { scheduleId: '9007199254740994', businessDateOffsetDays: 0 } }
|
||||
],
|
||||
edges: [
|
||||
{ edgeKey: 'a', sourceNodeKey: 'clean', targetNodeKey: 'condition', branchOutcome: 'DEFAULT' },
|
||||
{ edgeKey: 'b', sourceNodeKey: 'condition', targetNodeKey: 'quality', branchOutcome: 'TRUE' },
|
||||
{ edgeKey: 'c', sourceNodeKey: 'condition', targetNodeKey: 'code', branchOutcome: 'FALSE' },
|
||||
{ edgeKey: 'd', sourceNodeKey: 'batch', targetNodeKey: 'clean', branchOutcome: 'DEFAULT' },
|
||||
{ edgeKey: 'e', sourceNodeKey: 'dependency', targetNodeKey: 'condition', branchOutcome: 'DEFAULT' }
|
||||
],
|
||||
triggers: [], parameters: [], calendar: { timeZone: 'Asia/Shanghai', includedDates: [], excludedDates: [] },
|
||||
strategy: { maxConcurrency: 1, priority: 'MEDIUM', timeoutMinutes: 60, retryCount: 0, retryIntervalSeconds: 30, failureStrategy: 'END' }, definitionSha256: 'a'.repeat(64)
|
||||
};
|
||||
function read() { const saved = sessionStorage.getItem(store); return saved ? JSON.parse(saved) : { detail: fixture, layout: { layoutVersion: '1', definitionSha256: fixture.definitionSha256, positions: arrangeSchedule(fixture.nodes, fixture.edges), viewport: null, stale: false, droppedNodeKeys: [] }, receipts: {}, layoutReceipts: {} }; }
|
||||
const put = state => sessionStorage.setItem(store, JSON.stringify(state));
|
||||
export async function getSchedule() { return { data: read().detail }; }
|
||||
export async function listSchedules() { return { data: { rows: [{ scheduleId: '9007199254740994', name: '客户维度更新', status: 'READY' }] } }; }
|
||||
export async function getScheduleLayout() { const s = read(); return { data: { ...s.layout, stale: s.layout.definitionSha256 !== s.detail.definitionSha256 } }; }
|
||||
export async function getScheduleCapabilities() { return { data: { adapterConfigured: true, nodes: scheduleNodeTypes.map(t => ({ type: t.value, executable: !['BATCH_JOB', 'CODE_OBJECT'].includes(t.value), message: ['BATCH_JOB', 'CODE_OBJECT'].includes(t.value) ? '执行入口待接通,可保存定义' : '已接入定义;实际结果需运行观测' })), capabilityVersion: 'fixture', maxNodes: 200, maxEdges: 500, notices: [] } }; }
|
||||
export async function updateSchedule(id, definition, key) {
|
||||
const s = read(); if (s.receipts[key]) return { data: s.detail };
|
||||
const { version, name, ...body } = definition;
|
||||
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(JSON.stringify(body)));
|
||||
const hash = [...new Uint8Array(digest)].map(b => b.toString(16).padStart(2, '0')).join('');
|
||||
s.detail = { ...body, summary: { ...s.detail.summary, scheduleId: id, name, version: Number(version) + 1 }, definitionSha256: hash };
|
||||
s.receipts[key] = true; put(s); return { data: s.detail };
|
||||
}
|
||||
export const createSchedule = (definition, key) => updateSchedule('9007199254740993', { ...definition, version: 0 }, key);
|
||||
export async function saveScheduleLayout(id, command, key) {
|
||||
const s = read(); if (s.layoutReceipts[key]) return { data: s.layoutReceipts[key] };
|
||||
s.layout = { layoutVersion: String(Number(s.layout.layoutVersion) + 1), definitionSha256: command.definitionSha256, positions: command.positions, viewport: command.viewport, stale: false, droppedNodeKeys: [] };
|
||||
s.layoutReceipts[key] = s.layout; put(s);
|
||||
if (sessionStorage.getItem('schedule-review-interrupt')) { sessionStorage.removeItem('schedule-review-interrupt'); throw new Error('Simulated lost response'); }
|
||||
return { data: s.layout };
|
||||
}
|
||||
export async function getScheduleReceipt(action, resource, key) { const s = read(); return { data: { found: !!s.receipts[key], definition: s.receipts[key] ? s.detail : null } }; }
|
||||
export async function getScheduleLayoutReceipt(id, key) { const s = read(); return { data: { found: !!s.layoutReceipts[key], layout: s.layoutReceipts[key] || null } }; }
|
||||
export async function validateSchedule() { const s = read(); const definition = { ...s.detail, name: s.detail.summary.name }; const issues = definitionIssues(definition); definition.nodes.filter(n => ['BATCH_JOB', 'CODE_OBJECT'].includes(n.type)).forEach(n => issues.push({ code: 'OWNER_UNSUPPORTED', phase: 'EXECUTION', severity: 'ERROR', nodeKey: n.nodeKey, location: '/nodes', message: '该任务类型的调度执行入口待接通,可保留定义' })); return { data: { valid: !issues.length, issues, definitionSha256: s.detail.definitionSha256 } }; }
|
||||
export async function readySchedule(id, version, key) { const s = read(); s.detail.summary.status = 'READY'; s.receipts[key] = true; put(s); return { data: s.detail }; }
|
||||
@@ -0,0 +1,8 @@
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
const root = process.cwd();
|
||||
export default { plugins: [vue()], resolve: { alias: [
|
||||
{ find: '../../ai-workbench/EngineeringAssist.vue', replacement: root + '/.schedule-review/Assist.vue' },
|
||||
{ find: /^@\/api\/datagov\/schedules$/, replacement: root + '/.schedule-review/schedules.ts' },
|
||||
{ find: /^@\/api\/datagov\/(batch-jobs|code-developments|transformation-cleanings|quality-rule)$/, replacement: root + '/.schedule-review/candidates.ts' },
|
||||
{ find: '@', replacement: root + '/src' }
|
||||
] }, optimizeDeps: { entries: ['.schedule-review/index.html'] }, server: { host: '127.0.0.1', port: 59643, strictPort: true } };
|
||||
@@ -0,0 +1,50 @@
|
||||
<template>
|
||||
<main class="p-2 app-container">
|
||||
<header class="dg-metadata-workbench__heading"><div><h2>元数据可视化 · 实际组件验证</h2><p>合成快照 · 不连接业务API</p></div><el-button @click="toggleTheme">切换亮暗</el-button></header>
|
||||
<el-tabs v-model="page"><el-tab-pane name="lineage" label="血缘分析" /><el-tab-pane name="relations" label="关系图谱" /></el-tabs>
|
||||
<DgVisualWorkspace primary :label="page === 'lineage' ? '血缘分析' : '关系图谱'" v-model:inspector-visible="inspector">
|
||||
<template #toolbar><div class="toolbar-actions">
|
||||
<el-radio-group v-if="page === 'lineage'" v-model="view"><el-radio-button value="tables">表级</el-radio-button><el-radio-button value="fields">已映射字段</el-radio-button></el-radio-group>
|
||||
<el-radio-group v-else v-model="mode"><el-radio-button value="network">关系网络</el-radio-button><el-radio-button value="mindmap">分支视图</el-radio-button></el-radio-group>
|
||||
<el-button @click="select('detail')">定位选中</el-button>
|
||||
<el-button v-if="page === 'lineage'" @click="selectField({nodeId:'order',fieldId:'amount'})">订单金额路径</el-button>
|
||||
<el-button v-if="page === 'lineage'" @click="selectField({nodeId:'refund',fieldId:'refund'})">退款路径</el-button>
|
||||
</div></template>
|
||||
<template #catalog><div class="dg-visual-catalog-list"><el-button v-for="node in graph.nodes" :key="node.id" text @click="select(node.id)">{{ node.label }}</el-button></div></template>
|
||||
<DgEntityCanvas v-if="page === 'lineage'" :graph="graph" :scope-key="view" :focus="focus" :selected-field="field" :highlighted-node-ids="emphasis.nodeIds" :highlighted-edge-ids="emphasis.edgeIds" @select="select" @field="selectField" @edge="selectEdge" />
|
||||
<DgRelationCanvas v-else :graph="graph" root-id="detail" scope-key="relations" :mode="mode" :focus="focus" :highlighted-node-ids="emphasis.nodeIds" :highlighted-edge-ids="emphasis.edgeIds" @select="select" @edge="selectEdge" @projection="summary = $event" />
|
||||
<template #inspector><el-descriptions :column="1" direction="vertical" border class="dg-visual-detail-text"><el-descriptions-item label="完整名称">{{ selected?.subtitle || selected?.label || '--' }}</el-descriptions-item><el-descriptions-item label="选中字段">{{ field?.fieldId || '--' }}</el-descriptions-item><el-descriptions-item label="已知路径">{{ emphasis.edgeIds.length }} 条连接</el-descriptions-item></el-descriptions></template>
|
||||
<template #status><span>{{ graph.nodes.length }} 个对象 · {{ graph.edges.length }} 条连接</span><span v-if="field">当前字段路径 {{ emphasis.edgeIds.length }} 条</span><span v-if="page === 'relations'">显示 {{ summary.visibleNodeIds.length }} 个对象 / {{ summary.visibleEdgeIds.length }} 条关系</span></template>
|
||||
</DgVisualWorkspace>
|
||||
</main>
|
||||
</template>
|
||||
<script setup lang="ts">
|
||||
import { computed, ref, watch } from 'vue';
|
||||
import DgVisualWorkspace from '@/design-system/components/visualization/DgVisualWorkspace.vue';
|
||||
import DgEntityCanvas from '@/design-system/components/visualization/DgEntityCanvas.vue';
|
||||
import DgRelationCanvas from '@/design-system/components/visualization/DgRelationCanvas.vue';
|
||||
import { fieldEmphasis, projectLineage } from '@/views/datagov/governance/metadata-lineage/projection';
|
||||
import { relationGraph } from '@/views/datagov/governance/metadata-relations/projection';
|
||||
import type { LineageView } from '@/views/datagov/governance/metadata-lineage/projection';
|
||||
import type { ProjectionSummary } from '@/design-system/components/visualization/types';
|
||||
const page = ref('lineage'), view = ref<LineageView>('tables'), mode = ref<'network'|'mindmap'>('network'), inspector = ref(false);
|
||||
const focus = ref({nodeId:'detail',request:1}), field = ref<{nodeId:string;fieldId:string}>(), edgeId = ref('');
|
||||
const summary = ref<ProjectionSummary>({visibleNodeIds:[],visibleEdgeIds:[],hiddenNodeIds:[],hiddenEdgeIds:[]});
|
||||
const names = { order:'销售订单', refund:'退款记录', detail:'跨区域订单与退款业务明细汇合长名称示例', summary:'交易汇总', report:'经营分析报表' };
|
||||
const nodes = Object.entries(names).map(([externalId,name]) => ({externalId,name,fullyQualifiedName:'交易中心.生产域.'+externalId,entityType:'TABLE' as const}));
|
||||
const pairs = [['order','amount','detail','amount'],['detail','amount','summary','amount'],['summary','amount','report','amount'],['refund','refund','detail','refund'],['detail','refund','report','refund']];
|
||||
const lineage = {root:nodes[2],nodes,upstreamEdges:[],downstreamEdges:pairs.map(p=>({fromExternalId:p[0],toExternalId:p[2]})),fieldMappings:pairs.map(p=>({fromExternalId:p[0],fromField:p[1],toExternalId:p[2],toField:p[3]})),upstreamDepth:2,downstreamDepth:2,truncated:false};
|
||||
const relations = relationGraph({rootNodeId:'detail',nodes:[{nodeId:'detail',name:names.detail,nodeType:'TABLE',fullyQualifiedName:'交易中心.生产域.detail'},{nodeId:'db',name:'交易明细数据库',nodeType:'DATABASE'},{nodeId:'service',name:'业务数据服务',nodeType:'SERVICE'},{nodeId:'domain',name:'交易业务域',nodeType:'DOMAIN'},{nodeId:'term',name:'净销售额',nodeType:'GLOSSARY_TERM'},{nodeId:'owner',name:'交易数据负责人',nodeType:'OWNER'},{nodeId:'quality',name:'完整性规则',nodeType:'QUALITY'}],edges:[['detail','db','BELONGS_TO_DATABASE'],['db','service','BELONGS_TO_SERVICE'],['detail','domain','IN_DOMAIN'],['detail','term','HAS_GLOSSARY_TERM'],['detail','owner','OWNED_BY'],['detail','quality','HAS_QUALITY_PROJECTION'],['domain','owner','OWNED_BY']].map(p=>({fromNodeId:p[0],toNodeId:p[1],relationType:p[2]})),truncated:false});
|
||||
const graph = computed(()=>page.value==='lineage'?projectLineage(lineage,view.value):relations);
|
||||
const selected = computed(()=>graph.value.nodes.find(n=>n.id===focus.value.nodeId));
|
||||
const emphasis = computed(()=>{
|
||||
if(field.value)return fieldEmphasis(graph.value,field.value);
|
||||
const edges = graph.value.edges.filter(e=>edgeId.value?e.id===edgeId.value:e.source===focus.value.nodeId||e.target===focus.value.nodeId);
|
||||
return {nodeIds:[...new Set([focus.value.nodeId,...edges.flatMap(e=>[e.source,e.target])])],edgeIds:edges.map(e=>e.id)};
|
||||
});
|
||||
function select(id:string){focus.value={nodeId:id,request:focus.value.request+1};field.value=undefined;edgeId.value='';inspector.value=true;}
|
||||
function selectField(value:{nodeId:string;fieldId:string}){view.value='fields';select(value.nodeId);field.value=value;}
|
||||
function selectEdge(id:string){const edge=graph.value.edges.find(e=>e.id===id);if(edge){select(edge.source);edgeId.value=id;}}
|
||||
function toggleTheme(){document.documentElement.classList.toggle('dark');}
|
||||
watch(page,()=>{field.value=undefined;edgeId.value='';focus.value={nodeId:'detail',request:focus.value.request+1};inspector.value=false;});
|
||||
</script>
|
||||
@@ -0,0 +1 @@
|
||||
<!doctype html><html lang="zh-CN"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>元数据画布 · 组件验证</title></head><body><div id="app"></div><script type="module" src="./main.ts"></script></body></html>
|
||||
@@ -0,0 +1,7 @@
|
||||
import { createApp } from 'vue';
|
||||
import ElementPlus from 'element-plus';
|
||||
import 'element-plus/dist/index.css';
|
||||
import 'element-plus/theme-chalk/dark/css-vars.css';
|
||||
import '@/assets/styles/index.scss';
|
||||
import App from './App.vue';
|
||||
createApp(App).use(ElementPlus).mount('#app');
|
||||
@@ -0,0 +1,2 @@
|
||||
import vue from '@vitejs/plugin-vue';
|
||||
export default { plugins: [vue()], resolve: { alias: { '@': process.cwd() + '/src' } }, optimizeDeps: { entries: ['.visual-review/index.html'] }, server: { host: '127.0.0.1', port: 59642, strictPort: true } };
|
||||
@@ -0,0 +1,8 @@
|
||||
FROM nginx:1.31-alpine
|
||||
|
||||
LABEL maintainer="AiXun Technology <343559364@qq.com>"
|
||||
|
||||
COPY ./dist/ /usr/share/nginx/html/
|
||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
EXPOSE 80
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2019 RuoYi-Vue-Plus
|
||||
Copyright (c) 2026 艾讯科技
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
@@ -0,0 +1,30 @@
|
||||
# AiXun-Admin UI
|
||||
|
||||
艾讯科技 AiXun-Admin 管理端,基于 Vue 3、TypeScript、Element Plus 与 Vite。
|
||||
|
||||
## 品牌信息
|
||||
|
||||
- 中文品牌:艾讯
|
||||
- 产品名称:AiXun-Admin
|
||||
- 官方网站:https://www.aixunkeji.cn
|
||||
- 帮助文档:https://admin.aixunkeji.cn/docs
|
||||
- 演示地址:https://admin.aixunkeji.cn
|
||||
- 联系邮箱:343559364@qq.com
|
||||
- 版权所有:艾讯科技,2026
|
||||
|
||||
## 本地开发
|
||||
|
||||
```bash
|
||||
pnpm install
|
||||
pnpm dev
|
||||
```
|
||||
|
||||
开发服务器默认通过 `/dev-api` 将接口请求代理到 `http://localhost:8080`。
|
||||
|
||||
## 构建
|
||||
|
||||
```bash
|
||||
pnpm build
|
||||
```
|
||||
|
||||
构建产物输出到 `dist`。Docker 本地编排使用 Nginx 托管前端,并把 `/prod-api` 代理到后端网关。
|
||||
文件差异内容过多而无法显示
加载差异
@@ -0,0 +1,104 @@
|
||||
import type { ${BusinessName}Form, ${BusinessName}Query, ${BusinessName}VO } from '@/api/${moduleName}/${businessName}/types';
|
||||
<#if !table.tree>
|
||||
import type { PageResult } from '@/api/types';
|
||||
</#if>
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
|
||||
/**
|
||||
* 查询${functionName}列表
|
||||
* @param query
|
||||
* @returns {*}
|
||||
*/
|
||||
|
||||
export const list${BusinessName} = (query?: ${BusinessName}Query): AxiosPromise<<#if table.tree>${BusinessName}VO[]<#else>PageResult<${BusinessName}VO></#if>> => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/list',
|
||||
method: 'get',
|
||||
params: query
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 查询${functionName}详细
|
||||
* @param ${pkColumn.javaField}
|
||||
*/
|
||||
export const get${BusinessName} = (${pkColumn.javaField}: string | number): AxiosPromise<${BusinessName}VO> => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'get'
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 新增${functionName}
|
||||
* @param data
|
||||
*/
|
||||
export const add${BusinessName} = (data: ${BusinessName}Form) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'post',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* 修改${functionName}
|
||||
* @param data
|
||||
*/
|
||||
export const update${BusinessName} = (data: ${BusinessName}Form) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}',
|
||||
method: 'put',
|
||||
data: data
|
||||
});
|
||||
};
|
||||
|
||||
<#if enableStatus>
|
||||
/**
|
||||
* 修改${functionName}状态
|
||||
* @param ${pkColumn.javaField}
|
||||
* @param status
|
||||
*/
|
||||
export const change${BusinessName}Status = (${pkColumn.javaField}: string | number, status: <#if statusColumn.javaType == 'Boolean'>boolean<#elseif statusColumn.javaType == 'String'>string<#else> number</#if>) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/changeStatus',
|
||||
method: 'put',
|
||||
data: {
|
||||
${pkColumn.javaField},
|
||||
${statusField}: status
|
||||
}
|
||||
});
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if enableSort>
|
||||
/**
|
||||
* 调整${functionName}排序
|
||||
* @param ${pkColumn.javaField}
|
||||
* @param sortValue
|
||||
*/
|
||||
export const update${BusinessName}Sort = (${pkColumn.javaField}: string | number, sortValue: <#if sortColumn.javaType == 'String' || sortColumn.javaType == 'LocalDateTime'>string<#else> number</#if>) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/updateSort',
|
||||
method: 'put',
|
||||
data: {
|
||||
${pkColumn.javaField},
|
||||
${sortField}: sortValue
|
||||
}
|
||||
});
|
||||
};
|
||||
</#if>
|
||||
|
||||
/**
|
||||
* 删除${functionName}
|
||||
* @param ${pkColumn.javaField}
|
||||
*/
|
||||
export const del${BusinessName} = (${pkColumn.javaField}: string | number | Array<string | number>) => {
|
||||
return request({
|
||||
url: '/${moduleName}/${businessName}/' + ${pkColumn.javaField},
|
||||
method: 'delete'
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -0,0 +1,691 @@
|
||||
<template>
|
||||
<div class="p-2 page-shell ${moduleName}-${businessName}-page">
|
||||
<div class="search-wrap">
|
||||
<el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }">
|
||||
<template #header>
|
||||
<div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch">
|
||||
<div><h3>筛选条件</h3></div>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form">
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType == "input" || column.htmlType == "textarea">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="queryParams.${column.javaField}" placeholder="请输入${column.columnLabel}" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "inputNumber">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input-number v-model="queryParams.${column.javaField}" controls-position="right" />
|
||||
</el-form-item>
|
||||
<#elseif (column.htmlType == "select" || column.htmlType == "radio") && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable>
|
||||
<el-option v-for="dict in ${column.dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable>
|
||||
<el-option v-for="dict in ${column.dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable>
|
||||
<#if column.javaType == "Boolean">
|
||||
<el-option label="是" :value="true" />
|
||||
<el-option label="否" :value="false" />
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
<el-option label="开启" :value="0" />
|
||||
<el-option label="关闭" :value="1" />
|
||||
<#else>
|
||||
<el-option label="开启" value="0" />
|
||||
<el-option label="关闭" value="1" />
|
||||
</#if>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif (column.htmlType == "select" || column.htmlType == "radio") && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable>
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime" && column.queryType != "BETWEEN">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="选择${column.columnLabel}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
<el-form-item label="${column.columnLabel}" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange${column.capJavaField}"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<el-card shadow="hover" class="table-panel">
|
||||
<template #header>
|
||||
<div class="toolbar-shell">
|
||||
<div class="table-heading">
|
||||
<h3>${functionName}列表</h3>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd()" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
||||
<el-button type="info" plain icon="Sort" @click="handleToggleExpandAll">展开/折叠</el-button>
|
||||
<#if enableExport>
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button>
|
||||
</#if>
|
||||
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<el-table
|
||||
ref="${businessName}TableRef"
|
||||
v-loading="loading"
|
||||
class="data-table"
|
||||
:data="${businessName}List"
|
||||
row-key="${treeCode}"
|
||||
border
|
||||
:default-expand-all="isExpandAll"
|
||||
:tree-props="{ children: 'children', hasChildren: 'hasChildren' }"
|
||||
>
|
||||
<#assign firstTreeListField = "">
|
||||
<#list columns as tempColumn>
|
||||
<#if !tempColumn.pk && tempColumn.list && "" != tempColumn.javaField && firstTreeListField == "">
|
||||
<#assign firstTreeListField = tempColumn.javaField>
|
||||
</#if>
|
||||
</#list>
|
||||
<#list columns as column>
|
||||
<#if column.pk>
|
||||
<#elseif enableStatus && statusField == column.javaField>
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${column.javaField}"
|
||||
:active-value="${statusField}ActiveValue"
|
||||
:inactive-value="${statusField}InactiveValue"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif enableSort && sortField == column.javaField>
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}" width="160">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="160">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<#if column.javaType == "LocalDateTime">
|
||||
<el-date-picker
|
||||
v-model="scope.row.${column.javaField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${column.columnLabel}"
|
||||
@change="handleSortChange(scope.row)"
|
||||
/>
|
||||
<#else>
|
||||
<el-input-number v-model="scope.row.${column.javaField}" controls-position="right" :min="0" @change="handleSortChange(scope.row)" />
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "switch">
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}" width="120">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="120">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${column.javaField}"
|
||||
<#if column.javaType == "Boolean">
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
<#else>
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
</#if>
|
||||
disabled
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "datetime">
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}" width="180">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="180">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.${column.javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "imageUpload">
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}Url" width="100">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}Url" width="100">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${column.javaField}Url" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.dictColumn>
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}">
|
||||
</#if>
|
||||
<template #default="scope">
|
||||
<#if column.htmlType == "checkbox">
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${column.javaField} ? scope.row.${column.javaField}.split(',') : []"/>
|
||||
<#else>
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${column.javaField}"/>
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && "" != column.javaField>
|
||||
<#if column.javaField == firstTreeListField>
|
||||
<el-table-column label="${column.columnLabel}" prop="${column.javaField}" />
|
||||
<#else>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" />
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if enableStatus && !statusColumn.list>
|
||||
<el-table-column label="${statusColumn.columnComment}" align="center" prop="${statusField}">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${statusField}"
|
||||
:active-value="${statusField}ActiveValue"
|
||||
:inactive-value="${statusField}InactiveValue"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</#if>
|
||||
<#if enableSort && !sortColumn.list>
|
||||
<el-table-column label="${sortColumn.columnComment}" align="center" prop="${sortField}" width="160">
|
||||
<template #default="scope">
|
||||
<#if sortColumn.javaType == "LocalDateTime">
|
||||
<el-date-picker
|
||||
v-model="scope.row.${sortField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${sortColumn.columnComment}"
|
||||
@change="handleSortChange(scope.row)"
|
||||
/>
|
||||
<#else>
|
||||
<el-input-number v-model="scope.row.${sortField}" controls-position="right" :min="0" @change="handleSortChange(scope.row)" />
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</#if>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="新增" placement="top">
|
||||
<el-button link type="primary" icon="Plus" @click="handleAdd(scope.row)" v-hasPermi="['${moduleName}:${businessName}:add']" />
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']" />
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
</el-card>
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<#list columns as column>
|
||||
<#if (column.insert || column.edit) && !column.pk>
|
||||
<#if "" != treeParentCode && column.javaField == treeParentCode>
|
||||
<el-form-item label="${column.columnLabel}" prop="${treeParentCode}">
|
||||
<el-tree-select
|
||||
v-model="form.${treeParentCode}"
|
||||
:data="${businessName}Options"
|
||||
:props="{ value: '${treeCode}', label: '${treeName}', children: 'children' } as any"
|
||||
value-key="${treeCode}"
|
||||
placeholder="请选择${column.columnLabel}"
|
||||
check-strictly
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "input">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="form.${column.javaField}" placeholder="请输入${column.columnLabel}" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "inputNumber">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input-number v-model="form.${column.javaField}" controls-position="right" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "imageUpload">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<image-upload v-model="form.${column.javaField}"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "fileUpload">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<file-upload v-model="form.${column.javaField}"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "editor">
|
||||
<el-form-item label="${column.columnLabel}">
|
||||
<editor v-model="form.${column.javaField}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "select" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="form.${column.javaField}" placeholder="请选择${column.columnLabel}">
|
||||
<el-option
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
<#if column.javaType == "Integer" || column.javaType == "Long">
|
||||
:value="parseInt(dict.value)"
|
||||
<#else>
|
||||
:value="dict.value"
|
||||
</#if>
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "select" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="form.${column.javaField}" placeholder="请选择${column.columnLabel}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "checkbox" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-checkbox-group v-model="form.${column.javaField}">
|
||||
<el-checkbox
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "checkbox" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-checkbox-group v-model="form.${column.javaField}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "radio" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-radio-group v-model="form.${column.javaField}">
|
||||
<el-radio
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
<#if column.javaType == "Integer" || column.javaType == "Long">
|
||||
:value="parseInt(dict.value)"
|
||||
<#else>
|
||||
:value="dict.value"
|
||||
</#if>
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "radio" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-radio-group v-model="form.${column.javaField}">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-switch
|
||||
v-model="form.${column.javaField}"
|
||||
<#if column.javaType == "Boolean">
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
<#else>
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
</#if>
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="form.${column.javaField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${column.columnLabel}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "textarea">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="form.${column.javaField}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="${BusinessName}" lang="ts">
|
||||
import {
|
||||
add${BusinessName},
|
||||
<#if enableStatus>
|
||||
change${BusinessName}Status,
|
||||
</#if>
|
||||
del${BusinessName},
|
||||
get${BusinessName},
|
||||
list${BusinessName},
|
||||
<#if enableSort>
|
||||
update${BusinessName}Sort,
|
||||
</#if>
|
||||
update${BusinessName}
|
||||
} from '@/api/${moduleName}/${businessName}';
|
||||
import { ${BusinessName}Form, ${BusinessName}Query, ${BusinessName}VO } from '@/api/${moduleName}/${businessName}/types';
|
||||
import { useLoading } from '@/hooks/async/useLoading';
|
||||
import { useFormDialog } from '@/hooks/dialog/useFormDialog';
|
||||
<#if needAddDateRange>
|
||||
import { useDateRangeQuery } from '@/hooks/form/useDateRangeQuery';
|
||||
</#if>
|
||||
import { useSearchReset } from '@/hooks/form/useSearchReset';
|
||||
import { useSearchToggle } from '@/hooks/form/useSearchToggle';
|
||||
import { useTreeTableExpand } from '@/hooks/tree/useTreeTableExpand';
|
||||
<#if needDict>
|
||||
import { useDict } from '@/utils/dict';
|
||||
</#if>
|
||||
import modal from '@/plugins/modal';
|
||||
import { handleTree } from '@/utils/aixun';
|
||||
<#if enableExport>
|
||||
import { download as requestDownload } from '@/utils/request';
|
||||
</#if>
|
||||
|
||||
<#if needDict>
|
||||
const { ${dictsNoSymbol} } = toRefs<any>(useDict(${dicts}));
|
||||
</#if>
|
||||
|
||||
<#if enableStatus>
|
||||
const ${statusField}ActiveValue = <#if statusColumn.javaType == "Boolean">true<#elseif statusColumn.javaType == "Integer" || statusColumn.javaType == "Long">0<#else>'0'</#if>;
|
||||
const ${statusField}InactiveValue = <#if statusColumn.javaType == "Boolean">false<#elseif statusColumn.javaType == "Integer" || statusColumn.javaType == "Long">1<#else>'1'</#if>;
|
||||
</#if>
|
||||
|
||||
type ${BusinessName}Option = {
|
||||
${treeCode}: <#if treeParentColumn.javaType == 'String'>string<#else> number</#if>;
|
||||
${treeName}: string;
|
||||
children?: ${BusinessName}Option[];
|
||||
};
|
||||
|
||||
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||
const ${businessName}Options = ref<${BusinessName}Option[]>([]);
|
||||
const all${BusinessName}Options = ref<${BusinessName}Option[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const { showSearch } = useSearchToggle();
|
||||
const { loading, setLoading, withLoading } = useLoading();
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const ${businessName}FormRef = ref<ElFormInstance>();
|
||||
const ${businessName}TableRef = ref<ElTableInstance>();
|
||||
const { isExpandAll, handleToggleExpandAll } = useTreeTableExpand<${BusinessName}VO>({
|
||||
tableRef: ${businessName}TableRef,
|
||||
data: ${businessName}List
|
||||
});
|
||||
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
const {
|
||||
dateRange: dateRange${column.capJavaField},
|
||||
applyDateRange: apply${column.capJavaField}DateRange,
|
||||
resetDateRange: reset${column.capJavaField}DateRange
|
||||
} = useDateRangeQuery('${column.capJavaField}');
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
const initFormData: ${BusinessName}Form = {
|
||||
<#list columns as column>
|
||||
<#if column.insert || column.edit>
|
||||
<#if column.htmlType == "checkbox">
|
||||
${column.javaField}: [],
|
||||
<#else>
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
|
||||
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||
form: {...initFormData},
|
||||
queryParams: {
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType != "datetime" || column.queryType != "BETWEEN">
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
params: {
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
<#list columns as column>
|
||||
<#if column.insert || column.edit>
|
||||
<#if column.required>
|
||||
${column.javaField}: [
|
||||
{ required: true, message: "${column.columnLabel}不能为空", trigger: <#if column.htmlType == "select" || column.htmlType == "radio" || column.htmlType == "switch" || column.htmlType == "inputNumber">"change"<#else>"blur"</#if> }
|
||||
],
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const { dialog, resetForm: reset, openDialog, showDialog, closeDialog } = useFormDialog({
|
||||
form,
|
||||
formRef: ${businessName}FormRef,
|
||||
initialFormData: initFormData
|
||||
});
|
||||
|
||||
/** 查询${functionName}列表 */
|
||||
const getList = async () => {
|
||||
await withLoading(async () => {
|
||||
<#if needAddDateRange>
|
||||
let params = queryParams.value;
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
params = apply${column.capJavaField}DateRange(params);
|
||||
</#if>
|
||||
</#list>
|
||||
const res = await list${BusinessName}(params);
|
||||
<#else>
|
||||
const res = await list${BusinessName}(queryParams.value);
|
||||
</#if>
|
||||
const data = handleTree<${BusinessName}VO>(res.data, '${treeCode}', '${treeParentCode}');
|
||||
if (data) {
|
||||
${businessName}List.value = data;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 查询${functionName}下拉树结构 */
|
||||
const getTreeselect = async (excludeId?: string | number) => {
|
||||
const res = await list${BusinessName}();
|
||||
const data: ${BusinessName}Option = { ${treeCode}: ${treeRootValueTsLiteral}, ${treeName}: '顶级节点', children: [] };
|
||||
data.children = handleTree<${BusinessName}Option>(res.data, '${treeCode}', '${treeParentCode}');
|
||||
all${BusinessName}Options.value = [data];
|
||||
${businessName}Options.value = excludeId != null ? filterTreeOptions(all${BusinessName}Options.value, excludeId) : all${BusinessName}Options.value;
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
getList();
|
||||
};
|
||||
|
||||
const { resetQuery } = useSearchReset({
|
||||
queryFormRef,
|
||||
queryParams,
|
||||
resetExtras: () => {
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
reset${column.capJavaField}DateRange();
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
afterReset: () => {
|
||||
handleQuery();
|
||||
}
|
||||
});
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = (row?: Partial<${BusinessName}VO>) => {
|
||||
openDialog('添加${functionName}');
|
||||
getTreeselect();
|
||||
if (row != null && row.${treeCode}) {
|
||||
form.value.${treeParentCode} = row.${treeCode};
|
||||
} else {
|
||||
form.value.${treeParentCode} = ${treeRootValueTsLiteral};
|
||||
}
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row: Partial<${BusinessName}VO>) => {
|
||||
reset();
|
||||
await getTreeselect(row.${treeCode});
|
||||
if (row != null) {
|
||||
form.value.${treeParentCode} = row.${treeParentCode};
|
||||
}
|
||||
const res = await get${BusinessName}(row.${pkColumn.javaField});
|
||||
Object.assign(form.value, res.data);
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "checkbox">
|
||||
form.value.${column.javaField} = form.value.${column.javaField}.split(",");
|
||||
</#if>
|
||||
</#list>
|
||||
showDialog('修改${functionName}');
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
${businessName}FormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "checkbox">
|
||||
form.value.${column.javaField} = form.value.${column.javaField}.join(",");
|
||||
</#if>
|
||||
</#list>
|
||||
if (form.value.${pkColumn.javaField}) {
|
||||
await update${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await add${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
modal.msgSuccess('操作成功');
|
||||
closeDialog();
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row: Partial<${BusinessName}VO>) => {
|
||||
await modal.confirm('是否确认删除${functionName}编号为"' + row.${pkColumn.javaField} + '"的数据项?');
|
||||
setLoading(true);
|
||||
await del${BusinessName}(row.${pkColumn.javaField}).finally(() => setLoading(false));
|
||||
await getList();
|
||||
modal.msgSuccess('删除成功');
|
||||
};
|
||||
|
||||
const filterTreeOptions = (options: ${BusinessName}Option[], excludeId: string | number): ${BusinessName}Option[] => {
|
||||
return options
|
||||
.filter(item => item.${treeCode} !== excludeId)
|
||||
.map(item => ({
|
||||
...item,
|
||||
children: item.children ? filterTreeOptions(item.children, excludeId) : []
|
||||
}));
|
||||
};
|
||||
|
||||
<#if enableStatus>
|
||||
/** 状态修改 */
|
||||
const handleStatusChange = async (row: Partial<${BusinessName}VO>) => {
|
||||
const text = row.${statusField} === ${statusField}ActiveValue ? '启用' : '停用';
|
||||
try {
|
||||
await modal.confirm('确认要"' + text + '"吗?');
|
||||
await change${BusinessName}Status(row.${pkColumn.javaField}, row.${statusField});
|
||||
modal.msgSuccess(text + '成功');
|
||||
} catch (err) {
|
||||
row.${statusField} = row.${statusField} === ${statusField}ActiveValue ? ${statusField}InactiveValue : ${statusField}ActiveValue;
|
||||
}
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if enableSort>
|
||||
/** 排序调整 */
|
||||
const handleSortChange = async (row: Partial<${BusinessName}VO>) => {
|
||||
try {
|
||||
await update${BusinessName}Sort(row.${pkColumn.javaField}, row.${sortField});
|
||||
modal.msgSuccess('排序更新成功');
|
||||
} catch (err) {
|
||||
await getList();
|
||||
}
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if enableExport>
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
requestDownload(
|
||||
'${moduleName}/${businessName}/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`${businessName}_${r'${new Date().getTime()}'}.xlsx`
|
||||
);
|
||||
};
|
||||
</#if>
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,615 @@
|
||||
<template>
|
||||
<div class="p-2 page-shell ${moduleName}-${businessName}-page">
|
||||
<div class="search-wrap">
|
||||
<el-card shadow="hover" class="search-panel" :class="{ 'is-collapsed': !showSearch }">
|
||||
<template #header>
|
||||
<div class="panel-heading search-panel-toggle" @click.stop="showSearch = !showSearch">
|
||||
<div><h3>筛选条件</h3></div>
|
||||
</div>
|
||||
</template>
|
||||
<el-form ref="queryFormRef" :model="queryParams" :inline="true" class="query-form">
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType == "input" || column.htmlType == "textarea">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="queryParams.${column.javaField}" placeholder="请输入${column.columnLabel}" clearable @keyup.enter="handleQuery" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "inputNumber">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input-number v-model="queryParams.${column.javaField}" controls-position="right" />
|
||||
</el-form-item>
|
||||
<#elseif (column.htmlType == "select" || column.htmlType == "radio") && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable >
|
||||
<el-option v-for="dict in ${column.dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable >
|
||||
<el-option v-for="dict in ${column.dictType}" :key="dict.value" :label="dict.label" :value="dict.value"/>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable >
|
||||
<#if column.javaType == "Boolean">
|
||||
<el-option label="是" :value="true" />
|
||||
<el-option label="否" :value="false" />
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
<el-option label="开启" :value="0" />
|
||||
<el-option label="关闭" :value="1" />
|
||||
<#else>
|
||||
<el-option label="开启" value="0" />
|
||||
<el-option label="关闭" value="1" />
|
||||
</#if>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif (column.htmlType == "select" || column.htmlType == "radio") && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="queryParams.${column.javaField}" placeholder="请选择${column.columnLabel}" clearable >
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime" && column.queryType != "BETWEEN">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="queryParams.${column.javaField}"
|
||||
type="date"
|
||||
value-format="YYYY-MM-DD"
|
||||
placeholder="请选择${column.columnLabel}"
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query>
|
||||
<el-form-item label="${column.columnLabel}" style="width: 308px">
|
||||
<el-date-picker
|
||||
v-model="dateRange${column.capJavaField}"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
type="daterange"
|
||||
range-separator="-"
|
||||
start-placeholder="开始日期"
|
||||
end-placeholder="结束日期"
|
||||
:default-time="[new Date(2000, 1, 1, 0, 0, 0), new Date(2000, 1, 1, 23, 59, 59)]"
|
||||
/>
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<el-form-item>
|
||||
<el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
|
||||
<el-button icon="Refresh" @click="resetQuery">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</el-card>
|
||||
</div>
|
||||
|
||||
<el-card shadow="hover" class="table-panel">
|
||||
<template #header>
|
||||
<div class="toolbar-shell">
|
||||
<div class="table-heading">
|
||||
<h3>${functionName}列表</h3>
|
||||
</div>
|
||||
<div class="toolbar-actions">
|
||||
<el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['${moduleName}:${businessName}:add']">新增</el-button>
|
||||
<el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['${moduleName}:${businessName}:edit']">修改</el-button>
|
||||
<el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['${moduleName}:${businessName}:remove']">删除</el-button>
|
||||
<#if enableExport>
|
||||
<el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['${moduleName}:${businessName}:export']">导出</el-button>
|
||||
</#if>
|
||||
<right-toolbar v-model:show-search="showSearch" :search="false" @query-table="getList"></right-toolbar>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<el-table v-loading="loading" border class="data-table" :data="${businessName}List" @selection-change="handleSelectionChange">
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<#list columns as column>
|
||||
<#if column.pk && column.list>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" />
|
||||
<#elseif enableStatus && statusField == column.javaField>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${column.javaField}"
|
||||
:active-value="${statusField}ActiveValue"
|
||||
:inactive-value="${statusField}InactiveValue"
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif enableSort && sortField == column.javaField>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="160">
|
||||
<template #default="scope">
|
||||
<#if column.javaType == "LocalDateTime">
|
||||
<el-date-picker
|
||||
v-model="scope.row.${column.javaField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${column.columnLabel}"
|
||||
@change="handleSortChange(scope.row)"
|
||||
/>
|
||||
<#else>
|
||||
<el-input-number v-model="scope.row.${column.javaField}" controls-position="right" :min="0" @change="handleSortChange(scope.row)" />
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "switch">
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="120">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${column.javaField}"
|
||||
<#if column.javaType == "Boolean">
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
<#else>
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
</#if>
|
||||
disabled
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "datetime">
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.${column.javaField}, '{y}-{m}-{d}') }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.htmlType == "imageUpload">
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}Url" width="100">
|
||||
<template #default="scope">
|
||||
<image-preview :src="scope.row.${column.javaField}Url" :width="50" :height="50"/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && column.dictColumn>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}">
|
||||
<template #default="scope">
|
||||
<#if column.htmlType == "checkbox">
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${column.javaField} ? scope.row.${column.javaField}.split(',') : []"/>
|
||||
<#else>
|
||||
<dict-tag :options="${column.dictType}" :value="scope.row.${column.javaField}"/>
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<#elseif column.list && "" != column.javaField>
|
||||
<el-table-column label="${column.columnLabel}" align="center" prop="${column.javaField}" />
|
||||
</#if>
|
||||
</#list>
|
||||
<#if enableStatus && !statusColumn.list>
|
||||
<el-table-column label="${statusColumn.columnComment}" align="center" prop="${statusField}">
|
||||
<template #default="scope">
|
||||
<el-switch
|
||||
v-model="scope.row.${statusField}"
|
||||
<#if statusColumn.javaType == "Boolean">
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
<#elseif statusColumn.javaType == "Integer" || statusColumn.javaType == "Long">
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
<#else>
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
</#if>
|
||||
@change="handleStatusChange(scope.row)"
|
||||
/>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</#if>
|
||||
<#if enableSort && !sortColumn.list>
|
||||
<el-table-column label="${sortColumn.columnComment}" align="center" prop="${sortField}" width="160">
|
||||
<template #default="scope">
|
||||
<#if sortColumn.javaType == "LocalDateTime">
|
||||
<el-date-picker
|
||||
v-model="scope.row.${sortField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="选择${sortColumn.columnComment}"
|
||||
@change="handleSortChange(scope.row)"
|
||||
/>
|
||||
<#else>
|
||||
<el-input-number v-model="scope.row.${sortField}" controls-position="right" :min="0" @change="handleSortChange(scope.row)" />
|
||||
</#if>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</#if>
|
||||
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
|
||||
<template #default="scope">
|
||||
<el-tooltip content="修改" placement="top">
|
||||
<el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['${moduleName}:${businessName}:edit']"></el-button>
|
||||
</el-tooltip>
|
||||
<el-tooltip content="删除" placement="top">
|
||||
<el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['${moduleName}:${businessName}:remove']"></el-button>
|
||||
</el-tooltip>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
|
||||
</el-card>
|
||||
<!-- 添加或修改${functionName}对话框 -->
|
||||
<el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
|
||||
<el-form ref="${businessName}FormRef" :model="form" :rules="rules" label-width="80px">
|
||||
<#list columns as column>
|
||||
<#if (column.insert || column.edit) && !column.pk>
|
||||
<#if column.htmlType == "input">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="form.${column.javaField}" placeholder="请输入${column.columnLabel}" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "inputNumber">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input-number v-model="form.${column.javaField}" controls-position="right" />
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "imageUpload">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<image-upload v-model="form.${column.javaField}"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "fileUpload">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<file-upload v-model="form.${column.javaField}"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "editor">
|
||||
<el-form-item label="${column.columnLabel}">
|
||||
<editor v-model="form.${column.javaField}" :min-height="192"/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "select" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="form.${column.javaField}" placeholder="请选择${column.columnLabel}">
|
||||
<el-option
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.label"
|
||||
<#if column.javaType == "Integer" || column.javaType == "Long">
|
||||
:value="parseInt(dict.value)"
|
||||
<#else>
|
||||
:value="dict.value"
|
||||
</#if>
|
||||
></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "select" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-select v-model="form.${column.javaField}" placeholder="请选择${column.columnLabel}">
|
||||
<el-option label="请选择字典生成" value="" />
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "checkbox" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-checkbox-group v-model="form.${column.javaField}">
|
||||
<el-checkbox
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
:label="dict.value">
|
||||
{{dict.label}}
|
||||
</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "checkbox" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-checkbox-group v-model="form.${column.javaField}">
|
||||
<el-checkbox>请选择字典生成</el-checkbox>
|
||||
</el-checkbox-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "radio" && column.dictType?has_content>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-radio-group v-model="form.${column.javaField}">
|
||||
<el-radio
|
||||
v-for="dict in ${column.dictType}"
|
||||
:key="dict.value"
|
||||
<#if column.javaType == "Integer" || column.javaType == "Long">
|
||||
:value="parseInt(dict.value)"
|
||||
<#else>
|
||||
:value="dict.value"
|
||||
</#if>
|
||||
>{{dict.label}}</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "radio" && !(column.dictType?has_content)>
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-radio-group v-model="form.${column.javaField}">
|
||||
<el-radio value="1">请选择字典生成</el-radio>
|
||||
</el-radio-group>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "switch">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-switch
|
||||
v-model="form.${column.javaField}"
|
||||
<#if column.javaType == "Boolean">
|
||||
:active-value="true"
|
||||
:inactive-value="false"
|
||||
<#elseif column.javaType == "Integer" || column.javaType == "Long">
|
||||
:active-value="0"
|
||||
:inactive-value="1"
|
||||
<#else>
|
||||
active-value="0"
|
||||
inactive-value="1"
|
||||
</#if>
|
||||
/>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "datetime">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-date-picker clearable
|
||||
v-model="form.${column.javaField}"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择${column.columnLabel}">
|
||||
</el-date-picker>
|
||||
</el-form-item>
|
||||
<#elseif column.htmlType == "textarea">
|
||||
<el-form-item label="${column.columnLabel}" prop="${column.javaField}">
|
||||
<el-input v-model="form.${column.javaField}" type="textarea" placeholder="请输入内容" />
|
||||
</el-form-item>
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
</el-form>
|
||||
<template #footer>
|
||||
<div class="dialog-footer">
|
||||
<el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
|
||||
<el-button @click="cancel">取 消</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="${BusinessName}" lang="ts">
|
||||
import {
|
||||
add${BusinessName},
|
||||
<#if enableStatus>
|
||||
change${BusinessName}Status,
|
||||
</#if>
|
||||
del${BusinessName},
|
||||
get${BusinessName},
|
||||
list${BusinessName},
|
||||
<#if enableSort>
|
||||
update${BusinessName}Sort,
|
||||
</#if>
|
||||
update${BusinessName}
|
||||
} from '@/api/${moduleName}/${businessName}';
|
||||
import { ${BusinessName}Form, ${BusinessName}Query, ${BusinessName}VO } from '@/api/${moduleName}/${businessName}/types';
|
||||
import { useLoading } from '@/hooks/async/useLoading';
|
||||
import { useFormDialog } from '@/hooks/dialog/useFormDialog';
|
||||
<#if needAddDateRange>
|
||||
import { useDateRangeQuery } from '@/hooks/form/useDateRangeQuery';
|
||||
</#if>
|
||||
import { useSearchReset } from '@/hooks/form/useSearchReset';
|
||||
import { useSearchToggle } from '@/hooks/form/useSearchToggle';
|
||||
import { useTableSelection } from '@/hooks/table/useTableSelection';
|
||||
<#if needDict>
|
||||
import { useDict } from '@/utils/dict';
|
||||
</#if>
|
||||
<#if needParseTime>
|
||||
import { parseTime } from '@/utils/aixun';
|
||||
</#if>
|
||||
import modal from '@/plugins/modal';
|
||||
<#if enableExport>
|
||||
import { download as requestDownload } from '@/utils/request';
|
||||
</#if>
|
||||
|
||||
<#if needDict>
|
||||
const { ${dictsNoSymbol} } = toRefs<any>(useDict(${dicts}));
|
||||
</#if>
|
||||
|
||||
<#if enableStatus>
|
||||
const ${statusField}ActiveValue = <#if statusColumn.javaType == "Boolean">true<#elseif statusColumn.javaType == "Integer" || statusColumn.javaType == "Long">0<#else>'0'</#if>;
|
||||
const ${statusField}InactiveValue = <#if statusColumn.javaType == "Boolean">false<#elseif statusColumn.javaType == "Integer" || statusColumn.javaType == "Long">1<#else>'1'</#if>;
|
||||
</#if>
|
||||
|
||||
const ${businessName}List = ref<${BusinessName}VO[]>([]);
|
||||
const buttonLoading = ref(false);
|
||||
const { loading, withLoading } = useLoading(true);
|
||||
const { showSearch } = useSearchToggle();
|
||||
const total = ref(0);
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query>
|
||||
const {
|
||||
dateRange: dateRange${column.capJavaField},
|
||||
applyDateRange: apply${column.capJavaField}DateRange,
|
||||
resetDateRange: reset${column.capJavaField}DateRange
|
||||
} = useDateRangeQuery('${column.capJavaField}');
|
||||
</#if>
|
||||
</#list>
|
||||
|
||||
const queryFormRef = ref<ElFormInstance>();
|
||||
const ${businessName}FormRef = ref<ElFormInstance>();
|
||||
|
||||
const initFormData: ${BusinessName}Form = {
|
||||
<#list columns as column>
|
||||
<#if column.insert || column.edit>
|
||||
<#if column.htmlType == "checkbox">
|
||||
${column.javaField}: [],
|
||||
<#else>
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
const data = reactive<PageData<${BusinessName}Form, ${BusinessName}Query>>({
|
||||
form: { ...initFormData },
|
||||
queryParams: {
|
||||
pageNum: 1,
|
||||
pageSize: 10,
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType != "datetime" || column.queryType != "BETWEEN">
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
params: {
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN">
|
||||
${column.javaField}: undefined,
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
},
|
||||
rules: {
|
||||
<#list columns as column>
|
||||
<#if column.insert || column.edit>
|
||||
<#if column.required>
|
||||
${column.javaField}: [
|
||||
{ required: true, message: "${column.columnLabel}不能为空", trigger: <#if column.htmlType == "select" || column.htmlType == "radio" || column.htmlType == "switch" || column.htmlType == "inputNumber">"change"<#else>"blur"</#if> }
|
||||
],
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
});
|
||||
|
||||
const { queryParams, form, rules } = toRefs(data);
|
||||
const { ids, single, multiple, handleSelectionChange } = useTableSelection<${BusinessName}VO>(item => item.${pkColumn.javaField});
|
||||
const { dialog, resetForm: reset, openDialog, showDialog, closeDialog } = useFormDialog({
|
||||
form,
|
||||
formRef: ${businessName}FormRef,
|
||||
initialFormData: initFormData
|
||||
});
|
||||
|
||||
/** 查询${functionName}列表 */
|
||||
const getList = async () => {
|
||||
await withLoading(async () => {
|
||||
<#if needAddDateRange>
|
||||
let params = queryParams.value;
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query>
|
||||
params = apply${column.capJavaField}DateRange(params);
|
||||
</#if>
|
||||
</#list>
|
||||
const res = await list${BusinessName}(params);
|
||||
<#else>
|
||||
const res = await list${BusinessName}(queryParams.value);
|
||||
</#if>
|
||||
${businessName}List.value = res.data?.rows;
|
||||
total.value = res.data?.total;
|
||||
});
|
||||
};
|
||||
|
||||
/** 取消按钮 */
|
||||
const cancel = () => {
|
||||
reset();
|
||||
closeDialog();
|
||||
};
|
||||
|
||||
/** 搜索按钮操作 */
|
||||
const handleQuery = () => {
|
||||
queryParams.value.pageNum = 1;
|
||||
getList();
|
||||
};
|
||||
|
||||
const { resetQuery } = useSearchReset({
|
||||
queryFormRef,
|
||||
queryParams,
|
||||
pageNumKey: 'pageNum',
|
||||
pageSizeKey: 'pageSize',
|
||||
initialPageSize: 10,
|
||||
resetExtras: () => {
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "datetime" && column.queryType == "BETWEEN" && column.query>
|
||||
reset${column.capJavaField}DateRange();
|
||||
</#if>
|
||||
</#list>
|
||||
},
|
||||
afterReset: () => {
|
||||
handleQuery();
|
||||
}
|
||||
});
|
||||
|
||||
/** 新增按钮操作 */
|
||||
const handleAdd = () => {
|
||||
openDialog('添加${functionName}');
|
||||
};
|
||||
|
||||
/** 修改按钮操作 */
|
||||
const handleUpdate = async (row?: Partial<${BusinessName}VO>) => {
|
||||
reset();
|
||||
const _${pkColumn.javaField} = row?.${pkColumn.javaField} || ids.value[0];
|
||||
const res = await get${BusinessName}(_${pkColumn.javaField});
|
||||
Object.assign(form.value, res.data);
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "checkbox">
|
||||
form.value.${column.javaField} = form.value.${column.javaField}.split(",");
|
||||
</#if>
|
||||
</#list>
|
||||
showDialog('修改${functionName}');
|
||||
};
|
||||
|
||||
/** 提交按钮 */
|
||||
const submitForm = () => {
|
||||
${businessName}FormRef.value?.validate(async (valid: boolean) => {
|
||||
if (valid) {
|
||||
buttonLoading.value = true;
|
||||
<#list columns as column>
|
||||
<#if column.htmlType == "checkbox">
|
||||
form.value.${column.javaField} = form.value.${column.javaField}.join(",");
|
||||
</#if>
|
||||
</#list>
|
||||
if (form.value.${pkColumn.javaField}) {
|
||||
await update${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
|
||||
} else {
|
||||
await add${BusinessName}(form.value).finally(() => (buttonLoading.value = false));
|
||||
}
|
||||
modal.msgSuccess('操作成功');
|
||||
closeDialog();
|
||||
await getList();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
/** 删除按钮操作 */
|
||||
const handleDelete = async (row?: Partial<${BusinessName}VO>) => {
|
||||
const _${pkColumn.javaField}s = row?.${pkColumn.javaField} || ids.value;
|
||||
await modal.confirm('是否确认删除${functionName}编号为"' + _${pkColumn.javaField}s + '"的数据项?');
|
||||
await del${BusinessName}(_${pkColumn.javaField}s);
|
||||
modal.msgSuccess('删除成功');
|
||||
await getList();
|
||||
};
|
||||
|
||||
<#if enableExport>
|
||||
/** 导出按钮操作 */
|
||||
const handleExport = () => {
|
||||
requestDownload(
|
||||
'${moduleName}/${businessName}/export',
|
||||
{
|
||||
...queryParams.value
|
||||
},
|
||||
`${businessName}_${r'${new Date().getTime()}'}.xlsx`
|
||||
);
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if enableStatus>
|
||||
/** 状态修改 */
|
||||
const handleStatusChange = async (row: Partial<${BusinessName}VO>) => {
|
||||
const text = row.${statusField} === ${statusField}ActiveValue ? '启用' : '停用';
|
||||
try {
|
||||
await modal.confirm('确认要"' + text + '"吗?');
|
||||
await change${BusinessName}Status(row.${pkColumn.javaField}, row.${statusField});
|
||||
modal.msgSuccess(text + '成功');
|
||||
} catch (err) {
|
||||
row.${statusField} = row.${statusField} === ${statusField}ActiveValue ? ${statusField}InactiveValue : ${statusField}ActiveValue;
|
||||
}
|
||||
};
|
||||
</#if>
|
||||
|
||||
<#if enableSort>
|
||||
/** 排序调整 */
|
||||
const handleSortChange = async (row: Partial<${BusinessName}VO>) => {
|
||||
try {
|
||||
await update${BusinessName}Sort(row.${pkColumn.javaField}, row.${sortField});
|
||||
modal.msgSuccess('排序更新成功');
|
||||
} catch (err) {
|
||||
await getList();
|
||||
}
|
||||
};
|
||||
</#if>
|
||||
|
||||
onMounted(() => {
|
||||
getList();
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
export interface ${BusinessName}VO {
|
||||
<#list columns as column>
|
||||
<#if column.list>
|
||||
/**
|
||||
* ${column.columnComment}
|
||||
*/
|
||||
${column.javaField}: ${column.tsType};
|
||||
<#if column.htmlType == "imageUpload">
|
||||
/**
|
||||
* ${column.columnComment}Url
|
||||
*/
|
||||
${column.javaField}Url: string;
|
||||
</#if>
|
||||
</#if>
|
||||
</#list>
|
||||
<#if table.tree>
|
||||
/**
|
||||
* 子对象
|
||||
*/
|
||||
children: ${BusinessName}VO[];
|
||||
</#if>
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Form extends BaseEntity {
|
||||
<#list columns as column>
|
||||
<#if column.insert || column.edit>
|
||||
/**
|
||||
* ${column.columnComment}
|
||||
*/
|
||||
${column.javaField}?: ${column.tsType};
|
||||
</#if>
|
||||
</#list>
|
||||
}
|
||||
|
||||
export interface ${BusinessName}Query<#if !table.tree> extends PageQuery</#if> {
|
||||
<#list columns as column>
|
||||
<#if column.query>
|
||||
/**
|
||||
* ${column.columnComment}
|
||||
*/
|
||||
${column.javaField}?: ${column.tsType};
|
||||
</#if>
|
||||
</#list>
|
||||
/**
|
||||
* 日期范围参数
|
||||
*/
|
||||
params?: any;
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
|
||||
<meta name="renderer" content="webkit" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||
<link rel="icon" type="image/svg+xml" href="/zhuohui-mark.svg" />
|
||||
<title>%VITE_APP_TITLE%</title>
|
||||
<!--[if lt IE 11]>
|
||||
<script>
|
||||
window.location.href = '/ie.html';
|
||||
</script>
|
||||
<![endif]-->
|
||||
<style>
|
||||
html,
|
||||
body,
|
||||
#app {
|
||||
height: 100%;
|
||||
margin: 0px;
|
||||
padding: 0px;
|
||||
}
|
||||
|
||||
.chromeframe {
|
||||
margin: 0.2em 0;
|
||||
background: #ccc;
|
||||
color: #000;
|
||||
padding: 0.2em 0;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
<script type="module" src="/src/main.ts"></script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,27 @@
|
||||
server {
|
||||
listen 80;
|
||||
server_name localhost;
|
||||
resolver 127.0.0.11 valid=10s;
|
||||
|
||||
root /usr/share/nginx/html;
|
||||
index index.html;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
|
||||
location /prod-api/ {
|
||||
set $aixun_gateway http://gateway:8080;
|
||||
rewrite ^/prod-api/(.*)$ /$1 break;
|
||||
proxy_pass $aixun_gateway;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_buffering off;
|
||||
proxy_read_timeout 3600s;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
{
|
||||
"$schema": "https://json.schemastore.org/package",
|
||||
"name": "aixun-datagov-ui",
|
||||
"version": "1.0.0",
|
||||
"description": "艾讯科技 AiXun-DataGov 数据治理平台管理端",
|
||||
"license": "MIT",
|
||||
"author": "艾讯科技 <343559364@qq.com>",
|
||||
"packageManager": "pnpm@10.34.5",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "vite build --mode production",
|
||||
"build:dev": "vite build --mode development",
|
||||
"build:prod": "vite build --mode production",
|
||||
"dev": "vite serve --mode development",
|
||||
"fmt": "oxfmt .",
|
||||
"lint": "oxlint src",
|
||||
"lint:fix": "oxlint --fix src",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"dependencies": {
|
||||
"@antv/g6": "5.1.1",
|
||||
"@dagrejs/dagre": "3.1.1",
|
||||
"@element-plus/icons-vue": "2.3.2",
|
||||
"@highlightjs/vue-plugin": "2.1.2",
|
||||
"@iconify/vue": "^5.0.1",
|
||||
"@vue-flow/core": "1.48.2",
|
||||
"@vueuse/core": "14.3.0",
|
||||
"@wangeditor-next/editor": "5.7.16",
|
||||
"@wangeditor-next/editor-for-vue": "5.1.14",
|
||||
"animate.css": "4.1.1",
|
||||
"await-to-js": "3.0.0",
|
||||
"axios": "1.18.1",
|
||||
"crypto-js": "4.2.0",
|
||||
"echarts": "6.1.0",
|
||||
"element-plus": "2.14.3",
|
||||
"highlight.js": "11.11.1",
|
||||
"image-conversion": "2.1.1",
|
||||
"jsencrypt": "3.5.4",
|
||||
"monaco-editor": "0.56.0",
|
||||
"nprogress": "0.2.0",
|
||||
"pinia": "4.0.2",
|
||||
"vue": "3.5.40",
|
||||
"vue-cropper": "1.1.4",
|
||||
"vue-i18n": "11.4.8",
|
||||
"vue-json-pretty": "2.6.0",
|
||||
"vue-router": "5.2.0",
|
||||
"vue-types": "7.0.0",
|
||||
"vxe-pc-ui": "4.16.22",
|
||||
"vxe-table": "4.20.8"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/crypto-js": "4.2.2",
|
||||
"@types/node": "^26.1.1",
|
||||
"@types/nprogress": "0.2.3",
|
||||
"@unocss/preset-attributify": "66.7.5",
|
||||
"@unocss/preset-wind3": "66.7.5",
|
||||
"@vitejs/plugin-vue": "^6.0.8",
|
||||
"@vue/compiler-sfc": "3.5.40",
|
||||
"autoprefixer": "10.5.4",
|
||||
"oxfmt": "^0.60.0",
|
||||
"oxlint": "^1.75.0",
|
||||
"sass": "1.102.0",
|
||||
"typescript": "^6.0.3",
|
||||
"unocss": "66.7.5",
|
||||
"unplugin-auto-import": "21.0.0",
|
||||
"unplugin-vue-components": "32.1.0",
|
||||
"unplugin-vue-setup-extend-plus": "1.0.1",
|
||||
"vite": "^8.1.5",
|
||||
"vite-plugin-svg-icons-ng": "^1.9.2",
|
||||
"vitest": "4.1.10",
|
||||
"vue-tsc": "^3.3.8"
|
||||
},
|
||||
"browserslist": [
|
||||
"Chrome >= 87",
|
||||
"Edge >= 88",
|
||||
"Safari >= 14",
|
||||
"Firefox >= 78"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">=20.19.0",
|
||||
"pnpm": ">=10.0.0"
|
||||
}
|
||||
}
|
||||
+5185
文件差异内容过多而无法显示
加载差异
@@ -0,0 +1,11 @@
|
||||
packages:
|
||||
- '.'
|
||||
|
||||
allowBuilds:
|
||||
'@parcel/watcher': true
|
||||
es5-ext: true
|
||||
esbuild: true
|
||||
vue-demi: set this to true or false
|
||||
|
||||
overrides:
|
||||
esbuild: 0.28.1
|
||||
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 8.2 KiB |
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 8.2 KiB |
文件差异因一行或多行过长而隐藏
@@ -0,0 +1,21 @@
|
||||
The MIT License
|
||||
|
||||
Copyright © 2010-2025 three.js authors
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
二进制文件未显示。
|
之后 宽度: | 高度: | 大小: 99 KiB |
文件差异因一行或多行过长而隐藏
文件差异因一行或多行过长而隐藏
|
之后 宽度: | 高度: | 大小: 132 KiB |
@@ -0,0 +1,23 @@
|
||||
<template>
|
||||
<el-config-provider :locale="appStore.locale" :size="appStore.size">
|
||||
<router-view />
|
||||
</el-config-provider>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { useAppStore } from '@/store/modules/app';
|
||||
import { useSettingsStore } from '@/store/modules/settings';
|
||||
import { handleThemeStyle } from '@/utils/theme';
|
||||
|
||||
const appStore = useAppStore();
|
||||
const settingsStore = useSettingsStore();
|
||||
|
||||
onBeforeMount(() => {
|
||||
const root = document.documentElement;
|
||||
root.classList.remove('dark');
|
||||
root.classList.add('light');
|
||||
root.style.colorScheme = 'light';
|
||||
root.style.setProperty('--app-radius-base', `${settingsStore.radiusBase}px`);
|
||||
handleThemeStyle(settingsStore.theme);
|
||||
});
|
||||
</script>
|
||||
@@ -0,0 +1,48 @@
|
||||
// 前缀
|
||||
const animatePrefix = 'animate__animated ';
|
||||
// 开启随机动画 随机动画值
|
||||
const animateList: string[] = [
|
||||
animatePrefix + 'animate__pulse',
|
||||
animatePrefix + 'animate__rubberBand',
|
||||
animatePrefix + 'animate__bounceIn',
|
||||
animatePrefix + 'animate__bounceInLeft',
|
||||
animatePrefix + 'animate__fadeIn',
|
||||
animatePrefix + 'animate__fadeInLeft',
|
||||
animatePrefix + 'animate__fadeInDown',
|
||||
animatePrefix + 'animate__fadeInUp',
|
||||
animatePrefix + 'animate__flipInX',
|
||||
animatePrefix + 'animate__lightSpeedInLeft',
|
||||
animatePrefix + 'animate__rotateInDownLeft',
|
||||
animatePrefix + 'animate__rollIn',
|
||||
animatePrefix + 'animate__rotateInDownLeft',
|
||||
animatePrefix + 'animate__zoomIn',
|
||||
animatePrefix + 'animate__zoomInDown',
|
||||
animatePrefix + 'animate__slideInLeft',
|
||||
animatePrefix + 'animate__lightSpeedIn'
|
||||
];
|
||||
// 关闭随机动画后的默认效果
|
||||
const defaultAnimate = animatePrefix + 'animate__fadeIn';
|
||||
// 搜索隐藏显示动画
|
||||
const searchAnimate = {
|
||||
enter: '',
|
||||
leave: ''
|
||||
};
|
||||
|
||||
// 菜单搜索动画
|
||||
const menuSearchAnimate = {
|
||||
enter: animatePrefix + 'animate__fadeIn',
|
||||
leave: animatePrefix + 'animate__fadeOut'
|
||||
};
|
||||
// logo动画
|
||||
const logoAnimate = {
|
||||
enter: animatePrefix + 'animate__fadeIn',
|
||||
leave: animatePrefix + 'animate__fadeOut'
|
||||
};
|
||||
|
||||
export default {
|
||||
animateList,
|
||||
defaultAnimate,
|
||||
searchAnimate,
|
||||
menuSearchAnimate,
|
||||
logoAnimate
|
||||
};
|
||||
@@ -0,0 +1,84 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
CreatePolicyCommand,
|
||||
PolicyStatusCommand,
|
||||
PolicyVO,
|
||||
PurposeCommand,
|
||||
UpdatePolicyCommand,
|
||||
VerificationCommand,
|
||||
VerificationVO,
|
||||
WriteResult
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/governance/v1/access-controls';
|
||||
const writeHeaders = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
type RequestOptions = { suppressErrorToast?: boolean };
|
||||
|
||||
export const listAccessControlPolicies = (options: RequestOptions = {}): AxiosPromise<PolicyVO[]> =>
|
||||
request({ ...options, url: baseUrl, method: 'get' });
|
||||
|
||||
export const getAccessControlPolicy = (policyId: number, options: RequestOptions = {}): AxiosPromise<PolicyVO> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'get' });
|
||||
|
||||
export const createAccessControlPolicy = (
|
||||
data: CreatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: baseUrl, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateAccessControlPolicy = (
|
||||
policyId: number,
|
||||
data: UpdatePolicyCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const deleteAccessControlPolicy = (policyId: number, version: number, key: string, options: RequestOptions = {}): AxiosPromise<void> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}`, method: 'delete', params: { version }, headers: writeHeaders(key) });
|
||||
|
||||
export const changeAccessControlPolicyStatus = (
|
||||
policyId: number,
|
||||
data: PolicyStatusCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/status`, method: 'post', data, headers: writeHeaders(key) });
|
||||
|
||||
export const updateAccessControlPurpose = (
|
||||
policyId: number,
|
||||
data: PurposeCommand,
|
||||
key: string,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<WriteResult<PolicyVO>> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/purpose`, method: 'put', data, headers: writeHeaders(key) });
|
||||
|
||||
export const registerAccessControlEvidence = (
|
||||
policyId: number,
|
||||
data: VerificationCommand,
|
||||
key: string
|
||||
): AxiosPromise<WriteResult<VerificationVO>> =>
|
||||
request({
|
||||
url: `${baseUrl}/${policyId}/enforcement-evidence`,
|
||||
method: 'post',
|
||||
data,
|
||||
headers: writeHeaders(key)
|
||||
});
|
||||
|
||||
export const getAccessControlVerification = (
|
||||
policyId: number,
|
||||
verificationId: number,
|
||||
options: RequestOptions = {}
|
||||
): AxiosPromise<VerificationVO> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/verifications/${verificationId}`, method: 'get' });
|
||||
|
||||
export const listAccessControlVerifications = (policyId: number, options: RequestOptions = {}): AxiosPromise<VerificationVO[]> =>
|
||||
request({ ...options, url: `${baseUrl}/${policyId}/verifications`, method: 'get' });
|
||||
|
||||
export const searchAccessControlSubjects = (subjectType: import('./types').SubjectType, keyword?: string, options: RequestOptions = {}): AxiosPromise<import('./types').SubjectCandidate[]> =>
|
||||
request({ ...options, url: `${baseUrl}/subject-candidates`, method: 'get', params: { subjectType, keyword } });
|
||||
|
||||
export const searchAccessControlSources = (keyword?: string, options: RequestOptions = {}): AxiosPromise<import('./types').SecuritySourceCandidate[]> =>
|
||||
request({ ...options, url: `${baseUrl}/source-candidates`, method: 'get', params: { keyword } });
|
||||
@@ -0,0 +1,117 @@
|
||||
export type PolicyStatus = 'DRAFT' | 'ACTIVE' | 'DEPRECATED' | 'ARCHIVED';
|
||||
export type ExecutionStatus = 'REGISTERED' | 'NOT_ENFORCED' | 'ENFORCED' | 'UNSUPPORTED';
|
||||
export type SubjectType = 'USER' | 'ROLE' | 'DEPARTMENT';
|
||||
export type EngineType = 'HIVE' | 'DORIS' | 'MYSQL' | 'MARIADB' | 'POSTGRESQL' | 'SQLSERVER' | 'DAMENG' | 'ORACLE';
|
||||
export type EnforcementUnit =
|
||||
| 'PLATFORM_QUERY'
|
||||
| 'HIVE_TABLE_SELECT'
|
||||
| 'HIVE_PROTECTED_EXPORT'
|
||||
| 'HIVE_COLUMN_SELECT'
|
||||
| 'HIVE_ROW_FILTER'
|
||||
| 'HIVE_MASKING'
|
||||
| 'DORIS_TENANT_ROW_POLICY'
|
||||
| 'DORIS_COLUMN_SELECT'
|
||||
| 'DORIS_MASKING';
|
||||
export type AccessAction = 'SELECT' | 'EXPORT';
|
||||
export type RowOperator = 'EQUALS' | 'NOT_EQUALS' | 'IN' | 'NOT_IN' | 'IS_NULL' | 'IS_NOT_NULL';
|
||||
export type EvidenceKind = 'DISPATCH' | 'READBACK' | 'ALLOW' | 'DENY';
|
||||
export type EvidenceOutcome = 'DISPATCHED' | 'MATCHED' | 'ALLOWED' | 'DENIED';
|
||||
|
||||
export interface RowCondition {
|
||||
fieldRef: string;
|
||||
operator: RowOperator;
|
||||
valueRef?: string;
|
||||
}
|
||||
|
||||
export interface PurposeConstraint {
|
||||
purposeCode: string;
|
||||
scenarioRef: string;
|
||||
scopeRef: string;
|
||||
validFrom: string;
|
||||
validUntil: string;
|
||||
allowedActions: AccessAction[];
|
||||
}
|
||||
|
||||
export interface CreatePolicyCommand {
|
||||
policyCode: string;
|
||||
policyName: string;
|
||||
subjectType: SubjectType;
|
||||
subjectRef: string;
|
||||
engineType: EngineType;
|
||||
enforcementUnit: EnforcementUnit;
|
||||
resourceRef: string;
|
||||
actions: AccessAction[];
|
||||
rowConditions: RowCondition[];
|
||||
columnRefs: string[];
|
||||
purpose: PurposeConstraint;
|
||||
}
|
||||
|
||||
export interface UpdatePolicyCommand extends Omit<CreatePolicyCommand, 'policyCode'> {
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PolicyStatusCommand {
|
||||
targetStatus: PolicyStatus;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PurposeCommand {
|
||||
purpose: PurposeConstraint;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface EnforcementEvidence {
|
||||
kind: EvidenceKind;
|
||||
outcome: EvidenceOutcome;
|
||||
evidenceRef: string;
|
||||
externalPolicyRef: string;
|
||||
observedAt: string;
|
||||
reliable: boolean;
|
||||
snapshotSha256: string;
|
||||
}
|
||||
|
||||
export interface VerificationCommand {
|
||||
policyVersion: number;
|
||||
evidence: EnforcementEvidence[];
|
||||
}
|
||||
|
||||
export interface PolicyVO extends CreatePolicyCommand {
|
||||
policyId: number;
|
||||
policyStatus: PolicyStatus;
|
||||
executionStatus: ExecutionStatus;
|
||||
executionReason?: string;
|
||||
organizationId: number;
|
||||
departmentId: number;
|
||||
version: number;
|
||||
createTime?: string;
|
||||
updateTime?: string;
|
||||
}
|
||||
|
||||
export interface VerificationVO {
|
||||
verificationId: number;
|
||||
policyId: number;
|
||||
policyVersion: number;
|
||||
executionStatus: ExecutionStatus;
|
||||
reasonCode?: string;
|
||||
snapshotSha256?: string;
|
||||
evidence: EnforcementEvidence[];
|
||||
verifiedAt?: string;
|
||||
}
|
||||
|
||||
export interface WriteResult<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
export interface SubjectCandidate { subjectRef: string; subjectType: SubjectType; label: string }
|
||||
|
||||
export interface SecuritySourceCandidate {
|
||||
reference: string;
|
||||
tableId: string;
|
||||
label: string;
|
||||
engineType: EngineType;
|
||||
sourceVersion: number;
|
||||
metadataRevision: number;
|
||||
fields: Array<{ reference: string; name: string; type: string; restricted: boolean }>;
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const { request } = vi.hoisted(() => ({ request: vi.fn() }));
|
||||
vi.mock('@/utils/request', () => ({ default: request }));
|
||||
|
||||
import { listAiCandidates } from './index';
|
||||
|
||||
describe('AI governance candidate contract', () => {
|
||||
beforeEach(() => request.mockReset());
|
||||
|
||||
it('requests only the supported type with bounded search parameters', async () => {
|
||||
request.mockResolvedValue({ data: [{ label: '规则 · db.table', targetRef: 'quality-rule:7', objectType: 'QUALITY_RULE' }] });
|
||||
await listAiCandidates('QUALITY_RULE', 'table', 20);
|
||||
expect(request).toHaveBeenCalledWith(expect.objectContaining({
|
||||
url: '/api/governance/v1/ai-suggestions/candidates', method: 'get',
|
||||
params: { type: 'QUALITY_RULE', keyword: 'table', limit: 20 }, suppressErrorToast: true
|
||||
}));
|
||||
});
|
||||
|
||||
it('preserves the server targetRef instead of constructing an internal id', async () => {
|
||||
const response = { label: '可靠快照 · doris', targetRef: 'metadata:91', objectType: 'METADATA_ENRICHMENT' };
|
||||
request.mockResolvedValue({ data: [response] });
|
||||
const result = await listAiCandidates('METADATA_ENRICHMENT');
|
||||
expect(result.data[0]).toEqual(response);
|
||||
expect(result.data[0].targetRef).toBe('metadata:91');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface FormAssistField { key: string; label: string; maxLength: number }
|
||||
export interface FormAssistSchema { page: { id: string; title: string; fields: FormAssistField[] }; enabled: boolean }
|
||||
export interface FormAssistResult { requestId: string; state: string; answer?: string; candidate: Record<string, string>; code: string }
|
||||
const base = '/api/integration/v1/ai/form-assistance';
|
||||
export const formAssistSchema = (page: string): AxiosPromise<FormAssistSchema> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}`, method: 'get', suppressErrorToast: true });
|
||||
export const generateFormCandidate = (page: string, data: { requestId: string; prompt: string; values: Record<string, string> }, signal: AbortSignal): AxiosPromise<FormAssistResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}`, method: 'post', data, signal, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,115 @@
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
const { request } = vi.hoisted(() => ({
|
||||
request: vi.fn((config: unknown) => Promise.resolve({ data: config }))
|
||||
}));
|
||||
vi.mock('@/utils/request', () => ({ default: request }));
|
||||
|
||||
import { generateAiSuggestion, listAiCandidates, listAiSuggestions, updateAiProvider } from './index';
|
||||
|
||||
describe('AI assistant request security', () => {
|
||||
beforeEach(() => request.mockClear());
|
||||
|
||||
it('never writes an API Key request into the repeat-submit session cache', async () => {
|
||||
await updateAiProvider({
|
||||
enabled: true,
|
||||
providerType: 'OPENAI_COMPATIBLE',
|
||||
model: 'model-1',
|
||||
endpoint: 'https://provider.example/v1',
|
||||
apiKey: 'temporary-test-key',
|
||||
revokeApiKey: false,
|
||||
timeoutSeconds: 20,
|
||||
version: 0
|
||||
});
|
||||
|
||||
expect(request).toHaveBeenCalledWith(expect.objectContaining({
|
||||
method: 'put',
|
||||
headers: { repeatSubmit: false }
|
||||
}));
|
||||
});
|
||||
|
||||
it('does not send client evidence authorization assertions to Governance', async () => {
|
||||
await generateAiSuggestion('quality-rule', {
|
||||
objectType: 'QUALITY_RULE',
|
||||
objectId: 'quality-rule:1',
|
||||
purpose: '生成审查建议',
|
||||
evidenceRefs: ['client-value-must-not-be-trusted']
|
||||
}, 'request-12345678');
|
||||
|
||||
const config = request.mock.calls[0][0] as { data: Record<string, unknown>; headers: Record<string, unknown> };
|
||||
expect(config.data).toEqual({
|
||||
requestId: 'request-12345678',
|
||||
type: 'QUALITY_RULE',
|
||||
targetRef: 'quality-rule:1',
|
||||
context: '生成审查建议'
|
||||
});
|
||||
expect(config.headers).toEqual({ repeatSubmit: false });
|
||||
});
|
||||
|
||||
it('loads standard governance workflow candidates from the server evidence owner', async () => {
|
||||
await listAiCandidates('GOVERNANCE_WORKFLOW', 'STD', 10);
|
||||
|
||||
expect(request).toHaveBeenCalledWith({
|
||||
url: '/api/governance/v1/ai-suggestions/candidates',
|
||||
method: 'get',
|
||||
params: { type: 'GOVERNANCE_WORKFLOW', keyword: 'STD', limit: 10 },
|
||||
suppressErrorToast: true
|
||||
});
|
||||
});
|
||||
|
||||
it('sends DataOps evidence references without client authorization or summary facts', async () => {
|
||||
await generateAiSuggestion('sql-processing', {
|
||||
objectType: 'TABLE',
|
||||
objectId: 'DORIS_SALES.product',
|
||||
purpose: '检查只读SQL',
|
||||
evidenceRefs: ['table-file:1'],
|
||||
tableFileId: 1,
|
||||
sqlDraft: 'SELECT * FROM DORIS_SALES.product',
|
||||
processingDraft: '只读检查'
|
||||
}, 'request-12345678');
|
||||
|
||||
const config = request.mock.calls[0][0] as { data: { evidence: Array<Record<string, unknown>> } };
|
||||
expect(config.data.evidence).toEqual([{ reference: 'table-file:1', kind: 'METADATA' }]);
|
||||
});
|
||||
|
||||
it('loads and normalizes persisted drafts from both business services', async () => {
|
||||
request
|
||||
.mockResolvedValueOnce({
|
||||
data: [{
|
||||
suggestionId: 1,
|
||||
type: 'QUALITY_RULE',
|
||||
proposal: '',
|
||||
rationale: '证据不足',
|
||||
failureCode: 'EVIDENCE_INSUFFICIENT',
|
||||
state: 'DRAFT',
|
||||
createTime: '2026-10-07T20:00:00'
|
||||
}]
|
||||
})
|
||||
.mockResolvedValueOnce({
|
||||
data: {
|
||||
rows: [{
|
||||
suggestionId: 2,
|
||||
title: 'SQL建议',
|
||||
status: 'DRAFT',
|
||||
createdAt: '2026-10-07T20:01:00',
|
||||
evidence: [{ reference: 'table-file:1' }]
|
||||
}],
|
||||
total: 1
|
||||
}
|
||||
});
|
||||
|
||||
const rows = await listAiSuggestions();
|
||||
|
||||
expect(rows.map((item) => item.suggestionId)).toEqual([2, 1]);
|
||||
expect(rows[0]).toEqual(expect.objectContaining({
|
||||
assistantType: 'sql-processing',
|
||||
evidenceRefs: ['table-file:1']
|
||||
}));
|
||||
expect(rows[1]).toEqual(expect.objectContaining({
|
||||
assistantType: 'quality-rule',
|
||||
summary: '证据不足',
|
||||
status: 'FAILED',
|
||||
code: 'EVIDENCE_INSUFFICIENT'
|
||||
}));
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,148 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AiAssistantType,
|
||||
AiProviderCommand,
|
||||
AiProviderVerifyVO,
|
||||
AiProviderVO,
|
||||
AiSuggestionCommand,
|
||||
AiSuggestionPage,
|
||||
AiSuggestionVO,
|
||||
AiSuggestionCandidate
|
||||
} from './types';
|
||||
|
||||
const providerUrl = '/api/integration/v1/ai/providers/current';
|
||||
const governanceTypes: Record<Exclude<AiAssistantType, 'sql-processing'>, string> = {
|
||||
'governance-flow': 'GOVERNANCE_WORKFLOW',
|
||||
'fault-diagnosis': 'FAILURE_DIAGNOSIS',
|
||||
'metadata-enrichment': 'METADATA_ENRICHMENT',
|
||||
'standard-match': 'STANDARD_MATCH',
|
||||
'quality-rule': 'QUALITY_RULE'
|
||||
};
|
||||
const governanceAssistantTypes = Object.fromEntries(
|
||||
Object.entries(governanceTypes).map(([assistantType, suggestionType]) => [suggestionType, assistantType])
|
||||
) as Record<string, Exclude<AiAssistantType, 'sql-processing'>>;
|
||||
|
||||
const normalizeGovernanceSuggestion = (item: any): AiSuggestionVO => ({
|
||||
...item,
|
||||
assistantType: governanceAssistantTypes[item.type],
|
||||
title: item.proposal ? '治理辅助建议' : undefined,
|
||||
summary: item.proposal || item.rationale,
|
||||
impactScope: item.impact,
|
||||
status: item.failureCode ? 'FAILED' : item.state,
|
||||
code: item.failureCode,
|
||||
createTime: item.createTime
|
||||
});
|
||||
|
||||
const normalizeDataOpsSuggestion = (item: any): AiSuggestionVO => ({
|
||||
...item,
|
||||
assistantType: 'sql-processing',
|
||||
impactScope: item.impactSummary,
|
||||
status: item.status,
|
||||
code: item.errorCode,
|
||||
createTime: item.createdAt,
|
||||
evidenceRefs: item.evidence?.map((evidence: any) => evidence.reference) || []
|
||||
});
|
||||
|
||||
export const getAiProvider = (): AxiosPromise<AiProviderVO> => request({ url: providerUrl, method: 'get' });
|
||||
export const updateAiProvider = async (data: AiProviderCommand): AxiosPromise<AiProviderVO> => {
|
||||
const response = await request({ url: providerUrl, method: 'put', data, headers: { repeatSubmit: false } });
|
||||
window.dispatchEvent(new CustomEvent('datagov-ai-provider-changed', { detail: { enabled: response.data.enabled === true } }));
|
||||
return response;
|
||||
};
|
||||
export const verifyAiProvider = (): AxiosPromise<AiProviderVerifyVO> =>
|
||||
request({ url: `${providerUrl}/verify`, method: 'post', suppressErrorToast: true });
|
||||
export function listAiCandidates(type: 'QUALITY_RULE' | 'METADATA_ENRICHMENT' | 'GOVERNANCE_WORKFLOW', keyword = '', limit = 20): AxiosPromise<AiSuggestionCandidate[]> {
|
||||
return request({ url: '/api/governance/v1/ai-suggestions/candidates', method: 'get', params: { type, keyword, limit }, suppressErrorToast: true });
|
||||
}
|
||||
|
||||
export async function listAiSuggestions(): Promise<AiSuggestionVO[]> {
|
||||
const [governance, dataops] = await Promise.allSettled([
|
||||
request({ url: '/api/governance/v1/ai-suggestions', method: 'get', suppressErrorToast: true }) as AxiosPromise<any[]>,
|
||||
request({
|
||||
url: '/api/dataops/v1/ai-assistant/sql-processing/suggestions',
|
||||
method: 'get',
|
||||
params: { pageNum: 1, pageSize: 100 },
|
||||
suppressErrorToast: true
|
||||
}) as AxiosPromise<AiSuggestionPage>
|
||||
]);
|
||||
if (governance.status === 'rejected' && dataops.status === 'rejected') {
|
||||
throw new Error('AI_SUGGESTION_LIST_UNAVAILABLE');
|
||||
}
|
||||
const governanceRows = governance.status === 'fulfilled'
|
||||
? (governance.value.data || []).map(normalizeGovernanceSuggestion) : [];
|
||||
const dataOpsRows = dataops.status === 'fulfilled'
|
||||
? (dataops.value.data?.rows || []).map(normalizeDataOpsSuggestion) : [];
|
||||
return [...governanceRows, ...dataOpsRows].toSorted((left, right) =>
|
||||
(right.createTime || '').localeCompare(left.createTime || ''));
|
||||
}
|
||||
|
||||
export function generateAiSuggestion(
|
||||
type: AiAssistantType,
|
||||
data: AiSuggestionCommand,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<AiSuggestionVO> {
|
||||
if (type !== 'sql-processing') {
|
||||
return request({
|
||||
url: '/api/governance/v1/ai-suggestions',
|
||||
method: 'post',
|
||||
data: {
|
||||
requestId: idempotencyKey,
|
||||
type: governanceTypes[type],
|
||||
targetRef: data.objectId,
|
||||
context: data.purpose
|
||||
},
|
||||
headers: { repeatSubmit: false },
|
||||
suppressErrorToast: true
|
||||
}).then((response: any) => ({
|
||||
...response,
|
||||
data: normalizeGovernanceSuggestion(response.data)
|
||||
}));
|
||||
}
|
||||
return request({
|
||||
url: '/api/dataops/v1/ai-assistant/sql-processing/suggestions',
|
||||
method: 'post',
|
||||
data: {
|
||||
requestId: idempotencyKey,
|
||||
objectRef: data.objectId,
|
||||
objectType: data.objectType,
|
||||
instruction: data.purpose,
|
||||
sqlDraft: data.sqlDraft,
|
||||
processingDraft: data.processingDraft,
|
||||
tableFileId: data.tableFileId,
|
||||
evidence: data.evidenceRefs.map((reference) => ({
|
||||
reference,
|
||||
kind: 'METADATA'
|
||||
}))
|
||||
},
|
||||
headers: { 'Idempotency-Key': idempotencyKey, repeatSubmit: false },
|
||||
suppressErrorToast: true
|
||||
}).then((response: any) => ({
|
||||
...response,
|
||||
data: normalizeDataOpsSuggestion(response.data)
|
||||
}));
|
||||
}
|
||||
|
||||
export function adoptAiSuggestion(unit: 'governance' | 'dataops', id: number, version: number, idempotencyKey: string) {
|
||||
const url = unit === 'governance'
|
||||
? `/api/governance/v1/ai-suggestions/${id}/adopt`
|
||||
: `/api/dataops/v1/ai-assistant/sql-processing/suggestions/${id}/adopt`;
|
||||
return request({
|
||||
url,
|
||||
method: 'post',
|
||||
data: unit === 'governance' ? { version } : { version, reason: '用户在AI辅助建议页显式采纳' },
|
||||
headers: unit === 'dataops' ? { 'Idempotency-Key': idempotencyKey, repeatSubmit: false } : undefined
|
||||
});
|
||||
}
|
||||
|
||||
export function ignoreAiSuggestion(unit: 'governance' | 'dataops', id: number, version: number, idempotencyKey: string) {
|
||||
const url = unit === 'governance'
|
||||
? `/api/governance/v1/ai-suggestions/${id}/ignore`
|
||||
: `/api/dataops/v1/ai-assistant/sql-processing/suggestions/${id}/ignore`;
|
||||
return request({
|
||||
url,
|
||||
method: 'post',
|
||||
data: unit === 'governance' ? { version } : { version, reason: '用户在AI辅助建议页显式忽略' },
|
||||
headers: unit === 'dataops' ? { 'Idempotency-Key': idempotencyKey, repeatSubmit: false } : undefined
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface MetadataGraphSelection { pageId: 'P27' | 'P28'; snapshotId: string; mode: 'RELATIONS' | 'TRACE' | 'IMPACT'; fromId: string; toId?: string }
|
||||
export interface MetadataGraphNode { key: string; label: string; type: string }
|
||||
export interface MetadataGraphFact { key: string; kind: string; fromKey: string; toKey: string | null; fromField: string | null; toField: string | null; distance: number | null }
|
||||
export interface MetadataGraphContext { pageId: string; snapshotId: string; mode: string; observedAt: string | null; truncated: boolean; scopeNote: string; nodes: MetadataGraphNode[]; facts: MetadataGraphFact[]; contextSha256: string }
|
||||
export interface MetadataGraphFinding { explanation: string; evidenceKeys: string[]; reviewHint: string }
|
||||
export interface MetadataGraphResult { requestId: string; state: string; answer: string | null; findings: MetadataGraphFinding[]; code: string | null }
|
||||
export const metadataGraphContext = (data: MetadataGraphSelection, signal?: AbortSignal): AxiosPromise<MetadataGraphContext> => request({ url: '/api/governance/v1/metadata-graph-assist/context', method: 'post', data, signal });
|
||||
export const explainMetadataGraph = (data: { requestId: string; selection: MetadataGraphSelection; contextSha256: string; factKeys: string[]; prompt: string }, signal?: AbortSignal): AxiosPromise<MetadataGraphResult> => request({ url: '/api/integration/v1/ai/metadata-graph/explain', method: 'post', data, signal, timeout: 180000 });
|
||||
@@ -0,0 +1,11 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
|
||||
export interface AiProviderNetworkPolicy {
|
||||
publicEndpointsAllowed: boolean;
|
||||
privateEndpoints: string[];
|
||||
httpsRequired: boolean;
|
||||
}
|
||||
|
||||
export const getAiProviderNetworkPolicy = (): AxiosPromise<AiProviderNetworkPolicy> =>
|
||||
request({ url: '/api/integration/v1/ai/providers/current/network-policy', method: 'get' });
|
||||
@@ -0,0 +1,25 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface PageAssistField { key: string; label: string; kind: 'N' | 'T' | 'B' | 'CODE' | 'TEXT'; values: string[] }
|
||||
export interface PageAssistSchema {
|
||||
page: { id: string; title: string; permission: string; referencePath: string; referenceValues: string[]; guidance: string; fields: PageAssistField[] };
|
||||
enabled: boolean;
|
||||
code: string;
|
||||
}
|
||||
export type PageAssistValue = string | number | boolean | null;
|
||||
export interface PageAssistSnapshot { reference: string; facts: Record<string, PageAssistValue> }
|
||||
export interface PageAssistEvidence extends PageAssistSnapshot { inputSha256: string; origin: 'OWNER_READ' | 'DRAFT_INPUT' | 'NOT_READ'; sourceVersion: string; contextSha256: string }
|
||||
export interface PageAssistContextRequest { reference: string; qualifiers: Record<string, string>; draftFacts?: Record<string, PageAssistValue> }
|
||||
export interface PageAssistResult {
|
||||
requestId: string; state: string; answer?: string; code: string; model?: string;
|
||||
evidence: PageAssistEvidence;
|
||||
}
|
||||
const base = '/api/integration/v1/ai/page-assist';
|
||||
export const getPageAssistSchema = (page: string): AxiosPromise<PageAssistSchema> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/schema`, method: 'get', suppressErrorToast: true });
|
||||
export const getPageAssistContext = (page: string, data: PageAssistContextRequest): AxiosPromise<PageAssistEvidence> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/context`, method: 'post', data, timeout: 45000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const explainPageSelection = (page: string, data: PageAssistSnapshot & PageAssistContextRequest & { requestId: string; contextSha256: string }, signal: AbortSignal): AxiosPromise<PageAssistResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(page)}/explanations`, method: 'post', data, signal, timeout: 75000,
|
||||
headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,31 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export type ProviderProbeState = 'IN_PROGRESS' | 'SUCCEEDED' | 'FAILED' | 'NOT_RUN' | 'UNKNOWN';
|
||||
export interface ProviderProbeRequest { requestId: string; expectedProviderVersion: number }
|
||||
export interface ProviderProbeReceipt {
|
||||
requestId: string;
|
||||
providerVersion: number;
|
||||
state: ProviderProbeState;
|
||||
code: string;
|
||||
startedAt: string;
|
||||
completedAt: string | null;
|
||||
expiresAt: string;
|
||||
elapsedMillis: number | null;
|
||||
fingerprint: string;
|
||||
}
|
||||
export interface ProviderProbeCandidate { items: { factKeys: string[]; explanation: string }[] }
|
||||
export interface ProviderProbeCandidateResult {
|
||||
state: string;
|
||||
code: string;
|
||||
fingerprint: string;
|
||||
candidate: ProviderProbeCandidate | null;
|
||||
}
|
||||
|
||||
const base = '/api/integration/v1/ai/providers/current/verification-evidence';
|
||||
export const verifyProviderEvidence = (data: ProviderProbeRequest): AxiosPromise<ProviderProbeReceipt> =>
|
||||
request({ url: base, method: 'post', data, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const readProviderEvidence = (requestId: string): AxiosPromise<ProviderProbeReceipt> =>
|
||||
request({ url: `${base}/${encodeURIComponent(requestId)}`, method: 'get', suppressErrorToast: true });
|
||||
export const explainProviderEvidence = (requestId: string, data: { fingerprint: string; prompt: string }): AxiosPromise<ProviderProbeCandidateResult> =>
|
||||
request({ url: `${base}/${encodeURIComponent(requestId)}/candidates`, method: 'post', data, suppressErrorToast: true });
|
||||
@@ -0,0 +1,12 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface ComparisonSelection { pageId: 'P37' | 'P39'; objectIds: number[]; publicationIds: number[] }
|
||||
export interface ComparisonSubject { key: string; objectId: number; version: number; label: string; attributes: Record<string, string> }
|
||||
export interface ComparisonFact { key: string; kind: string; leftKey: string | null; rightKey: string | null; details: string[] }
|
||||
export interface ComparisonContext { selection: ComparisonSelection; subjects: ComparisonSubject[]; facts: ComparisonFact[]; sourceLabel: string; sourceVersion: number; scopeNote: string; contextSha256: string }
|
||||
export interface ComparisonFinding { evidenceKeys: string[]; assessment: string; explanation: string; reviewHint: string }
|
||||
export interface ComparisonTermDraft { subjectKey: string; definition: string; businessDefinition: string }
|
||||
export interface ComparisonValueMatch { leftKey: string; rightKey: string; reason: string }
|
||||
export interface ComparisonResult { requestId: string; state: string; answer: string | null; findings: ComparisonFinding[]; termDrafts: ComparisonTermDraft[]; valueMatches: ComparisonValueMatch[]; code: string | null }
|
||||
export const readComparison = (data: ComparisonSelection, signal?: AbortSignal): AxiosPromise<ComparisonContext> => request({ url: '/api/governance/v1/record-comparison/context', method: 'post', data, signal });
|
||||
export const explainComparison = (data: { requestId: string; selection: ComparisonSelection; contextSha256: string; evidenceKeys: string[]; prompt: string }, signal?: AbortSignal): AxiosPromise<ComparisonResult> => request({ url: '/api/integration/v1/ai/record-comparison/candidates', method: 'post', data, signal });
|
||||
@@ -0,0 +1,73 @@
|
||||
export type AiProviderType = 'OPENAI_COMPATIBLE';
|
||||
export type AiAssistantType =
|
||||
| 'governance-flow'
|
||||
| 'fault-diagnosis'
|
||||
| 'metadata-enrichment'
|
||||
| 'standard-match'
|
||||
| 'quality-rule'
|
||||
| 'sql-processing';
|
||||
|
||||
export interface AiProviderVO {
|
||||
enabled: boolean;
|
||||
secretConfigured: boolean;
|
||||
providerType: AiProviderType;
|
||||
model: string;
|
||||
endpoint: string;
|
||||
secretFingerprint?: string;
|
||||
timeoutSeconds: number;
|
||||
status: 'ENABLED' | 'DISABLED';
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AiProviderCommand {
|
||||
enabled: boolean;
|
||||
providerType: AiProviderType;
|
||||
model: string;
|
||||
endpoint: string;
|
||||
apiKey?: string;
|
||||
revokeApiKey: boolean;
|
||||
timeoutSeconds: number;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AiProviderVerifyVO {
|
||||
enabled: boolean;
|
||||
available: boolean;
|
||||
code: string;
|
||||
message: string;
|
||||
}
|
||||
|
||||
export interface AiSuggestionCommand {
|
||||
objectType: string;
|
||||
objectId: string;
|
||||
purpose: string;
|
||||
evidenceRefs: string[];
|
||||
tableFileId?: string | number;
|
||||
sqlDraft?: string;
|
||||
processingDraft?: string;
|
||||
}
|
||||
export interface AiSuggestionCandidate { label: string; targetRef: string; objectType: string; version?: string; observedAt?: string; }
|
||||
|
||||
export interface AiSuggestionVO {
|
||||
suggestionId?: number;
|
||||
requestId?: string;
|
||||
assistantType?: AiAssistantType;
|
||||
title?: string;
|
||||
summary?: string;
|
||||
proposal?: string;
|
||||
rationale?: string;
|
||||
confidence?: number;
|
||||
impactScope?: string;
|
||||
evidenceRefs?: string[];
|
||||
status?: 'DRAFT' | 'ADOPTED' | 'IGNORED' | 'DISABLED' | 'FAILED' | 'NOT_RUN';
|
||||
code?: string;
|
||||
model?: string;
|
||||
providerVersion?: string;
|
||||
version?: number;
|
||||
createTime?: string;
|
||||
}
|
||||
|
||||
export interface AiSuggestionPage {
|
||||
rows: AiSuggestionVO[];
|
||||
total: number;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Attachment } from '@/api/datagov/workbench-knowledge/attachments';
|
||||
|
||||
export interface AttachmentReference { id: string; version: number; fragmentId: number; hash: string; source: 'SESSION_ATTACHMENT'; }
|
||||
export interface ChatAttachment { file: Attachment; sessionId: string; expiresAt: string; revoked: boolean; retained: boolean; contentVersion: number; }
|
||||
const root = (sessionId: string) => `/api/governance/v1/workbench-attachments/sessions/${sessionId}`;
|
||||
export const listChatAttachments = (sessionId: string): AxiosPromise<ChatAttachment[]> => request({ url: root(sessionId), suppressErrorToast: true });
|
||||
export const readChatAttachment = (sessionId: string, id: string): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}`, suppressErrorToast: true });
|
||||
export function uploadChatAttachment(sessionId: string, id: string, file: File): AxiosPromise<ChatAttachment> {
|
||||
const data = new FormData(); data.append('file', file);
|
||||
return request({ url: `${root(sessionId)}/${id}`, method: 'post', data, headers: { repeatSubmit: false }, timeout: 120000, suppressErrorToast: true });
|
||||
}
|
||||
export const retryChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/retry`, method: 'post', data: { version }, timeout: 120000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const revokeChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/revoke`, method: 'post', data: { version }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const retainChatAttachment = (sessionId: string, id: string, version: number): AxiosPromise<ChatAttachment> => request({ url: `${root(sessionId)}/${id}/retain`, method: 'post', data: { version }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const selectChatAttachment = (sessionId: string, id: string, version: number, fragmentIds: number[]): AxiosPromise<AttachmentReference[]> => request({ url: `${root(sessionId)}/${id}/selection`, method: 'post', data: { version, fragmentIds }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Content } from './business';
|
||||
export interface Candidate { requestId: string; state: string; answer?: string; content?: Content; code?: string }
|
||||
export interface Draft { id: string; sessionId: string; type: string; title: string; version: number; pending: boolean; linked: boolean; candidates: Candidate[] }
|
||||
export interface Item { id: string; draftId: string; draftVersion: number; requestId: string; state: string; code?: string; candidateVersion?: number; adoptedVersion?: number }
|
||||
export interface Batch { id: string; sessionId: string; title: string; prompt: string; version: number; state: string; items: Item[]; updatedAt: string }
|
||||
export interface ItemView { item: Item; draft?: Draft; candidate?: Candidate; state: string; message: string }
|
||||
export interface View { batch: Batch; items: ItemView[] }
|
||||
export interface Create { id: string; title: string; prompt: string; items: { draftId: string; draftVersion: number }[] }
|
||||
const base = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(path: string, data: unknown): AxiosPromise<T> => request({ url: base + path, method: 'post', data, timeout: 85000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const candidates = (session: string): AxiosPromise<Draft[]> => request({ url: `${base}/sessions/${session}/batch-candidates` });
|
||||
export const list = (session: string): AxiosPromise<Batch[]> => request({ url: `${base}/sessions/${session}/suggestion-batches` });
|
||||
export const create = (session: string, data: Create) => write<View>(`/sessions/${session}/suggestion-batches`, data);
|
||||
export const get = (id: string): AxiosPromise<View> => request({ url: `${base}/suggestion-batches/${id}` });
|
||||
export const generate = (id: string, itemId: string, version: number) => write<View>(`/suggestion-batches/${id}/items/${itemId}/generate`, { version });
|
||||
export const adopt = (id: string, itemId: string, version: number, draftVersion: number) => write<View>(`/suggestion-batches/${id}/items/${itemId}/adopt`, { version, draftVersion });
|
||||
export const status = (id: string, version: number, stopped: boolean) => write<View>(`/suggestion-batches/${id}/${stopped ? 'stop' : 'resume'}`, { version });
|
||||
@@ -0,0 +1,35 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { EngineeringType } from '@/api/datagov/engineering-drafts/types';
|
||||
import type { ObjectReference } from './object-contexts';
|
||||
import type { RuleReference } from './rule-references';
|
||||
import type { GovernanceToolType } from '@/views/datagov/ai-workbench/governanceTools';
|
||||
import type { EngineeringBinding } from './engineering-context';
|
||||
export type BusinessType = GovernanceToolType | EngineeringType | 'MODEL_REPOSITORY' | 'MODEL_DESIGN' | 'BUSINESS_TERM' | 'DATA_ELEMENT' | 'STANDARD_SYSTEM' | 'REFERENCE_DATA' | 'DATASET' | 'METRIC' | 'SEMANTIC_MODEL' | 'API' | 'BI_DATASET' | 'BI_CHART' | 'BI_REPORT' | 'BI_SCREEN' | 'DATASET_SCHEMA' | 'DATASET_PUBLISH' | 'METRIC_SELF_SERVICE' | 'SELF_SERVICE_SHARE' | 'DATA_EXCHANGE' | 'DATA_EXCHANGE_READY';
|
||||
export type Content = Record<string, unknown>;
|
||||
export interface BusinessField { name: string; label: string; kind: 'TEXT' | 'LONG_TEXT' | 'SELECT' | 'ID' | 'NUMBER' | 'OBJECT' | 'ARRAY'; required: boolean; options: string[] }
|
||||
export interface BusinessTool { type: BusinessType; label: string; scenario: string; route: string; permission: string; effect: string; fields: BusinessField[] }
|
||||
export interface KnowledgeReference { id: string; version: number; fragmentId: number; hash: string; source?: 'SESSION_ATTACHMENT' }
|
||||
export interface KnowledgeFragment extends KnowledgeReference { title: string; kind: string; scope: string; documentHash: string; text: string }
|
||||
export interface BusinessTurn { id: string; hash: string; prompt: string; context: string; state: string; answer?: string; content?: Content; code?: string; model?: string; at: number; knowledgeRefs?: KnowledgeReference[]; objectRefs?: ObjectReference[]; ruleRefs?: RuleReference[]; usage?: import('./model-usage').ModelUsage; engineeringContext?: EngineeringBinding }
|
||||
export interface BusinessIntent { id: string; hash: string; content: Content; at: number; expiresAt: number; phase: 'READY' | 'SUBMITTED'; ruleRefs?: RuleReference[] }
|
||||
export interface BusinessReference { intentId: string; objectId: string; objectVersion?: number | null; nativeVersion?: string }
|
||||
export interface BusinessUpdateTarget { objectId: string; objectVersion: number; sourceHash: string; baselineContent: Content; editableFields: string[] }
|
||||
export interface BusinessDraft { id: string; sessionId: string; type: BusinessType; title: string; content: Content; version: number; createHash: string;
|
||||
revisions: { version: number; title: string; content: Content; at: number }[]; turns: BusinessTurn[]; intent?: BusinessIntent; reference?: BusinessReference;
|
||||
branchSource?: { draftId: string; sessionId: string; sourceVersion: number; revisionVersion: number }; updateTarget?: BusinessUpdateTarget }
|
||||
const base = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(path: string, data?: unknown, method = 'post'): AxiosPromise<T> => request({ url: base + path, method, data, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const businessTools = (): AxiosPromise<BusinessTool[]> => request({ url: base + '/tools' });
|
||||
export const businessDrafts = (sessionId: string): AxiosPromise<BusinessDraft[]> => request({ url: `${base}/sessions/${sessionId}/artifacts` });
|
||||
export const getBusinessDraft = (id: string): AxiosPromise<BusinessDraft> => request({ url: `${base}/artifacts/${id}` });
|
||||
export const reviseOriginalBusinessDraft = (draftId: string, command: { id: string; version: number; title: string }) => write<BusinessDraft>(`/artifacts/${draftId}/revise-original`, command);
|
||||
export const createBusinessDraft = (sessionId: string, id: string, type: BusinessType, title: string, content: Content) => write<BusinessDraft>(`/sessions/${sessionId}/artifacts`, { id, type, title, content });
|
||||
export const editBusinessDraft = (draft: BusinessDraft, title: string, content: Content) => write<BusinessDraft>(`/artifacts/${draft.id}`, { version: draft.version, title, content }, 'put');
|
||||
export const generateBusinessDraft = (draft: BusinessDraft, requestId: string, prompt: string, context: string, knowledgeRefs: KnowledgeReference[] = [], objectRefs: ObjectReference[] = [], engineeringContext?: EngineeringBinding) => write<BusinessDraft>(`/artifacts/${draft.id}/turns`, { version: draft.version, requestId, prompt, context, knowledgeRefs, objectRefs, engineeringContext });
|
||||
export const stopBusinessDraft = (id: string, requestId: string) => write<BusinessDraft>(`/artifacts/${id}/turns/${requestId}/stop`);
|
||||
export const prepareBusinessDraft = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent`, { version: draft.version });
|
||||
export const claimBusinessIntent = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent/claim`, { version: draft.version, intentId: draft.intent?.id });
|
||||
export const releaseBusinessIntent = (draft: BusinessDraft) => write<BusinessDraft>(`/artifacts/${draft.id}/save-intent/release`, { version: draft.version, intentId: draft.intent?.id });
|
||||
export const linkBusinessDraft = (draft: BusinessDraft, reference: BusinessReference) => write<BusinessDraft>(`/artifacts/${draft.id}/reference`, reference);
|
||||
export const searchWorkbenchKnowledge = (q: string): AxiosPromise<KnowledgeFragment[]> => request({ url: `${base}/knowledge`, method: 'get', params: { q, limit: 10 } });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { Content } from './business';
|
||||
export interface EngineeringReference { kind: string; id: string; executionOptions?: Record<string, string> }
|
||||
export interface EngineeringEditedObject { id: string; version: number }
|
||||
export interface EngineeringBatchSelection { sourceId: string; sourceObject: string; resourceId: string; spaceId: string; targetObject: string }
|
||||
export interface EngineeringLayerSelection { resourceId: string; spaceId: string; layerType: string; admissionVersion?: number | null }
|
||||
export interface EngineeringVisualSelection { sourceId: string; sourceObject: string; resourceId: string; spaceId: string; targetObject: string }
|
||||
export interface EngineeringCleaningSelection { sourceTableId: string; outputTableId: string; publications: { id: string; version: number }[] }
|
||||
export interface EngineeringTableStructureSelection { resourceId: string; spaceId: string; layerId: string | null; sourceTableFileId: string }
|
||||
export interface EngineeringSelection { type: string; references: EngineeringReference[]; ingestion: { sources: { sourceId: string; sourceVersion: number; sourceName: string; sourceDatabase: string; table: string }[]; targetType: 'DORIS' | 'HIVE'; resourceId: string; spaceId: string } | null; editedObject: EngineeringEditedObject | null; batch?: EngineeringBatchSelection | null; layer?: EngineeringLayerSelection | null; visual?: EngineeringVisualSelection | null; cleaning?: EngineeringCleaningSelection | null; tableStructure?: EngineeringTableStructureSelection | null }
|
||||
export interface EngineeringBinding { selection: EngineeringSelection; contextSha256: string }
|
||||
export interface EngineeringField { name: string; type: string; nullable: boolean | null; precision?: number | null; scale?: number | null }
|
||||
export interface EngineeringLayerDefinition { key: string; id: string; name: string; layerType: string; version: number; admissionVersion: number; granularity: string; namingPattern: string; minimumQualityScore: number; lifecycleDays: number; upstreamIds: string[]; enabled: boolean; mappingStatus: string; definitionSha256: string }
|
||||
export interface EngineeringLayerContext { resourceId: string; resourceVersion: number; accessVersion: number | null; spaceId: string; spaceVersion: number; engineType: string; catalogName: string; namespaceName: string; mappingSha256: string; layers: EngineeringLayerDefinition[] }
|
||||
export interface EngineeringContext { selection: EngineeringSelection; contextSha256: string; scopeNote: string; facts: { key: string; kind: string; id: string; version: string; sha256: string; state: string; capability: string; fields: EngineeringField[] }[]; sources: { key: string; id: string; version: number; name: string; database: string; table: string; fingerprint: string; sourceFields: EngineeringField[]; proposedTargetFields: EngineeringField[] }[]; target: { resourceId: string; resourceVersion: number; accessVersion: number; spaceId: string; spaceVersion: number; type: string; namespace: string } | null; layer?: EngineeringLayerContext | null }
|
||||
const base = '/api/integration/v1/ai/engineering-context';
|
||||
export const inspectEngineeringContext = (selection: EngineeringSelection): AxiosPromise<EngineeringContext> => request({ url: base, method: 'post', data: selection, timeout: 65000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const validateEngineeringCandidate = (binding: EngineeringBinding, baseline: Content, candidate: Content): AxiosPromise<Content> => request({ url: `${base}/validate`, method: 'post', data: { binding, baseline, candidate }, timeout: 65000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,5 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BusinessDraft } from './business';
|
||||
export interface BusinessForkCommand { id: string; version: number; revisionVersion?: number; title: string; targetSessionId: string; newSessionTitle?: string; }
|
||||
export const forkBusinessDraft = (sourceId: string, data: BusinessForkCommand): AxiosPromise<BusinessDraft> => request({ url: `/api/integration/v1/ai/workbench/artifacts/${sourceId}/fork`, method: 'post', data, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,31 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { AttachmentReference } from './attachments';
|
||||
import type { ObjectReference } from './object-contexts';
|
||||
import type { RuleReference } from './rule-references';
|
||||
import type { ModelUsage } from './model-usage';
|
||||
export interface Turn { id: string; prompt: string; state: string; answer?: string; name?: string; sql?: string; code?: string; model?: string; startedAt: number; knowledgeRefs?: AttachmentReference[]; objectRefs?: ObjectReference[]; ruleRefs?: RuleReference[]; usage?: ModelUsage; }
|
||||
export interface SaveIntent { id: string; name: string; sql: string; codeId?: string; codeVersion?: number; expiresAt: number; phase: 'READY' | 'SUBMITTED'; ruleRefs?: RuleReference[]; }
|
||||
export type Scenario = 'SQL' | 'ENGINEERING' | 'GOVERNANCE' | 'ANALYSIS';
|
||||
export type SessionStatus = 'ACTIVE' | 'ARCHIVED';
|
||||
export interface Feedback { rating: 'USEFUL' | 'NOT_USEFUL'; category: string; comment: string; at: number }
|
||||
export interface Session { id: string; title: string; name: string; sql: string; version: number; turns: Turn[]; saveIntent?: SaveIntent; codeReference?: { intentId: string; codeId: string; version: number }; scenario?: Scenario; status?: SessionStatus; feedback?: Record<string, Feedback>; }
|
||||
export interface Summary { id: string; title: string; version: number; updatedAt: string; scenario?: Scenario; status?: SessionStatus; artifactCount?: number; }
|
||||
const root = '/api/integration/v1/ai/workbench';
|
||||
const write = <T>(url: string, data?: unknown, method = 'post'): AxiosPromise<T> =>
|
||||
request({ url: root + url, method, data, timeout: 75000, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const capability = (): AxiosPromise<{ enabled: boolean; model?: string }> => request({ url: root + '/capability', suppressErrorToast: true });
|
||||
export const sessions = (pageNum: number, keyword = '', scenario?: Scenario, status: SessionStatus = 'ACTIVE'): AxiosPromise<Summary[]> => request({ url: root + '/sessions', params: { pageNum, keyword, scenario, status } });
|
||||
export const session = (id: string): AxiosPromise<Session> => request({ url: root + '/sessions/' + id });
|
||||
export const createSession = (id: string, title: string) => write<Session>('/sessions', { id, title });
|
||||
export const saveDraft = (s: Session, name: string, sql: string) => write<Session>('/sessions/' + s.id + '/draft', { version: s.version, name, sql }, 'put');
|
||||
export const generate = (s: Session, requestId: string, prompt: string, knowledgeRefs: AttachmentReference[] = [], objectRefs: ObjectReference[] = []) => write<Session>('/sessions/' + s.id + '/turns', { version: s.version, requestId, prompt, knowledgeRefs, objectRefs });
|
||||
export const stop = (id: string, requestId: string) => write<Session>('/sessions/' + id + '/turns/' + requestId + '/stop');
|
||||
export const prepare = (s: Session) => write<Session>('/sessions/' + s.id + '/save-intent', { version: s.version });
|
||||
export const claim = (s: Session) => write<Session>(`/sessions/${s.id}/save-intent/claim`, { version: s.version, intentId: s.saveIntent?.id });
|
||||
export const release = (s: Session) => write<Session>(`/sessions/${s.id}/save-intent/release`, { version: s.version, intentId: s.saveIntent?.id });
|
||||
export const link = (id: string, intentId: string, codeId: string, codeVersion: number) =>
|
||||
write<Session>('/sessions/' + id + '/code-reference', { intentId, codeId, codeVersion });
|
||||
export const settings = (s: Session, title: string, scenario: Scenario, status: SessionStatus) => write<Session>(`/sessions/${s.id}/settings`, { version: s.version, title, scenario, status }, 'put');
|
||||
export const forkSession = (sourceId: string, version: number, id: string, title: string) => write<Session>(`/sessions/${sourceId}/fork`, { version, id, title });
|
||||
export const feedback = (s: Session, turnId: string, rating: Feedback['rating'], category: string, comment: string) => write<Session>(`/sessions/${s.id}/turns/${turnId}/feedback`, { version: s.version, rating, category, comment });
|
||||
@@ -0,0 +1,11 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface MemoryEntry { id: string; category: 'TERM' | 'DISPLAY' | 'PREFERENCE'; title: string; content: string; version: number; updatedAt: string }
|
||||
export interface MemoryState { enabled: boolean; version: number; entries: MemoryEntry[] }
|
||||
export interface MemoryWrite { requestId: string; id: string; version: number; category: MemoryEntry['category']; title: string; content: string }
|
||||
const base = '/api/integration/v1/ai/workbench/memories';
|
||||
export const memoryState = (): AxiosPromise<MemoryState> => request({ url: base });
|
||||
export const memorySettings = (data: { requestId: string; version: number; enabled: boolean }): AxiosPromise<MemoryState> => request({ url: `${base}/settings`, method: 'put', data, headers: { repeatSubmit: false } });
|
||||
export const writeMemory = (data: MemoryWrite, create: boolean): AxiosPromise<MemoryState> => request({ url: create ? base : `${base}/${data.id}`, method: create ? 'post' : 'put', data, headers: { repeatSubmit: false } });
|
||||
export const deleteMemory = (id: string, data: { requestId: string; version: number }): AxiosPromise<MemoryState> => request({ url: `${base}/${id}`, method: 'delete', data, headers: { repeatSubmit: false } });
|
||||
@@ -0,0 +1,17 @@
|
||||
export interface ModelUsage {
|
||||
providerVersion?: number | string;
|
||||
requestedModel?: string;
|
||||
reportedModel?: string;
|
||||
inputTokens?: number;
|
||||
outputTokens?: number;
|
||||
totalTokens?: number;
|
||||
tokenStatus: 'PROVIDER_REPORTED' | 'PARTIAL' | 'NOT_REPORTED' | 'INVALID';
|
||||
durationMillis?: number;
|
||||
completedAt?: number;
|
||||
}
|
||||
export function measuredCount(value?: number | null) { return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0 ? value.toLocaleString('zh-CN') : '未观测'; }
|
||||
export function usageStatus(value?: ModelUsage) {
|
||||
if(!value) return '未记录模型用量';
|
||||
return ({PROVIDER_REPORTED:'提供方返回',PARTIAL:'提供方仅返回部分用量',NOT_REPORTED:'提供方未返回用量',INVALID:'提供方用量字段无效,未采信'})[value.tokenStatus] || '用量状态未知';
|
||||
}
|
||||
export function observationTime(value?: number) { return typeof value === 'number' && Number.isSafeInteger(value) && value>0 && value<=8.64e15 ? new Date(value).toLocaleString('zh-CN',{hour12:false}) : '未观测'; }
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface ObjectReference { type: string; objectId: string; version: number; hash: string; fields: string[]; reason: string }
|
||||
export interface Choice { type: string; objectId: string; fields?: string[]; reason: string }
|
||||
export interface Resolved { reference: ObjectReference; name: string; status: string; path: string; updatedAt?: string; checkedAt: string; availableFields: string[]; content: Record<string, unknown> }
|
||||
export interface Verification { reference: ObjectReference; state: 'CURRENT' | 'STALE' | 'UNAVAILABLE'; current?: Resolved }
|
||||
const base = '/api/integration/v1/ai/workbench/object-contexts';
|
||||
export const readObjectContext = (data: Choice): AxiosPromise<Resolved> => request({ url: base + '/read', method: 'post', data, suppressErrorToast: true });
|
||||
export const verifyObjectContexts = (data: ObjectReference[]): AxiosPromise<Verification[]> => request({ url: base + '/verify', method: 'post', data, suppressErrorToast: true });
|
||||
@@ -0,0 +1,9 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { BusinessType } from './business';
|
||||
|
||||
export type OriginType = BusinessType | 'SQL';
|
||||
export interface WorkbenchOrigin { sessionId: string; title: string; status: string; draftId?: string; type: OriginType; objectId: string; linkedVersion?: number | null; nativeVersion?: string; linkedAt: string }
|
||||
export function workbenchOrigins(type: OriginType, objectId: string): AxiosPromise<WorkbenchOrigin[]> {
|
||||
return request({ url: '/api/integration/v1/ai/workbench/origins', params: { type, objectId } });
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { ModelUsage } from './model-usage';
|
||||
|
||||
export interface Question { id: string; fieldPath: string; question: string; options: string[]; required: boolean; answer: string; }
|
||||
export interface Step { id: string; title: string; draftId: string; draftVersion: number; dependsOn: string[]; inputSummary: string; impactSummary: string; budgetTokens: number; }
|
||||
export interface Definition { title: string; intent: string; questions: Question[]; steps: Step[]; maxTokens: number; }
|
||||
export interface Reference { objectId: string; objectVersion?: number | null; nativeVersion?: string; }
|
||||
export interface Artifact { draftId: string; sessionId: string; version: number; type: string; title: string; requiredPermission: string; pending: boolean; reference?: Reference; }
|
||||
export interface Dependency { draftId: string; draftVersion: number; type: string; reference?: Reference; }
|
||||
export interface Confirmation { id: string; planId: string; planVersion: number; planHash: string; stepId: string; draftId: string; draftVersion: number; type: string; phase: 'READY' | 'SUBMITTED' | 'VOID'; expiresAt: string; dependencies: Dependency[]; }
|
||||
export interface Generation { id: string; inputHash: string; state: 'PENDING' | 'DRAFT' | 'FAILED' | 'DISABLED' | 'STALE' | 'STOPPED' | 'UNKNOWN'; prompt: string; explanation?: string; candidate?: Definition; model?: string; code?: string; startedAt: string; usage?: ModelUsage; }
|
||||
export interface Plan { id: string; sessionId: string; version: number; status: 'DRAFT' | 'STOPPED'; hash: string; definition: Definition; revisions: { version: number; hash: string; definition: Definition; at: string }[]; confirmations: Confirmation[]; generations: Generation[]; updatedAt: string; }
|
||||
export type StepState = 'REFERENCE_RECORDED' | 'OUTCOME_PENDING' | 'DRAFT_STALE' | 'STOPPED' | 'WAITING_INPUT' | 'WAITING_DEPENDENCY' | 'READY';
|
||||
export interface View { plan: Plan; steps: { step: Step; state: StepState; message: string; artifact: Artifact }[]; unanswered: string[]; }
|
||||
export interface ExecuteStep { planId: string; stepId: string; draftId: string; draftVersion: number; confirmationId: string; dependencies: Dependency[]; }
|
||||
export interface Pending { key: string; path: string; method: 'post' | 'put'; data: unknown; kind: 'VIEW' | 'CONFIRMATION'; }
|
||||
const root = '/api/integration/v1/ai/workbench';
|
||||
export const list = (sessionId: string): AxiosPromise<View[]> => request({ url: `${root}/sessions/${sessionId}/plans` });
|
||||
export const artifacts = (sessionId: string): AxiosPromise<Artifact[]> => request({ url: `${root}/sessions/${sessionId}/plan-artifacts` });
|
||||
export const get = (id: string): AxiosPromise<View> => request({ url: `${root}/plans/${id}`, suppressErrorToast: true });
|
||||
export const write = (command: Pending): AxiosPromise<View | Confirmation> => request({ url: root + command.path, method: command.method, data: command.data, headers: { 'Idempotency-Key': command.key, repeatSubmit: false }, suppressErrorToast: true });
|
||||
export const claim = (command: ExecuteStep): AxiosPromise<Confirmation> => request({ url: `${root}/plans/${command.planId}/steps/${command.stepId}/claim`, method: 'post', data: { confirmationId: command.confirmationId, draftId: command.draftId, draftVersion: command.draftVersion }, headers: { repeatSubmit: false }, suppressErrorToast: true });
|
||||
@@ -0,0 +1,8 @@
|
||||
import type { Fragment } from '@/api/datagov/workbench-knowledge';
|
||||
|
||||
export interface RuleReference { id: string; version: number; hash: string }
|
||||
|
||||
export function matchesRuleReference(reference: RuleReference, fragment: Fragment): boolean {
|
||||
return fragment.id === reference.id && fragment.version === reference.version && fragment.kind === 'RULE'
|
||||
&& fragment.documentHash === reference.hash && fragment.fragmentId === 1;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AlertSource, AlertMetric, AlertOperator, AlertSeverity } from './types';
|
||||
|
||||
export type EvidenceId = string | number;
|
||||
export interface OccurrenceReference { eventId: string; occurrenceId: string; eventVersion: number; payloadSha256?: string }
|
||||
export interface FrozenAlertRule {
|
||||
ruleId: string; version: number; source: AlertSource; metric: AlertMetric; operator: AlertOperator;
|
||||
threshold: string; severity: AlertSeverity; observationMinutes: number; triggerCount: number;
|
||||
recoveryCount: number; aggregateMinutes: number; silenceMinutes: number; enabled: boolean;
|
||||
}
|
||||
export interface FrozenAlertRun {
|
||||
key: string; runId: string; source: AlertSource; ownerObjectId: string; orgId: string;
|
||||
projectRef?: string; dataDomainCode?: string; status: string; startedAt?: string; completedAt?: string;
|
||||
createdAt: string; updatedAt?: string; windowTime: string; timeBasis: string; metricRoles: string[];
|
||||
}
|
||||
export interface OccurrencePayload {
|
||||
formatVersion: number; state: 'BOUND' | 'REFERENCE_LIMIT' | 'OWNER_CHANGED'; rule: FrozenAlertRule;
|
||||
orgId: string; ownerObjectId: string; projectRef?: string; dataDomainCode?: string;
|
||||
appliedFrom: string; appliedTo: string; zoneId: string; timeBasis: string; sampleMinCreatedAt: string;
|
||||
ownerRowCount: number; metricSampleCount: number; unknownStatusCount: number; metricValue: string;
|
||||
breached: boolean; originalEvidenceSha256: string; streakEvidenceState: 'UNBOUND'; runs: FrozenAlertRun[];
|
||||
}
|
||||
export interface OccurrenceEvidence {
|
||||
reference: OccurrenceReference; state: 'BOUND' | 'REFERENCE_LIMIT' | 'OWNER_CHANGED' | 'LEGACY_UNBOUND';
|
||||
source: AlertSource; eventStatus: string; payload?: OccurrencePayload; scopeNote: string;
|
||||
}
|
||||
export interface OccurrenceSelection { references: OccurrenceReference[] }
|
||||
export interface OccurrenceFinding { occurrenceKeys: string[]; explanation: string; checks: string[] }
|
||||
export interface OccurrenceExplanation { requestId: string; state: string; fingerprint?: string; findings: OccurrenceFinding[]; code?: string }
|
||||
|
||||
export const readOccurrenceEvidence = (eventId: string, occurrenceId: string): AxiosPromise<OccurrenceEvidence> =>
|
||||
request({ url: `/api/dataops/v1/alert-events/${eventId}/occurrences/${occurrenceId}/evidence`, method: 'get' });
|
||||
export const explainOccurrenceEvidence = (requestId: string, selection: OccurrenceSelection, prompt: string): AxiosPromise<OccurrenceExplanation> =>
|
||||
request({ url: '/api/integration/v1/ai/alert-occurrence-evidence', method: 'post', data: { requestId, selection, prompt, consent: true } });
|
||||
@@ -0,0 +1,19 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
|
||||
export interface DeliveryChannel { id: string; label: string; type: 'SMTP' | 'WEBHOOK'; targets: { key: string; label: string }[] }
|
||||
export interface DeliveryReceipt {
|
||||
requestKey: string; eventId: string | number; channelId: string; channelLabel: string;
|
||||
targetKey: string; targetLabel: string; state: 'ACCEPTED' | 'UNKNOWN' | 'CANCELLED'; safeCode: string;
|
||||
startedAt: string; completedAt: string | null;
|
||||
}
|
||||
export interface ExternalDeliveryRequest { channelId: string; targetKey: string; eventVersion: number }
|
||||
const base = (id: string | number) => `/api/dataops/v1/alert-events/${encodeURIComponent(String(id))}/external-deliveries`;
|
||||
export const deliveryChannels = (id: string | number): AxiosPromise<DeliveryChannel[]> => request({ url: `${base(id)}/channels` });
|
||||
export const deliveryHistory = (id: string | number): AxiosPromise<DeliveryReceipt[]> => request({ url: base(id) });
|
||||
export const deliveryReceipt = (id: string | number, key: string): AxiosPromise<DeliveryReceipt | null> =>
|
||||
request({ url: `${base(id)}/${encodeURIComponent(key)}` });
|
||||
export const cancelUnsubmittedDelivery = (id: string | number, key: string): AxiosPromise<DeliveryReceipt> =>
|
||||
request({ url: `${base(id)}/${encodeURIComponent(key)}/cancellation`, method: 'post' });
|
||||
export const sendExternalAlert = (id: string | number, data: ExternalDeliveryRequest, key: string): AxiosPromise<DeliveryReceipt> =>
|
||||
request({ url: base(id), method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false } });
|
||||
@@ -0,0 +1,88 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type {
|
||||
AssignRequest,
|
||||
EventDetailView,
|
||||
EventQuery,
|
||||
EventSummary,
|
||||
IdentityCandidate,
|
||||
NotifyRequest,
|
||||
PageView,
|
||||
PostmortemRequest,
|
||||
ProcessRequest,
|
||||
RuleQuery,
|
||||
RuleSaveRequest,
|
||||
RuleView,
|
||||
VerifyRequest,
|
||||
WriteView
|
||||
} from './types';
|
||||
|
||||
const baseUrl = '/api/dataops/v1/alert-events';
|
||||
const writeHeaders = (idempotencyKey: string) => ({
|
||||
'Idempotency-Key': idempotencyKey,
|
||||
repeatSubmit: false
|
||||
});
|
||||
|
||||
export const listAlertEvents = (params: EventQuery): AxiosPromise<PageView<EventSummary>> =>
|
||||
request({ url: baseUrl, method: 'get', params });
|
||||
|
||||
export const getAlertEvent = (eventId: number | string): AxiosPromise<EventDetailView> =>
|
||||
request({ url: `${baseUrl}/${eventId}`, method: 'get' });
|
||||
|
||||
export const listAlertRules = (params: RuleQuery): AxiosPromise<PageView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules`, method: 'get', params });
|
||||
|
||||
export const listAlertIdentityCandidates = (keyword: string, limit = 20): AxiosPromise<IdentityCandidate[]> =>
|
||||
request({ url: `${baseUrl}/identity-candidates`, method: 'get', params: { keyword, limit } });
|
||||
|
||||
export const createAlertRule = (data: RuleSaveRequest, idempotencyKey: string): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules`, method: 'post', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAlertRule = (
|
||||
ruleId: number,
|
||||
data: RuleSaveRequest,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({ url: `${baseUrl}/rules/${ruleId}`, method: 'put', data, headers: writeHeaders(idempotencyKey) });
|
||||
|
||||
export const updateAlertRuleStatus = (
|
||||
ruleId: number,
|
||||
enabled: boolean,
|
||||
version: number,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<RuleView>> =>
|
||||
request({
|
||||
url: `${baseUrl}/rules/${ruleId}/status`,
|
||||
method: 'put',
|
||||
data: { enabled, version },
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
const eventWrite = <T>(
|
||||
eventId: number,
|
||||
action: string,
|
||||
method: 'post' | 'put',
|
||||
data: T,
|
||||
idempotencyKey: string
|
||||
): AxiosPromise<WriteView<EventDetailView>> =>
|
||||
request({
|
||||
url: `${baseUrl}/${eventId}/${action}`,
|
||||
method,
|
||||
data,
|
||||
headers: writeHeaders(idempotencyKey)
|
||||
});
|
||||
|
||||
export const notifyAlertEvent = (eventId: number, data: NotifyRequest, key: string) =>
|
||||
eventWrite(eventId, 'notifications', 'post', data, key);
|
||||
|
||||
export const assignAlertEvent = (eventId: number, data: AssignRequest, key: string) =>
|
||||
eventWrite(eventId, 'assignment', 'post', data, key);
|
||||
|
||||
export const processAlertEvent = (eventId: number, data: ProcessRequest, key: string) =>
|
||||
eventWrite(eventId, 'processing', 'post', data, key);
|
||||
|
||||
export const verifyAlertEvent = (eventId: number, data: VerifyRequest, key: string) =>
|
||||
eventWrite(eventId, 'verification', 'post', data, key);
|
||||
|
||||
export const saveAlertPostmortem = (eventId: number, data: PostmortemRequest, key: string) =>
|
||||
eventWrite(eventId, 'postmortem', 'put', data, key);
|
||||
@@ -0,0 +1,206 @@
|
||||
export type AlertSource = 'SCHEDULING' | 'BATCH_INGESTION' | 'FILE_INGESTION';
|
||||
export type AlertMetric = 'FAILED_COUNT' | 'FAILURE_RATE_PERCENT' | 'BACKLOG_COUNT' | 'MAX_DURATION_MS';
|
||||
export type AlertOperator = 'GT' | 'GTE' | 'LT' | 'LTE';
|
||||
export type AlertSeverity = 'CRITICAL' | 'HIGH' | 'MEDIUM' | 'LOW';
|
||||
export type AlertEventStatus = 'OPEN' | 'ASSIGNED' | 'PROCESSING' | 'RESOLVED' | 'VERIFIED' | 'CLOSED';
|
||||
export type AlertNotificationType = 'OPEN' | 'MANUAL' | 'RECOVERY' | 'ESCALATION';
|
||||
export type ProcessAction = 'START_PROCESSING' | 'RESOLVE';
|
||||
export type VerifyAction = 'VERIFY' | 'CLOSE';
|
||||
|
||||
export interface PageView<T> {
|
||||
rows: T[];
|
||||
total: number;
|
||||
}
|
||||
|
||||
export interface WriteView<T> {
|
||||
requestId: string;
|
||||
result: T;
|
||||
}
|
||||
|
||||
export interface RuleView {
|
||||
ruleId: number;
|
||||
orgId: number;
|
||||
name: string;
|
||||
source: AlertSource;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
severity: AlertSeverity;
|
||||
observationMinutes: number;
|
||||
triggerCount: number;
|
||||
recoveryCount: number;
|
||||
aggregateMinutes: number;
|
||||
silenceMinutes: number;
|
||||
dataDomainCode?: string;
|
||||
primaryUserId: number;
|
||||
primaryUserName: string;
|
||||
escalationUserId?: number;
|
||||
escalationUserName?: string;
|
||||
escalationWaitMinutes: number;
|
||||
enabled: boolean;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface RuleSaveRequest {
|
||||
name: string;
|
||||
source: AlertSource;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
severity: AlertSeverity;
|
||||
observationMinutes: number;
|
||||
triggerCount: number;
|
||||
recoveryCount: number;
|
||||
aggregateMinutes: number;
|
||||
silenceMinutes: number;
|
||||
dataDomainCode?: string;
|
||||
primaryUserId?: number;
|
||||
escalationUserId?: number;
|
||||
escalationWaitMinutes: number;
|
||||
enabled: boolean;
|
||||
version?: number;
|
||||
}
|
||||
|
||||
export interface RuleQuery {
|
||||
keyword?: string;
|
||||
source?: AlertSource;
|
||||
enabled?: boolean;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface EventSummary {
|
||||
eventId: number;
|
||||
ruleId: number;
|
||||
ruleName: string;
|
||||
source: AlertSource;
|
||||
ownerObjectId: number;
|
||||
ownerObjectName: string;
|
||||
dataDomainCode?: string;
|
||||
metric: AlertMetric;
|
||||
operator: AlertOperator;
|
||||
threshold: number;
|
||||
currentValue: number;
|
||||
severity: AlertSeverity;
|
||||
status: AlertEventStatus;
|
||||
occurrenceCount: number;
|
||||
primaryUserId: number;
|
||||
primaryUserName: string;
|
||||
assigneeUserId?: number;
|
||||
assigneeUserName?: string;
|
||||
openedAt: string;
|
||||
lastOccurredAt: string;
|
||||
resolvedAt?: string;
|
||||
verifiedAt?: string;
|
||||
closedAt?: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface EventQuery {
|
||||
keyword?: string;
|
||||
source?: AlertSource;
|
||||
severity?: AlertSeverity;
|
||||
status?: AlertEventStatus;
|
||||
dataDomainCode?: string;
|
||||
pageNum: number;
|
||||
pageSize: number;
|
||||
}
|
||||
|
||||
export interface OccurrenceView {
|
||||
occurrenceId: number;
|
||||
metricValue: number;
|
||||
sampleCount: number;
|
||||
evidenceSha256: string;
|
||||
observedFrom: string;
|
||||
observedTo: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface NotificationView {
|
||||
notificationId: number;
|
||||
type: AlertNotificationType;
|
||||
status: 'RECORDED';
|
||||
recipientUserId: number;
|
||||
recipientUserName: string;
|
||||
contentSummary: string;
|
||||
recordedAt: string;
|
||||
mailboxState?: 'RECORDED' | 'SUBMITTING' | 'STORED' | 'UNKNOWN';
|
||||
mailboxMessageId?: string | number;
|
||||
mailboxAttemptedAt?: string;
|
||||
}
|
||||
|
||||
export interface TimelineView {
|
||||
timelineId: number;
|
||||
action: string;
|
||||
fromStatus?: AlertEventStatus;
|
||||
toStatus: AlertEventStatus;
|
||||
actorUserId?: number;
|
||||
actorName: string;
|
||||
requestId: string;
|
||||
reasonSummary: string;
|
||||
createdAt: string;
|
||||
}
|
||||
|
||||
export interface PostmortemView {
|
||||
postmortemId: number;
|
||||
summary: string;
|
||||
rootCause: string;
|
||||
impact: string;
|
||||
correctiveActions: string;
|
||||
evidenceRefs: string[];
|
||||
authorUserId: number;
|
||||
authorName: string;
|
||||
version: number;
|
||||
createdAt: string;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
export interface EventDetailView {
|
||||
summary: EventSummary;
|
||||
occurrences: OccurrenceView[];
|
||||
notifications: NotificationView[];
|
||||
timeline: TimelineView[];
|
||||
postmortem?: PostmortemView;
|
||||
}
|
||||
|
||||
export interface IdentityCandidate {
|
||||
userId: number;
|
||||
userName: string;
|
||||
nickName: string;
|
||||
}
|
||||
|
||||
export interface NotifyRequest {
|
||||
recipientUserId?: number;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface AssignRequest {
|
||||
assigneeUserId?: number;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface ProcessRequest {
|
||||
action: ProcessAction;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface VerifyRequest {
|
||||
action: VerifyAction;
|
||||
reason: string;
|
||||
version: number;
|
||||
}
|
||||
|
||||
export interface PostmortemRequest {
|
||||
summary: string;
|
||||
rootCause: string;
|
||||
impact: string;
|
||||
correctiveActions: string;
|
||||
evidenceRefs: string[];
|
||||
eventVersion: number;
|
||||
postmortemVersion?: number;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
export interface AnomalySeriesSelection { detectionId: string; version: number; snapshotIds: string[]; windowStart: string; windowEnd: string }
|
||||
export interface AnomalyProfileChoice { snapshotId: string; observedAt: string; sourceLabel: string }
|
||||
export interface AnomalyThresholdOption { key: string; lower: string | null; upper: string | null; sampleCount: number; fallbackReason: string | null }
|
||||
export interface AnomalySeriesContext {
|
||||
selection: AnomalySeriesSelection; fingerprint: string; sourceLabel: string; observationScope: string;
|
||||
points: { key: string; observedAt: string; rowCount: string }[];
|
||||
evaluation: { verdict: string; reasonCode: string; algorithm: string; algorithmVersion: string; lower: string | null; upper: string | null };
|
||||
thresholdOptions: AnomalyThresholdOption[];
|
||||
}
|
||||
export interface AnomalySeriesCandidate { hypotheses: { text: string; evidenceKeys: string[] }[]; thresholdOptionId: string; reviewNotes: string }
|
||||
export interface AnomalySeriesResult { requestId: string; state: string; fingerprint: string; candidate?: AnomalySeriesCandidate; code?: string }
|
||||
export const anomalyProfileChoices = (id: string, version: number): AxiosPromise<AnomalyProfileChoice[]> => request({ url: `/api/governance/v1/anomaly-detections/assist/${id}/profiles`, params: { version } });
|
||||
export const anomalySeriesContext = (selection: AnomalySeriesSelection): AxiosPromise<AnomalySeriesContext> => request({ url: '/api/governance/v1/anomaly-detections/assist/context', method: 'post', data: selection });
|
||||
export const anomalySeriesCandidate = (data: { requestId: string; selection: AnomalySeriesSelection; fingerprint: string; prompt: string }): AxiosPromise<AnomalySeriesResult> => request({ url: '/api/integration/v1/ai/anomaly-detection/candidates', method: 'post', data, timeout: 120000 });
|
||||
export interface AnomalyStoredEvaluation { resultId: string; detectionId: string; configVersion: number; targetLogicalId: string; targetFqn: string; name: string; verdict: string; observedValue: number; observedAt: string; evaluatedAt: string; evidenceSha: string; samplingStartedAt: string }
|
||||
export const saveAnomalySeriesEvaluation = (data: { selection: AnomalySeriesSelection; fingerprint: string }, key: string): AxiosPromise<AnomalyStoredEvaluation> => request({ url: '/api/governance/v1/anomaly-detections/assist/evaluations', method: 'post', data, headers: { 'Idempotency-Key': key, repeatSubmit: false } });
|
||||
export const readAnomalySeriesEvaluation = (key: string): AxiosPromise<AnomalyStoredEvaluation | null> => request({ url: `/api/governance/v1/anomaly-detections/assist/evaluations/requests/${encodeURIComponent(key)}`, method: 'get' });
|
||||
@@ -0,0 +1,4 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
export interface TargetCandidate { id: string; label: string }
|
||||
export const targetCandidates = (): AxiosPromise<TargetCandidate[]> => request({url:'/api/governance/v1/anomaly-detections/candidates/targets',method:'get'});
|
||||
@@ -0,0 +1,15 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types'; import request from '@/utils/request';
|
||||
interface PageResult<T> { rows: T[]; total: number }
|
||||
import type { BaselineVO, DetectionCommand, DetectionQuery, DetectionStatus, DetectionVO, ObservationCommand, ObservationVO, ResultVO } from './types';
|
||||
const base = '/api/governance/v1/anomaly-detections'; const headers = (key: string) => ({ 'Idempotency-Key': key, repeatSubmit: false });
|
||||
export const pageDetections = (params: DetectionQuery): AxiosPromise<PageResult<DetectionVO>> => request({ url: base, method: 'get', params });
|
||||
export const getDetection = (id: number | string): AxiosPromise<DetectionVO> => request({ url: `${base}/${id}`, method: 'get' });
|
||||
export const createDetection = (data: DetectionCommand, key: string) => request({ url: base, method: 'post', data, headers: headers(key) });
|
||||
export const updateDetection = (id: number, data: DetectionCommand, key: string) => request({ url: `${base}/${id}`, method: 'put', data, headers: headers(key) });
|
||||
export const changeDetectionStatus = (id: number, data: { targetStatus: DetectionStatus; reason: string; version: number }, key: string) => request({ url: `${base}/${id}/status`, method: 'post', data, headers: headers(key) });
|
||||
export const pageObservations = (id: number, params: PageQuery): AxiosPromise<PageResult<ObservationVO>> => request({ url: `${base}/${id}/observations`, method: 'get', params });
|
||||
export const createObservation = (id: number, data: ObservationCommand, key: string) => request({ url: `${base}/${id}/observations`, method: 'post', data, headers: headers(key) });
|
||||
export const evaluateDetection = (id: number, data: { observationId: number; version: number }, key: string) => request({ url: `${base}/${id}/evaluate`, method: 'post', data, headers: headers(key) });
|
||||
export const pageDetectionResults = (id: number, params: PageQuery): AxiosPromise<PageResult<ResultVO>> => request({ url: `${base}/${id}/results`, method: 'get', params });
|
||||
export const createBaseline = (id: number, data: { sampleCount?: number; version: number }, key: string) => request({ url: `${base}/${id}/baselines`, method: 'post', data, headers: headers(key) });
|
||||
export const pageBaselines = (id: number, params: PageQuery): AxiosPromise<PageResult<BaselineVO>> => request({ url: `${base}/${id}/baselines`, method: 'get', params });
|
||||
@@ -0,0 +1,6 @@
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import request from '@/utils/request';
|
||||
import type { AnomalyProfileChoice } from './assist';
|
||||
export interface AnomalyProfileTarget { snapshotId: string; targetLogicalId: string; targetFqn: string; fingerprint: string }
|
||||
export const anomalyTargetProfiles = (): AxiosPromise<AnomalyProfileChoice[]> => request({ url: '/api/governance/v1/anomaly-detections/assist/target-profiles' });
|
||||
export const anomalyProfileTarget = (snapshotId: string): AxiosPromise<AnomalyProfileTarget> => request({ url: '/api/governance/v1/anomaly-detections/assist/target', method: 'post', data: { snapshotId } });
|
||||
@@ -0,0 +1,13 @@
|
||||
export type DetectionType = 'SCHEMA' | 'VOLUME' | 'DISTRIBUTION' | 'FRESHNESS';
|
||||
export type DetectionStatus = 'ENABLED' | 'DISABLED';
|
||||
export type Verdict = 'NORMAL' | 'ANOMALY' | 'UNKNOWN';
|
||||
export type DetectionSeverity = 'INFO' | 'LOW' | 'MEDIUM' | 'HIGH' | 'CRITICAL';
|
||||
export type ObservationSource = 'OPENMETADATA' | 'DORIS' | 'HIVE' | 'DOLPHINSCHEDULER' | 'DATAGOV';
|
||||
export interface DetectionProfileTarget { snapshotId: string; fingerprint: string }
|
||||
export interface DetectionQuery extends PageQuery { keyword?: string; type?: DetectionType; status?: DetectionStatus }
|
||||
export interface DetectionVO { detectionId: number; detectionCode: string; detectionName: string; detectionType: DetectionType; targetLogicalId: string; targetFqn: string; expectedSchemaFingerprint?: string; severity: DetectionSeverity; thresholdStrategy: 'FIXED' | 'BASELINE'; fixedLower?: number; fixedUpper?: number; minimumSamples: number; historyLimit: number; deviationMultiplier: number; allowedSources: ObservationSource[]; status: DetectionStatus; version: number; createTime?: string; updateTime?: string }
|
||||
export interface DetectionCommand { detectionCode?: string; detectionName: string; detectionType?: DetectionType; targetLogicalId: string; targetFqn: string; expectedSchemaFingerprint?: string; severity: DetectionSeverity; thresholdStrategy: 'FIXED' | 'BASELINE'; fixedLower?: number; fixedUpper?: number; minimumSamples: number; historyLimit: number; deviationMultiplier: number; allowedSources: ObservationSource[]; version?: number; profileTarget?: DetectionProfileTarget }
|
||||
export interface ObservationCommand { sourceType: ObservationSource; externalRef: string; observedAt: string; payloadSha: string; reliable: boolean; unreliableReason?: string; schemaFingerprint?: string; rowCount?: number; emptyBatch?: boolean; interrupted?: boolean; mean?: number; standardDeviation?: number; minimum?: number; maximum?: number; nullRatio?: number; dataUpdatedAt?: string; arrivedAt?: string; processingDelaySeconds?: number; version: number }
|
||||
export interface ObservationVO extends ObservationCommand { observationId: number; detectionId: number; createTime?: string }
|
||||
export interface ResultVO { resultId: number; detectionId: number; observationId: number; verdict: Verdict; reasonCode: string; reasonSummary?: string; algorithm: string; algorithmVersion: string; sampleCount?: number; lowerBound?: number; upperBound?: number; fallbackReason?: string; evaluatedAt?: string }
|
||||
export interface BaselineVO { baselineId: number; detectionId: number; algorithm: string; algorithmVersion: string; sampleCount: number; lowerBound?: number; upperBound?: number; fallbackReason?: string; createTime?: string }
|
||||
@@ -0,0 +1,14 @@
|
||||
import request from '@/utils/request';
|
||||
import type { AxiosPromise } from '@/utils/api-types';
|
||||
import type { ModelCommand, RequestParameter, ValueType } from './types';
|
||||
export type ApiModelDraft = Omit<ModelCommand, 'version' | 'assistBinding'>;
|
||||
export interface ApiModelSelection { apiId: string; version: number }
|
||||
export interface ApiModelContext { selection: ApiModelSelection; fingerprint: string; method: string; relativePath: string; fields: { name: string; valueType: ValueType; nullable: boolean }[]; pathParameters: RequestParameter[] }
|
||||
export interface ApiModelValidation { selection: ApiModelSelection; fingerprint: string; draft: ApiModelDraft }
|
||||
export interface ApiModelCandidate { requestId: string; state: string; fingerprint: string; candidate: ApiModelDraft | null; code: string }
|
||||
export const getApiModelContext = (data: ApiModelSelection): AxiosPromise<ApiModelContext> => request({ url: '/api/dataproduct/v1/api-model-assist/context', method: 'post', data });
|
||||
export const validateApiModel = (data: ApiModelValidation): AxiosPromise<ApiModelDraft> => request({ url: '/api/dataproduct/v1/api-model-assist/validate', method: 'post', data });
|
||||
export const generateApiModel = (data: ApiModelSelection & { requestId: string; fingerprint: string; fields: string[]; prompt: string }): AxiosPromise<ApiModelCandidate> => {
|
||||
const { apiId, version, ...rest } = data;
|
||||
return request({ url: '/api/integration/v1/ai/api-model/candidates', method: 'post', data: { ...rest, selection: { apiId, version } } });
|
||||
};
|
||||
某些文件未显示,因为此 diff 中更改的文件太多 显示更多
在新工单中引用
屏蔽一个用户