@agile-team/wl-skills-kit 1.2.1 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +137 -0
- package/README.md +180 -357
- package/bin/wl-skills.js +206 -44
- package/files/.github/copilot-instructions.md +104 -43
- package/files/.github/guides/README.md +13 -0
- package/files/.github/guides/architecture.md +555 -0
- package/files/.github/guides/usage.md +166 -0
- package/files/.github/reports/README.md +65 -0
- package/files/.github/reports/SYS_DICT_INFO.md +19 -0
- package/files/.github/reports/SYS_PERMISSION_INFO.md +20 -0
- package/files/.github/reports//347/273/204/344/273/266/346/217/220/345/217/226/345/273/272/350/256/256.md +33 -0
- package/files/.github/reports//350/247/204/350/214/203/345/256/241/346/237/245/346/212/245/345/221/212.md +44 -0
- package/files/.github/skills/_compat/README.md +108 -0
- package/files/.github/skills/_compat/editors.json +61 -0
- package/files/.github/skills/_compat/headers/agents.txt +8 -0
- package/files/.github/skills/_compat/headers/claude-code.txt +7 -0
- package/files/.github/skills/_compat/headers/cline.txt +7 -0
- package/files/.github/skills/_compat/headers/cursor-mdc.txt +16 -0
- package/files/.github/skills/_compat/headers/cursor-rules.txt +7 -0
- package/files/.github/skills/_compat/headers/github-copilot.txt +1 -0
- package/files/.github/skills/_compat/headers/kiro.txt +10 -0
- package/files/.github/skills/_compat/headers/trae.txt +11 -0
- package/files/.github/skills/_compat/headers/windsurf.txt +7 -0
- package/files/.github/skills/_registry.md +81 -0
- package/files/.github/skills/{api-contract → core/api-contract}/SKILL.md +126 -29
- package/files/.github/skills/core/api-contract/USAGE.md +110 -0
- package/files/.github/skills/core/convention-audit/SKILL.md +189 -0
- package/files/.github/skills/core/convention-audit/USAGE.md +99 -0
- package/files/.github/skills/{page-codegen → core/page-codegen}/SKILL.md +64 -21
- package/files/.github/skills/core/page-codegen/USAGE.md +102 -0
- package/files/.github/skills/core/page-codegen/templates/_index.md +46 -0
- package/files/.github/skills/core/page-codegen/templates/domains/_CONTRIBUTING.md +107 -0
- package/files/.github/skills/{page-codegen → core/page-codegen/templates/domains/produce}/TPL-OPERATION-STATION.md +442 -442
- package/files/.github/skills/core/page-codegen/templates/domains/sale/README.md +26 -0
- package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-DETAIL-TABS.md +94 -39
- package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-DRIVEN.md +124 -124
- package/files/.github/skills/core/prototype-scan/USAGE.md +95 -0
- package/files/.github/skills/core/template-extract/SKILL.md +139 -0
- package/files/.github/skills/core/template-extract/USAGE.md +93 -0
- package/files/.github/skills/domain/README.md +51 -0
- package/files/.github/skills/ops/code-fix/SKILL.draft.md +108 -0
- package/files/.github/skills/sync/dict-sync/SKILL.draft.md +100 -0
- package/files/.github/skills/{menu-sync → sync/menu-sync}/SKILL.md +258 -258
- package/files/.github/skills/sync/menu-sync/USAGE.md +104 -0
- package/files/.github/skills/{menu-sync → sync/menu-sync}/env/guide.md +83 -83
- package/files/.github/skills/sync/permission-sync/SKILL.draft.md +91 -0
- package/files/.github/standards/01-toolchain.md +57 -0
- package/files/.github/standards/02-code-structure.md +111 -0
- package/files/.github/standards/03-comments.md +53 -0
- package/files/.github/standards/04-coding-basics.md +33 -0
- package/files/.github/standards/05-logging.md +38 -0
- package/files/.github/standards/06-security.md +44 -0
- package/files/.github/standards/07-config.md +52 -0
- package/files/.github/standards/08-git.md +60 -0
- package/files/.github/standards/09-typescript.md +71 -0
- package/files/.github/standards/10-pinia.md +57 -0
- package/files/.github/standards/11-form-validation.md +81 -0
- package/files/.github/standards/12-base-table.md +116 -0
- package/files/.github/standards/13-platform-components.md +123 -0
- package/files/.github/standards/index.md +89 -0
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/data.ts +196 -196
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.scss +150 -150
- package/files/demo/produce/aiflow/mmwr-customer-apply-change-history/index.vue +79 -79
- package/files/docs/jh-date-range.md +257 -257
- package/files/docs/jh-date.md +222 -222
- package/files/docs/jh-dept-picker.md +190 -190
- package/files/docs/jh-drag-row.md +590 -590
- package/files/docs/jh-file-upload.md +216 -216
- package/files/docs/jh-picker.md +218 -218
- package/files/docs/jh-select.md +148 -148
- package/files/docs/jh-text.md +248 -248
- package/files/docs/jh-user-picker.md +197 -197
- package/package.json +6 -2
- package/files/.github/docs/menu-sync-design.md +0 -264
- package/files/.github/docs/use-skill.md +0 -382
- package/files/.github/docs/wl-skills-kit.md +0 -266
- package/files/.github/skills/convention-extract/SKILL.md +0 -236
- /package/files/.github/{docs → reports}/SYS_MENU_INFO.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-CHANGE-HISTORY.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-FORM-ROUTE.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-LIST.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-MASTER-DETAIL.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-RECORD-FORM.md +0 -0
- /package/files/.github/skills/{page-codegen → core/page-codegen/templates/universal}/TPL-TREE-LIST.md +0 -0
- /package/files/.github/skills/{prototype-scan → core/prototype-scan}/SKILL.md +0 -0
- /package/files/.github/skills/{menu-sync → sync/menu-sync}/env/env.local.json +0 -0
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
# 08 — Git 分支 & 提交规范
|
|
2
|
+
|
|
3
|
+
> **强制度**:🔴 必遵。
|
|
4
|
+
> 本项目强制使用 `@robot-admin/git-standards`(commitlint + cz-customizable + husky)。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 分支命名
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
feat/xxx 新功能
|
|
12
|
+
fix/xxx Bug 修复
|
|
13
|
+
refactor/xxx 重构
|
|
14
|
+
docs/xxx 文档更新
|
|
15
|
+
chore/xxx 构建/工具变更
|
|
16
|
+
perf/xxx 性能优化
|
|
17
|
+
test/xxx 测试相关
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## 提交方式(强制)
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
git add .
|
|
24
|
+
git cz # 交互式选择 type + scope + 描述
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
❌ **禁止**:`git commit -m "xxx"` 直接提交(绕过规范校验)
|
|
28
|
+
|
|
29
|
+
## 提交类型(type)枚举
|
|
30
|
+
|
|
31
|
+
`feat` / `fix` / `perf` / `docs` / `style` / `refactor` / `test` / `chore` / `revert` / `build` / `deps` / `wip`
|
|
32
|
+
|
|
33
|
+
## scope 强制要求
|
|
34
|
+
|
|
35
|
+
提交时必须填写影响范围,格式:`type(scope): 中文描述`
|
|
36
|
+
|
|
37
|
+
```
|
|
38
|
+
feat(mmwr-customer): 新增客户档案页面
|
|
39
|
+
fix(domestic-trade): 修复订单状态切换闪烁
|
|
40
|
+
refactor(c_formModal): 重构表单回填逻辑
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## husky 钩子未生效时
|
|
44
|
+
|
|
45
|
+
1. 检查 `@robot-admin/git-standards` 是否已执行 `init`
|
|
46
|
+
2. 检查 `.husky/` 目录及 `pre-commit`、`commit-msg` 钩子文件
|
|
47
|
+
3. 联系 CHENY(工号 409322)
|
|
48
|
+
|
|
49
|
+
## AI 生成 commit message 参考
|
|
50
|
+
|
|
51
|
+
AI 在协助提交时,按以下格式输出建议:
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
feat(模块名): 中文描述
|
|
55
|
+
|
|
56
|
+
- 变更点 1
|
|
57
|
+
- 变更点 2
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
不主动执行 `git commit`,由开发者通过 `git cz` 交互式确认。
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# 09 — TypeScript 类型规范
|
|
2
|
+
|
|
3
|
+
> **强制度**:🟡 建议。
|
|
4
|
+
> 项目使用 `strict: false` 宽松模式起步。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 类型定义优先级
|
|
9
|
+
|
|
10
|
+
- **`interface`**:可扩展的对象类型
|
|
11
|
+
- **`type`**:联合类型 / 工具类型 / 字面量类型
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
// ✅ interface 用于对象
|
|
15
|
+
interface User {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// ✅ type 用于联合 / 工具类型
|
|
21
|
+
type Status = "pending" | "active" | "closed";
|
|
22
|
+
type PartialUser = Partial<User>;
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## any 使用约束
|
|
26
|
+
|
|
27
|
+
❌ 禁止滥用 `any`。`as any` 仅允许出现在以下场景:
|
|
28
|
+
|
|
29
|
+
1. 对接外部 SDK 返回值的边界处
|
|
30
|
+
2. `AbstractPageQueryHook.create()` 的返回值接收(框架限制)
|
|
31
|
+
3. 确实无法确定类型时,加注释 `// TODO: 待补充类型`
|
|
32
|
+
|
|
33
|
+
```typescript
|
|
34
|
+
// ✅ 允许(框架限制)
|
|
35
|
+
return Page.create() as any
|
|
36
|
+
|
|
37
|
+
// ✅ 允许(外部边界,加注释)
|
|
38
|
+
const sdkResult = thirdPartySdk.call() as any // TODO(cheny): SDK 1.5 后补充类型
|
|
39
|
+
|
|
40
|
+
// ❌ 禁止(懒省事)
|
|
41
|
+
function handleClick(row: any) { ... }
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
## 类型导入
|
|
45
|
+
|
|
46
|
+
- 业务类型统一从 `@/types/page` 桶文件引入
|
|
47
|
+
- ❌ 不重复定义同名类型
|
|
48
|
+
- ✅ 复杂类型在 `@/types/` 下分文件管理
|
|
49
|
+
|
|
50
|
+
## 字段类型
|
|
51
|
+
|
|
52
|
+
- 业务字段优先用 `string` / `number` / `boolean`
|
|
53
|
+
- ❌ 不默认用 `any`
|
|
54
|
+
- ⚠️ 可选字段用 `?`,可空字段用 `| null`
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
interface Customer {
|
|
58
|
+
id: string;
|
|
59
|
+
name: string;
|
|
60
|
+
remark?: string; // 可选
|
|
61
|
+
closedAt: string | null; // 可空(后端明确返回 null)
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
## 与 @robot-admin/git-standards 兼容
|
|
66
|
+
|
|
67
|
+
| 项目状态 | 处理 |
|
|
68
|
+
| -------------------- | ------------------------------------------ |
|
|
69
|
+
| 已有 `tsconfig.json` | ✅ 直接安装 git-standards,零冲突 |
|
|
70
|
+
| 无 TS 环境 | 先 `tsc --init` 初始化,再装 git-standards |
|
|
71
|
+
| ESLint TS 规则 | `warn` 级别,不阻断提交,仅作质量提示 |
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 10 — Pinia 状态管理规范
|
|
2
|
+
|
|
3
|
+
> **强制度**:🔴 必遵。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 何时用 Store
|
|
8
|
+
|
|
9
|
+
- ✅ 跨页面共享:用户信息、权限、全局配置、主题
|
|
10
|
+
- ✅ 需要持久化到 `localStorage` 的状态
|
|
11
|
+
- ✅ 多个不相邻组件共享的会话级状态
|
|
12
|
+
|
|
13
|
+
## 何时不用 Store(保留页面级 ref)
|
|
14
|
+
|
|
15
|
+
- ❌ 当前页的查询参数、列表数据、分页、弹窗状态
|
|
16
|
+
- ❌ data.ts 内部的所有状态(默认页面级,不提升到 Store)
|
|
17
|
+
|
|
18
|
+
## 强制约束
|
|
19
|
+
|
|
20
|
+
❌ **禁止**:在 `data.ts` 里 `import` Store
|
|
21
|
+
|
|
22
|
+
> 理由:data.ts 是**页面数据契约**,应保持职责单一,不依赖全局状态。
|
|
23
|
+
> 跨页面共享数据通过 props / 路由参数 / 组件层包装传入,不直接耦合 Store。
|
|
24
|
+
|
|
25
|
+
## Store 文件结构
|
|
26
|
+
|
|
27
|
+
```
|
|
28
|
+
src/stores/
|
|
29
|
+
└── {domain}/
|
|
30
|
+
└── index.ts 每个领域独立目录,避免单文件膨胀
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
## Store 命名
|
|
34
|
+
|
|
35
|
+
- `useXxxStore` 标准命名
|
|
36
|
+
- 若项目已统一 `s_` 前缀(如 `s_userStore`),全项目保持一致
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
// src/stores/user/index.ts
|
|
40
|
+
export const useUserStore = defineStore("user", () => {
|
|
41
|
+
const userInfo = ref<User | null>(null);
|
|
42
|
+
function setUser(u: User) {
|
|
43
|
+
userInfo.value = u;
|
|
44
|
+
}
|
|
45
|
+
return { userInfo, setUser };
|
|
46
|
+
});
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 持久化
|
|
50
|
+
|
|
51
|
+
如需持久化,推荐 `pinia-plugin-persistedstate`:
|
|
52
|
+
|
|
53
|
+
```typescript
|
|
54
|
+
defineStore('user', () => { ... }, {
|
|
55
|
+
persist: { storage: localStorage, paths: ['userInfo'] }
|
|
56
|
+
})
|
|
57
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
# 11 — 表单与校验规范
|
|
2
|
+
|
|
3
|
+
> **强制度**:🔴 必遵。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## c_formModal / c_formSections 场景
|
|
8
|
+
|
|
9
|
+
平台已封装组件,**内置完整生命周期**:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
open → 数据回填 → validate → submit → close / resetFields
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
✅ AI 直接按组件文档使用即可,**不需要重复写 validate / resetFields 逻辑**。
|
|
16
|
+
|
|
17
|
+
参考:`src/components/local/c_formModal/README.md`
|
|
18
|
+
|
|
19
|
+
---
|
|
20
|
+
|
|
21
|
+
## FORM_ROUTE 独立路由表单页(c_formModal 不适用时)
|
|
22
|
+
|
|
23
|
+
无 c_formModal 托管的复杂表单(多 Tab、多子表、向导式),**必须遵守**:
|
|
24
|
+
|
|
25
|
+
### 1. 提交前调用 validate
|
|
26
|
+
|
|
27
|
+
```typescript
|
|
28
|
+
async function handleSubmit() {
|
|
29
|
+
const valid = await formRef.value?.validate();
|
|
30
|
+
if (!valid) return;
|
|
31
|
+
await postAction(API_CONFIG.save, formData.value);
|
|
32
|
+
}
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### 2. 取消/离开调用 resetFields
|
|
36
|
+
|
|
37
|
+
```typescript
|
|
38
|
+
function handleCancel() {
|
|
39
|
+
formRef.value?.resetFields();
|
|
40
|
+
router.back();
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
onBeforeRouteLeave(() => {
|
|
44
|
+
formRef.value?.resetFields();
|
|
45
|
+
});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### 3. rules 在 data.ts 中独立导出
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
// data.ts
|
|
52
|
+
export const formRules = {
|
|
53
|
+
fieldName: [
|
|
54
|
+
{ required: true, message: "请输入字段名", trigger: "blur" },
|
|
55
|
+
{ max: 50, message: "不超过 50 字符", trigger: "blur" },
|
|
56
|
+
],
|
|
57
|
+
status: [{ required: true, message: "请选择状态", trigger: "change" }],
|
|
58
|
+
};
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
❌ **禁止**:把 rules 写在 `<template>` 字面量里。
|
|
62
|
+
|
|
63
|
+
---
|
|
64
|
+
|
|
65
|
+
## 校验时机
|
|
66
|
+
|
|
67
|
+
| 时机 | 触发 |
|
|
68
|
+
| ----------------- | -------------------------------- |
|
|
69
|
+
| `blur` 失焦 | 字符串类、必填字段 |
|
|
70
|
+
| `change` 变更 | 选择类(select / date / picker) |
|
|
71
|
+
| 手动 `validate()` | 提交时全量校验 |
|
|
72
|
+
| 字段间联动 | `watch` + 手动 `validateField()` |
|
|
73
|
+
|
|
74
|
+
## AI 检查清单
|
|
75
|
+
|
|
76
|
+
生成 FORM_ROUTE 模板代码时确认:
|
|
77
|
+
|
|
78
|
+
- [ ] 提交按钮 click 处理函数中调用了 `formRef.value?.validate()`
|
|
79
|
+
- [ ] 取消按钮 / 路由离开钩子中调用了 `resetFields()`
|
|
80
|
+
- [ ] rules 定义在 `data.ts` 而非 `<template>`
|
|
81
|
+
- [ ] 必填字段都加了 `required: true` 校验规则
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
# 12 — BaseTable 渲染与 AGGrid cid 唯一性规范
|
|
2
|
+
|
|
3
|
+
> **强制度**:🔴 必遵。
|
|
4
|
+
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
## 渲染模式(强制)
|
|
8
|
+
|
|
9
|
+
所有 `BaseTable` 必须默认使用 **AGGrid** 渲染:
|
|
10
|
+
|
|
11
|
+
```vue
|
|
12
|
+
<BaseTable
|
|
13
|
+
ref="tableRef"
|
|
14
|
+
render-type="agGrid"
|
|
15
|
+
cid="mca-745831"
|
|
16
|
+
:data="list"
|
|
17
|
+
:columns="columns"
|
|
18
|
+
showToolbar
|
|
19
|
+
/>
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
> 全局配置:`envConfig().componentConfig.table = { renderType: 'agGrid' }`
|
|
23
|
+
> 设置后所有未显式指定 `render-type` 的 BaseTable 默认 AGGrid。
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## cid 命名规则(核心)
|
|
28
|
+
|
|
29
|
+
AGGrid 通过 `cid` 持久化列配置(列宽、顺序、显示),**cid 必须全局唯一**。
|
|
30
|
+
|
|
31
|
+
### 表格级 cid
|
|
32
|
+
|
|
33
|
+
```
|
|
34
|
+
格式:{页面目录首字母缩写}-{Unix秒后6位}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
**生成规则(AI 执行)**:
|
|
38
|
+
|
|
39
|
+
1. 取页面 kebab-case 目录名,每个单词取首字母拼接为缩写
|
|
40
|
+
2. 取 `Math.floor(Date.now() / 1000).toString().slice(-6)` 作为 6 位时间戳后缀
|
|
41
|
+
3. 用 `-` 连接
|
|
42
|
+
|
|
43
|
+
**示例**:
|
|
44
|
+
|
|
45
|
+
| 页面目录 | 缩写 | cid |
|
|
46
|
+
| ------------------------ | ---- | ----------------- |
|
|
47
|
+
| `mmwr-customer-archive` | mca | `mca-745831` |
|
|
48
|
+
| `domestic-trade-order` | dto | `dto-745832` |
|
|
49
|
+
| 同页面第二个表格(子表) | mca | `mca-745831-sub1` |
|
|
50
|
+
| 同页面第三个表格 | mca | `mca-745831-sub2` |
|
|
51
|
+
|
|
52
|
+
### 列级 cid
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
格式:{表格cid的缩写部分}-{fieldName}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
```typescript
|
|
59
|
+
// 表格缩写为 mca
|
|
60
|
+
columnsDef(): TableColumnDesc<any>[] {
|
|
61
|
+
return [
|
|
62
|
+
{ type: 'selection' },
|
|
63
|
+
{ type: 'index' },
|
|
64
|
+
{ label: '取样', name: 'sampling', cid: 'mca-sampling', width: 70 },
|
|
65
|
+
{ label: '线上公告', name: 'onlineAnnouncement', cid: 'mca-onlineAnnouncement', width: 70 },
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 禁止事项
|
|
73
|
+
|
|
74
|
+
- ❌ 随机短字符串 `cid="ipiCfsb"`(AI 重新生成时极易碰撞)
|
|
75
|
+
- ❌ 纯字段名 `cid: "sampling"`(不同页面同名字段冲突)
|
|
76
|
+
- ❌ 省略 cid(列配置持久化完全失效)
|
|
77
|
+
- ❌ 跨页面复用同一 cid
|
|
78
|
+
|
|
79
|
+
---
|
|
80
|
+
|
|
81
|
+
## Pre-flight 声明示例
|
|
82
|
+
|
|
83
|
+
```
|
|
84
|
+
✅ cid 已生成:mca-745831(mmwr-customer-archive)
|
|
85
|
+
✅ 列级 cid 前缀:mca-
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## 完整代码示例
|
|
91
|
+
|
|
92
|
+
```vue
|
|
93
|
+
<!-- index.vue -->
|
|
94
|
+
<template>
|
|
95
|
+
<BaseTable
|
|
96
|
+
ref="tableRef"
|
|
97
|
+
render-type="agGrid"
|
|
98
|
+
cid="mca-745831"
|
|
99
|
+
:data="list"
|
|
100
|
+
:columns="columns"
|
|
101
|
+
showToolbar
|
|
102
|
+
/>
|
|
103
|
+
</template>
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
```typescript
|
|
107
|
+
// data.ts
|
|
108
|
+
columnsDef(): TableColumnDesc<any>[] {
|
|
109
|
+
return [
|
|
110
|
+
{ type: 'selection' },
|
|
111
|
+
{ type: 'index' },
|
|
112
|
+
{ label: '客户名称', name: 'customerName', cid: 'mca-customerName', minWidth: 120 },
|
|
113
|
+
{ label: '状态', name: 'status', cid: 'mca-status', minWidth: 80 },
|
|
114
|
+
]
|
|
115
|
+
}
|
|
116
|
+
```
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# 13 — 平台组件合规规范(核心 AI 质量门控)
|
|
2
|
+
|
|
3
|
+
> **强制度**:🔴 必遵 + 阻断式。
|
|
4
|
+
> 这是防止 AI 绕过平台封装、自由发挥使用 `el-*` 原生组件的核心规则。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 总原则
|
|
9
|
+
|
|
10
|
+
> **优先使用平台封装组件;无对应封装时才允许使用 `el-*` 原生组件;
|
|
11
|
+
> 跨 3+ 页面相同 `el-*` 模式 → convention-audit 输出"组件提取建议"到 `reports/`,由人工评审决定是否封装。**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
## 组件强制对照表
|
|
16
|
+
|
|
17
|
+
| 场景 | 优先使用(有则必用) | 替代方案 |
|
|
18
|
+
| ------------------- | --------------------------------------------- | ---------------------------- |
|
|
19
|
+
| 查询栏 | `BaseQuery` | ❌ el-form 手写查询区 |
|
|
20
|
+
| 工具栏 / 操作按钮行 | `BaseToolbar` | ❌ 自定义按钮排列 |
|
|
21
|
+
| 列表 / 表格 | `BaseTable` (`render-type="agGrid"`) | ❌ el-table |
|
|
22
|
+
| 表单弹窗 | `c_formModal` | ❌ el-dialog + el-form 手写 |
|
|
23
|
+
| 列表选择弹窗 | `c_listModal` | ❌ el-dialog + el-table 手写 |
|
|
24
|
+
| 表单内容分区 | `c_formSections` | ❌ 裸分组 |
|
|
25
|
+
| 分割标题 | `c_spliterTitle` | ❌ el-divider |
|
|
26
|
+
| 复杂路由表单页 | FORM-ROUTE 模板 | ❌ 完全手写 |
|
|
27
|
+
| 日期 / 日期范围 | `jh-date` / `jh-date-range` | ❌ el-date-picker |
|
|
28
|
+
| 文件上传 | `jh-file-upload` | ❌ el-upload |
|
|
29
|
+
| 用户选择 | `jh-user-picker` | ❌ 自定义弹窗选人 |
|
|
30
|
+
| 部门选择 | `jh-dept-picker` | ❌ 同上 |
|
|
31
|
+
| 下拉 / 选择器 | `jh-select` / `jh-picker` | ❌ el-select 手写 options |
|
|
32
|
+
| 只读文本展示 | `jh-text` | ❌ span/div 直接渲染 |
|
|
33
|
+
| 分页 | `jh-pagination` | ❌ el-pagination |
|
|
34
|
+
| 上下分栏 | `jh-drag-row` | ❌ 手动 flex/grid |
|
|
35
|
+
| 左右分割 | `C_Splitter` | ❌ 手动 flex/grid |
|
|
36
|
+
| 树形面板 | `C_Tree` | ❌ el-tree 手写 |
|
|
37
|
+
| 状态标签 | `C_TagStatus` | ❌ el-tag + 颜色映射 |
|
|
38
|
+
| HTTP 请求 | `getAction/postAction/putAction/deleteAction` | ❌ axios / fetch 直接调用 |
|
|
39
|
+
|
|
40
|
+
---
|
|
41
|
+
|
|
42
|
+
## 组件在 template 中的书写顺序
|
|
43
|
+
|
|
44
|
+
当页面同时存在多个区块时,**有则按下列顺序排列**(**全部可选,不强制必须存在**):
|
|
45
|
+
|
|
46
|
+
```
|
|
47
|
+
BaseQuery → BaseToolbar → BaseTable → jh-pagination
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
✅ 仅有 BaseTable 的页面:直接写 BaseTable,没问题
|
|
51
|
+
✅ 仅 BaseQuery + BaseToolbar 的录入型页面:按此顺序,后接表单区即可
|
|
52
|
+
❌ 顺序颠倒:BaseToolbar 写在 BaseQuery 之前
|
|
53
|
+
|
|
54
|
+
---
|
|
55
|
+
|
|
56
|
+
## docs/ 文档前置读取清单
|
|
57
|
+
|
|
58
|
+
生成涉及以下场景的代码时,AI 必须先读取对应文档(按需,不全读):
|
|
59
|
+
|
|
60
|
+
| 涉及组件 / 模式 | 必读文档 |
|
|
61
|
+
| --------------------------- | --------------------------------------------- |
|
|
62
|
+
| `jh-date` / `jh-date-range` | `docs/jh-date.md` / `docs/jh-date-range.md` |
|
|
63
|
+
| `jh-file-upload` | `docs/jh-file-upload.md` |
|
|
64
|
+
| `jh-user-picker` | `docs/jh-user-picker.md` |
|
|
65
|
+
| `jh-dept-picker` | `docs/jh-dept-picker.md` |
|
|
66
|
+
| `jh-select` | `docs/jh-select.md` |
|
|
67
|
+
| `jh-picker` | `docs/jh-picker.md` |
|
|
68
|
+
| `jh-text` | `docs/jh-text.md` |
|
|
69
|
+
| `jh-pagination` | `docs/jh-pagination.md` |
|
|
70
|
+
| `jh-drag-row` | `docs/jh-drag-row.md` |
|
|
71
|
+
| HTTP 请求方式 | `docs/request.md` |
|
|
72
|
+
| 页面 Hook 模式 | `docs/page-query-hook-best-practices.md` |
|
|
73
|
+
| BaseQuery / BaseTable 等 | `src/components/remote/{Component}/README.md` |
|
|
74
|
+
| c_formModal / c_listModal | `src/components/local/{component}/README.md` |
|
|
75
|
+
|
|
76
|
+
> AI 在 Pre-flight 声明中明确列出已读文档。
|
|
77
|
+
|
|
78
|
+
---
|
|
79
|
+
|
|
80
|
+
## AbstractPageQueryHook(强制)
|
|
81
|
+
|
|
82
|
+
所有页面 `data.ts` **必须** `extends AbstractPageQueryHook`:
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
import { AbstractPageQueryHook } from '@jhlc/common-core/src/page-hooks/page-query-hook.ts'
|
|
86
|
+
|
|
87
|
+
export function createPage() {
|
|
88
|
+
let Page = new (class extends AbstractPageQueryHook {
|
|
89
|
+
constructor() { super({ url: { list: '...' } }) }
|
|
90
|
+
queryDef() { return [...] }
|
|
91
|
+
toolbarDef() { return [...] }
|
|
92
|
+
columnsDef() { return [...] }
|
|
93
|
+
})()
|
|
94
|
+
return Page.create() as any
|
|
95
|
+
}
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
---
|
|
99
|
+
|
|
100
|
+
## 提取建议触发规则
|
|
101
|
+
|
|
102
|
+
`convention-audit` 扫描发现 **3+ 个页面**出现相同的未封装 `el-*` 模式时,输出到 `reports/组件提取建议.md`:
|
|
103
|
+
|
|
104
|
+
```markdown
|
|
105
|
+
| 建议组件名 | 出现次数 | 页面路径 | 菜单位置(来自文件头) | 模式描述 |
|
|
106
|
+
| ------------- | -------- | ------------------------------- | ----------------------- | ---------------- |
|
|
107
|
+
| c_statusBadge | 5 处 | src/views/sale/.../index.vue 等 | 销售管理 > 国内贸易订单 | 状态枚举彩色标签 |
|
|
108
|
+
| c_priceFormat | 4 处 | ... | ... | 千分位金额显示 |
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> ⚠️ AI **不自动提取**。人工确认后,触发 template-extract 或手动封装。
|
|
112
|
+
|
|
113
|
+
---
|
|
114
|
+
|
|
115
|
+
## AI 检查清单(每次代码生成前自查)
|
|
116
|
+
|
|
117
|
+
- [ ] 查询区使用了 BaseQuery,没有自己写 el-form?
|
|
118
|
+
- [ ] 表格使用了 BaseTable + agGrid + cid,没有用 el-table?
|
|
119
|
+
- [ ] 弹窗使用了 c_formModal / c_listModal,没有手写 el-dialog?
|
|
120
|
+
- [ ] 日期组件用了 jh-date 系列,没有用 el-date-picker?
|
|
121
|
+
- [ ] HTTP 请求都走 `this.getAction / postAction`,没有 import axios?
|
|
122
|
+
- [ ] data.ts 继承了 AbstractPageQueryHook?
|
|
123
|
+
- [ ] 涉及 jh-_ 组件时已读取对应 docs/jh-_.md?
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Standards 规范门控(懒加载入口)
|
|
2
|
+
|
|
3
|
+
> **版本**:v1.0.0 **维护者**:CHENY (工号 409322)
|
|
4
|
+
> **加载策略**:AI 按当前任务类型,**只读取相关条目**,不全量加载。
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 13 条规范清单
|
|
9
|
+
|
|
10
|
+
| 编号 | 文件 | 主题 | 强制度 |
|
|
11
|
+
| ---- | --------------------------- | ---------------------- | -------------- |
|
|
12
|
+
| 01 | `01-toolchain.md` | 工具链前置检测 | 🔴 阻断 |
|
|
13
|
+
| 02 | `02-code-structure.md` | 代码结构与顺序 | 🔴 必遵 |
|
|
14
|
+
| 03 | `03-comments.md` | 注释规范 | 🟡 建议 |
|
|
15
|
+
| 04 | `04-coding-basics.md` | 基础编码(13 条) | 🔴 必遵 |
|
|
16
|
+
| 05 | `05-logging.md` | 日志输出 | 🔴 必遵 |
|
|
17
|
+
| 06 | `06-security.md` | 安全规范 | 🔴 必遵 |
|
|
18
|
+
| 07 | `07-config.md` | 配置管理 | 🔴 必遵 |
|
|
19
|
+
| 08 | `08-git.md` | Git 分支 & 提交 | 🔴 必遵 |
|
|
20
|
+
| 09 | `09-typescript.md` | TypeScript 类型 | 🟡 建议 |
|
|
21
|
+
| 10 | `10-pinia.md` | Pinia 状态管理 | 🔴 必遵 |
|
|
22
|
+
| 11 | `11-form-validation.md` | 表单与校验 | 🔴 必遵 |
|
|
23
|
+
| 12 | `12-base-table.md` | BaseTable + AGGrid cid | 🔴 必遵 |
|
|
24
|
+
| 13 | `13-platform-components.md` | 平台组件合规(核心) | 🔴 必遵 + 阻断 |
|
|
25
|
+
|
|
26
|
+
---
|
|
27
|
+
|
|
28
|
+
## 任务类型 → 必读规范映射
|
|
29
|
+
|
|
30
|
+
> AI 按用户意图选取下方匹配的「任务类型」,**仅加载该类型对应的规范文件**。
|
|
31
|
+
|
|
32
|
+
### 任务类型 A:生成新页面(page-codegen)
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
必读:01 / 02 / 04 / 12 / 13
|
|
36
|
+
按需:09(TS 类型复杂时) / 10(涉及 Store) / 11(FORM_ROUTE 模板)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### 任务类型 B:修改/重构既有页面
|
|
40
|
+
|
|
41
|
+
```
|
|
42
|
+
必读:02 / 04 / 13
|
|
43
|
+
按需:09 / 10 / 11
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
### 任务类型 C:规范审计(convention-audit)
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
必读:全部 13 条(审计需要完整对照)
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### 任务类型 D:模板提取(template-extract)
|
|
53
|
+
|
|
54
|
+
```
|
|
55
|
+
必读:02 / 13(模板必须遵循结构与组件合规规则)
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### 任务类型 E:菜单/字典/权限同步类
|
|
59
|
+
|
|
60
|
+
```
|
|
61
|
+
必读:07(环境变量与 API 地址不硬编码)
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 任务类型 F:仅 Git 操作 / Commit
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
必读:08
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
---
|
|
71
|
+
|
|
72
|
+
## 加载方式(Pre-flight 声明示例)
|
|
73
|
+
|
|
74
|
+
```
|
|
75
|
+
✅ 已读取 standards/index.md → 规范门控,匹配任务类型 A(生成新页面)
|
|
76
|
+
✅ 已读取 standards/02-code-structure.md → 4 文件原则 + 三段式 + script 9 段顺序
|
|
77
|
+
✅ 已读取 standards/12-base-table.md → AGGrid 必用 + cid 命名规范
|
|
78
|
+
✅ 已读取 standards/13-platform-components.md → 平台组件对照表
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
> **不要** 一次性读取全部 13 条。错误示范:`✅ 已读取 standards/01 ~ standards/13`(浪费 token,违反懒加载原则)。
|
|
82
|
+
|
|
83
|
+
---
|
|
84
|
+
|
|
85
|
+
## 规范变更管理
|
|
86
|
+
|
|
87
|
+
- 新增规范条目:编号顺序追加,不复用废弃编号
|
|
88
|
+
- 修改既有规范:在文件末尾追加 `## 变更记录` 章节,登记日期 + 变更摘要
|
|
89
|
+
- 整体破坏性变更:升级本文件顶部 `version`,并在根 `CHANGELOG.md` 标注
|