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.
- package/dist/admin/config/plugin-dev.js +67 -1
- package/dist/admin/crud/config.js +33 -1
- package/dist/admin/crud/confirm.js +97 -1
- package/dist/admin/crud/dict.js +67 -1
- package/dist/admin/crud/index.js +81 -1
- package/dist/admin/crud/key.js +20 -1
- package/dist/admin/crud/mitt.js +21 -1
- package/dist/admin/crud/plugins.js +278 -1
- package/dist/admin/crud/span.js +35 -1
- package/dist/admin/crud/style.js +132 -1
- package/dist/admin/crud/validate.js +92 -1
- package/dist/admin/crud/vm-upsert.vue +29 -0
- package/dist/admin/directives/perm.js +14 -1
- package/dist/admin/hooks/useUpload.js +63 -1
- package/dist/admin/lib/browser.js +24 -1
- package/dist/admin/lib/cn.js +5 -1
- package/dist/admin/lib/dialog-float.js +13 -1
- package/dist/admin/lib/export-excel.js +64 -1
- package/dist/admin/lib/import-excel.js +61 -1
- package/dist/admin/lib/json.js +42 -1
- package/dist/admin/lib/menu.js +11 -1
- package/dist/admin/lib/tree.js +1 -1
- package/dist/admin/lib/upload.js +88 -1
- package/dist/admin/lib/video-frame.js +80 -1
- package/dist/client/dict.d.ts +8 -1
- package/dist/client/dict.js +13 -2
- package/dist/index.js +28215 -1
- package/dist/server/index.js +36228 -1
- package/dist/shared/excel.js +93 -1
- package/dist/shared/index.js +20 -1
- package/dist/shared/locale-json.js +68 -1
- package/dist/shared/tree.js +39 -1
- package/package.json +1 -1
|
@@ -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
|
+
}
|
package/dist/admin/crud/span.js
CHANGED
|
@@ -1 +1,35 @@
|
|
|
1
|
-
|
|
1
|
+
import { onMounted, onUnmounted, ref } from "vue";
|
|
2
|
+
import { getCrudStyle } from "./style";
|
|
3
|
+
export const FORM_COLS_DESKTOP = 24;
|
|
4
|
+
export const FORM_COLS_MOBILE = 12;
|
|
5
|
+
export const FORM_SPAN_FULL = 24;
|
|
6
|
+
export const FORM_MQ_MOBILE = "(max-width: 768px)";
|
|
7
|
+
export function getFormCols() {
|
|
8
|
+
if (typeof window !== "undefined" && window.matchMedia(FORM_MQ_MOBILE).matches) {
|
|
9
|
+
return FORM_COLS_MOBILE;
|
|
10
|
+
}
|
|
11
|
+
return FORM_COLS_DESKTOP;
|
|
12
|
+
}
|
|
13
|
+
export function resolveFormSpan(span, cols = getFormCols()) {
|
|
14
|
+
const raw = span ?? getCrudStyle().form.span ?? FORM_SPAN_FULL;
|
|
15
|
+
const normalized = Math.min(FORM_SPAN_FULL, Math.max(1, raw));
|
|
16
|
+
if (cols === FORM_COLS_DESKTOP)
|
|
17
|
+
return normalized;
|
|
18
|
+
return Math.max(1, Math.round(normalized / FORM_COLS_DESKTOP * FORM_COLS_MOBILE));
|
|
19
|
+
}
|
|
20
|
+
export function useFormCols() {
|
|
21
|
+
const cols = ref(getFormCols());
|
|
22
|
+
let mql = null;
|
|
23
|
+
const sync = () => {
|
|
24
|
+
cols.value = getFormCols();
|
|
25
|
+
};
|
|
26
|
+
onMounted(() => {
|
|
27
|
+
mql = window.matchMedia(FORM_MQ_MOBILE);
|
|
28
|
+
mql.addEventListener("change", sync);
|
|
29
|
+
sync();
|
|
30
|
+
});
|
|
31
|
+
onUnmounted(() => {
|
|
32
|
+
mql?.removeEventListener("change", sync);
|
|
33
|
+
});
|
|
34
|
+
return cols;
|
|
35
|
+
}
|
package/dist/admin/crud/style.js
CHANGED
|
@@ -1 +1,132 @@
|
|
|
1
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
+
}
|