import { useAccessStore } from '@vben/stores';
|
export const features = [
|
{ key: 'inbound', title: '扫码入库', hint: '生产暂存库', icon: 'scan', permission: 'mes:pro-scan-in:inbound' },
|
{ key: 'bags', title: '袋码查询', hint: '查询与绑定托盘', icon: 'bag', permission: 'mes:pro-bag-code:query' },
|
{ key: 'pallets', title: '托盘查询', hint: '查询与绑定批次', icon: 'box', permission: 'mes:pro-pallet:query' },
|
{ key: 'batches', title: '批次查询', hint: '查看生产信息', icon: 'layers', permission: 'mes:pro-batch:query' },
|
{ key: 'stock', title: '库存查询', hint: '品种、批次与库位', icon: 'warehouse', permission: 'mes:wm-material-stock:query' },
|
{ key: 'quality', title: '种子质检', hint: '袋码、托盘与批次', icon: 'scan', permission: 'mes:qc-seed-quality:submit' },
|
{ key: 'quality-records', title: '质检记录', hint: '结果与不合格原因', icon: 'records', permission: 'mes:qc-seed-quality:query' },
|
{ key: 'sales', title: '销售出库', hint: '拣货、运单与出库', icon: 'box', permission: 'mes:wm-product-sales:query' },
|
] as const;
|
export function can(permission: string) { return useAccessStore().accessCodes.includes(permission); }
|
export function availableFeatures() {
|
const store = useAccessStore();
|
return features.filter(f => can(f.permission) && store.accessMenus.some(m => m.path === '/mobile/' + f.key));
|
}
|
export function allowedMobilePath(path: string) {
|
const key = path.split('/')[2];
|
if (['home', 'work', 'mine'].includes(key || '')) return true;
|
if (key === 'records') return can('mes:pro-scan-in:query') && useAccessStore().accessMenus.some(m => m.path === '/mobile/inbound');
|
return availableFeatures().some(f => f.key === key);
|
}
|
export function extractCode(raw: string) {
|
let value = raw.trim();
|
if (!value) throw new Error('请扫描或输入码值');
|
if (/^https?:\/\//i.test(value)) {
|
const code = new URL(value).searchParams.get('code');
|
if (!code) throw new Error('该链接不包含业务码值');
|
value = code.trim();
|
}
|
if (!value || value.length > 64 || /\s/.test(value)) throw new Error('码值格式不正确');
|
return value;
|
}
|