oa_app仓库初始化
This commit is contained in:
@@ -0,0 +1,85 @@
|
||||
/**
|
||||
* Web 路由 → 手机页。工作台 shortcuts / pendingItems 下发的是 Web path。
|
||||
*/
|
||||
export function mobileUrl(webPath, extra = {}) {
|
||||
const raw = String(webPath || '').trim()
|
||||
if (!raw) return ''
|
||||
if (raw.startsWith('/pages/')) return raw
|
||||
const qIndex = raw.indexOf('?')
|
||||
const path = qIndex >= 0 ? raw.slice(0, qIndex) : raw
|
||||
const query = qIndex >= 0 ? raw.slice(qIndex + 1) : ''
|
||||
const no = extra.no || extra.id || extra.requestNo || ''
|
||||
|
||||
if (path === '/apply') return '/pages/apply/list'
|
||||
const apply = path.match(/^\/apply\/([^/]+)$/)
|
||||
if (apply) return '/pages/apply/form?kind=' + encodeURIComponent(apply[1])
|
||||
|
||||
if (path.startsWith('/todo')) {
|
||||
if (no) return '/pages/todo/detail?no=' + encodeURIComponent(no)
|
||||
const tab = path.split('/')[2] || 'pending'
|
||||
return '/pages/todo/list?tab=' + encodeURIComponent(tab)
|
||||
}
|
||||
|
||||
if (path === '/contacts') return '/pages/tabs/contacts'
|
||||
if (path === '/profile' || path === '/me') return '/pages/me/archive'
|
||||
if (path.startsWith('/hr/notice') || path === '/notice') return '/pages/notice/list'
|
||||
if (path.startsWith('/report')) return '/pages/reports/list'
|
||||
if (path.includes('clock') || path.includes('attend')) return '/pages/tabs/clock'
|
||||
if (path.startsWith('/work')) {
|
||||
if (no) return '/pages/coop/detail?id=' + encodeURIComponent(no)
|
||||
return '/pages/coop/list'
|
||||
}
|
||||
|
||||
const erp = [
|
||||
['/project', 'project'],
|
||||
['/bidding', 'bidding'],
|
||||
['/finance', 'finance'],
|
||||
['/hr', 'hr'],
|
||||
['/contracts', 'contracts'],
|
||||
['/seals', 'seals'],
|
||||
['/crm', 'crm'],
|
||||
['/system', 'system']
|
||||
]
|
||||
for (const [prefix, id] of erp) {
|
||||
if (path === prefix || path.startsWith(prefix + '/')) return '/pages/erp/hub?id=' + id
|
||||
}
|
||||
|
||||
if (query) {
|
||||
const mapped = mobileUrl(path, extra)
|
||||
if (mapped && mapped.includes('?')) return mapped + '&' + query
|
||||
if (mapped) return mapped + '?' + query
|
||||
}
|
||||
return ''
|
||||
}
|
||||
|
||||
export function openHref(webPath, extra = {}) {
|
||||
const url = mobileUrl(webPath, extra)
|
||||
if (!url) return false
|
||||
if (url.startsWith('/pages/tabs/')) {
|
||||
uni.switchTab({ url: url.split('?')[0] })
|
||||
return true
|
||||
}
|
||||
uni.navigateTo({ url })
|
||||
return true
|
||||
}
|
||||
|
||||
const EMOJI = {
|
||||
expense: '🧾', loan: '¥', leave: '休', trip: '✈', procurement: '购',
|
||||
overtime: '加', outing: '出', card: '补', transfer: '转', regularize: '正',
|
||||
resign: '离', layoff: '裁', seal: '章', receive: '领', clock: '📍',
|
||||
todo: '☑', apply: '✎', report: '▤', salary: '💳', perf: '↗',
|
||||
archive: '👤', notice: '📢', coop: '🤝', contacts: '☎',
|
||||
bidding: '◎', project: '▣', finance: '◈', hr: '☰', contracts: '▤',
|
||||
seals: '◆', crm: '◇', system: '⚙'
|
||||
}
|
||||
|
||||
export function tileEmoji(item) {
|
||||
if (item && item.emoji) return item.emoji
|
||||
const to = String((item && (item.to || item.url || item.path)) || '')
|
||||
const m = to.match(/\/apply\/([^/?]+)/)
|
||||
if (m && EMOJI[m[1]]) return EMOJI[m[1]]
|
||||
const id = String((item && (item.id || item.kind || item.key)) || '')
|
||||
if (EMOJI[id]) return EMOJI[id]
|
||||
const label = String((item && (item.label || item.title)) || '')
|
||||
return label ? label.slice(0, 1) : '·'
|
||||
}
|
||||
Reference in New Issue
Block a user