Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
ujia
/
uj-store
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit bfc7e751
authored
Oct 10, 2026
by
liimin
Browse Files
Options
Browse Files
Tag
Download
Plain Diff
Merge branch 'v1.0.0' of
http://192.168.3.233:8090/ujia/uj-store
into v1.0.0
2 parents
f379044c
11cf705b
Pipeline
#320
for
bfc7e751
failed
in 0 seconds
Changes
8
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
64 additions
and
87 deletions
src/api/modules/role.ts
src/components/CombiForm/index.tsx
src/components/formSchema.ts
src/pages/AccountManage/components/AccountModal.tsx
src/pages/RoleManage/components/RoleModal.tsx
src/pages/RoleManage/index.tsx
src/pages/StoreApprove/index.tsx
src/pages/StoreListing/index.tsx
src/api/modules/role.ts
View file @
bfc7e75
...
@@ -23,7 +23,7 @@ export interface RolePageItem {
...
@@ -23,7 +23,7 @@ export interface RolePageItem {
roleName
:
string
;
roleName
:
string
;
roleCode
:
string
;
roleCode
:
string
;
defaultDataScope
:
number
;
defaultDataScope
:
number
;
account
Count
:
number
;
user
Count
:
number
;
description
?:
string
;
description
?:
string
;
isBuiltin
:
number
;
isBuiltin
:
number
;
status
:
number
;
status
:
number
;
...
...
src/components/CombiForm/index.tsx
View file @
bfc7e75
...
@@ -61,19 +61,38 @@ export function CombiForm<T extends Record<string, unknown>>({
...
@@ -61,19 +61,38 @@ export function CombiForm<T extends Record<string, unknown>>({
[],
[],
);
);
const defaultControl = (field: FieldSchema<T>) => {
const defaultControl = (field: FieldSchema<T>) => {
const disabled = typeof field.disabled === 'function' ? field.disabled(data) : field.disabled;
if (field.type === 'cascader')
if (field.type === 'cascader')
return <UCascader options={field.options} style={{ width: '100%' }} />;
return (
<UCascader
options={field.options}
disabled={disabled}
style={{ width: '100%' }}
{...field.cascaderProps}
/>
);
if (field.type === 'select' || field.type === 'selectMultiple')
if (field.type === 'select' || field.type === 'selectMultiple')
return (
return (
<USelect
<USelect
options={field.options}
options={field.options}
mode={field.type === 'selectMultiple' ? 'multiple' : undefined}
mode={field.type === 'selectMultiple' ? 'multiple' : undefined}
disabled={disabled}
style={{ width: '100%' }}
style={{ width: '100%' }}
{...field.selectProps}
/>
/>
);
);
if (field.type === 'switch') return <USwitch />;
if (field.type === 'switch') return <USwitch disabled={disabled} />;
if (field.type === 'textarea') return <UInput.TextArea placeholder={inputPlaceholder(field)} />;
if (field.type === 'textarea')
return <UInput placeholder={inputPlaceholder(field)} />;
return (
<UInput.TextArea
disabled={disabled}
placeholder={inputPlaceholder(field)}
{...field.textareaProps}
/>
);
return (
<UInput disabled={disabled} placeholder={inputPlaceholder(field)} {...field.inputProps} />
);
};
};
return (
return (
<UForm
<UForm
...
@@ -94,6 +113,7 @@ export function CombiForm<T extends Record<string, unknown>>({
...
@@ -94,6 +113,7 @@ export function CombiForm<T extends Record<string, unknown>>({
label={field.label}
label={field.label}
rules={field.rules}
rules={field.rules}
style={field.itemStyle}
style={field.itemStyle}
normalize={field.normalize}
>
>
{renderControl?.(field, form, data) ?? defaultControl(field)}
{renderControl?.(field, form, data) ?? defaultControl(field)}
</UFormItem>
</UFormItem>
...
...
src/components/formSchema.ts
View file @
bfc7e75
import
type
{
CSSProperties
,
ReactNode
}
from
'react'
;
import
type
{
CSSProperties
,
ReactNode
}
from
'react'
;
import
type
{
ButtonProps
}
from
'antd'
;
import
type
{
ButtonProps
,
CascaderProps
,
FormItemProps
,
InputProps
,
SelectProps
}
from
'antd'
;
import
type
{
TextAreaProps
}
from
'antd/es/input'
;
import
type
{
Rule
}
from
'antd/es/form'
;
import
type
{
Rule
}
from
'antd/es/form'
;
export
type
FieldType
=
export
type
FieldType
=
...
@@ -27,6 +28,16 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
...
@@ -27,6 +28,16 @@ export interface FieldSchema<T extends Record<string, unknown> = Record<string,
rules
?:
Rule
[];
rules
?:
Rule
[];
section
?:
string
;
section
?:
string
;
itemStyle
?:
CSSProperties
;
itemStyle
?:
CSSProperties
;
/** input 类型的扩展属性,如最大长度、数字键盘等。 */
inputProps
?:
InputProps
;
/** textarea 类型的扩展属性。 */
textareaProps
?:
TextAreaProps
;
/** select 类型的扩展属性。 */
selectProps
?:
SelectProps
;
/** cascader 类型的扩展属性,选项统一由 options 提供。 */
cascaderProps
?:
Omit
<
CascaderProps
,
'options'
|
'multiple'
>
;
/** 表单值标准化处理,例如手机号仅保留数字。 */
normalize
?:
FormItemProps
[
'normalize'
];
hidden
?:
boolean
|
((
values
:
T
)
=>
boolean
);
hidden
?:
boolean
|
((
values
:
T
)
=>
boolean
);
disabled
?:
boolean
|
((
values
:
T
)
=>
boolean
);
disabled
?:
boolean
|
((
values
:
T
)
=>
boolean
);
render
?:
(
value
:
unknown
,
values
:
T
)
=>
ReactNode
;
render
?:
(
value
:
unknown
,
values
:
T
)
=>
ReactNode
;
...
...
src/pages/AccountManage/components/AccountModal.tsx
View file @
bfc7e75
import { useEffect } from 'react';
import { useEffect } from 'react';
import { message } from 'antd';
import { message } from 'antd';
import { useMutation } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';
import { UButton, U
Cascader, UForm, UInput, UModal, USelect
} from '@uj/ui';
import { UButton, U
Form, UModal
} from '@uj/ui';
import { user, type OrgNode, type RoleOption, type UserPageItem } from '@/api';
import { user, type OrgNode, type RoleOption, type UserPageItem } from '@/api';
import { CombiForm, type FieldSchema } from '@/components';
import { CombiForm, type FieldSchema } from '@/components';
import { dataScopeOptions } from '@/constants/dataScope';
import { dataScopeOptions } from '@/constants/dataScope';
...
@@ -86,6 +86,8 @@ export function AccountModal({
...
@@ -86,6 +86,8 @@ export function AccountModal({
label: '账号',
label: '账号',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
disabled: isEdit,
inputProps: { maxLength: 20 },
rules: [
rules: [
{ required: true, message: '请输入账号' },
{ required: true, message: '请输入账号' },
{ min: 1, max: 20, message: '账号长度为 1-20 个字符' },
{ min: 1, max: 20, message: '账号长度为 1-20 个字符' },
...
@@ -96,6 +98,7 @@ export function AccountModal({
...
@@ -96,6 +98,7 @@ export function AccountModal({
label: '姓名',
label: '姓名',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
inputProps: { maxLength: 20 },
rules: [
rules: [
{ required: true, message: '请输入姓名' },
{ required: true, message: '请输入姓名' },
{ min: 1, max: 20, message: '姓名长度为 1-20 个字符' },
{ min: 1, max: 20, message: '姓名长度为 1-20 个字符' },
...
@@ -106,6 +109,8 @@ export function AccountModal({
...
@@ -106,6 +109,8 @@ export function AccountModal({
label: '手机号',
label: '手机号',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
inputProps: { inputMode: 'numeric', maxLength: 11 },
normalize: (value) => (typeof value === 'string' ? value.replace(/\D/g, '') : value),
rules: [
rules: [
{ required: true, message: '请输入手机号' },
{ required: true, message: '请输入手机号' },
{ pattern: /^1\d{10}$/, message: '请输入正确的 11 位手机号' },
{ pattern: /^1\d{10}$/, message: '请输入正确的 11 位手机号' },
...
@@ -123,6 +128,8 @@ export function AccountModal({
...
@@ -123,6 +128,8 @@ export function AccountModal({
label: '所属组织',
label: '所属组织',
type: 'cascader',
type: 'cascader',
section: '组织归属',
section: '组织归属',
options: toOrgCascaderOptions(orgTree),
cascaderProps: { changeOnSelect: true, showSearch: true },
rules: [{ required: true, message: '请选择所属组织' }],
rules: [{ required: true, message: '请选择所属组织' }],
},
},
{
{
...
@@ -164,45 +171,6 @@ export function AccountModal({
...
@@ -164,45 +171,6 @@ export function AccountModal({
sectionContentStyle={twoColumnStyle}
sectionContentStyle={twoColumnStyle}
renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>}
renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>}
renderControl={(field) => {
renderControl={(field) => {
if (field.name === 'account')
return (
<UInput disabled={isEdit} maxLength={20} placeholder="请输入登录账号" size="small" />
);
if (field.name === 'name')
return <UInput maxLength={20} placeholder="请输入姓名" size="small" />;
if (field.name === 'mobile')
return (
<UInput
inputMode="numeric"
maxLength={11}
placeholder="请输入手机号"
size="small"
onChange={(event) =>
form.setFieldValue('mobile', event.target.value.replace(/\D/g, ''))
}
/>
);
if (field.name === 'email') return <UInput placeholder="选填" size="small" />;
if (field.name === 'orgPath')
return (
<UCascader
options={toOrgCascaderOptions(orgTree)}
changeOnSelect
placeholder="请选择所属组织"
showSearch
size="small"
style={{ width: '100%' }}
/>
);
if (field.name === 'dataScope')
return (
<USelect
options={dataScopeOptions}
placeholder="请选择数据域"
size="small"
style={{ width: '100%' }}
/>
);
if (field.name === 'roleIds')
if (field.name === 'roleIds')
return (
return (
<div style={roleListStyle}>
<div style={roleListStyle}>
...
@@ -210,7 +178,6 @@ export function AccountModal({
...
@@ -210,7 +178,6 @@ export function AccountModal({
<UButton
<UButton
key={item.roleId}
key={item.roleId}
type={selectedRoleIds.includes(item.roleId) ? 'primary' : 'default'}
type={selectedRoleIds.includes(item.roleId) ? 'primary' : 'default'}
size="small"
style={roleOptionStyle}
style={roleOptionStyle}
onClick={() => {
onClick={() => {
const nextRoleIds = selectedRoleIds.includes(item.roleId)
const nextRoleIds = selectedRoleIds.includes(item.roleId)
...
...
src/pages/RoleManage/components/RoleModal.tsx
View file @
bfc7e75
import { useEffect } from 'react';
import { useEffect } from 'react';
import { message } from 'antd';
import { message } from 'antd';
import { useMutation } from '@tanstack/react-query';
import { useMutation } from '@tanstack/react-query';
import { UForm, U
Input, UModal, USelect
} from '@uj/ui';
import { UForm, U
Modal
} from '@uj/ui';
import { role, type RolePageItem } from '@/api';
import { role, type RolePageItem } from '@/api';
import { CombiForm, type FieldSchema } from '@/components';
import { CombiForm, type FieldSchema } from '@/components';
import { dataScopeOptions } from '@/constants/dataScope';
import { dataScopeOptions } from '@/constants/dataScope';
...
@@ -68,6 +68,7 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
...
@@ -68,6 +68,7 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
label: '角色名称',
label: '角色名称',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
inputProps: { maxLength: 20 },
rules: [
rules: [
{ required: true, message: '请输入角色名称' },
{ required: true, message: '请输入角色名称' },
{ max: 20, message: '角色名称不能超过 20 个字符' },
{ max: 20, message: '角色名称不能超过 20 个字符' },
...
@@ -78,6 +79,9 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
...
@@ -78,6 +79,9 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
label: '角色编码',
label: '角色编码',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
disabled: isEdit,
inputProps: { maxLength: 50 },
placeholder: '例如:REGION_OPS',
rules: [
rules: [
{ required: true, message: '请输入角色编码' },
{ required: true, message: '请输入角色编码' },
{ pattern: /^[A-Z0-9_]+$/, message: '仅支持大写字母、数字和下划线' },
{ pattern: /^[A-Z0-9_]+$/, message: '仅支持大写字母、数字和下划线' },
...
@@ -88,15 +92,25 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
...
@@ -88,15 +92,25 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
label: '显示排序',
label: '显示排序',
type: 'input',
type: 'input',
section: '基本信息',
section: '基本信息',
inputProps: { inputMode: 'numeric' },
rules: [{ pattern: /^\d+$/, message: '请输入整数' }],
rules: [{ pattern: /^\d+$/, message: '请输入整数' }],
},
},
{ name: 'status', label: '状态', type: 'select', section: '基本信息', options: statusOptions },
{
name: 'status',
label: '状态',
type: 'select',
section: '基本信息',
options: statusOptions,
selectProps: { allowClear: false },
},
{
{
name: 'description',
name: 'description',
label: '角色描述',
label: '角色描述',
type: 'textarea',
type: 'textarea',
section: '基本信息',
section: '基本信息',
itemStyle: { gridColumn: '1 / -1' },
itemStyle: { gridColumn: '1 / -1' },
textareaProps: { maxLength: 200, rows: 2 },
placeholder: '选填,用于说明角色的职责边界',
rules: [{ max: 200, message: '角色描述不能超过 200 个字符' }],
rules: [{ max: 200, message: '角色描述不能超过 200 个字符' }],
},
},
{
{
...
@@ -130,39 +144,6 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
...
@@ -130,39 +144,6 @@ export function RoleModal({ open, roleItem, onCancel, onSuccess }: RoleModalProp
onSubmit={(values) => saveMutation.mutate(values)}
onSubmit={(values) => saveMutation.mutate(values)}
sectionContentStyle={twoColumnStyle}
sectionContentStyle={twoColumnStyle}
renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>}
renderSectionTitle={(title) => <SectionTitle>{title}</SectionTitle>}
renderControl={(field) => {
if (field.name === 'roleName') return <UInput maxLength={20} size="small" />;
if (field.name === 'roleCode')
return (
<UInput
disabled={isEdit}
maxLength={50}
placeholder="例如:REGION_OPS"
size="small"
/>
);
if (field.name === 'sort') return <UInput inputMode="numeric" size="small" />;
if (field.name === 'status')
return (
<USelect
options={statusOptions}
allowClear={false}
size="small"
style={{ width: '100%' }}
/>
);
if (field.name === 'description')
return (
<UInput.TextArea
maxLength={200}
placeholder="选填,用于说明角色的职责边界"
rows={2}
/>
);
if (field.name === 'defaultDataScope')
return <USelect options={dataScopeOptions} size="small" style={{ width: '100%' }} />;
return undefined;
}}
/>
/>
</UModal>
</UModal>
);
);
...
...
src/pages/RoleManage/index.tsx
View file @
bfc7e75
...
@@ -21,7 +21,7 @@ interface Row {
...
@@ -21,7 +21,7 @@ interface Row {
name: string;
name: string;
code: string;
code: string;
scope: string;
scope: string;
accounts
: number;
userCount
: number;
description: string;
description: string;
type: string;
type: string;
status?: number;
status?: number;
...
@@ -66,7 +66,7 @@ export default function RoleManage() {
...
@@ -66,7 +66,7 @@ export default function RoleManage() {
name: item.roleName,
name: item.roleName,
code: item.roleCode,
code: item.roleCode,
scope: getDataScopeLabel(item.defaultDataScope),
scope: getDataScopeLabel(item.defaultDataScope),
accounts: item.account
Count,
userCount: item.user
Count,
description: item.description ?? '—',
description: item.description ?? '—',
type: item.isBuiltin === 1 ? '内置' : '自定义',
type: item.isBuiltin === 1 ? '内置' : '自定义',
status: item.status,
status: item.status,
...
@@ -104,7 +104,7 @@ export default function RoleManage() {
...
@@ -104,7 +104,7 @@ export default function RoleManage() {
render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>,
render: (v) => <UText style={{ color: '#315ce8', fontFamily: 'monospace' }}>{v}</UText>,
},
},
{ title: '默认数据域', dataIndex: 'scope', width: 130 },
{ title: '默认数据域', dataIndex: 'scope', width: 130 },
{ title: '账号数', dataIndex: '
accounts', width: 90, align: 'right'
},
{ title: '账号数', dataIndex: '
userCount', width: 90
},
{ title: '角色描述', dataIndex: 'description' },
{ title: '角色描述', dataIndex: 'description' },
{
{
title: '类型',
title: '类型',
...
...
src/pages/StoreApprove/index.tsx
View file @
bfc7e75
...
@@ -293,7 +293,6 @@ export default function StoreApprove() {
...
@@ -293,7 +293,6 @@ export default function StoreApprove() {
onSearch={changeQuery}
onSearch={changeQuery}
onReset={() => changeQuery({})}
onReset={() => changeQuery({})}
/>
/>
<UText type="secondary">数据可见范围:{dataScope}</UText>
</UCard>
</UCard>
{list.isError ? (
{list.isError ? (
<UAlert
<UAlert
...
...
src/pages/StoreListing/index.tsx
View file @
bfc7e75
...
@@ -222,7 +222,6 @@ export default function StoreListing() {
...
@@ -222,7 +222,6 @@ export default function StoreListing() {
if (!exportFile.isPending) exportFile.reset();
if (!exportFile.isPending) exportFile.reset();
}}
}}
/>
/>
<UText type="secondary">数据可见范围:{scopeLabel}</UText>
</UCard>
</UCard>
{listing.error ? (
{listing.error ? (
<UAlert
<UAlert
...
...
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment