优化客服账号标签管理
This commit is contained in:
@@ -45,9 +45,10 @@ export default function AccountsPage() {
|
||||
|
||||
const canViewFull = can('account:view_full');
|
||||
const canImport = can('account:import');
|
||||
const canTag = can('account:tag') || canImport;
|
||||
const canAssign = can('account:assign');
|
||||
const canDelete = can('account:delete');
|
||||
const canSelectRows = canImport || canDelete || canAssign;
|
||||
const canSelectRows = canTag || canDelete || canAssign;
|
||||
|
||||
const loadAccounts = useCallback(async () => {
|
||||
setLoading(true);
|
||||
@@ -252,43 +253,29 @@ export default function AccountsPage() {
|
||||
{
|
||||
title: '标签',
|
||||
dataIndex: 'tag',
|
||||
width: 120,
|
||||
width: 170,
|
||||
render: (tag: string, record: AccountItem) => {
|
||||
if (!tag) {
|
||||
if (canImport) {
|
||||
return (
|
||||
<Input
|
||||
size="small"
|
||||
placeholder="输入标签"
|
||||
style={{ width: 90 }}
|
||||
onPressEnter={(e) => {
|
||||
const val = (e.target as HTMLInputElement).value.trim();
|
||||
if (val) handleSetTag(record.id, val);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
const val = e.target.value.trim();
|
||||
if (val) handleSetTag(record.id, val);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <Text type="secondary">-</Text>;
|
||||
}
|
||||
if (canImport) {
|
||||
if (canTag) {
|
||||
return (
|
||||
<Tag
|
||||
color={tagColorMap[tag]}
|
||||
closable
|
||||
onClose={(e) => {
|
||||
e.preventDefault();
|
||||
handleSetTag(record.id, '');
|
||||
<Select
|
||||
mode="tags"
|
||||
maxCount={1}
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
size="small"
|
||||
placeholder="选择或输入标签"
|
||||
style={{ width: 150 }}
|
||||
value={tag ? [tag] : []}
|
||||
onChange={(values) => {
|
||||
const value = values.at(-1)?.trim() || '';
|
||||
if (value !== tag) handleSetTag(record.id, value);
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</Tag>
|
||||
options={tags.map((value) => ({ value, label: value }))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <Tag color={tagColorMap[tag]}>{tag}</Tag>;
|
||||
return tag ? <Tag color={tagColorMap[tag]}>{tag}</Tag> : <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -346,6 +333,8 @@ export default function AccountsPage() {
|
||||
<Space>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="按标签筛选"
|
||||
style={{ width: 150 }}
|
||||
value={tagFilter || undefined}
|
||||
@@ -375,7 +364,7 @@ export default function AccountsPage() {
|
||||
{sensitiveVisible ? '隐藏凭据' : '显示凭据'}
|
||||
</Button>
|
||||
)}
|
||||
{canImport && (
|
||||
{canTag && (
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<TagOutlined />}
|
||||
|
||||
@@ -89,6 +89,7 @@ export default function HuyaAccountsPage() {
|
||||
|
||||
const canManage = can('huya:account');
|
||||
const canImport = can('huya:import') || canManage;
|
||||
const canTag = can('huya:tag') || canImport;
|
||||
const canAssign = can('huya:assign') || canManage;
|
||||
const canDelete = can('huya:delete') || canManage;
|
||||
const canViewCookie = can('huya:cookie:view') || can('huya:cookie:export') || canManage;
|
||||
@@ -426,43 +427,29 @@ export default function HuyaAccountsPage() {
|
||||
{
|
||||
title: '标签',
|
||||
dataIndex: 'tag',
|
||||
width: 110,
|
||||
width: 170,
|
||||
render: (tag: string, record) => {
|
||||
if (!tag) {
|
||||
if (canImport) {
|
||||
return (
|
||||
<Input
|
||||
size="small"
|
||||
placeholder="输入标签"
|
||||
style={{ width: 90 }}
|
||||
onPressEnter={(e) => {
|
||||
const value = (e.target as HTMLInputElement).value.trim();
|
||||
if (value) handleSetTag(record.id, value);
|
||||
}}
|
||||
onBlur={(e) => {
|
||||
const value = e.target.value.trim();
|
||||
if (value) handleSetTag(record.id, value);
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <Text type="secondary">-</Text>;
|
||||
}
|
||||
if (canImport) {
|
||||
if (canTag) {
|
||||
return (
|
||||
<Tag
|
||||
color={tagColorMap[tag]}
|
||||
closable
|
||||
onClose={(e) => {
|
||||
e.preventDefault();
|
||||
handleSetTag(record.id, '');
|
||||
<Select
|
||||
mode="tags"
|
||||
maxCount={1}
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
size="small"
|
||||
placeholder="选择或输入标签"
|
||||
style={{ width: 150 }}
|
||||
value={tag ? [tag] : []}
|
||||
onChange={(values) => {
|
||||
const value = values.at(-1)?.trim() || '';
|
||||
if (value !== tag) handleSetTag(record.id, value);
|
||||
}}
|
||||
>
|
||||
{tag}
|
||||
</Tag>
|
||||
options={tags.map((value) => ({ value, label: value }))}
|
||||
/>
|
||||
);
|
||||
}
|
||||
return <Tag color={tagColorMap[tag]}>{tag}</Tag>;
|
||||
return tag ? <Tag color={tagColorMap[tag]}>{tag}</Tag> : <Text type="secondary">-</Text>;
|
||||
},
|
||||
},
|
||||
{
|
||||
@@ -560,6 +547,8 @@ export default function HuyaAccountsPage() {
|
||||
<Space wrap>
|
||||
<Select
|
||||
allowClear
|
||||
showSearch
|
||||
optionFilterProp="label"
|
||||
placeholder="按标签筛选"
|
||||
style={{ width: 150 }}
|
||||
value={tagFilter || undefined}
|
||||
@@ -573,7 +562,7 @@ export default function HuyaAccountsPage() {
|
||||
<Button icon={<ReloadOutlined />} onClick={loadAccounts} loading={loading}>
|
||||
刷新
|
||||
</Button>
|
||||
{canImport && (
|
||||
{canTag && (
|
||||
<Button
|
||||
disabled={selectedCount === 0}
|
||||
icon={<TagOutlined />}
|
||||
@@ -699,7 +688,7 @@ export default function HuyaAccountsPage() {
|
||||
)}
|
||||
/>
|
||||
) : undefined}
|
||||
rowSelection={(canImport || canDelete || canAssign) ? {
|
||||
rowSelection={(canTag || canDelete || canAssign) ? {
|
||||
selectedRowKeys,
|
||||
onChange: (keys) => {
|
||||
setSelectedRowKeys(keys);
|
||||
|
||||
Reference in New Issue
Block a user