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.
- package/README.md +358 -0
- package/dist/cli/kcode.d.ts +15 -0
- package/dist/cli/kcode.js +153 -0
- package/dist/cli/main.d.ts +2 -0
- package/dist/cli/main.js +7 -0
- package/docs/KCODE_DISTRIBUTION.md +91 -0
- package/extensions/kingdee-harness.ts +180 -0
- package/extensions/kingdee-header.ts +122 -0
- package/extensions/kingdee-tools.ts +379 -0
- package/knowledge/.backup/v1.0.0/version.json +10 -0
- package/knowledge/cangqiong/product-notes.md +15 -0
- package/knowledge/common/business-flows.md +115 -0
- package/knowledge/common/config-guides.md +110 -0
- package/knowledge/common/error-patterns.md +170 -0
- package/knowledge/common/implementation.md +144 -0
- package/knowledge/cosmic/hard-constraints.md +38 -0
- package/knowledge/cosmic/ksql-datafix.md +34 -0
- package/knowledge/cosmic/platform-baseline.md +32 -0
- package/knowledge/cosmic/plugin-decision-matrix.md +40 -0
- package/knowledge/cosmic/review-checklist.md +40 -0
- package/knowledge/cosmic/unittest.md +35 -0
- package/knowledge/enterprise/api-reference.md +186 -0
- package/knowledge/enterprise/code-patterns.md +217 -0
- package/knowledge/enterprise/plugin-lifecycle.md +188 -0
- package/knowledge/enterprise/tables.json +159 -0
- package/knowledge/flagship/api-reference.md +237 -0
- package/knowledge/flagship/code-patterns.md +246 -0
- package/knowledge/flagship/cosmic-platform-note.md +15 -0
- package/knowledge/flagship/plugin-lifecycle.md +248 -0
- package/knowledge/flagship/tables.json +159 -0
- package/knowledge/version.json +10 -0
- package/knowledge/xinghan/product-notes.md +15 -0
- package/package.json +71 -0
- package/prompts/kd-discuss.md +11 -0
- package/prompts/kd-execute.md +12 -0
- package/prompts/kd-plan.md +12 -0
- package/prompts/kd-ship.md +12 -0
- package/prompts/kd-spec.md +12 -0
- package/prompts/kd-verify.md +12 -0
- package/skills/kd-check/SKILL.md +26 -0
- package/skills/kd-cosmic-dev/SKILL.md +82 -0
- package/skills/kd-cosmic-review/SKILL.md +90 -0
- package/skills/kd-cosmic-unittest/SKILL.md +92 -0
- package/skills/kd-debug/SKILL.md +30 -0
- package/skills/kd-discuss/SKILL.md +24 -0
- package/skills/kd-execute/SKILL.md +22 -0
- package/skills/kd-gen/SKILL.md +34 -0
- package/skills/kd-ksql/SKILL.md +86 -0
- package/skills/kd-plan/SKILL.md +24 -0
- package/skills/kd-ship/SKILL.md +22 -0
- package/skills/kd-spec/SKILL.md +24 -0
- package/skills/kd-verify/SKILL.md +22 -0
- package/themes/kcode-dark.json +81 -0
- package/vendor/kingdee-skills/cosmic-unittest/SKILL.md +788 -0
- package/vendor/kingdee-skills/cosmic-unittest/author-cache.json +5 -0
- package/vendor/kingdee-skills/cosmic-unittest/cosmic-unittest-skill-overview.html +746 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/business-test.md +205 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/common-test.md +257 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/formplugin-test.md +560 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/op-plugin-test.md +231 -0
- package/vendor/kingdee-skills/cosmic-unittest/examples/validator-test.md +232 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/business-helper.md +184 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/common-module.md +355 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/convert-plugin.md +130 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/formplugin.md +235 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/op-plugin.md +226 -0
- package/vendor/kingdee-skills/cosmic-unittest/patterns/validator.md +206 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/SKILL.md +674 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/advanced-scenario-checklist.md +307 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/algox-performance-checklist.md +129 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/coding-standard-checklist.md +491 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/cosmic-api-checklist.md +285 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-access-checklist.md +261 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/data-transaction-checklist.md +390 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/domain-logic-checklist.md +295 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/form-plugin-checklist.md +508 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/infra-checklist.md +254 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ksql-checklist.md +305 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/lifecycle-checklist.md +298 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/operation-plugin-checklist.md +442 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/test-mock-checklist.md +120 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/references/ui-performance-checklist.md +320 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/pattern-matcher.py +336 -0
- package/vendor/kingdee-skills/kingdee-cosmic-reviewer/scripts/review-score-calculator.py +121 -0
- package/vendor/kingdee-skills/ok-cosmic/CHANGELOG.md +295 -0
- package/vendor/kingdee-skills/ok-cosmic/README.md +460 -0
- package/vendor/kingdee-skills/ok-cosmic/SKILL.md +287 -0
- package/vendor/kingdee-skills/ok-cosmic/agents/openai.yaml +17 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/BatchImportPluginTemplate.java +93 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/BillPlugInTemplate.java +156 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ConvertPlugInTemplate.java +255 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/FormPluginTemplate.java +597 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/IWorkflowPluginTemplate.java +91 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ListPluginTemplate.java +194 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/OpPluginTemplate.java +201 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/OpenApiControllerTemplate.java +103 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/PrintPluginTemplate.java +95 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ReportFormPluginTemplate.java +257 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/ReportListDataPluginTemplate.java +70 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/StandardTreeListPluginTemplate.java +130 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/TaskTemplate.java +80 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/TreeListPluginTemplate.java +152 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/WriteBackPlugInTemplate.java +286 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/attachment/AttachmentUploadBindSample.java +93 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/BotpTracePushSample.java +168 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/botp/SampleConvertPlugin.java +223 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/cache/SampleCacheUsage.java +218 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/concurrent/SampleThreadPoolBatch.java +156 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectCrudSample.java +205 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/data/DynamicObjectOpsSample.java +100 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/BeforeOperationConfirmSample.java +217 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ConfirmDialogSample.java +131 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/EntryRowCalculateSample.java +116 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/F7FilterSample.java +134 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/GetAndSetValueSample.java +176 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/HyperlinkJumpSample.java +124 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/OpenBillModalSample.java +253 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ReturnParentDataSample.java +295 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/TreeControlSample.java +140 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/form/ViewControlOpsSample.java +132 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPluginBasicSample.java +170 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/list/ListPreOpenFilterSample.java +68 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/message/MessageNotifySample.java +95 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/SampleMQConsumer.java +198 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/mq/sample_mq.xml +15 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OpAddValidatorsSample.java +137 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/operation/OperationOptionBridgeSample.java +228 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/package-info.java +19 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BaseDataQuerySample.java +194 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/BatchQuerySample.java +368 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/query/DataSetQueryStatSample.java +131 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportFormPlugin.java +179 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/report/SampleReportListDataPlugin.java +616 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/snippets-guide.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/task/ScheduleTaskSample.java +160 -0
- package/vendor/kingdee-skills/ok-cosmic/assets/snippets/workflow/SampleWorkflowPlugin.java +302 -0
- package/vendor/kingdee-skills/ok-cosmic/manifest.json +78 -0
- package/vendor/kingdee-skills/ok-cosmic/ok-cosmic-intro.html +903 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/attachment-api.md +114 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/botp-convert.md +98 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/dynamic-object.md +113 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/entity-metadata.md +123 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/event-lifecycle.md +184 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/flex-prop.md +114 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/form-utils.md +133 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/operate-chain.md +159 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/plugin-base.md +218 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/query-dataset.md +149 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/request-context.md +88 -0
- package/vendor/kingdee-skills/ok-cosmic/references/adv/view-handler.md +157 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-bill.md +76 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-botp.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-form.md +165 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-import.md +69 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-list.md +227 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-openapi.md +112 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-operation.md +135 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-print.md +65 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-data.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-report-form.md +90 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-task.md +62 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-tree-list.md +71 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-workflow.md +82 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/plugin/plugin-writeback.md +71 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-algo.md +67 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-cache.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-model-svc.md +82 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-dynamic-object.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-entity-model.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-exception.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-file.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-id.md +47 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-lock.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-log.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-network-control.md +70 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-orm-access.md +78 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-request-context.md +62 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-threadpool.md +63 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-tx.md +64 -0
- package/vendor/kingdee-skills/ok-cosmic/references/base/sdk/sdk-utils.md +67 -0
- package/vendor/kingdee-skills/ok-cosmic/requirements.txt +2 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/a-layer-rules.json +24 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/anti-patterns.md +48 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/cheat-sheet.md +256 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/coding-preferences.md +140 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/constraints.md +61 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/decision-matrix.md +222 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/intent-routing.md +94 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/platform-baseline.md +69 -0
- package/vendor/kingdee-skills/ok-cosmic/rules/post-check.md +109 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/config_loader.py +204 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-api-knowledge.py +910 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-basedata-query.py +359 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-config-check.py +181 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-extpoints-query.py +389 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-form-metadata.py +856 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-check.py +262 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/cosmic-post-lint.py +293 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/__init__.py +2 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/base.py +393 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/resource_check.py +176 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/scene_check.py +375 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/style_check.py +434 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/lint/verify_check.py +36 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/route_client.py +186 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/script_utils.py +40 -0
- package/vendor/kingdee-skills/ok-cosmic/scripts/sqlite_cache.py +142 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-commons.jar +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/cuslib/kd-cd-cosmic-features.jar +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic-docs.db +0 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/ok-cosmic.json +13 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup-mac.sh +18 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup-windows.bat +53 -0
- package/vendor/kingdee-skills/ok-cosmic/setup/setup.jar +0 -0
- package/vendor/kingdee-skills/ok-ksql/SKILL.md +81 -0
- package/vendor/kingdee-skills/ok-ksql/agents/openai.yaml +7 -0
- package/vendor/kingdee-skills/ok-ksql/manifest.json +14 -0
- package/vendor/kingdee-skills/ok-ksql/references/ksql-datafix.md +452 -0
- package/vendor/kingdee-skills/ok-ksql/scripts/ksql_lint.py +363 -0
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
package kd.cd.common;
|
|
2
|
+
|
|
3
|
+
import kd.bos.dataentity.resource.ResManager;
|
|
4
|
+
import kd.bos.entity.datamodel.events.PropertyChangedArgs;
|
|
5
|
+
import kd.bos.form.control.events.ItemClickEvent;
|
|
6
|
+
import kd.bos.form.events.AfterDoOperationEventArgs;
|
|
7
|
+
import kd.bos.form.events.BeforeDoOperationEventArgs;
|
|
8
|
+
import kd.bos.form.operate.AbstractOperate;
|
|
9
|
+
import kd.bos.list.BillList;
|
|
10
|
+
import kd.cd.common.operate.OpUtils;
|
|
11
|
+
import kd.cd.common.plugin.AbstractListPluginExt;
|
|
12
|
+
import kd.cd.core.util.CollectionUtils;
|
|
13
|
+
|
|
14
|
+
import java.util.EventObject;
|
|
15
|
+
import java.util.Map;
|
|
16
|
+
import java.util.Set;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 列表插件骨架模板。
|
|
20
|
+
* 该类仅用于示例写法,生成后请按实际业务删除无用事件并替换占位常量。
|
|
21
|
+
*
|
|
22
|
+
* @template ListPluginTemplate
|
|
23
|
+
* @extends AbstractListPluginExt (kd.cd.common.plugin)
|
|
24
|
+
* @highFreqEvents itemClick, beforeDoOperation, afterDoOperation
|
|
25
|
+
* @medFreqEvents registerListener, propertyChanged, setFilter
|
|
26
|
+
* @relatedDocs references/adv/plugin-base.md, references/base/plugin/plugin-list.md
|
|
27
|
+
*/
|
|
28
|
+
public class ListPluginTemplate extends AbstractListPluginExt {
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 触发时机: 在需要了解当前插件可访问上下文能力时调用。
|
|
32
|
+
* 参数要点: 无入参;仅展示当前插件可通过 this. 访问的方法能力。
|
|
33
|
+
* 典型用途: 作为模板提示,指导在各事件内选择正确的上下文 API。
|
|
34
|
+
*/
|
|
35
|
+
private void getContextSample() {
|
|
36
|
+
// this.getView();
|
|
37
|
+
// this.getModel();
|
|
38
|
+
// this.getPageCache();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// 占位常量:复制模板后请统一替换为业务真实 key。
|
|
43
|
+
private static final String TOOLBAR_KEY = "toolbar";
|
|
44
|
+
private static final String BTN_BATCH_AUDIT = "btn_batchaudit";
|
|
45
|
+
private static final String BTN_CUSTOM_OP = "btn_customop";
|
|
46
|
+
private static final String ENTITY_ID = "entityid";
|
|
47
|
+
private static final String OP_KEY_AUDIT = "audit";
|
|
48
|
+
private static final String OP_KEY_DELETE = "delete";
|
|
49
|
+
private static final String FIELD_STATUS = "billstatus";
|
|
50
|
+
private static final String FIELD_BILL_NO = "billno";
|
|
51
|
+
private static final String COLOR_WARNING = "#FFF1B8";
|
|
52
|
+
private static final String RES_APP_ID = "kd-cd-common-template";
|
|
53
|
+
|
|
54
|
+
// ===== 生命周期事件 =====
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* 触发时机: 列表初始化完毕,所有事件监听注册前。
|
|
58
|
+
* 参数要点:
|
|
59
|
+
* - EventObject e: 通用事件参数。
|
|
60
|
+
* 典型用途: 注册列表工具栏、菜单、行按钮等的事件监听。
|
|
61
|
+
*
|
|
62
|
+
*/
|
|
63
|
+
|
|
64
|
+
@Override
|
|
65
|
+
public void registerListener(EventObject e) {
|
|
66
|
+
super.registerListener(e);
|
|
67
|
+
// 注册工具栏点击事件。
|
|
68
|
+
this.addItemClickListeners(TOOLBAR_KEY);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ===== 工具栏按钮点击事件 =====
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* 触发时机: 用户点击列表工具栏按钮或菜单项时。
|
|
75
|
+
* 参数要点:
|
|
76
|
+
* - ItemClickEvent evt: 包含点击的菜单项信息。
|
|
77
|
+
* - evt.getItemKey(): 获取被点击的菜单项标识。
|
|
78
|
+
* 典型用途: 处理工具栏按钮的点击事件,如批量审核、导出等。
|
|
79
|
+
*
|
|
80
|
+
*/
|
|
81
|
+
|
|
82
|
+
@Override
|
|
83
|
+
public void itemClick(ItemClickEvent evt) {
|
|
84
|
+
super.itemClick(evt);
|
|
85
|
+
String key = evt.getItemKey();
|
|
86
|
+
if (BTN_BATCH_AUDIT.equals(key)) {
|
|
87
|
+
doBatchAudit();
|
|
88
|
+
} else if (BTN_CUSTOM_OP.equals(key)) {
|
|
89
|
+
doCustomOp();
|
|
90
|
+
//刷新列表
|
|
91
|
+
BillList billList = getBillList();
|
|
92
|
+
billList.refresh();
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// ===== 操作前后事件 =====
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* 触发时机: 用户在列表执行操作(如删除行)前。
|
|
100
|
+
* 参数要点:
|
|
101
|
+
* - BeforeDoOperationEventArgs args: 操作前置事件参数。
|
|
102
|
+
* - getOperate(args): 获取当前操作对象。
|
|
103
|
+
* - operate.getOperateKey(): 获取操作类型。
|
|
104
|
+
* - args.setCancel(true): 取消操作。
|
|
105
|
+
* 典型用途: 列表操作前校验。
|
|
106
|
+
*
|
|
107
|
+
*/
|
|
108
|
+
|
|
109
|
+
@Override
|
|
110
|
+
public void beforeDoOperation(BeforeDoOperationEventArgs args) {
|
|
111
|
+
super.beforeDoOperation(args);
|
|
112
|
+
AbstractOperate operate = getOperate(args);
|
|
113
|
+
String opKey = operate.getOperateKey();
|
|
114
|
+
if (OP_KEY_AUDIT.equals(opKey)) {
|
|
115
|
+
Set<Object> pks = getSelectedRowPkValues();
|
|
116
|
+
Map<String, String> variables = operate.getOption().getVariables();
|
|
117
|
+
if (CollectionUtils.isEmpty(pks) && variables.containsKey(FIELD_STATUS)) {
|
|
118
|
+
args.setCancel(true);
|
|
119
|
+
this.getView().showErrorNotification(ResManager.loadKDString("请先选择需要审核的单据", "ListPluginTemplate_0", RES_APP_ID));
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
if (OP_KEY_DELETE.equals(opKey) && CollectionUtils.isEmpty(getSelectedRowPkValues())) {
|
|
123
|
+
args.setCancel(true);
|
|
124
|
+
this.getView().showErrorNotification(ResManager.loadKDString("未选中任何数据,不能执行删除", "ListPluginTemplate_1", RES_APP_ID));
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 触发时机: 列表操作(删除、审核等)完成后。
|
|
130
|
+
* 参数要点:
|
|
131
|
+
* - AfterDoOperationEventArgs e: 操作后置事件参数。
|
|
132
|
+
* 典型用途: 操作完成后的处理,如刷新列表、显示提示等。
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public void afterDoOperation(AfterDoOperationEventArgs e) {
|
|
138
|
+
super.afterDoOperation(e);
|
|
139
|
+
this.getView().showTipNotification(String.format(
|
|
140
|
+
ResManager.loadKDString("列表操作完成:%s", "ListPluginTemplate_2", RES_APP_ID),
|
|
141
|
+
e.getOperateKey()
|
|
142
|
+
));
|
|
143
|
+
this.getView().invokeOperation("refresh");
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// ===== 字段值变更事件 =====
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* 触发时机: 用户在列表中修改单元格值后。
|
|
150
|
+
* 参数要点:
|
|
151
|
+
* - PropertyChangedArgs e: 属性变更事件参数。
|
|
152
|
+
* - e.getProperty().getName(): 获取变更字段标识。
|
|
153
|
+
* - getChangedRowIndex(e): 获取变更行号。
|
|
154
|
+
* - getChangedNewValue(e): 获取新值。
|
|
155
|
+
* - getChangedOldValue(e): 获取旧值。
|
|
156
|
+
* 典型用途: 根据单元格变化进行行高亮、联动等操作。
|
|
157
|
+
*
|
|
158
|
+
*/
|
|
159
|
+
|
|
160
|
+
@Override
|
|
161
|
+
public void propertyChanged(PropertyChangedArgs e) {
|
|
162
|
+
super.propertyChanged(e);
|
|
163
|
+
String fieldKey = e.getProperty().getName();
|
|
164
|
+
if (!FIELD_STATUS.equals(fieldKey)) {
|
|
165
|
+
return;
|
|
166
|
+
}
|
|
167
|
+
int rowIndex = getChangedRowIndex(e);
|
|
168
|
+
setBackColor4ListRows(COLOR_WARNING, rowIndex);
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// ---- 业务方法 ----
|
|
172
|
+
|
|
173
|
+
private void doBatchAudit() {
|
|
174
|
+
Set<Object> pks = getSelectedRowPkValues();
|
|
175
|
+
if (CollectionUtils.isEmpty(pks)) {
|
|
176
|
+
this.getView().showTipNotification(ResManager.loadKDString("请先选择需要审核的单据", "ListPluginTemplate_3", RES_APP_ID));
|
|
177
|
+
return;
|
|
178
|
+
}
|
|
179
|
+
OpUtils.executeOperateOrThrow(OP_KEY_AUDIT, ENTITY_ID, pks.toArray());
|
|
180
|
+
this.getView().invokeOperation("refresh");
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
private void doCustomOp() {
|
|
184
|
+
Set<Object> pks = getSelectedRowPkValues();
|
|
185
|
+
if (CollectionUtils.isEmpty(pks)) {
|
|
186
|
+
this.getView().showTipNotification(ResManager.loadKDString("请先选择需要处理的数据", "ListPluginTemplate_4", RES_APP_ID));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
this.getView().showSuccessNotification(String.format(
|
|
190
|
+
ResManager.loadKDString("已触发自定义列表动作,选中条数:%s", "ListPluginTemplate_5", RES_APP_ID),
|
|
191
|
+
pks.size()
|
|
192
|
+
));
|
|
193
|
+
}
|
|
194
|
+
}
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
package kd.cd.common;
|
|
2
|
+
|
|
3
|
+
import kd.bos.dataentity.entity.DynamicObject;
|
|
4
|
+
import kd.bos.dataentity.resource.ResManager;
|
|
5
|
+
import kd.bos.entity.ExtendedDataEntity;
|
|
6
|
+
import kd.bos.entity.plugin.AddValidatorsEventArgs;
|
|
7
|
+
import kd.bos.entity.plugin.PreparePropertysEventArgs;
|
|
8
|
+
import kd.bos.entity.plugin.args.AfterOperationArgs;
|
|
9
|
+
import kd.bos.entity.plugin.args.BeforeOperationArgs;
|
|
10
|
+
import kd.bos.entity.plugin.args.BeginOperationTransactionArgs;
|
|
11
|
+
import kd.bos.entity.plugin.args.EndOperationTransactionArgs;
|
|
12
|
+
import kd.bos.entity.validate.AbstractValidator;
|
|
13
|
+
import kd.cd.common.plugin.AbstractOperationServicePlugInExt;
|
|
14
|
+
import kd.cd.common.plugin.AbstractValidatorExt;
|
|
15
|
+
import kd.cd.core.util.CharSequenceUtils;
|
|
16
|
+
|
|
17
|
+
import java.util.List;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 操作插件骨架模板。
|
|
21
|
+
* 该类仅用于示例写法,生成后请按实际业务删除无用事件并替换占位常量。
|
|
22
|
+
*
|
|
23
|
+
* @template OpPluginTemplate
|
|
24
|
+
* @extends AbstractOperationServicePlugInExt (kd.cd.common.plugin)
|
|
25
|
+
* @highFreqEvents onPreparePropertys, endOperationTransaction, onAddValidators
|
|
26
|
+
* @medFreqEvents beforeExecuteOperationTransaction, beginOperationTransaction, afterExecuteOperationTransaction
|
|
27
|
+
* @lowFreqEvents onReturnOperation
|
|
28
|
+
* @relatedDocs references/adv/operate-chain.md, references/base/plugin/plugin-operation.md
|
|
29
|
+
*/
|
|
30
|
+
public class OpPluginTemplate extends AbstractOperationServicePlugInExt {
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* 触发时机: 在需要了解当前插件可访问上下文能力时调用。
|
|
34
|
+
* 参数要点: 无入参;仅展示当前插件可通过 this. 访问的方法能力。
|
|
35
|
+
* 典型用途: 作为模板提示,指导在各事件内选择正确的上下文 API。
|
|
36
|
+
*/
|
|
37
|
+
private void getContextSample() {
|
|
38
|
+
// this.billEntityType;
|
|
39
|
+
// this.operateMeta;
|
|
40
|
+
// this.operationResult;
|
|
41
|
+
// this.getOption();
|
|
42
|
+
// this.entryFields(ENTRY_KEY_MAIN);
|
|
43
|
+
// this.addErrorMessage(null, ERROR_MSG_DEMO);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// 占位常量:复制模板后请统一替换为业务真实 key。
|
|
47
|
+
private static final String OP_KEY_SAVE = "save";
|
|
48
|
+
private static final String OP_KEY_SUBMIT = "submit";
|
|
49
|
+
private static final String OP_KEY_AUDIT = "audit";
|
|
50
|
+
private static final String OP_KEY_UNAUDIT = "unaudit";
|
|
51
|
+
private static final String FIELD_BILL_NO = "billno";
|
|
52
|
+
private static final String FIELD_BILL_STATUS = "billstatus";
|
|
53
|
+
private static final String ENTRY_KEY_MAIN = "entryentity";
|
|
54
|
+
private static final String OPTION_KEY_DEMO = "key3";
|
|
55
|
+
private static final String OPTION_VALUE_DEMO = "value1";
|
|
56
|
+
private static final String ERROR_CODE_DEMO = "OperateError_001";
|
|
57
|
+
private static final String ERROR_MSG_REQUIRED_BILL_NO = "OperateError_002";
|
|
58
|
+
private static final String RES_APP_ID = "kd-cd-common-template";
|
|
59
|
+
private static final String ERROR_MSG_DEMO = "xxxxxx";
|
|
60
|
+
|
|
61
|
+
// ===== 字段准备事件 =====
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* 触发时机: 操作执行前,框架装载数据字段阶段。
|
|
65
|
+
* 参数要点:
|
|
66
|
+
* - {@link PreparePropertysEventArgs#getFieldKeys()} 为本次操作需预加载的字段集合。
|
|
67
|
+
* - 未加入的字段在后续事件里可能取值为空。
|
|
68
|
+
*
|
|
69
|
+
*/
|
|
70
|
+
|
|
71
|
+
@Override
|
|
72
|
+
public void onPreparePropertys(PreparePropertysEventArgs e) {
|
|
73
|
+
super.onPreparePropertys(e);
|
|
74
|
+
// 按实际场景显式准备字段,避免运行期缺字段。
|
|
75
|
+
List<String> fieldKeys = e.getFieldKeys();
|
|
76
|
+
fieldKeys.add(FIELD_BILL_NO);
|
|
77
|
+
fieldKeys.add(FIELD_BILL_STATUS);
|
|
78
|
+
// 需要整张分录的场景可直接准备分录字段。
|
|
79
|
+
fieldKeys.addAll(entryFields(ENTRY_KEY_MAIN));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
// ===== 校验器注册事件 =====
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* 触发时机: 进入操作执行链前,注册业务校验器阶段。
|
|
86
|
+
* 参数要点:
|
|
87
|
+
* - {@link AddValidatorsEventArgs#addValidator(AbstractValidator)} 可追加多个校验器。
|
|
88
|
+
* - 校验器在事务开启前执行,失败会阻断操作。
|
|
89
|
+
*
|
|
90
|
+
*/
|
|
91
|
+
|
|
92
|
+
@Override
|
|
93
|
+
public void onAddValidators(AddValidatorsEventArgs e) {
|
|
94
|
+
super.onAddValidators(e);
|
|
95
|
+
// 注册自定义校验器(示例)。
|
|
96
|
+
e.addValidator(new BillNoRequiredValidator());
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
// ===== 事务前事件 =====
|
|
100
|
+
|
|
101
|
+
/**
|
|
102
|
+
* 触发时机: 校验通过后、数据库事务开启前。
|
|
103
|
+
* 参数要点:
|
|
104
|
+
* - {@link BeforeOperationArgs#getOperationKey()} 获取当前操作 key(save/submit/audit...)。
|
|
105
|
+
* - {@link BeforeOperationArgs#getDataEntities()} 获取待处理单据数组。
|
|
106
|
+
* - 可通过 e.setCancel(true) 直接取消操作。
|
|
107
|
+
*
|
|
108
|
+
*/
|
|
109
|
+
|
|
110
|
+
@Override
|
|
111
|
+
public void beforeExecuteOperationTransaction(BeforeOperationArgs e) {
|
|
112
|
+
super.beforeExecuteOperationTransaction(e);
|
|
113
|
+
// 校验通过后、开启事务前的最后拦截点。
|
|
114
|
+
String opKey = e.getOperationKey();
|
|
115
|
+
DynamicObject[] dataEntities = e.getDataEntities();
|
|
116
|
+
if (OP_KEY_SAVE.equals(opKey) || OP_KEY_SUBMIT.equals(opKey)) {
|
|
117
|
+
for (DynamicObject bill : dataEntities) {
|
|
118
|
+
bill.set(OPTION_KEY_DEMO, "A");
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
// 若需直接取消整个操作,可按需启用:
|
|
122
|
+
// e.setCancel(true);
|
|
123
|
+
// e.setCancelMessage("xxxxxx");
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
// ===== 事务中事件 =====
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* 触发时机: 事务已开启,主操作执行中。
|
|
130
|
+
* 参数要点:
|
|
131
|
+
* - {@link BeginOperationTransactionArgs#getDataEntities()} 可安全参与同事务处理。
|
|
132
|
+
* - 适合同步写入关联表、BOTP 关系追踪等“必须同事务成功/失败”的逻辑。
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
|
|
136
|
+
@Override
|
|
137
|
+
public void beginOperationTransaction(BeginOperationTransactionArgs e) {
|
|
138
|
+
super.beginOperationTransaction(e);
|
|
139
|
+
// 事务已开启,适合处理需要与主操作同事务的数据同步。
|
|
140
|
+
String opKey = e.getOperationKey();
|
|
141
|
+
DynamicObject[] bills = e.getDataEntities();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ===== 事务结束(未提交)事件 =====
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* 触发时机: SQL 已执行完成,但事务尚未提交。
|
|
148
|
+
* 参数要点:
|
|
149
|
+
* - {@link EndOperationTransactionArgs#getOperationKey()} 可区分操作类型。
|
|
150
|
+
* - 适合做同事务内收尾,不建议调用外部系统。
|
|
151
|
+
*
|
|
152
|
+
*/
|
|
153
|
+
|
|
154
|
+
@Override
|
|
155
|
+
public void endOperationTransaction(EndOperationTransactionArgs e) {
|
|
156
|
+
super.endOperationTransaction(e);
|
|
157
|
+
String opKey = e.getOperationKey();
|
|
158
|
+
if (OP_KEY_AUDIT.equals(opKey)) {
|
|
159
|
+
log.info("endOperationTransaction, opKey={}", opKey);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
// ===== 事务提交后事件 =====
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* 触发时机: 事务提交成功后。
|
|
167
|
+
* 参数要点:
|
|
168
|
+
* - {@link AfterOperationArgs} 可读取操作结果。
|
|
169
|
+
* - 适合通知、日志、异步任务;失败不影响主事务。
|
|
170
|
+
*
|
|
171
|
+
*/
|
|
172
|
+
|
|
173
|
+
@Override
|
|
174
|
+
public void afterExecuteOperationTransaction(AfterOperationArgs e) {
|
|
175
|
+
super.afterExecuteOperationTransaction(e);
|
|
176
|
+
String opKey = e.getOperationKey();
|
|
177
|
+
if (OP_KEY_AUDIT.equals(opKey)) {
|
|
178
|
+
DynamicObject[] entities = e.getDataEntities();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* 示例校验器:校验表头编号必填。
|
|
184
|
+
*/
|
|
185
|
+
private static class BillNoRequiredValidator extends AbstractValidatorExt {
|
|
186
|
+
@Override
|
|
187
|
+
public void validate() {
|
|
188
|
+
super.validate();
|
|
189
|
+
for (ExtendedDataEntity ext : getDataEntities()) {
|
|
190
|
+
DynamicObject bill = ext.getDataEntity();
|
|
191
|
+
String billNo = bill.getString(FIELD_BILL_NO);
|
|
192
|
+
if (CharSequenceUtils.isBlank(billNo)) {
|
|
193
|
+
// 强制校验拦截
|
|
194
|
+
this.addErrorMessage(ext, ResManager.loadKDString("单据编号不能为空", ERROR_MSG_REQUIRED_BILL_NO, RES_APP_ID));
|
|
195
|
+
// 弱提示拦截(示例)
|
|
196
|
+
this.addWarningMessage(ext, ResManager.loadKDString("xxxxxx", ERROR_CODE_DEMO, RES_APP_ID));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
package kd.cd.common;
|
|
2
|
+
|
|
3
|
+
import java.io.Serializable;
|
|
4
|
+
import java.util.Map;
|
|
5
|
+
|
|
6
|
+
import kd.bos.dataentity.resource.ResManager;
|
|
7
|
+
import kd.bos.exception.ErrorCode;
|
|
8
|
+
import kd.bos.exception.KDBizException;
|
|
9
|
+
import kd.bos.openapi.common.custom.annotation.ApiController;
|
|
10
|
+
import kd.bos.openapi.common.custom.annotation.ApiGetMapping;
|
|
11
|
+
import kd.bos.openapi.common.custom.annotation.ApiMapping;
|
|
12
|
+
import kd.bos.openapi.common.custom.annotation.ApiModel;
|
|
13
|
+
import kd.bos.openapi.common.custom.annotation.ApiParam;
|
|
14
|
+
import kd.bos.openapi.common.custom.annotation.ApiPostMapping;
|
|
15
|
+
import kd.bos.openapi.common.custom.annotation.ApiRequestBody;
|
|
16
|
+
import kd.bos.openapi.common.custom.annotation.ApiResponseBody;
|
|
17
|
+
import kd.bos.openapi.common.result.CustomApiResult;
|
|
18
|
+
import kd.cd.common.entity.EntityUtils;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 开放平台自定义 API 骨架模板(注解模式)。
|
|
22
|
+
* 该类仅用于示例写法,生成后请按实际业务删除无用接口并替换占位常量。
|
|
23
|
+
*/
|
|
24
|
+
@ApiController(value = "open", desc = "示例开放 API")
|
|
25
|
+
@ApiMapping("/template")
|
|
26
|
+
public class OpenApiControllerTemplate implements Serializable {
|
|
27
|
+
private static final long serialVersionUID = 1L;
|
|
28
|
+
private static final String RES_APP_ID = "kd-cd-common-template";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* 触发时机: 在需要了解当前控制器可通过 this. 访问哪些能力时调用。
|
|
32
|
+
* 参数要点: 无入参;OpenAPI 控制器不具备表单插件的 view/model/pageCache 上下文。
|
|
33
|
+
* 典型用途: 告诉 AI 当前类只能通过 this. 访问本类方法与普通 Java 成员,业务上下文需从入参获取。
|
|
34
|
+
*/
|
|
35
|
+
private void getContextSample() {
|
|
36
|
+
// this.getClass();
|
|
37
|
+
// this.getById(1001L);
|
|
38
|
+
// this.saveMap(java.util.Collections.emptyMap());
|
|
39
|
+
// this.saveBody(new UserModel());
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
private static final String ERR_CODE_PARAM = "OpenApi_001";
|
|
43
|
+
|
|
44
|
+
@ApiGetMapping(value = "/getById", desc = "按 id 查询示例")
|
|
45
|
+
public CustomApiResult<String> getById(
|
|
46
|
+
@ApiParam(value = "主键ID", required = true, example = "1001") Long id) {
|
|
47
|
+
if (EntityUtils.isEmptyPk(id)) {
|
|
48
|
+
return CustomApiResult.fail(ERR_CODE_PARAM, ResManager.loadKDString("id 必须大于 0", "OpenApiControllerTemplate_0", RES_APP_ID));
|
|
49
|
+
}
|
|
50
|
+
return CustomApiResult.success("U-" + id);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
@ApiPostMapping(value = "/saveMap", desc = "Map 入参保存示例")
|
|
54
|
+
public CustomApiResult<@ApiResponseBody("true-成功,false-失败") Boolean> saveMap(
|
|
55
|
+
@ApiParam(value = "业务数据", required = true) Map<String, Object> data) {
|
|
56
|
+
if (data == null || EntityUtils.isEmptyPk(data.get("id"))) {
|
|
57
|
+
throw new KDBizException(new ErrorCode(
|
|
58
|
+
ERR_CODE_PARAM,
|
|
59
|
+
ResManager.loadKDString("id 不能为空", "OpenApiControllerTemplate_1", RES_APP_ID)
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
return CustomApiResult.success(Boolean.TRUE);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
@ApiPostMapping(value = "/saveBody", desc = "@ApiRequestBody 入参示例")
|
|
66
|
+
public CustomApiResult<@ApiResponseBody("保存后的模型") UserModel> saveBody(
|
|
67
|
+
@ApiRequestBody(value = "用户模型", required = true) UserModel model) {
|
|
68
|
+
if (model == null || model.getUserName() == null) {
|
|
69
|
+
return CustomApiResult.fail(ERR_CODE_PARAM, ResManager.loadKDString("userName 不能为空", "OpenApiControllerTemplate_2", RES_APP_ID));
|
|
70
|
+
}
|
|
71
|
+
return CustomApiResult.success(model);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 示例请求体模型。
|
|
76
|
+
*/
|
|
77
|
+
@ApiModel
|
|
78
|
+
public static class UserModel implements Serializable {
|
|
79
|
+
private static final long serialVersionUID = 1L;
|
|
80
|
+
|
|
81
|
+
@ApiParam(value = "用户ID", example = "1001")
|
|
82
|
+
private Long id;
|
|
83
|
+
|
|
84
|
+
@ApiParam(value = "用户名", required = true, example = "Tom")
|
|
85
|
+
private String userName;
|
|
86
|
+
|
|
87
|
+
public Long getId() {
|
|
88
|
+
return id;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
public void setId(Long id) {
|
|
92
|
+
this.id = id;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
public String getUserName() {
|
|
96
|
+
return userName;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
public void setUserName(String userName) {
|
|
100
|
+
this.userName = userName;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
package kd.cd.common;
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
import kd.bos.print.core.plugin.AbstractPrintPlugin;
|
|
5
|
+
import kd.bos.print.core.plugin.event.AfterOutputWidgetEvent;
|
|
6
|
+
import kd.bos.print.core.plugin.event.BeforeLoadDataEvent;
|
|
7
|
+
import kd.bos.print.core.plugin.event.BeforeOutputWidgetEvent;
|
|
8
|
+
import kd.bos.print.core.plugin.event.CustomDataLoadEvent;
|
|
9
|
+
|
|
10
|
+
import java.util.List;
|
|
11
|
+
import java.util.Map;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* 打印插件骨架模板(原生 AbstractPrintPlugin)。
|
|
15
|
+
* 该类仅用于示例写法,生成后请按实际业务删除无用事件并替换占位常量。
|
|
16
|
+
*/
|
|
17
|
+
public class PrintPluginTemplate extends AbstractPrintPlugin {
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* 触发时机: 在需要了解当前插件可访问上下文能力时调用。
|
|
21
|
+
* 参数要点: 无入参;仅展示当前插件可通过 this. 访问的方法能力。
|
|
22
|
+
* 典型用途: 作为模板提示,指导在各事件内选择正确的上下文 API。
|
|
23
|
+
*/
|
|
24
|
+
private void getContextSample() {
|
|
25
|
+
// this.getMainDataVisitor();
|
|
26
|
+
// this.getDataVisitor("ds_main");
|
|
27
|
+
// this.getPrintSetting();
|
|
28
|
+
// this.getExtParam();
|
|
29
|
+
// this.getTplInfo();
|
|
30
|
+
// this.isPreview();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* 触发时机: 打印引擎读取数据前。
|
|
35
|
+
* 参数要点: evt 可取消默认数据加载;取消后通常需在自定义数据事件中重新提供数据。
|
|
36
|
+
* 典型用途: 拦截默认打印取数,切换成自定义数据包来源。
|
|
37
|
+
*/
|
|
38
|
+
@Override
|
|
39
|
+
public void beforeLoadData(BeforeLoadDataEvent evt) {
|
|
40
|
+
super.beforeLoadData(evt);
|
|
41
|
+
if ("ds_custom".equals(evt.getDataSource().getDsName())) {
|
|
42
|
+
evt.setCancleLoadData(true);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* 触发时机: 自定义数据源加载数据时。
|
|
48
|
+
* 参数要点: evt 含数据源标识、过滤条件与当前数据包。
|
|
49
|
+
* 典型用途: 构造自定义打印数据、加工默认读取的数据集合。
|
|
50
|
+
*/
|
|
51
|
+
@Override
|
|
52
|
+
public void loadCustomData(CustomDataLoadEvent evt) {
|
|
53
|
+
super.loadCustomData(evt);
|
|
54
|
+
if (!"ds_custom".equals(evt.getDataSource().getDsName())) {
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
List rows = evt.getCustomDataRows();
|
|
58
|
+
if (rows != null) {
|
|
59
|
+
rows.clear();
|
|
60
|
+
}
|
|
61
|
+
Map extParam = this.getExtParam();
|
|
62
|
+
if (extParam != null) {
|
|
63
|
+
extParam.put("customDataLoaded", Boolean.TRUE);
|
|
64
|
+
extParam.put("customDataSource", evt.getDataSource().getDsName());
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* 触发时机: 打印控件输出前。
|
|
70
|
+
* 参数要点: evt 可读取控件标识、当前输出值并在输出前改写。
|
|
71
|
+
* 典型用途: 格式化文本、替换图片地址、控制单元格输出内容。
|
|
72
|
+
*/
|
|
73
|
+
@Override
|
|
74
|
+
public void beforeOutputWidget(BeforeOutputWidgetEvent evt) {
|
|
75
|
+
super.beforeOutputWidget(evt);
|
|
76
|
+
Map extParam = this.getExtParam();
|
|
77
|
+
if (extParam != null) {
|
|
78
|
+
extParam.put("beforeOutputWidget", evt.getWidgetKey());
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* 触发时机: 打印控件输出后。
|
|
84
|
+
* 参数要点: evt 可读取输出结果并做后置调整。
|
|
85
|
+
* 典型用途: 记录输出过程、对合并行列或后置格式做补充处理。
|
|
86
|
+
*/
|
|
87
|
+
@Override
|
|
88
|
+
public void afterOutputWidget(AfterOutputWidgetEvent evt) {
|
|
89
|
+
super.afterOutputWidget(evt);
|
|
90
|
+
Map extParam = this.getExtParam();
|
|
91
|
+
if (extParam != null) {
|
|
92
|
+
extParam.put("afterOutputWidget", evt.getWidgetKey());
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
}
|