vome-core 0.0.89 → 0.0.91

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.
@@ -1 +1,278 @@
1
- (function(_0x5c7184,_0x43f656){const _0x157196=_0x5311,_0x4e1b94=_0x5c7184();while(!![]){try{const _0x441253=parseInt(_0x157196(0xf2))/0x1*(-parseInt(_0x157196(0x103))/0x2)+parseInt(_0x157196(0xec))/0x3+parseInt(_0x157196(0xf5))/0x4+-parseInt(_0x157196(0xe9))/0x5*(parseInt(_0x157196(0x10a))/0x6)+-parseInt(_0x157196(0xe1))/0x7*(-parseInt(_0x157196(0x11f))/0x8)+parseInt(_0x157196(0x10c))/0x9+-parseInt(_0x157196(0xfc))/0xa;if(_0x441253===_0x43f656)break;else _0x4e1b94['push'](_0x4e1b94['shift']());}catch(_0x5260d4){_0x4e1b94['push'](_0x4e1b94['shift']());}}}(_0x9bd4,0xbd1ee));import{findEpsEntity}from'../lib/eps';import{getCrudStyle}from'./style';export function toTree(_0x13d40e={}){const _0x2debd7=_0x5311;return{'__plugin':_0x2debd7(0xf3),'tree':!![],'lazy':_0x13d40e[_0x2debd7(0xfd)]??![]};}export function setFocus(_0x278310){const _0x1eaca8=_0x5311;return{'__plugin':_0x1eaca8(0x10e),'prop':_0x278310??''};}export function setRules(){const _0xaf0d70=_0x5311;return{'__plugin':_0xaf0d70(0xe5)};}export function setAuto(_0x4107fb={'hideLabel':!![]}){const _0x416dbb=_0x5311;return{'__plugin':_0x416dbb(0xeb),..._0x4107fb};}export const Plugins={'Table':{'toTree':toTree},'Form':{'setFocus':setFocus,'setRules':setRules},'Search':{'setAuto':setAuto}};export function applyTablePlugins(_0x1bc01b){const _0xdb1778=_0x5311,_0x1df5fa=getCrudStyle()[_0xdb1778(0x122)],_0x2f7164={'border':_0x1df5fa['border'],'autoHeight':_0x1df5fa[_0xdb1778(0xe7)],'contextMenu':_0x1df5fa[_0xdb1778(0x113)],..._0x1bc01b},_0x2f07d8=[..._0x1df5fa['plugins'],..._0x1bc01b?.['plugins']||[]],_0x55f5bd={..._0x2f7164};delete _0x55f5bd[_0xdb1778(0xe3)];for(const _0x54a28e of _0x2f07d8){if(!_0x54a28e||typeof _0x54a28e!==_0xdb1778(0xef))continue;_0x54a28e[_0xdb1778(0x124)]===_0xdb1778(0xf3)&&(_0x55f5bd['tree']=!![],_0x55f5bd[_0xdb1778(0x116)]=Boolean(_0x54a28e[_0xdb1778(0xfd)]));}return _0x55f5bd;}function _0x5311(_0x1598af,_0x524154){_0x1598af=_0x1598af-0xe0;const _0x9bd40b=_0x9bd4();let _0x5311c6=_0x9bd40b[_0x1598af];if(_0x5311['FJVZkZ']===undefined){var _0x896781=function(_0x3f4ca4){const _0x481246='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x13d40e='',_0x278310='';for(let _0x4107fb=0x0,_0x1bc01b,_0x1df5fa,_0x2f7164=0x0;_0x1df5fa=_0x3f4ca4['charAt'](_0x2f7164++);~_0x1df5fa&&(_0x1bc01b=_0x4107fb%0x4?_0x1bc01b*0x40+_0x1df5fa:_0x1df5fa,_0x4107fb++%0x4)?_0x13d40e+=String['fromCharCode'](0xff&_0x1bc01b>>(-0x2*_0x4107fb&0x6)):0x0){_0x1df5fa=_0x481246['indexOf'](_0x1df5fa);}for(let _0x2f07d8=0x0,_0x55f5bd=_0x13d40e['length'];_0x2f07d8<_0x55f5bd;_0x2f07d8++){_0x278310+='%'+('00'+_0x13d40e['charCodeAt'](_0x2f07d8)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x278310);};_0x5311['ekwyrV']=_0x896781,_0x5311['zamOcB']={},_0x5311['FJVZkZ']=!![];}const _0x18577f=_0x9bd40b[0x0],_0x46935d=_0x1598af+_0x18577f,_0x2cda45=_0x5311['zamOcB'][_0x46935d];return!_0x2cda45?(_0x5311c6=_0x5311['ekwyrV'](_0x5311c6),_0x5311['zamOcB'][_0x46935d]=_0x5311c6):_0x5311c6=_0x2cda45,_0x5311c6;}function stripAlias(_0x5720dd){const _0x15edbf=_0x5311;return _0x5720dd[_0x15edbf(0x111)]('.')?_0x5720dd['split']('.')[_0x15edbf(0x114)]():_0x5720dd;}function toSource(_0x36ff37){const _0x2c3451=_0x5311,_0x2fa907=_0x36ff37[_0x2c3451(0xf8)]()[_0x2c3451(0x118)](/\s+as\s+[a-zA-Z_]\w*$/i,'')[_0x2c3451(0xf8)]();return _0x2fa907[_0x2c3451(0x111)]('.')?_0x2fa907:'a.'+_0x2fa907;}function parseRef(_0x3124a4){const _0x56fb3e=_0x5311,_0x32ca34=/^(.+?)\s+as\s+([a-zA-Z_]\w*)$/i,_0x4ae871=_0x1bbf95=>{const _0x549a62=_0x5311,_0x11cbe6=_0x1bbf95['trim'](),_0x49a479=_0x11cbe6[_0x549a62(0xf0)](_0x32ca34);if(_0x49a479)return{'expr':_0x49a479[0x1][_0x549a62(0xf8)](),'asName':_0x49a479[0x2]};return{'expr':_0x11cbe6,'asName':undefined};};if(typeof _0x3124a4===_0x56fb3e(0x119)){const {expr:_0x5ba425,asName:_0x2d8f9b}=_0x4ae871(_0x3124a4),_0x362a5d=toSource(_0x5ba425),_0x2dda7a=stripAlias(_0x362a5d);return{'column':_0x2dda7a,'source':_0x362a5d,'param':_0x2d8f9b??_0x2dda7a,'multiple':!![],'none':![]};}if(!_0x3124a4||typeof _0x3124a4!==_0x56fb3e(0xef))return null;const _0x1c06c2=_0x3124a4;if(!_0x1c06c2[_0x56fb3e(0xfe)])return null;const {expr:_0x5ceb20,asName:_0x52ab51}=_0x4ae871(_0x1c06c2[_0x56fb3e(0xfe)]),_0x2d712b=toSource(_0x5ceb20),_0x4d38f4=stripAlias(_0x2d712b);return{'column':_0x4d38f4,'source':_0x2d712b,'param':_0x52ab51??_0x4d38f4,'label':_0x1c06c2[_0x56fb3e(0x123)],'dict':_0x1c06c2[_0x56fb3e(0xea)],'multiple':_0x1c06c2[_0x56fb3e(0x108)]!==![],'none':Boolean(_0x1c06c2[_0x56fb3e(0x107)])};}function displayName(_0x21e47c,_0x5d3043){const _0x5d46a8=_0x5311;return _0x21e47c[_0x5d46a8(0x123)]||_0x5d3043?.[_0x5d46a8(0x11e)]||_0x21e47c[_0x5d46a8(0xfe)];}function fieldKeyOf(_0x9ce9ca,_0x5412b3){const _0x95c4dc=_0x5311,_0x15aee4=_0x5412b3?.['table']?.[_0x95c4dc(0xf8)](),_0x5c6845=(_0x5412b3?.[_0x95c4dc(0x11c)]||_0x9ce9ca[_0x95c4dc(0xfe)]||'')['trim']();if(!_0x15aee4||!_0x5c6845)return;return _0x15aee4+'.'+_0x5c6845;}export function buildAutoSearchItems(_0x4fe890,_0x980c65={}){const _0x30a29c=_0x5311,_0x2edbdc=new Set(_0x980c65['ignoreFields']||[]),_0x504f0b=_0x4fe890['search']||{};let _0x212294=_0x504f0b['fieldEq']||[],_0x2d81aa=_0x504f0b['fieldLike']||[],_0x3d7b2e=_0x504f0b[_0x30a29c(0xe4)]||[],_0x53b323=_0x504f0b[_0x30a29c(0x104)]||[],_0x1027a0=_0x504f0b[_0x30a29c(0xe0)]||[],_0x14727f=[];const _0x22e147=_0x4fe890[_0x30a29c(0x121)]?findEpsEntity('/'+_0x4fe890[_0x30a29c(0x121)]):undefined;if(_0x22e147){_0x14727f=[..._0x22e147[_0x30a29c(0xe2)]||[],..._0x22e147[_0x30a29c(0x120)]||[]];if(!_0x4fe890[_0x30a29c(0xe8)]){const _0x414f0a=_0x22e147['pageQueryOp'];_0x414f0a&&(_0x212294=_0x414f0a['fieldEq']||[],_0x2d81aa=_0x414f0a['fieldLike']||[],_0x3d7b2e=_0x414f0a[_0x30a29c(0xe4)]||[],_0x53b323=_0x414f0a[_0x30a29c(0x104)]||[],_0x1027a0=_0x414f0a['keyWordLikeFields']||[]);}}const _0x2364cd=(_0x2496c9,_0x28bdad)=>{const _0x43f5de=_0x30a29c,_0x945027=_0x2496c9['includes']('.')?_0x2496c9:'a.'+_0x2496c9,_0x1d6195=_0x28bdad??stripAlias(_0x945027);return _0x14727f[_0x43f5de(0xed)](_0x3b36eb=>_0x3b36eb[_0x43f5de(0xfa)]===_0x945027)||_0x14727f[_0x43f5de(0xed)](_0x3a3fde=>_0x3a3fde['propertyName']===_0x1d6195&&(!_0x3a3fde[_0x43f5de(0xfa)]||_0x3a3fde[_0x43f5de(0xfa)]['startsWith']('a.')))||_0x14727f['find'](_0x20b5f3=>_0x20b5f3['propertyName']===_0x1d6195);},_0x362447=[],_0x14a82f=new Set(),_0x34467e=_0x58322d=>{const _0x913a6e=_0x30a29c;if(!_0x58322d['prop']||_0x14a82f[_0x913a6e(0x11a)](_0x58322d[_0x913a6e(0xf1)]))return;_0x14a82f[_0x913a6e(0x102)](_0x58322d['prop']),_0x362447[_0x913a6e(0xff)](_0x58322d);};for(const _0x2f5618 of _0x2d81aa){const _0x4ff761=parseRef(_0x2f5618);if(!_0x4ff761||_0x4ff761[_0x30a29c(0x107)]||_0x2edbdc[_0x30a29c(0x11a)](_0x4ff761[_0x30a29c(0x117)]))continue;const _0x4983f5=_0x2364cd(_0x4ff761[_0x30a29c(0xfa)],_0x4ff761[_0x30a29c(0xfe)]),_0x214198=displayName(_0x4ff761,_0x4983f5),_0x534a1b=fieldKeyOf(_0x4ff761,_0x4983f5);_0x34467e({'prop':_0x4ff761[_0x30a29c(0x117)],'label':_0x980c65[_0x30a29c(0xf4)]?'':_0x214198,'nameFallback':_0x214198,'fieldKey':_0x534a1b,'phMode':'search','placeholder':'搜索'+_0x214198,'type':_0x30a29c(0xe6)});}for(const _0x4a09ae of _0x3d7b2e){const _0x21923c=parseRef(_0x4a09ae);if(!_0x21923c||_0x21923c['none']||_0x2edbdc[_0x30a29c(0x11a)](_0x21923c[_0x30a29c(0x117)]))continue;const _0xaf86a9=_0x2364cd(_0x21923c[_0x30a29c(0xfa)],_0x21923c[_0x30a29c(0xfe)]),_0x48eb50=displayName(_0x21923c,_0xaf86a9),_0x4b3534=fieldKeyOf(_0x21923c,_0xaf86a9);_0x34467e({'prop':_0x21923c[_0x30a29c(0x117)],'label':_0x980c65[_0x30a29c(0xf4)]?'':_0x48eb50,'nameFallback':_0x48eb50,'fieldKey':_0x4b3534,'phMode':_0x30a29c(0xe8),'placeholder':'搜索'+_0x48eb50,'type':_0x30a29c(0xe6)});}for(const _0x152cce of _0x212294){const _0x3f00a7=parseRef(_0x152cce);if(!_0x3f00a7||_0x3f00a7[_0x30a29c(0x107)]||_0x2edbdc[_0x30a29c(0x11a)](_0x3f00a7[_0x30a29c(0x117)]))continue;const _0x3fbf2d=_0x2364cd(_0x3f00a7[_0x30a29c(0xfa)],_0x3f00a7[_0x30a29c(0xfe)]),_0x5d5eb6=_0x3f00a7['dict']||(typeof _0x3fbf2d?.['dict']===_0x30a29c(0x119)?_0x3fbf2d[_0x30a29c(0xea)]:Array['isArray'](_0x3fbf2d?.['dict'])?_0x3fbf2d['dict'][0x0]:undefined),_0x5063ee=displayName(_0x3f00a7,_0x3fbf2d),_0x34c0f2=fieldKeyOf(_0x3f00a7,_0x3fbf2d),_0x4af2f1=_0x980c65[_0x30a29c(0xf4)]?'':_0x5063ee;_0x5d5eb6?_0x34467e({'prop':_0x3f00a7[_0x30a29c(0x117)],'label':_0x4af2f1,'nameFallback':_0x5063ee,'fieldKey':_0x34c0f2,'phMode':_0x30a29c(0xf7),'placeholder':'选择'+_0x5063ee,'type':'select','dict':_0x5d5eb6,'multiple':_0x3f00a7[_0x30a29c(0x108)]}):_0x34467e({'prop':_0x3f00a7[_0x30a29c(0x117)],'label':_0x4af2f1,'nameFallback':_0x5063ee,'fieldKey':_0x34c0f2,'phMode':'search','placeholder':'搜索'+_0x5063ee,'type':'input'});}for(const _0x1d3c4a of _0x53b323){if(!_0x1d3c4a?.['column']||_0x1d3c4a[_0x30a29c(0x107)])continue;if(_0x2edbdc[_0x30a29c(0x11a)](_0x1d3c4a[_0x30a29c(0x105)])||_0x2edbdc['has'](_0x1d3c4a[_0x30a29c(0xfb)]))continue;const _0x362407=toSource(_0x1d3c4a[_0x30a29c(0xfe)]),_0x1fa8c0=stripAlias(_0x1d3c4a[_0x30a29c(0xfe)]),_0x60cc01=_0x2364cd(_0x362407,_0x1fa8c0),_0x59f159=_0x1d3c4a['label']||_0x60cc01?.[_0x30a29c(0x11e)]||_0x1fa8c0,_0x482668=fieldKeyOf({'column':_0x1fa8c0},_0x60cc01),_0x5a6b47=_0x980c65[_0x30a29c(0xf4)]?'':_0x59f159,_0x47463b=_0x1d3c4a['type']===_0x30a29c(0xf6)||_0x1d3c4a['type']===_0x30a29c(0x101),_0x92b682=_0x47463b?_0x30a29c(0x115):'开始',_0x38be77=_0x47463b?_0x30a29c(0x10d):'结束';_0x34467e({'prop':_0x30a29c(0x106)+_0x1d3c4a['min']+'_'+_0x1d3c4a[_0x30a29c(0xfb)],'label':_0x5a6b47,'nameFallback':_0x59f159,'fieldKey':_0x482668,'phMode':_0x30a29c(0x110),'placeholder':_0x59f159||'区间','type':_0x47463b?'number-range':'daterange','range':{'min':_0x1d3c4a[_0x30a29c(0x105)],'max':_0x1d3c4a[_0x30a29c(0xfb)],'rangeType':_0x1d3c4a[_0x30a29c(0x11b)]},'component':{'name':_0x47463b?_0x30a29c(0x10f):_0x30a29c(0x112),'props':_0x47463b?{'mode':_0x1d3c4a['type'],'startPlaceholder':''+_0x59f159+_0x92b682,'endPlaceholder':''+_0x59f159+_0x38be77}:{'precision':_0x1d3c4a[_0x30a29c(0x11b)],'startPlaceholder':''+_0x59f159+_0x92b682,'endPlaceholder':''+_0x59f159+_0x38be77}}});}if(_0x1027a0[_0x30a29c(0x100)]){const _0x1fed2e=[],_0x179e2c=_0x1027a0[_0x30a29c(0xee)](_0x53048d=>{const _0x11a16a=_0x30a29c,_0x358ae4=parseRef(_0x53048d);if(!_0x358ae4)return typeof _0x53048d===_0x11a16a(0x119)?stripAlias(_0x53048d):'';const _0x4d72aa=_0x2364cd(_0x358ae4[_0x11a16a(0xfa)],_0x358ae4[_0x11a16a(0xfe)]),_0x3f8522=fieldKeyOf(_0x358ae4,_0x4d72aa);if(_0x3f8522)_0x1fed2e[_0x11a16a(0xff)](_0x3f8522);return displayName(_0x358ae4,_0x4d72aa);})[_0x30a29c(0x10b)](Boolean);_0x34467e({'prop':'keyWord','label':_0x980c65['hideLabel']?'':_0x30a29c(0x109),'nameFallback':_0x179e2c[_0x30a29c(0x11d)]('、')||_0x30a29c(0x109),'phMode':_0x30a29c(0xf9),'keywordParts':_0x1fed2e,'placeholder':'搜索'+(_0x179e2c[_0x30a29c(0x11d)]('、')||_0x30a29c(0x109)),'type':'input'});}return _0x362447;}function _0x9bd4(){const _0x380922=['Bwf4','nJK5ndK3me5iDeXVuW','Bgf6Eq','y29SDw1U','ChvZAa','BgvUz3rO','zMXVyxq','ywrK','mJj2ANflthK','zMLLBgrsyw5Nzq','BwLU','x19Yyw5Nzv8','BM9Uzq','BxvSDgLWBgu','5ywZ6zsU5A2x','mtKYDhPHwwrL','zMLSDgvY','ntq5mdu5nejdwhfvzq','5PYa5AsN5yc8','C2v0rM9JDxm','DM0TBNvTyMvYlxjHBMDL','CMfUz2u','Aw5JBhvKzxm','DM0Tzgf0zs1Yyw5Nzq','y29UDgv4De1LBNu','Cg9W','5PYa5Bcp5yc8','DhjLzuXHENK','CgfYyw0','CMvWBgfJzq','C3rYAw5N','AgfZ','DhLWzq','ChjVCgvYDhLoyw1L','AM9PBG','y29TBwvUDa','og5OshzezW','CgfNzunVBhvTBNm','BMfTzxnWywnL','DgfIBgu','BgfIzwW','x19WBhvNAw4','A2v5v29YzeXPA2vgAwvSzhm','mtG4mZK4n3DAz0rZyG','y29SDw1UCW','CgX1z2LUCW','zMLLBgrbCNjHEq','C2v0uNvSzxm','Aw5WDxq','yxv0B0HLAwDODa','C2vHCMnO','mti0mdyWA2roCw9x','zgLJDa','C2v0qxv0BW','mZGWmZG4ow5rCwzRsW','zMLUza','BwfW','B2jQzwn0','Bwf0y2G','ChjVCa','odyXotHgA1DoAxG','Dg9uCMvL','AgLKzuXHyMvS','ndi3nJuWogH3BKTqua','Aw50','C2vSzwn0','DhjPBq','A2v5D29Yza','C291CMnL'];_0x9bd4=function(){return _0x380922;};return _0x9bd4();}
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 toSource(column) {
60
+ const expr = column.trim().replace(/\s+as\s+[a-zA-Z_]\w*$/i, "").trim();
61
+ return expr.includes(".") ? expr : `a.${expr}`;
62
+ }
63
+ function parseRef(ref) {
64
+ const AS_RE = /^(.+?)\s+as\s+([a-zA-Z_]\w*)$/i;
65
+ const splitAs = (input) => {
66
+ const raw = input.trim();
67
+ const m = raw.match(AS_RE);
68
+ if (m)
69
+ return { expr: m[1].trim(), asName: m[2] };
70
+ return { expr: raw, asName: undefined };
71
+ };
72
+ if (typeof ref === "string") {
73
+ const { expr, asName } = splitAs(ref);
74
+ const source = toSource(expr);
75
+ const column = stripAlias(source);
76
+ return {
77
+ column,
78
+ source,
79
+ param: asName ?? column,
80
+ multiple: true,
81
+ none: false
82
+ };
83
+ }
84
+ if (!ref || typeof ref !== "object")
85
+ return null;
86
+ const o = ref;
87
+ if (!o.column)
88
+ return null;
89
+ const { expr, asName } = splitAs(o.column);
90
+ const source = toSource(expr);
91
+ const column = stripAlias(source);
92
+ return {
93
+ column,
94
+ source,
95
+ param: asName ?? column,
96
+ label: o.label,
97
+ dict: o.dict,
98
+ multiple: o.multiple !== false,
99
+ none: Boolean(o.none)
100
+ };
101
+ }
102
+ function displayName(ref, meta) {
103
+ return ref.label || meta?.comment || ref.column;
104
+ }
105
+ function fieldKeyOf(ref, meta) {
106
+ const table = meta?.table?.trim();
107
+ const prop = (meta?.propertyName || ref.column || "").trim();
108
+ if (!table || !prop)
109
+ return;
110
+ return `${table}.${prop}`;
111
+ }
112
+ export function buildAutoSearchItems(service, options = {}) {
113
+ const ignore = new Set(options.ignoreFields || []);
114
+ const search = service.search || {};
115
+ let fieldEq = search.fieldEq || [];
116
+ let fieldLike = search.fieldLike || [];
117
+ let fieldArray = search.fieldArray || [];
118
+ let fieldRange = search.fieldRange || [];
119
+ let keyWordLikeFields = search.keyWordLikeFields || [];
120
+ let cols = [];
121
+ const entity = service.namespace ? findEpsEntity(`/${service.namespace}`) : undefined;
122
+ if (entity) {
123
+ cols = [
124
+ ...entity.columns || [],
125
+ ...entity.pageColumns || []
126
+ ];
127
+ if (!service.search) {
128
+ const op = entity.pageQueryOp;
129
+ if (op) {
130
+ fieldEq = op.fieldEq || [];
131
+ fieldLike = op.fieldLike || [];
132
+ fieldArray = op.fieldArray || [];
133
+ fieldRange = op.fieldRange || [];
134
+ keyWordLikeFields = op.keyWordLikeFields || [];
135
+ }
136
+ }
137
+ }
138
+ const colOf = (sourceOrName, short) => {
139
+ const source = sourceOrName.includes(".") ? sourceOrName : `a.${sourceOrName}`;
140
+ const leaf = short ?? stripAlias(source);
141
+ return cols.find((c) => c.source === source) || cols.find((c) => c.propertyName === leaf && (!c.source || c.source.startsWith("a."))) || cols.find((c) => c.propertyName === leaf);
142
+ };
143
+ const items = [];
144
+ const usedProps = new Set;
145
+ const pushItem = (item) => {
146
+ if (!item.prop || usedProps.has(item.prop))
147
+ return;
148
+ usedProps.add(item.prop);
149
+ items.push(item);
150
+ };
151
+ for (const raw of fieldLike) {
152
+ const ref = parseRef(raw);
153
+ if (!ref || ref.none || ignore.has(ref.param))
154
+ continue;
155
+ const meta = colOf(ref.source, ref.column);
156
+ const name = displayName(ref, meta);
157
+ const fieldKey = fieldKeyOf(ref, meta);
158
+ pushItem({
159
+ prop: ref.param,
160
+ label: options.hideLabel ? "" : name,
161
+ nameFallback: name,
162
+ fieldKey,
163
+ phMode: "search",
164
+ placeholder: `搜索${name}`,
165
+ type: "input"
166
+ });
167
+ }
168
+ for (const raw of fieldArray) {
169
+ const ref = parseRef(raw);
170
+ if (!ref || ref.none || ignore.has(ref.param))
171
+ continue;
172
+ const meta = colOf(ref.source, ref.column);
173
+ const name = displayName(ref, meta);
174
+ const fieldKey = fieldKeyOf(ref, meta);
175
+ pushItem({
176
+ prop: ref.param,
177
+ label: options.hideLabel ? "" : name,
178
+ nameFallback: name,
179
+ fieldKey,
180
+ phMode: "search",
181
+ placeholder: `搜索${name}`,
182
+ type: "input"
183
+ });
184
+ }
185
+ for (const raw of fieldEq) {
186
+ const ref = parseRef(raw);
187
+ if (!ref || ref.none || ignore.has(ref.param))
188
+ continue;
189
+ const meta = colOf(ref.source, ref.column);
190
+ const dictKey = ref.dict || (typeof meta?.dict === "string" ? meta.dict : Array.isArray(meta?.dict) ? meta.dict[0] : undefined);
191
+ const name = displayName(ref, meta);
192
+ const fieldKey = fieldKeyOf(ref, meta);
193
+ const label = options.hideLabel ? "" : name;
194
+ if (dictKey) {
195
+ pushItem({
196
+ prop: ref.param,
197
+ label,
198
+ nameFallback: name,
199
+ fieldKey,
200
+ phMode: "select",
201
+ placeholder: `选择${name}`,
202
+ type: "select",
203
+ dict: dictKey,
204
+ multiple: ref.multiple
205
+ });
206
+ } else {
207
+ pushItem({
208
+ prop: ref.param,
209
+ label,
210
+ nameFallback: name,
211
+ fieldKey,
212
+ phMode: "search",
213
+ placeholder: `搜索${name}`,
214
+ type: "input"
215
+ });
216
+ }
217
+ }
218
+ for (const r of fieldRange) {
219
+ if (!r?.column || r.none)
220
+ continue;
221
+ if (ignore.has(r.min) || ignore.has(r.max))
222
+ continue;
223
+ const source = toSource(r.column);
224
+ const col = stripAlias(r.column);
225
+ const meta = colOf(source, col);
226
+ const name = r.label || meta?.comment || col;
227
+ const fieldKey = fieldKeyOf({ column: col }, meta);
228
+ const label = options.hideLabel ? "" : name;
229
+ const isNum = r.type === "int" || r.type === "float";
230
+ const startHint = isNum ? "最小值" : "开始";
231
+ const endHint = isNum ? "最大值" : "结束";
232
+ pushItem({
233
+ prop: `__range_${r.min}_${r.max}`,
234
+ label,
235
+ nameFallback: name,
236
+ fieldKey,
237
+ phMode: "range",
238
+ placeholder: name || "区间",
239
+ type: isNum ? "number-range" : "daterange",
240
+ range: { min: r.min, max: r.max, rangeType: r.type },
241
+ component: {
242
+ name: isNum ? "vm-number-range" : "vm-date-range",
243
+ props: isNum ? {
244
+ mode: r.type,
245
+ startPlaceholder: `${name}${startHint}`,
246
+ endPlaceholder: `${name}${endHint}`
247
+ } : {
248
+ precision: r.type,
249
+ startPlaceholder: `${name}${startHint}`,
250
+ endPlaceholder: `${name}${endHint}`
251
+ }
252
+ }
253
+ });
254
+ }
255
+ if (keyWordLikeFields.length) {
256
+ const parts = [];
257
+ const names = keyWordLikeFields.map((raw) => {
258
+ const ref = parseRef(raw);
259
+ if (!ref)
260
+ return typeof raw === "string" ? stripAlias(raw) : "";
261
+ const meta = colOf(ref.source, ref.column);
262
+ const fk = fieldKeyOf(ref, meta);
263
+ if (fk)
264
+ parts.push(fk);
265
+ return displayName(ref, meta);
266
+ }).filter(Boolean);
267
+ pushItem({
268
+ prop: "keyWord",
269
+ label: options.hideLabel ? "" : "关键字",
270
+ nameFallback: names.join("、") || "关键字",
271
+ phMode: "keyword",
272
+ keywordParts: parts,
273
+ placeholder: `搜索${names.join("、") || "关键字"}`,
274
+ type: "input"
275
+ });
276
+ }
277
+ return items;
278
+ }
@@ -1 +1,35 @@
1
- const _0xd8f552=_0x47a5;(function(_0xa22d2f,_0x4c1bd4){const _0x290900=_0x47a5,_0x8f374e=_0xa22d2f();while(!![]){try{const _0x2d5fa2=-parseInt(_0x290900(0x10d))/0x1*(-parseInt(_0x290900(0x11b))/0x2)+parseInt(_0x290900(0x119))/0x3*(parseInt(_0x290900(0x112))/0x4)+parseInt(_0x290900(0x11a))/0x5+parseInt(_0x290900(0x10b))/0x6+-parseInt(_0x290900(0x116))/0x7*(parseInt(_0x290900(0x115))/0x8)+-parseInt(_0x290900(0x111))/0x9+parseInt(_0x290900(0x114))/0xa*(-parseInt(_0x290900(0x10e))/0xb);if(_0x2d5fa2===_0x4c1bd4)break;else _0x8f374e['push'](_0x8f374e['shift']());}catch(_0x101dae){_0x8f374e['push'](_0x8f374e['shift']());}}}(_0x80fc,0x5ec97));import{onMounted,onUnmounted,ref}from'vue';import{getCrudStyle}from'./style';export const FORM_COLS_DESKTOP=0x18;function _0x47a5(_0x4b5da4,_0x28a294){_0x4b5da4=_0x4b5da4-0x10b;const _0x80fc3=_0x80fc();let _0x47a512=_0x80fc3[_0x4b5da4];if(_0x47a5['YCyuSc']===undefined){var _0x3ed15a=function(_0x59f936){const _0x2b1dc9='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x138121='',_0x38df55='';for(let _0x20d88e=0x0,_0xc1fb15,_0x3ff1ad,_0x24c351=0x0;_0x3ff1ad=_0x59f936['charAt'](_0x24c351++);~_0x3ff1ad&&(_0xc1fb15=_0x20d88e%0x4?_0xc1fb15*0x40+_0x3ff1ad:_0x3ff1ad,_0x20d88e++%0x4)?_0x138121+=String['fromCharCode'](0xff&_0xc1fb15>>(-0x2*_0x20d88e&0x6)):0x0){_0x3ff1ad=_0x2b1dc9['indexOf'](_0x3ff1ad);}for(let _0x18a527=0x0,_0x1e8cdd=_0x138121['length'];_0x18a527<_0x1e8cdd;_0x18a527++){_0x38df55+='%'+('00'+_0x138121['charCodeAt'](_0x18a527)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x38df55);};_0x47a5['zNDyzo']=_0x3ed15a,_0x47a5['XCJDgp']={},_0x47a5['YCyuSc']=!![];}const _0xfa2c75=_0x80fc3[0x0],_0x5c3f7c=_0x4b5da4+_0xfa2c75,_0x3a3d9d=_0x47a5['XCJDgp'][_0x5c3f7c];return!_0x3a3d9d?(_0x47a512=_0x47a5['zNDyzo'](_0x47a512),_0x47a5['XCJDgp'][_0x5c3f7c]=_0x47a512):_0x47a512=_0x3a3d9d,_0x47a512;}export const FORM_COLS_MOBILE=0xc;export const FORM_SPAN_FULL=0x18;function _0x80fc(){const _0x2e281f=['mteYodq4mfrUEuPXCW','mtKYndC5mLbVy0Pitq','mJffyuHXCuG','y2HHBMDL','CMvTB3zLrxzLBNrmAxn0zw5LCG','nKLhAuLJDG','mZmXmJGWmgjHreDSEG','mJGZmtzOBhzyEMq','Bwf4','kg1HEc13Awr0AdOGnZy4ChGP','Bwf0y2HLCW','ywrKrxzLBNrmAxn0zw5LCG','mZyWodCXmKHrCuLiua','BwLU','ntbhBeLkzwe','mJjdvfPzCNO','C3bHBG','Bwf0y2HnzwrPyq','nJy2nZG0ohrWvu1bAa','mJa5ndaWr01SyMve','CM91BMq'];_0x80fc=function(){return _0x2e281f;};return _0x80fc();}export const FORM_MQ_MOBILE=_0xd8f552(0x11d);export function getFormCols(){const _0x146f7f=_0xd8f552;if(typeof window!=='undefined'&&window[_0x146f7f(0x110)](FORM_MQ_MOBILE)[_0x146f7f(0x11e)])return FORM_COLS_MOBILE;return FORM_COLS_DESKTOP;}export function resolveFormSpan(_0x138121,_0x38df55=getFormCols()){const _0xa378b4=_0xd8f552,_0x20d88e=_0x138121??getCrudStyle()['form'][_0xa378b4(0x10f)]??FORM_SPAN_FULL,_0xc1fb15=Math[_0xa378b4(0x10c)](FORM_SPAN_FULL,Math['max'](0x1,_0x20d88e));if(_0x38df55===FORM_COLS_DESKTOP)return _0xc1fb15;return Math[_0xa378b4(0x11c)](0x1,Math[_0xa378b4(0x113)](_0xc1fb15/FORM_COLS_DESKTOP*FORM_COLS_MOBILE));}export function useFormCols(){const _0x3ff1ad=ref(getFormCols());let _0x24c351=null;const _0x18a527=()=>{_0x3ff1ad['value']=getFormCols();};return onMounted(()=>{const _0x1df883=_0x47a5;_0x24c351=window[_0x1df883(0x110)](FORM_MQ_MOBILE),_0x24c351[_0x1df883(0x11f)](_0x1df883(0x117),_0x18a527),_0x18a527();}),onUnmounted(()=>{const _0xfaa8c9=_0x47a5;_0x24c351?.[_0xfaa8c9(0x118)](_0xfaa8c9(0x117),_0x18a527);}),_0x3ff1ad;}
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 +1,132 @@
1
- const _0x19b041=_0x4a8d;(function(_0x337a02,_0x3502f9){const _0x3f96e0=_0x4a8d,_0x69cfda=_0x337a02();while(!![]){try{const _0xa30923=-parseInt(_0x3f96e0(0x80))/0x1*(-parseInt(_0x3f96e0(0x92))/0x2)+parseInt(_0x3f96e0(0x8e))/0x3+-parseInt(_0x3f96e0(0x82))/0x4*(parseInt(_0x3f96e0(0x7e))/0x5)+-parseInt(_0x3f96e0(0x7b))/0x6*(-parseInt(_0x3f96e0(0x83))/0x7)+-parseInt(_0x3f96e0(0x93))/0x8*(parseInt(_0x3f96e0(0x95))/0x9)+parseInt(_0x3f96e0(0xa6))/0xa*(parseInt(_0x3f96e0(0x99))/0xb)+parseInt(_0x3f96e0(0x9b))/0xc;if(_0xa30923===_0x3502f9)break;else _0x69cfda['push'](_0x69cfda['shift']());}catch(_0x17b8ea){_0x69cfda['push'](_0x69cfda['shift']());}}}(_0x21c1,0x56d44));import{ref}from'vue';import{CRUD_LABELS,DEFAULT_CRUD_DICT}from'./dict';function _0x4a8d(_0x35f8e1,_0x270b45){_0x35f8e1=_0x35f8e1-0x76;const _0x21c194=_0x21c1();let _0x4a8dd6=_0x21c194[_0x35f8e1];if(_0x4a8d['bqONPw']===undefined){var _0x130157=function(_0x7f3dbe){const _0x2f5066='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x257d36='',_0x2b234b='';for(let _0x204c97=0x0,_0x333fdc,_0x1fe27e,_0x46eb6c=0x0;_0x1fe27e=_0x7f3dbe['charAt'](_0x46eb6c++);~_0x1fe27e&&(_0x333fdc=_0x204c97%0x4?_0x333fdc*0x40+_0x1fe27e:_0x1fe27e,_0x204c97++%0x4)?_0x257d36+=String['fromCharCode'](0xff&_0x333fdc>>(-0x2*_0x204c97&0x6)):0x0){_0x1fe27e=_0x2f5066['indexOf'](_0x1fe27e);}for(let _0x331c3c=0x0,_0x6b9ac3=_0x257d36['length'];_0x331c3c<_0x6b9ac3;_0x331c3c++){_0x2b234b+='%'+('00'+_0x257d36['charCodeAt'](_0x331c3c)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2b234b);};_0x4a8d['iyheGp']=_0x130157,_0x4a8d['tFvhzq']={},_0x4a8d['bqONPw']=!![];}const _0x329bc5=_0x21c194[0x0],_0x20bbb2=_0x35f8e1+_0x329bc5,_0x2db9b1=_0x4a8d['tFvhzq'][_0x20bbb2];return!_0x2db9b1?(_0x4a8dd6=_0x4a8d['iyheGp'](_0x4a8dd6),_0x4a8d['tFvhzq'][_0x20bbb2]=_0x4a8dd6):_0x4a8dd6=_0x2db9b1,_0x4a8dd6;}export const DEFAULT_CRUD_STYLE={'form':{'labelPosition':'top','labelWidth':_0x19b041(0x7a),'span':0x18,'plugins':[]},'table':{'border':![],'highlightCurrentRow':!![],'autoHeight':!![],'contextMenu':[_0x19b041(0x87),_0x19b041(0x8a),_0x19b041(0x8f),_0x19b041(0x9f),_0x19b041(0x88),_0x19b041(0x81)],'column':{'align':'left','opWidth':0xb4},'plugins':[]},'search':{'plugins':[]},'colors':[_0x19b041(0xa9),_0x19b041(0x94),_0x19b041(0x9d),_0x19b041(0x8c),_0x19b041(0xa5),_0x19b041(0xaa),'#aa7a24','#1c109d']};let globalConfig={'dict':{...DEFAULT_CRUD_DICT,'label':{...CRUD_LABELS}},'style':structuredClone(DEFAULT_CRUD_STYLE)};export const crudLocaleRev=ref(0x0);let translateFn=null;export function setCrudTranslator(_0x257d36){const _0x3d2f0f=_0x19b041;translateFn=_0x257d36,crudLocaleRev[_0x3d2f0f(0x98)]++;}export function crudT(_0x2b234b,_0x204c97){if(translateFn){const _0x333fdc=translateFn(_0x2b234b,_0x204c97);if(_0x333fdc!=null&&_0x333fdc!==''&&_0x333fdc!==_0x2b234b)return _0x333fdc;}return _0x204c97??_0x2b234b;}function _0x21c1(){const _0xb2089=['mtaWChG','mJq2nZG2Eg9SvKDt','yxbP','CgfNAw5HDgLVBG','mJq2odGWnxbYzw5oBG','A2v5D29YzfbHCNrZ','mwzUtfDfwG','B3jKzxiTzgvZyW','nfjsvwzmyG','n1DAs0PzBG','CMfUz2u','C2vSzwn0tMfTzwq','Aw50','CMvMCMvZAa','B3jKzxiTyxnJ','y29SDw1U','y2HLy2S','zMLLBgrlzxK','i2q1nZeYmq','zMLLBgqU','mJy4mdC0zvHOAvPq','zwrPDa','zM9YBq','C2vHCMnO','mJGWnZeYrLzAqujA','mJe0mJr0r3rLqwK','iZa2yJmXyW','mty1nLbYEhfnDW','y29SB3jZ','BgfIzwW','DMfSDwu','mtfrvu1huwO','C29YDa','ody5ndiWnhPOthrytW','A2v5D29Yza','i2u5m2y0za','CMfUz2vuExbL','zgvSzxrL','Cg9W','C3rHCNq','C3r5Bgu','AM9PBG','zgLJDa','iZzKmtDJmW','mZq2odaZmeLlAhvPCG','zw5K','C2vHCMnOtMfTzwq','iZrfnurgrG','iZa0yZi3mW','zMLSDgvY','BwfW','C2vSzwn0','DgfIBgu','CgHnB2rL','DhLWzq','BMfTzuzHBgXIywnR'];_0x21c1=function(){return _0xb2089;};return _0x21c1();}export function crudLabel(_0x1fe27e,_0x46eb6c){const _0x379b64=_0x19b041;crudLocaleRev[_0x379b64(0x98)];const _0x331c3c=_0x46eb6c?.[_0x1fe27e]??globalConfig['dict'][_0x379b64(0x97)][_0x1fe27e]??CRUD_LABELS[_0x1fe27e]??_0x1fe27e;return crudT('crud.'+_0x1fe27e,_0x331c3c);}export function crudFormat(_0x6b9ac3,..._0x4f9ba3){let _0x2a0ba5=String(_0x6b9ac3??'');for(let _0x1b460c=0x0;_0x1b460c<_0x4f9ba3['length'];_0x1b460c++){_0x2a0ba5=_0x2a0ba5['replace'](new RegExp('\x5c{'+_0x1b460c+'\x5c}','g'),String(_0x4f9ba3[_0x1b460c]));}return _0x2a0ba5;}export function resolveSearchPlaceholder(_0x49287a){const _0x3d4fd3=_0x19b041;crudLocaleRev[_0x3d4fd3(0x98)];const _0x5c119b=(_0x5a8824,_0x3ef7a3)=>_0x5a8824?crudT(_0x3d4fd3(0x8d)+_0x5a8824,_0x3ef7a3||_0x5a8824):_0x3ef7a3||'';if(_0x49287a[_0x3d4fd3(0x77)]===_0x3d4fd3(0x9c)){const _0x135bc1=(_0x49287a[_0x3d4fd3(0x7f)]||[])[_0x3d4fd3(0xac)](_0x4c8ad1=>_0x5c119b(_0x4c8ad1,_0x4c8ad1['split']('.')[_0x3d4fd3(0xa0)]()))[_0x3d4fd3(0xab)](Boolean),_0x54bdd3=_0x135bc1[_0x3d4fd3(0xa3)]('、')||_0x49287a['nameFallback']||crudLabel('keyword');return crudFormat(crudLabel('searchNamed'),_0x54bdd3);}const _0x2c50cd=_0x5c119b(_0x49287a[_0x3d4fd3(0x8b)],_0x49287a[_0x3d4fd3(0x79)]||_0x49287a[_0x3d4fd3(0x97)])||_0x49287a[_0x3d4fd3(0x79)]||_0x49287a[_0x3d4fd3(0x97)]||'';if(_0x49287a[_0x3d4fd3(0x77)]===_0x3d4fd3(0xad))return crudFormat(crudLabel(_0x3d4fd3(0x85)),_0x2c50cd);if(_0x49287a['phMode']===_0x3d4fd3(0x84))return _0x2c50cd||crudLabel(_0x3d4fd3(0x84));if(_0x49287a[_0x3d4fd3(0x77)]===_0x3d4fd3(0x91)||_0x49287a[_0x3d4fd3(0x8b)])return crudFormat(crudLabel(_0x3d4fd3(0xa8)),_0x2c50cd);return _0x49287a['placeholder']||_0x49287a[_0x3d4fd3(0x97)]||'';}export function resolveRangePlaceholders(_0x2e5a8f){const _0x43674f=_0x19b041;crudLocaleRev[_0x43674f(0x98)];const _0x3a9b5a=(_0x2e5a8f[_0x43674f(0x8b)]?crudT('field.'+_0x2e5a8f[_0x43674f(0x8b)],_0x2e5a8f[_0x43674f(0x79)]||_0x2e5a8f[_0x43674f(0x97)]||''):_0x2e5a8f[_0x43674f(0x79)]||_0x2e5a8f['label']||'')||'',_0x2f92c4=_0x2e5a8f[_0x43674f(0x78)]==='number-range'||_0x2e5a8f[_0x43674f(0x84)]?.[_0x43674f(0x9e)]===_0x43674f(0x86)||_0x2e5a8f[_0x43674f(0x84)]?.[_0x43674f(0x9e)]==='float',_0xe803f4=_0x2f92c4?crudLabel('min'):crudLabel(_0x43674f(0xa1)),_0x865d6b=_0x2f92c4?crudLabel('max'):crudLabel(_0x43674f(0xa7));return{'startPlaceholder':''+_0x3a9b5a+_0xe803f4,'endPlaceholder':''+_0x3a9b5a+_0x865d6b};}export function setCrudConfig(_0x1526bb){const _0xc8f66d=_0x19b041;if(!_0x1526bb)return globalConfig;return globalConfig={'dict':{...globalConfig['dict'],..._0x1526bb[_0xc8f66d(0xa4)],'api':{...globalConfig[_0xc8f66d(0xa4)][_0xc8f66d(0x7c)],..._0x1526bb[_0xc8f66d(0xa4)]?.[_0xc8f66d(0x7c)]},'pagination':{...globalConfig[_0xc8f66d(0xa4)][_0xc8f66d(0x7d)],..._0x1526bb[_0xc8f66d(0xa4)]?.[_0xc8f66d(0x7d)]},'search':{...globalConfig['dict'][_0xc8f66d(0x91)],..._0x1526bb['dict']?.[_0xc8f66d(0x91)]},'sort':{...globalConfig['dict'][_0xc8f66d(0x9a)],..._0x1526bb[_0xc8f66d(0xa4)]?.[_0xc8f66d(0x9a)]},'label':{...globalConfig[_0xc8f66d(0xa4)]['label'],..._0x1526bb['dict']?.[_0xc8f66d(0x97)]}},'style':{...globalConfig[_0xc8f66d(0xa2)],..._0x1526bb['style'],'form':{...globalConfig[_0xc8f66d(0xa2)][_0xc8f66d(0x90)],..._0x1526bb[_0xc8f66d(0xa2)]?.[_0xc8f66d(0x90)]},'table':{...globalConfig[_0xc8f66d(0xa2)]['table'],..._0x1526bb['style']?.['table'],'column':{...globalConfig[_0xc8f66d(0xa2)][_0xc8f66d(0x76)]['column'],..._0x1526bb['style']?.[_0xc8f66d(0x76)]?.[_0xc8f66d(0x89)]}},'search':{...globalConfig[_0xc8f66d(0xa2)][_0xc8f66d(0x91)],..._0x1526bb['style']?.['search']},'colors':_0x1526bb[_0xc8f66d(0xa2)]?.[_0xc8f66d(0x96)]||globalConfig[_0xc8f66d(0xa2)][_0xc8f66d(0x96)]}},globalConfig;}export function getCrudConfig(){return globalConfig;}export function getCrudStyle(){return globalConfig['style'];}
1
+ import { ref } from "vue";
2
+ import { CRUD_LABELS, DEFAULT_CRUD_DICT } from "./dict";
3
+ export const DEFAULT_CRUD_STYLE = {
4
+ form: {
5
+ labelPosition: "top",
6
+ labelWidth: "100px",
7
+ span: 24,
8
+ plugins: []
9
+ },
10
+ table: {
11
+ border: false,
12
+ highlightCurrentRow: true,
13
+ autoHeight: true,
14
+ contextMenu: ["refresh", "check", "edit", "delete", "order-asc", "order-desc"],
15
+ column: {
16
+ align: "left",
17
+ opWidth: 180
18
+ },
19
+ plugins: []
20
+ },
21
+ search: {
22
+ plugins: []
23
+ },
24
+ colors: [
25
+ "#4E5DFF",
26
+ "#06b31c",
27
+ "#e93f4d",
28
+ "#d57121",
29
+ "#6d17c3",
30
+ "#04c273",
31
+ "#aa7a24",
32
+ "#1c109d"
33
+ ]
34
+ };
35
+ let globalConfig = {
36
+ dict: { ...DEFAULT_CRUD_DICT, label: { ...CRUD_LABELS } },
37
+ style: structuredClone(DEFAULT_CRUD_STYLE)
38
+ };
39
+ export const crudLocaleRev = ref(0);
40
+ let translateFn = null;
41
+ export function setCrudTranslator(fn) {
42
+ translateFn = fn;
43
+ crudLocaleRev.value++;
44
+ }
45
+ export function crudT(key, fallback) {
46
+ if (translateFn) {
47
+ const v = translateFn(key, fallback);
48
+ if (v != null && v !== "" && v !== key)
49
+ return v;
50
+ }
51
+ return fallback ?? key;
52
+ }
53
+ export function crudLabel(name, localLabel) {
54
+ crudLocaleRev.value;
55
+ const fb = localLabel?.[name] ?? globalConfig.dict.label[name] ?? CRUD_LABELS[name] ?? name;
56
+ return crudT(`crud.${name}`, fb);
57
+ }
58
+ export function crudFormat(tpl, ...args) {
59
+ let out = String(tpl ?? "");
60
+ for (let i = 0;i < args.length; i++) {
61
+ out = out.replace(new RegExp(`\\{${i}\\}`, "g"), String(args[i]));
62
+ }
63
+ return out;
64
+ }
65
+ export function resolveSearchPlaceholder(item) {
66
+ crudLocaleRev.value;
67
+ const fieldName = (key, fb) => key ? crudT(`field.${key}`, fb || key) : fb || "";
68
+ if (item.phMode === "keyword") {
69
+ const names = (item.keywordParts || []).map((k) => fieldName(k, k.split(".").pop())).filter(Boolean);
70
+ const joined = names.join("、") || item.nameFallback || crudLabel("keyword");
71
+ return crudFormat(crudLabel("searchNamed"), joined);
72
+ }
73
+ const name = fieldName(item.fieldKey, item.nameFallback || item.label) || item.nameFallback || item.label || "";
74
+ if (item.phMode === "select") {
75
+ return crudFormat(crudLabel("selectNamed"), name);
76
+ }
77
+ if (item.phMode === "range") {
78
+ return name || crudLabel("range");
79
+ }
80
+ if (item.phMode === "search" || item.fieldKey) {
81
+ return crudFormat(crudLabel("searchNamed"), name);
82
+ }
83
+ return item.placeholder || item.label || "";
84
+ }
85
+ export function resolveRangePlaceholders(item) {
86
+ crudLocaleRev.value;
87
+ const name = (item.fieldKey ? crudT(`field.${item.fieldKey}`, item.nameFallback || item.label || "") : item.nameFallback || item.label || "") || "";
88
+ const isNum = item.type === "number-range" || item.range?.rangeType === "int" || item.range?.rangeType === "float";
89
+ const startHint = isNum ? crudLabel("min") : crudLabel("start");
90
+ const endHint = isNum ? crudLabel("max") : crudLabel("end");
91
+ return {
92
+ startPlaceholder: `${name}${startHint}`,
93
+ endPlaceholder: `${name}${endHint}`
94
+ };
95
+ }
96
+ export function setCrudConfig(partial) {
97
+ if (!partial)
98
+ return globalConfig;
99
+ globalConfig = {
100
+ dict: {
101
+ ...globalConfig.dict,
102
+ ...partial.dict,
103
+ api: { ...globalConfig.dict.api, ...partial.dict?.api },
104
+ pagination: { ...globalConfig.dict.pagination, ...partial.dict?.pagination },
105
+ search: { ...globalConfig.dict.search, ...partial.dict?.search },
106
+ sort: { ...globalConfig.dict.sort, ...partial.dict?.sort },
107
+ label: { ...globalConfig.dict.label, ...partial.dict?.label }
108
+ },
109
+ style: {
110
+ ...globalConfig.style,
111
+ ...partial.style,
112
+ form: { ...globalConfig.style.form, ...partial.style?.form },
113
+ table: {
114
+ ...globalConfig.style.table,
115
+ ...partial.style?.table,
116
+ column: {
117
+ ...globalConfig.style.table.column,
118
+ ...partial.style?.table?.column
119
+ }
120
+ },
121
+ search: { ...globalConfig.style.search, ...partial.style?.search },
122
+ colors: partial.style?.colors || globalConfig.style.colors
123
+ }
124
+ };
125
+ return globalConfig;
126
+ }
127
+ export function getCrudConfig() {
128
+ return globalConfig;
129
+ }
130
+ export function getCrudStyle() {
131
+ return globalConfig.style;
132
+ }
@@ -1 +1,92 @@
1
- (function(_0x27fd1c,_0x4f1a4d){const _0x300aee=_0x455e,_0x2c7119=_0x27fd1c();while(!![]){try{const _0xe056a1=-parseInt(_0x300aee(0x81))/0x1*(-parseInt(_0x300aee(0x87))/0x2)+parseInt(_0x300aee(0x7e))/0x3*(-parseInt(_0x300aee(0x79))/0x4)+parseInt(_0x300aee(0x8a))/0x5+-parseInt(_0x300aee(0x8b))/0x6+-parseInt(_0x300aee(0x82))/0x7+-parseInt(_0x300aee(0x92))/0x8*(-parseInt(_0x300aee(0x7f))/0x9)+-parseInt(_0x300aee(0x75))/0xa*(-parseInt(_0x300aee(0x7c))/0xb);if(_0xe056a1===_0x4f1a4d)break;else _0x2c7119['push'](_0x2c7119['shift']());}catch(_0x479e60){_0x2c7119['push'](_0x2c7119['shift']());}}}(_0x3e62,0x8112b));function isEmpty(_0x203f8a){const _0x5d3a5f=_0x455e;if(_0x203f8a==null||_0x203f8a==='')return!![];if(typeof _0x203f8a===_0x5d3a5f(0x77)&&_0x203f8a[_0x5d3a5f(0x8c)]()==='')return!![];if(Array[_0x5d3a5f(0x8f)](_0x203f8a)&&_0x203f8a['length']===0x0)return!![];return![];}function normalizeRules(_0x308fe2){const _0x3b50a1=_0x455e,_0x1f1466=[];_0x308fe2[_0x3b50a1(0x7a)]&&_0x1f1466[_0x3b50a1(0x91)]({'required':!![],'message':_0x308fe2['label']+_0x3b50a1(0x88)});const _0x112261=_0x308fe2[_0x3b50a1(0x94)];if(!_0x112261)return _0x1f1466;if(Array[_0x3b50a1(0x8f)](_0x112261))for(const _0x285a7a of _0x112261){if(_0x285a7a&&typeof _0x285a7a==='object')_0x1f1466[_0x3b50a1(0x91)](_0x285a7a);}else typeof _0x112261==='object'&&_0x1f1466['push'](_0x112261);return _0x1f1466;}function isItemHidden(_0x166817,_0x18b8aa){const _0x392c48=_0x455e;if(typeof _0x166817['hidden']===_0x392c48(0x7d))return _0x166817[_0x392c48(0x85)](_0x18b8aa);return Boolean(_0x166817[_0x392c48(0x85)]);}function _0x3e62(){const _0x1efc29=['mJq1nZm4n0jdyurIEq','ChjVCa','mMzUv2Pdvq','mZe0oty5ovrYruvLrq','BgfIzwW','BwLU','AgLKzgvU','Bwf4','ndaWnZG4BMTlBM5R','5lIn6io95lI656M6','5QcH6AQm5AsX6lsL','ndyZnZG2nufKC0zRzG','mZeWode5ohjysxnLsG','DhjPBq','BgvUz3rO','DgvZDa','AxnbCNjHEq','BwvZC2fNzq','ChvZAa','mJrfyK15rgy','5PYa5AsAia','CNvSzxm','nZi0odiWvKP1z1j2','Cgf0DgvYBG','C3rYAw5N','DMfSAwrHDg9Y','mJHht2vREKe','CMvXDwLYzwq','ios4QUwTL+ESPG','mJjRCxjyy0S','zNvUy3rPB24','mZqXmdq5yu9ot0Ps'];_0x3e62=function(){return _0x1efc29;};return _0x3e62();}async function validateItem(_0x46e3cf,_0x105f2b){const _0x1c377e=_0x455e,_0x476c61=_0x105f2b[_0x46e3cf[_0x1c377e(0x80)]];for(const _0x330c27 of normalizeRules(_0x46e3cf)){if(_0x330c27['required']&&isEmpty(_0x476c61))return _0x330c27[_0x1c377e(0x90)]||_0x46e3cf[_0x1c377e(0x83)]+'不能为空';if(isEmpty(_0x476c61))continue;const _0x33a601=String(_0x476c61);if(_0x330c27[_0x1c377e(0x84)]!=null&&_0x33a601[_0x1c377e(0x8d)]<_0x330c27[_0x1c377e(0x84)])return _0x330c27[_0x1c377e(0x90)]||_0x46e3cf[_0x1c377e(0x83)]+'至少\x20'+_0x330c27[_0x1c377e(0x84)]+'\x20个字符';if(_0x330c27[_0x1c377e(0x86)]!=null&&_0x33a601[_0x1c377e(0x8d)]>_0x330c27[_0x1c377e(0x86)])return _0x330c27[_0x1c377e(0x90)]||_0x46e3cf[_0x1c377e(0x83)]+_0x1c377e(0x93)+_0x330c27['max']+_0x1c377e(0x7b);if(_0x330c27['pattern']&&!_0x330c27[_0x1c377e(0x76)][_0x1c377e(0x8e)](_0x33a601))return _0x330c27['message']||_0x46e3cf[_0x1c377e(0x83)]+'格式不正确';if(_0x330c27['validator']){const _0x14a0f0=await _0x330c27[_0x1c377e(0x78)](_0x476c61,_0x105f2b);if(_0x14a0f0!==!![])return _0x14a0f0||_0x46e3cf[_0x1c377e(0x83)]+_0x1c377e(0x89);}}return null;}export async function validateFormItems(_0x429d6b,_0x5a2d26){for(const _0x37f4e8 of _0x429d6b){if(isItemHidden(_0x37f4e8,_0x5a2d26))continue;const _0x534516=await validateItem(_0x37f4e8,_0x5a2d26);if(_0x534516)return _0x534516;}return null;}export async function validateFormFields(_0x356583,_0x1aeeb7){const _0x5ae800=_0x455e,_0x24a7b5={};for(const _0x38e65e of _0x356583){if(isItemHidden(_0x38e65e,_0x1aeeb7))continue;const _0x11a58b=await validateItem(_0x38e65e,_0x1aeeb7);if(_0x11a58b)_0x24a7b5[_0x38e65e[_0x5ae800(0x80)]]=_0x11a58b;}return _0x24a7b5;}function _0x455e(_0x59c136,_0x1b0aa4){_0x59c136=_0x59c136-0x75;const _0x3e627b=_0x3e62();let _0x455e57=_0x3e627b[_0x59c136];if(_0x455e['HtmLpS']===undefined){var _0x237336=function(_0x22807f){const _0x3452c7='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x203f8a='',_0x308fe2='';for(let _0x1f1466=0x0,_0x112261,_0x285a7a,_0x166817=0x0;_0x285a7a=_0x22807f['charAt'](_0x166817++);~_0x285a7a&&(_0x112261=_0x1f1466%0x4?_0x112261*0x40+_0x285a7a:_0x285a7a,_0x1f1466++%0x4)?_0x203f8a+=String['fromCharCode'](0xff&_0x112261>>(-0x2*_0x1f1466&0x6)):0x0){_0x285a7a=_0x3452c7['indexOf'](_0x285a7a);}for(let _0x18b8aa=0x0,_0x46e3cf=_0x203f8a['length'];_0x18b8aa<_0x46e3cf;_0x18b8aa++){_0x308fe2+='%'+('00'+_0x203f8a['charCodeAt'](_0x18b8aa)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x308fe2);};_0x455e['zxQYkx']=_0x237336,_0x455e['EqPyle']={},_0x455e['HtmLpS']=!![];}const _0x382fc9=_0x3e627b[0x0],_0x339fcf=_0x59c136+_0x382fc9,_0x12b366=_0x455e['EqPyle'][_0x339fcf];return!_0x12b366?(_0x455e57=_0x455e['zxQYkx'](_0x455e57),_0x455e['EqPyle'][_0x339fcf]=_0x455e57):_0x455e57=_0x12b366,_0x455e57;}export function applySetRules(_0x126067){return _0x126067['map'](_0x2c4967=>{const _0x44a8f8=_0x455e;if(!_0x2c4967[_0x44a8f8(0x7a)]||_0x2c4967[_0x44a8f8(0x94)])return _0x2c4967;return{..._0x2c4967,'rules':[{'required':!![],'message':_0x2c4967['label']+_0x44a8f8(0x88)}]};});}
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
+ }
@@ -90,6 +90,8 @@
90
90
  class="vm-crud-upsert__textarea"
91
91
  :placeholder="item.placeholder"
92
92
  :disabled="isInfo || item.disabled"
93
+ :rows="textareaRows(item)"
94
+ :style="textareaStyle(item)"
93
95
  :value="String(crud.upsertForm.value[item.prop] ?? '')"
94
96
  @input="setField(item.prop, ($event.target as HTMLTextAreaElement).value)"
95
97
  />
@@ -368,6 +370,33 @@ function itemSpan(item: CrudFormItem) {
368
370
  return resolveFormSpan(item.span, formCols.value)
369
371
  }
370
372
 
373
+ /** textarea:component.props.rows / height / style */
374
+ function textareaProps(item: CrudFormItem) {
375
+ const raw = toValue(item.component?.props)
376
+ if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {}
377
+ return raw as Record<string, unknown>
378
+ }
379
+
380
+ function textareaRows(item: CrudFormItem) {
381
+ const rows = textareaProps(item).rows
382
+ return typeof rows === 'number' || typeof rows === 'string' ? rows : undefined
383
+ }
384
+
385
+ function textareaStyle(item: CrudFormItem) {
386
+ const p = textareaProps(item)
387
+ const style: Record<string, string> = {
388
+ ...((p.style && typeof p.style === 'object'
389
+ ? (p.style as Record<string, string>)
390
+ : {}) as Record<string, string>),
391
+ }
392
+ if (p.height != null && p.height !== '') {
393
+ const h = typeof p.height === 'number' ? `${p.height}px` : String(p.height)
394
+ style.height = h
395
+ if (!style.minHeight) style.minHeight = h
396
+ }
397
+ return Object.keys(style).length ? style : undefined
398
+ }
399
+
371
400
  function onCloseClick() {
372
401
  const done = () => crud.upsertClose()
373
402
  if (upsertOpts?.onClose) {
@@ -1 +1,14 @@
1
- (function(_0x260403,_0xce07b4){const _0x5ab27e=_0x55dc,_0x646923=_0x260403();while(!![]){try{const _0x59c218=parseInt(_0x5ab27e(0x1e3))/0x1+parseInt(_0x5ab27e(0x1e0))/0x2*(parseInt(_0x5ab27e(0x1d8))/0x3)+parseInt(_0x5ab27e(0x1df))/0x4+parseInt(_0x5ab27e(0x1d5))/0x5*(-parseInt(_0x5ab27e(0x1e2))/0x6)+-parseInt(_0x5ab27e(0x1de))/0x7*(parseInt(_0x5ab27e(0x1d6))/0x8)+parseInt(_0x5ab27e(0x1d9))/0x9+parseInt(_0x5ab27e(0x1e1))/0xa*(-parseInt(_0x5ab27e(0x1db))/0xb);if(_0x59c218===_0xce07b4)break;else _0x646923['push'](_0x646923['shift']());}catch(_0x45621e){_0x646923['push'](_0x646923['shift']());}}}(_0x1adf,0x1f1b1));function _0x55dc(_0x78153a,_0x5860f9){_0x78153a=_0x78153a-0x1d4;const _0x1adf17=_0x1adf();let _0x55dc07=_0x1adf17[_0x78153a];if(_0x55dc['aHeYZL']===undefined){var _0x41d3ff=function(_0x7f5e9e){const _0x480c6a='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x24cded='',_0x4f5144='';for(let _0x3da18b=0x0,_0x3b6e8e,_0x240283,_0x16e6a0=0x0;_0x240283=_0x7f5e9e['charAt'](_0x16e6a0++);~_0x240283&&(_0x3b6e8e=_0x3da18b%0x4?_0x3b6e8e*0x40+_0x240283:_0x240283,_0x3da18b++%0x4)?_0x24cded+=String['fromCharCode'](0xff&_0x3b6e8e>>(-0x2*_0x3da18b&0x6)):0x0){_0x240283=_0x480c6a['indexOf'](_0x240283);}for(let _0xff612f=0x0,_0x4356d7=_0x24cded['length'];_0xff612f<_0x4356d7;_0xff612f++){_0x4f5144+='%'+('00'+_0x24cded['charCodeAt'](_0xff612f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4f5144);};_0x55dc['jdEmhU']=_0x41d3ff,_0x55dc['evqrus']={},_0x55dc['aHeYZL']=!![];}const _0x25de7f=_0x1adf17[0x0],_0x201a68=_0x78153a+_0x25de7f,_0x50b2d2=_0x55dc['evqrus'][_0x201a68];return!_0x50b2d2?(_0x55dc07=_0x55dc['jdEmhU'](_0x55dc07),_0x55dc['evqrus'][_0x201a68]=_0x55dc07):_0x55dc07=_0x50b2d2,_0x55dc07;}import{useUserStore}from'../stores/user';export const vPerm={'mounted'(_0x24cded,_0x4f5144){const _0x1c18d4=_0x55dc;apply(_0x24cded,_0x4f5144[_0x1c18d4(0x1d7)]);},'updated'(_0x3da18b,_0x3b6e8e){apply(_0x3da18b,_0x3b6e8e['value']);}};function _0x1adf(){const _0x38c797=['ntzbqwjlBfa','DMfSDwu','ntG0ne9rtNLqEG','mtCYmZK1owLNv0nLEa','zgLZCgXHEq','ntG2mJy3BfvwyxrP','AgfZugvYBq','BM9Uzq','mJm1mJa3u252A1vs','mtaWmZm3nKfjy0fAsW','mMT6u0H0zG','ndbvtuzvD0G','odK3mdz3DvnmAuK','mtC2mZe0DxPRCujJ','C3r5Bgu','mtvXCuPXBNi'];_0x1adf=function(){return _0x38c797;};return _0x1adf();}function apply(_0x240283,_0x16e6a0){const _0x3dabf4=_0x55dc,_0xff612f=useUserStore(),_0x4356d7=_0xff612f[_0x3dabf4(0x1dc)](_0x16e6a0);_0x240283[_0x3dabf4(0x1d4)][_0x3dabf4(0x1da)]=_0x4356d7?'':_0x3dabf4(0x1dd);}
1
+ import { useUserStore } from "../stores/user";
2
+ export const vPerm = {
3
+ mounted(el, binding) {
4
+ apply(el, binding.value);
5
+ },
6
+ updated(el, binding) {
7
+ apply(el, binding.value);
8
+ }
9
+ };
10
+ function apply(el, value) {
11
+ const user = useUserStore();
12
+ const ok = user.hasPerm(value);
13
+ el.style.display = ok ? "" : "none";
14
+ }