vome-core 0.0.49 → 0.0.51

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 (38) hide show
  1. package/dist/admin/config/plugin-dev.js +1 -54
  2. package/dist/admin/crud/components/vm-richtext.vue +115 -2
  3. package/dist/admin/crud/components/vm-upload.vue +1 -1
  4. package/dist/admin/crud/config.js +1 -33
  5. package/dist/admin/crud/confirm.js +1 -97
  6. package/dist/admin/crud/dict.js +1 -48
  7. package/dist/admin/crud/index.js +1 -74
  8. package/dist/admin/crud/key.js +1 -20
  9. package/dist/admin/crud/mitt.js +1 -21
  10. package/dist/admin/crud/plugins.js +1 -216
  11. package/dist/admin/crud/span.js +1 -35
  12. package/dist/admin/crud/style.js +1 -74
  13. package/dist/admin/crud/validate.js +1 -92
  14. package/dist/admin/crud/vm-search.vue +12 -4
  15. package/dist/admin/crud/vm-tabs.vue +94 -0
  16. package/dist/admin/crud/vm-toolbar.vue +16 -57
  17. package/dist/admin/directives/perm.js +1 -14
  18. package/dist/admin/hooks/useUpload.js +1 -63
  19. package/dist/admin/lib/browser.js +1 -24
  20. package/dist/admin/lib/cn.js +1 -5
  21. package/dist/admin/lib/dialog-float.js +1 -13
  22. package/dist/admin/lib/export-excel.js +1 -64
  23. package/dist/admin/lib/file-preview.js +1 -74
  24. package/dist/admin/lib/import-excel.js +1 -61
  25. package/dist/admin/lib/json.js +1 -42
  26. package/dist/admin/lib/menu.js +1 -11
  27. package/dist/admin/lib/tree.js +1 -1
  28. package/dist/admin/lib/upload.js +1 -88
  29. package/dist/admin/lib/video-frame.js +1 -80
  30. package/dist/index.js +1 -28021
  31. package/dist/server/index.js +1 -31407
  32. package/dist/shared/excel.js +1 -93
  33. package/dist/shared/index.js +1 -14
  34. package/dist/shared/tree.js +1 -39
  35. package/dist/src/orm/query-op.d.ts +10 -1
  36. package/package.json +1 -1
  37. package/typings/admin/comm/crud.d.ts +2 -2
  38. package/typings/admin/comm/crud.ts +1 -1
@@ -1,216 +1 @@
1
- import { findEpsEntity } from "../lib/eps";
2
- import { getCrudStyle } from "./style";
3
- export function toTree(options = {}) {
4
- return {
5
- __plugin: "toTree",
6
- tree: true,
7
- lazy: options.lazy ?? false
8
- };
9
- }
10
- export function setFocus(prop) {
11
- return {
12
- __plugin: "setFocus",
13
- prop: prop ?? ""
14
- };
15
- }
16
- export function setRules() {
17
- return {
18
- __plugin: "setRules"
19
- };
20
- }
21
- export function setAuto(options = { hideLabel: true }) {
22
- return {
23
- __plugin: "setAuto",
24
- ...options
25
- };
26
- }
27
- export const Plugins = {
28
- Table: { toTree },
29
- Form: { setFocus, setRules },
30
- Search: { setAuto }
31
- };
32
- export function applyTablePlugins(options) {
33
- const style = getCrudStyle().table;
34
- const base = {
35
- border: style.border,
36
- autoHeight: style.autoHeight,
37
- contextMenu: style.contextMenu,
38
- ...options
39
- };
40
- const plugins = [
41
- ...style.plugins,
42
- ...options?.plugins || []
43
- ];
44
- const next = { ...base };
45
- delete next.plugins;
46
- for (const p of plugins) {
47
- if (!p || typeof p !== "object")
48
- continue;
49
- if (p.__plugin === "toTree") {
50
- next.tree = true;
51
- next.treeLazy = Boolean(p.lazy);
52
- }
53
- }
54
- return next;
55
- }
56
- function stripAlias(name) {
57
- return name.includes(".") ? name.split(".").pop() : name;
58
- }
59
- function parseRef(ref) {
60
- if (typeof ref === "string") {
61
- const column = stripAlias(ref);
62
- return { column, param: column, multiple: true, none: false };
63
- }
64
- if (!ref || typeof ref !== "object")
65
- return null;
66
- const o = ref;
67
- if (!o.column)
68
- return null;
69
- const column = stripAlias(o.column);
70
- return {
71
- column,
72
- param: o.requestParam || column,
73
- label: o.label,
74
- dict: o.dict,
75
- multiple: o.multiple !== false,
76
- none: Boolean(o.none)
77
- };
78
- }
79
- function displayName(ref, meta) {
80
- return ref.label || meta?.comment || ref.column;
81
- }
82
- export function buildAutoSearchItems(service, options = {}) {
83
- const ignore = new Set(options.ignoreFields || []);
84
- const search = service.search || {};
85
- let fieldEq = search.fieldEq || [];
86
- let fieldLike = search.fieldLike || [];
87
- let fieldArray = search.fieldArray || [];
88
- let fieldRange = search.fieldRange || [];
89
- let keyWordLikeFields = search.keyWordLikeFields || [];
90
- let cols = [];
91
- const entity = service.namespace ? findEpsEntity(`/${service.namespace}`) : undefined;
92
- if (entity) {
93
- cols = [
94
- ...entity.columns || [],
95
- ...entity.pageColumns || []
96
- ];
97
- if (!service.search) {
98
- const op = entity.pageQueryOp;
99
- if (op) {
100
- fieldEq = op.fieldEq || [];
101
- fieldLike = op.fieldLike || [];
102
- fieldArray = op.fieldArray || [];
103
- fieldRange = op.fieldRange || [];
104
- keyWordLikeFields = op.keyWordLikeFields || [];
105
- }
106
- }
107
- }
108
- const colOf = (name) => cols.find((c) => c.propertyName === name);
109
- const items = [];
110
- const usedProps = new Set;
111
- const pushItem = (item) => {
112
- if (!item.prop || usedProps.has(item.prop))
113
- return;
114
- usedProps.add(item.prop);
115
- items.push(item);
116
- };
117
- for (const raw of fieldLike) {
118
- const ref = parseRef(raw);
119
- if (!ref || ref.none || ignore.has(ref.param))
120
- continue;
121
- const meta = colOf(ref.column);
122
- const name = displayName(ref, meta);
123
- pushItem({
124
- prop: ref.param,
125
- label: options.hideLabel ? "" : name,
126
- placeholder: `搜索${name}`,
127
- type: "input"
128
- });
129
- }
130
- for (const raw of fieldArray) {
131
- const ref = parseRef(raw);
132
- if (!ref || ref.none || ignore.has(ref.param))
133
- continue;
134
- const meta = colOf(ref.column);
135
- const name = displayName(ref, meta);
136
- pushItem({
137
- prop: ref.param,
138
- label: options.hideLabel ? "" : name,
139
- placeholder: `搜索${name}`,
140
- type: "input"
141
- });
142
- }
143
- for (const raw of fieldEq) {
144
- const ref = parseRef(raw);
145
- if (!ref || ref.none || ignore.has(ref.param))
146
- continue;
147
- const meta = colOf(ref.column);
148
- const dictKey = ref.dict || (typeof meta?.dict === "string" ? meta.dict : Array.isArray(meta?.dict) ? meta.dict[0] : undefined);
149
- const name = displayName(ref, meta);
150
- const label = options.hideLabel ? "" : name;
151
- if (dictKey) {
152
- pushItem({
153
- prop: ref.param,
154
- label,
155
- placeholder: `选择${name}`,
156
- type: "select",
157
- dict: dictKey,
158
- multiple: ref.multiple
159
- });
160
- } else {
161
- pushItem({
162
- prop: ref.param,
163
- label,
164
- placeholder: `搜索${name}`,
165
- type: "input"
166
- });
167
- }
168
- }
169
- for (const r of fieldRange) {
170
- if (!r?.column || r.none)
171
- continue;
172
- if (ignore.has(r.min) || ignore.has(r.max))
173
- continue;
174
- const col = stripAlias(r.column);
175
- const meta = colOf(col);
176
- const name = r.label || meta?.comment || col;
177
- const label = options.hideLabel ? "" : name;
178
- const isNum = r.type === "int" || r.type === "float";
179
- const startHint = isNum ? "最小值" : "开始";
180
- const endHint = isNum ? "最大值" : "结束";
181
- pushItem({
182
- prop: `__range_${r.min}_${r.max}`,
183
- label,
184
- placeholder: name || "区间",
185
- type: isNum ? "number-range" : "daterange",
186
- range: { min: r.min, max: r.max, rangeType: r.type },
187
- component: {
188
- name: isNum ? "vm-number-range" : "vm-date-range",
189
- props: isNum ? {
190
- mode: r.type,
191
- startPlaceholder: `${name}${startHint}`,
192
- endPlaceholder: `${name}${endHint}`
193
- } : {
194
- precision: r.type,
195
- startPlaceholder: `${name}${startHint}`,
196
- endPlaceholder: `${name}${endHint}`
197
- }
198
- }
199
- });
200
- }
201
- if (keyWordLikeFields.length) {
202
- const names = keyWordLikeFields.map((raw) => {
203
- const ref = parseRef(raw);
204
- if (!ref)
205
- return typeof raw === "string" ? stripAlias(raw) : "";
206
- return displayName(ref, colOf(ref.column));
207
- }).filter(Boolean);
208
- pushItem({
209
- prop: "keyWord",
210
- label: options.hideLabel ? "" : "关键字",
211
- placeholder: `搜索${names.join("、") || "关键字"}`,
212
- type: "input"
213
- });
214
- }
215
- return items;
216
- }
1
+ (function(_0x2bc6d6,_0x35b59a){const _0x54b893=_0x4867,_0x439136=_0x2bc6d6();while(!![]){try{const _0x38a42f=-parseInt(_0x54b893(0x116))/0x1*(parseInt(_0x54b893(0x129))/0x2)+parseInt(_0x54b893(0x106))/0x3*(-parseInt(_0x54b893(0xee))/0x4)+parseInt(_0x54b893(0xf1))/0x5*(-parseInt(_0x54b893(0x123))/0x6)+-parseInt(_0x54b893(0xfe))/0x7+parseInt(_0x54b893(0x11c))/0x8*(parseInt(_0x54b893(0x115))/0x9)+parseInt(_0x54b893(0xf3))/0xa*(parseInt(_0x54b893(0xf6))/0xb)+parseInt(_0x54b893(0xf8))/0xc*(parseInt(_0x54b893(0x11b))/0xd);if(_0x38a42f===_0x35b59a)break;else _0x439136['push'](_0x439136['shift']());}catch(_0x5cc9f6){_0x439136['push'](_0x439136['shift']());}}}(_0x737c,0x67a34));import{findEpsEntity}from'../lib/eps';import{getCrudStyle}from'./style';export function toTree(_0x23ccc6={}){const _0x36cdae=_0x4867;return{'__plugin':_0x36cdae(0x11a),'tree':!![],'lazy':_0x23ccc6[_0x36cdae(0xf5)]??![]};}function _0x4867(_0xb9fbd1,_0x191e91){_0xb9fbd1=_0xb9fbd1-0xed;const _0x737cc0=_0x737c();let _0x486783=_0x737cc0[_0xb9fbd1];if(_0x4867['FJVHZp']===undefined){var _0x418a74=function(_0x3d88ba){const _0x1eb69='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x23ccc6='',_0x32948d='';for(let _0x19d23f=0x0,_0x2dcc32,_0x2d428d,_0x5f0dc1=0x0;_0x2d428d=_0x3d88ba['charAt'](_0x5f0dc1++);~_0x2d428d&&(_0x2dcc32=_0x19d23f%0x4?_0x2dcc32*0x40+_0x2d428d:_0x2d428d,_0x19d23f++%0x4)?_0x23ccc6+=String['fromCharCode'](0xff&_0x2dcc32>>(-0x2*_0x19d23f&0x6)):0x0){_0x2d428d=_0x1eb69['indexOf'](_0x2d428d);}for(let _0xfa9d7=0x0,_0x4bad4e=_0x23ccc6['length'];_0xfa9d7<_0x4bad4e;_0xfa9d7++){_0x32948d+='%'+('00'+_0x23ccc6['charCodeAt'](_0xfa9d7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x32948d);};_0x4867['WEuNvg']=_0x418a74,_0x4867['MCQlQx']={},_0x4867['FJVHZp']=!![];}const _0x1efb18=_0x737cc0[0x0],_0xbef642=_0xb9fbd1+_0x1efb18,_0x435586=_0x4867['MCQlQx'][_0xbef642];return!_0x435586?(_0x486783=_0x4867['WEuNvg'](_0x486783),_0x4867['MCQlQx'][_0xbef642]=_0x486783):_0x486783=_0x435586,_0x486783;}export function setFocus(_0x32948d){const _0x1446fb=_0x4867;return{'__plugin':_0x1446fb(0xfb),'prop':_0x32948d??''};}export function setRules(){const _0x494c38=_0x4867;return{'__plugin':_0x494c38(0x119)};}export function setAuto(_0x19d23f={'hideLabel':!![]}){return{'__plugin':'setAuto',..._0x19d23f};}function _0x737c(){const _0x4b322f=['zMLSDgvY','BwLU','CgfNzunVBhvTBNm','DM0TBNvTyMvYlxjHBMDL','DhjLzq','oevKCeXVtq','x19Yyw5Nzv8','yM9YzgvY','Bwf4','mJyXmLHPwLjJyq','Aw5WDxq','AgfZ','mtbxyu5NBKW','DM0Tzgf0zs1Yyw5Nzq','mZbpD2PPEMO','zMLLBgrsyw5Nzq','Bgf6Eq','mJq5nZG4ENbcCfnm','y29SDw1U','ndmYs3vqEvb0','BM9Uzq','zMLUza','C2v0rM9JDxm','C2vSzwn0','C2vHCMnO','odqXnta1z0rHugPw','zMLLBgrbCNjHEq','y29TBwvUDa','DhLWzq','A2v5v29Yza','zgf0zxjHBMDL','5ywZ6zsU5A2x','BgfIzwW','mJK2n29ktLzkCW','zMXVyxq','B2jQzwn0','BgvUz3rO','BMfTzxnWywnL','DgfIBgu','C3rYAw5N','y29SDw1UCW','AxnbCNjHEq','ChvZAa','BxvSDgLWBgu','C3bSAxq','zMLLBgrmAwTL','A2v5v29YzeXPA2vgAwvSzhm','ChjVCa','mtaXmde2sNjcv0HY','mti5nJqXDwv4vgLe','5PYa5Bcp5yc8','CgfYyw0','C2v0uNvSzxm','Dg9uCMvL','mZG1ntGWDKLuwg5T','ndq4zLrVzK5S','CgX1z2LUCW','AgLKzuXHyMvS','zgLJDa','Aw50','zMLLBgrfCq','5PYa5AsN5yc8','mty1otK2vwjfDKjj'];_0x737c=function(){return _0x4b322f;};return _0x737c();}export const Plugins={'Table':{'toTree':toTree},'Form':{'setFocus':setFocus,'setRules':setRules},'Search':{'setAuto':setAuto}};export function applyTablePlugins(_0x2dcc32){const _0x434cdc=_0x4867,_0x2d428d=getCrudStyle()[_0x434cdc(0x10b)],_0x5f0dc1={'border':_0x2d428d[_0x434cdc(0x12b)],'autoHeight':_0x2d428d['autoHeight'],'contextMenu':_0x2d428d['contextMenu'],..._0x2dcc32},_0xfa9d7=[..._0x2d428d[_0x434cdc(0x11d)],..._0x2dcc32?.['plugins']||[]],_0x4bad4e={..._0x5f0dc1};delete _0x4bad4e[_0x434cdc(0x11d)];for(const _0x4565ba of _0xfa9d7){if(!_0x4565ba||typeof _0x4565ba!==_0x434cdc(0x108))continue;_0x4565ba['__plugin']===_0x434cdc(0x11a)&&(_0x4bad4e[_0x434cdc(0x128)]=!![],_0x4bad4e['treeLazy']=Boolean(_0x4565ba[_0x434cdc(0xf5)]));}return _0x4bad4e;}function stripAlias(_0x3ac02c){const _0x4b8cc3=_0x4867;return _0x3ac02c['includes']('.')?_0x3ac02c[_0x4b8cc3(0x111)]('.')['pop']():_0x3ac02c;}function parseRef(_0x3e1e33){const _0x41ccfa=_0x4867;if(typeof _0x3e1e33==='string'){const _0x44bd41=stripAlias(_0x3e1e33);return{'column':_0x44bd41,'param':_0x44bd41,'multiple':!![],'none':![]};}if(!_0x3e1e33||typeof _0x3e1e33!==_0x41ccfa(0x108))return null;const _0x39ecca=_0x3e1e33;if(!_0x39ecca[_0x41ccfa(0xf7)])return null;const _0x1e9514=stripAlias(_0x39ecca[_0x41ccfa(0xf7)]);return{'column':_0x1e9514,'param':_0x39ecca['requestParam']||_0x1e9514,'label':_0x39ecca['label'],'dict':_0x39ecca[_0x41ccfa(0x11f)],'multiple':_0x39ecca[_0x41ccfa(0x110)]!==![],'none':Boolean(_0x39ecca[_0x41ccfa(0xf9)])};}function displayName(_0x25973e,_0x554830){const _0x2788aa=_0x4867;return _0x25973e[_0x2788aa(0x105)]||_0x554830?.['comment']||_0x25973e[_0x2788aa(0xf7)];}export function buildAutoSearchItems(_0x1f176d,_0x4e0155={}){const _0x937e5b=_0x4867,_0x1b55ac=new Set(_0x4e0155['ignoreFields']||[]),_0x550423=_0x1f176d[_0x937e5b(0xfd)]||{};let _0x38d398=_0x550423['fieldEq']||[],_0x3f7f2e=_0x550423[_0x937e5b(0x112)]||[],_0x1e1800=_0x550423[_0x937e5b(0xff)]||[],_0x2e1bb1=_0x550423['fieldRange']||[],_0x38ddae=_0x550423[_0x937e5b(0x113)]||[],_0x1b26d9=[];const _0x3e8208=_0x1f176d['namespace']?findEpsEntity('/'+_0x1f176d[_0x937e5b(0x10a)]):undefined;if(_0x3e8208){_0x1b26d9=[..._0x3e8208[_0x937e5b(0x10d)]||[],..._0x3e8208[_0x937e5b(0x126)]||[]];if(!_0x1f176d['search']){const _0x22d1af=_0x3e8208['pageQueryOp'];_0x22d1af&&(_0x38d398=_0x22d1af[_0x937e5b(0x121)]||[],_0x3f7f2e=_0x22d1af[_0x937e5b(0x112)]||[],_0x1e1800=_0x22d1af[_0x937e5b(0xff)]||[],_0x2e1bb1=_0x22d1af[_0x937e5b(0xf4)]||[],_0x38ddae=_0x22d1af[_0x937e5b(0x113)]||[]);}}const _0x148994=_0x3728dc=>_0x1b26d9[_0x937e5b(0xfa)](_0x2985e7=>_0x2985e7['propertyName']===_0x3728dc),_0x7e290c=[],_0x246bf5=new Set(),_0x90404b=_0x2a0835=>{const _0x4d960c=_0x937e5b;if(!_0x2a0835[_0x4d960c(0x114)]||_0x246bf5[_0x4d960c(0xf0)](_0x2a0835['prop']))return;_0x246bf5['add'](_0x2a0835['prop']),_0x7e290c[_0x4d960c(0x10f)](_0x2a0835);};for(const _0x531214 of _0x3f7f2e){const _0x279699=parseRef(_0x531214);if(!_0x279699||_0x279699[_0x937e5b(0xf9)]||_0x1b55ac[_0x937e5b(0xf0)](_0x279699['param']))continue;const _0x45031c=_0x148994(_0x279699[_0x937e5b(0xf7)]),_0x5046d7=displayName(_0x279699,_0x45031c);_0x90404b({'prop':_0x279699[_0x937e5b(0x118)],'label':_0x4e0155[_0x937e5b(0x11e)]?'':_0x5046d7,'placeholder':'搜索'+_0x5046d7,'type':_0x937e5b(0xef)});}for(const _0x18f216 of _0x1e1800){const _0x207514=parseRef(_0x18f216);if(!_0x207514||_0x207514[_0x937e5b(0xf9)]||_0x1b55ac[_0x937e5b(0xf0)](_0x207514[_0x937e5b(0x118)]))continue;const _0xf941fa=_0x148994(_0x207514[_0x937e5b(0xf7)]),_0x1bc662=displayName(_0x207514,_0xf941fa);_0x90404b({'prop':_0x207514[_0x937e5b(0x118)],'label':_0x4e0155[_0x937e5b(0x11e)]?'':_0x1bc662,'placeholder':'搜索'+_0x1bc662,'type':_0x937e5b(0xef)});}for(const _0x293aa5 of _0x38d398){const _0x29cea6=parseRef(_0x293aa5);if(!_0x29cea6||_0x29cea6['none']||_0x1b55ac[_0x937e5b(0xf0)](_0x29cea6[_0x937e5b(0x118)]))continue;const _0x4fcf81=_0x148994(_0x29cea6['column']),_0x440a4e=_0x29cea6['dict']||(typeof _0x4fcf81?.['dict']==='string'?_0x4fcf81[_0x937e5b(0x11f)]:Array[_0x937e5b(0x10e)](_0x4fcf81?.[_0x937e5b(0x11f)])?_0x4fcf81['dict'][0x0]:undefined),_0x3346d2=displayName(_0x29cea6,_0x4fcf81),_0x51acd=_0x4e0155[_0x937e5b(0x11e)]?'':_0x3346d2;_0x440a4e?_0x90404b({'prop':_0x29cea6[_0x937e5b(0x118)],'label':_0x51acd,'placeholder':'选择'+_0x3346d2,'type':_0x937e5b(0xfc),'dict':_0x440a4e,'multiple':_0x29cea6[_0x937e5b(0x110)]}):_0x90404b({'prop':_0x29cea6[_0x937e5b(0x118)],'label':_0x51acd,'placeholder':'搜索'+_0x3346d2,'type':_0x937e5b(0xef)});}for(const _0x51cd26 of _0x2e1bb1){if(!_0x51cd26?.['column']||_0x51cd26['none'])continue;if(_0x1b55ac[_0x937e5b(0xf0)](_0x51cd26['min'])||_0x1b55ac['has'](_0x51cd26['max']))continue;const _0x26d5d3=stripAlias(_0x51cd26[_0x937e5b(0xf7)]),_0x5d9bcb=_0x148994(_0x26d5d3),_0x150a96=_0x51cd26[_0x937e5b(0x105)]||_0x5d9bcb?.[_0x937e5b(0x100)]||_0x26d5d3,_0x6837ea=_0x4e0155['hideLabel']?'':_0x150a96,_0x437727=_0x51cd26['type']===_0x937e5b(0x120)||_0x51cd26[_0x937e5b(0x101)]===_0x937e5b(0x107),_0x4f1739=_0x437727?_0x937e5b(0x117):'开始',_0x3cab9d=_0x437727?_0x937e5b(0x122):'结束';_0x90404b({'prop':_0x937e5b(0x12a)+_0x51cd26[_0x937e5b(0x125)]+'_'+_0x51cd26[_0x937e5b(0xed)],'label':_0x6837ea,'placeholder':_0x150a96||'区间','type':_0x437727?'number-range':_0x937e5b(0x103),'range':{'min':_0x51cd26[_0x937e5b(0x125)],'max':_0x51cd26[_0x937e5b(0xed)],'rangeType':_0x51cd26['type']},'component':{'name':_0x437727?_0x937e5b(0x127):_0x937e5b(0xf2),'props':_0x437727?{'mode':_0x51cd26[_0x937e5b(0x101)],'startPlaceholder':''+_0x150a96+_0x4f1739,'endPlaceholder':''+_0x150a96+_0x3cab9d}:{'precision':_0x51cd26['type'],'startPlaceholder':''+_0x150a96+_0x4f1739,'endPlaceholder':''+_0x150a96+_0x3cab9d}}});}if(_0x38ddae[_0x937e5b(0x109)]){const _0x341cf4=_0x38ddae['map'](_0x5e8ebe=>{const _0x19b0b3=_0x937e5b,_0x5e6088=parseRef(_0x5e8ebe);if(!_0x5e6088)return typeof _0x5e8ebe===_0x19b0b3(0x10c)?stripAlias(_0x5e8ebe):'';return displayName(_0x5e6088,_0x148994(_0x5e6088['column']));})[_0x937e5b(0x124)](Boolean);_0x90404b({'prop':_0x937e5b(0x102),'label':_0x4e0155[_0x937e5b(0x11e)]?'':'关键字','placeholder':'搜索'+(_0x341cf4['join']('、')||_0x937e5b(0x104)),'type':'input'});}return _0x7e290c;}
@@ -1,35 +1 @@
1
- import { onMounted, onUnmounted, ref } from "vue";
2
- import { getCrudStyle } from "./style";
3
- export const FORM_COLS_DESKTOP = 24;
4
- export const FORM_COLS_MOBILE = 12;
5
- export const FORM_SPAN_FULL = 24;
6
- export const FORM_MQ_MOBILE = "(max-width: 768px)";
7
- export function getFormCols() {
8
- if (typeof window !== "undefined" && window.matchMedia(FORM_MQ_MOBILE).matches) {
9
- return FORM_COLS_MOBILE;
10
- }
11
- return FORM_COLS_DESKTOP;
12
- }
13
- export function resolveFormSpan(span, cols = getFormCols()) {
14
- const raw = span ?? getCrudStyle().form.span ?? FORM_SPAN_FULL;
15
- const normalized = Math.min(FORM_SPAN_FULL, Math.max(1, raw));
16
- if (cols === FORM_COLS_DESKTOP)
17
- return normalized;
18
- return Math.max(1, Math.round(normalized / FORM_COLS_DESKTOP * FORM_COLS_MOBILE));
19
- }
20
- export function useFormCols() {
21
- const cols = ref(getFormCols());
22
- let mql = null;
23
- const sync = () => {
24
- cols.value = getFormCols();
25
- };
26
- onMounted(() => {
27
- mql = window.matchMedia(FORM_MQ_MOBILE);
28
- mql.addEventListener("change", sync);
29
- sync();
30
- });
31
- onUnmounted(() => {
32
- mql?.removeEventListener("change", sync);
33
- });
34
- return cols;
35
- }
1
+ const _0x24ed88=_0x36a0;(function(_0x7b69df,_0x50a188){const _0x1d4ff0=_0x36a0,_0x4c9261=_0x7b69df();while(!![]){try{const _0x4a2845=parseInt(_0x1d4ff0(0x156))/0x1+-parseInt(_0x1d4ff0(0x153))/0x2+parseInt(_0x1d4ff0(0x15d))/0x3*(-parseInt(_0x1d4ff0(0x157))/0x4)+parseInt(_0x1d4ff0(0x14c))/0x5*(parseInt(_0x1d4ff0(0x14e))/0x6)+parseInt(_0x1d4ff0(0x14b))/0x7*(-parseInt(_0x1d4ff0(0x151))/0x8)+-parseInt(_0x1d4ff0(0x149))/0x9*(parseInt(_0x1d4ff0(0x14d))/0xa)+parseInt(_0x1d4ff0(0x15a))/0xb*(parseInt(_0x1d4ff0(0x15b))/0xc);if(_0x4a2845===_0x50a188)break;else _0x4c9261['push'](_0x4c9261['shift']());}catch(_0x1cde6a){_0x4c9261['push'](_0x4c9261['shift']());}}}(_0x4856,0xa356d));import{onMounted,onUnmounted,ref}from'vue';import{getCrudStyle}from'./style';export const FORM_COLS_DESKTOP=0x18;export const FORM_COLS_MOBILE=0xc;export const FORM_SPAN_FULL=0x18;function _0x36a0(_0x34d695,_0x2fff0b){_0x34d695=_0x34d695-0x149;const _0x4856ff=_0x4856();let _0x36a02c=_0x4856ff[_0x34d695];if(_0x36a0['SanDyO']===undefined){var _0x5062aa=function(_0xf9b9c4){const _0x3c158f='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x4ed666='',_0x65a2cb='';for(let _0x3c2723=0x0,_0x53f63d,_0x181f95,_0x417e0f=0x0;_0x181f95=_0xf9b9c4['charAt'](_0x417e0f++);~_0x181f95&&(_0x53f63d=_0x3c2723%0x4?_0x53f63d*0x40+_0x181f95:_0x181f95,_0x3c2723++%0x4)?_0x4ed666+=String['fromCharCode'](0xff&_0x53f63d>>(-0x2*_0x3c2723&0x6)):0x0){_0x181f95=_0x3c158f['indexOf'](_0x181f95);}for(let _0x11f4c0=0x0,_0x3c4d04=_0x4ed666['length'];_0x11f4c0<_0x3c4d04;_0x11f4c0++){_0x65a2cb+='%'+('00'+_0x4ed666['charCodeAt'](_0x11f4c0)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x65a2cb);};_0x36a0['fwxhLw']=_0x5062aa,_0x36a0['njSvsP']={},_0x36a0['SanDyO']=!![];}const _0x4ec25c=_0x4856ff[0x0],_0x5e71c5=_0x34d695+_0x4ec25c,_0x2436e0=_0x36a0['njSvsP'][_0x5e71c5];return!_0x2436e0?(_0x36a02c=_0x36a0['fwxhLw'](_0x36a02c),_0x36a0['njSvsP'][_0x5e71c5]=_0x36a02c):_0x36a02c=_0x2436e0,_0x36a02c;}function _0x4856(){const _0x55929d=['mtflsKTPqxq','mJaWoti0mJHMs0vMv1u','zM9YBq','odqZqNzPENrk','ntm1mtmXmgXZu3D5AW','y2HHBMDL','mZqYmJnHqMncrge','mZKWmJu1BeT6swHU','mtbVz05Asu0','nJz1uvDmBwW','DMfSDwu','ywrKrxzLBNrmAxn0zw5LCG','nZeYExzLwwD5','kg1HEc13Awr0AdOGnZy4ChGP','mJKXndG4BNPfEKjQ','CM91BMq','Bwf4','mtiZmZCXsK96tfL6','mte1ntzxyuT2DuS','C3bHBG','CMvTB3zLrxzLBNrmAxn0zw5LCG'];_0x4856=function(){return _0x55929d;};return _0x4856();}export const FORM_MQ_MOBILE=_0x24ed88(0x152);export function getFormCols(){if(typeof window!=='undefined'&&window['matchMedia'](FORM_MQ_MOBILE)['matches'])return FORM_COLS_MOBILE;return FORM_COLS_DESKTOP;}export function resolveFormSpan(_0x4ed666,_0x65a2cb=getFormCols()){const _0x148557=_0x24ed88,_0x3c2723=_0x4ed666??getCrudStyle()[_0x148557(0x15c)][_0x148557(0x158)]??FORM_SPAN_FULL,_0x53f63d=Math['min'](FORM_SPAN_FULL,Math[_0x148557(0x155)](0x1,_0x3c2723));if(_0x65a2cb===FORM_COLS_DESKTOP)return _0x53f63d;return Math[_0x148557(0x155)](0x1,Math[_0x148557(0x154)](_0x53f63d/FORM_COLS_DESKTOP*FORM_COLS_MOBILE));}export function useFormCols(){const _0x181f95=ref(getFormCols());let _0x417e0f=null;const _0x11f4c0=()=>{const _0x148586=_0x36a0;_0x181f95[_0x148586(0x14f)]=getFormCols();};return onMounted(()=>{const _0x40c2ff=_0x36a0;_0x417e0f=window['matchMedia'](FORM_MQ_MOBILE),_0x417e0f[_0x40c2ff(0x150)](_0x40c2ff(0x14a),_0x11f4c0),_0x11f4c0();}),onUnmounted(()=>{const _0x438337=_0x36a0;_0x417e0f?.[_0x438337(0x159)](_0x438337(0x14a),_0x11f4c0);}),_0x181f95;}
@@ -1,74 +1 @@
1
- import { CRUD_LABELS, DEFAULT_CRUD_DICT } from "./dict";
2
- export const DEFAULT_CRUD_STYLE = {
3
- form: {
4
- labelPosition: "top",
5
- labelWidth: "100px",
6
- span: 24,
7
- plugins: []
8
- },
9
- table: {
10
- border: false,
11
- highlightCurrentRow: true,
12
- autoHeight: true,
13
- contextMenu: ["refresh", "check", "edit", "delete", "order-asc", "order-desc"],
14
- column: {
15
- align: "left",
16
- opWidth: 180
17
- },
18
- plugins: []
19
- },
20
- search: {
21
- plugins: []
22
- },
23
- colors: [
24
- "#4E5DFF",
25
- "#06b31c",
26
- "#e93f4d",
27
- "#d57121",
28
- "#6d17c3",
29
- "#04c273",
30
- "#aa7a24",
31
- "#1c109d"
32
- ]
33
- };
34
- let globalConfig = {
35
- dict: { ...DEFAULT_CRUD_DICT, label: { ...CRUD_LABELS } },
36
- style: structuredClone(DEFAULT_CRUD_STYLE)
37
- };
38
- export function setCrudConfig(partial) {
39
- if (!partial)
40
- return globalConfig;
41
- globalConfig = {
42
- dict: {
43
- ...globalConfig.dict,
44
- ...partial.dict,
45
- api: { ...globalConfig.dict.api, ...partial.dict?.api },
46
- pagination: { ...globalConfig.dict.pagination, ...partial.dict?.pagination },
47
- search: { ...globalConfig.dict.search, ...partial.dict?.search },
48
- sort: { ...globalConfig.dict.sort, ...partial.dict?.sort },
49
- label: { ...globalConfig.dict.label, ...partial.dict?.label }
50
- },
51
- style: {
52
- ...globalConfig.style,
53
- ...partial.style,
54
- form: { ...globalConfig.style.form, ...partial.style?.form },
55
- table: {
56
- ...globalConfig.style.table,
57
- ...partial.style?.table,
58
- column: {
59
- ...globalConfig.style.table.column,
60
- ...partial.style?.table?.column
61
- }
62
- },
63
- search: { ...globalConfig.style.search, ...partial.style?.search },
64
- colors: partial.style?.colors || globalConfig.style.colors
65
- }
66
- };
67
- return globalConfig;
68
- }
69
- export function getCrudConfig() {
70
- return globalConfig;
71
- }
72
- export function getCrudStyle() {
73
- return globalConfig.style;
74
- }
1
+ function _0x2ca1(){const _0x524aff=['mZm5odq5mg5YueTuBq','DgfIBgu','mJGWyvzHvenm','C3r5Bgu','C29YDa','mtznCwLAtw8','iZa2yJmXyW','y29SB3jZ','iZa0yZi3mW','C2vHCMnO','mti4nZyZmffKvNjfuG','BgfIzwW','y29SDw1U','mtaWChG','iZzKmtDJmW','y2HLy2S','CgfNAw5HDgLVBG','mtrODhjpBeO','ntm3nduZENbJrgrz','zM9YBq','zgLJDa','ndm1mZGWquv5s3Pk','ndryEgX1Dhq','B3jKzxiTzgvZyW','i2q1nZeYmq','i2fHn2eYna','mZq2oti5tvrhwuDu','i2u5m2y0za','Dg9W','mtm5mZq4ohDls29erG','zwrPDa','zgvSzxrL','mJK0nZiXofbcDhDgza','yxbP'];_0x2ca1=function(){return _0x524aff;};return _0x2ca1();}const _0x5d7315=_0x47d4;(function(_0x5e65c2,_0x18d775){const _0x1b622a=_0x47d4,_0x830eab=_0x5e65c2();while(!![]){try{const _0x5e56df=parseInt(_0x1b622a(0x11f))/0x1+-parseInt(_0x1b622a(0x139))/0x2+parseInt(_0x1b622a(0x127))/0x3*(parseInt(_0x1b622a(0x123))/0x4)+-parseInt(_0x1b622a(0x12f))/0x5+parseInt(_0x1b622a(0x12d))/0x6*(parseInt(_0x1b622a(0x11e))/0x7)+-parseInt(_0x1b622a(0x134))/0x8*(-parseInt(_0x1b622a(0x12a))/0x9)+-parseInt(_0x1b622a(0x131))/0xa*(parseInt(_0x1b622a(0x122))/0xb);if(_0x5e56df===_0x18d775)break;else _0x830eab['push'](_0x830eab['shift']());}catch(_0x297510){_0x830eab['push'](_0x830eab['shift']());}}}(_0x2ca1,0xa3893));import{CRUD_LABELS,DEFAULT_CRUD_DICT}from'./dict';export const DEFAULT_CRUD_STYLE={'form':{'labelPosition':_0x5d7315(0x129),'labelWidth':_0x5d7315(0x13c),'span':0x18,'plugins':[]},'table':{'border':![],'highlightCurrentRow':!![],'autoHeight':!![],'contextMenu':['refresh',_0x5d7315(0x11c),_0x5d7315(0x12b),_0x5d7315(0x12c),'order-asc',_0x5d7315(0x124)],'column':{'align':'left','opWidth':0xb4},'plugins':[]},'search':{'plugins':[]},'colors':['#4E5DFF',_0x5d7315(0x135),_0x5d7315(0x128),_0x5d7315(0x125),_0x5d7315(0x11b),_0x5d7315(0x137),_0x5d7315(0x126),'#1c109d']};function _0x47d4(_0x21f931,_0x3f35c4){_0x21f931=_0x21f931-0x11b;const _0x2ca13d=_0x2ca1();let _0x47d4ed=_0x2ca13d[_0x21f931];if(_0x47d4['iIsanT']===undefined){var _0x49231d=function(_0x2d66a1){const _0x4775c6='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x19b2b9='',_0x3c62e0='';for(let _0x42d0f5=0x0,_0x18c67e,_0x5cf60a,_0x177f8f=0x0;_0x5cf60a=_0x2d66a1['charAt'](_0x177f8f++);~_0x5cf60a&&(_0x18c67e=_0x42d0f5%0x4?_0x18c67e*0x40+_0x5cf60a:_0x5cf60a,_0x42d0f5++%0x4)?_0x19b2b9+=String['fromCharCode'](0xff&_0x18c67e>>(-0x2*_0x42d0f5&0x6)):0x0){_0x5cf60a=_0x4775c6['indexOf'](_0x5cf60a);}for(let _0x52a6e7=0x0,_0x3ab596=_0x19b2b9['length'];_0x52a6e7<_0x3ab596;_0x52a6e7++){_0x3c62e0+='%'+('00'+_0x19b2b9['charCodeAt'](_0x52a6e7)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x3c62e0);};_0x47d4['aIwfpe']=_0x49231d,_0x47d4['nIcNra']={},_0x47d4['iIsanT']=!![];}const _0x495966=_0x2ca13d[0x0],_0x527e68=_0x21f931+_0x495966,_0x2dde8e=_0x47d4['nIcNra'][_0x527e68];return!_0x2dde8e?(_0x47d4ed=_0x47d4['aIwfpe'](_0x47d4ed),_0x47d4['nIcNra'][_0x527e68]=_0x47d4ed):_0x47d4ed=_0x2dde8e,_0x47d4ed;}let globalConfig={'dict':{...DEFAULT_CRUD_DICT,'label':{...CRUD_LABELS}},'style':structuredClone(DEFAULT_CRUD_STYLE)};export function setCrudConfig(_0x19b2b9){const _0x165acc=_0x5d7315;if(!_0x19b2b9)return globalConfig;return globalConfig={'dict':{...globalConfig[_0x165acc(0x121)],..._0x19b2b9[_0x165acc(0x121)],'api':{...globalConfig[_0x165acc(0x121)]['api'],..._0x19b2b9['dict']?.[_0x165acc(0x12e)]},'pagination':{...globalConfig[_0x165acc(0x121)][_0x165acc(0x11d)],..._0x19b2b9[_0x165acc(0x121)]?.['pagination']},'search':{...globalConfig['dict'][_0x165acc(0x138)],..._0x19b2b9[_0x165acc(0x121)]?.[_0x165acc(0x138)]},'sort':{...globalConfig['dict']['sort'],..._0x19b2b9[_0x165acc(0x121)]?.[_0x165acc(0x133)]},'label':{...globalConfig[_0x165acc(0x121)][_0x165acc(0x13a)],..._0x19b2b9[_0x165acc(0x121)]?.[_0x165acc(0x13a)]}},'style':{...globalConfig[_0x165acc(0x132)],..._0x19b2b9['style'],'form':{...globalConfig[_0x165acc(0x132)][_0x165acc(0x120)],..._0x19b2b9[_0x165acc(0x132)]?.[_0x165acc(0x120)]},'table':{...globalConfig[_0x165acc(0x132)][_0x165acc(0x130)],..._0x19b2b9[_0x165acc(0x132)]?.[_0x165acc(0x130)],'column':{...globalConfig[_0x165acc(0x132)][_0x165acc(0x130)][_0x165acc(0x13b)],..._0x19b2b9[_0x165acc(0x132)]?.[_0x165acc(0x130)]?.['column']}},'search':{...globalConfig['style'][_0x165acc(0x138)],..._0x19b2b9['style']?.['search']},'colors':_0x19b2b9[_0x165acc(0x132)]?.[_0x165acc(0x136)]||globalConfig[_0x165acc(0x132)][_0x165acc(0x136)]}},globalConfig;}export function getCrudConfig(){return globalConfig;}export function getCrudStyle(){const _0x32a2a6=_0x5d7315;return globalConfig[_0x32a2a6(0x132)];}
@@ -1,92 +1 @@
1
- function isEmpty(v) {
2
- if (v == null || v === "")
3
- return true;
4
- if (typeof v === "string" && v.trim() === "")
5
- return true;
6
- if (Array.isArray(v) && v.length === 0)
7
- return true;
8
- return false;
9
- }
10
- function normalizeRules(item) {
11
- const rules = [];
12
- if (item.required) {
13
- rules.push({
14
- required: true,
15
- message: `${item.label}不能为空`
16
- });
17
- }
18
- const raw = item.rules;
19
- if (!raw)
20
- return rules;
21
- if (Array.isArray(raw)) {
22
- for (const r of raw) {
23
- if (r && typeof r === "object")
24
- rules.push(r);
25
- }
26
- } else if (typeof raw === "object") {
27
- rules.push(raw);
28
- }
29
- return rules;
30
- }
31
- function isItemHidden(item, form) {
32
- if (typeof item.hidden === "function")
33
- return item.hidden(form);
34
- return Boolean(item.hidden);
35
- }
36
- async function validateItem(item, form) {
37
- const value = form[item.prop];
38
- for (const rule of normalizeRules(item)) {
39
- if (rule.required && isEmpty(value)) {
40
- return rule.message || `${item.label}不能为空`;
41
- }
42
- if (isEmpty(value))
43
- continue;
44
- const str = String(value);
45
- if (rule.min != null && str.length < rule.min) {
46
- return rule.message || `${item.label}至少 ${rule.min} 个字符`;
47
- }
48
- if (rule.max != null && str.length > rule.max) {
49
- return rule.message || `${item.label}最多 ${rule.max} 个字符`;
50
- }
51
- if (rule.pattern && !rule.pattern.test(str)) {
52
- return rule.message || `${item.label}格式不正确`;
53
- }
54
- if (rule.validator) {
55
- const r = await rule.validator(value, form);
56
- if (r !== true)
57
- return r || `${item.label}校验失败`;
58
- }
59
- }
60
- return null;
61
- }
62
- export async function validateFormItems(items, form) {
63
- for (const item of items) {
64
- if (isItemHidden(item, form))
65
- continue;
66
- const err = await validateItem(item, form);
67
- if (err)
68
- return err;
69
- }
70
- return null;
71
- }
72
- export async function validateFormFields(items, form) {
73
- const errors = {};
74
- for (const item of items) {
75
- if (isItemHidden(item, form))
76
- continue;
77
- const err = await validateItem(item, form);
78
- if (err)
79
- errors[item.prop] = err;
80
- }
81
- return errors;
82
- }
83
- export function applySetRules(items) {
84
- return items.map((it) => {
85
- if (!it.required || it.rules)
86
- return it;
87
- return {
88
- ...it,
89
- rules: [{ required: true, message: `${it.label}不能为空` }]
90
- };
91
- });
92
- }
1
+ function _0x136e(){const _0x22d4b3=['mtqYmtK1mKv0zwzpza','CNvSzxm','6iEZ5Bcria','mtrNq3nQEfi','mtuYnZK3nJbfEwjuuMq','mtqXnJi3nK50rLntqG','ChvZAa','ios4QUwTL+ESPG','mJjYwgXQA3u','mtGXoen1ENfluW','BwfW','BwvZC2fNzq','BwLU','nZC5mtqZmLzQy09uBq','mtaZmtC0uvLKAK9i','nhnsB09syW','ChjVCa','Bwf4','BgvUz3rO','Cgf0DgvYBG','BgfIzwW','5QcH6AQm5AsX6lsL','5PYa5AsAia','5Qc85BYp5lIn5Q2J56gU','DMfSAwrHDg9Y','C3rYAw5N','nZy4oeHkAfjcwa','AxnbCNjHEq','5lIn6io95lI656M6','ndy2mtu3mfjVwMDdCq','B2jQzwn0','CMvXDwLYzwq','AgLKzgvU'];_0x136e=function(){return _0x22d4b3;};return _0x136e();}(function(_0x2e8d24,_0x29108c){const _0x3f4c79=_0x1d4f,_0x59d67c=_0x2e8d24();while(!![]){try{const _0x5235c9=-parseInt(_0x3f4c79(0x161))/0x1*(parseInt(_0x3f4c79(0x167))/0x2)+parseInt(_0x3f4c79(0x17a))/0x3+parseInt(_0x3f4c79(0x168))/0x4*(parseInt(_0x3f4c79(0x176))/0x5)+-parseInt(_0x3f4c79(0x17f))/0x6*(parseInt(_0x3f4c79(0x17d))/0x7)+-parseInt(_0x3f4c79(0x173))/0x8*(-parseInt(_0x3f4c79(0x162))/0x9)+parseInt(_0x3f4c79(0x17e))/0xa+-parseInt(_0x3f4c79(0x166))/0xb;if(_0x5235c9===_0x29108c)break;else _0x59d67c['push'](_0x59d67c['shift']());}catch(_0x53dbca){_0x59d67c['push'](_0x59d67c['shift']());}}}(_0x136e,0xc6816));function isEmpty(_0x2f8f54){const _0x4ad219=_0x1d4f;if(_0x2f8f54==null||_0x2f8f54==='')return!![];if(typeof _0x2f8f54===_0x4ad219(0x172)&&_0x2f8f54['trim']()==='')return!![];if(Array[_0x4ad219(0x174)](_0x2f8f54)&&_0x2f8f54[_0x4ad219(0x16b)]===0x0)return!![];return![];}function normalizeRules(_0x4fbc27){const _0x10bc9c=_0x1d4f,_0x2b7fff=[];_0x4fbc27['required']&&_0x2b7fff['push']({'required':!![],'message':_0x4fbc27[_0x10bc9c(0x16d)]+'不能为空'});const _0x1505c5=_0x4fbc27['rules'];if(!_0x1505c5)return _0x2b7fff;if(Array['isArray'](_0x1505c5))for(const _0x2af557 of _0x1505c5){if(_0x2af557&&typeof _0x2af557===_0x10bc9c(0x177))_0x2b7fff[_0x10bc9c(0x180)](_0x2af557);}else typeof _0x1505c5===_0x10bc9c(0x177)&&_0x2b7fff[_0x10bc9c(0x180)](_0x1505c5);return _0x2b7fff;}function _0x1d4f(_0x45df71,_0x24a995){_0x45df71=_0x45df71-0x160;const _0x136e12=_0x136e();let _0x1d4fd8=_0x136e12[_0x45df71];if(_0x1d4f['gondTy']===undefined){var _0x15f449=function(_0x4aa6f){const _0x1e7f78='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2f8f54='',_0x4fbc27='';for(let _0x2b7fff=0x0,_0x1505c5,_0x2af557,_0x16eb12=0x0;_0x2af557=_0x4aa6f['charAt'](_0x16eb12++);~_0x2af557&&(_0x1505c5=_0x2b7fff%0x4?_0x1505c5*0x40+_0x2af557:_0x2af557,_0x2b7fff++%0x4)?_0x2f8f54+=String['fromCharCode'](0xff&_0x1505c5>>(-0x2*_0x2b7fff&0x6)):0x0){_0x2af557=_0x1e7f78['indexOf'](_0x2af557);}for(let _0x245233=0x0,_0xc00160=_0x2f8f54['length'];_0x245233<_0xc00160;_0x245233++){_0x4fbc27+='%'+('00'+_0x2f8f54['charCodeAt'](_0x245233)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4fbc27);};_0x1d4f['HXVBYB']=_0x15f449,_0x1d4f['BiEnfr']={},_0x1d4f['gondTy']=!![];}const _0x125913=_0x136e12[0x0],_0x5b915a=_0x45df71+_0x125913,_0x45d8c2=_0x1d4f['BiEnfr'][_0x5b915a];return!_0x45d8c2?(_0x1d4fd8=_0x1d4f['HXVBYB'](_0x1d4fd8),_0x1d4f['BiEnfr'][_0x5b915a]=_0x1d4fd8):_0x1d4fd8=_0x45d8c2,_0x1d4fd8;}function isItemHidden(_0x16eb12,_0x245233){const _0x53176e=_0x1d4f;if(typeof _0x16eb12['hidden']==='function')return _0x16eb12[_0x53176e(0x179)](_0x245233);return Boolean(_0x16eb12[_0x53176e(0x179)]);}async function validateItem(_0xc00160,_0x4cad80){const _0x2c0831=_0x1d4f,_0x4ce208=_0x4cad80[_0xc00160[_0x2c0831(0x169)]];for(const _0xf5cdf1 of normalizeRules(_0xc00160)){if(_0xf5cdf1[_0x2c0831(0x178)]&&isEmpty(_0x4ce208))return _0xf5cdf1['message']||_0xc00160[_0x2c0831(0x16d)]+_0x2c0831(0x175);if(isEmpty(_0x4ce208))continue;const _0xdbc374=String(_0x4ce208);if(_0xf5cdf1['min']!=null&&_0xdbc374[_0x2c0831(0x16b)]<_0xf5cdf1[_0x2c0831(0x165)])return _0xf5cdf1['message']||_0xc00160['label']+_0x2c0831(0x17c)+_0xf5cdf1[_0x2c0831(0x165)]+'\x20个字符';if(_0xf5cdf1[_0x2c0831(0x16a)]!=null&&_0xdbc374[_0x2c0831(0x16b)]>_0xf5cdf1[_0x2c0831(0x16a)])return _0xf5cdf1[_0x2c0831(0x164)]||_0xc00160[_0x2c0831(0x16d)]+_0x2c0831(0x16f)+_0xf5cdf1[_0x2c0831(0x16a)]+_0x2c0831(0x160);if(_0xf5cdf1['pattern']&&!_0xf5cdf1[_0x2c0831(0x16c)]['test'](_0xdbc374))return _0xf5cdf1['message']||_0xc00160[_0x2c0831(0x16d)]+_0x2c0831(0x170);if(_0xf5cdf1[_0x2c0831(0x171)]){const _0x45465d=await _0xf5cdf1[_0x2c0831(0x171)](_0x4ce208,_0x4cad80);if(_0x45465d!==!![])return _0x45465d||_0xc00160[_0x2c0831(0x16d)]+_0x2c0831(0x16e);}}return null;}export async function validateFormItems(_0x25d694,_0x2beb08){for(const _0x46bed4 of _0x25d694){if(isItemHidden(_0x46bed4,_0x2beb08))continue;const _0xf39c22=await validateItem(_0x46bed4,_0x2beb08);if(_0xf39c22)return _0xf39c22;}return null;}export async function validateFormFields(_0x12c8a2,_0x336507){const _0x31c8d8={};for(const _0x155094 of _0x12c8a2){if(isItemHidden(_0x155094,_0x336507))continue;const _0x31a4df=await validateItem(_0x155094,_0x336507);if(_0x31a4df)_0x31c8d8[_0x155094['prop']]=_0x31a4df;}return _0x31c8d8;}export function applySetRules(_0xee6409){const _0x56f0d5=_0x1d4f;return _0xee6409[_0x56f0d5(0x163)](_0x50bfc5=>{const _0x5d347d=_0x56f0d5;if(!_0x50bfc5[_0x5d347d(0x178)]||_0x50bfc5[_0x5d347d(0x17b)])return _0x50bfc5;return{..._0x50bfc5,'rules':[{'required':!![],'message':_0x50bfc5[_0x5d347d(0x16d)]+'不能为空'}]};});}
@@ -21,7 +21,7 @@
21
21
  </SelectTrigger>
22
22
  <SelectContent>
23
23
  <SelectItem
24
- v-for="opt in item.options || []"
24
+ v-for="opt in resolveOptions(item.options)"
25
25
  :key="String(opt.value)"
26
26
  :value="String(opt.value)"
27
27
  >
@@ -48,7 +48,7 @@
48
48
  </template>
49
49
 
50
50
  <script setup lang="ts">
51
- import { ref, computed, watch, reactive, onMounted } from 'vue'
51
+ import { ref, computed, watch, reactive, onMounted, toValue } from 'vue'
52
52
  import { onBeforeUnmount } from 'vue'
53
53
  import { useCrud } from './useCrud'
54
54
  import { injectSearchOptions } from './key'
@@ -102,10 +102,18 @@ function emptyValue(item: CrudSearchItem) {
102
102
  function coerceSelect(item: CrudSearchItem, v: unknown) {
103
103
  const s = v == null ? '' : String(v)
104
104
  if (!s) return ''
105
- const hit = item.options?.find((o) => String(o.value) === s)
105
+ const hit = resolveOptions(item.options).find((o) => String(o.value) === s)
106
106
  return hit ? hit.value : s
107
107
  }
108
108
 
109
+ /** options 支持 Ref / ComputedRef / getter(与 vm-upsert 一致) */
110
+ function resolveOptions(
111
+ options: CrudSearchItem['options'],
112
+ ): Array<{ label: string; value: string | number | boolean }> {
113
+ const list = options == null ? [] : toValue(options)
114
+ return Array.isArray(list) ? list : []
115
+ }
116
+
109
117
  async function loadDictOptions(list: CrudSearchItem[]) {
110
118
  const keys = [
111
119
  ...new Set(list.map((i) => i.dict).filter((d): d is string => Boolean(d))),
@@ -200,7 +208,7 @@ function fieldProps(item: CrudSearchItem) {
200
208
  }
201
209
  : {}
202
210
  return {
203
- options: item.options,
211
+ options: resolveOptions(item.options),
204
212
  placeholder: item.placeholder || item.label,
205
213
  refreshOnChange: false,
206
214
  precision: item.range?.rangeType,
@@ -0,0 +1,94 @@
1
+ <template>
2
+ <div class="vm-tabs">
3
+ <button
4
+ v-for="item in items"
5
+ :key="String(item.value)"
6
+ type="button"
7
+ class="vm-tabs__item"
8
+ :class="{ 'is-active': isActive(item.value) }"
9
+ :disabled="disabled || item.disabled"
10
+ @click="onSelect(item)"
11
+ >
12
+ {{ item.label }}
13
+ </button>
14
+ </div>
15
+ </template>
16
+
17
+ <script setup lang="ts">
18
+ defineOptions({ name: 'vm-tabs' })
19
+
20
+ export type VmTabItem = {
21
+ label: string
22
+ value: string | number
23
+ disabled?: boolean
24
+ }
25
+
26
+ const props = withDefaults(
27
+ defineProps<{
28
+ modelValue?: string | number
29
+ items?: VmTabItem[]
30
+ disabled?: boolean
31
+ }>(),
32
+ {
33
+ modelValue: '',
34
+ items: () => [],
35
+ disabled: false,
36
+ },
37
+ )
38
+
39
+ const emit = defineEmits<{
40
+ 'update:modelValue': [value: string | number]
41
+ change: [value: string | number]
42
+ }>()
43
+
44
+ function isActive(value: string | number) {
45
+ return String(props.modelValue) === String(value)
46
+ }
47
+
48
+ function onSelect(item: VmTabItem) {
49
+ if (props.disabled || item.disabled) return
50
+ if (isActive(item.value)) return
51
+ emit('update:modelValue', item.value)
52
+ emit('change', item.value)
53
+ }
54
+ </script>
55
+
56
+ <style lang="scss" scoped>
57
+ .vm-tabs {
58
+ display: inline-flex;
59
+ height: 36px;
60
+ align-items: center;
61
+ padding: 3px;
62
+ border-radius: 12px;
63
+ background: var(--muted);
64
+ }
65
+
66
+ .vm-tabs__item {
67
+ height: 30px;
68
+ padding: 0 12px;
69
+ border: none;
70
+ border-radius: 10px;
71
+ background: transparent;
72
+ color: var(--muted-foreground);
73
+ font-size: 12px;
74
+ font-weight: 500;
75
+ cursor: pointer;
76
+ transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
77
+
78
+ &:disabled {
79
+ cursor: not-allowed;
80
+ opacity: 0.45;
81
+ }
82
+
83
+ &.is-active {
84
+ background: #fff;
85
+ color: var(--foreground);
86
+ font-weight: 600;
87
+ box-shadow: var(--shadow-card);
88
+
89
+ .dark & {
90
+ background: var(--card);
91
+ }
92
+ }
93
+ }
94
+ </style>