@agile-team/wl-skills-ui 1.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +207 -0
- package/README.md +623 -0
- package/SKILL.md +632 -0
- package/bin/wl-ui.js +794 -0
- package/design/spec/color.md +41 -0
- package/design/spec/spacing.md +28 -0
- package/design/spec/typography.md +29 -0
- package/design/tokens/base.css +144 -0
- package/design/tokens/index.css +8 -0
- package/dist/ag-grid-override.scss +1 -0
- package/dist/element.scss +1 -0
- package/dist/index.scss +1 -0
- package/dist/portal.scss +1 -0
- package/dist/style-override.scss +1 -0
- package/dist/tokens.css +144 -0
- package/es/chunk-GBB7LDKQ.js +261 -0
- package/es/chunk-MDI2SCUP.js +281 -0
- package/es/chunk-QDTNMM7W.js +286 -0
- package/es/chunk-YLNAFAWE.js +233 -0
- package/es/common-preset.d.ts +38 -0
- package/es/common-preset.js +157 -0
- package/es/index.d.ts +32 -0
- package/es/index.js +1 -0
- package/es/presets/security.d.ts +16 -0
- package/es/presets/security.js +99 -0
- package/es/renderers-BFRSp2BH.d.ts +51 -0
- package/es/renderers-DMZbi_Gs.d.ts +51 -0
- package/es/renderers-DWhUlI2y.d.ts +47 -0
- package/es/types-04qLKHMt.d.ts +62 -0
- package/es/types-BrCPjAH6.d.ts +62 -0
- package/es/types-QZ1gy9KX.d.ts +63 -0
- package/examples/migration-operations-to-renderOps.md +107 -0
- package/examples/wk-exempt.example.json +30 -0
- package/mcp/server.js +394 -0
- package/package.json +130 -0
- package/reference/SelectPopupCom.vue +634 -0
- package/reference/ag-cell-renders.ts +644 -0
- package/reference/define-columns.ts +185 -0
- package/reference/jhlc.d.ts +1 -0
- package/scanner/coverage.mjs +287 -0
- package/scanner/exempt.mjs +127 -0
- package/scanner/fix.mjs +216 -0
- package/scanner/index.mjs +403 -0
- package/scanner/integration.mjs +155 -0
- package/scanner/report.mjs +459 -0
- package/scanner/rules/_shared.mjs +134 -0
- package/scanner/rules/button.mjs +97 -0
- package/scanner/rules/color.mjs +118 -0
- package/scanner/rules/componentFamily.mjs +184 -0
- package/scanner/rules/dialog.mjs +42 -0
- package/scanner/rules/form.mjs +86 -0
- package/scanner/rules/index.mjs +58 -0
- package/scanner/rules/table.mjs +170 -0
- package/scanner/rules/tag.mjs +245 -0
- package/scanner/snapshot.mjs +198 -0
- package/skills/_flows/full-audit.md +65 -0
- package/skills/_flows/legacy-skin-align.md +71 -0
- package/skills/_flows/new-project-init.md +80 -0
- package/skills/_flows/progressive-migrate.md +49 -0
- package/skills/_meta/_compat/README.md +47 -0
- package/skills/_meta/_compat/editors.json +76 -0
- package/skills/_meta/_compat/headers/agents.txt +7 -0
- package/skills/_meta/_compat/headers/claude-code.txt +7 -0
- package/skills/_meta/_compat/headers/cline.txt +7 -0
- package/skills/_meta/_compat/headers/cursor-mdc.txt +5 -0
- package/skills/_meta/_compat/headers/github-copilot.txt +5 -0
- package/skills/_meta/_compat/headers/kiro.txt +4 -0
- package/skills/_meta/_compat/headers/qoder.txt +4 -0
- package/skills/_meta/_compat/headers/trae.txt +3 -0
- package/skills/_meta/_compat/headers/windsurf.txt +5 -0
- package/skills/_meta/_detection.md +81 -0
- package/skills/_meta/_registry.md +96 -0
- package/skills/element/component-family/SKILL.md +71 -0
- package/skills/element/el-dialog/SKILL.md +124 -0
- package/skills/element/el-form/SKILL.md +84 -0
- package/skills/element/el-table/SKILL.md +86 -0
- package/skills/element/el-tag/SKILL.md +127 -0
- package/skills/layouts/detail-page/SKILL.md +99 -0
- package/skills/layouts/form-dialog/SKILL.md +128 -0
- package/skills/layouts/list-page/SKILL.md +111 -0
- package/skills/layouts/tree-list/SKILL.md +108 -0
- package/skills/ops/audit/SKILL.md +109 -0
- package/skills/ops/fix/SKILL.md +52 -0
- package/skills/ops/fix/USAGE.md +24 -0
- package/skills/ops/migrate/SKILL.md +157 -0
- package/skills/ops/scan/SKILL.md +71 -0
- package/skills/ops/scan/USAGE.md +16 -0
- package/skills/runtime/design-tokens/SKILL.md +88 -0
- package/skills/runtime/design-tokens/USAGE.md +19 -0
- package/skills/runtime/migration/SKILL.md +106 -0
- package/skills/runtime/migration/USAGE.md +34 -0
- package/skills/runtime/style-align/SKILL.md +124 -0
- package/skills/runtime/style-align/USAGE.md +52 -0
- package/skills/vendors/ag-grid/SKILL.md +94 -0
- package/skills/vendors/base-table/SKILL.md +57 -0
- package/skills/vendors/c-components/SKILL.md +36 -0
- package/skills/vendors/custom-wrappers/SKILL.md +45 -0
- package/skills/vendors/jh-components/SKILL.md +42 -0
- package/skills/vendors/unknown-wrapper/SKILL.md +44 -0
- package/standards/engineering/01-import-order.md +46 -0
- package/standards/engineering/02-naming.md +54 -0
- package/standards/engineering/03-scss-structure.md +59 -0
- package/standards/ui/01-table.md +111 -0
- package/standards/ui/02-button.md +83 -0
- package/standards/ui/03-form.md +118 -0
- package/standards/ui/04-tag-status.md +110 -0
- package/standards/ui/05-dialog-pagination.md +118 -0
- package/styles/element/_card.scss +26 -0
- package/styles/element/_descriptions.scss +22 -0
- package/styles/element/_dialog.scss +43 -0
- package/styles/element/_drawer.scss +22 -0
- package/styles/element/_feedback.scss +52 -0
- package/styles/element/_form.scss +22 -0
- package/styles/element/_navigation.scss +36 -0
- package/styles/element/_overlay.scss +32 -0
- package/styles/element/_pagination.scss +16 -0
- package/styles/element/_steps.scss +32 -0
- package/styles/element/_table.scss +13 -0
- package/styles/element/_tabs.scss +40 -0
- package/styles/element/_tree.scss +27 -0
- package/styles/element/_upload.scss +34 -0
- package/styles/element/index.scss +17 -0
- package/styles/index.scss +21 -0
- package/styles/layouts/_detail-page.scss +27 -0
- package/styles/layouts/_form-dialog.scss +19 -0
- package/styles/layouts/_list-page.scss +47 -0
- package/styles/layouts/_tree-list.scss +33 -0
- package/styles/layouts/index.scss +6 -0
- package/styles/presets/element-only.scss +6 -0
- package/styles/presets/full.scss +12 -0
- package/styles/presets/security.scss +37 -0
- package/styles/presets/skin.scss +14 -0
- package/styles/presets/tokens-only.scss +7 -0
- package/styles/tokens/index.scss +79 -0
- package/styles/vendors/_ag-grid.scss +273 -0
- package/styles/vendors/_base-components.scss +480 -0
- package/styles/vendors/_base-query-toolbar.scss +253 -0
- package/styles/vendors/_base-table.scss +41 -0
- package/styles/vendors/_c-components.scss +34 -0
- package/styles/vendors/_custom-wrappers.scss +30 -0
- package/styles/vendors/_jh-drag-col.scss +63 -0
- package/styles/vendors/_jh-pagination.scss +81 -0
- package/styles/vendors/_jh-tree.scss +196 -0
- package/styles/vendors/_portal.scss +114 -0
- package/styles/vendors/index.scss +17 -0
- package/templates/ag-grid-page/TPL-AG-GRID.md +76 -0
- package/templates/form-dialog/TPL-FORM-DIALOG.md +165 -0
- package/templates/list-page/TPL-LIST.md +139 -0
- package/templates/tree-list/TPL-TREE-LIST.md +176 -0
- package/templates/ui-optimization-report/TPL-UI-OPTIM-REPORT.md +343 -0
|
@@ -0,0 +1,281 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import { ElTag } from 'element-plus';
|
|
3
|
+
import { Upload, CircleCheck, Document, Delete, Edit, View } from '@element-plus/icons-vue';
|
|
4
|
+
|
|
5
|
+
// runtime/core/renderers.ts
|
|
6
|
+
var ENABLE_STATUS_MAP = {
|
|
7
|
+
0: { label: "\u505C\u7528", type: "danger" },
|
|
8
|
+
1: { label: "\u542F\u7528", type: "success" }
|
|
9
|
+
};
|
|
10
|
+
var AUDIT_STATUS_MAP = {
|
|
11
|
+
0: { label: "\u5F85\u5BA1\u6279", type: "info" },
|
|
12
|
+
1: { label: "\u5DF2\u901A\u8FC7", type: "success" },
|
|
13
|
+
2: { label: "\u5DF2\u9A73\u56DE", type: "danger" }
|
|
14
|
+
};
|
|
15
|
+
var VERIFY_STATUS_MAP = {
|
|
16
|
+
0: { label: "\u672A\u6838\u5B9E", type: "warning" },
|
|
17
|
+
1: { label: "\u5DF2\u6838\u5B9E", type: "success" }
|
|
18
|
+
};
|
|
19
|
+
var RATING_LEVEL_COLORS = {
|
|
20
|
+
\u4E00: {
|
|
21
|
+
bg: "var(--wk-rating-lv1-bg, rgba(16,185,129,0.14))",
|
|
22
|
+
color: "var(--wk-rating-lv1-color, #065F46)"
|
|
23
|
+
},
|
|
24
|
+
\u4E8C: {
|
|
25
|
+
bg: "var(--wk-rating-lv2-bg, rgba(59,130,246,0.14))",
|
|
26
|
+
color: "var(--wk-rating-lv2-color, #1E40AF)"
|
|
27
|
+
},
|
|
28
|
+
\u4E09: {
|
|
29
|
+
bg: "var(--wk-rating-lv3-bg, rgba(245,158,11,0.14))",
|
|
30
|
+
color: "var(--wk-rating-lv3-color, #78350F)"
|
|
31
|
+
},
|
|
32
|
+
\u56DB: {
|
|
33
|
+
bg: "var(--wk-rating-lv4-bg, rgba(249,115,22,0.14))",
|
|
34
|
+
color: "var(--wk-rating-lv4-color, #9A3412)"
|
|
35
|
+
},
|
|
36
|
+
\u4E94: {
|
|
37
|
+
bg: "var(--wk-rating-lv5-bg, rgba(239,68,68,0.14))",
|
|
38
|
+
color: "var(--wk-rating-lv5-color, #991B1B)"
|
|
39
|
+
},
|
|
40
|
+
"1": {
|
|
41
|
+
bg: "var(--wk-rating-lv1-bg, rgba(16,185,129,0.14))",
|
|
42
|
+
color: "var(--wk-rating-lv1-color, #065F46)"
|
|
43
|
+
},
|
|
44
|
+
"2": {
|
|
45
|
+
bg: "var(--wk-rating-lv2-bg, rgba(59,130,246,0.14))",
|
|
46
|
+
color: "var(--wk-rating-lv2-color, #1E40AF)"
|
|
47
|
+
},
|
|
48
|
+
"3": {
|
|
49
|
+
bg: "var(--wk-rating-lv3-bg, rgba(245,158,11,0.14))",
|
|
50
|
+
color: "var(--wk-rating-lv3-color, #78350F)"
|
|
51
|
+
},
|
|
52
|
+
"4": {
|
|
53
|
+
bg: "var(--wk-rating-lv4-bg, rgba(249,115,22,0.14))",
|
|
54
|
+
color: "var(--wk-rating-lv4-color, #9A3412)"
|
|
55
|
+
},
|
|
56
|
+
"5": {
|
|
57
|
+
bg: "var(--wk-rating-lv5-bg, rgba(239,68,68,0.14))",
|
|
58
|
+
color: "var(--wk-rating-lv5-color, #991B1B)"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function renderTagNode(value, map) {
|
|
62
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
63
|
+
const item = map[value];
|
|
64
|
+
if (!item) return null;
|
|
65
|
+
return { tag: "jh-tag", item: [{ title: item.label, type: item.type }] };
|
|
66
|
+
}
|
|
67
|
+
function renderTagSlot(value, map) {
|
|
68
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
69
|
+
const item = map[value];
|
|
70
|
+
if (!item) return null;
|
|
71
|
+
const typeClass = item.type ? `jh-cell-tag--${item.type}` : "jh-cell-tag--default";
|
|
72
|
+
return h("span", { class: ["jh-cell-tag", typeClass] }, item.label);
|
|
73
|
+
}
|
|
74
|
+
function renderClassifyTag(value, map) {
|
|
75
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
76
|
+
const item = map[value];
|
|
77
|
+
if (!item) return null;
|
|
78
|
+
return h(
|
|
79
|
+
ElTag,
|
|
80
|
+
{ type: item.type || "primary", size: "small", effect: "plain" },
|
|
81
|
+
() => item.label
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
var AUTO_TAG_PALETTE = ["", "success", "warning", "info"];
|
|
85
|
+
var dictResolver = null;
|
|
86
|
+
function setDictResolver(fn) {
|
|
87
|
+
dictResolver = fn;
|
|
88
|
+
}
|
|
89
|
+
var DICT_COLOR_REGISTRY = {};
|
|
90
|
+
function registerDictColorMap(dictKey, colorMap) {
|
|
91
|
+
DICT_COLOR_REGISTRY[dictKey] = colorMap;
|
|
92
|
+
}
|
|
93
|
+
function registerDictColorMaps(maps) {
|
|
94
|
+
Object.assign(DICT_COLOR_REGISTRY, maps);
|
|
95
|
+
}
|
|
96
|
+
function autoTagType(value) {
|
|
97
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
98
|
+
if (!Number.isNaN(n) && n > 0) {
|
|
99
|
+
return AUTO_TAG_PALETTE[(n - 1) % AUTO_TAG_PALETTE.length];
|
|
100
|
+
}
|
|
101
|
+
let hash = 0;
|
|
102
|
+
for (let i = 0; i < String(value).length; i++) {
|
|
103
|
+
hash = (hash << 5) - hash + String(value).charCodeAt(i) | 0;
|
|
104
|
+
}
|
|
105
|
+
return AUTO_TAG_PALETTE[Math.abs(hash) % AUTO_TAG_PALETTE.length];
|
|
106
|
+
}
|
|
107
|
+
function renderDictClassifyTag(value, dictKey, typeColorMap) {
|
|
108
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
109
|
+
let label = String(value);
|
|
110
|
+
if (dictResolver) {
|
|
111
|
+
const resolved = dictResolver(dictKey, value);
|
|
112
|
+
if (resolved) label = resolved;
|
|
113
|
+
}
|
|
114
|
+
const colorMap = typeColorMap ?? DICT_COLOR_REGISTRY[dictKey];
|
|
115
|
+
const tagType = colorMap?.[String(value)] ?? autoTagType(value);
|
|
116
|
+
return h(
|
|
117
|
+
ElTag,
|
|
118
|
+
{ type: tagType, size: "small", effect: "plain" },
|
|
119
|
+
() => label
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function renderBadge(value) {
|
|
123
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
124
|
+
return h("span", { class: "jh-riskno-badge" }, String(value));
|
|
125
|
+
}
|
|
126
|
+
function renderCountBadge(value) {
|
|
127
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
128
|
+
return h("span", { class: "jh-count-badge" }, String(value));
|
|
129
|
+
}
|
|
130
|
+
function renderDangerText(value) {
|
|
131
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
132
|
+
return h(
|
|
133
|
+
"span",
|
|
134
|
+
{ style: { color: "var(--el-color-danger)", fontWeight: 500 } },
|
|
135
|
+
String(value)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function renderRatingLevel(value) {
|
|
139
|
+
if (!value) return null;
|
|
140
|
+
const clr = RATING_LEVEL_COLORS[value] ?? {
|
|
141
|
+
bg: "var(--wk-rating-fallback-bg, rgba(107,114,128,0.12))",
|
|
142
|
+
color: "var(--wk-rating-fallback-color, #374151)"
|
|
143
|
+
};
|
|
144
|
+
return h(
|
|
145
|
+
"span",
|
|
146
|
+
{
|
|
147
|
+
class: "jh-rating-lv",
|
|
148
|
+
style: { "--lv-bg": clr.bg, "--lv-color": clr.color }
|
|
149
|
+
},
|
|
150
|
+
value
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
var renderEnableStatus = (v) => renderTagNode(v, ENABLE_STATUS_MAP);
|
|
154
|
+
var renderAuditStatus = (v) => renderTagNode(v, AUDIT_STATUS_MAP);
|
|
155
|
+
var renderVerifyStatus = (v) => renderTagNode(v, VERIFY_STATUS_MAP);
|
|
156
|
+
var ICON_PRESETS = {
|
|
157
|
+
view: { icon: View, cls: "jh-op-view", title: "\u67E5\u770B" },
|
|
158
|
+
edit: { icon: Edit, cls: "jh-op-edit", title: "\u7F16\u8F91" },
|
|
159
|
+
del: { icon: Delete, cls: "jh-op-del", title: "\u5220\u9664" },
|
|
160
|
+
log: { icon: Document, cls: "jh-op-log", title: "\u8BB0\u5F55" },
|
|
161
|
+
ok: { icon: CircleCheck, cls: "jh-op-ok", title: "\u5BA1\u6838" },
|
|
162
|
+
send: { icon: Upload, cls: "jh-op-send", title: "\u63D0\u4EA4" }
|
|
163
|
+
};
|
|
164
|
+
function renderOps(items) {
|
|
165
|
+
const visible = items.filter((item) => item.show !== false);
|
|
166
|
+
const iconItems = visible.filter((i) => i.type in ICON_PRESETS);
|
|
167
|
+
const otherItems = visible.filter((i) => !(i.type in ICON_PRESETS));
|
|
168
|
+
const nodes = [];
|
|
169
|
+
for (const item of iconItems) {
|
|
170
|
+
const preset = ICON_PRESETS[item.type];
|
|
171
|
+
nodes.push(
|
|
172
|
+
h(
|
|
173
|
+
"button",
|
|
174
|
+
{
|
|
175
|
+
class: ["jh-op-btn", preset.cls],
|
|
176
|
+
type: "button",
|
|
177
|
+
title: item.title ?? preset.title,
|
|
178
|
+
onClick: (e) => {
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
item.onClick(e);
|
|
181
|
+
}
|
|
182
|
+
},
|
|
183
|
+
h(preset.icon)
|
|
184
|
+
)
|
|
185
|
+
);
|
|
186
|
+
}
|
|
187
|
+
if (iconItems.length > 0 && otherItems.length > 0)
|
|
188
|
+
nodes.push(h("span", { class: "jh-op-sep", "aria-hidden": "true" }));
|
|
189
|
+
for (const item of otherItems) {
|
|
190
|
+
if (item.type === "chip") {
|
|
191
|
+
const children = [];
|
|
192
|
+
if (item.icon) children.push(h(item.icon));
|
|
193
|
+
children.push(h("span", null, item.label));
|
|
194
|
+
nodes.push(
|
|
195
|
+
h(
|
|
196
|
+
"button",
|
|
197
|
+
{
|
|
198
|
+
class: "jh-op-chip",
|
|
199
|
+
type: "button",
|
|
200
|
+
onClick: (e) => {
|
|
201
|
+
e.stopPropagation();
|
|
202
|
+
item.onClick(e);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
children
|
|
206
|
+
)
|
|
207
|
+
);
|
|
208
|
+
} else {
|
|
209
|
+
nodes.push(
|
|
210
|
+
h(
|
|
211
|
+
"button",
|
|
212
|
+
{
|
|
213
|
+
class: "jh-op-link",
|
|
214
|
+
type: "button",
|
|
215
|
+
onClick: (e) => {
|
|
216
|
+
e.stopPropagation();
|
|
217
|
+
item.onClick(e);
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
item.label
|
|
221
|
+
)
|
|
222
|
+
);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
return h("div", { class: "jh-op-group" }, nodes);
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
// runtime/core/registry.ts
|
|
229
|
+
var COLUMN_AUTO_MAP = {};
|
|
230
|
+
function registerColumnAutoMap(name, config) {
|
|
231
|
+
COLUMN_AUTO_MAP[name] = config;
|
|
232
|
+
}
|
|
233
|
+
function registerColumnAutoMaps(maps) {
|
|
234
|
+
Object.assign(COLUMN_AUTO_MAP, maps);
|
|
235
|
+
}
|
|
236
|
+
function getColumnAutoMap() {
|
|
237
|
+
return COLUMN_AUTO_MAP;
|
|
238
|
+
}
|
|
239
|
+
function clearColumnAutoMap(name) {
|
|
240
|
+
if (name) delete COLUMN_AUTO_MAP[name];
|
|
241
|
+
else for (const k of Object.keys(COLUMN_AUTO_MAP)) delete COLUMN_AUTO_MAP[k];
|
|
242
|
+
}
|
|
243
|
+
function defineColumns(columns) {
|
|
244
|
+
return columns.map((col) => {
|
|
245
|
+
const fieldName = col.name ?? col.label ?? "";
|
|
246
|
+
const preset = COLUMN_AUTO_MAP[fieldName];
|
|
247
|
+
const hasRenderer = col.defaultNode !== void 0 || col.defaultSlot !== void 0;
|
|
248
|
+
if (hasRenderer) return col;
|
|
249
|
+
if (!preset && isDictColumn(col)) {
|
|
250
|
+
return {
|
|
251
|
+
...col,
|
|
252
|
+
defaultSlot: ({ row }) => renderDictClassifyTag(row?.[fieldName], String(col.logicValue))
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
if (!preset) return col;
|
|
256
|
+
return { ...preset, ...col };
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function isDictColumn(col) {
|
|
260
|
+
const logicType = String(col.logicType ?? "").toLowerCase();
|
|
261
|
+
return Boolean(col.logicValue) && logicType.includes("dict");
|
|
262
|
+
}
|
|
263
|
+
registerColumnAutoMaps({
|
|
264
|
+
enableStatus: {
|
|
265
|
+
width: 80,
|
|
266
|
+
fixed: "right",
|
|
267
|
+
defaultNode: ({ row }) => renderEnableStatus(row.enableStatus)
|
|
268
|
+
},
|
|
269
|
+
approvalStatus: {
|
|
270
|
+
width: 90,
|
|
271
|
+
fixed: "right",
|
|
272
|
+
defaultNode: ({ row }) => renderAuditStatus(row.approvalStatus)
|
|
273
|
+
},
|
|
274
|
+
verifyStatus: {
|
|
275
|
+
width: 90,
|
|
276
|
+
fixed: "right",
|
|
277
|
+
defaultNode: ({ row }) => renderVerifyStatus(row.verifyStatus)
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
export { AUDIT_STATUS_MAP, ENABLE_STATUS_MAP, RATING_LEVEL_COLORS, VERIFY_STATUS_MAP, clearColumnAutoMap, defineColumns, getColumnAutoMap, registerColumnAutoMap, registerColumnAutoMaps, registerDictColorMap, registerDictColorMaps, renderAuditStatus, renderBadge, renderClassifyTag, renderCountBadge, renderDangerText, renderDictClassifyTag, renderEnableStatus, renderOps, renderRatingLevel, renderTagNode, renderTagSlot, renderVerifyStatus, setDictResolver };
|
|
@@ -0,0 +1,286 @@
|
|
|
1
|
+
import { h } from 'vue';
|
|
2
|
+
import { ElTag } from 'element-plus';
|
|
3
|
+
import { Upload, CircleCheck, Document, Delete, Edit, View } from '@element-plus/icons-vue';
|
|
4
|
+
|
|
5
|
+
// runtime/core/renderers.ts
|
|
6
|
+
var ENABLE_STATUS_MAP = {
|
|
7
|
+
0: { label: "\u505C\u7528", type: "danger" },
|
|
8
|
+
1: { label: "\u542F\u7528", type: "success" }
|
|
9
|
+
};
|
|
10
|
+
var AUDIT_STATUS_MAP = {
|
|
11
|
+
0: { label: "\u5F85\u5BA1\u6279", type: "info" },
|
|
12
|
+
1: { label: "\u5DF2\u901A\u8FC7", type: "success" },
|
|
13
|
+
2: { label: "\u5DF2\u9A73\u56DE", type: "danger" }
|
|
14
|
+
};
|
|
15
|
+
var VERIFY_STATUS_MAP = {
|
|
16
|
+
0: { label: "\u672A\u6838\u5B9E", type: "warning" },
|
|
17
|
+
1: { label: "\u5DF2\u6838\u5B9E", type: "success" }
|
|
18
|
+
};
|
|
19
|
+
var RATING_LEVEL_COLORS = {
|
|
20
|
+
\u4E00: {
|
|
21
|
+
bg: "var(--wk-rating-lv1-bg, rgba(16,185,129,0.14))",
|
|
22
|
+
color: "var(--wk-rating-lv1-color, #065F46)"
|
|
23
|
+
},
|
|
24
|
+
\u4E8C: {
|
|
25
|
+
bg: "var(--wk-rating-lv2-bg, rgba(59,130,246,0.14))",
|
|
26
|
+
color: "var(--wk-rating-lv2-color, #1E40AF)"
|
|
27
|
+
},
|
|
28
|
+
\u4E09: {
|
|
29
|
+
bg: "var(--wk-rating-lv3-bg, rgba(245,158,11,0.14))",
|
|
30
|
+
color: "var(--wk-rating-lv3-color, #78350F)"
|
|
31
|
+
},
|
|
32
|
+
\u56DB: {
|
|
33
|
+
bg: "var(--wk-rating-lv4-bg, rgba(249,115,22,0.14))",
|
|
34
|
+
color: "var(--wk-rating-lv4-color, #9A3412)"
|
|
35
|
+
},
|
|
36
|
+
\u4E94: {
|
|
37
|
+
bg: "var(--wk-rating-lv5-bg, rgba(239,68,68,0.14))",
|
|
38
|
+
color: "var(--wk-rating-lv5-color, #991B1B)"
|
|
39
|
+
},
|
|
40
|
+
"1": {
|
|
41
|
+
bg: "var(--wk-rating-lv1-bg, rgba(16,185,129,0.14))",
|
|
42
|
+
color: "var(--wk-rating-lv1-color, #065F46)"
|
|
43
|
+
},
|
|
44
|
+
"2": {
|
|
45
|
+
bg: "var(--wk-rating-lv2-bg, rgba(59,130,246,0.14))",
|
|
46
|
+
color: "var(--wk-rating-lv2-color, #1E40AF)"
|
|
47
|
+
},
|
|
48
|
+
"3": {
|
|
49
|
+
bg: "var(--wk-rating-lv3-bg, rgba(245,158,11,0.14))",
|
|
50
|
+
color: "var(--wk-rating-lv3-color, #78350F)"
|
|
51
|
+
},
|
|
52
|
+
"4": {
|
|
53
|
+
bg: "var(--wk-rating-lv4-bg, rgba(249,115,22,0.14))",
|
|
54
|
+
color: "var(--wk-rating-lv4-color, #9A3412)"
|
|
55
|
+
},
|
|
56
|
+
"5": {
|
|
57
|
+
bg: "var(--wk-rating-lv5-bg, rgba(239,68,68,0.14))",
|
|
58
|
+
color: "var(--wk-rating-lv5-color, #991B1B)"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
function renderTagNode(value, map) {
|
|
62
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
63
|
+
const item = map[value];
|
|
64
|
+
if (!item) return null;
|
|
65
|
+
return { tag: "jh-tag", item: [{ title: item.label, type: item.type }] };
|
|
66
|
+
}
|
|
67
|
+
function renderTagSlot(value, map) {
|
|
68
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
69
|
+
const item = map[value];
|
|
70
|
+
if (!item) return null;
|
|
71
|
+
const typeClass = item.type ? `jh-cell-tag--${item.type}` : "jh-cell-tag--default";
|
|
72
|
+
return h("span", { class: ["jh-cell-tag", typeClass] }, item.label);
|
|
73
|
+
}
|
|
74
|
+
function renderClassifyTag(value, map) {
|
|
75
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
76
|
+
const item = map[value];
|
|
77
|
+
if (!item) return null;
|
|
78
|
+
return h(
|
|
79
|
+
ElTag,
|
|
80
|
+
{ type: item.type || "primary", size: "small", effect: "plain" },
|
|
81
|
+
() => item.label
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
var AUTO_TAG_PALETTE = ["", "success", "warning", "info"];
|
|
85
|
+
var dictResolver = null;
|
|
86
|
+
function setDictResolver(fn) {
|
|
87
|
+
dictResolver = fn;
|
|
88
|
+
}
|
|
89
|
+
var DICT_COLOR_REGISTRY = {};
|
|
90
|
+
function registerDictColorMap(dictKey, colorMap) {
|
|
91
|
+
DICT_COLOR_REGISTRY[dictKey] = colorMap;
|
|
92
|
+
}
|
|
93
|
+
function registerDictColorMaps(maps) {
|
|
94
|
+
Object.assign(DICT_COLOR_REGISTRY, maps);
|
|
95
|
+
}
|
|
96
|
+
function autoTagType(value) {
|
|
97
|
+
const n = typeof value === "number" ? value : Number(value);
|
|
98
|
+
if (!Number.isNaN(n) && n > 0) {
|
|
99
|
+
return AUTO_TAG_PALETTE[(n - 1) % AUTO_TAG_PALETTE.length];
|
|
100
|
+
}
|
|
101
|
+
let hash = 0;
|
|
102
|
+
for (let i = 0; i < String(value).length; i++) {
|
|
103
|
+
hash = (hash << 5) - hash + String(value).charCodeAt(i) | 0;
|
|
104
|
+
}
|
|
105
|
+
return AUTO_TAG_PALETTE[Math.abs(hash) % AUTO_TAG_PALETTE.length];
|
|
106
|
+
}
|
|
107
|
+
function renderDictClassifyTag(value, dictKey, typeColorMap) {
|
|
108
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
109
|
+
let label = String(value);
|
|
110
|
+
if (dictResolver) {
|
|
111
|
+
const resolved = dictResolver(dictKey, value);
|
|
112
|
+
if (resolved) label = resolved;
|
|
113
|
+
}
|
|
114
|
+
const colorMap = typeColorMap ?? DICT_COLOR_REGISTRY[dictKey];
|
|
115
|
+
const tagType = colorMap?.[String(value)] ?? autoTagType(value);
|
|
116
|
+
return h(
|
|
117
|
+
ElTag,
|
|
118
|
+
{ type: tagType, size: "small", effect: "plain" },
|
|
119
|
+
() => label
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
function renderBadge(value) {
|
|
123
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
124
|
+
return h("span", { class: "jh-riskno-badge" }, String(value));
|
|
125
|
+
}
|
|
126
|
+
function renderCountBadge(value) {
|
|
127
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
128
|
+
return h("span", { class: "jh-count-badge" }, String(value));
|
|
129
|
+
}
|
|
130
|
+
function renderDangerText(value) {
|
|
131
|
+
if (value === null || value === void 0 || value === "") return null;
|
|
132
|
+
return h(
|
|
133
|
+
"span",
|
|
134
|
+
{ style: { color: "var(--el-color-danger)", fontWeight: 500 } },
|
|
135
|
+
String(value)
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
function renderRatingLevel(value) {
|
|
139
|
+
if (!value) return null;
|
|
140
|
+
const clr = RATING_LEVEL_COLORS[value] ?? {
|
|
141
|
+
bg: "var(--wk-rating-fallback-bg, rgba(107,114,128,0.12))",
|
|
142
|
+
color: "var(--wk-rating-fallback-color, #374151)"
|
|
143
|
+
};
|
|
144
|
+
return h(
|
|
145
|
+
"span",
|
|
146
|
+
{
|
|
147
|
+
class: "jh-rating-lv",
|
|
148
|
+
style: { "--lv-bg": clr.bg, "--lv-color": clr.color }
|
|
149
|
+
},
|
|
150
|
+
value
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
var renderEnableStatus = (v) => renderTagNode(v, ENABLE_STATUS_MAP);
|
|
154
|
+
var renderAuditStatus = (v) => renderTagNode(v, AUDIT_STATUS_MAP);
|
|
155
|
+
var renderVerifyStatus = (v) => renderTagNode(v, VERIFY_STATUS_MAP);
|
|
156
|
+
var ICON_PRESETS = {
|
|
157
|
+
view: { icon: View, cls: "jh-op-view", title: "\u67E5\u770B" },
|
|
158
|
+
edit: { icon: Edit, cls: "jh-op-edit", title: "\u7F16\u8F91" },
|
|
159
|
+
del: { icon: Delete, cls: "jh-op-del", title: "\u5220\u9664" },
|
|
160
|
+
danger: { icon: Delete, cls: "jh-op-del", title: "\u5220\u9664" },
|
|
161
|
+
log: { icon: Document, cls: "jh-op-log", title: "\u8BB0\u5F55" },
|
|
162
|
+
ok: { icon: CircleCheck, cls: "jh-op-ok", title: "\u5BA1\u6838" },
|
|
163
|
+
send: { icon: Upload, cls: "jh-op-send", title: "\u63D0\u4EA4" }
|
|
164
|
+
};
|
|
165
|
+
function isOpVisible(item) {
|
|
166
|
+
if (typeof item.show === "function") return item.show();
|
|
167
|
+
return item.show !== false;
|
|
168
|
+
}
|
|
169
|
+
function renderOps(items) {
|
|
170
|
+
const visible = items.filter(isOpVisible);
|
|
171
|
+
const iconItems = visible.filter((i) => i.type in ICON_PRESETS);
|
|
172
|
+
const otherItems = visible.filter((i) => !(i.type in ICON_PRESETS));
|
|
173
|
+
const nodes = [];
|
|
174
|
+
for (const item of iconItems) {
|
|
175
|
+
const preset = ICON_PRESETS[item.type];
|
|
176
|
+
nodes.push(
|
|
177
|
+
h(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
class: ["jh-op-btn", preset.cls],
|
|
181
|
+
type: "button",
|
|
182
|
+
title: item.title ?? item.label ?? preset.title,
|
|
183
|
+
onClick: (e) => {
|
|
184
|
+
e.stopPropagation();
|
|
185
|
+
item.onClick(e);
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
h(preset.icon)
|
|
189
|
+
)
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
if (iconItems.length > 0 && otherItems.length > 0)
|
|
193
|
+
nodes.push(h("span", { class: "jh-op-sep", "aria-hidden": "true" }));
|
|
194
|
+
for (const item of otherItems) {
|
|
195
|
+
if (item.type === "chip") {
|
|
196
|
+
const children = [];
|
|
197
|
+
if (item.icon) children.push(h(item.icon));
|
|
198
|
+
children.push(h("span", null, item.label));
|
|
199
|
+
nodes.push(
|
|
200
|
+
h(
|
|
201
|
+
"button",
|
|
202
|
+
{
|
|
203
|
+
class: "jh-op-chip",
|
|
204
|
+
type: "button",
|
|
205
|
+
onClick: (e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
item.onClick(e);
|
|
208
|
+
}
|
|
209
|
+
},
|
|
210
|
+
children
|
|
211
|
+
)
|
|
212
|
+
);
|
|
213
|
+
} else {
|
|
214
|
+
nodes.push(
|
|
215
|
+
h(
|
|
216
|
+
"button",
|
|
217
|
+
{
|
|
218
|
+
class: "jh-op-link",
|
|
219
|
+
type: "button",
|
|
220
|
+
onClick: (e) => {
|
|
221
|
+
e.stopPropagation();
|
|
222
|
+
item.onClick(e);
|
|
223
|
+
}
|
|
224
|
+
},
|
|
225
|
+
item.label
|
|
226
|
+
)
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return h("div", { class: "jh-op-group" }, nodes);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
// runtime/core/registry.ts
|
|
234
|
+
var COLUMN_AUTO_MAP = {};
|
|
235
|
+
function registerColumnAutoMap(name, config) {
|
|
236
|
+
COLUMN_AUTO_MAP[name] = config;
|
|
237
|
+
}
|
|
238
|
+
function registerColumnAutoMaps(maps) {
|
|
239
|
+
Object.assign(COLUMN_AUTO_MAP, maps);
|
|
240
|
+
}
|
|
241
|
+
function getColumnAutoMap() {
|
|
242
|
+
return COLUMN_AUTO_MAP;
|
|
243
|
+
}
|
|
244
|
+
function clearColumnAutoMap(name) {
|
|
245
|
+
if (name) delete COLUMN_AUTO_MAP[name];
|
|
246
|
+
else for (const k of Object.keys(COLUMN_AUTO_MAP)) delete COLUMN_AUTO_MAP[k];
|
|
247
|
+
}
|
|
248
|
+
function defineColumns(columns) {
|
|
249
|
+
return columns.map((col) => {
|
|
250
|
+
const fieldName = col.name ?? col.label ?? "";
|
|
251
|
+
const preset = COLUMN_AUTO_MAP[fieldName];
|
|
252
|
+
const hasRenderer = col.defaultNode !== void 0 || col.defaultSlot !== void 0;
|
|
253
|
+
if (hasRenderer) return col;
|
|
254
|
+
if (!preset && isDictColumn(col)) {
|
|
255
|
+
return {
|
|
256
|
+
...col,
|
|
257
|
+
defaultSlot: ({ row }) => renderDictClassifyTag(row?.[fieldName], String(col.logicValue))
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
if (!preset) return col;
|
|
261
|
+
return { ...preset, ...col };
|
|
262
|
+
});
|
|
263
|
+
}
|
|
264
|
+
function isDictColumn(col) {
|
|
265
|
+
const logicType = String(col.logicType ?? "").toLowerCase();
|
|
266
|
+
return Boolean(col.logicValue) && logicType.includes("dict");
|
|
267
|
+
}
|
|
268
|
+
registerColumnAutoMaps({
|
|
269
|
+
enableStatus: {
|
|
270
|
+
width: 80,
|
|
271
|
+
fixed: "right",
|
|
272
|
+
defaultNode: ({ row }) => renderEnableStatus(row.enableStatus)
|
|
273
|
+
},
|
|
274
|
+
approvalStatus: {
|
|
275
|
+
width: 90,
|
|
276
|
+
fixed: "right",
|
|
277
|
+
defaultNode: ({ row }) => renderAuditStatus(row.approvalStatus)
|
|
278
|
+
},
|
|
279
|
+
verifyStatus: {
|
|
280
|
+
width: 90,
|
|
281
|
+
fixed: "right",
|
|
282
|
+
defaultNode: ({ row }) => renderVerifyStatus(row.verifyStatus)
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
export { AUDIT_STATUS_MAP, ENABLE_STATUS_MAP, RATING_LEVEL_COLORS, VERIFY_STATUS_MAP, clearColumnAutoMap, defineColumns, getColumnAutoMap, registerColumnAutoMap, registerColumnAutoMaps, registerDictColorMap, registerDictColorMaps, renderAuditStatus, renderBadge, renderClassifyTag, renderCountBadge, renderDangerText, renderDictClassifyTag, renderEnableStatus, renderOps, renderRatingLevel, renderTagNode, renderTagSlot, renderVerifyStatus, setDictResolver };
|