vome-core 0.0.90 → 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(_0x4cc5be,_0x343c89){const _0xb4e4af=_0x2bdd,_0xc70598=_0x4cc5be();while(!![]){try{const _0x37bbae=-parseInt(_0xb4e4af(0x1c0))/0x1*(-parseInt(_0xb4e4af(0x1e9))/0x2)+parseInt(_0xb4e4af(0x201))/0x3+-parseInt(_0xb4e4af(0x1e7))/0x4+-parseInt(_0xb4e4af(0x207))/0x5*(parseInt(_0xb4e4af(0x1c6))/0x6)+-parseInt(_0xb4e4af(0x1e3))/0x7+parseInt(_0xb4e4af(0x1f0))/0x8+parseInt(_0xb4e4af(0x1cb))/0x9*(parseInt(_0xb4e4af(0x1f4))/0xa);if(_0x37bbae===_0x343c89)break;else _0xc70598['push'](_0xc70598['shift']());}catch(_0x2bc08a){_0xc70598['push'](_0xc70598['shift']());}}}(_0x12ad,0xeacc6));import{findEpsEntity}from'../lib/eps';import{getCrudStyle}from'./style';export function toTree(_0x260228={}){const _0x33017e=_0x2bdd;return{'__plugin':'toTree','tree':!![],'lazy':_0x260228[_0x33017e(0x1ed)]??![]};}function _0x2bdd(_0x5ad1ef,_0x546810){_0x5ad1ef=_0x5ad1ef-0x1bd;const _0x12adb0=_0x12ad();let _0x2bdd2f=_0x12adb0[_0x5ad1ef];if(_0x2bdd['fASLBq']===undefined){var _0x532457=function(_0x1af824){const _0x164832='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x260228='',_0x1711a8='';for(let _0x1ef68d=0x0,_0x3ea85c,_0x243bd2,_0x127b16=0x0;_0x243bd2=_0x1af824['charAt'](_0x127b16++);~_0x243bd2&&(_0x3ea85c=_0x1ef68d%0x4?_0x3ea85c*0x40+_0x243bd2:_0x243bd2,_0x1ef68d++%0x4)?_0x260228+=String['fromCharCode'](0xff&_0x3ea85c>>(-0x2*_0x1ef68d&0x6)):0x0){_0x243bd2=_0x164832['indexOf'](_0x243bd2);}for(let _0x49fc9f=0x0,_0x3affc6=_0x260228['length'];_0x49fc9f<_0x3affc6;_0x49fc9f++){_0x1711a8+='%'+('00'+_0x260228['charCodeAt'](_0x49fc9f)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1711a8);};_0x2bdd['KilhzZ']=_0x532457,_0x2bdd['sLMdhL']={},_0x2bdd['fASLBq']=!![];}const _0x4290fe=_0x12adb0[0x0],_0x4db59b=_0x5ad1ef+_0x4290fe,_0x1f46e7=_0x2bdd['sLMdhL'][_0x4db59b];return!_0x1f46e7?(_0x2bdd2f=_0x2bdd['KilhzZ'](_0x2bdd2f),_0x2bdd['sLMdhL'][_0x4db59b]=_0x2bdd2f):_0x2bdd2f=_0x1f46e7,_0x2bdd2f;}function _0x12ad(){const _0x2f97e9=['mZGWntG5Du1NrgTW','DhjLzuXHENK','AgfZ','C2v0uNvSzxm','AwDUB3jLrMLLBgrZ','BgfIzwW','mJa1C2zTzKDA','zMLUza','x19Yyw5Nzv8','Aw5JBhvKzxm','mufWvu91uG','B2jQzwn0','C2v0qxv0BW','C291CMnL','yxv0B0HLAwDODa','zMXVyxq','mty0mZGYtNrKrKPz','DgfIBgu','A2v5v29YzeXPA2vgAwvSzhm','DM0Tzgf0zs1Yyw5Nzq','BM9Uzq','mZe3ntG1n21yqxbpzq','5ywZ6zsU5A2x','DhLWzq','zMLSDgvY','C3rYAw5N','y29SDw1U','5PYa5AsN5yc8','DhjLzq','zMLLBgrmAwTL','CMvWBgfJzq','CgfYyw0','AM9PBG','zMLLBgrsyw5Nzq','zMLLBgrbCNjHEq','AgLKzuXHyMvS','DM0TBNvTyMvYlxjHBMDL','C2vHCMnO','CgfNzvf1zxj5t3a','Aw5WDxq','zgLJDa','BNvTyMvYlxjHBMDL','yM9YzgvY','CgfNzunVBhvTBNm','Aw50','nZi3mZq5s21gB0vI','ChjVCgvYDhLoyw1L','C3bSAxq','C3rHCNrZv2L0Aa','nJi5mtuYnfjTDhvtyq','BwLU','mte1mJi4nNrmyuH3DG','C2vSzwn0','y29UDgv4De1LBNu','BxvSDgLWBgu','Bgf6Eq','ywrK','Dg9uCMvL','mtmXnZG0mdHWz3Pmy0C','BwfW','ChjVCa','AxnbCNjHEq','ndbLEu1hrgu','BMfTzxnWywnL','CgX1z2LUCW','ChvZAa','y29SDw1UCW','Bwf4','A2v5v29Yza','A2v5D29Yza','zMLLBgrfCq','DhjPBq','y29TBwvUDa','Cg9W','Bwf0y2G'];_0x12ad=function(){return _0x2f97e9;};return _0x12ad();}export function setFocus(_0x1711a8){return{'__plugin':'setFocus','prop':_0x1711a8??''};}export function setRules(){const _0x2de6a4=_0x2bdd;return{'__plugin':_0x2de6a4(0x204)};}export function setAuto(_0x1ef68d={'hideLabel':!![]}){const _0x56b971=_0x2bdd;return{'__plugin':_0x56b971(0x1c2),..._0x1ef68d};}export const Plugins={'Table':{'toTree':toTree},'Form':{'setFocus':setFocus,'setRules':setRules},'Search':{'setAuto':setAuto}};export function applyTablePlugins(_0x3ea85c){const _0x50d03b=_0x2bdd,_0x243bd2=getCrudStyle()[_0x50d03b(0x1c7)],_0x127b16={'border':_0x243bd2[_0x50d03b(0x1e0)],'autoHeight':_0x243bd2[_0x50d03b(0x1c4)],'contextMenu':_0x243bd2[_0x50d03b(0x1eb)],..._0x3ea85c},_0x49fc9f=[..._0x243bd2['plugins'],..._0x3ea85c?.[_0x50d03b(0x1f6)]||[]],_0x3affc6={..._0x127b16};delete _0x3affc6[_0x50d03b(0x1f6)];for(const _0xff7f00 of _0x49fc9f){if(!_0xff7f00||typeof _0xff7f00!=='object')continue;_0xff7f00['__plugin']===_0x50d03b(0x1ef)&&(_0x3affc6[_0x50d03b(0x1d2)]=!![],_0x3affc6[_0x50d03b(0x202)]=Boolean(_0xff7f00['lazy']));}return _0x3affc6;}function stripAlias(_0x22e266){const _0x256437=_0x2bdd;return _0x22e266[_0x256437(0x1bf)]('.')?_0x22e266[_0x256437(0x1e5)]('.')[_0x256437(0x1ff)]():_0x22e266;}function toSource(_0x6a47e3){const _0x53b158=_0x2bdd,_0x5090f0=_0x6a47e3[_0x53b158(0x1fd)]()[_0x53b158(0x1d4)](/\s+as\s+[a-zA-Z_]\w*$/i,'')['trim']();return _0x5090f0[_0x53b158(0x1bf)]('.')?_0x5090f0:'a.'+_0x5090f0;}function parseRef(_0x5089f1){const _0x51d1da=_0x2bdd,_0x52fef7=/^(.+?)\s+as\s+([a-zA-Z_]\w*)$/i,_0x9c6146=_0x89a0cc=>{const _0x5c5441=_0x2bdd,_0x1e332f=_0x89a0cc[_0x5c5441(0x1fd)](),_0x568c60=_0x1e332f[_0x5c5441(0x200)](_0x52fef7);if(_0x568c60)return{'expr':_0x568c60[0x1]['trim'](),'asName':_0x568c60[0x2]};return{'expr':_0x1e332f,'asName':undefined};};if(typeof _0x5089f1===_0x51d1da(0x1cf)){const {expr:_0x39367c,asName:_0x2b05fc}=_0x9c6146(_0x5089f1),_0xd8a62f=toSource(_0x39367c),_0x1fb78f=stripAlias(_0xd8a62f);return{'column':_0x1fb78f,'source':_0xd8a62f,'param':_0x2b05fc??_0x1fb78f,'multiple':!![],'none':![]};}if(!_0x5089f1||typeof _0x5089f1!==_0x51d1da(0x1c1))return null;const _0x567b85=_0x5089f1;if(!_0x567b85[_0x51d1da(0x1d0)])return null;const {expr:_0x284aa7,asName:_0x314a4f}=_0x9c6146(_0x567b85[_0x51d1da(0x1d0)]),_0x2e0e38=toSource(_0x284aa7),_0x343fb8=stripAlias(_0x2e0e38);return{'column':_0x343fb8,'source':_0x2e0e38,'param':_0x314a4f??_0x343fb8,'label':_0x567b85[_0x51d1da(0x206)],'dict':_0x567b85[_0x51d1da(0x1de)],'multiple':_0x567b85[_0x51d1da(0x1ec)]!==![],'none':Boolean(_0x567b85[_0x51d1da(0x1ca)])};}function displayName(_0x185f20,_0x22bf0f){const _0x44f9ae=_0x2bdd;return _0x185f20['label']||_0x22bf0f?.[_0x44f9ae(0x1fe)]||_0x185f20['column'];}function fieldKeyOf(_0x10926c,_0x15141b){const _0x365a11=_0x2bdd,_0x4a2145=_0x15141b?.[_0x365a11(0x1c7)]?.[_0x365a11(0x1fd)](),_0x2c92c3=(_0x15141b?.[_0x365a11(0x1e4)]||_0x10926c[_0x365a11(0x1d0)]||'')[_0x365a11(0x1fd)]();if(!_0x4a2145||!_0x2c92c3)return;return _0x4a2145+'.'+_0x2c92c3;}export function buildAutoSearchItems(_0x4f8709,_0x311137={}){const _0x3572a8=_0x2bdd,_0x59ebe9=new Set(_0x311137[_0x3572a8(0x205)]||[]),_0x575d46=_0x4f8709[_0x3572a8(0x1db)]||{};let _0x3c8650=_0x575d46['fieldEq']||[],_0x5e13cb=_0x575d46[_0x3572a8(0x1d3)]||[],_0x16bd9c=_0x575d46[_0x3572a8(0x1d8)]||[],_0x17753e=_0x575d46[_0x3572a8(0x1d7)]||[],_0x5deb66=_0x575d46[_0x3572a8(0x1c8)]||[],_0x389d76=[];const _0x1e1ce9=_0x4f8709[_0x3572a8(0x1f5)]?findEpsEntity('/'+_0x4f8709[_0x3572a8(0x1f5)]):undefined;if(_0x1e1ce9){_0x389d76=[..._0x1e1ce9[_0x3572a8(0x1f8)]||[],..._0x1e1ce9[_0x3572a8(0x1e1)]||[]];if(!_0x4f8709[_0x3572a8(0x1db)]){const _0x43450d=_0x1e1ce9[_0x3572a8(0x1dc)];_0x43450d&&(_0x3c8650=_0x43450d[_0x3572a8(0x1fc)]||[],_0x5e13cb=_0x43450d['fieldLike']||[],_0x16bd9c=_0x43450d['fieldArray']||[],_0x17753e=_0x43450d[_0x3572a8(0x1d7)]||[],_0x5deb66=_0x43450d['keyWordLikeFields']||[]);}}const _0x111428=(_0x24257c,_0x2c9b32)=>{const _0xde89f8=_0x3572a8,_0x4b4f09=_0x24257c[_0xde89f8(0x1bf)]('.')?_0x24257c:'a.'+_0x24257c,_0x1c527a=_0x2c9b32??stripAlias(_0x4b4f09);return _0x389d76[_0xde89f8(0x1bd)](_0x1ad4d5=>_0x1ad4d5[_0xde89f8(0x1c3)]===_0x4b4f09)||_0x389d76['find'](_0x1bb981=>_0x1bb981[_0xde89f8(0x1e4)]===_0x1c527a&&(!_0x1bb981[_0xde89f8(0x1c3)]||_0x1bb981[_0xde89f8(0x1c3)][_0xde89f8(0x1e6)]('a.')))||_0x389d76['find'](_0x218abb=>_0x218abb[_0xde89f8(0x1e4)]===_0x1c527a);},_0x44f24f=[],_0x1d7425=new Set(),_0x160d47=_0x46c5f8=>{const _0x4eedff=_0x3572a8;if(!_0x46c5f8[_0x4eedff(0x1f2)]||_0x1d7425[_0x4eedff(0x203)](_0x46c5f8['prop']))return;_0x1d7425[_0x4eedff(0x1ee)](_0x46c5f8[_0x4eedff(0x1f2)]),_0x44f24f[_0x4eedff(0x1f7)](_0x46c5f8);};for(const _0x3086c5 of _0x5e13cb){const _0x5c2d03=parseRef(_0x3086c5);if(!_0x5c2d03||_0x5c2d03[_0x3572a8(0x1ca)]||_0x59ebe9[_0x3572a8(0x203)](_0x5c2d03['param']))continue;const _0x2a6afb=_0x111428(_0x5c2d03['source'],_0x5c2d03['column']),_0x4c5134=displayName(_0x5c2d03,_0x2a6afb),_0xd8e4ec=fieldKeyOf(_0x5c2d03,_0x2a6afb);_0x160d47({'prop':_0x5c2d03['param'],'label':_0x311137['hideLabel']?'':_0x4c5134,'nameFallback':_0x4c5134,'fieldKey':_0xd8e4ec,'phMode':_0x3572a8(0x1db),'placeholder':'搜索'+_0x4c5134,'type':_0x3572a8(0x1dd)});}for(const _0x40aa49 of _0x16bd9c){const _0xf1dffa=parseRef(_0x40aa49);if(!_0xf1dffa||_0xf1dffa['none']||_0x59ebe9[_0x3572a8(0x203)](_0xf1dffa['param']))continue;const _0xcbdb84=_0x111428(_0xf1dffa[_0x3572a8(0x1c3)],_0xf1dffa[_0x3572a8(0x1d0)]),_0x5e29d3=displayName(_0xf1dffa,_0xcbdb84),_0x839d0=fieldKeyOf(_0xf1dffa,_0xcbdb84);_0x160d47({'prop':_0xf1dffa[_0x3572a8(0x1d5)],'label':_0x311137[_0x3572a8(0x1d9)]?'':_0x5e29d3,'nameFallback':_0x5e29d3,'fieldKey':_0x839d0,'phMode':_0x3572a8(0x1db),'placeholder':'搜索'+_0x5e29d3,'type':_0x3572a8(0x1dd)});}for(const _0x5bcbae of _0x3c8650){const _0x56a869=parseRef(_0x5bcbae);if(!_0x56a869||_0x56a869[_0x3572a8(0x1ca)]||_0x59ebe9[_0x3572a8(0x203)](_0x56a869[_0x3572a8(0x1d5)]))continue;const _0x5034e5=_0x111428(_0x56a869[_0x3572a8(0x1c3)],_0x56a869[_0x3572a8(0x1d0)]),_0x3d0b8f=_0x56a869[_0x3572a8(0x1de)]||(typeof _0x5034e5?.[_0x3572a8(0x1de)]===_0x3572a8(0x1cf)?_0x5034e5[_0x3572a8(0x1de)]:Array[_0x3572a8(0x1f3)](_0x5034e5?.['dict'])?_0x5034e5['dict'][0x0]:undefined),_0x452c19=displayName(_0x56a869,_0x5034e5),_0x1beb8c=fieldKeyOf(_0x56a869,_0x5034e5),_0x458fe2=_0x311137['hideLabel']?'':_0x452c19;_0x3d0b8f?_0x160d47({'prop':_0x56a869[_0x3572a8(0x1d5)],'label':_0x458fe2,'nameFallback':_0x452c19,'fieldKey':_0x1beb8c,'phMode':_0x3572a8(0x1ea),'placeholder':'选择'+_0x452c19,'type':_0x3572a8(0x1ea),'dict':_0x3d0b8f,'multiple':_0x56a869[_0x3572a8(0x1ec)]}):_0x160d47({'prop':_0x56a869[_0x3572a8(0x1d5)],'label':_0x458fe2,'nameFallback':_0x452c19,'fieldKey':_0x1beb8c,'phMode':_0x3572a8(0x1db),'placeholder':'搜索'+_0x452c19,'type':'input'});}for(const _0x376266 of _0x17753e){if(!_0x376266?.['column']||_0x376266[_0x3572a8(0x1ca)])continue;if(_0x59ebe9[_0x3572a8(0x203)](_0x376266['min'])||_0x59ebe9[_0x3572a8(0x203)](_0x376266[_0x3572a8(0x1f9)]))continue;const _0x3c15c4=toSource(_0x376266[_0x3572a8(0x1d0)]),_0x5696a5=stripAlias(_0x376266[_0x3572a8(0x1d0)]),_0x2853f2=_0x111428(_0x3c15c4,_0x5696a5),_0x351846=_0x376266[_0x3572a8(0x206)]||_0x2853f2?.[_0x3572a8(0x1fe)]||_0x5696a5,_0x5ceadc=fieldKeyOf({'column':_0x5696a5},_0x2853f2),_0x4508c1=_0x311137[_0x3572a8(0x1d9)]?'':_0x351846,_0x26ed26=_0x376266[_0x3572a8(0x1cd)]===_0x3572a8(0x1e2)||_0x376266[_0x3572a8(0x1cd)]===_0x3572a8(0x1c5),_0x1e73f7=_0x26ed26?'最小值':'开始',_0x16e1eb=_0x26ed26?_0x3572a8(0x1d1):'结束';_0x160d47({'prop':_0x3572a8(0x1be)+_0x376266[_0x3572a8(0x1e8)]+'_'+_0x376266[_0x3572a8(0x1f9)],'label':_0x4508c1,'nameFallback':_0x351846,'fieldKey':_0x5ceadc,'phMode':'range','placeholder':_0x351846||'区间','type':_0x26ed26?_0x3572a8(0x1df):'daterange','range':{'min':_0x376266[_0x3572a8(0x1e8)],'max':_0x376266[_0x3572a8(0x1f9)],'rangeType':_0x376266[_0x3572a8(0x1cd)]},'component':{'name':_0x26ed26?_0x3572a8(0x1da):_0x3572a8(0x1c9),'props':_0x26ed26?{'mode':_0x376266['type'],'startPlaceholder':''+_0x351846+_0x1e73f7,'endPlaceholder':''+_0x351846+_0x16e1eb}:{'precision':_0x376266[_0x3572a8(0x1cd)],'startPlaceholder':''+_0x351846+_0x1e73f7,'endPlaceholder':''+_0x351846+_0x16e1eb}}});}if(_0x5deb66['length']){const _0x2e5000=[],_0x32d38c=_0x5deb66[_0x3572a8(0x1f1)](_0x8cc354=>{const _0xc238b9=_0x3572a8,_0xbfeff2=parseRef(_0x8cc354);if(!_0xbfeff2)return typeof _0x8cc354==='string'?stripAlias(_0x8cc354):'';const _0x4609bf=_0x111428(_0xbfeff2[_0xc238b9(0x1c3)],_0xbfeff2['column']),_0x5e7576=fieldKeyOf(_0xbfeff2,_0x4609bf);if(_0x5e7576)_0x2e5000[_0xc238b9(0x1f7)](_0x5e7576);return displayName(_0xbfeff2,_0x4609bf);})[_0x3572a8(0x1ce)](Boolean);_0x160d47({'prop':_0x3572a8(0x1fa),'label':_0x311137[_0x3572a8(0x1d9)]?'':_0x3572a8(0x1cc),'nameFallback':_0x32d38c[_0x3572a8(0x1d6)]('、')||'关键字','phMode':_0x3572a8(0x1fb),'keywordParts':_0x2e5000,'placeholder':'搜索'+(_0x32d38c[_0x3572a8(0x1d6)]('、')||_0x3572a8(0x1cc)),'type':_0x3572a8(0x1dd)});}return _0x44f24f;}
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 _0x414c3a=_0x1547;(function(_0x517a1a,_0x21fadf){const _0x58b297=_0x1547,_0x3b9b23=_0x517a1a();while(!![]){try{const _0x4dba98=-parseInt(_0x58b297(0x11b))/0x1+parseInt(_0x58b297(0x117))/0x2+-parseInt(_0x58b297(0x10a))/0x3*(parseInt(_0x58b297(0x111))/0x4)+-parseInt(_0x58b297(0x10b))/0x5*(-parseInt(_0x58b297(0x10c))/0x6)+parseInt(_0x58b297(0x119))/0x7+-parseInt(_0x58b297(0x10d))/0x8+-parseInt(_0x58b297(0x108))/0x9*(-parseInt(_0x58b297(0x110))/0xa);if(_0x4dba98===_0x21fadf)break;else _0x3b9b23['push'](_0x3b9b23['shift']());}catch(_0x2382f6){_0x3b9b23['push'](_0x3b9b23['shift']());}}}(_0xb6ee,0xb72e8));import{onMounted,onUnmounted,ref}from'vue';import{getCrudStyle}from'./style';export const FORM_COLS_DESKTOP=0x18;function _0x1547(_0x230244,_0x53824f){_0x230244=_0x230244-0x108;const _0xb6ee66=_0xb6ee();let _0x1547be=_0xb6ee66[_0x230244];if(_0x1547['irZpJT']===undefined){var _0x4b03a8=function(_0x2a0883){const _0xf46f19='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x2b62f6='',_0x532523='';for(let _0x42f1c2=0x0,_0x43de72,_0x51f942,_0x577d0a=0x0;_0x51f942=_0x2a0883['charAt'](_0x577d0a++);~_0x51f942&&(_0x43de72=_0x42f1c2%0x4?_0x43de72*0x40+_0x51f942:_0x51f942,_0x42f1c2++%0x4)?_0x2b62f6+=String['fromCharCode'](0xff&_0x43de72>>(-0x2*_0x42f1c2&0x6)):0x0){_0x51f942=_0xf46f19['indexOf'](_0x51f942);}for(let _0x45b560=0x0,_0x44e984=_0x2b62f6['length'];_0x45b560<_0x44e984;_0x45b560++){_0x532523+='%'+('00'+_0x2b62f6['charCodeAt'](_0x45b560)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x532523);};_0x1547['YGPmXA']=_0x4b03a8,_0x1547['ZoobKJ']={},_0x1547['irZpJT']=!![];}const _0xf760d6=_0xb6ee66[0x0],_0x41dda4=_0x230244+_0xf760d6,_0x40ce4c=_0x1547['ZoobKJ'][_0x41dda4];return!_0x40ce4c?(_0x1547be=_0x1547['YGPmXA'](_0x1547be),_0x1547['ZoobKJ'][_0x41dda4]=_0x1547be):_0x1547be=_0x40ce4c,_0x1547be;}export const FORM_COLS_MOBILE=0xc;export const FORM_SPAN_FULL=0x18;export const FORM_MQ_MOBILE=_0x414c3a(0x10f);function _0xb6ee(){const _0x4f8557=['nZiYnZi3mKXhqvLjyG','BwLU','kg1HEc13Awr0AdOGnZy4ChGP','mJa0mfvsugv3Cq','nJHZEffZs2y','DMfSDwu','Bwf0y2HLCW','CMvTB3zLrxzLBNrmAxn0zw5LCG','ywrKrxzLBNrmAxn0zw5LCG','Dw5KzwzPBMvK','mJiWmdG5mgHtrwHZrW','zM9YBq','nZGWmJy0ofLIqwLzEa','y2HHBMDL','nZq4ntq2B0Hlvu5u','CM91BMq','mtu5odrjB0nQr0q','Bwf0y2HnzwrPyq','nZGYotD4rKncEfy','nw5gD2jRza','mtyXmtiYmKf2r1DxAW'];_0xb6ee=function(){return _0x4f8557;};return _0xb6ee();}export function getFormCols(){const _0x86f52=_0x414c3a;if(typeof window!==_0x86f52(0x116)&&window['matchMedia'](FORM_MQ_MOBILE)[_0x86f52(0x113)])return FORM_COLS_MOBILE;return FORM_COLS_DESKTOP;}export function resolveFormSpan(_0x2b62f6,_0x532523=getFormCols()){const _0x562583=_0x414c3a,_0x42f1c2=_0x2b62f6??getCrudStyle()[_0x562583(0x118)]['span']??FORM_SPAN_FULL,_0x43de72=Math[_0x562583(0x10e)](FORM_SPAN_FULL,Math['max'](0x1,_0x42f1c2));if(_0x532523===FORM_COLS_DESKTOP)return _0x43de72;return Math['max'](0x1,Math[_0x562583(0x11c)](_0x43de72/FORM_COLS_DESKTOP*FORM_COLS_MOBILE));}export function useFormCols(){const _0x51f942=ref(getFormCols());let _0x577d0a=null;const _0x45b560=()=>{const _0x1fa733=_0x1547;_0x51f942[_0x1fa733(0x112)]=getFormCols();};return onMounted(()=>{const _0x58dfb0=_0x1547;_0x577d0a=window[_0x58dfb0(0x109)](FORM_MQ_MOBILE),_0x577d0a[_0x58dfb0(0x115)](_0x58dfb0(0x11a),_0x45b560),_0x45b560();}),onUnmounted(()=>{const _0x8de39e=_0x1547;_0x577d0a?.[_0x8de39e(0x114)]('change',_0x45b560);}),_0x51f942;}
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 _0x37f352=_0x1c6b;(function(_0x56e9d9,_0x21352c){const _0x2994cf=_0x1c6b,_0x1344bc=_0x56e9d9();while(!![]){try{const _0x991776=-parseInt(_0x2994cf(0x1a3))/0x1*(-parseInt(_0x2994cf(0x199))/0x2)+parseInt(_0x2994cf(0x18b))/0x3*(parseInt(_0x2994cf(0x195))/0x4)+-parseInt(_0x2994cf(0x193))/0x5*(-parseInt(_0x2994cf(0x181))/0x6)+parseInt(_0x2994cf(0x1a5))/0x7*(-parseInt(_0x2994cf(0x18a))/0x8)+-parseInt(_0x2994cf(0x182))/0x9+parseInt(_0x2994cf(0x186))/0xa*(-parseInt(_0x2994cf(0x184))/0xb)+-parseInt(_0x2994cf(0x1b4))/0xc*(-parseInt(_0x2994cf(0x1b1))/0xd);if(_0x991776===_0x21352c)break;else _0x1344bc['push'](_0x1344bc['shift']());}catch(_0xda64cc){_0x1344bc['push'](_0x1344bc['shift']());}}}(_0x27b0,0x9ede1));import{ref}from'vue';import{CRUD_LABELS,DEFAULT_CRUD_DICT}from'./dict';export const DEFAULT_CRUD_STYLE={'form':{'labelPosition':_0x37f352(0x1a9),'labelWidth':'100px','span':0x18,'plugins':[]},'table':{'border':![],'highlightCurrentRow':!![],'autoHeight':!![],'contextMenu':['refresh',_0x37f352(0x1b2),'edit',_0x37f352(0x19f),'order-asc',_0x37f352(0x1a6)],'column':{'align':_0x37f352(0x1b5),'opWidth':0xb4},'plugins':[]},'search':{'plugins':[]},'colors':[_0x37f352(0x19e),_0x37f352(0x17f),_0x37f352(0x19c),_0x37f352(0x198),_0x37f352(0x18f),_0x37f352(0x197),'#aa7a24',_0x37f352(0x19b)]};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(_0x496734){translateFn=_0x496734,crudLocaleRev['value']++;}function _0x1c6b(_0x1df118,_0x4a828c){_0x1df118=_0x1df118-0x179;const _0x27b076=_0x27b0();let _0x1c6be7=_0x27b076[_0x1df118];if(_0x1c6b['krcJpa']===undefined){var _0x1c30f2=function(_0x48cf3b){const _0x529758='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x496734='',_0x1b8c19='';for(let _0x31182e=0x0,_0x33a40d,_0x5995f2,_0x317985=0x0;_0x5995f2=_0x48cf3b['charAt'](_0x317985++);~_0x5995f2&&(_0x33a40d=_0x31182e%0x4?_0x33a40d*0x40+_0x5995f2:_0x5995f2,_0x31182e++%0x4)?_0x496734+=String['fromCharCode'](0xff&_0x33a40d>>(-0x2*_0x31182e&0x6)):0x0){_0x5995f2=_0x529758['indexOf'](_0x5995f2);}for(let _0x4725c1=0x0,_0xe91185=_0x496734['length'];_0x4725c1<_0xe91185;_0x4725c1++){_0x1b8c19+='%'+('00'+_0x496734['charCodeAt'](_0x4725c1)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x1b8c19);};_0x1c6b['NubDkk']=_0x1c30f2,_0x1c6b['Vegsqt']={},_0x1c6b['krcJpa']=!![];}const _0x781da1=_0x27b076[0x0],_0x2484b1=_0x1df118+_0x781da1,_0x2bfa24=_0x1c6b['Vegsqt'][_0x2484b1];return!_0x2bfa24?(_0x1c6be7=_0x1c6b['NubDkk'](_0x1c6be7),_0x1c6b['Vegsqt'][_0x2484b1]=_0x1c6be7):_0x1c6be7=_0x2bfa24,_0x1c6be7;}export function crudT(_0x1b8c19,_0x31182e){if(translateFn){const _0x33a40d=translateFn(_0x1b8c19,_0x31182e);if(_0x33a40d!=null&&_0x33a40d!==''&&_0x33a40d!==_0x1b8c19)return _0x33a40d;}return _0x31182e??_0x1b8c19;}export function crudLabel(_0x5995f2,_0x317985){const _0x404d7f=_0x37f352;crudLocaleRev[_0x404d7f(0x18c)];const _0x4725c1=_0x317985?.[_0x5995f2]??globalConfig[_0x404d7f(0x1aa)][_0x404d7f(0x191)][_0x5995f2]??CRUD_LABELS[_0x5995f2]??_0x5995f2;return crudT(_0x404d7f(0x1ad)+_0x5995f2,_0x4725c1);}export function crudFormat(_0xe91185,..._0xfdf93e){const _0x3653e0=_0x37f352;let _0x2e3940=String(_0xe91185??'');for(let _0x49895b=0x0;_0x49895b<_0xfdf93e[_0x3653e0(0x187)];_0x49895b++){_0x2e3940=_0x2e3940['replace'](new RegExp('\x5c{'+_0x49895b+'\x5c}','g'),String(_0xfdf93e[_0x49895b]));}return _0x2e3940;}export function resolveSearchPlaceholder(_0x2141ea){const _0x4fba6f=_0x37f352;crudLocaleRev[_0x4fba6f(0x18c)];const _0x75a905=(_0x281a01,_0x4a6e61)=>_0x281a01?crudT(_0x4fba6f(0x192)+_0x281a01,_0x4a6e61||_0x281a01):_0x4a6e61||'';if(_0x2141ea['phMode']===_0x4fba6f(0x1b3)){const _0x49961c=(_0x2141ea['keywordParts']||[])[_0x4fba6f(0x189)](_0x5006e6=>_0x75a905(_0x5006e6,_0x5006e6[_0x4fba6f(0x1a8)]('.')[_0x4fba6f(0x1ae)]()))[_0x4fba6f(0x190)](Boolean),_0x4b006d=_0x49961c[_0x4fba6f(0x19a)]('、')||_0x2141ea['nameFallback']||crudLabel(_0x4fba6f(0x1b3));return crudFormat(crudLabel('searchNamed'),_0x4b006d);}const _0x3fe978=_0x75a905(_0x2141ea[_0x4fba6f(0x188)],_0x2141ea[_0x4fba6f(0x17e)]||_0x2141ea[_0x4fba6f(0x191)])||_0x2141ea[_0x4fba6f(0x17e)]||_0x2141ea[_0x4fba6f(0x191)]||'';if(_0x2141ea['phMode']===_0x4fba6f(0x18e))return crudFormat(crudLabel(_0x4fba6f(0x1a4)),_0x3fe978);if(_0x2141ea[_0x4fba6f(0x183)]===_0x4fba6f(0x1b0))return _0x3fe978||crudLabel(_0x4fba6f(0x1b0));if(_0x2141ea[_0x4fba6f(0x183)]===_0x4fba6f(0x1b6)||_0x2141ea[_0x4fba6f(0x188)])return crudFormat(crudLabel(_0x4fba6f(0x17c)),_0x3fe978);return _0x2141ea['placeholder']||_0x2141ea['label']||'';}export function resolveRangePlaceholders(_0x3ff244){const _0x33a7c6=_0x37f352;crudLocaleRev[_0x33a7c6(0x18c)];const _0x2447d5=(_0x3ff244['fieldKey']?crudT(_0x33a7c6(0x192)+_0x3ff244['fieldKey'],_0x3ff244[_0x33a7c6(0x17e)]||_0x3ff244[_0x33a7c6(0x191)]||''):_0x3ff244[_0x33a7c6(0x17e)]||_0x3ff244[_0x33a7c6(0x191)]||'')||'',_0x41e910=_0x3ff244[_0x33a7c6(0x1af)]===_0x33a7c6(0x1a1)||_0x3ff244[_0x33a7c6(0x1b0)]?.[_0x33a7c6(0x185)]===_0x33a7c6(0x17d)||_0x3ff244['range']?.[_0x33a7c6(0x185)]===_0x33a7c6(0x17b),_0x4603c3=_0x41e910?crudLabel(_0x33a7c6(0x17a)):crudLabel(_0x33a7c6(0x18d)),_0x4ce6ed=_0x41e910?crudLabel(_0x33a7c6(0x180)):crudLabel(_0x33a7c6(0x1ac));return{'startPlaceholder':''+_0x2447d5+_0x4603c3,'endPlaceholder':''+_0x2447d5+_0x4ce6ed};}export function setCrudConfig(_0x585a22){const _0x45628b=_0x37f352;if(!_0x585a22)return globalConfig;return globalConfig={'dict':{...globalConfig[_0x45628b(0x1aa)],..._0x585a22['dict'],'api':{...globalConfig[_0x45628b(0x1aa)][_0x45628b(0x19d)],..._0x585a22[_0x45628b(0x1aa)]?.['api']},'pagination':{...globalConfig['dict'][_0x45628b(0x179)],..._0x585a22[_0x45628b(0x1aa)]?.['pagination']},'search':{...globalConfig[_0x45628b(0x1aa)][_0x45628b(0x1b6)],..._0x585a22[_0x45628b(0x1aa)]?.[_0x45628b(0x1b6)]},'sort':{...globalConfig[_0x45628b(0x1aa)]['sort'],..._0x585a22[_0x45628b(0x1aa)]?.[_0x45628b(0x1a7)]},'label':{...globalConfig['dict'][_0x45628b(0x191)],..._0x585a22['dict']?.['label']}},'style':{...globalConfig[_0x45628b(0x1a2)],..._0x585a22['style'],'form':{...globalConfig['style'][_0x45628b(0x196)],..._0x585a22[_0x45628b(0x1a2)]?.[_0x45628b(0x196)]},'table':{...globalConfig[_0x45628b(0x1a2)][_0x45628b(0x1a0)],..._0x585a22[_0x45628b(0x1a2)]?.[_0x45628b(0x1a0)],'column':{...globalConfig['style'][_0x45628b(0x1a0)][_0x45628b(0x194)],..._0x585a22['style']?.['table']?.[_0x45628b(0x194)]}},'search':{...globalConfig[_0x45628b(0x1a2)]['search'],..._0x585a22[_0x45628b(0x1a2)]?.[_0x45628b(0x1b6)]},'colors':_0x585a22['style']?.[_0x45628b(0x1ab)]||globalConfig[_0x45628b(0x1a2)][_0x45628b(0x1ab)]}},globalConfig;}function _0x27b0(){const _0x504992=['zMLLBgrlzxK','BwfW','ntuWndHXrMTWzLu','m21nsvrOEa','DMfSDwu','C3rHCNq','C2vSzwn0','iZzKmtDJmW','zMLSDgvY','BgfIzwW','zMLLBgqU','mtKXodiWDw5lDur3','y29SDw1U','mJiXotq0ngnLwKTqvW','zM9YBq','iZa0yZi3mW','i2q1nZeYmq','mJa5mtHws1f4sue','AM9PBG','iZfJmta5za','i2u5m2y0za','yxbP','iZrfnurgrG','zgvSzxrL','DgfIBgu','BNvTyMvYlxjHBMDL','C3r5Bgu','n1L6ruDisq','C2vSzwn0tMfTzwq','mti5nxrzDxPjEa','B3jKzxiTzgvZyW','C29YDa','C3bSAxq','Dg9W','zgLJDa','y29SB3jZ','zw5K','y3j1zc4','Cg9W','DhLWzq','CMfUz2u','mJzcv1b2rM0','y2HLy2S','A2v5D29Yza','nJe2nZC0oejlELjmDW','BgvMDa','C2vHCMnO','CgfNAw5HDgLVBG','BwLU','zMXVyxq','C2vHCMnOtMfTzwq','Aw50','BMfTzuzHBgXIywnR','iZa2yJmXyW','Bwf4','mte0zevUDwrK','mta0nta3mu14v3Hlzq','CgHnB2rL','mZC5nJm1m25xrez6rW','CMfUz2vuExbL','mtbVEhrUCLO','BgvUz3rO'];_0x27b0=function(){return _0x504992;};return _0x27b0();}export function getCrudConfig(){return globalConfig;}export function getCrudStyle(){const _0x3b8905=_0x37f352;return globalConfig[_0x3b8905(0x1a2)];}
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(_0x40eae9,_0x3ed8d9){const _0x19e4e6=_0x27fe,_0x39ab2b=_0x40eae9();while(!![]){try{const _0x2898f2=parseInt(_0x19e4e6(0xab))/0x1*(parseInt(_0x19e4e6(0xbc))/0x2)+-parseInt(_0x19e4e6(0xae))/0x3+parseInt(_0x19e4e6(0xa4))/0x4+-parseInt(_0x19e4e6(0xa6))/0x5*(-parseInt(_0x19e4e6(0xaa))/0x6)+parseInt(_0x19e4e6(0xbf))/0x7+-parseInt(_0x19e4e6(0xb1))/0x8+-parseInt(_0x19e4e6(0xad))/0x9;if(_0x2898f2===_0x3ed8d9)break;else _0x39ab2b['push'](_0x39ab2b['shift']());}catch(_0x3badfb){_0x39ab2b['push'](_0x39ab2b['shift']());}}}(_0x1e43,0xa6268));function _0x27fe(_0x3a12ba,_0xfb171c){_0x3a12ba=_0x3a12ba-0xa3;const _0x1e4357=_0x1e43();let _0x27fe2d=_0x1e4357[_0x3a12ba];if(_0x27fe['Muzmin']===undefined){var _0x160837=function(_0x5f04c5){const _0x22acfe='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x36d01c='',_0x4e6d90='';for(let _0x112b96=0x0,_0x543513,_0x2dadca,_0x148a28=0x0;_0x2dadca=_0x5f04c5['charAt'](_0x148a28++);~_0x2dadca&&(_0x543513=_0x112b96%0x4?_0x543513*0x40+_0x2dadca:_0x2dadca,_0x112b96++%0x4)?_0x36d01c+=String['fromCharCode'](0xff&_0x543513>>(-0x2*_0x112b96&0x6)):0x0){_0x2dadca=_0x22acfe['indexOf'](_0x2dadca);}for(let _0x3fbd34=0x0,_0x39b6ad=_0x36d01c['length'];_0x3fbd34<_0x39b6ad;_0x3fbd34++){_0x4e6d90+='%'+('00'+_0x36d01c['charCodeAt'](_0x3fbd34)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x4e6d90);};_0x27fe['ATTabN']=_0x160837,_0x27fe['aChKKb']={},_0x27fe['Muzmin']=!![];}const _0x6a4a60=_0x1e4357[0x0],_0x199da4=_0x3a12ba+_0x6a4a60,_0x36d1cf=_0x27fe['aChKKb'][_0x199da4];return!_0x36d1cf?(_0x27fe2d=_0x27fe['ATTabN'](_0x27fe2d),_0x27fe['aChKKb'][_0x199da4]=_0x27fe2d):_0x27fe2d=_0x36d1cf,_0x27fe2d;}function isEmpty(_0x36d01c){const _0x400d23=_0x27fe;if(_0x36d01c==null||_0x36d01c==='')return!![];if(typeof _0x36d01c===_0x400d23(0xa5)&&_0x36d01c['trim']()==='')return!![];if(Array['isArray'](_0x36d01c)&&_0x36d01c[_0x400d23(0xbd)]===0x0)return!![];return![];}function _0x1e43(){const _0xbaa641=['5Qc85BYp5lIn5Q2J56gU','mtuXmZi1otf1Bxnvwu0','mJC3nJy5nvzIzvvRvq','6iEZ5Bcria','5lIn6io95lI656M6','mZG2nJm0ng1JyNPQra','zNvUy3rPB24','Cgf0DgvYBG','AxnbCNjHEq','ios4QUwTL+ESPG','Bwf4','BgfIzwW','BwLU','ChvZAa','B2jQzwn0','DgvZDa','mtrAuu1ADhG','BgvUz3rO','CNvSzxm','nZm1mJyWne1quwHgCG','ChjVCa','BwvZC2fNzq','ndmWmdaYoeHWCgrgzG','C3rYAw5N','otaZmdv1tvrVsuS','BwfW','DMfSAwrHDg9Y','CMvXDwLYzwq','mZu0t1buwLPp','odi4mZnqBMfUzNC'];_0x1e43=function(){return _0xbaa641;};return _0x1e43();}function normalizeRules(_0x4e6d90){const _0x22ed4a=_0x27fe,_0x112b96=[];_0x4e6d90['required']&&_0x112b96['push']({'required':!![],'message':_0x4e6d90['label']+_0x22ed4a(0xb0)});const _0x543513=_0x4e6d90[_0x22ed4a(0xbe)];if(!_0x543513)return _0x112b96;if(Array[_0x22ed4a(0xb4)](_0x543513))for(const _0x2dadca of _0x543513){if(_0x2dadca&&typeof _0x2dadca===_0x22ed4a(0xba))_0x112b96['push'](_0x2dadca);}else typeof _0x543513===_0x22ed4a(0xba)&&_0x112b96[_0x22ed4a(0xb9)](_0x543513);return _0x112b96;}function isItemHidden(_0x148a28,_0x3fbd34){const _0x5711c9=_0x27fe;if(typeof _0x148a28['hidden']===_0x5711c9(0xb2))return _0x148a28['hidden'](_0x3fbd34);return Boolean(_0x148a28['hidden']);}async function validateItem(_0x39b6ad,_0x4a963e){const _0x2ac2f5=_0x27fe,_0x678ddb=_0x4a963e[_0x39b6ad[_0x2ac2f5(0xc0)]];for(const _0x386c48 of normalizeRules(_0x39b6ad)){if(_0x386c48['required']&&isEmpty(_0x678ddb))return _0x386c48[_0x2ac2f5(0xa3)]||_0x39b6ad[_0x2ac2f5(0xb7)]+_0x2ac2f5(0xb0);if(isEmpty(_0x678ddb))continue;const _0x2b1e66=String(_0x678ddb);if(_0x386c48[_0x2ac2f5(0xb8)]!=null&&_0x2b1e66[_0x2ac2f5(0xbd)]<_0x386c48[_0x2ac2f5(0xb8)])return _0x386c48[_0x2ac2f5(0xa3)]||_0x39b6ad[_0x2ac2f5(0xb7)]+_0x2ac2f5(0xaf)+_0x386c48[_0x2ac2f5(0xb8)]+_0x2ac2f5(0xb5);if(_0x386c48[_0x2ac2f5(0xb6)]!=null&&_0x2b1e66[_0x2ac2f5(0xbd)]>_0x386c48[_0x2ac2f5(0xb6)])return _0x386c48[_0x2ac2f5(0xa3)]||_0x39b6ad[_0x2ac2f5(0xb7)]+'最多\x20'+_0x386c48[_0x2ac2f5(0xb6)]+'\x20个字符';if(_0x386c48[_0x2ac2f5(0xb3)]&&!_0x386c48[_0x2ac2f5(0xb3)][_0x2ac2f5(0xbb)](_0x2b1e66))return _0x386c48[_0x2ac2f5(0xa3)]||_0x39b6ad[_0x2ac2f5(0xb7)]+_0x2ac2f5(0xac);if(_0x386c48[_0x2ac2f5(0xa8)]){const _0x236616=await _0x386c48[_0x2ac2f5(0xa8)](_0x678ddb,_0x4a963e);if(_0x236616!==!![])return _0x236616||_0x39b6ad[_0x2ac2f5(0xb7)]+'校验失败';}}return null;}export async function validateFormItems(_0x40fafa,_0x292009){for(const _0x96ae5 of _0x40fafa){if(isItemHidden(_0x96ae5,_0x292009))continue;const _0x1d613b=await validateItem(_0x96ae5,_0x292009);if(_0x1d613b)return _0x1d613b;}return null;}export async function validateFormFields(_0x920505,_0x57f146){const _0x1665bf=_0x27fe,_0x194fa3={};for(const _0x2f7130 of _0x920505){if(isItemHidden(_0x2f7130,_0x57f146))continue;const _0x20fbd8=await validateItem(_0x2f7130,_0x57f146);if(_0x20fbd8)_0x194fa3[_0x2f7130[_0x1665bf(0xc0)]]=_0x20fbd8;}return _0x194fa3;}export function applySetRules(_0x1f19d5){const _0xbadf7a=_0x27fe;return _0x1f19d5[_0xbadf7a(0xa7)](_0x2a2f90=>{const _0x59929d=_0xbadf7a;if(!_0x2a2f90[_0x59929d(0xa9)]||_0x2a2f90['rules'])return _0x2a2f90;return{..._0x2a2f90,'rules':[{'required':!![],'message':_0x2a2f90[_0x59929d(0xb7)]+_0x59929d(0xb0)}]};});}
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(_0x41e8f6,_0x4e652c){const _0x3044b7=_0x3900,_0xe6dd46=_0x41e8f6();while(!![]){try{const _0x5e9056=-parseInt(_0x3044b7(0xc6))/0x1*(parseInt(_0x3044b7(0xc2))/0x2)+parseInt(_0x3044b7(0xca))/0x3+parseInt(_0x3044b7(0xc4))/0x4*(-parseInt(_0x3044b7(0xc9))/0x5)+-parseInt(_0x3044b7(0xd1))/0x6+parseInt(_0x3044b7(0xcf))/0x7*(parseInt(_0x3044b7(0xc7))/0x8)+parseInt(_0x3044b7(0xc5))/0x9*(-parseInt(_0x3044b7(0xcb))/0xa)+parseInt(_0x3044b7(0xcd))/0xb*(parseInt(_0x3044b7(0xc8))/0xc);if(_0x5e9056===_0x4e652c)break;else _0xe6dd46['push'](_0xe6dd46['shift']());}catch(_0x392168){_0xe6dd46['push'](_0xe6dd46['shift']());}}}(_0x41f5,0xedfe8));function _0x3900(_0xa0a04d,_0x17d1c0){_0xa0a04d=_0xa0a04d-0xc1;const _0x41f52b=_0x41f5();let _0x390047=_0x41f52b[_0xa0a04d];if(_0x3900['zcvQoI']===undefined){var _0x4e7d24=function(_0x2ff86e){const _0x19484b='abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789+/=';let _0x3eb49f='',_0x2207ec='';for(let _0x45d104=0x0,_0x140a26,_0x5e4eb5,_0x45f510=0x0;_0x5e4eb5=_0x2ff86e['charAt'](_0x45f510++);~_0x5e4eb5&&(_0x140a26=_0x45d104%0x4?_0x140a26*0x40+_0x5e4eb5:_0x5e4eb5,_0x45d104++%0x4)?_0x3eb49f+=String['fromCharCode'](0xff&_0x140a26>>(-0x2*_0x45d104&0x6)):0x0){_0x5e4eb5=_0x19484b['indexOf'](_0x5e4eb5);}for(let _0x589fef=0x0,_0x491312=_0x3eb49f['length'];_0x589fef<_0x491312;_0x589fef++){_0x2207ec+='%'+('00'+_0x3eb49f['charCodeAt'](_0x589fef)['toString'](0x10))['slice'](-0x2);}return decodeURIComponent(_0x2207ec);};_0x3900['BVRNQv']=_0x4e7d24,_0x3900['gaKugc']={},_0x3900['zcvQoI']=!![];}const _0x54ccc4=_0x41f52b[0x0],_0x1e7002=_0xa0a04d+_0x54ccc4,_0x559a91=_0x3900['gaKugc'][_0x1e7002];return!_0x559a91?(_0x390047=_0x3900['BVRNQv'](_0x390047),_0x3900['gaKugc'][_0x1e7002]=_0x390047):_0x390047=_0x559a91,_0x390047;}import{useUserStore}from'../stores/user';export const vPerm={'mounted'(_0x3eb49f,_0x2207ec){const _0x2fddb4=_0x3900;apply(_0x3eb49f,_0x2207ec[_0x2fddb4(0xcc)]);},'updated'(_0x45d104,_0x140a26){apply(_0x45d104,_0x140a26['value']);}};function _0x41f5(){const _0x1e485c=['oejorMrPAG','mtjwrwnkBLG','mtq3mta1nvHAB2veta','mJm2mdeWm3v4CNjyAG','ntK1mdG3mfjwB1nJzW','DMfSDwu','nduZnJKYotftENvmA2y','C3r5Bgu','nJaZmtqZmvjVyMjowa','zgLZCgXHEq','mteXota3ntzpEgHrDvC','AgfZugvYBq','mJq5ota4ruLhDLr1','BM9Uzq','ofnZD09YzG','oxfTq2riza','mtr4EvjPshe'];_0x41f5=function(){return _0x1e485c;};return _0x41f5();}function apply(_0x5e4eb5,_0x45f510){const _0x33b63d=_0x3900,_0x589fef=useUserStore(),_0x491312=_0x589fef[_0x33b63d(0xc1)](_0x45f510);_0x5e4eb5[_0x33b63d(0xce)][_0x33b63d(0xd0)]=_0x491312?'':_0x33b63d(0xc3);}
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
+ }