Commit 6c991900 by liimin

refactor(merchant): 重构三类页面信息架构并抽取共享零件

- 列表:身份列固定常驻、状态前置为圆点+文字、审计列按需展开;行操作全部直显
- 详情:统一身份带与任务分区,长字段折行不省略,权限 tab 长标题不再截断
- 表单:移除 SectionTitle 双重编号与重复描述,底部唯一 primary 确定
- 新增 pages/shared 收口 FilterCard/LoadErrorAlert/DetailItem/ReadOnlyPermTabs/LogTab/FormFooter/IdentityBand/StatusMark/TaskSection
- 图标字形改为 @ant-design/icons outlined,统一从 @uj/ui 导出
- CSS 去除彩色光环/transition all/hover 缩放,硬编码红改 --uj-error

验证:tsc --noEmit、eslint --max-warnings=0、prettier --check 全绿
1 parent 3b182e50
Pipeline #772 for 6c991900 failed in 0 seconds
...@@ -60,6 +60,87 @@ body { ...@@ -60,6 +60,87 @@ body {
border-radius: 6px; border-radius: 6px;
} }
/* 状态标记:小圆点 + 文字。语义色只给正/待两档,停用等一律走 muted,
不用彩色 pill 抢表格里真正的亮色(状态本身)。 */
.uj-status-mark {
display: inline-flex;
align-items: center;
gap: 6px;
white-space: nowrap;
}
.uj-status-mark__dot {
flex: none;
width: 6px;
height: 6px;
border-radius: 50%;
background: var(--uj-text-3);
}
.uj-status-mark__dot--positive {
background: var(--uj-success);
}
.uj-status-mark__dot--pending {
background: var(--uj-warning);
}
/* 详情页身份带:页头下一行读完「是谁 / 编号 / 状态 / 等级」。 */
.uj-identity-band {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px 24px;
padding: 12px 16px;
border: 1px solid var(--uj-border);
border-radius: 8px;
background: var(--uj-surface);
}
.uj-identity-band__name {
color: var(--uj-text-1);
font-size: 16px;
font-weight: 600;
line-height: 24px;
}
.uj-identity-band__status {
padding-inline-start: 24px;
border-inline-start: 1px solid var(--uj-divider);
}
.uj-identity-band__fields {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 8px 24px;
margin: 0;
}
.uj-identity-band__field {
display: flex;
align-items: baseline;
gap: 8px;
min-width: 0;
}
.uj-identity-band__field dt {
color: var(--uj-text-3);
font-size: 12px;
}
.uj-identity-band__field dd {
margin: 0;
color: var(--uj-text-1);
font-size: 13px;
}
.uj-identity-band__field dd.is-mono {
font-family: var(--uj-font-mono, monospace);
font-variant-numeric: tabular-nums;
}
/* 任务分区标题:无编号、无副标题,只留标题与一条线。 */
.uj-task-section {
margin: 0 0 16px;
padding-bottom: 8px;
border-bottom: 1px solid var(--uj-divider);
color: var(--uj-text-1);
font-size: 14px;
font-weight: 600;
line-height: 20px;
}
/* ============================================================ /* ============================================================
创建商户二级页 创建商户二级页
设计语言:B 端克制专业感,统一 8pt 网格、12px 圆角、单层描边, 设计语言:B 端克制专业感,统一 8pt 网格、12px 圆角、单层描边,
...@@ -86,7 +167,7 @@ body { ...@@ -86,7 +167,7 @@ body {
.uj-step { .uj-step {
display: flex; display: flex;
align-items: center; align-items: center;
gap: 10px; gap: 8px;
} }
.uj-step__badge { .uj-step__badge {
display: inline-flex; display: inline-flex;
...@@ -101,7 +182,10 @@ body { ...@@ -101,7 +182,10 @@ body {
color: var(--uj-text-3); color: var(--uj-text-3);
font-size: 13px; font-size: 13px;
font-weight: 600; font-weight: 600;
transition: all 200ms ease; transition:
border-color 200ms ease,
background-color 200ms ease,
color 200ms ease;
} }
.uj-step__label { .uj-step__label {
color: var(--uj-text-3); color: var(--uj-text-3);
...@@ -116,8 +200,8 @@ body { ...@@ -116,8 +200,8 @@ body {
.uj-step.is-active .uj-step__badge { .uj-step.is-active .uj-step__badge {
border-color: var(--uj-primary); border-color: var(--uj-primary);
background: var(--uj-primary); background: var(--uj-primary);
box-shadow: 0 0 0 3px var(--uj-primary-soft); color: var(--uj-on-primary);
color: #fff; font-size: 14px;
} }
.uj-step.is-active .uj-step__label { .uj-step.is-active .uj-step__label {
color: var(--uj-text-1); color: var(--uj-text-1);
...@@ -136,7 +220,7 @@ body { ...@@ -136,7 +220,7 @@ body {
height: 1px; height: 1px;
max-width: 120px; max-width: 120px;
background: var(--uj-border); background: var(--uj-border);
transition: background 200ms ease; transition: background-color 200ms ease;
} }
.uj-steps__line.is-done { .uj-steps__line.is-done {
background: var(--uj-primary); background: var(--uj-primary);
...@@ -156,47 +240,6 @@ body { ...@@ -156,47 +240,6 @@ body {
.uj-section + .uj-section { .uj-section + .uj-section {
margin-top: 20px; margin-top: 20px;
} }
.uj-section-head {
display: flex;
align-items: flex-start;
gap: 12px;
padding-bottom: 20px;
margin-bottom: 24px;
border-bottom: 1px solid var(--uj-divider);
}
.uj-section-head__index {
display: inline-flex;
flex: none;
align-items: center;
justify-content: center;
width: 28px;
height: 28px;
border-radius: 8px;
background: var(--uj-primary-soft);
color: var(--uj-primary);
font-size: 12px;
font-weight: 700;
letter-spacing: 0.02em;
}
.uj-section-head__text {
display: flex;
flex-direction: column;
gap: 4px;
}
.uj-section-head__title {
margin: 0;
color: var(--uj-text-1);
font-size: 15px;
font-weight: 600;
line-height: 20px;
}
.uj-section-head__desc {
margin: 0;
color: var(--uj-text-3);
font-size: 12px;
line-height: 18px;
}
/* 12 列表单栅格:字段用 .uj-col-N 声明占宽,跨行项 .uj-full; /* 12 列表单栅格:字段用 .uj-col-N 声明占宽,跨行项 .uj-full;
容器变窄时短字段自动并列降级,不再固定一行两列。 */ 容器变窄时短字段自动并列降级,不再固定一行两列。 */
.uj-form-grid { .uj-form-grid {
...@@ -204,7 +247,7 @@ body { ...@@ -204,7 +247,7 @@ body {
grid-template-columns: repeat(12, minmax(0, 1fr)); grid-template-columns: repeat(12, minmax(0, 1fr));
container-type: inline-size; container-type: inline-size;
column-gap: 20px; column-gap: 20px;
row-gap: 14px; row-gap: 16px;
} }
/* 默认列(未标级别的字段)占半行;:where 把特异性压到单类,列级类才能按写序覆盖它。 */ /* 默认列(未标级别的字段)占半行;:where 把特异性压到单类,列级类才能按写序覆盖它。 */
.uj-form-grid > :where(.ant-form-item) { .uj-form-grid > :where(.ant-form-item) {
...@@ -386,8 +429,8 @@ body { ...@@ -386,8 +429,8 @@ body {
object-fit: cover; object-fit: cover;
} }
.uj-images__plus { .uj-images__plus {
font-size: 24px; display: inline-flex;
font-weight: 300; font-size: 20px;
line-height: 1; line-height: 1;
} }
.uj-images__remove { .uj-images__remove {
...@@ -405,18 +448,16 @@ body { ...@@ -405,18 +448,16 @@ body {
background: var(--uj-surface); background: var(--uj-surface);
color: var(--uj-text-2); color: var(--uj-text-2);
cursor: pointer; cursor: pointer;
font-size: 14px; font-size: 12px;
line-height: 1; line-height: 1;
box-shadow: 0 2px 6px rgba(29, 37, 51, 0.12); box-shadow: 0 2px 6px rgba(29, 37, 51, 0.12);
transition: transition:
color 150ms ease, color 150ms ease,
border-color 150ms ease, border-color 150ms ease;
transform 150ms ease;
} }
.uj-images__remove:hover { .uj-images__remove:hover {
border-color: var(--uj-error); border-color: var(--uj-error);
color: var(--uj-error); color: var(--uj-error);
transform: scale(1.1);
} }
.uj-images__remove:focus-visible { .uj-images__remove:focus-visible {
outline: 2px solid var(--uj-primary); outline: 2px solid var(--uj-primary);
...@@ -561,14 +602,17 @@ body { ...@@ -561,14 +602,17 @@ body {
margin: 12px; margin: 12px;
} }
/* 商户详情:页面顶部页签与功能权限里的两级页签,每项固定同一宽度。 /* 商户详情:页面顶部页签与功能权限里的两级页签。
账户类型 / 产品名称长短不一,按内容宽会让药丸滑块宽度随数据跳动。 */ 原先固定 width:128px + nowrap + ellipsis,账户类型/产品名一长就被截断,
且 .ant-tabs-nav-list 是 fit-content,右侧项被 nav 裁掉。改为定下限 + 上限后
允许折行:标题完整可见,列不会随数据横向撑破容器。 */
.uj-page__tabs.uj-tabs-uniform.ant-tabs .uj-page__tabs.uj-tabs-uniform.ant-tabs
> .ant-tabs-nav > .ant-tabs-nav
> .ant-tabs-nav-wrap > .ant-tabs-nav-wrap
.ant-tabs-nav-list .ant-tabs-nav-list
> .ant-tabs-tab { > .ant-tabs-tab {
width: 128px; min-width: 128px;
max-width: 200px;
text-align: center; text-align: center;
} }
.uj-page__tabs.uj-tabs-uniform.ant-tabs .uj-page__tabs.uj-tabs-uniform.ant-tabs
...@@ -582,9 +626,10 @@ body { ...@@ -582,9 +626,10 @@ body {
justify-content: center; justify-content: center;
width: 100%; width: 100%;
min-width: 0; min-width: 0;
overflow: hidden; white-space: normal;
text-overflow: ellipsis; overflow-wrap: anywhere;
white-space: nowrap; line-height: 20px;
text-align: center;
} }
/* 权限区:账户类型页签 → 选择产品 → 功能菜单页签 → 树。 /* 权限区:账户类型页签 → 选择产品 → 功能菜单页签 → 树。
...@@ -704,34 +749,34 @@ body { ...@@ -704,34 +749,34 @@ body {
} }
/* 有效期 / 接入模式弹窗 */ /* 有效期 / 接入模式弹窗 */
.uj-period-modal { .uj-modal-form {
display: flex; display: flex;
flex-direction: column; flex-direction: column;
gap: 12px; gap: 12px;
padding: 4px 0 8px; padding: 4px 0 8px;
} }
.uj-period-modal__row { .uj-modal-form__row {
margin: 0; margin: 0;
color: var(--uj-text-2); color: var(--uj-text-2);
font-size: 13px; font-size: 13px;
} }
.uj-period-modal__quick { .uj-modal-form__quick {
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
gap: 8px; gap: 8px;
} }
.uj-period-modal__radios .ant-radio-wrapper { .uj-modal-form__radios .ant-radio-wrapper {
margin-inline-end: 24px; margin-inline-end: 24px;
} }
.uj-period-modal__radio-line { .uj-modal-form__radio-line {
display: flex; display: flex;
align-items: center; align-items: center;
min-height: 32px; min-height: 32px;
} }
.uj-period-modal__error { .uj-modal-form__error {
margin: 0; margin: 0;
color: var(--uj-danger, #f56c6c); color: var(--uj-error);
font-size: 12px; font-size: 12px;
} }
...@@ -768,7 +813,7 @@ body { ...@@ -768,7 +813,7 @@ body {
} }
/* 源把失败模板链接标红(index.html:849 updateTemplateLink isError)。 */ /* 源把失败模板链接标红(index.html:849 updateTemplateLink isError)。 */
.uj-import__fail.ant-btn-link { .uj-import__fail.ant-btn-link {
color: var(--uj-danger, #f56c6c); color: var(--uj-error);
} }
.uj-import__loading { .uj-import__loading {
margin: 0; margin: 0;
...@@ -823,16 +868,17 @@ body { ...@@ -823,16 +868,17 @@ body {
min-width: 0; min-width: 0;
color: var(--uj-text-1); color: var(--uj-text-1);
font-size: 13px; font-size: 13px;
overflow: hidden; line-height: 20px;
text-overflow: ellipsis; /* 长值折行显示,不省略。grid 列宽由 1fr 固定,折行只增高、不挤占相邻字段。 */
white-space: nowrap; white-space: normal;
overflow-wrap: anywhere;
} }
.uj-detail-accounttypes { .uj-detail-accounttypes {
display: flex; display: flex;
align-items: center; align-items: center;
flex-wrap: wrap; flex-wrap: wrap;
gap: 8px; gap: 8px;
margin-top: 14px; margin-top: 16px;
} }
.uj-detail-accounttypes__label { .uj-detail-accounttypes__label {
color: var(--uj-text-3); color: var(--uj-text-3);
...@@ -843,30 +889,11 @@ body { ...@@ -843,30 +889,11 @@ body {
display: inline-block; display: inline-block;
padding: 4px 12px; padding: 4px 12px;
border-radius: 4px; border-radius: 4px;
background: var(--uj-primary-soft, rgba(88, 80, 255, 0.08)); background: var(--uj-primary-soft);
color: var(--uj-primary); color: var(--uj-primary);
font-size: 12px; font-size: 12px;
} }
/* 员工详情:分组标题行(左标题 + 右商户名)与可见下级商户清单。 */ /* 可见下级商户清单。 */
.uj-detail-title-row {
display: flex;
align-items: baseline;
justify-content: space-between;
gap: 16px;
}
.uj-detail-title-row .uj-detail-title {
flex: 1;
min-width: 0;
}
.uj-detail-merchant {
flex: none;
max-width: 40%;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: var(--uj-text-2);
font-size: 13px;
}
.uj-detail-visible { .uj-detail-visible {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
...@@ -951,21 +978,23 @@ body { ...@@ -951,21 +978,23 @@ body {
top: 2px; top: 2px;
right: 2px; right: 2px;
z-index: 1; z-index: 1;
width: 18px; display: inline-flex;
height: 18px; align-items: center;
justify-content: center;
width: 20px;
height: 20px;
border-radius: 50%; border-radius: 50%;
background: rgba(0, 0, 0, 0.55); background: rgba(0, 0, 0, 0.55);
color: #fff; color: var(--uj-on-primary);
font-size: 14px; font-size: 11px;
line-height: 18px;
text-align: center;
cursor: pointer; cursor: pointer;
} }
.uj-staff-avatar__remove:hover { .uj-staff-avatar__remove:hover {
background: rgba(0, 0, 0, 0.75); background: rgba(0, 0, 0, 0.75);
} }
.uj-staff-avatar__empty { .uj-staff-avatar__empty {
font-size: 28px; display: inline-flex;
font-size: 24px;
line-height: 1; line-height: 1;
color: var(--uj-text-3); color: var(--uj-text-3);
} }
...@@ -1003,8 +1032,8 @@ body { ...@@ -1003,8 +1032,8 @@ body {
.uj-detail-images { .uj-detail-images {
display: flex; display: flex;
flex-wrap: wrap; flex-wrap: wrap;
gap: 10px; gap: 12px;
margin-top: 14px; margin-top: 16px;
} }
.uj-detail-images__box { .uj-detail-images__box {
width: 88px; width: 88px;
...@@ -1058,7 +1087,7 @@ body { ...@@ -1058,7 +1087,7 @@ body {
white-space: nowrap; white-space: nowrap;
} }
.uj-hierarchy__meta { .uj-hierarchy__meta {
margin: 2px 0; margin: 4px 0;
font-size: 12px; font-size: 12px;
line-height: 20px; line-height: 20px;
color: var(--uj-text-3); color: var(--uj-text-3);
...@@ -1143,8 +1172,11 @@ body { ...@@ -1143,8 +1172,11 @@ body {
/* 角色管理:内置角色名后的 hover 说明图标(源 layui-icon-about + layer.tips)。 */ /* 角色管理:内置角色名后的 hover 说明图标(源 layui-icon-about + layer.tips)。 */
.uj-role-name__tip { .uj-role-name__tip {
display: inline-flex;
margin-left: 4px; margin-left: 4px;
color: var(--uj-text-3); color: var(--uj-text-3);
font-size: 13px;
vertical-align: middle;
cursor: help; cursor: help;
} }
/* 角色权限区顶层账户类型复选组(源 #accountType switch 复选行)。 */ /* 角色权限区顶层账户类型复选组(源 #accountType switch 复选行)。 */
......
import { useState } from 'react'; import { useState } from 'react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UEmpty, UTabs } from '@uj/ui'; import { UButton, UEmpty, UTabs } from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { DataTable, PageShell } from '@/components'; import { PageShell } from '@/components';
import type { PageParams } from '../../../routes'; import type { PageParams } from '../../../routes';
import { employeeApi, merchantApi } from '@/api'; import { employeeApi } from '@/api';
import { errorDetail } from '@/utils/error'; import { errorDetail } from '@/utils/error';
import { useMerchantAccess } from '@/adapter/access'; import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { asArray, nodeList, type AccountPerm } from '../../Merchant/Create/model'; import { asArray, type AccountPerm } from '../../Merchant/Create/model';
import { ReadOnlyPermTree } from '../../Merchant/Create/ui';
import { staffLabelText } from '../model'; import { staffLabelText } from '../model';
import {
DetailItem,
LoadErrorAlert,
LogTab,
ReadOnlyPermTabs,
IdentityBand,
TaskSection,
} from '../../shared';
/** /**
* 员工详情二级页(源 temp/account/html/employee/detail.html)。 * 员工详情二级页(源 temp/account/html/employee/detail.html)。
...@@ -40,21 +47,11 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } = ...@@ -40,21 +47,11 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } =
if (detailQuery.isPending) return <UEmpty description="正在读取员工详情…" />; if (detailQuery.isPending) return <UEmpty description="正在读取员工详情…" />;
if (detailQuery.isError || !detail) { if (detailQuery.isError || !detail) {
return ( return (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="员工详情加载失败" title="员工详情加载失败"
description={detailQuery.error ? errorDetail(detailQuery.error) : '员工不存在'} description={detailQuery.error ? errorDetail(detailQuery.error) : '员工不存在'}
action={ onRetry={() => void detailQuery.refetch()}
<> onBack={() => goTo('employee')}
<UButton type="link" onClick={() => void detailQuery.refetch()}>
重试
</UButton>
<UButton type="link" onClick={() => goTo('employee')}>
返回列表
</UButton>
</>
}
/> />
); );
} }
...@@ -76,13 +73,22 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } = ...@@ -76,13 +73,22 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } =
<PageShell <PageShell
fill fill
title={`员工详情 · ${text(detail.staffName)}`} title={`员工详情 · ${text(detail.staffName)}`}
description="员工基本信息、账户权限与修改记录;均为只读展示。" description="员工基本信息、账户权限与修改记录;均为只读展示"
actions={ actions={
<UButton type="primary" onClick={() => goTo('employee')}> <UButton type="primary" onClick={() => goTo('employee')}>
关闭 关闭
</UButton> </UButton>
} }
> >
<IdentityBand
name={text(detail.staffName)}
fields={[
{ label: '所属商户', value: merchantName },
{ label: '登录手机号', value: text(detail.staffPhone), mono: true },
{ label: '角色', value: text(detail.roleName) },
]}
/>
<UTabs <UTabs
className="uj-tabs-uniform" className="uj-tabs-uniform"
activeKey={tab} activeKey={tab}
...@@ -100,29 +106,31 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } = ...@@ -100,29 +106,31 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } =
{tab === 'basic' ? ( {tab === 'basic' ? (
<div className="uj-create-card"> <div className="uj-create-card">
<section className="uj-section"> <section className="uj-section">
<div className="uj-detail-title-row"> <TaskSection>身份与职务</TaskSection>
<h3 className="uj-detail-title">员工基本信息</h3> <dl className="uj-detail-grid">
<span className="uj-detail-merchant" title={merchantName}> <DetailItem empty="无" label="企微号" value={text(detail.entmicroName)} />
{merchantName} <DetailItem empty="无" label="职务" value={text(detail.staffJob)} />
</span> <DetailItem empty="无" label="员工标签" value={staffLabelText(detail.staffLabel)} />
</div> </dl>
</section>
<section className="uj-section">
<TaskSection>归属与可见范围</TaskSection>
<dl className="uj-detail-grid">
<DetailItem empty="无" label="所属部门" value={text(detail.departmentName)} />
<DetailItem empty="无" label="创建人" value={text(detail.createdAccount)} />
</dl>
</section>
<section className="uj-section">
<TaskSection>企业微信绑定</TaskSection>
<dl className="uj-detail-grid"> <dl className="uj-detail-grid">
<DetailItem label="姓名" value={text(detail.staffName)} /> <DetailItem empty="无" label="微信昵称" value={text(detail.weChatNickName)} />
<DetailItem label="登录手机号" value={text(detail.staffPhone)} /> <DetailItem empty="无" label="微信手机号" value={text(detail.weChatPhone)} />
<DetailItem label="企微号" value={text(detail.entmicroName)} /> <DetailItem empty="无" label="微信openid" value={text(detail.weChatOpenId)} />
<DetailItem label="职务" value={text(detail.staffJob)} />
<DetailItem label="角色名称" value={text(detail.roleName)} />
<DetailItem label="创建人" value={text(detail.createdAccount)} />
<DetailItem label="所属部门" value={text(detail.departmentName)} />
<DetailItem label="员工标签" value={staffLabelText(detail.staffLabel)} />
<DetailItem label="微信昵称" value={text(detail.weChatNickName)} />
<DetailItem label="微信手机号" value={text(detail.weChatPhone)} />
<DetailItem label="微信openid" value={text(detail.weChatOpenId)} />
</dl> </dl>
</section> </section>
{visibleList.length ? ( {visibleList.length ? (
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">可见下级商户</h3> <TaskSection>可见下级商户</TaskSection>
<ul className="uj-detail-visible"> <ul className="uj-detail-visible">
{visibleList.map((name, index) => ( {visibleList.map((name, index) => (
<li key={index}> <li key={index}>
...@@ -139,95 +147,16 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } = ...@@ -139,95 +147,16 @@ export default function EmployeeDetailPage({ params }: { params?: PageParams } =
{tab === 'perm' ? ( {tab === 'perm' ? (
<div className="uj-create-card"> <div className="uj-create-card">
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">账户权限</h3> <TaskSection>账户权限</TaskSection>
{permAccounts.length ? ( <ReadOnlyPermTabs accounts={permAccounts} emptyText="暂无账户权限数据" />
<div className="uj-create-tabs">
<UTabs
className="uj-tabs-uniform"
items={permAccounts.map((account) => ({
key: String(account.accounttypeId),
label: account.accounttypeName ?? String(account.accounttypeId),
children: (account.products ?? []).length ? (
<UTabs
className="uj-tabs-uniform"
items={(account.products ?? []).map((product) => ({
key: String(product.productId),
label: product.productName ?? String(product.productId),
children: <ReadOnlyPermTree nodes={nodeList(product)} />,
}))}
/>
) : (
<div className="uj-create-hint">暂无产品</div>
),
}))}
/>
</div>
) : (
<div className="uj-create-hint">暂无账户权限数据</div>
)}
</section> </section>
</div> </div>
) : null} ) : null}
{tab === 'log' ? <LogTab staffId={staffId} /> : null} {tab === 'log' ? (
<LogTab queryKey="staffLog" bussinessId={staffId} moduleName="员工模块" />
) : null}
</div> </div>
</PageShell> </PageShell>
); );
} }
function DetailItem({ label, value }: { label: string; value: string }) {
return (
<div className="uj-detail-item">
<dt>{label}</dt>
<dd title={value === '无' ? undefined : value}>{value}</dd>
</div>
);
}
function LogTab({ staffId }: { staffId: string }) {
const [page, setPage] = useState({ current: 1, size: 10 });
const logQuery = useQuery({
queryKey: ['merchant', 'staffLog', staffId, page],
queryFn: () =>
merchantApi.findLog({
bussinessId: staffId,
moduleName: '员工模块',
pageNum: page.current,
pageSize: page.size,
}),
enabled: Boolean(staffId),
});
const wrapped = (logQuery.data ?? {}) as Record<string, unknown>;
const rows = asArray<Record<string, unknown>>(wrapped.list ?? wrapped.data ?? logQuery.data);
const total = Number(wrapped.total ?? wrapped.count ?? rows.length);
return (
<UCard size="small" fill>
<DataTable<Record<string, unknown>>
fillHeight
rowKey={(row) => String(row.id ?? Math.random())}
loading={logQuery.isFetching}
dataSource={rows.map((row, index) => ({
...row,
index: (page.current - 1) * page.size + index + 1,
modifyContent: `${String(row.module ?? '')}-${String(row.action ?? '')}`,
}))}
pagination={{
current: page.current,
pageSize: page.size,
total,
showSizeChanger: false,
onChange: (current: number, size: number) => setPage({ current, size }),
}}
columns={[
{ title: '序号', dataIndex: 'index', width: 64 },
{ title: '登录账户', dataIndex: 'operator' },
{ title: '登录产品', dataIndex: 'productName', width: 180 },
{ title: '登录IP', dataIndex: 'ip', width: 180 },
{ title: '修改内容', dataIndex: 'modifyContent', width: 200 },
{ title: '操作人', dataIndex: 'userName', width: 160 },
{ title: '操作时间', dataIndex: 'createdTime', width: 190 },
]}
/>
</UCard>
);
}
...@@ -3,10 +3,12 @@ import { useMutation, useQuery } from '@tanstack/react-query'; ...@@ -3,10 +3,12 @@ import { useMutation, useQuery } from '@tanstack/react-query';
import { import {
UButton, UButton,
UCheckbox, UCheckbox,
UCloseIcon,
UEmpty, UEmpty,
UForm, UForm,
UFormItem, UFormItem,
UInput, UInput,
UPlusIcon,
USelect, USelect,
UTree, UTree,
useUMessage, useUMessage,
...@@ -19,8 +21,8 @@ import { errorDetail } from '@/utils/error'; ...@@ -19,8 +21,8 @@ import { errorDetail } from '@/utils/error';
import { useMerchantAccess } from '@/adapter/access'; import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { DICT, useDictionaries, useMerchantOptions } from '@/hooks/useDictionaries'; import { DICT, useDictionaries, useMerchantOptions } from '@/hooks/useDictionaries';
import { SectionTitle } from '../../Merchant/Create/ui';
import { PHONE_REGEX } from '../../Merchant/Create/model'; import { PHONE_REGEX } from '../../Merchant/Create/model';
import { FormFooter, REQUIRED, TaskSection } from '../../shared';
import { import {
buildStaffPayload, buildStaffPayload,
collectLeafIds, collectLeafIds,
...@@ -45,8 +47,6 @@ import { ...@@ -45,8 +47,6 @@ import {
* 「刷新/创建角色」按钮组属于嵌入分支,本系统按超管态复刻、该分支有意不复刻。 * 「刷新/创建角色」按钮组属于嵌入分支,本系统按超管态复刻、该分支有意不复刻。
*/ */
const REQUIRED = { required: true, message: '必填项' };
export default function EmployeeFormPage({ params }: { params?: PageParams } = {}) { export default function EmployeeFormPage({ params }: { params?: PageParams } = {}) {
const staffId = params?.id; const staffId = params?.id;
const presetMerchantId = params?.merchantId; const presetMerchantId = params?.merchantId;
...@@ -278,7 +278,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -278,7 +278,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
return ( return (
<PageShell <PageShell
title={mode === 'edit' ? '修改员工' : '创建员工'} title={mode === 'edit' ? '修改员工' : '创建员工'}
description="员工归属商户、可见范围与角色权限在此维护;保存后返回员工列表。" description="员工归属商户、可见范围与角色权限在此维护;保存后返回员工列表"
> >
<div className="uj-create-card"> <div className="uj-create-card">
{/* 排版参照商户详情/权限行:标签左置 88px、每字段一行、控件限宽,不再用 12 列栅格混排。 */} {/* 排版参照商户详情/权限行:标签左置 88px、每字段一行、控件限宽,不再用 12 列栅格混排。 */}
...@@ -290,9 +290,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -290,9 +290,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
labelAlign="left" labelAlign="left"
> >
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="01" description="员工主体与登录凭据"> <TaskSection>员工基本信息</TaskSection>
员工基本信息
</SectionTitle>
<UFormItem label="所属商户" required> <UFormItem label="所属商户" required>
{merchantFixed ? ( {merchantFixed ? (
<div className="uj-static-text">{merchantText || '-'}</div> <div className="uj-static-text">{merchantText || '-'}</div>
...@@ -394,11 +392,13 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -394,11 +392,13 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
setAvatar(undefined); setAvatar(undefined);
}} }}
> >
× <UCloseIcon />
</span> </span>
</> </>
) : ( ) : (
<span className="uj-staff-avatar__empty">{uploading ? '…' : '+'}</span> <span className="uj-staff-avatar__empty">
{uploading ? '…' : <UPlusIcon />}
</span>
)} )}
</div> </div>
<p className="uj-hint"> <p className="uj-hint">
...@@ -420,9 +420,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -420,9 +420,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
</section> </section>
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="02" description="可见商户范围、角色与标签"> <TaskSection>权限与标签</TaskSection>
权限与标签
</SectionTitle>
<UFormItem label="可见商户" required> <UFormItem label="可见商户" required>
{specialVisible ? ( {specialVisible ? (
<div className="uj-static-text">全部商户</div> <div className="uj-static-text">全部商户</div>
...@@ -504,9 +502,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -504,9 +502,7 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
{mode === 'edit' ? ( {mode === 'edit' ? (
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="03" description="绑定后由企微侧维护,此处只读"> <TaskSection>企微信息</TaskSection>
企微信息
</SectionTitle>
<UFormItem label="微信昵称" name="weChatNickName"> <UFormItem label="微信昵称" name="weChatNickName">
<UInput className="uj-edit-form__field" readOnly placeholder="-" /> <UInput className="uj-edit-form__field" readOnly placeholder="-" />
</UFormItem> </UFormItem>
...@@ -520,12 +516,11 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = { ...@@ -520,12 +516,11 @@ export default function EmployeeFormPage({ params }: { params?: PageParams } = {
) : null} ) : null}
</UForm> </UForm>
<div className="uj-create-footer"> <FormFooter onCancel={() => goTo('employee')}>
<UButton onClick={() => goTo('employee')}>取消</UButton>
<UButton type="primary" loading={save.isPending} onClick={() => void submit()}> <UButton type="primary" loading={save.isPending} onClick={() => void submit()}>
确定 确定
</UButton> </UButton>
</div> </FormFooter>
</div> </div>
</PageShell> </PageShell>
); );
......
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UForm, UTooltip, useUMessage } from '@uj/ui'; import { UButton, UCard, UForm, UTooltip, useUMessage } from '@uj/ui';
import { downloadCenter, goTo } from '@uj/platform-sdk'; import { downloadCenter, goTo } from '@uj/platform-sdk';
import { import {
ConfirmModal, ConfirmModal,
...@@ -23,6 +23,14 @@ import { ...@@ -23,6 +23,14 @@ import {
useDictionaries, useDictionaries,
useMerchantOptions, useMerchantOptions,
} from '@/hooks/useDictionaries'; } from '@/hooks/useDictionaries';
import {
FilterCard,
LoadErrorAlert,
labelOf,
useAuditColumns,
StatusMark,
statusTone,
} from '../shared';
type Filters = { type Filters = {
merchantId?: string; merchantId?: string;
...@@ -44,11 +52,6 @@ function asArray<T>(value: unknown): T[] { ...@@ -44,11 +52,6 @@ function asArray<T>(value: unknown): T[] {
return Array.isArray(value) ? (value as T[]) : []; return Array.isArray(value) ? (value as T[]) : [];
} }
function labelOf(value: unknown, derived: unknown, map: Record<string, string>): string {
if (typeof derived === 'string' && derived) return derived;
return map[String(value ?? '')] ?? (value === undefined || value === '' ? '-' : String(value));
}
export default function EmployeePage() { export default function EmployeePage() {
const { can } = useMerchantAccess(); const { can } = useMerchantAccess();
const message = useUMessage(); const message = useUMessage();
...@@ -170,23 +173,36 @@ export default function EmployeePage() { ...@@ -170,23 +173,36 @@ export default function EmployeePage() {
}, },
]; ];
const { showAudit, toggle: auditToggle } = useAuditColumns();
const columns: DataTableColumnsType<EmployeeRow> = [ const columns: DataTableColumnsType<EmployeeRow> = [
{ title: '员工姓名', dataIndex: 'staffName', width: 140 }, { title: '员工姓名', dataIndex: 'staffName', width: 140, fixed: 'left' },
{ title: '角色', dataIndex: 'roleName', width: 160 },
{ title: '登录手机号', dataIndex: 'staffPhone', width: 150 },
{ title: '企微号', dataIndex: 'entmicroName', width: 160, line: 1 },
{ {
title: '状态', title: '状态',
dataIndex: 'statusName', dataIndex: 'statusName',
width: 100, width: 100,
render: (value, row) => labelOf(row.status, value, { '0': '启用', '2': '停用' }), fixed: 'left',
render: (value, row) => {
const status = String(row.status ?? '');
return (
<StatusMark tone={statusTone(status)}>
{labelOf(status, value, { '0': '启用', '2': '停用' })}
</StatusMark>
);
},
}, },
{ title: '创建者', dataIndex: 'createdAccount', width: 130 },
// 源 index.html:157 列标题逐字为「商户名(商户号)」。 // 源 index.html:157 列标题逐字为「商户名(商户号)」。
{ title: '商户名(商户号)', dataIndex: 'merchantName', width: 200, line: 1 }, { title: '商户名(商户号)', dataIndex: 'merchantName', width: 200, line: 1 },
{ title: '来源', dataIndex: 'createdSourceStr', width: 120 }, { title: '角色', dataIndex: 'roleName', width: 160 },
{ title: '创建时间', dataIndex: 'createdTime', width: 170 }, { title: '登录手机号', dataIndex: 'staffPhone', width: 150 },
{ title: '更新时间', dataIndex: 'updatedTime', width: 170 }, { title: '企微号', dataIndex: 'entmicroName', width: 160, line: 1 },
...(showAudit
? [
{ title: '创建者', dataIndex: 'createdAccount', width: 130 },
{ title: '来源', dataIndex: 'createdSourceStr', width: 120 },
{ title: '创建时间', dataIndex: 'createdTime', width: 170 },
{ title: '更新时间', dataIndex: 'updatedTime', width: 170 },
]
: []),
]; ];
const rowActions: RowActionSchema<EmployeeRow>[] = [ const rowActions: RowActionSchema<EmployeeRow>[] = [
...@@ -251,7 +267,7 @@ export default function EmployeePage() { ...@@ -251,7 +267,7 @@ export default function EmployeePage() {
return ( return (
<PageShell <PageShell
title="员工管理" title="员工管理"
description="维护商户员工、角色与可见商户范围,支持启停操作。" description="维护商户员工、角色与可见商户范围,支持启停操作"
fill fill
actions={ actions={
can(MC.EMPLOYEE_CREATE) ? ( can(MC.EMPLOYEE_CREATE) ? (
...@@ -261,7 +277,7 @@ export default function EmployeePage() { ...@@ -261,7 +277,7 @@ export default function EmployeePage() {
) : null ) : null
} }
> >
<UCard className="uj-filter-card" size="small"> <FilterCard>
<SearchForm <SearchForm
form={filterForm} form={filterForm}
fields={fields} fields={fields}
...@@ -274,18 +290,12 @@ export default function EmployeePage() { ...@@ -274,18 +290,12 @@ export default function EmployeePage() {
setPage({ current: pagination.current, size: pagination.size }); setPage({ current: pagination.current, size: pagination.size });
}} }}
/> />
</UCard> </FilterCard>
{list.isError ? ( {list.isError ? (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="员工列表加载失败" title="员工列表加载失败"
description={errorDetail(list.error)} description={errorDetail(list.error)}
action={ onRetry={() => void list.refetch()}
<UButton type="link" onClick={() => void list.refetch()}>
重试
</UButton>
}
/> />
) : null} ) : null}
<UCard size="small" fill> <UCard size="small" fill>
...@@ -295,6 +305,7 @@ export default function EmployeePage() { ...@@ -295,6 +305,7 @@ export default function EmployeePage() {
rowKey={(row) => String(row.id ?? '')} rowKey={(row) => String(row.id ?? '')}
columns={columns} columns={columns}
rowActions={rowActions} rowActions={rowActions}
toolbarExtra={auditToggle}
loading={list.isPending || list.isFetching} loading={list.isPending || list.isFetching}
pageData={list.data as Record<string, unknown> | undefined} pageData={list.data as Record<string, unknown> | undefined}
recordsKey="list" recordsKey="list"
......
...@@ -46,26 +46,26 @@ export function AccessModeModal({ ...@@ -46,26 +46,26 @@ export function AccessModeModal({
}} }}
okButtonProps={{ loading: update.isPending }} okButtonProps={{ loading: update.isPending }}
> >
<div className="uj-period-modal"> <div className="uj-modal-form">
<p className="uj-period-modal__row">商户名称:{row.merchantName ?? '-'}</p> <p className="uj-modal-form__row">商户名称:{row.merchantName ?? '-'}</p>
<URadio.Group <URadio.Group
className="uj-period-modal__radios" className="uj-modal-form__radios"
value={accessMode || undefined} value={accessMode || undefined}
onChange={(event) => { onChange={(event) => {
setAccessMode(String(event.target.value)); setAccessMode(String(event.target.value));
setModeError(false); setModeError(false);
}} }}
> >
<div className="uj-period-modal__radio-line"> <div className="uj-modal-form__radio-line">
<URadio value="3">应用代开发模式</URadio> <URadio value="3">应用代开发模式</URadio>
<span className="uj-hint">(SCRM非独立部署)</span> <span className="uj-hint">(SCRM非独立部署)</span>
</div> </div>
<div className="uj-period-modal__radio-line"> <div className="uj-modal-form__radio-line">
<URadio value="0">自建应用模式</URadio> <URadio value="0">自建应用模式</URadio>
<span className="uj-hint">(SCRM需独立部署,且生成独立接口域名)</span> <span className="uj-hint">(SCRM需独立部署,且生成独立接口域名)</span>
</div> </div>
</URadio.Group> </URadio.Group>
{modeError ? <p className="uj-period-modal__error">请选择企微接入模式</p> : null} {modeError ? <p className="uj-modal-form__error">请选择企微接入模式</p> : null}
</div> </div>
</UModal> </UModal>
); );
......
...@@ -4,10 +4,12 @@ import dayjs from 'dayjs'; ...@@ -4,10 +4,12 @@ import dayjs from 'dayjs';
import { import {
UButton, UButton,
UCheckbox, UCheckbox,
UCloseIcon,
UDatePicker, UDatePicker,
UForm, UForm,
UFormItem, UFormItem,
UInput, UInput,
UPlusIcon,
URadio, URadio,
USelect, USelect,
UTree, UTree,
...@@ -19,8 +21,8 @@ import { errorDetail } from '@/utils/error'; ...@@ -19,8 +21,8 @@ import { errorDetail } from '@/utils/error';
import { AddressModal, type AddressValue } from './AddressModal'; import { AddressModal, type AddressValue } from './AddressModal';
import type { BrandNode, CreateFormValues, MerchantFile } from './model'; import type { BrandNode, CreateFormValues, MerchantFile } from './model';
import { PASSWORD_REGEX, PHONE_REGEX, RESIDENT_PHONE_REGEX, asArray } from './model'; import { PASSWORD_REGEX, PHONE_REGEX, RESIDENT_PHONE_REGEX, asArray } from './model';
import { SectionTitle } from './ui';
import { PROVINCES, citiesOf } from './regions'; import { PROVINCES, citiesOf } from './regions';
import { TaskSection } from '../../shared';
interface ControlProps { interface ControlProps {
value?: unknown; value?: unknown;
...@@ -477,7 +479,9 @@ function ImageControl({ value, onChange }: ControlProps) { ...@@ -477,7 +479,9 @@ function ImageControl({ value, onChange }: ControlProps) {
{file?.fileUrl ? ( {file?.fileUrl ? (
<img src={file.fileUrl} alt={`门店照片 ${index + 1}`} /> <img src={file.fileUrl} alt={`门店照片 ${index + 1}`} />
) : ( ) : (
<span className="uj-images__plus">+</span> <span className="uj-images__plus">
<UPlusIcon />
</span>
)} )}
</button> </button>
{file?.fileUrl ? ( {file?.fileUrl ? (
...@@ -488,7 +492,7 @@ function ImageControl({ value, onChange }: ControlProps) { ...@@ -488,7 +492,7 @@ function ImageControl({ value, onChange }: ControlProps) {
aria-label={`删除门店照片 ${index + 1}`} aria-label={`删除门店照片 ${index + 1}`}
onClick={() => remove(index)} onClick={() => remove(index)}
> >
× <UCloseIcon />
</button> </button>
) : null} ) : null}
<input <input
...@@ -656,9 +660,7 @@ export function BasicForm({ ...@@ -656,9 +660,7 @@ export function BasicForm({
</UFormItem> </UFormItem>
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="01" description="商户主体与门店经营信息"> <TaskSection>企业基本信息</TaskSection>
企业基本信息
</SectionTitle>
<div className="uj-form-grid"> <div className="uj-form-grid">
{mode === 'sub' && parent ? ( {mode === 'sub' && parent ? (
<div className="uj-full uj-parent-row"> <div className="uj-full uj-parent-row">
...@@ -779,9 +781,7 @@ export function BasicForm({ ...@@ -779,9 +781,7 @@ export function BasicForm({
</section> </section>
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="02" description="商户平台登录与权限模板"> <TaskSection>账户基本信息</TaskSection>
账户基本信息
</SectionTitle>
<div className="uj-form-grid"> <div className="uj-form-grid">
<UFormItem <UFormItem
label="登录账户名" label="登录账户名"
......
...@@ -9,7 +9,7 @@ import { ...@@ -9,7 +9,7 @@ import {
type AccountPerm, type AccountPerm,
type ProductPerm, type ProductPerm,
} from './model'; } from './model';
import { SectionTitle } from './ui'; import { TaskSection } from '../../shared';
/** 源 getById() 的 check_arr:产品回显用 productId;编辑态节点按已存 menuIds 精确回勾(edit.html L2713-2738)。 */ /** 源 getById() 的 check_arr:产品回显用 productId;编辑态节点按已存 menuIds 精确回勾(edit.html L2713-2738)。 */
export interface PermissionSeed { export interface PermissionSeed {
...@@ -25,8 +25,6 @@ export interface PermissionFormHandle { ...@@ -25,8 +25,6 @@ export interface PermissionFormHandle {
interface PermissionFormProps { interface PermissionFormProps {
accounts: AccountPerm[]; accounts: AccountPerm[];
seed: PermissionSeed[]; seed: PermissionSeed[];
/** Edit 页在 tab 内复用,块编号跟随所在流程(默认 03=创建第二步)。 */
sectionIndex?: string;
/** 账户类型 id→名称(字典):接口偶发不返回 accounttypeName 时兜底,避免页签显示裸 id。 */ /** 账户类型 id→名称(字典):接口偶发不返回 accounttypeName 时兜底,避免页签显示裸 id。 */
typeNameById?: Record<string, string>; typeNameById?: Record<string, string>;
/** Edit 页脏守卫:任何勾选交互都要置脏,切 tab 时才提示保存。 */ /** Edit 页脏守卫:任何勾选交互都要置脏,切 tab 时才提示保存。 */
...@@ -46,7 +44,7 @@ function seedProductIds(seed: PermissionSeed[]): Set<string> { ...@@ -46,7 +44,7 @@ function seedProductIds(seed: PermissionSeed[]): Set<string> {
} }
export const PermissionForm = forwardRef<PermissionFormHandle, PermissionFormProps>( export const PermissionForm = forwardRef<PermissionFormHandle, PermissionFormProps>(
function PermissionForm({ accounts, seed, sectionIndex = '03', typeNameById, onInteract }, ref) { function PermissionForm({ accounts, seed, typeNameById, onInteract }, ref) {
const { nodeIndex, allChecked } = useMemo(() => collectNodeIndex(accounts), [accounts]); const { nodeIndex, allChecked } = useMemo(() => collectNodeIndex(accounts), [accounts]);
const [productChecked, setProductChecked] = useState<Record<string, Array<string | number>>>( const [productChecked, setProductChecked] = useState<Record<string, Array<string | number>>>(
() => initialProducts(accounts, seed), () => initialProducts(accounts, seed),
...@@ -100,9 +98,7 @@ export const PermissionForm = forwardRef<PermissionFormHandle, PermissionFormPro ...@@ -100,9 +98,7 @@ export const PermissionForm = forwardRef<PermissionFormHandle, PermissionFormPro
return ( return (
<section className="uj-section"> <section className="uj-section">
<SectionTitle index={sectionIndex} description="按账户类型勾选产品与功能菜单"> <TaskSection>功能权限</TaskSection>
功能权限
</SectionTitle>
<span className="uj-create-perm__caption">账户类型</span> <span className="uj-create-perm__caption">账户类型</span>
<div className="uj-create-tabs"> <div className="uj-create-tabs">
<UTabs <UTabs
......
import { useEffect, useMemo, useRef, useState } from 'react'; import { useEffect, useMemo, useRef, useState } from 'react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UEmpty, UForm, UModal, USelect, useUMessage } from '@uj/ui'; import { UButton, UCheckIcon, UEmpty, UForm, USelect, useUMessage } from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { PageShell } from '@/components'; import { PageShell } from '@/components';
import type { FieldOption } from '@/components'; import type { FieldOption } from '@/components';
...@@ -20,6 +20,7 @@ import { ...@@ -20,6 +20,7 @@ import {
type BrandNode, type BrandNode,
type CreateFormValues, type CreateFormValues,
} from './model'; } from './model';
import { DuplicateNameModal, FormFooter, LoadErrorAlert } from '../../shared';
const MODEL_LABEL: Record<string, string> = { '1': '集团企微版', '2': '单店企微版' }; const MODEL_LABEL: Record<string, string> = { '1': '集团企微版', '2': '单店企微版' };
...@@ -264,21 +265,11 @@ export default function CreateMerchantPage({ params }: { params?: PageParams }) ...@@ -264,21 +265,11 @@ export default function CreateMerchantPage({ params }: { params?: PageParams })
if (mode === 'sub' && parentQuery.isPending) return <UEmpty description="正在读取上级商户…" />; if (mode === 'sub' && parentQuery.isPending) return <UEmpty description="正在读取上级商户…" />;
if (mode === 'sub' && (!parent || parentQuery.isError)) if (mode === 'sub' && (!parent || parentQuery.isError))
return ( return (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="上级商户加载失败" title="上级商户加载失败"
description={parentQuery.error ? errorDetail(parentQuery.error) : '上级商户不存在'} description={parentQuery.error ? errorDetail(parentQuery.error) : '上级商户不存在'}
action={ onRetry={() => void parentQuery.refetch()}
<> onBack={goList}
<UButton type="link" onClick={() => void parentQuery.refetch()}>
重试
</UButton>
<UButton type="link" onClick={goList}>
返回列表
</UButton>
</>
}
/> />
); );
...@@ -287,8 +278,8 @@ export default function CreateMerchantPage({ params }: { params?: PageParams }) ...@@ -287,8 +278,8 @@ export default function CreateMerchantPage({ params }: { params?: PageParams })
title={mode === 'sub' ? '创建子商户' : '创建商户'} title={mode === 'sub' ? '创建子商户' : '创建商户'}
description={ description={
mode === 'sub' mode === 'sub'
? '子商户继承上级渠道与模式,按等级范围填写资料后配置功能权限。' ? '子商户继承上级渠道与模式,按等级范围填写资料后配置功能权限'
: '按源系统口径填写企业与账户信息,再配置功能权限。' : '按源系统口径填写企业与账户信息,再配置功能权限'
} }
actions={ actions={
mode === 'create' ? ( mode === 'create' ? (
...@@ -307,7 +298,7 @@ export default function CreateMerchantPage({ params }: { params?: PageParams }) ...@@ -307,7 +298,7 @@ export default function CreateMerchantPage({ params }: { params?: PageParams })
> >
<div className="uj-steps" role="list" aria-label="创建步骤"> <div className="uj-steps" role="list" aria-label="创建步骤">
<div className={`uj-step${step === 1 ? ' is-active' : ' is-done'}`}> <div className={`uj-step${step === 1 ? ' is-active' : ' is-done'}`}>
<span className="uj-step__badge">{step === 2 ? '✓' : '1'}</span> <span className="uj-step__badge">{step === 2 ? <UCheckIcon /> : '1'}</span>
<span className="uj-step__label">基本信息</span> <span className="uj-step__label">基本信息</span>
<span className="uj-step__desc">企业与账户资料</span> <span className="uj-step__desc">企业与账户资料</span>
</div> </div>
...@@ -350,33 +341,25 @@ export default function CreateMerchantPage({ params }: { params?: PageParams }) ...@@ -350,33 +341,25 @@ export default function CreateMerchantPage({ params }: { params?: PageParams })
/> />
)} )}
{brandQuery.isError ? ( {brandQuery.isError ? (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="主营品牌加载失败" title="主营品牌加载失败"
description={errorDetail(brandQuery.error)} description={errorDetail(brandQuery.error)}
action={ onRetry={() => void brandQuery.refetch()}
<UButton type="link" onClick={() => void brandQuery.refetch()}>
重试
</UButton>
}
/> />
) : null} ) : null}
</div> </div>
<div className="uj-create-footer"> <FormFooter onCancel={goList}>
{step === 1 ? ( {step === 1 ? (
<> <UButton type="primary" loading={saving} onClick={() => void submitBasic()}>
<UButton onClick={goList}>取消</UButton> 下一步
<UButton type="primary" loading={saving} onClick={() => void submitBasic()}> </UButton>
下一步
</UButton>
</>
) : ( ) : (
<> <>
<UButton onClick={goList}>取消</UButton> <UButton type="text" onClick={() => setStep(1)}>
<UButton onClick={() => setStep(1)}>上一步</UButton> 上一步
<UButton loading={saving} onClick={() => void submitPermissions(true)}> </UButton>
<UButton type="text" loading={saving} onClick={() => void submitPermissions(true)}>
存草稿 存草稿
</UButton> </UButton>
<UButton type="primary" loading={saving} onClick={() => void submitPermissions(false)}> <UButton type="primary" loading={saving} onClick={() => void submitPermissions(false)}>
...@@ -384,22 +367,17 @@ export default function CreateMerchantPage({ params }: { params?: PageParams }) ...@@ -384,22 +367,17 @@ export default function CreateMerchantPage({ params }: { params?: PageParams })
</UButton> </UButton>
</> </>
)} )}
</div> </FormFooter>
<UModal <DuplicateNameModal
title="提示"
open={duplicate !== null} open={duplicate !== null}
okText="确定"
cancelText="取消"
onCancel={() => setDuplicate(null)} onCancel={() => setDuplicate(null)}
onOk={() => { onConfirm={() => {
const params = duplicate; const params = duplicate;
setDuplicate(null); setDuplicate(null);
if (params) void finishCreate(params); if (params) void finishCreate(params);
}} }}
> />
<p>商户名称已经被使用,是否确定继续使用</p>
</UModal>
</PageShell> </PageShell>
); );
} }
......
import { useMemo, type ReactNode } from 'react'; import { useMemo } from 'react';
import { UTree } from '@uj/ui'; import { UTree } from '@uj/ui';
import type { PermNode } from './model'; import type { PermNode } from './model';
interface SectionTitleProps {
children: ReactNode;
index?: string;
description?: string;
}
/** 分区标题:序号徽章 + 标题 + 说明,给长表单建立清晰的视觉层级。 */
export function SectionTitle({ children, index, description }: SectionTitleProps) {
return (
<div className="uj-section-head">
{index ? <span className="uj-section-head__index">{index}</span> : null}
<div className="uj-section-head__text">
<h3 className="uj-section-head__title">{children}</h3>
{description ? <p className="uj-section-head__desc">{description}</p> : null}
</div>
</div>
);
}
/** 只读权限树(商户/员工/角色详情共用):节点自带 checked 标记即回勾(源 treeTab 展示口径)。 */ /** 只读权限树(商户/员工/角色详情共用):节点自带 checked 标记即回勾(源 treeTab 展示口径)。 */
export function ReadOnlyPermTree({ nodes }: { nodes: PermNode[] }) { export function ReadOnlyPermTree({ nodes }: { nodes: PermNode[] }) {
const checkedKeys = useMemo(() => { const checkedKeys = useMemo(() => {
......
import { useEffect, useMemo, useState } from 'react'; import { useEffect, useMemo, useState } from 'react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UEmpty, UInput, UTabs, UTree } from '@uj/ui'; import { UButton, UEmpty, UInput, UTabs, UTree } from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { DataTable, PageShell } from '@/components'; import { DataTable, PageShell } from '@/components';
import type { PageParams } from '../../../routes'; import type { PageParams } from '../../../routes';
...@@ -8,8 +8,17 @@ import { commonApi, merchantApi } from '@/api'; ...@@ -8,8 +8,17 @@ import { commonApi, merchantApi } from '@/api';
import { errorDetail } from '@/utils/error'; import { errorDetail } from '@/utils/error';
import { useMerchantAccess } from '@/adapter/access'; import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { asArray, nodeList, type AccountPerm } from '../Create/model'; import { asArray, type AccountPerm } from '../Create/model';
import { ReadOnlyPermTree } from '../Create/ui'; import {
DetailItem,
LoadErrorAlert,
LogTab,
ReadOnlyPermTabs,
IdentityBand,
StatusMark,
statusTone,
TaskSection,
} from '../../shared';
/** /**
* 商户详情二级页(源 temp/account/html/merchant/detail.html)。 * 商户详情二级页(源 temp/account/html/merchant/detail.html)。
...@@ -52,21 +61,11 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -52,21 +61,11 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
if (detailQuery.isPending) return <UEmpty description="正在读取商户详情…" />; if (detailQuery.isPending) return <UEmpty description="正在读取商户详情…" />;
if (detailQuery.isError || !detail) if (detailQuery.isError || !detail)
return ( return (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="商户详情加载失败" title="商户详情加载失败"
description={detailQuery.error ? errorDetail(detailQuery.error) : '商户不存在'} description={detailQuery.error ? errorDetail(detailQuery.error) : '商户不存在'}
action={ onRetry={() => void detailQuery.refetch()}
<> onBack={() => goTo('merchant')}
<UButton type="link" onClick={() => void detailQuery.refetch()}>
重试
</UButton>
<UButton type="link" onClick={() => goTo('merchant')}>
返回列表
</UButton>
</>
}
/> />
); );
...@@ -82,7 +81,7 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -82,7 +81,7 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
// 长内容(商户信息)改由 .uj-detail__body 自己滚,列表仍整屏定高 + 表体内滚。 // 长内容(商户信息)改由 .uj-detail__body 自己滚,列表仍整屏定高 + 表体内滚。
fill fill
title={`商户详情 · ${text(detail.merchantName)}`} title={`商户详情 · ${text(detail.merchantName)}`}
description="账户信息、功能权限与组织关系;功能权限为只读展示。" description="账户信息、功能权限与组织关系;功能权限为只读展示"
actions={ actions={
can(MC.MERCHANT_EDIT) ? ( can(MC.MERCHANT_EDIT) ? (
<UButton type="primary" onClick={() => goTo(`merchant/edit/${merchantId}`)}> <UButton type="primary" onClick={() => goTo(`merchant/edit/${merchantId}`)}>
...@@ -91,6 +90,16 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -91,6 +90,16 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
) : null ) : null
} }
> >
<IdentityBand
name={text(detail.merchantName)}
status={<StatusMark tone={statusTone(detail.status)}>{text(detail.statusName)}</StatusMark>}
fields={[
{ label: '商户号', value: text(detail.merchantNo), mono: true },
{ label: '账户等级', value: text(detail.accountLevelName) },
{ label: '有效期', value: text(detail.effectiveTimeName) },
]}
/>
<UTabs <UTabs
className="uj-tabs-uniform" className="uj-tabs-uniform"
activeKey={tab} activeKey={tab}
...@@ -109,15 +118,11 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -109,15 +118,11 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
<div className="uj-create-card"> <div className="uj-create-card">
<> <>
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">账户信息</h3> <TaskSection>登录与归属</TaskSection>
<dl className="uj-detail-grid"> <dl className="uj-detail-grid">
<DetailItem label="登录账户名" value={text(detail.merchantLoginAccount)} /> <DetailItem label="登录账户名" value={text(detail.merchantLoginAccount)} />
<DetailItem label="账户等级" value={text(detail.accountLevelName)} />
<DetailItem label="开通模式" value={text(detail.merchantModelName)} /> <DetailItem label="开通模式" value={text(detail.merchantModelName)} />
<DetailItem label="账户状态" value={text(detail.statusName)} />
<DetailItem label="关联企业微信名" value={text(detail.entmicroName)} /> <DetailItem label="关联企业微信名" value={text(detail.entmicroName)} />
<DetailItem label="账户有效期" value={text(detail.effectiveTimeName)} />
<DetailItem label="商户号" value={text(detail.merchantNo)} />
<DetailItem label="来源" value={text(detail.createdSourceStr)} /> <DetailItem label="来源" value={text(detail.createdSourceStr)} />
</dl> </dl>
<div className="uj-detail-accounttypes"> <div className="uj-detail-accounttypes">
...@@ -137,43 +142,18 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -137,43 +142,18 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
</section> </section>
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">功能权限</h3> <TaskSection>功能权限</TaskSection>
{permAccounts.length ? ( <ReadOnlyPermTabs
<div className="uj-create-tabs"> accounts={permAccounts}
<UTabs loading={permQuery.isPending}
className="uj-tabs-uniform" loadingText="权限树加载中…"
items={permAccounts.map((account) => ({ emptyText="暂无功能权限数据"
key: String(account.accounttypeId), />
label: account.accounttypeName ?? String(account.accounttypeId),
children: (account.products ?? []).length ? (
<UTabs
className="uj-tabs-uniform"
items={(account.products ?? []).map((product) => {
const nodes = nodeList(product);
return {
key: String(product.productId),
label: product.productName ?? String(product.productId),
children: <ReadOnlyPermTree nodes={nodes} />,
};
})}
/>
) : (
<div className="uj-create-hint">暂无产品</div>
),
}))}
/>
</div>
) : (
<div className="uj-create-hint">
{permQuery.isPending ? '权限树加载中…' : '暂无功能权限数据'}
</div>
)}
</section> </section>
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">企业信息</h3> <TaskSection>企业与经营信息</TaskSection>
<dl className="uj-detail-grid"> <dl className="uj-detail-grid">
<DetailItem label="商户名称" value={text(detail.merchantName)} />
<DetailItem label="简称" value={text(detail.merchantAbbreviation)} /> <DetailItem label="简称" value={text(detail.merchantAbbreviation)} />
<DetailItem label="联系电话" value={text(detail.merchantLegalPersonPhone)} /> <DetailItem label="联系电话" value={text(detail.merchantLegalPersonPhone)} />
<DetailItem label="联系人" value={text(detail.merchantLegalPerson)} /> <DetailItem label="联系人" value={text(detail.merchantLegalPerson)} />
...@@ -218,21 +198,14 @@ export default function MerchantDetailPage({ params }: { params?: PageParams }) ...@@ -218,21 +198,14 @@ export default function MerchantDetailPage({ params }: { params?: PageParams })
/> />
) : null} ) : null}
{tab === 'log' ? <LogTab merchantId={merchantId} /> : null} {tab === 'log' ? (
<LogTab queryKey="log" bussinessId={merchantId} moduleName="商户模块" />
) : null}
</div> </div>
</PageShell> </PageShell>
); );
} }
function DetailItem({ label, value }: { label: string; value: string }) {
return (
<div className="uj-detail-item">
<dt>{label}</dt>
<dd title={value === '-' ? undefined : value}>{value}</dd>
</div>
);
}
function DetailImages({ files }: { files: Array<Record<string, unknown>> }) { function DetailImages({ files }: { files: Array<Record<string, unknown>> }) {
if (!files.length) return null; if (!files.length) return null;
return ( return (
...@@ -383,7 +356,7 @@ function HierarchyTab({ ...@@ -383,7 +356,7 @@ function HierarchyTab({
columns={[ columns={[
{ {
title: '序号', title: '序号',
width: 60, width: 64,
align: 'center', align: 'center',
render: (_: unknown, _row: unknown, index: number) => render: (_: unknown, _row: unknown, index: number) =>
(staffPage - 1) * 10 + index + 1, (staffPage - 1) * 10 + index + 1,
...@@ -401,55 +374,6 @@ function HierarchyTab({ ...@@ -401,55 +374,6 @@ function HierarchyTab({
); );
} }
function LogTab({ merchantId }: { merchantId: string }) {
const [page, setPage] = useState({ current: 1, size: 10 });
const logQuery = useQuery({
queryKey: ['merchant', 'log', merchantId, page],
queryFn: () =>
merchantApi.findLog({
bussinessId: merchantId,
moduleName: '商户模块',
pageNum: page.current,
pageSize: page.size,
}),
enabled: Boolean(merchantId),
});
const wrapped = (logQuery.data ?? {}) as Record<string, unknown>;
// 分页信封在网关归一后行数组落在 list;兼容尚未改名的旧形状(data 或裸数组)。
const rows = asArray<Record<string, unknown>>(wrapped.list ?? wrapped.data ?? logQuery.data);
const total = Number(wrapped.total ?? wrapped.count ?? rows.length);
return (
<UCard size="small" fill>
<DataTable<Record<string, unknown>>
fillHeight
rowKey={(row) => String(row.id ?? Math.random())}
loading={logQuery.isFetching}
dataSource={rows.map((row, index) => ({
...row,
index: (page.current - 1) * page.size + index + 1,
modifyContent: `${String(row.module ?? '')}-${String(row.action ?? '')}`,
}))}
pagination={{
current: page.current,
pageSize: page.size,
total,
showSizeChanger: false,
onChange: (current: number, size: number) => setPage({ current, size }),
}}
columns={[
{ title: '序号', dataIndex: 'index', width: 64 },
{ title: '登录账户', dataIndex: 'operator' },
{ title: '登录产品', dataIndex: 'productName', width: 180 },
{ title: '登录IP', dataIndex: 'ip', width: 180 },
{ title: '修改内容', dataIndex: 'modifyContent', width: 200 },
{ title: '操作人', dataIndex: 'userName', width: 160 },
{ title: '操作时间', dataIndex: 'createdTime', width: 190 },
]}
/>
</UCard>
);
}
interface MappedNode { interface MappedNode {
key: string; key: string;
title: string; title: string;
......
import { useCallback, useEffect, useMemo, useRef, useState } from 'react'; import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { import { UButton, UCheckbox, UEmpty, UForm, UModal, USelect, UTabs, useUMessage } from '@uj/ui';
UAlert,
UButton,
UCheckbox,
UEmpty,
UForm,
UModal,
USelect,
UTabs,
useUMessage,
} from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { PageShell } from '@/components'; import { PageShell } from '@/components';
import type { FieldOption } from '@/components'; import type { FieldOption } from '@/components';
...@@ -21,7 +11,6 @@ import { useMerchantAccess } from '@/adapter/access'; ...@@ -21,7 +11,6 @@ import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { DICT, useDictionaries } from '@/hooks/useDictionaries'; import { DICT, useDictionaries } from '@/hooks/useDictionaries';
import { BasicForm } from '../Create/BasicForm'; import { BasicForm } from '../Create/BasicForm';
import { SectionTitle } from '../Create/ui';
import { import {
PermissionForm, PermissionForm,
type PermissionFormHandle, type PermissionFormHandle,
...@@ -36,6 +25,7 @@ import { ...@@ -36,6 +25,7 @@ import {
type BrandNode, type BrandNode,
type CreateFormValues, type CreateFormValues,
} from '../Create/model'; } from '../Create/model';
import { DuplicateNameModal, FormFooter, LoadErrorAlert, TaskSection } from '../../shared';
/** 源 edit.html L304-309:权限 tab 的账户等级是硬编码四项,不走字典。 */ /** 源 edit.html L304-309:权限 tab 的账户等级是硬编码四项,不走字典。 */
const LEVEL_OPTIONS = [ const LEVEL_OPTIONS = [
...@@ -509,21 +499,11 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -509,21 +499,11 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
if (detailQuery.isPending) return <UEmpty description="正在读取商户详情…" />; if (detailQuery.isPending) return <UEmpty description="正在读取商户详情…" />;
if (detailQuery.isError || !detail) if (detailQuery.isError || !detail)
return ( return (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="商户详情加载失败" title="商户详情加载失败"
description={detailQuery.error ? errorDetail(detailQuery.error) : '商户不存在'} description={detailQuery.error ? errorDetail(detailQuery.error) : '商户不存在'}
action={ onRetry={() => void detailQuery.refetch()}
<> onBack={() => goTo('merchant')}
<UButton type="link" onClick={() => void detailQuery.refetch()}>
重试
</UButton>
<UButton type="link" onClick={() => goTo('merchant')}>
返回列表
</UButton>
</>
}
/> />
); );
...@@ -536,7 +516,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -536,7 +516,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
return ( return (
<PageShell <PageShell
title={`修改商户 · ${String(detail.merchantName ?? '')}`} title={`修改商户 · ${String(detail.merchantName ?? '')}`}
description="功能权限与基本信息分别保存;切换页签时未保存的修改会提示确认。" description="功能权限与基本信息分别保存;切换页签时未保存的修改会提示确认"
> >
<UTabs <UTabs
activeKey={tab} activeKey={tab}
...@@ -550,9 +530,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -550,9 +530,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
{tab === 'perm' ? ( {tab === 'perm' ? (
<div className="uj-create-card"> <div className="uj-create-card">
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="01" description="账户等级与上级商户共同决定可配置的产品范围"> <TaskSection>账户配置</TaskSection>
账户配置
</SectionTitle>
<div className="uj-perm-form"> <div className="uj-perm-form">
{level !== '1' ? ( {level !== '1' ? (
<div className="uj-perm-row"> <div className="uj-perm-row">
...@@ -611,7 +589,6 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -611,7 +589,6 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
ref={permissionRef} ref={permissionRef}
accounts={accounts} accounts={accounts}
seed={seedForTypes} seed={seedForTypes}
sectionIndex="02"
typeNameById={Object.fromEntries( typeNameById={Object.fromEntries(
dict[DICT.ACCOUNT_TYPE].map((item) => [String(item.value), String(item.label)]), dict[DICT.ACCOUNT_TYPE].map((item) => [String(item.value), String(item.label)]),
)} )}
...@@ -619,9 +596,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -619,9 +596,7 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
/> />
) : ( ) : (
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="02" description="按账户类型勾选产品与功能菜单"> <TaskSection>功能权限</TaskSection>
功能权限
</SectionTitle>
<div className="uj-perm-empty"> <div className="uj-perm-empty">
{level !== '1' && !superior?.value {level !== '1' && !superior?.value
? '请选择上级商户后加载权限树' ? '请选择上级商户后加载权限树'
...@@ -629,12 +604,11 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -629,12 +604,11 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
</div> </div>
</section> </section>
)} )}
<div className="uj-create-footer"> <FormFooter onCancel={() => goTo('merchant')}>
<UButton onClick={() => goTo('merchant')}>取消</UButton>
<UButton type="primary" loading={saving} onClick={() => void submitPerm()}> <UButton type="primary" loading={saving} onClick={() => void submitPerm()}>
确定 确定
</UButton> </UButton>
</div> </FormFooter>
</div> </div>
) : ( ) : (
<div className="uj-create-card"> <div className="uj-create-card">
...@@ -658,24 +632,17 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -658,24 +632,17 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
/> />
) : null} ) : null}
{brandQuery.isError ? ( {brandQuery.isError ? (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="主营品牌加载失败" title="主营品牌加载失败"
description={errorDetail(brandQuery.error)} description={errorDetail(brandQuery.error)}
action={ onRetry={() => void brandQuery.refetch()}
<UButton type="link" onClick={() => void brandQuery.refetch()}>
重试
</UButton>
}
/> />
) : null} ) : null}
<div className="uj-create-footer"> <FormFooter onCancel={() => goTo('merchant')}>
<UButton onClick={() => goTo('merchant')}>取消</UButton>
<UButton type="primary" loading={saving} onClick={() => void submitBasic()}> <UButton type="primary" loading={saving} onClick={() => void submitBasic()}>
确定 确定
</UButton> </UButton>
</div> </FormFooter>
</div> </div>
)} )}
...@@ -697,19 +664,14 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) { ...@@ -697,19 +664,14 @@ export default function MerchantEditPage({ params }: { params?: PageParams }) {
<p className="uj-hint">「是」将先提交当前页签的修改;「否」将放弃未保存内容直接切换。</p> <p className="uj-hint">「是」将先提交当前页签的修改;「否」将放弃未保存内容直接切换。</p>
</UModal> </UModal>
<UModal <DuplicateNameModal
title="提示"
open={duplicateParams !== null} open={duplicateParams !== null}
okText="确定"
cancelText="取消"
onCancel={() => setDuplicateParams(null)} onCancel={() => setDuplicateParams(null)}
onOk={() => { onConfirm={() => {
const payload = duplicateParams; const payload = duplicateParams;
if (payload) void persistBasic(payload); if (payload) void persistBasic(payload);
}} }}
> />
<p>商户名称已经被使用,是否确定继续使用</p>
</UModal>
</PageShell> </PageShell>
); );
} }
...@@ -84,8 +84,8 @@ export function PeriodModal({ ...@@ -84,8 +84,8 @@ export function PeriodModal({
onOk={onOk} onOk={onOk}
okButtonProps={{ loading: update.isPending }} okButtonProps={{ loading: update.isPending }}
> >
<div className="uj-period-modal"> <div className="uj-modal-form">
<p className="uj-period-modal__row"> <p className="uj-modal-form__row">
商户名称:{row.merchantName ?? '-'}(商户号 {row.merchantNo ?? '-'}) 商户名称:{row.merchantName ?? '-'}(商户号 {row.merchantNo ?? '-'})
</p> </p>
{isStore ? ( {isStore ? (
...@@ -114,7 +114,7 @@ export function PeriodModal({ ...@@ -114,7 +114,7 @@ export function PeriodModal({
}} }}
/> />
</div> </div>
<div className="uj-period-modal__quick"> <div className="uj-modal-form__quick">
<UButton size="small" onClick={() => applyQuick(0)}> <UButton size="small" onClick={() => applyQuick(0)}>
续7天 续7天
</UButton> </UButton>
...@@ -135,7 +135,7 @@ export function PeriodModal({ ...@@ -135,7 +135,7 @@ export function PeriodModal({
) : ( ) : (
<> <>
<URadio.Group <URadio.Group
className="uj-period-modal__radios" className="uj-modal-form__radios"
value={effectiveTime || undefined} value={effectiveTime || undefined}
onChange={(event) => setEffectiveTime(String(event.target.value))} onChange={(event) => setEffectiveTime(String(event.target.value))}
> >
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useQuery, useQueryClient } from '@tanstack/react-query'; import { useQuery, useQueryClient } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UModal, UExportIcon, useUMessage } from '@uj/ui'; import { UButton, UCard, UModal, UExportIcon, useUMessage } from '@uj/ui';
import { downloadCenter, goTo } from '@uj/platform-sdk'; import { downloadCenter, goTo } from '@uj/platform-sdk';
import { import {
DataTable, DataTable,
...@@ -25,6 +25,14 @@ import { ...@@ -25,6 +25,14 @@ import {
} from '@/hooks/useDictionaries'; } from '@/hooks/useDictionaries';
import { PeriodModal } from './PeriodModal'; import { PeriodModal } from './PeriodModal';
import { AccessModeModal } from './AccessModeModal'; import { AccessModeModal } from './AccessModeModal';
import {
FilterCard,
LoadErrorAlert,
labelOf,
useAuditColumns,
StatusMark,
statusTone,
} from '../shared';
type Filters = { type Filters = {
merchantName?: string; merchantName?: string;
...@@ -42,11 +50,6 @@ type Filters = { ...@@ -42,11 +50,6 @@ type Filters = {
isRelevance?: string; isRelevance?: string;
}; };
function labelOf(value: unknown, derived: unknown, map: Record<string, string>): string {
if (typeof derived === 'string' && derived) return derived;
return map[String(value ?? '')] ?? (value === undefined || value === '' ? '-' : String(value));
}
/** /**
* 行按钮可见性(源 index.html L890-951 超管分支):btn 是拿到列表后本地重算的, * 行按钮可见性(源 index.html L890-951 超管分支):btn 是拿到列表后本地重算的,
* 服务端同名字段被整体覆盖,因此这里同样只看行数据推导,不读 row.btn。 * 服务端同名字段被整体覆盖,因此这里同样只看行数据推导,不读 row.btn。
...@@ -235,14 +238,25 @@ export default function MerchantPage() { ...@@ -235,14 +238,25 @@ export default function MerchantPage() {
}, },
]; ];
const { showAudit, toggle: auditToggle } = useAuditColumns();
const columns: DataTableColumnsType<MerchantRow> = [ const columns: DataTableColumnsType<MerchantRow> = [
// 身份列固定:横滚到最右仍能认出这是哪一行。
{ title: '商户号', dataIndex: 'merchantNo', width: 160, fixed: 'left' },
{ title: '商户名称', dataIndex: 'merchantName', width: 220, line: 1, fixed: 'left' },
// 状态前置到第三列:台账里第一眼要看的是「能不能继续操作」。
{ {
title: '序号', title: '账户状态',
width: 64, dataIndex: 'statusName',
render: (_value, _row, index) => (page.current - 1) * page.size + index + 1, width: 110,
render: (value, row) => {
const status = String(row['status'] ?? '');
return (
<StatusMark tone={statusTone(status)}>
{labelOf(status, value, MERCHANT_STATUS_LABEL)}
</StatusMark>
);
},
}, },
{ title: '商户号', dataIndex: 'merchantNo', width: 160 },
{ title: '商户名称', dataIndex: 'merchantName', width: 220, line: 1 },
{ {
title: '模式', title: '模式',
dataIndex: 'merchantModelName', dataIndex: 'merchantModelName',
...@@ -259,19 +273,18 @@ export default function MerchantPage() { ...@@ -259,19 +273,18 @@ export default function MerchantPage() {
render: (value, row) => labelOf(row['merchantAccountLevel'], value, MERCHANT_LEVEL_LABEL), render: (value, row) => labelOf(row['merchantAccountLevel'], value, MERCHANT_LEVEL_LABEL),
}, },
{ title: '上级商户', dataIndex: 'parentMerchant', width: 180, line: 1 }, { title: '上级商户', dataIndex: 'parentMerchant', width: 180, line: 1 },
{
title: '账户状态',
dataIndex: 'statusName',
width: 110,
render: (value, row) => labelOf(row['status'], value, MERCHANT_STATUS_LABEL),
},
{ title: '联系人', dataIndex: 'merchantLegalPerson', width: 120 }, { title: '联系人', dataIndex: 'merchantLegalPerson', width: 120 },
{ title: '手机号', dataIndex: 'merchantLegalPersonPhone', width: 150 }, { title: '手机号', dataIndex: 'merchantLegalPersonPhone', width: 150 },
{ title: '关联的企业微信', dataIndex: 'entmicroName', width: 180, line: 1 }, { title: '关联的企业微信', dataIndex: 'entmicroName', width: 180, line: 1 },
{ title: '来源', dataIndex: 'createdSourceStr', width: 120 }, // 审计层默认收起,按需展开。
{ title: '创建人', dataIndex: 'createdAccount', width: 130 }, ...(showAudit
{ title: '创建时间', dataIndex: 'createdTime', width: 170 }, ? [
{ title: '更新时间', dataIndex: 'updatedTime', width: 170 }, { title: '来源', dataIndex: 'createdSourceStr', width: 120 },
{ title: '创建人', dataIndex: 'createdAccount', width: 130 },
{ title: '创建时间', dataIndex: 'createdTime', width: 170 },
{ title: '更新时间', dataIndex: 'updatedTime', width: 170 },
]
: []),
]; ];
const rowActions: RowActionSchema<MerchantRow>[] = [ const rowActions: RowActionSchema<MerchantRow>[] = [
...@@ -316,7 +329,7 @@ export default function MerchantPage() { ...@@ -316,7 +329,7 @@ export default function MerchantPage() {
return ( return (
<PageShell <PageShell
title="商户管理" title="商户管理"
description="查看商户档案、创建商户与子商户,维护有效期与企微接入模式。" description="查看商户档案、创建商户与子商户,维护有效期与企微接入模式"
fill fill
actions={ actions={
<> <>
...@@ -340,7 +353,7 @@ export default function MerchantPage() { ...@@ -340,7 +353,7 @@ export default function MerchantPage() {
</> </>
} }
> >
<UCard className="uj-filter-card" size="small"> <FilterCard>
<SearchForm <SearchForm
fields={fields} fields={fields}
initialValues={{ isRelevance: '0' }} initialValues={{ isRelevance: '0' }}
...@@ -353,26 +366,22 @@ export default function MerchantPage() { ...@@ -353,26 +366,22 @@ export default function MerchantPage() {
setPage({ current: pagination.current, size: pagination.size }); setPage({ current: pagination.current, size: pagination.size });
}} }}
/> />
</UCard> </FilterCard>
{list.isError ? ( {list.isError ? (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="商户列表加载失败" title="商户列表加载失败"
description={errorDetail(list.error)} description={errorDetail(list.error)}
action={ onRetry={() => void list.refetch()}
<UButton type="link" onClick={() => void list.refetch()}>
重试
</UButton>
}
/> />
) : null} ) : null}
<UCard size="small" fill> <UCard size="small" fill>
<DataTable <DataTable
fillHeight fillHeight
showIndex
rowKey={(row) => String(row.id ?? '')} rowKey={(row) => String(row.id ?? '')}
columns={columns} columns={columns}
rowActions={rowActions} rowActions={rowActions}
toolbarExtra={auditToggle}
loading={list.isPending || list.isFetching} loading={list.isPending || list.isFetching}
pageData={list.data as Record<string, unknown> | undefined} pageData={list.data as Record<string, unknown> | undefined}
recordsKey="list" recordsKey="list"
......
import { useQuery } from '@tanstack/react-query'; import { useQuery } from '@tanstack/react-query';
import { UAlert, UButton, UEmpty, UTabs } from '@uj/ui'; import { UButton, UEmpty } from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { PageShell } from '@/components'; import { PageShell } from '@/components';
import type { PageParams } from '../../../routes'; import type { PageParams } from '../../../routes';
...@@ -7,8 +7,16 @@ import { commonApi, roleApi } from '@/api'; ...@@ -7,8 +7,16 @@ import { commonApi, roleApi } from '@/api';
import { errorDetail } from '@/utils/error'; import { errorDetail } from '@/utils/error';
import { useMerchantAccess } from '@/adapter/access'; import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { nodeList, type AccountPerm } from '../../Merchant/Create/model'; import { type AccountPerm } from '../../Merchant/Create/model';
import { ReadOnlyPermTree } from '../../Merchant/Create/ui'; import {
DetailItem,
LoadErrorAlert,
ReadOnlyPermTabs,
IdentityBand,
StatusMark,
statusTone,
TaskSection,
} from '../../shared';
/** /**
* 角色详情二级页(源 temp/account/html/role/detail.html)。 * 角色详情二级页(源 temp/account/html/role/detail.html)。
...@@ -42,21 +50,11 @@ export default function RoleDetailPage({ params }: { params?: PageParams } = {}) ...@@ -42,21 +50,11 @@ export default function RoleDetailPage({ params }: { params?: PageParams } = {})
if (detailQuery.isPending) return <UEmpty description="正在读取角色详情…" />; if (detailQuery.isPending) return <UEmpty description="正在读取角色详情…" />;
if (detailQuery.isError || !detail) { if (detailQuery.isError || !detail) {
return ( return (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="角色详情加载失败" title="角色详情加载失败"
description={detailQuery.error ? errorDetail(detailQuery.error) : '角色不存在'} description={detailQuery.error ? errorDetail(detailQuery.error) : '角色不存在'}
action={ onRetry={() => void detailQuery.refetch()}
<> onBack={() => goTo('role')}
<UButton type="link" onClick={() => void detailQuery.refetch()}>
重试
</UButton>
<UButton type="link" onClick={() => goTo('role')}>
返回列表
</UButton>
</>
}
/> />
); );
} }
...@@ -69,68 +67,44 @@ export default function RoleDetailPage({ params }: { params?: PageParams } = {}) ...@@ -69,68 +67,44 @@ export default function RoleDetailPage({ params }: { params?: PageParams } = {})
<PageShell <PageShell
fill fill
title={`角色详情 · ${text(detail.roleName)}`} title={`角色详情 · ${text(detail.roleName)}`}
description="角色基本信息与已授权的功能权限;均为只读展示。" description="角色基本信息与已授权的功能权限;均为只读展示"
actions={ actions={
<UButton type="primary" onClick={() => goTo('role')}> <UButton type="primary" onClick={() => goTo('role')}>
关闭 关闭
</UButton> </UButton>
} }
> >
<IdentityBand
name={text(detail.roleName)}
status={
<StatusMark tone={statusTone(detail.delFlag)}>
{text(detail.statusName || (String(detail.delFlag) === '1' ? '草稿' : '正常'))}
</StatusMark>
}
fields={[
{ label: '角色号', value: text(detail.roleCode), mono: true },
{ label: '所属商户', value: merchantName },
]}
/>
<div className="uj-create-card uj-detail__body--scroll"> <div className="uj-create-card uj-detail__body--scroll">
<section className="uj-section"> <section className="uj-section">
<div className="uj-detail-title-row"> <TaskSection>角色标识</TaskSection>
<h3 className="uj-detail-title">角色基本信息</h3>
<span className="uj-detail-merchant" title={merchantName}>
{merchantName}
</span>
</div>
<dl className="uj-detail-grid"> <dl className="uj-detail-grid">
<DetailItem label="角色名称" value={text(detail.roleName)} /> <DetailItem empty="无" label="角色说明" value={text(detail.roleDescription)} />
<DetailItem label="角色号" value={text(detail.roleCode)} />
<DetailItem label="角色说明" value={text(detail.roleDescription)} />
</dl> </dl>
</section> </section>
<section className="uj-section"> <section className="uj-section">
<h3 className="uj-detail-title">角色权限</h3> <TaskSection>已授权权限</TaskSection>
{treeQuery.isPending ? ( <ReadOnlyPermTabs
<div className="uj-create-hint">权限树加载中…</div> accounts={permAccounts}
) : permAccounts.length ? ( loading={treeQuery.isPending}
<div className="uj-create-tabs"> loadingText="权限树加载中…"
<UTabs emptyText="暂无角色权限数据"
className="uj-tabs-uniform" />
items={permAccounts.map((account) => ({
key: String(account.accounttypeId),
label: account.accounttypeName ?? String(account.accounttypeId),
children: (account.products ?? []).length ? (
<UTabs
className="uj-tabs-uniform"
items={(account.products ?? []).map((product) => ({
key: String(product.productId),
label: product.productName ?? String(product.productId),
children: <ReadOnlyPermTree nodes={nodeList(product)} />,
}))}
/>
) : (
<div className="uj-create-hint">暂无产品</div>
),
}))}
/>
</div>
) : (
<div className="uj-create-hint">暂无角色权限数据</div>
)}
</section> </section>
</div> </div>
</PageShell> </PageShell>
); );
} }
function DetailItem({ label, value }: { label: string; value: string }) {
return (
<div className="uj-detail-item">
<dt>{label}</dt>
<dd title={value === '无' ? undefined : value}>{value}</dd>
</div>
);
}
...@@ -9,7 +9,6 @@ import { errorDetail } from '@/utils/error'; ...@@ -9,7 +9,6 @@ import { errorDetail } from '@/utils/error';
import { useMerchantAccess } from '@/adapter/access'; import { useMerchantAccess } from '@/adapter/access';
import { MC } from '@/permissions/codes'; import { MC } from '@/permissions/codes';
import { useMerchantOptions } from '@/hooks/useDictionaries'; import { useMerchantOptions } from '@/hooks/useDictionaries';
import { SectionTitle } from '../../Merchant/Create/ui';
import { import {
asArray, asArray,
buildRolePayload, buildRolePayload,
...@@ -19,6 +18,7 @@ import { ...@@ -19,6 +18,7 @@ import {
type RolePermSeed, type RolePermSeed,
} from '../model'; } from '../model';
import { RolePermForm, type RolePermFormHandle } from '../PermForm'; import { RolePermForm, type RolePermFormHandle } from '../PermForm';
import { FormFooter, REQUIRED, TaskSection } from '../../shared';
/** /**
* 角色创建/修改二级页(源 temp/account/html/role/add.html,按 URL id 区分两态)。 * 角色创建/修改二级页(源 temp/account/html/role/add.html,按 URL id 区分两态)。
...@@ -31,8 +31,6 @@ import { RolePermForm, type RolePermFormHandle } from '../PermForm'; ...@@ -31,8 +31,6 @@ import { RolePermForm, type RolePermFormHandle } from '../PermForm';
* 源「全选/取消全选」按钮在源里已注释、level4 登录态商户锁定分支属老 H5 嵌入态,均不复刻。 * 源「全选/取消全选」按钮在源里已注释、level4 登录态商户锁定分支属老 H5 嵌入态,均不复刻。
*/ */
const REQUIRED = { required: true, message: '必填项' };
export default function RoleFormPage({ params }: { params?: PageParams } = {}) { export default function RoleFormPage({ params }: { params?: PageParams } = {}) {
const roleId = params?.id; const roleId = params?.id;
const mode: 'create' | 'edit' = roleId ? 'edit' : 'create'; const mode: 'create' | 'edit' = roleId ? 'edit' : 'create';
...@@ -154,7 +152,7 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) { ...@@ -154,7 +152,7 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) {
return ( return (
<PageShell <PageShell
title={mode === 'edit' ? '修改角色' : '创建角色'} title={mode === 'edit' ? '修改角色' : '创建角色'}
description="角色归属商户与功能权限在此维护;保存后返回角色列表。" description="角色归属商户与功能权限在此维护;保存后返回角色列表"
> >
<div className="uj-create-card"> <div className="uj-create-card">
<UForm <UForm
...@@ -165,9 +163,7 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) { ...@@ -165,9 +163,7 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) {
labelAlign="left" labelAlign="left"
> >
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="01" description="商户归属与角色标识"> <TaskSection>角色基本信息</TaskSection>
角色基本信息
</SectionTitle>
{mode === 'edit' ? ( {mode === 'edit' ? (
<> <>
<UFormItem label="所属商户" required> <UFormItem label="所属商户" required>
...@@ -201,24 +197,21 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) { ...@@ -201,24 +197,21 @@ export default function RoleFormPage({ params }: { params?: PageParams } = {}) {
</section> </section>
<section className="uj-section"> <section className="uj-section">
<SectionTitle index="02" description="按账户类型勾选产品与功能菜单"> <TaskSection>角色权限</TaskSection>
角色权限
</SectionTitle>
{permBody} {permBody}
</section> </section>
</UForm> </UForm>
<div className="uj-create-footer"> <FormFooter onCancel={() => goTo('role')}>
<UButton onClick={() => goTo('role')}>取消</UButton>
{mode === 'create' ? ( {mode === 'create' ? (
<UButton loading={save.isPending} onClick={saveDraft}> <UButton type="text" loading={save.isPending} onClick={saveDraft}>
存草稿 存草稿
</UButton> </UButton>
) : null} ) : null}
<UButton type="primary" loading={save.isPending} onClick={() => void submit()}> <UButton type="primary" loading={save.isPending} onClick={() => void submit()}>
确定 确定
</UButton> </UButton>
</div> </FormFooter>
</div> </div>
</PageShell> </PageShell>
); );
......
import { useMemo, useState } from 'react'; import { useMemo, useState } from 'react';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'; import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { UAlert, UButton, UCard, UTooltip, useUMessage } from '@uj/ui'; import { UButton, UCard, UInfoIcon, UTooltip, useUMessage } from '@uj/ui';
import { goTo } from '@uj/platform-sdk'; import { goTo } from '@uj/platform-sdk';
import { import {
ConfirmModal, ConfirmModal,
...@@ -18,6 +18,7 @@ import { MC } from '@/permissions/codes'; ...@@ -18,6 +18,7 @@ import { MC } from '@/permissions/codes';
import { roleApi } from '@/api'; import { roleApi } from '@/api';
import type { RoleRow } from '@/api'; import type { RoleRow } from '@/api';
import { DEL_FLAG_LABEL, useMerchantOptions } from '@/hooks/useDictionaries'; import { DEL_FLAG_LABEL, useMerchantOptions } from '@/hooks/useDictionaries';
import { FilterCard, LoadErrorAlert, StatusMark, statusTone } from '../shared';
/** /**
* 角色列表(源 temp/account/html/role/index.html,非 level4 分支口径)。 * 角色列表(源 temp/account/html/role/index.html,非 level4 分支口径)。
...@@ -45,7 +46,7 @@ function RoleNameCell({ row }: { row: RoleRow }) { ...@@ -45,7 +46,7 @@ function RoleNameCell({ row }: { row: RoleRow }) {
{tip ? ( {tip ? (
<UTooltip title={tip}> <UTooltip title={tip}>
<span className="uj-role-name__tip" aria-label="角色说明"> <span className="uj-role-name__tip" aria-label="角色说明">
ⓘ <UInfoIcon />
</span> </span>
</UTooltip> </UTooltip>
) : null} ) : null}
...@@ -109,16 +110,25 @@ export default function RolePage() { ...@@ -109,16 +110,25 @@ export default function RolePage() {
title: '角色名称', title: '角色名称',
dataIndex: 'roleName', dataIndex: 'roleName',
width: 200, width: 200,
fixed: 'left',
render: (_v, row) => <RoleNameCell row={row} />, render: (_v, row) => <RoleNameCell row={row} />,
}, },
{ title: '角色号', dataIndex: 'roleCode', width: 160 },
{ title: '所属商户名', dataIndex: 'merchantName', width: 220, line: 1 },
{ {
title: '状态', title: '状态',
dataIndex: 'statusName', dataIndex: 'statusName',
width: 110, width: 110,
render: (value, row) => value || DEL_FLAG_LABEL[String(row.delFlag ?? '')] || '-', fixed: 'left',
render: (value, row) => {
const delFlag = String(row.delFlag ?? '');
return (
<StatusMark tone={statusTone(delFlag)}>
{value || DEL_FLAG_LABEL[delFlag] || '-'}
</StatusMark>
);
},
}, },
{ title: '角色号', dataIndex: 'roleCode', width: 160 },
{ title: '所属商户名', dataIndex: 'merchantName', width: 220, line: 1 },
{ title: '更新时间', dataIndex: 'updatedTime', width: 170 }, { title: '更新时间', dataIndex: 'updatedTime', width: 170 },
]; ];
...@@ -146,7 +156,7 @@ export default function RolePage() { ...@@ -146,7 +156,7 @@ export default function RolePage() {
return ( return (
<PageShell <PageShell
title="角色管理" title="角色管理"
description="按商户维护角色及角色权限,支持草稿与发布状态。" description="按商户维护角色及角色权限,支持草稿与发布状态"
fill fill
actions={ actions={
can(MC.ROLE_CREATE) ? ( can(MC.ROLE_CREATE) ? (
...@@ -156,7 +166,7 @@ export default function RolePage() { ...@@ -156,7 +166,7 @@ export default function RolePage() {
) : null ) : null
} }
> >
<UCard className="uj-filter-card" size="small"> <FilterCard>
<SearchForm <SearchForm
fields={fields} fields={fields}
onSearch={(values, pagination) => { onSearch={(values, pagination) => {
...@@ -168,18 +178,12 @@ export default function RolePage() { ...@@ -168,18 +178,12 @@ export default function RolePage() {
setPage({ current: pagination.current, size: pagination.size }); setPage({ current: pagination.current, size: pagination.size });
}} }}
/> />
</UCard> </FilterCard>
{list.isError ? ( {list.isError ? (
<UAlert <LoadErrorAlert
type="error"
showIcon
title="角色列表加载失败" title="角色列表加载失败"
description={errorDetail(list.error)} description={errorDetail(list.error)}
action={ onRetry={() => void list.refetch()}
<UButton type="link" onClick={() => void list.refetch()}>
重试
</UButton>
}
/> />
) : null} ) : null}
<UCard size="small" fill> <UCard size="small" fill>
......
import type { StatusTone } from './identity';
/** 员工 / 角色表单共用,避免两份重复的必填规则。 */
export const REQUIRED = { required: true, message: '必填项' };
/** 商户状态 1-草稿 2-正常 3-注销 4-过期;员工状态 0-启用 2-停用;角色 delFlag 0-正常 1-草稿。 */
export function statusTone(value: unknown): StatusTone {
const key = String(value ?? '');
if (key === '2' || key === '0') return 'positive';
if (key === '1') return 'pending';
return 'muted';
}
import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { UCard, UTabs } from '@uj/ui';
import { DataTable } from '@/components';
import { merchantApi } from '@/api';
import { asArray, nodeList, type AccountPerm } from '../Merchant/Create/model';
import { ReadOnlyPermTree } from '../Merchant/Create/ui';
/**
* 三个详情页(商户 / 员工 / 角色)共用的只读展示零件。
*
* 空值占位按源口径分两派:商户详情 '-',员工与角色详情 '无'。由 empty 参数传入,
* 不在组件里猜,也不把源文案统一掉。
*/
export function DetailItem({
label,
value,
empty = '-',
}: {
label: string;
value: string;
empty?: string;
}) {
return (
<div className="uj-detail-item">
<dt>{label}</dt>
<dd title={value === empty ? undefined : value}>{value}</dd>
</div>
);
}
/** 账户类型 tab → 产品 tab → 只读权限树,三处详情逐字同构。 */
export function ReadOnlyPermTabs({
accounts,
loading = false,
loadingText = '权限树加载中…',
emptyText = '暂无功能权限数据',
}: {
accounts: AccountPerm[];
loading?: boolean;
loadingText?: string;
emptyText?: string;
}) {
if (loading) return <div className="uj-create-hint">{loadingText}</div>;
if (!accounts.length) return <div className="uj-create-hint">{emptyText}</div>;
return (
<div className="uj-create-tabs">
<UTabs
className="uj-tabs-uniform"
items={accounts.map((account) => ({
key: String(account.accounttypeId),
label: account.accounttypeName ?? String(account.accounttypeId),
children: (account.products ?? []).length ? (
<UTabs
className="uj-tabs-uniform"
items={(account.products ?? []).map((product) => ({
key: String(product.productId),
label: product.productName ?? String(product.productId),
children: <ReadOnlyPermTree nodes={nodeList(product)} />,
}))}
/>
) : (
<div className="uj-create-hint">暂无产品</div>
),
}))}
/>
</div>
);
}
/**
* 修改记录 tab。商户详情与员工详情原本是两份逐字相同的实现,
* 差异只有 queryKey / bussinessId / moduleName 三个入参。
*/
export function LogTab({
queryKey,
bussinessId,
moduleName,
}: {
queryKey: string;
bussinessId: string;
moduleName: string;
}) {
const [page, setPage] = useState({ current: 1, size: 10 });
const logQuery = useQuery({
queryKey: ['merchant', queryKey, bussinessId, page],
queryFn: () =>
merchantApi.findLog({
bussinessId,
moduleName,
pageNum: page.current,
pageSize: page.size,
}),
enabled: Boolean(bussinessId),
});
const wrapped = (logQuery.data ?? {}) as Record<string, unknown>;
// 分页信封在网关归一后行数组落在 list;兼容尚未改名的旧形状(data 或裸数组)。
const rows = asArray<Record<string, unknown>>(wrapped.list ?? wrapped.data ?? logQuery.data);
const total = Number(wrapped.total ?? wrapped.count ?? rows.length);
return (
<UCard size="small" fill>
<DataTable<Record<string, unknown>>
fillHeight
rowKey={(row) => String(row.id ?? Math.random())}
loading={logQuery.isFetching}
dataSource={rows.map((row, index) => ({
...row,
index: (page.current - 1) * page.size + index + 1,
modifyContent: `${String(row.module ?? '')}-${String(row.action ?? '')}`,
}))}
pagination={{
current: page.current,
pageSize: page.size,
total,
showSizeChanger: false,
onChange: (current: number, size: number) => setPage({ current, size }),
}}
columns={[
{ title: '序号', dataIndex: 'index', width: 64 },
{ title: '登录账户', dataIndex: 'operator' },
{ title: '登录产品', dataIndex: 'productName', width: 180 },
{ title: '登录IP', dataIndex: 'ip', width: 180 },
{ title: '修改内容', dataIndex: 'modifyContent', width: 200 },
{ title: '操作人', dataIndex: 'userName', width: 160 },
{ title: '操作时间', dataIndex: 'createdTime', width: 190 },
]}
/>
</UCard>
);
}
import type { ReactNode } from 'react';
import { UButton, UModal } from '@uj/ui';
/** 长表单底部操作栏:取消固定在最左,其余动作由调用方按业务顺序给。 */
export function FormFooter({ onCancel, children }: { onCancel: () => void; children: ReactNode }) {
return (
<div className="uj-create-footer">
<UButton type="text" onClick={onCancel}>
取消
</UButton>
{children}
</div>
);
}
/** 创建与编辑共用的重名继续确认;提示文案按源逐字保留。 */
export function DuplicateNameModal({
open,
onCancel,
onConfirm,
}: {
open: boolean;
onCancel: () => void;
onConfirm: () => void;
}) {
return (
<UModal
title="提示"
open={open}
okText="确定"
cancelText="取消"
onCancel={onCancel}
onOk={onConfirm}
>
<p>商户名称已经被使用,是否确定继续使用</p>
</UModal>
);
}
import type { ReactNode } from 'react';
/**
* 状态呈现:小圆点 + 文字,不用彩色 pill。
*
* 只认三种语义:正常/启用(positive)、草稿(pending)、停用/注销/过期(muted)。
* 状态的第一作用是「能不能继续操作」,不是给表格加颜色;颜色只做第二重提示。
*/
export type StatusTone = 'positive' | 'pending' | 'muted';
export function StatusMark({ tone, children }: { tone: StatusTone; children: ReactNode }) {
return (
<span className="uj-status-mark">
<span className={`uj-status-mark__dot uj-status-mark__dot--${tone}`} aria-hidden="true" />
{children}
</span>
);
}
export interface IdentityField {
label: string;
value: ReactNode;
/** 等宽呈现,用于编号、商户号这类需要逐位辨认的值。 */
mono?: boolean;
}
/**
* 详情页身份带:名称 + 编号 + 状态 + 等级,一行读完。
*
* 三个详情页共用同一结构,字段由调用方按业务给:商户给商户号/等级/有效期,
* 员工给手机号/角色/所属商户,角色给角色号/所属商户/状态。
* 只有第一项会用强调样式,其余等权 —— 避免把 dl 的平铺问题搬进页头。
*/
export function IdentityBand({
name,
fields,
status,
}: {
name: ReactNode;
fields: IdentityField[];
status?: ReactNode;
}) {
return (
<div className="uj-identity-band">
<div className="uj-identity-band__name">{name}</div>
{status ? <div className="uj-identity-band__status">{status}</div> : null}
<dl className="uj-identity-band__fields">
{fields.map((field) => (
<div className="uj-identity-band__field" key={field.label}>
<dt>{field.label}</dt>
<dd className={field.mono ? 'is-mono' : undefined}>{field.value}</dd>
</div>
))}
</dl>
</div>
);
}
/**
* 任务分区标题:只留标题 + 一条分割线。
*
* 取代 SectionTitle 的 index 徽章与 description。创建商户外层已有两步 steps,
* 内层再 01/02 是双重编号;Role/PermForm 甚至出现两个 02。
* 分区靠标题本身说清任务,不靠编号。
*/
export function TaskSection({ children }: { children: ReactNode }) {
return <h3 className="uj-task-section">{children}</h3>;
}
export { FilterCard, LoadErrorAlert, useAuditColumns } from './list';
export { DetailItem, ReadOnlyPermTabs, LogTab } from './detail';
export { FormFooter, DuplicateNameModal } from './form';
export { REQUIRED, statusTone } from './constants';
export { labelOf } from './util';
export { StatusMark, IdentityBand, TaskSection } from './identity';
export type { StatusTone, IdentityField } from './identity';
import { useState, type ReactNode } from 'react';
import { UAlert, UButton, UCard } from '@uj/ui';
/**
* 商户子应用内部共用的列表页零件。
*
* 只收口「三个列表页逐字重复」的那一层:筛选卡、加载失败条、字典标签回退。
* 表格本身由 @/components 的 DataTable 负责,这里不再包一层,避免把列配置、
* 分页、工具栏的口子收窄。
*/
export function FilterCard({ children }: { children: ReactNode }) {
return (
<UCard className="uj-filter-card" size="small">
{children}
</UCard>
);
}
/** 审计列(创建人/时间/来源)默认收起,需要时由用户显式展开。 */
// eslint-disable-next-line react-refresh/only-export-components
export function useAuditColumns() {
const [showAudit, setShowAudit] = useState(false);
const toggle = (
<UButton type="link" size="small" onClick={() => setShowAudit((value) => !value)}>
{showAudit ? '收起审计信息' : '显示审计信息'}
</UButton>
);
return { showAudit, toggle };
}
/** 三个列表页 + 详情页 + 编辑页共用的加载失败条。onBack 缺省时只有「重试」。 */
export function LoadErrorAlert({
title,
description,
onRetry,
onBack,
}: {
title: string;
description: ReactNode;
onRetry: () => void;
onBack?: () => void;
}) {
return (
<UAlert
type="error"
showIcon
title={title}
description={description}
action={
<>
<UButton type="link" onClick={onRetry}>
重试
</UButton>
{onBack ? (
<UButton type="link" onClick={onBack}>
返回列表
</UButton>
) : null}
</>
}
/>
);
}
/** 字典回显:后端给的 derivedName 优先,其次本地枚举,最后原值/占位。 */
export function labelOf(value: unknown, derived: unknown, map: Record<string, string>): string {
if (typeof derived === 'string' && derived) return derived;
return map[String(value ?? '')] ?? (value === undefined || value === '' ? '-' : String(value));
}
...@@ -27,6 +27,15 @@ export type { UButtonProps } from './components/Button'; ...@@ -27,6 +27,15 @@ export type { UButtonProps } from './components/Button';
// 各列表页不再各自 import 图标,保证全站导出按钮外观一致。 // 各列表页不再各自 import 图标,保证全站导出按钮外观一致。
export { DownloadOutlined as UExportIcon } from '@ant-design/icons'; export { DownloadOutlined as UExportIcon } from '@ant-design/icons';
// 结构性字形图标统一从这一组取:同一套 outlined 笔画、统一继承文字色。
// 页面里不再用 ✓ / + / × / ⓘ 这类字符当图标(字形宽度随字体漂移,也不随文字色走)。
export {
CheckOutlined as UCheckIcon,
CloseOutlined as UCloseIcon,
InfoCircleOutlined as UInfoIcon,
PlusOutlined as UPlusIcon,
} from '@ant-design/icons';
export { UInput } from './components/Input'; export { UInput } from './components/Input';
export type { UInputProps } from './components/Input'; export type { UInputProps } from './components/Input';
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!