@brms/ai-skills 0.1.0
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/README.md +256 -0
- package/bin/brms-skills.mjs +411 -0
- package/package.json +30 -0
- package/skills/brms-prototype-generator/SKILL.md +129 -0
- package/skills/brms-prototype-generator/agents/openai.yaml +7 -0
- package/skills/brms-prototype-generator/examples/few-shot-examples.md +577 -0
- package/skills/brms-prototype-generator/references/01-list-query.md +444 -0
- package/skills/brms-prototype-generator/references/02-form-entry.md +129 -0
- package/skills/brms-prototype-generator/references/03-detail-display.md +125 -0
- package/skills/brms-prototype-generator/references/04-composite-page-package.md +339 -0
- package/skills/brms-prototype-generator/references/05-dialog-patterns.md +113 -0
- package/skills/brms-prototype-generator/references/06-backend-request-patterns.md +118 -0
- package/skills/brms-prototype-generator/references/resource-index.md +46 -0
- package/skills/brms-prototype-generator/references/system-prompt.md +242 -0
- package/skills/brms-prototype-generator/scripts/analyze-doc.mjs +554 -0
- package/skills/brms-prototype-generator/scripts/check-project.mjs +228 -0
- package/skills/brms-prototype-generator/scripts/discover-targets.mjs +158 -0
- package/skills/brms-prototype-generator/scripts/install-codex.mjs +74 -0
- package/skills/brms-prototype-generator/scripts/plan-pages.mjs +390 -0
- package/skills/brms-prototype-generator/scripts/validate-generated.mjs +838 -0
- package/skills/brms-prototype-generator/templates/user-input-template.md +182 -0
- package/skills/brms-vxe-plus-developer/SKILL.md +105 -0
- package/skills/brms-vxe-plus-developer/agents/openai.yaml +7 -0
- package/skills/brms-vxe-plus-developer/references/prototype-to-real.md +54 -0
- package/skills/brms-vxe-plus-developer/references/real-base-development.md +110 -0
- package/skills/brms-vxe-plus-developer/references/resource-index.md +43 -0
- package/skills/brms-vxe-plus-developer/references/review-checklist.md +49 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/01-mental-model.md +150 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/02-vxe-plus-form.md +302 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/03-vxe-plus-table.md +253 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/04-example-map.md +488 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/05-request-and-eiinfo.md +170 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/90-anti-patterns.md +137 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/README.md +43 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/README.md +21 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/A1/P0/A1P01601.vue +483 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/A1/P1/A1P11011.vue +444 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/AB/BP/ABBP0201.vue +1648 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/AM/AF/component/AMAF0601/Bidding/formConfig.ts +228 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/AM/AF/component/AMAF0601/Record/columns.ts +110 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/BM/BR/BMBR01.vue +130 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/BM/BR/component/BMBR01/columns.ts +94 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/BM/BR/component/BMBR01/formConfig.ts +108 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Change/formConfig.ts +123 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Change/index.vue +103 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Clause/columns.ts +48 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Clause/index.vue +202 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Correcte/formConfig.ts +117 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Correcte/index.vue +103 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Pay/Payment/formConfig.ts +90 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Pay/Payment/index.vue +42 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Pay/columns.ts +376 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Pay/index.vue +619 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/Domestic/formConfig.ts +73 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/Domestic/index.vue +47 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/Foreign/formConfig.ts +141 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/Foreign/index.vue +42 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/columns.ts +123 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/Settle/index.vue +593 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Explain/index.vue +68 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Fee/columns.ts +150 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Fee/index.vue +235 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Files/columns.ts +63 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Files/index.vue +117 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Goods/columns.ts +327 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Goods/index.vue +790 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Approve/formConfig.ts +341 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Approve/index.vue +63 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Approve2/formConfig.ts +232 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Approve2/index.vue +27 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Diff/columns.ts +46 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/Diff/index.vue +92 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/formConfig.ts +979 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Base/index.vue +62 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Other/formConfig.ts +179 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Other/index.vue +140 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Sign/formConfig.ts +118 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/Sign/index.vue +44 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Main/index.vue +168 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Party/Major/formConfig.ts +257 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Party/Major/index.vue +47 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Party/columns.ts +256 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Party/index.vue +738 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Price/formConfig.ts +174 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Price/index.vue +51 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/PM/PC/component/PMPC0101/Top/index.vue +924 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/SM/SW/SMSW0101.vue +567 -0
- package/skills/brms-vxe-plus-developer/references/vxe-plus-knowledge/sources/project/base/src/views/demo/index.vue +448 -0
- package/skills/brms-vxe-plus-developer/scripts/check-project.mjs +259 -0
- package/skills/brms-vxe-plus-developer/scripts/check-vxe-plus-page.mjs +137 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
# 01-Mental Model For AI
|
|
2
|
+
|
|
3
|
+
本文件用于让 AI 快速判断页面结构和组件契约。生成代码前先按本页做分类,不要直接复制最复杂样例。
|
|
4
|
+
|
|
5
|
+
## 组件分工
|
|
6
|
+
|
|
7
|
+
`VxePlusForm`:独立表单渲染组件。
|
|
8
|
+
|
|
9
|
+
```vue
|
|
10
|
+
<VxePlusForm ref="xForm" :form-options="formOptions" />
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
`VxePlusTable`:表格、分页、查询代理、编辑、按钮、导入导出组件。
|
|
14
|
+
|
|
15
|
+
```vue
|
|
16
|
+
<VxePlusTable
|
|
17
|
+
id="PAGE_result"
|
|
18
|
+
ref="xGrid"
|
|
19
|
+
:columns="columns"
|
|
20
|
+
:form-config="tableFormConfig"
|
|
21
|
+
:service-config="serviceConfig"
|
|
22
|
+
/>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
关键区分:
|
|
26
|
+
|
|
27
|
+
- `VxePlusForm :form-options` 用于渲染表单。
|
|
28
|
+
- `VxePlusTable :form-config` 用于表格查询参数来源。
|
|
29
|
+
- 两者经常共享同一个 `formData`,但 prop 名不同。
|
|
30
|
+
|
|
31
|
+
## 页面类型判断
|
|
32
|
+
|
|
33
|
+
标准查询页:
|
|
34
|
+
|
|
35
|
+
- 一个查询 `BxContainer` + `VxePlusForm`
|
|
36
|
+
- 一个结果 `BxContainer` + `VxePlusTable`
|
|
37
|
+
- 查询按钮执行 `xGrid.value.reload()`
|
|
38
|
+
- 重置按钮执行表单 reset,再 reload 或清空
|
|
39
|
+
|
|
40
|
+
详情表单页:
|
|
41
|
+
|
|
42
|
+
- 一个或多个 `VxePlusForm`
|
|
43
|
+
- 保存时显式校验表单并构造 `EiInfo`
|
|
44
|
+
- 不一定有 `VxePlusTable`
|
|
45
|
+
|
|
46
|
+
可编辑表格页:
|
|
47
|
+
|
|
48
|
+
- `VxePlusTable :is-edit="true"`
|
|
49
|
+
- 有 `editRules`
|
|
50
|
+
- 新增、删除、保存按钮在 `toolbarButtonClick`
|
|
51
|
+
- 保存前必须校验表格
|
|
52
|
+
- 复杂保存显式构造 `EiInfo`
|
|
53
|
+
|
|
54
|
+
弹窗选择页:
|
|
55
|
+
|
|
56
|
+
- 页面本身通常也是 `VxePlusTable`
|
|
57
|
+
- 被 `formSelectDialog` 或 `tableSelectDialog` 打开
|
|
58
|
+
- 必须确认 `fields` 与 `dialogFields` 一一对应
|
|
59
|
+
|
|
60
|
+
复合详情页:
|
|
61
|
+
|
|
62
|
+
- 多个表单、多张表格、tabs 或步骤
|
|
63
|
+
- 可能通过 `provide/inject` 共享详情数据和保存方法
|
|
64
|
+
- 只在当前需求确实复杂时参考,不要作为普通页面默认模板
|
|
65
|
+
|
|
66
|
+
## 标准查询页骨架
|
|
67
|
+
|
|
68
|
+
```vue
|
|
69
|
+
<BxContainer id="INQU" title="查询条件" :form-ref="xForm" @btn-click="btnClick">
|
|
70
|
+
<VxePlusForm ref="xForm" folding :form-options="formOptions" />
|
|
71
|
+
</BxContainer>
|
|
72
|
+
|
|
73
|
+
<BxContainer title="查询结果">
|
|
74
|
+
<VxePlusTable
|
|
75
|
+
id="BMBR01_result"
|
|
76
|
+
ref="xGrid"
|
|
77
|
+
:columns="columns"
|
|
78
|
+
:form-config="tableFormConfig"
|
|
79
|
+
:service-config="serviceConfig"
|
|
80
|
+
:show-checkbox="true"
|
|
81
|
+
v-on="gridEvents"
|
|
82
|
+
/>
|
|
83
|
+
</BxContainer>
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
```ts
|
|
87
|
+
const formData = reactive({})
|
|
88
|
+
|
|
89
|
+
const formOptions = reactive({
|
|
90
|
+
id: 'inqu_status',
|
|
91
|
+
data: formData,
|
|
92
|
+
items: [],
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const tableFormConfig = reactive({
|
|
96
|
+
id: 'inqu_status',
|
|
97
|
+
data: formData,
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const serviceConfig = reactive({
|
|
101
|
+
serviceName: 'BMBR01',
|
|
102
|
+
queryMethod: 'pageQueryLike',
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
function btnClick(btn) {
|
|
106
|
+
if (btn.code === 'QUERY') {
|
|
107
|
+
xGrid.value.reload()
|
|
108
|
+
}
|
|
109
|
+
if (btn.code === 'RESET') {
|
|
110
|
+
xForm.value.getFormInstance().reset()
|
|
111
|
+
xGrid.value.reload()
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## id 与 EiInfo block
|
|
117
|
+
|
|
118
|
+
`VxePlusTable` 根据 `id` 推导表格 block:
|
|
119
|
+
|
|
120
|
+
```ts
|
|
121
|
+
id="BMBR01_result" -> tableId = "result"
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`VxePlusTable` 根据 `form-config.id` 推导查询条件 block:
|
|
125
|
+
|
|
126
|
+
```ts
|
|
127
|
+
tableFormConfig.id || 'inqu_status'
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
所以后端返回 block、表格 id、`transformResponse` 必须一致。请求细节读 [05-request-and-eiinfo.md](./05-request-and-eiinfo.md)。
|
|
131
|
+
|
|
132
|
+
## 配置拆分
|
|
133
|
+
|
|
134
|
+
业务页常见拆分:
|
|
135
|
+
|
|
136
|
+
- `.vue`:页面流程、按钮事件、请求动作、路由跳转
|
|
137
|
+
- `formConfig.ts`:表单字段配置
|
|
138
|
+
- `columns.ts`:表格列配置、编辑规则
|
|
139
|
+
|
|
140
|
+
新生成代码可以拆分,但不要为了拆分而新增不必要 helper。AI 优先保留当前模块已有组织方式。
|
|
141
|
+
|
|
142
|
+
## 数据对象
|
|
143
|
+
|
|
144
|
+
常见三类数据:
|
|
145
|
+
|
|
146
|
+
- 表单显示数据:`formOptions.data`
|
|
147
|
+
- 表格查询数据:`tableFormConfig.data`
|
|
148
|
+
- 表格行数据:`xGrid.value.getGridInstance().getTableData().tableData`
|
|
149
|
+
|
|
150
|
+
查询页通常让 `formOptions.data` 和 `tableFormConfig.data` 指向同一个 `formData`。
|
|
@@ -0,0 +1,302 @@
|
|
|
1
|
+
# 02-VxePlusForm
|
|
2
|
+
|
|
3
|
+
本文件只记录 AI 可以稳定复制的 `VxePlusForm` 契约。不要把业务侧 `useForm()` helper 当成推荐写法;它是历史代码里的二次封装,AI 新生成页面时继续套一层会更容易混淆属性名和请求形态。
|
|
4
|
+
|
|
5
|
+
## 推荐生成形态
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<VxePlusForm
|
|
9
|
+
id="inqu_status"
|
|
10
|
+
ref="xForm"
|
|
11
|
+
folding
|
|
12
|
+
:form-options="formOptions"
|
|
13
|
+
/>
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```ts
|
|
17
|
+
const formData = reactive({
|
|
18
|
+
formulaCode: '',
|
|
19
|
+
formulaName: '',
|
|
20
|
+
createdTimeStart: '',
|
|
21
|
+
createdTimeEnd: '',
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
const formOptions = reactive({
|
|
25
|
+
id: 'inqu_status',
|
|
26
|
+
data: formData,
|
|
27
|
+
titleWidth: 120,
|
|
28
|
+
rules: {
|
|
29
|
+
formulaCode: [{ required: true, message: '请输入价格公式编号' }],
|
|
30
|
+
},
|
|
31
|
+
items: [
|
|
32
|
+
{ field: 'formulaCode', title: '价格公式编号', itemRender: { name: 'VxeInput' } },
|
|
33
|
+
{ field: 'formulaName', title: '价格公式名称', itemRender: { name: 'VxeInput' } },
|
|
34
|
+
{
|
|
35
|
+
field: 'createdTime',
|
|
36
|
+
title: '创建日期',
|
|
37
|
+
itemRender: {
|
|
38
|
+
name: 'dateRange',
|
|
39
|
+
props: {
|
|
40
|
+
startDate: 'createdTimeStart',
|
|
41
|
+
endDate: 'createdTimeEnd',
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
})
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## 可复制字段渲染器
|
|
50
|
+
|
|
51
|
+
直接写 `itemRender`,不要为了少写几行再封装 helper。
|
|
52
|
+
|
|
53
|
+
```ts
|
|
54
|
+
{ field: 'name', title: '名称', itemRender: { name: 'VxeInput' } }
|
|
55
|
+
{ field: 'remark', title: '备注', itemRender: { name: 'VxeTextarea' } }
|
|
56
|
+
{ field: 'enabled', title: '是否启用', itemRender: { name: 'VxeCheckbox' } }
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
字典下拉:
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
{
|
|
63
|
+
field: 'formulaStatus',
|
|
64
|
+
title: '状态',
|
|
65
|
+
itemRender: {
|
|
66
|
+
name: 'formSelect',
|
|
67
|
+
props: {
|
|
68
|
+
codeSet: 'BRMERP.bm.formulaStatus',
|
|
69
|
+
clearable: true,
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
接口字典:
|
|
76
|
+
|
|
77
|
+
```ts
|
|
78
|
+
import { getCodeSetByService } from '@/utils/eiTools'
|
|
79
|
+
|
|
80
|
+
{
|
|
81
|
+
field: 'orgId',
|
|
82
|
+
title: '所属账套',
|
|
83
|
+
itemRender: {
|
|
84
|
+
name: 'formSelect',
|
|
85
|
+
props: {
|
|
86
|
+
codeSet: 'BMBE0000.queryBookOrgByListByPurOrg',
|
|
87
|
+
promiseFn: params => getCodeSetByService({
|
|
88
|
+
serviceName: 'BMBE0000',
|
|
89
|
+
methodName: 'queryBookOrgByListByPurOrg',
|
|
90
|
+
params,
|
|
91
|
+
blockName: 'bookResult',
|
|
92
|
+
value: 'orgId',
|
|
93
|
+
label: 'bookAndOrgDeptName',
|
|
94
|
+
}),
|
|
95
|
+
backfillFields: 'bookId,groupId,deptId,companyId',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
}
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
日期范围:
|
|
102
|
+
|
|
103
|
+
```ts
|
|
104
|
+
{
|
|
105
|
+
field: 'createdTime',
|
|
106
|
+
title: '创建日期',
|
|
107
|
+
itemRender: {
|
|
108
|
+
name: 'dateRange',
|
|
109
|
+
props: {
|
|
110
|
+
startDate: 'createdTimeStart',
|
|
111
|
+
endDate: 'createdTimeEnd',
|
|
112
|
+
},
|
|
113
|
+
},
|
|
114
|
+
}
|
|
115
|
+
```
|
|
116
|
+
|
|
117
|
+
## VxeDatePicker month valueFormat 限制
|
|
118
|
+
|
|
119
|
+
`VxeDatePicker` 在 `type: 'month'` 模式下,不要使用 `valueFormat: 'MM'`。
|
|
120
|
+
|
|
121
|
+
错误配置:
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
{
|
|
125
|
+
field: 'expiryMonth',
|
|
126
|
+
title: '到期月份',
|
|
127
|
+
itemRender: {
|
|
128
|
+
name: 'VxeDatePicker',
|
|
129
|
+
props: {
|
|
130
|
+
type: 'month',
|
|
131
|
+
valueFormat: 'MM',
|
|
132
|
+
clearable: true,
|
|
133
|
+
},
|
|
134
|
+
},
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
现象:选择月份后 modelValue 会变成 `"06"` 这类纯月份字符串,但输入框无法回显,面板也无法正确高亮选中月份。
|
|
139
|
+
|
|
140
|
+
根因:`vxe-pc-ui` 底层依赖 `xe-utils` 解析日期。格式化方向可以把 Date 格式化成纯月份:
|
|
141
|
+
|
|
142
|
+
```ts
|
|
143
|
+
xeUtils.toDateString(new Date(2026, 5, 15), 'MM') // "06"
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
但解析方向无法从纯月份字符串还原 Date:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
xeUtils.toStringDate('06', 'MM') // Invalid Date
|
|
150
|
+
```
|
|
151
|
+
|
|
152
|
+
`valueFormat` 会影响 modelValue、回显解析和面板选中匹配,所以它必须包含足够的日期信息。任何不包含年份的格式,例如 `MM`、`dd`,都不要作为 `valueFormat` 使用。
|
|
153
|
+
|
|
154
|
+
正确配置:用 `valueFormat` 存储可解析值,用 `labelFormat` 控制 UI 显示。
|
|
155
|
+
|
|
156
|
+
```ts
|
|
157
|
+
{
|
|
158
|
+
field: 'expiryMonth',
|
|
159
|
+
title: '到期月份',
|
|
160
|
+
itemRender: {
|
|
161
|
+
name: 'VxeDatePicker',
|
|
162
|
+
props: {
|
|
163
|
+
type: 'month',
|
|
164
|
+
valueFormat: 'yyyy-MM',
|
|
165
|
+
labelFormat: 'MM',
|
|
166
|
+
clearable: true,
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
}
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
分工:
|
|
173
|
+
|
|
174
|
+
- `valueFormat`:控制 modelValue 格式,影响存储值、回显解析、面板选中匹配。
|
|
175
|
+
- `labelFormat`:控制输入框显示文本,只影响 UI 展示。
|
|
176
|
+
|
|
177
|
+
弹窗选择:
|
|
178
|
+
|
|
179
|
+
```ts
|
|
180
|
+
{
|
|
181
|
+
field: 'customerName',
|
|
182
|
+
title: '客户名称',
|
|
183
|
+
itemRender: {
|
|
184
|
+
name: 'formSelectDialog',
|
|
185
|
+
props: {
|
|
186
|
+
component: UMUC9902,
|
|
187
|
+
fields: 'customerName',
|
|
188
|
+
dialogFields: 'corpName',
|
|
189
|
+
componentParam: {
|
|
190
|
+
param: {
|
|
191
|
+
corpType: 'CUSTOMER',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
},
|
|
195
|
+
},
|
|
196
|
+
}
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
`fields` 是当前表单字段,`dialogFields` 是弹窗选中行字段,多个字段用逗号并保持一一对应。
|
|
200
|
+
|
|
201
|
+
## 显隐、禁用、事件
|
|
202
|
+
|
|
203
|
+
显隐写在 item 上:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
{
|
|
207
|
+
field: 'otherReason',
|
|
208
|
+
title: '其他原因',
|
|
209
|
+
visibleMethod: ({ data }) => data.reasonType === 'OTHER',
|
|
210
|
+
itemRender: { name: 'VxeInput' },
|
|
211
|
+
}
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
禁用写在渲染器 props 上:
|
|
215
|
+
|
|
216
|
+
```ts
|
|
217
|
+
{
|
|
218
|
+
field: 'outstockType',
|
|
219
|
+
title: '出库单类型',
|
|
220
|
+
itemRender: {
|
|
221
|
+
name: 'formSelect',
|
|
222
|
+
props: {
|
|
223
|
+
codeSet: 'brmerp.sm.outstockType',
|
|
224
|
+
disabled: true,
|
|
225
|
+
readonly: true,
|
|
226
|
+
},
|
|
227
|
+
},
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
字段事件直接挂 `itemRender.events`:
|
|
232
|
+
|
|
233
|
+
```ts
|
|
234
|
+
{
|
|
235
|
+
field: 'qty',
|
|
236
|
+
title: '只看可出库',
|
|
237
|
+
itemRender: {
|
|
238
|
+
name: 'VxeCheckbox',
|
|
239
|
+
events: {
|
|
240
|
+
change({ data }) {
|
|
241
|
+
data.qtyButton = data.qty ? 'Y' : 'N'
|
|
242
|
+
},
|
|
243
|
+
},
|
|
244
|
+
},
|
|
245
|
+
}
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
## 校验
|
|
249
|
+
|
|
250
|
+
简单校验放在 `formOptions.rules`。
|
|
251
|
+
|
|
252
|
+
```ts
|
|
253
|
+
const formOptions = reactive({
|
|
254
|
+
id: 'inqu_status',
|
|
255
|
+
data: formData,
|
|
256
|
+
rules: {
|
|
257
|
+
outstockType: [{ required: true, message: '请选择出库单类型' }],
|
|
258
|
+
},
|
|
259
|
+
items,
|
|
260
|
+
})
|
|
261
|
+
```
|
|
262
|
+
|
|
263
|
+
提交前用组件实例校验:
|
|
264
|
+
|
|
265
|
+
```ts
|
|
266
|
+
await xForm.value.getFormInstance().validate()
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
字段必填校验必须写在 `formOptions.rules`,按字段名配置。不要把 `required: true` 写在 `items` 中,也不要用 `titlePrefix: { content: '必填' }` 代替校验;这些写法不会稳定触发表单校验。
|
|
270
|
+
字段级异步校验优先寻找同模块已有 `rules` 写法,不要凭空发明规则结构。
|
|
271
|
+
|
|
272
|
+
## 数据读取原则
|
|
273
|
+
|
|
274
|
+
请求查询时,`VxePlusTable` 会读取 `:form-config="{ id, data }"` 里的 `data` 并组装为 EiInfo。不要为查询再手工遍历表单字段。
|
|
275
|
+
|
|
276
|
+
保存详情表单时,如果页面只需要提交可见字段,可以按 `formOptions.items` 白名单提取;如果后端需要完整详情对象,就提交完整 `formData`。不要无条件提交整份 `formData`,也不要无条件只提交可见字段,先看当前业务接口契约。
|
|
277
|
+
|
|
278
|
+
历史代码里的 `getFormData(baseFields, formData)` 可以帮助识别旧页面意图,但新生成代码不要把 `useForm().getFormData` 当标准依赖引入。
|
|
279
|
+
|
|
280
|
+
## 插槽
|
|
281
|
+
|
|
282
|
+
字段默认插槽常用 `${field}_default`,标题插槽常用 `${field}_title`。
|
|
283
|
+
|
|
284
|
+
```vue
|
|
285
|
+
<VxePlusForm :form-options="formOptions">
|
|
286
|
+
<template #fileCount_default="{ data }">
|
|
287
|
+
<el-button type="primary" @click="handleUpload(data)">
|
|
288
|
+
附件管理
|
|
289
|
+
</el-button>
|
|
290
|
+
</template>
|
|
291
|
+
</VxePlusForm>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
## 历史 helper 识别规则
|
|
295
|
+
|
|
296
|
+
如果编辑的既有文件已经大量使用 `useForm()`,可以局部沿用以减少改动,但不要把它作为新文件样板扩散。遇到 helper 时按含义还原为直接配置:
|
|
297
|
+
|
|
298
|
+
- `commonVxeInput()` -> `{ name: 'VxeInput' }`
|
|
299
|
+
- `commonVxeTextarea()` -> `{ name: 'VxeTextarea' }`
|
|
300
|
+
- `commonFormSelect(codeSet)` -> `{ name: 'formSelect', props: { codeSet } }`
|
|
301
|
+
- `commonDateRange(start, end)` -> `{ name: 'dateRange', props: { startDate: start, endDate: end } }`
|
|
302
|
+
- `commonSelectDialog(...)` -> `{ name: 'formSelectDialog', props: ... }`
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# 03-VxePlusTable
|
|
2
|
+
|
|
3
|
+
本文件记录 AI 生成 `VxePlusTable` 时可复制的稳定契约。请求细节见 [05-request-and-eiinfo.md](./05-request-and-eiinfo.md)。
|
|
4
|
+
|
|
5
|
+
## 推荐生成形态
|
|
6
|
+
|
|
7
|
+
```vue
|
|
8
|
+
<VxePlusTable
|
|
9
|
+
id="BMBR01_result"
|
|
10
|
+
ref="xGrid"
|
|
11
|
+
:columns="columns"
|
|
12
|
+
:form-config="tableFormConfig"
|
|
13
|
+
:service-config="serviceConfig"
|
|
14
|
+
:show-checkbox="true"
|
|
15
|
+
:transform-params="transformParams"
|
|
16
|
+
:transform-response="transformResponse"
|
|
17
|
+
v-on="gridEvents"
|
|
18
|
+
/>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
```ts
|
|
22
|
+
const tableFormConfig = reactive({
|
|
23
|
+
id: 'inqu_status',
|
|
24
|
+
data: formData,
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const serviceConfig = reactive({
|
|
28
|
+
serviceName: 'BMBR01',
|
|
29
|
+
queryMethod: 'pageQueryLike',
|
|
30
|
+
})
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
`id="BMBR01_result"` 中下划线后的 `result` 是表格数据 block 名;组件内部会用它读取响应 `res.getBlock('result')`。
|
|
34
|
+
|
|
35
|
+
## 列配置
|
|
36
|
+
|
|
37
|
+
可以直接写列数组;如果既有文件已经使用 `useTable().createColumns()`,局部沿用即可,但新文件不要为了生成列再新增一层二次封装。
|
|
38
|
+
|
|
39
|
+
```ts
|
|
40
|
+
const columns = reactive([
|
|
41
|
+
{ field: 'formulaCode', title: '价格公式编号', minWidth: 140 },
|
|
42
|
+
{ field: 'formulaName', title: '价格公式名称', minWidth: 160, showOverflow: true },
|
|
43
|
+
{
|
|
44
|
+
field: 'formulaStatus',
|
|
45
|
+
title: '状态',
|
|
46
|
+
editRender: {
|
|
47
|
+
name: 'tableSelect',
|
|
48
|
+
enabled: false,
|
|
49
|
+
props: {
|
|
50
|
+
codeSet: 'BRMERP.bm.formulaStatus',
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
])
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
只展示字典文本但不允许编辑时,`editRender.enabled` 设为 `false`。
|
|
58
|
+
|
|
59
|
+
## 可编辑列
|
|
60
|
+
|
|
61
|
+
```ts
|
|
62
|
+
{
|
|
63
|
+
field: 'toBeAdd',
|
|
64
|
+
title: '待添加量',
|
|
65
|
+
align: 'right',
|
|
66
|
+
headerAlign: 'center',
|
|
67
|
+
editRender: { name: 'VxeInput' },
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
表格下拉:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
{
|
|
75
|
+
field: 'teamCode',
|
|
76
|
+
title: '创业团队',
|
|
77
|
+
editRender: {
|
|
78
|
+
name: 'tableSelect',
|
|
79
|
+
props: {
|
|
80
|
+
codeSet: 'BMBF3002.queryTeam',
|
|
81
|
+
promiseFn: params => getCodeSetByService({
|
|
82
|
+
serviceName: 'BMBF3002',
|
|
83
|
+
methodName: 'queryTeam',
|
|
84
|
+
params,
|
|
85
|
+
blockName: 'result',
|
|
86
|
+
value: 'teamCode',
|
|
87
|
+
label: 'teamName',
|
|
88
|
+
}),
|
|
89
|
+
backfillFields: 'teamName',
|
|
90
|
+
clearable: true,
|
|
91
|
+
filterable: true,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
}
|
|
95
|
+
```
|
|
96
|
+
|
|
97
|
+
表格弹窗选择:
|
|
98
|
+
|
|
99
|
+
```ts
|
|
100
|
+
{
|
|
101
|
+
field: 'feeTypeName',
|
|
102
|
+
title: '费用类型',
|
|
103
|
+
editRender: {
|
|
104
|
+
name: 'tableSelectDialog',
|
|
105
|
+
props: {
|
|
106
|
+
component: FeeTypeDialog,
|
|
107
|
+
fields: 'feeTypeName,cgFeeTypeCode',
|
|
108
|
+
dialogFields: 'estimationFeeTypeName,ceEstimationFeeTypeCode',
|
|
109
|
+
},
|
|
110
|
+
},
|
|
111
|
+
}
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
## 编辑校验
|
|
115
|
+
|
|
116
|
+
简单校验可直接写 `editRules`:
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const editRules = reactive({
|
|
120
|
+
toBeAdd: [{ required: true, message: '填写量必填' }],
|
|
121
|
+
})
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
```vue
|
|
125
|
+
<VxePlusTable
|
|
126
|
+
:columns="columns"
|
|
127
|
+
:is-edit="true"
|
|
128
|
+
:edit-rules="editRules"
|
|
129
|
+
/>
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
保存前优先使用底层 grid 校验或当前页面已有校验函数。生成代码前先检索同模块 `editRules`、`validate`、`fullValidate`、`validator` 的既有写法。
|
|
133
|
+
|
|
134
|
+
## 按钮事件
|
|
135
|
+
|
|
136
|
+
业务按钮常通过 `v-on="gridEvents"` 接收。
|
|
137
|
+
|
|
138
|
+
```ts
|
|
139
|
+
const gridEvents = reactive({
|
|
140
|
+
toolbarButtonClick: async ({ code, $grid }) => {
|
|
141
|
+
switch (code) {
|
|
142
|
+
case 'ADD':
|
|
143
|
+
await handleAdd($grid)
|
|
144
|
+
break
|
|
145
|
+
case 'SAVE':
|
|
146
|
+
await handleSave()
|
|
147
|
+
break
|
|
148
|
+
case 'DELETE':
|
|
149
|
+
await handleDelete($grid)
|
|
150
|
+
break
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
})
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
手工按钮:
|
|
157
|
+
|
|
158
|
+
```ts
|
|
159
|
+
const toolbarButtons = ref([
|
|
160
|
+
{ name: '新增', code: 'ADD' },
|
|
161
|
+
{ name: '保存', code: 'SAVE', status: 'success' },
|
|
162
|
+
{ name: '删除', code: 'DELETE', status: 'danger' },
|
|
163
|
+
])
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
按钮控制:
|
|
167
|
+
|
|
168
|
+
```ts
|
|
169
|
+
xGrid.value.btnSetDisable(['ADD', 'DELETE'], true)
|
|
170
|
+
xGrid.value.btnSetVisible(['VIEW_DETAIL'], false)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## 新增、删除、保存
|
|
174
|
+
|
|
175
|
+
新增行:
|
|
176
|
+
|
|
177
|
+
```ts
|
|
178
|
+
const $grid = xGrid.value.getGridInstance()
|
|
179
|
+
const { row } = await $grid.insertAt({ id: '' }, -1)
|
|
180
|
+
await $grid.setEditRow(row)
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
删除未保存行:
|
|
184
|
+
|
|
185
|
+
```ts
|
|
186
|
+
const $grid = xGrid.value.getGridInstance()
|
|
187
|
+
const records = $grid.getCheckboxRecords()
|
|
188
|
+
if (!records.length) {
|
|
189
|
+
ElMessage.warning('请选择数据')
|
|
190
|
+
return
|
|
191
|
+
}
|
|
192
|
+
await $grid.removeCheckboxRow()
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
复杂保存不要盲目依赖 `commitProxy('save')`。当前组件内部 proxy save 主要处理 insertRecords,update/delete 分支并不完整。涉及新增、修改、删除混合提交时,优先显式构造 `EiInfo` 并调用 `EiCommunicator.send`。
|
|
196
|
+
|
|
197
|
+
## 查询刷新
|
|
198
|
+
|
|
199
|
+
```ts
|
|
200
|
+
xGrid.value.reload()
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
或底层:
|
|
204
|
+
|
|
205
|
+
```ts
|
|
206
|
+
xGrid.value.getGridInstance().commitProxy('query')
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
`reload()` 会触发表格请求,参数来自 `:form-config` 的 `data`,再经过 `transformParams`。
|
|
210
|
+
|
|
211
|
+
## 插槽
|
|
212
|
+
|
|
213
|
+
列默认插槽:
|
|
214
|
+
|
|
215
|
+
```vue
|
|
216
|
+
<template #formulaCode_default="{ row }">
|
|
217
|
+
<el-link type="primary" @click="openDetail(row)">
|
|
218
|
+
{{ row.formulaCode }}
|
|
219
|
+
</el-link>
|
|
220
|
+
</template>
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
如果列配置统一注入 slot:
|
|
224
|
+
|
|
225
|
+
```ts
|
|
226
|
+
columns.forEach((column) => {
|
|
227
|
+
column.slots = {
|
|
228
|
+
...column.slots,
|
|
229
|
+
default: `${column.field}_default`,
|
|
230
|
+
}
|
|
231
|
+
})
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
表头插槽:
|
|
235
|
+
|
|
236
|
+
```vue
|
|
237
|
+
<template #goodsCode_header="{ column }">
|
|
238
|
+
<span class="vxe-cell--required-icon"><i /></span>
|
|
239
|
+
<span>{{ column.title }}</span>
|
|
240
|
+
</template>
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## 导入导出
|
|
244
|
+
|
|
245
|
+
```vue
|
|
246
|
+
<VxePlusTable
|
|
247
|
+
:is-import="true"
|
|
248
|
+
:is-export-template="true"
|
|
249
|
+
:export-config="{ fileName: '导入模板' }"
|
|
250
|
+
/>
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
导入导出依赖列配置,生成时必须确认隐藏列、必填列、字典列是否需要出现在模板里。
|