kcode-pi 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.
Files changed (219) hide show
  1. package/README.md +358 -0
  2. package/dist/cli/kcode.d.ts +15 -0
  3. package/dist/cli/kcode.js +153 -0
  4. package/dist/cli/main.d.ts +2 -0
  5. package/dist/cli/main.js +7 -0
  6. package/docs/KCODE_DISTRIBUTION.md +91 -0
  7. package/extensions/kingdee-harness.ts +180 -0
  8. package/extensions/kingdee-header.ts +122 -0
  9. package/extensions/kingdee-tools.ts +379 -0
  10. package/knowledge/.backup/v1.0.0/version.json +10 -0
  11. package/knowledge/cangqiong/product-notes.md +15 -0
  12. package/knowledge/common/business-flows.md +115 -0
  13. package/knowledge/common/config-guides.md +110 -0
  14. package/knowledge/common/error-patterns.md +170 -0
  15. package/knowledge/common/implementation.md +144 -0
  16. package/knowledge/cosmic/hard-constraints.md +38 -0
  17. package/knowledge/cosmic/ksql-datafix.md +34 -0
  18. package/knowledge/cosmic/platform-baseline.md +32 -0
  19. package/knowledge/cosmic/plugin-decision-matrix.md +40 -0
  20. package/knowledge/cosmic/review-checklist.md +40 -0
  21. package/knowledge/cosmic/unittest.md +35 -0
  22. package/knowledge/enterprise/api-reference.md +186 -0
  23. package/knowledge/enterprise/code-patterns.md +217 -0
  24. package/knowledge/enterprise/plugin-lifecycle.md +188 -0
  25. package/knowledge/enterprise/tables.json +159 -0
  26. package/knowledge/flagship/api-reference.md +237 -0
  27. package/knowledge/flagship/code-patterns.md +246 -0
  28. package/knowledge/flagship/cosmic-platform-note.md +15 -0
  29. package/knowledge/flagship/plugin-lifecycle.md +248 -0
  30. package/knowledge/flagship/tables.json +159 -0
  31. package/knowledge/version.json +10 -0
  32. package/knowledge/xinghan/product-notes.md +15 -0
  33. package/package.json +71 -0
  34. package/prompts/kd-discuss.md +11 -0
  35. package/prompts/kd-execute.md +12 -0
  36. package/prompts/kd-plan.md +12 -0
  37. package/prompts/kd-ship.md +12 -0
  38. package/prompts/kd-spec.md +12 -0
  39. package/prompts/kd-verify.md +12 -0
  40. package/skills/kd-check/SKILL.md +26 -0
  41. package/skills/kd-cosmic-dev/SKILL.md +82 -0
  42. package/skills/kd-cosmic-review/SKILL.md +90 -0
  43. package/skills/kd-cosmic-unittest/SKILL.md +92 -0
  44. package/skills/kd-debug/SKILL.md +30 -0
  45. package/skills/kd-discuss/SKILL.md +24 -0
  46. package/skills/kd-execute/SKILL.md +22 -0
  47. package/skills/kd-gen/SKILL.md +34 -0
  48. package/skills/kd-ksql/SKILL.md +86 -0
  49. package/skills/kd-plan/SKILL.md +24 -0
  50. package/skills/kd-ship/SKILL.md +22 -0
  51. package/skills/kd-spec/SKILL.md +24 -0
  52. package/skills/kd-verify/SKILL.md +22 -0
  53. package/themes/kcode-dark.json +81 -0
  54. package/vendor/kingdee-skills/cosmic-unittest/SKILL.md +788 -0
  55. package/vendor/kingdee-skills/cosmic-unittest/author-cache.json +5 -0
  56. package/vendor/kingdee-skills/cosmic-unittest/cosmic-unittest-skill-overview.html +746 -0
  57. package/vendor/kingdee-skills/cosmic-unittest/examples/business-test.md +205 -0
  58. package/vendor/kingdee-skills/cosmic-unittest/examples/common-test.md +257 -0
  59. package/vendor/kingdee-skills/cosmic-unittest/examples/formplugin-test.md +560 -0
  60. package/vendor/kingdee-skills/cosmic-unittest/examples/op-plugin-test.md +231 -0
  61. package/vendor/kingdee-skills/cosmic-unittest/examples/validator-test.md +232 -0
  62. package/vendor/kingdee-skills/cosmic-unittest/patterns/business-helper.md +184 -0
  63. package/vendor/kingdee-skills/cosmic-unittest/patterns/common-module.md +355 -0
  64. package/vendor/kingdee-skills/cosmic-unittest/patterns/convert-plugin.md +130 -0
  65. package/vendor/kingdee-skills/cosmic-unittest/patterns/formplugin.md +235 -0
  66. package/vendor/kingdee-skills/cosmic-unittest/patterns/op-plugin.md +226 -0
  67. package/vendor/kingdee-skills/cosmic-unittest/patterns/validator.md +206 -0
  68. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/SKILL.md +674 -0
  69. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/advanced-scenario-checklist.md +307 -0
  70. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/algox-performance-checklist.md +129 -0
  71. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/coding-standard-checklist.md +491 -0
  72. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/cosmic-api-checklist.md +285 -0
  73. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-access-checklist.md +261 -0
  74. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-transaction-checklist.md +390 -0
  75. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/domain-logic-checklist.md +295 -0
  76. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/form-plugin-checklist.md +508 -0
  77. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/infra-checklist.md +254 -0
  78. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ksql-checklist.md +305 -0
  79. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/lifecycle-checklist.md +298 -0
  80. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/operation-plugin-checklist.md +442 -0
  81. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/test-mock-checklist.md +120 -0
  82. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ui-performance-checklist.md +320 -0
  83. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/pattern-matcher.py +336 -0
  84. package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/review-score-calculator.py +121 -0
  85. package/vendor/kingdee-skills/ok-cosmic/CHANGELOG.md +295 -0
  86. package/vendor/kingdee-skills/ok-cosmic/README.md +460 -0
  87. package/vendor/kingdee-skills/ok-cosmic/SKILL.md +287 -0
  88. package/vendor/kingdee-skills/ok-cosmic/agents/openai.yaml +17 -0
  89. package/vendor/kingdee-skills/ok-cosmic/assets/BatchImportPluginTemplate.java +93 -0
  90. package/vendor/kingdee-skills/ok-cosmic/assets/BillPlugInTemplate.java +156 -0
  91. package/vendor/kingdee-skills/ok-cosmic/assets/ConvertPlugInTemplate.java +255 -0
  92. package/vendor/kingdee-skills/ok-cosmic/assets/FormPluginTemplate.java +597 -0
  93. package/vendor/kingdee-skills/ok-cosmic/assets/IWorkflowPluginTemplate.java +91 -0
  94. package/vendor/kingdee-skills/ok-cosmic/assets/ListPluginTemplate.java +194 -0
  95. package/vendor/kingdee-skills/ok-cosmic/assets/OpPluginTemplate.java +201 -0
  96. package/vendor/kingdee-skills/ok-cosmic/assets/OpenApiControllerTemplate.java +103 -0
  97. package/vendor/kingdee-skills/ok-cosmic/assets/PrintPluginTemplate.java +95 -0
  98. package/vendor/kingdee-skills/ok-cosmic/assets/ReportFormPluginTemplate.java +257 -0
  99. package/vendor/kingdee-skills/ok-cosmic/assets/ReportListDataPluginTemplate.java +70 -0
  100. package/vendor/kingdee-skills/ok-cosmic/assets/StandardTreeListPluginTemplate.java +130 -0
  101. package/vendor/kingdee-skills/ok-cosmic/assets/TaskTemplate.java +80 -0
  102. package/vendor/kingdee-skills/ok-cosmic/assets/TreeListPluginTemplate.java +152 -0
  103. package/vendor/kingdee-skills/ok-cosmic/assets/WriteBackPlugInTemplate.java +286 -0
  104. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/attachment/AttachmentUploadBindSample.java +93 -0
  105. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/BotpTracePushSample.java +168 -0
  106. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/SampleConvertPlugin.java +223 -0
  107. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/cache/SampleCacheUsage.java +218 -0
  108. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/concurrent/SampleThreadPoolBatch.java +156 -0
  109. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectCrudSample.java +205 -0
  110. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectOpsSample.java +100 -0
  111. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/BeforeOperationConfirmSample.java +217 -0
  112. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ConfirmDialogSample.java +131 -0
  113. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/EntryRowCalculateSample.java +116 -0
  114. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/F7FilterSample.java +134 -0
  115. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/GetAndSetValueSample.java +176 -0
  116. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/HyperlinkJumpSample.java +124 -0
  117. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/OpenBillModalSample.java +253 -0
  118. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ReturnParentDataSample.java +295 -0
  119. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/TreeControlSample.java +140 -0
  120. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ViewControlOpsSample.java +132 -0
  121. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPluginBasicSample.java +170 -0
  122. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPreOpenFilterSample.java +68 -0
  123. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/message/MessageNotifySample.java +95 -0
  124. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/SampleMQConsumer.java +198 -0
  125. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/sample_mq.xml +15 -0
  126. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OpAddValidatorsSample.java +137 -0
  127. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OperationOptionBridgeSample.java +228 -0
  128. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/package-info.java +19 -0
  129. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BaseDataQuerySample.java +194 -0
  130. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BatchQuerySample.java +368 -0
  131. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/DataSetQueryStatSample.java +131 -0
  132. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportFormPlugin.java +179 -0
  133. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportListDataPlugin.java +616 -0
  134. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/snippets-guide.md +64 -0
  135. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/task/ScheduleTaskSample.java +160 -0
  136. package/vendor/kingdee-skills/ok-cosmic/assets/snippets/workflow/SampleWorkflowPlugin.java +302 -0
  137. package/vendor/kingdee-skills/ok-cosmic/manifest.json +78 -0
  138. package/vendor/kingdee-skills/ok-cosmic/ok-cosmic-intro.html +903 -0
  139. package/vendor/kingdee-skills/ok-cosmic/references/adv/attachment-api.md +114 -0
  140. package/vendor/kingdee-skills/ok-cosmic/references/adv/botp-convert.md +98 -0
  141. package/vendor/kingdee-skills/ok-cosmic/references/adv/dynamic-object.md +113 -0
  142. package/vendor/kingdee-skills/ok-cosmic/references/adv/entity-metadata.md +123 -0
  143. package/vendor/kingdee-skills/ok-cosmic/references/adv/event-lifecycle.md +184 -0
  144. package/vendor/kingdee-skills/ok-cosmic/references/adv/flex-prop.md +114 -0
  145. package/vendor/kingdee-skills/ok-cosmic/references/adv/form-utils.md +133 -0
  146. package/vendor/kingdee-skills/ok-cosmic/references/adv/operate-chain.md +159 -0
  147. package/vendor/kingdee-skills/ok-cosmic/references/adv/plugin-base.md +218 -0
  148. package/vendor/kingdee-skills/ok-cosmic/references/adv/query-dataset.md +149 -0
  149. package/vendor/kingdee-skills/ok-cosmic/references/adv/request-context.md +88 -0
  150. package/vendor/kingdee-skills/ok-cosmic/references/adv/view-handler.md +157 -0
  151. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-bill.md +76 -0
  152. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-botp.md +70 -0
  153. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-form.md +165 -0
  154. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-import.md +69 -0
  155. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-list.md +227 -0
  156. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-openapi.md +112 -0
  157. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-operation.md +135 -0
  158. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-print.md +65 -0
  159. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-data.md +64 -0
  160. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-form.md +90 -0
  161. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-task.md +62 -0
  162. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-tree-list.md +71 -0
  163. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-workflow.md +82 -0
  164. package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-writeback.md +71 -0
  165. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-algo.md +67 -0
  166. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-cache.md +63 -0
  167. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-model-svc.md +82 -0
  168. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-object.md +70 -0
  169. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-entity-model.md +61 -0
  170. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-exception.md +64 -0
  171. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-file.md +63 -0
  172. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-id.md +47 -0
  173. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-lock.md +61 -0
  174. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-log.md +63 -0
  175. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-network-control.md +70 -0
  176. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-orm-access.md +78 -0
  177. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-request-context.md +62 -0
  178. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-threadpool.md +63 -0
  179. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-tx.md +64 -0
  180. package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-utils.md +67 -0
  181. package/vendor/kingdee-skills/ok-cosmic/requirements.txt +2 -0
  182. package/vendor/kingdee-skills/ok-cosmic/rules/a-layer-rules.json +24 -0
  183. package/vendor/kingdee-skills/ok-cosmic/rules/anti-patterns.md +48 -0
  184. package/vendor/kingdee-skills/ok-cosmic/rules/cheat-sheet.md +256 -0
  185. package/vendor/kingdee-skills/ok-cosmic/rules/coding-preferences.md +140 -0
  186. package/vendor/kingdee-skills/ok-cosmic/rules/constraints.md +61 -0
  187. package/vendor/kingdee-skills/ok-cosmic/rules/decision-matrix.md +222 -0
  188. package/vendor/kingdee-skills/ok-cosmic/rules/intent-routing.md +94 -0
  189. package/vendor/kingdee-skills/ok-cosmic/rules/platform-baseline.md +69 -0
  190. package/vendor/kingdee-skills/ok-cosmic/rules/post-check.md +109 -0
  191. package/vendor/kingdee-skills/ok-cosmic/scripts/config_loader.py +204 -0
  192. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-api-knowledge.py +910 -0
  193. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-basedata-query.py +359 -0
  194. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-config-check.py +181 -0
  195. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-extpoints-query.py +389 -0
  196. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-form-metadata.py +856 -0
  197. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-check.py +262 -0
  198. package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-lint.py +293 -0
  199. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/__init__.py +2 -0
  200. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/base.py +393 -0
  201. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/resource_check.py +176 -0
  202. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/scene_check.py +375 -0
  203. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/style_check.py +434 -0
  204. package/vendor/kingdee-skills/ok-cosmic/scripts/lint/verify_check.py +36 -0
  205. package/vendor/kingdee-skills/ok-cosmic/scripts/route_client.py +186 -0
  206. package/vendor/kingdee-skills/ok-cosmic/scripts/script_utils.py +40 -0
  207. package/vendor/kingdee-skills/ok-cosmic/scripts/sqlite_cache.py +142 -0
  208. package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-commons.jar +0 -0
  209. package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-features.jar +0 -0
  210. package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic-docs.db +0 -0
  211. package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic.json +13 -0
  212. package/vendor/kingdee-skills/ok-cosmic/setup/setup-mac.sh +18 -0
  213. package/vendor/kingdee-skills/ok-cosmic/setup/setup-windows.bat +53 -0
  214. package/vendor/kingdee-skills/ok-cosmic/setup/setup.jar +0 -0
  215. package/vendor/kingdee-skills/ok-ksql/SKILL.md +81 -0
  216. package/vendor/kingdee-skills/ok-ksql/agents/openai.yaml +7 -0
  217. package/vendor/kingdee-skills/ok-ksql/manifest.json +14 -0
  218. package/vendor/kingdee-skills/ok-ksql/references/ksql-datafix.md +452 -0
  219. package/vendor/kingdee-skills/ok-ksql/scripts/ksql_lint.py +363 -0
@@ -0,0 +1,597 @@
1
+ package kd.cd.common;
2
+
3
+ import kd.bos.bill.OperationStatus;
4
+ import kd.bos.dataentity.OperateOption;
5
+ import kd.bos.dataentity.entity.DynamicObject;
6
+ import kd.bos.dataentity.resource.ResManager;
7
+ import kd.bos.dataentity.serialization.SerializationUtils;
8
+ import kd.bos.entity.datamodel.events.AfterAddRowEventArgs;
9
+ import kd.bos.entity.datamodel.events.AfterDeleteEntryEventArgs;
10
+ import kd.bos.entity.datamodel.events.AfterDeleteRowEventArgs;
11
+ import kd.bos.entity.datamodel.events.BizDataEventArgs;
12
+ import kd.bos.entity.datamodel.events.PropertyChangedArgs;
13
+ import kd.bos.entity.operate.result.OperationResult;
14
+ import kd.bos.form.CloseCallBack;
15
+ import kd.bos.form.ConfirmCallBackListener;
16
+ import kd.bos.form.FormShowParameter;
17
+ import kd.bos.form.IFormView;
18
+ import kd.bos.form.MessageBoxOptions;
19
+ import kd.bos.form.MessageBoxResult;
20
+ import kd.bos.form.ShowType;
21
+ import kd.bos.form.control.events.BeforeItemClickEvent;
22
+ import kd.bos.form.control.events.ItemClickEvent;
23
+ import kd.bos.form.events.AfterDoOperationEventArgs;
24
+ import kd.bos.form.events.BeforeClosedEvent;
25
+ import kd.bos.form.events.BeforeDoOperationEventArgs;
26
+ import kd.bos.form.events.ClosedCallBackEvent;
27
+ import kd.bos.form.events.MessageBoxClosedEvent;
28
+ import kd.bos.form.events.PreOpenFormEventArgs;
29
+ import kd.bos.form.field.events.BeforeF7SelectEvent;
30
+ import kd.bos.form.operate.AbstractOperate;
31
+ import kd.bos.list.ListShowParameter;
32
+ import kd.bos.orm.query.QCP;
33
+ import kd.bos.orm.query.QFilter;
34
+ import kd.cd.common.form.FormUtils;
35
+ import kd.cd.common.form.ShowParameterUtils;
36
+ import kd.cd.common.plugin.AbstractFormPluginExt;
37
+ import kd.cd.common.util.DynamicObjectUtils;
38
+ import kd.cd.core.util.CharSequenceUtils;
39
+ import kd.cd.core.util.CollectionUtils;
40
+
41
+ import java.util.EventObject;
42
+ import java.util.List;
43
+ import java.util.Set;
44
+
45
+ /**
46
+ * 表单/单据/基础资料插件骨架模板。
47
+ * 该类仅用于示例写法,生成后请按实际业务删除无用事件并替换占位常量。
48
+ * <p>
49
+ * 低频事件(分录移动/置顶/拖拽/合计、导入、定时器、自定义事件等)已省略,
50
+ * 需要时请查阅 references/base/plugin/plugin-form.md 获取方法签名。
51
+ *
52
+ * <pre>
53
+ * ═══ 方法索引(按需跳转,无需通读) ═══
54
+ *
55
+ * ─ 生命周期事件
56
+ * initialize() — 初始化变量/缓存
57
+ * registerListener() — 注册控件/菜单/F7 监听
58
+ * preOpenForm() — 表单打开前参数准备
59
+ * beforeClosed() — 关闭前校验/回传数据
60
+ *
61
+ * ─ 数据创建/绑定事件
62
+ * createNewData() — 新增数据包创建前
63
+ * afterCreateNewData() — 新增后设置默认值
64
+ * beforeBindData() — 数据绑定前(禁止 setValue/UI 控制)
65
+ * afterBindData() — 数据绑定后,设置界面状态
66
+ * afterCopyData() — 复制后清理字段
67
+ *
68
+ * ─ 菜单/按钮事件
69
+ * beforeItemClick() — 菜单点击前校验
70
+ * itemClick() — 菜单点击后处理(弹窗/确认框)
71
+ *
72
+ * ─ 操作事件
73
+ * beforeDoOperation() — 保存/提交/审核前校验
74
+ * afterDoOperation() — 操作完成后处理
75
+ *
76
+ * ─ 字段变化事件
77
+ * propertyChanged() — 字段联动/级联更新
78
+ *
79
+ * ─ 回调/弹框事件
80
+ * confirmCallBack() — 确认框 Yes/No 回调
81
+ * closedCallBack() — 子页面关闭回调
82
+ *
83
+ * ─ F7 过滤事件
84
+ * beforeF7Select() — F7 下拉添加过滤条件
85
+ *
86
+ * ─ 分录增删改事件
87
+ * afterAddRow() — 新增分录行后初始化
88
+ * afterDeleteRow() — 删除分录行后清理
89
+ * afterDeleteEntry() — 清空分录后处理
90
+ * </pre>
91
+ *
92
+ * @template FormPluginTemplate
93
+ * @extends AbstractFormPluginExt (kd.cd.common.plugin)
94
+ * @highFreqEvents afterBindData, propertyChanged, beforeDoOperation, afterDoOperation, itemClick, closedCallBack
95
+ * @medFreqEvents registerListener, beforeF7Select, confirmCallBack, afterCreateNewData, afterAddRow, beforeClosed
96
+ * @relatedDocs references/adv/plugin-base.md, references/base/plugin/plugin-form.md
97
+ */
98
+ public class FormPluginTemplate extends AbstractFormPluginExt {
99
+
100
+
101
+ // 占位常量:复制模板后请统一替换为业务真实 key。
102
+ private static final String KEY_1 = "key1";
103
+ private static final String KEY_2 = "key2";
104
+ private static final String KEY_3 = "key3";
105
+ private static final String TB_MAIN = "tbmain";
106
+ private static final String TB_MAIN_1 = "tbmain1";
107
+ private static final String TB_MAIN_2 = "tbmain2";
108
+ private static final String ENTRY_KEY_1 = "entrykey1";
109
+ private static final String ENTRY_KEY_2 = "entrykey2";
110
+ private static final String FORM_ID_F7 = "billformid1";
111
+ private static final String FORM_ID_MODAL = "billformid2";
112
+ private static final String CLOSE_ACTION_ID = "actionid";
113
+ private static final String CONFIRM_CALLBACK_ID = "callbackid1";
114
+ private static final String CUSTOM_PARAM_KEY = "key";
115
+ private static final String CUSTOM_PARAM_VALUE = "val2";
116
+ private static final String PAGE_CACHE_SUBMIT_FLAG = "submitflag";
117
+ private static final String PAGE_CACHE_OPERATE_KEY = "operatekey";
118
+ private static final String RETURN_DATA_CONTINUE = "continueoperate";
119
+ private static final String FIELD_BILL_NO = "billno";
120
+ private static final String FILTER_VALUE_A = "A";
121
+ private static final String OPTION_VAR_VALUE = "value1";
122
+ private static final String RES_APP_ID = "kd-cd-common-template";
123
+
124
+ // ===== 生命周期事件 =====
125
+
126
+ /**
127
+ * 触发时机: 插件对象初始化时,在 registerListener 之前。
128
+ * 参数要点: 无参数。
129
+ * 典型用途: 初始化轻量化变量、缓存,避免在各事件中重复查询。
130
+ *
131
+ */
132
+
133
+ @Override
134
+ public void initialize() {
135
+ super.initialize();
136
+ this.getPageCache().put(PAGE_CACHE_SUBMIT_FLAG, "false");
137
+ }
138
+
139
+ /**
140
+ * 触发时机: 表单初始化完毕,所有事件监听注册前。
141
+ * 参数要点:
142
+ * - EventObject e: 通用事件参数。
143
+ * 典型用途: 注册表单控件、菜单、F7(基础资料/引用数据选择控件)等的事件监听。
144
+ *
145
+ */
146
+
147
+ @Override
148
+ public void registerListener(EventObject e) {
149
+ super.registerListener(e);
150
+ // 注册按钮、菜单、F7(基础资料/引用数据选择控件)等监听。
151
+ this.addBeforeF7SelectListeners(KEY_1, KEY_2, KEY_3);
152
+ this.addItemClickListeners(TB_MAIN, TB_MAIN_1, TB_MAIN_2);
153
+ this.addClickListeners(KEY_1, KEY_2, KEY_3);
154
+ this.addHyperClickListeners(KEY_1, KEY_2, KEY_3);
155
+ this.addEntryRowClickListeners(ENTRY_KEY_1, ENTRY_KEY_2, KEY_3);
156
+ }
157
+
158
+ /**
159
+ * 触发时机: 表单打开前,参数准备阶段。
160
+ * 参数要点:
161
+ * - PreOpenFormEventArgs e: 包含表单打开参数。
162
+ * - e.getFormShowParameter(): 获取和修改表单打开参数。
163
+ * - e.getFormShowParameter().getParentPageId(): 获取父页面 ID。
164
+ * 典型用途: 调整表单打开参数、访问父页面数据进行参数传递。
165
+ *
166
+ */
167
+
168
+ @Override
169
+ public void preOpenForm(PreOpenFormEventArgs e) {
170
+ super.preOpenForm(e);
171
+ // 打开前参数处理示例。
172
+ FormShowParameter fsp = e.getFormShowParameter();
173
+ String parentPageId = fsp.getParentPageId();
174
+ IFormView parentView = FormUtils.getViewByPageId(parentPageId);
175
+ if (parentView != null) {
176
+ Object value = parentView.getModel().getValue(KEY_1);
177
+ fsp.setCustomParam(CUSTOM_PARAM_KEY, value);
178
+ }
179
+ }
180
+
181
+ /**
182
+ * 触发时机: 表单关闭前,用户点击关闭按钮或程序调用关闭前。
183
+ * 参数要点:
184
+ * - BeforeClosedEvent e: 关闭前事件参数。
185
+ * - e.setCancel(true): 取消关闭操作。
186
+ * 典型用途: 关闭前校验、返回数据到父页面、触发父页面操作。
187
+ *
188
+ */
189
+
190
+ @Override
191
+ public void beforeClosed(BeforeClosedEvent e) {
192
+ super.beforeClosed(e);
193
+ if ("true".equals(this.getView().getPageCache().get(PAGE_CACHE_SUBMIT_FLAG))) {
194
+ this.getView().returnDataToParent(RETURN_DATA_CONTINUE);
195
+ return;
196
+ }
197
+ }
198
+
199
+ // ===== 数据创建/绑定事件 =====
200
+
201
+ /**
202
+ * 触发时机: 新增表单时,数据包创建前(可自定义数据包构建逻辑)。
203
+ * 参数要点:
204
+ * - BizDataEventArgs e: 业务数据事件参数。
205
+ * 典型用途: 自定义创建新增数据包的逻辑,如加载模板数据。
206
+ *
207
+ */
208
+
209
+ @Override
210
+ public void createNewData(BizDataEventArgs e) {
211
+ super.createNewData(e);
212
+ Object value = getView().getFormShowParameter().getCustomParams().get(CUSTOM_PARAM_KEY);
213
+ if (value != null) {
214
+ getView().getPageCache().put(CUSTOM_PARAM_KEY, String.valueOf(value));
215
+ }
216
+ }
217
+
218
+ /**
219
+ * 触发时机: 新增表单数据初始化完毕后(与 afterLoadData 互斥)。
220
+ * 参数要点:
221
+ * - EventObject e: 通用事件参数。
222
+ * 差异说明:
223
+ * - afterCreateNewData: 新增模式,用于设置默认值。
224
+ * - afterLoadData: 修改/查看模式,数据来自 DB。
225
+ * - 两个事件互斥,仅触发其一。
226
+ * 典型用途: 设置字段默认值、初始化分录数据。
227
+ *
228
+ */
229
+
230
+ @Override
231
+ public void afterCreateNewData(EventObject e) {
232
+ super.afterCreateNewData(e);
233
+ getModel().setValue(KEY_1, getView().getPageCache().get(CUSTOM_PARAM_KEY));
234
+ getModel().setValue(KEY_2, FILTER_VALUE_A);
235
+ List<DynamicObject> selectRowsEntity = getEntrySelectRowsEntity(ENTRY_KEY_1);
236
+ if (CollectionUtils.isNotEmpty(selectRowsEntity)) {
237
+ Set<Object> pks = DynamicObjectUtils.setOf(selectRowsEntity, "id");
238
+ getView().getPageCache().put("selectedEntryIds", SerializationUtils.toJsonString(pks));
239
+ }
240
+ }
241
+
242
+ /**
243
+ * 触发时机: 数据绑定到表单前。
244
+ * 参数要点:
245
+ * - EventObject e: 通用事件参数。
246
+ * 典型用途: 数据绑定前的准备工作,如日志记录、状态标记。
247
+ * 注意: 禁止在此事件中修改数据对象(setValue/分录增删)和做 UI 控制(setEnable/setVisible);
248
+ * 界面控制请放到 afterBindData,数据变更请放到 createNewData / propertyChanged 等正确事件。
249
+ *
250
+ */
251
+
252
+ @Override
253
+ public void beforeBindData(EventObject e) {
254
+ super.beforeBindData(e);
255
+ // 仅做轻量化准备,禁止 setValue / setEnable / setVisible。
256
+ log.info("beforeBindData: billNo={}", getModel().getValue(FIELD_BILL_NO));
257
+ }
258
+
259
+ /**
260
+ * 触发时机: 数据绑定到表单后,表单界面渲染完成。
261
+ * 参数要点:
262
+ * - EventObject e: 通用事件参数。
263
+ * 典型用途: 设置字段可见/隐藏、可编辑/锁定状态,初始化动态界面。
264
+ *
265
+ */
266
+
267
+ @Override
268
+ public void afterBindData(EventObject e) {
269
+ super.afterBindData(e);
270
+ // 设置可见/隐藏状态。
271
+ getView().setVisible(true, KEY_1, KEY_2, KEY_3);
272
+ // 设置可编辑/锁定状态。
273
+ getView().setEnable(false, KEY_1, KEY_2, KEY_3);
274
+ }
275
+
276
+
277
+ /**
278
+ * 触发时机: 单据复制后,新数据包初始化完毕。
279
+ * 参数要点:
280
+ * - EventObject e: 通用事件参数。
281
+ * 典型用途: 复制后清理字段(如单号、日期等不应被复制的字段)。
282
+ *
283
+ */
284
+
285
+ @Override
286
+ public void afterCopyData(EventObject e) {
287
+ super.afterCopyData(e);
288
+ getModel().setValue(KEY_1, null);
289
+ getModel().setValue(KEY_2, FILTER_VALUE_A);
290
+ }
291
+
292
+ // ===== 菜单/按钮事件 =====
293
+
294
+ /**
295
+ * 触发时机: 用户点击菜单项前(系统的菜单点击前置校验)。
296
+ * 参数要点:
297
+ * - BeforeItemClickEvent evt: 包含菜单项信息。
298
+ * - evt.getItemKey(): 获取菜单项标识。
299
+ * - evt.setCancel(true): 取消菜单点击。
300
+ * 典型用途: 菜单点击前校验,必要时取消菜单动作。
301
+ *
302
+ */
303
+
304
+ @Override
305
+ public void beforeItemClick(BeforeItemClickEvent evt) {
306
+ super.beforeItemClick(evt);
307
+ String itemKey = evt.getItemKey();
308
+ if (KEY_1.equals(itemKey)) {
309
+ Object currentValue = getModel().getValue(KEY_1);
310
+ if (currentValue == null) {
311
+ evt.setCancel(true);
312
+ getView().showErrorNotification(String.format(
313
+ ResManager.loadKDString("%s 不能为空", "FormPluginTemplate_0", RES_APP_ID),
314
+ KEY_1
315
+ ));
316
+ }
317
+ } else if (KEY_2.equals(itemKey)) {
318
+ getView().getPageCache().put("lastMenuKey", KEY_2);
319
+ }
320
+ }
321
+
322
+ /**
323
+ * 触发时机: 用户点击菜单项后(菜单点击已执行,触发自定义逻辑)。
324
+ * 参数要点:
325
+ * - ItemClickEvent evt: 包含菜单项信息。
326
+ * - evt.getItemKey(): 获取菜单项标识。
327
+ * 典型用途: 处理菜单项的点击动作,如打开表单、列表、确认框等。
328
+ *
329
+ */
330
+
331
+ @Override
332
+ public void itemClick(ItemClickEvent evt) {
333
+ super.itemClick(evt);
334
+ String itemKey = evt.getItemKey();
335
+ if (KEY_1.equals(itemKey)) {
336
+ // f7弹窗
337
+ ListShowParameter lsp = ShowParameterUtils.getF7List(FORM_ID_F7, true);
338
+ getView().showForm(lsp);
339
+ // 普通单据/动态表单弹窗
340
+ FormShowParameter fsp = ShowParameterUtils.getForm(FORM_ID_MODAL, OperationStatus.ADDNEW, ShowType.Modal, "500px", "300px");
341
+ fsp.setCustomParam(CUSTOM_PARAM_KEY, CUSTOM_PARAM_VALUE);
342
+ fsp.setCloseCallBack(new CloseCallBack(this, CLOSE_ACTION_ID));
343
+ getView().showForm(fsp);
344
+ // 确认框弹窗
345
+ ConfirmCallBackListener confirmCallBackListener = new ConfirmCallBackListener(CONFIRM_CALLBACK_ID, this);
346
+ this.getView().showConfirm(
347
+ ResManager.loadKDString("xxxxxx,请确认是否使用xxx功能", "FormPluginTemplate_1", RES_APP_ID),
348
+ MessageBoxOptions.YesNo,
349
+ confirmCallBackListener
350
+ );
351
+ } else if (KEY_2.equals(itemKey)) {
352
+ getView().showTipNotification(String.format(
353
+ ResManager.loadKDString("点击了菜单:%s", "FormPluginTemplate_2", RES_APP_ID),
354
+ KEY_2
355
+ ));
356
+ }
357
+ }
358
+
359
+
360
+
361
+ // ===== 操作事件 =====
362
+
363
+ /**
364
+ * 触发时机: 用户点击 save、submit、audit 等操作前(系统校验前)。
365
+ * 参数要点:
366
+ * - BeforeDoOperationEventArgs args: 操作前置事件参数。
367
+ * - getOpKey(args): 获取操作类型("save"、"submit"、"audit"、"reject" 等)。
368
+ * - getOperate(args): 获取操作对象。
369
+ * - getValue(fieldKey): 获取字段值。
370
+ * - args.setCancel(true): 取消操作。
371
+ * 典型用途: 业务前置校验、设置操作参数。
372
+ * 建议: 简单校验用此事件;复杂逻辑优先使用校验器插件。
373
+ *
374
+ */
375
+
376
+ @Override
377
+ public void beforeDoOperation(BeforeDoOperationEventArgs args) {
378
+ super.beforeDoOperation(args);
379
+ String opKey = getOpKey(args);
380
+ if (KEY_1.equals(opKey)) {
381
+ if (getValue(KEY_1) == null) {
382
+ args.setCancel(true);
383
+ getView().showErrorNotification(String.format(
384
+ ResManager.loadKDString("%s 未填写,不能执行操作", "FormPluginTemplate_3", RES_APP_ID),
385
+ KEY_1
386
+ ));
387
+ }
388
+ } else if (KEY_2.equals(opKey)) {
389
+ AbstractOperate operate = getOperate(args);
390
+ OperateOption option = operate.getOption();
391
+ option.setVariableValue(KEY_3, OPTION_VAR_VALUE);
392
+ getView().getPageCache().put(PAGE_CACHE_OPERATE_KEY, opKey);
393
+ }
394
+ }
395
+
396
+ /**
397
+ * 触发时机: 表单操作(save、submit、audit 等)完成后。
398
+ * 参数要点:
399
+ * - AfterDoOperationEventArgs args: 操作后置事件参数。
400
+ * - getOpKey(args): 获取操作类型。
401
+ * - args.getOperationResult(): 获取操作结果对象。
402
+ * - result.isSuccess(): 判断操作是否成功。
403
+ * 典型用途: 处理操作完成后的逻辑,如刷新列表、关闭表单、调用外部系统。
404
+ *
405
+ */
406
+
407
+ @Override
408
+ public void afterDoOperation(AfterDoOperationEventArgs args) {
409
+ super.afterDoOperation(args);
410
+ String opKey = getOpKey(args);
411
+ OperationResult operationResult = args.getOperationResult();
412
+ if (KEY_1.equals(opKey) && operationResult.isSuccess()) {
413
+ getView().showSuccessNotification(String.format(
414
+ ResManager.loadKDString("操作成功:%s", "FormPluginTemplate_4", RES_APP_ID),
415
+ KEY_1
416
+ ));
417
+ } else if (KEY_2.equals(opKey) && operationResult.isSuccess()) {
418
+ getView().showTipNotification(String.format(
419
+ ResManager.loadKDString("操作完成:%s", "FormPluginTemplate_5", RES_APP_ID),
420
+ KEY_2
421
+ ));
422
+ }
423
+ }
424
+
425
+ // ===== 字段变化事件 =====
426
+
427
+ /**
428
+ * 触发时机: 用户修改表单字段值后(字段值已更新到模型)。
429
+ * 参数要点:
430
+ * - e.getChangeSet() 返回发生改变的数据。通常本属性只返回一条数据,当批量触发字段值改变事件时,本属性会返回多条数据。
431
+ * - PropertyChangedArgs e: 属性变更事件参数。
432
+ * - ChangeData[] changeSet = e.getChangeSet(): 获取变更集合(通常一条,批量触发时可能多条)。
433
+ * - String fieldKey = e.getProperty().getName(): 获取变更字段标识。
434
+ * - int rowIndex = changeSet[0].getRowIndex(): 获取变更行号。
435
+ * - Object newValue = changeSet[0].getNewValue(): 获取新值。
436
+ * - Object oldValue = changeSet[0].getOldValue(): 获取旧值。
437
+ * 典型用途: 字段联动、级联更新、计算字段。
438
+ * 建议: 简单联动优先用公式;复杂逻辑才在此处理;保持轻量以避免重查询。
439
+ *
440
+ */
441
+
442
+ @Override
443
+ public void propertyChanged(PropertyChangedArgs e) {
444
+ super.propertyChanged(e);
445
+ // 字段联动:值改变后触发(保持轻量,避免重查询)。
446
+ // 当前分录变更行 index。
447
+ String name = e.getProperty().getName();
448
+ int changedRowIndex = getChangedRowIndex(e);
449
+ // 父分录变更行 index。
450
+ int parentChangedRowIndex = getParentChangedRowIndex(e);
451
+ // 变更后值(按需使用)。
452
+ Object changedNewValue = getChangedNewValue(e);
453
+ // 变更前值(按需使用)。
454
+ Object changedOldValue = getChangedOldValue(e);
455
+ if (KEY_1.equals(name)) {
456
+ Object value = getValue(KEY_1, changedRowIndex);
457
+ getModel().setValue(KEY_2, value, parentChangedRowIndex);
458
+ } else if (KEY_2.equals(name)) {
459
+ getView().showTipNotification(String.format(
460
+ ResManager.loadKDString("字段 %1$s 已变更,新值=%2$s, 旧值=%3$s", "FormPluginTemplate_6", RES_APP_ID),
461
+ KEY_2,
462
+ changedNewValue,
463
+ changedOldValue
464
+ ));
465
+ }
466
+ }
467
+
468
+ // ===== 回调/弹框事件 =====
469
+
470
+ /**
471
+ * 触发时机: 用户在确认框(showConfirm)中选择 Yes 或 No 时。
472
+ * 参数要点:
473
+ * - MessageBoxClosedEvent evt: 消息框关闭事件参数。
474
+ * - evt.getCallBackId(): 获取回调 ID。
475
+ * - evt.getResult(): 获取用户选择结果(Yes/No)。
476
+ * 典型用途: 处理确认框的用户选择结果。
477
+ *
478
+ */
479
+
480
+ @Override
481
+ public void confirmCallBack(MessageBoxClosedEvent evt) {
482
+ super.confirmCallBack(evt);
483
+ String callBackId = evt.getCallBackId();
484
+ if (CONFIRM_CALLBACK_ID.equals(callBackId)) {
485
+ if (MessageBoxResult.Yes.equals(evt.getResult())) {
486
+ getView().showSuccessNotification(ResManager.loadKDString("用户已确认执行后续逻辑", "FormPluginTemplate_7", RES_APP_ID));
487
+ }
488
+ }
489
+ }
490
+
491
+ /**
492
+ * 触发时机: 子表单/列表页面关闭时(被 showForm 打开的页面关闭)。
493
+ * 参数要点:
494
+ * - ClosedCallBackEvent e: 关闭回调事件参数。
495
+ * - e.getActionId(): 获取回调 ID。
496
+ * - e.getReturnData(): 获取子页面返回的数据。
497
+ * 典型用途: 处理子页面关闭后的逻辑,获取子页面返回的数据。
498
+ *
499
+ */
500
+
501
+ @Override
502
+ public void closedCallBack(ClosedCallBackEvent e) {
503
+ super.closedCallBack(e);
504
+ // 子页面关闭回调。
505
+ String actionId = e.getActionId();
506
+ if (CLOSE_ACTION_ID.equals(actionId)) {
507
+ this.getView().getPageCache().put(PAGE_CACHE_SUBMIT_FLAG, "false");
508
+ String returnData = (String) e.getReturnData();
509
+ // 字符串判空
510
+ if (CharSequenceUtils.equals(RETURN_DATA_CONTINUE, returnData)) {
511
+ this.getView().getPageCache().put(PAGE_CACHE_SUBMIT_FLAG, "true");
512
+ String operateKey = this.getView().getPageCache().get(PAGE_CACHE_OPERATE_KEY);
513
+ this.getView().invokeOperation(operateKey);
514
+ }
515
+ }
516
+ }
517
+
518
+ // ===== F7 过滤事件 =====
519
+
520
+ /**
521
+ * 触发时机: 用户点击基础资料 F7(基础资料/引用数据选择控件)下拉选择前。
522
+ * 参数要点:
523
+ * - BeforeF7SelectEvent e: F7(基础资料/引用数据选择控件)选择前事件参数。
524
+ * - e.getProperty().getName(): 获取字段标识。
525
+ * - e.getCustomQFilters(): 获取自定义过滤条件列表,可添加新的过滤。
526
+ * 典型用途: 为 F7(基础资料/引用数据选择控件)下拉添加过滤条件(如按部门、组织过滤)。
527
+ *
528
+ */
529
+
530
+ @Override
531
+ public void beforeF7Select(BeforeF7SelectEvent e) {
532
+ super.beforeF7Select(e);
533
+ // F7(基础资料/引用数据选择控件)打开前设置过滤条件。
534
+ String name = e.getProperty().getName();
535
+ if (KEY_1.equals(name)) {
536
+ List<QFilter> customQFilters = e.getCustomQFilters();
537
+ QFilter newFilter = new QFilter(KEY_1, QCP.equals, FILTER_VALUE_A);
538
+ customQFilters.add(newFilter);
539
+ } else if (KEY_2.equals(name)) {
540
+ e.getCustomQFilters().add(new QFilter(KEY_2, QCP.not_equals, "forbid"));
541
+ }
542
+ }
543
+
544
+ // ===== 分录增删改事件 =====
545
+
546
+ /**
547
+ * 触发时机: 用户新增分录行后。
548
+ * 参数要点:
549
+ * - AfterAddRowEventArgs e: 新增行后事件参数。
550
+ * - e.getEntryKey(): 获取分录标识。
551
+ * - e.getRowIndex(): 获取新增行的行号。
552
+ * 典型用途: 新增行后的初始化逻辑(如设置默认值)。
553
+ *
554
+ */
555
+
556
+ @Override
557
+ public void afterAddRow(AfterAddRowEventArgs e) {
558
+ super.afterAddRow(e);
559
+ getModel().setValue(KEY_1, 1, e.getInsertRow());
560
+ getModel().setValue(KEY_2, FILTER_VALUE_A, e.getInsertRow());
561
+ }
562
+
563
+ /**
564
+ * 触发时机: 用户删除分录行后。
565
+ * 参数要点:
566
+ * - AfterDeleteRowEventArgs e: 删除行后事件参数。
567
+ * - e.getRowIndex(): 获取删除行的行号。
568
+ * 典型用途: 删除行后的清理逻辑(如重新计算合计)。
569
+ *
570
+ */
571
+
572
+ @Override
573
+ public void afterDeleteRow(AfterDeleteRowEventArgs e) {
574
+ super.afterDeleteRow(e);
575
+ int[] rowIndexs = e.getRowIndexs();
576
+ getView().showTipNotification(String.format(
577
+ ResManager.loadKDString("已删除了:%s行分录", "FormPluginTemplate_8", RES_APP_ID),
578
+ rowIndexs.length
579
+ ));
580
+ }
581
+
582
+ /**
583
+ * 触发时机: 用户清空分录所有行后。
584
+ * 参数要点:
585
+ * - AfterDeleteEntryEventArgs e: 清空分录后事件参数。
586
+ * - e.getEntryKey(): 获取分录标识。
587
+ * 典型用途: 清空分录后的处理逻辑。
588
+ *
589
+ */
590
+
591
+ @Override
592
+ public void afterDeleteEntry(AfterDeleteEntryEventArgs e) {
593
+ super.afterDeleteEntry(e);
594
+ getModel().setValue(KEY_3, 0);
595
+ }
596
+
597
+ }
@@ -0,0 +1,91 @@
1
+ package kd.cd.common;
2
+
3
+ import kd.bos.workflow.api.AgentExecution;
4
+ import kd.bos.workflow.component.approvalrecord.IApprovalRecordItem;
5
+ import kd.bos.workflow.engine.extitf.IWorkflowPlugin;
6
+ import kd.cd.core.util.CollectionUtils;
7
+
8
+ import java.util.List;
9
+
10
+ /**
11
+ * 工作流插件骨架模板(原生 IWorkflowPlugin)。
12
+ * 该类仅用于示例写法,生成后请按实际业务删除无用方法并替换占位常量。
13
+ */
14
+ public class IWorkflowPluginTemplate implements IWorkflowPlugin {
15
+
16
+ /**
17
+ * 触发时机: 在需要了解当前插件可访问上下文能力时调用。
18
+ * 参数要点: 无入参;仅展示当前插件可通过 this. 访问的方法能力。
19
+ * 典型用途: 作为模板提示,指导在各事件内选择正确的上下文 API。
20
+ */
21
+ private void getContextSample() {
22
+ // execution.getBusinessKey();
23
+ // execution.getEntityNumber();
24
+ // execution.getCurrentFlowElement();
25
+ // execution.getVariable("amount");
26
+ // execution.setVariable("lastNodeName", "财务审核");
27
+ // execution.setAssigneeList(new java.util.ArrayList<>());
28
+ }
29
+
30
+ private static final String VAR_AMOUNT = "amount";
31
+ private static final String VAR_START_USER = "startUserId";
32
+ private static final String VAR_LAST_NODE = "lastNodeName";
33
+
34
+ /**
35
+ * 触发时机: 工作流节点需要计算参与人时。
36
+ * 参数要点: execution 含流程实例、单据、节点、变量等上下文。
37
+ * 典型用途: 根据单据字段、发起人、组织等信息动态返回审批人。
38
+ */
39
+ @Override
40
+ public List<Long> calcUserIds(AgentExecution execution) {
41
+ List<Long> userIds = CollectionUtils.newArrayList();
42
+ Object starter = execution.getVariable(VAR_START_USER);
43
+ if (starter instanceof Number) {
44
+ userIds.add(((Number) starter).longValue());
45
+ }
46
+ return userIds;
47
+ }
48
+
49
+ /**
50
+ * 触发时机: 条件分支判断阶段。
51
+ * 参数要点: execution 可读取流程变量、业务主键与节点信息。
52
+ * 典型用途: 根据金额、组织、单据类型等条件决定是否命中当前分支。
53
+ */
54
+ @Override
55
+ public boolean hasTrueCondition(AgentExecution execution) {
56
+ Object amount = execution.getVariable(VAR_AMOUNT);
57
+ return amount instanceof Number && ((Number) amount).doubleValue() > 100000D;
58
+ }
59
+
60
+ /**
61
+ * 触发时机: 流程节点通知阶段。
62
+ * 参数要点: execution 可访问流程变量、当前节点、业务主键。
63
+ * 典型用途: 同步单据状态、写流程变量、发送外部通知。
64
+ */
65
+ @Override
66
+ public void notify(AgentExecution execution) {
67
+ if (execution.getCurrentFlowElement() != null) {
68
+ execution.setVariable(VAR_LAST_NODE, execution.getCurrentFlowElement().getName());
69
+ }
70
+ }
71
+
72
+ /**
73
+ * 触发时机: 流程撤回时。
74
+ * 参数要点: execution 仍可访问当前流程与业务上下文。
75
+ * 典型用途: 撤回时恢复状态、清理流程变量或做补偿处理。
76
+ */
77
+ @Override
78
+ public void notifyByWithdraw(AgentExecution execution) {
79
+ execution.setVariable(VAR_LAST_NODE, "withdraw");
80
+ }
81
+
82
+ /**
83
+ * 触发时机: 展示审批记录时。
84
+ * 参数要点: item 为当前待格式化的审批记录项。
85
+ * 典型用途: 定制审批记录显示文本、补充节点说明或统一格式。
86
+ */
87
+ @Override
88
+ public IApprovalRecordItem formatFlowRecord(IApprovalRecordItem item) {
89
+ return item;
90
+ }
91
+ }