All checks were successful
Build and Deploy Front / deploy (push) Successful in 6m33s
Co-authored-by: Cursor <cursoragent@cursor.com>
134 lines
5.4 KiB
TypeScript
134 lines
5.4 KiB
TypeScript
/** Handsontable 列表操作列:统一图标按钮 HTML(配合 data-action 点击)
|
||
* 风格基准:/order/platformStoreOrder
|
||
*/
|
||
|
||
const ICON_STYLE = 'width:17px;height:17px;display:block;pointer-events:none'
|
||
|
||
const svg = (paths: string) =>
|
||
`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round" style="${ICON_STYLE}">${paths}</svg>`
|
||
|
||
export const warehouseActionIcons = {
|
||
view: svg(
|
||
'<path d="M2 12s3.5-7 10-7 10 7 10 7-3.5 7-10 7-10-7-10-7Z"/><circle cx="12" cy="12" r="3"/>',
|
||
),
|
||
edit: svg(
|
||
'<path d="M12 20h9"/><path d="M16.5 3.5a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4Z"/>',
|
||
),
|
||
delete: svg(
|
||
'<path d="M3 6h18"/><path d="M8 6V4h8v2"/><path d="M19 6v14a1 1 0 0 1-1 1H6a1 1 0 0 1-1-1V6"/><path d="M10 11v6"/><path d="M14 11v6"/>',
|
||
),
|
||
relocate: svg(
|
||
'<path d="M7 7h11l-2.5-2.5"/><path d="M17 17H6l2.5 2.5"/><path d="M7 7v4"/><path d="M17 17v-4"/>',
|
||
),
|
||
receive: svg(
|
||
'<path d="M20 6 9 17l-5-5"/><path d="M21 12v7a1 1 0 0 1-1 1H4a1 1 0 0 1-1-1V5a1 1 0 0 1 1-1h11"/>',
|
||
),
|
||
star: svg(
|
||
'<path d="M12 2.8 14.7 9l6.8.6-5.2 4.5 1.6 6.6L12 17.8 6.1 20.7l1.6-6.6L2.5 9.6 9.3 9Z"/>',
|
||
),
|
||
pay: svg(
|
||
'<rect x="2" y="5" width="20" height="14" rx="2"/><path d="M2 10h20"/><path d="M6 15h2"/>',
|
||
),
|
||
track: svg(
|
||
'<path d="M12 21s7-4.5 7-11a7 7 0 1 0-14 0c0 6.5 7 11 7 11Z"/><circle cx="12" cy="10" r="2.5"/>',
|
||
),
|
||
advisor: svg(
|
||
'<path d="M12 3 13.4 7.2 17.6 8.6 13.4 10 12 14.2 10.6 10 6.4 8.6 10.6 7.2 12 3Z"/><path d="M19 13l.7 1.8 1.8.7-1.8.7-.7 1.8-.7-1.8-1.8-.7 1.8-.7.7-1.8Z"/><path d="M5 15l.5 1.3 1.3.5-1.3.5-.5 1.3-.5-1.3-1.3-.5 1.3-.5.5-1.3Z"/>',
|
||
),
|
||
history: svg('<circle cx="12" cy="12" r="9"/><path d="M12 7v5l3 2"/>'),
|
||
auth: svg(
|
||
'<circle cx="8" cy="15" r="4"/><path d="M12 15h8"/><path d="M18 15v-2"/><path d="M16 15v-3"/>',
|
||
),
|
||
match: svg(
|
||
'<path d="M10 13a5 5 0 0 0 7.07 0l2.12-2.12a5 5 0 0 0-7.07-7.07L11 5"/><path d="M14 11a5 5 0 0 0-7.07 0L4.81 13.12a5 5 0 0 0 7.07 7.07L13 19"/>',
|
||
),
|
||
ship: svg(
|
||
'<path d="M3 7h11v10H3z"/><path d="M14 10h4l3 3v4h-7"/><circle cx="7" cy="19" r="2"/><circle cx="17" cy="19" r="2"/>',
|
||
),
|
||
label: svg(
|
||
'<path d="M20.6 13.4 12.7 21.3a2 2 0 0 1-2.8 0L2.7 14.1a2 2 0 0 1 0-2.8L10.6 3.4a2 2 0 0 1 1.4-.6H20a1 1 0 0 1 1 1v7.9a2 2 0 0 1-.4 1.3Z"/><circle cx="16" cy="8" r="1.5"/>',
|
||
),
|
||
suspend: svg(
|
||
'<circle cx="12" cy="12" r="9"/><path d="M10 9v6"/><path d="M14 9v6"/>',
|
||
),
|
||
resume: svg(
|
||
'<circle cx="12" cy="12" r="9"/><path d="M10 9.5v5l5-2.5Z"/>',
|
||
),
|
||
/** 审批通过 */
|
||
approve: svg('<path d="M20 6 9 17l-5-5"/>'),
|
||
/** 审批拒绝 / 关闭 */
|
||
reject: svg('<path d="M18 6 6 18"/><path d="M6 6l12 12"/>'),
|
||
/** 分配角色 */
|
||
assignRoles: svg(
|
||
'<circle cx="9" cy="8" r="3.5"/><circle cx="17" cy="9" r="2.5"/><path d="M2.5 19c0-3.6 2.9-6.5 6.5-6.5s6.5 2.9 6.5 6.5"/><path d="M15.5 17.5c.6-2.4 2.6-4.1 5-4.5"/>',
|
||
),
|
||
/** 重置密码 */
|
||
resetPassword: svg(
|
||
'<rect x="5" y="11" width="14" height="10" rx="2"/><path d="M8 11V8a4 4 0 0 1 8 0v3"/><path d="M12 15v2"/>',
|
||
),
|
||
/** OMS 登录 / 外链进入 */
|
||
login: svg(
|
||
'<path d="M10 17H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v3"/><path d="M15 11h7"/><path d="M19 8l3 3-3 3"/>',
|
||
),
|
||
/** 发布 */
|
||
publish: svg(
|
||
'<path d="M12 19V5"/><path d="M5 12l7-7 7 7"/>',
|
||
),
|
||
/** 结束活动 */
|
||
end: svg(
|
||
'<circle cx="12" cy="12" r="9"/><rect x="9" y="9" width="6" height="6" rx="0.5"/>',
|
||
),
|
||
/** 重试 */
|
||
retry: svg(
|
||
'<path d="M21 12a9 9 0 1 1-2.6-6.3"/><path d="M21 4v6h-6"/>',
|
||
),
|
||
/** 取消任务 */
|
||
cancel: svg('<path d="M18 6 6 18"/><path d="M6 6l12 12"/>'),
|
||
/** 改绑 */
|
||
rebind: svg(
|
||
'<path d="M10 13a5 5 0 0 0 7.07 0l1.5-1.5a5 5 0 0 0-7.07-7.07L10 6"/><path d="M14 11a5 5 0 0 0-7.07 0L5.5 12.5a5 5 0 0 0 7.07 7.07L14 18"/><path d="M8 12h8"/>',
|
||
),
|
||
/** 已读确认 */
|
||
read: svg('<path d="M20 6 9 17l-5-5"/>'),
|
||
/** 打印面单 */
|
||
print: svg(
|
||
'<path d="M6 9V3h12v6"/><path d="M6 17H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4a2 2 0 0 1-2 2h-2"/><path d="M6 13h12v8H6z"/>',
|
||
),
|
||
/** 禁用账号 */
|
||
disable: svg(
|
||
'<circle cx="12" cy="12" r="9"/><path d="M7.5 7.5l9 9"/>',
|
||
),
|
||
/** 启用账号 */
|
||
enable: svg(
|
||
'<circle cx="12" cy="12" r="9"/><path d="M20 6 9 17l-5-5"/>',
|
||
),
|
||
} as const
|
||
|
||
export type WarehouseActionVariant = keyof typeof warehouseActionIcons
|
||
|
||
/** @deprecated 使用 WarehouseActionVariant;保留别名便于列表页统一导入 */
|
||
export type ListActionVariant = WarehouseActionVariant
|
||
|
||
export function renderWarehouseActionBtn(
|
||
action: string,
|
||
title: string,
|
||
variant: WarehouseActionVariant = action as WarehouseActionVariant,
|
||
): string {
|
||
const icon = warehouseActionIcons[variant] || warehouseActionIcons.view
|
||
const safeTitle = String(title).replace(/"/g, '"')
|
||
return `<span class="wh-action-btn wh-action-btn--${variant}" data-action="${action}" title="${safeTitle}" role="button">${icon}</span>`
|
||
}
|
||
|
||
export function wrapWarehouseActions(parts: string[], rowIndex?: number): string {
|
||
if (!parts.length) return ''
|
||
let html = `<div class="wh-action-group">${parts.join('')}</div>`
|
||
if (rowIndex != null && Number.isFinite(rowIndex)) {
|
||
html = html.replace(/data-action=/g, `data-row-index="${rowIndex}" data-action=`)
|
||
}
|
||
return html
|
||
}
|
||
|
||
/** 别名:列表页可统一从此导入 */
|
||
export const renderListActionBtn = renderWarehouseActionBtn
|
||
export const wrapListActions = wrapWarehouseActions
|