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.
- 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(_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
|
+
}
|
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
|
+
}
|