Commit 09cbacbc by 李伟康

Merge branch 'v1.0.0' of http://192.168.3.233:8090/ujia/uj-store into v1.0.0

2 parents a904059e b8e6dc2a
Pipeline #344 for 09cbacbc failed in 0 seconds
...@@ -22,7 +22,14 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>( ...@@ -22,7 +22,14 @@ export const PermButton = forwardRef<HTMLButtonElement, PermButtonProps>(
if (!ok && fallback === 'hide') return null; if (!ok && fallback === 'hide') return null;
const btn = <UButton ref={ref} {...rest} disabled={!ok || rest.disabled} />; const btn = (
<UButton
ref={ref}
{...rest}
disabled={!ok || rest.disabled}
style={rest.type === 'text' ? { ...rest.style, paddingInline: 0 } : rest.style}
/>
);
if (!ok && fallback === 'disabled' && unauthorizedTip) { if (!ok && fallback === 'disabled' && unauthorizedTip) {
return <UTooltip title={unauthorizedTip}>{btn}</UTooltip>; return <UTooltip title={unauthorizedTip}>{btn}</UTooltip>;
......
...@@ -126,12 +126,21 @@ export function DataTable<T extends object>({ ...@@ -126,12 +126,21 @@ export function DataTable<T extends object>({
onClick: () => void, onClick: () => void,
key: string, key: string,
isRowAction = false, isRowAction = false,
style?: CSSProperties,
) => { ) => {
const type = action.type ?? (isRowAction ? ('text' as const) : undefined);
const buttonProps = { const buttonProps = {
danger: action.danger, danger: action.danger,
disabled: action.disabled, disabled: action.disabled,
onClick, onClick,
type: action.type ?? (isRowAction ? ('link' as const) : undefined), type,
style:
isRowAction && type === 'text'
? {
color: action.danger ? 'var(--ant-color-error)' : 'var(--ant-color-primary)',
...style,
}
: style,
}; };
return action.permission ? ( return action.permission ? (
...@@ -150,12 +159,14 @@ export function DataTable<T extends object>({ ...@@ -150,12 +159,14 @@ export function DataTable<T extends object>({
key: '__actions', key: '__actions',
width: actionColumnWidth, width: actionColumnWidth,
fixed: actionColumnFixed, fixed: actionColumnFixed,
render: (_: unknown, record: T) => render: (_: unknown, record: T) => {
rowActions const visibleActions = rowActions.filter((action) => action.visible?.(record) ?? true);
.filter((action) => action.visible?.(record) ?? true) const lastPermissionActionIndex = visibleActions.reduce(
.map((action, index) => { (lastIndex, action, index) => (action.permission ? index : lastIndex),
const label = -1,
typeof action.label === 'function' ? action.label(record) : action.label; );
return visibleActions.map((action, index) => {
const label = typeof action.label === 'function' ? action.label(record) : action.label;
const danger = const danger =
typeof action.danger === 'function' ? action.danger(record) : action.danger; typeof action.danger === 'function' ? action.danger(record) : action.danger;
return renderActionButton( return renderActionButton(
...@@ -163,8 +174,12 @@ export function DataTable<T extends object>({ ...@@ -163,8 +174,12 @@ export function DataTable<T extends object>({
() => action.onClick(record), () => action.onClick(record),
`row-action-${index}`, `row-action-${index}`,
true, true,
action.permission && index < lastPermissionActionIndex
? { marginRight: 8 }
: undefined,
); );
}), });
},
} }
: undefined; : undefined;
const sourceColumns: DataTableColumnsType<T> = showIndex const sourceColumns: DataTableColumnsType<T> = showIndex
...@@ -211,6 +226,10 @@ export function DataTable<T extends object>({ ...@@ -211,6 +226,10 @@ export function DataTable<T extends object>({
columns={tableColumns} columns={tableColumns}
tableLayout={hasLineLimit ? 'fixed' : undefined} tableLayout={hasLineLimit ? 'fixed' : undefined}
rowSelection={resolvedSelection} rowSelection={resolvedSelection}
styles={{
header: { cell: { paddingLeft: 20 } },
body: { cell: { paddingLeft: 20 } },
}}
pagination={ pagination={
resolvedPagination === false resolvedPagination === false
? false ? false
......
...@@ -129,13 +129,13 @@ export default function AccountManage() { ...@@ -129,13 +129,13 @@ export default function AccountManage() {
<UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{value}</UText> <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{value}</UText>
), ),
}, },
{ title: '姓名', dataIndex: 'name', width: 110, line: 1 }, { title: '姓名', dataIndex: 'name', width: 130, line: 1 },
{ title: '手机号', dataIndex: 'mobile', width: 120 }, { title: '手机号', dataIndex: 'mobile', width: 120 },
{ title: '所属组织', dataIndex: 'orgPath', width: 230, line: 1 }, { title: '所属组织', dataIndex: 'orgPath', width: 230, line: 1 },
{ {
title: '角色', title: '角色',
dataIndex: 'roleNames', dataIndex: 'roleNames',
width: 280, width: 290,
render: (names: string[]) => render: (names: string[]) =>
names.length names.length
? names.map((name, index) => ( ? names.map((name, index) => (
...@@ -149,7 +149,7 @@ export default function AccountManage() { ...@@ -149,7 +149,7 @@ export default function AccountManage() {
)) ))
: '—', : '—',
}, },
{ title: '数据域', dataIndex: 'dataScopeLabel', width: 140 }, { title: '数据域', dataIndex: 'dataScopeLabel' },
{ {
title: '状态', title: '状态',
width: 90, width: 90,
......
...@@ -114,13 +114,13 @@ export default function RoleManage() { ...@@ -114,13 +114,13 @@ export default function RoleManage() {
{ {
title: '角色编码', title: '角色编码',
dataIndex: 'code', dataIndex: 'code',
width: 150, width: 200,
line: 1, line: 1,
render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>, render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>,
}, },
{ title: '默认数据域', dataIndex: 'scope', width: 130 }, { title: '默认数据域', dataIndex: 'scope' },
{ title: '账号数', dataIndex: 'userCount', width: 90 }, { title: '账号数', dataIndex: 'userCount', width: 90 },
{ title: '角色描述', dataIndex: 'description', width: 380, line: 1 }, { title: '角色描述', dataIndex: 'description', width: 400, line: 1 },
{ {
title: '类型', title: '类型',
dataIndex: 'type', dataIndex: 'type',
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!