fix: use standard picker for user selection
This commit is contained in:
@@ -89,7 +89,7 @@ export function AmisRenderer({ schema }: AmisRendererProps) {
|
||||
// amis-core 未暴露 registerAction 时静默降级(onEvent 重放不可用,不阻断渲染)
|
||||
}
|
||||
try {
|
||||
registerApprovalAction(amisRequire('amis'));
|
||||
registerApprovalAction(amisRequire('amis')) || registerApprovalAction(amisRequire('amis-core'));
|
||||
} catch {
|
||||
// amis-core 未暴露 registerAction 时静默降级(审批抽屉入口不可用,不阻断渲染)
|
||||
}
|
||||
|
||||
@@ -1,619 +0,0 @@
|
||||
import { Component, type ChangeEvent, type CSSProperties, type MouseEvent } from 'react';
|
||||
import { createPortal } from 'react-dom';
|
||||
import { http } from '../api/http';
|
||||
|
||||
const ALL_VALUE = 'ALL ';
|
||||
|
||||
type Option = {
|
||||
label: string;
|
||||
value: string;
|
||||
type?: string;
|
||||
groupKind?: string;
|
||||
groupId?: string;
|
||||
};
|
||||
|
||||
type PickerValue = string | string[] | Option | Option[] | null | undefined;
|
||||
|
||||
type BootstrapData = {
|
||||
departGroups: Option[];
|
||||
positionTypes: Option[];
|
||||
categories: Option[];
|
||||
allUsers?: Option[];
|
||||
orgs?: Option[];
|
||||
departs?: Option[];
|
||||
};
|
||||
|
||||
type PaneKey =
|
||||
| 'all'
|
||||
| 'depart'
|
||||
| 'positionType'
|
||||
| 'category'
|
||||
| 'allUsers'
|
||||
| 'orgs'
|
||||
| 'departs'
|
||||
| 'positionTypes';
|
||||
|
||||
type UserTransferPickerProps = {
|
||||
value?: PickerValue;
|
||||
defaultValue?: PickerValue;
|
||||
data?: Record<string, unknown>;
|
||||
name?: string;
|
||||
label?: string | false;
|
||||
className?: string;
|
||||
style?: CSSProperties;
|
||||
onChange?: (value: string | string[] | undefined) => void;
|
||||
multiple?: boolean;
|
||||
delimiter?: string;
|
||||
mode?: string;
|
||||
userSelectMode?: string;
|
||||
disabled?: boolean;
|
||||
readOnly?: boolean;
|
||||
placeholder?: string;
|
||||
clearable?: boolean;
|
||||
};
|
||||
|
||||
type UserTransferPickerState = {
|
||||
open: boolean;
|
||||
labels: Option[];
|
||||
draft: Option[];
|
||||
bootstrap: BootstrapData;
|
||||
activePane: PaneKey;
|
||||
available: Option[];
|
||||
availableSearch: string;
|
||||
selectedSearch: string;
|
||||
groupSearch: string;
|
||||
selectedGroup: Record<string, string>;
|
||||
leftPicked: string[];
|
||||
rightPicked: string[];
|
||||
loading: boolean;
|
||||
};
|
||||
|
||||
const BASE_PANES: Array<{ key: PaneKey; label: string }> = [
|
||||
{ key: 'all', label: '全部人员' },
|
||||
{ key: 'depart', label: '按公司、部门选择人员' },
|
||||
{ key: 'positionType', label: '按岗位类别选择人员' },
|
||||
{ key: 'category', label: '按用户类别选择人员' },
|
||||
];
|
||||
|
||||
const ORG_PANES: Array<{ key: PaneKey; label: string }> = [
|
||||
{ key: 'allUsers', label: '全体人员' },
|
||||
{ key: 'orgs', label: '选择公司' },
|
||||
{ key: 'departs', label: '选择部门' },
|
||||
{ key: 'positionTypes', label: '选择岗位类别' },
|
||||
];
|
||||
|
||||
function optionKey(value: string): string {
|
||||
return value.trim().toUpperCase() === 'ALL' ? ALL_VALUE : value;
|
||||
}
|
||||
|
||||
function normalizeValue(value: PickerValue, delimiter: string): string[] {
|
||||
if (Array.isArray(value)) {
|
||||
return value
|
||||
.map((item) => (typeof item === 'string' ? item : item?.value))
|
||||
.filter((item): item is string => Boolean(item))
|
||||
.map(optionKey);
|
||||
}
|
||||
if (typeof value === 'object' && value?.value) {
|
||||
return [optionKey(String(value.value))];
|
||||
}
|
||||
if (typeof value !== 'string' || value.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return value
|
||||
.split(delimiter)
|
||||
.map((item) => item.trim())
|
||||
.filter(Boolean)
|
||||
.map(optionKey);
|
||||
}
|
||||
|
||||
function getOptions(payload: unknown): Option[] {
|
||||
const data = (payload as { data?: { data?: { options?: Option[]; items?: Option[] } } })?.data?.data;
|
||||
return data?.options ?? data?.items ?? [];
|
||||
}
|
||||
|
||||
function getBootstrap(payload: unknown): BootstrapData {
|
||||
const data = (payload as { data?: { data?: Partial<BootstrapData> } })?.data?.data ?? {};
|
||||
return {
|
||||
departGroups: data.departGroups ?? [],
|
||||
positionTypes: data.positionTypes ?? [],
|
||||
categories: data.categories ?? [],
|
||||
allUsers: data.allUsers ?? [],
|
||||
orgs: data.orgs ?? [],
|
||||
departs: data.departs ?? [],
|
||||
};
|
||||
}
|
||||
|
||||
function dedupeOptions(items: Option[]): Option[] {
|
||||
const map = new Map<string, Option>();
|
||||
for (const item of items) {
|
||||
map.set(optionKey(item.value), { ...item, value: optionKey(item.value) });
|
||||
}
|
||||
return Array.from(map.values());
|
||||
}
|
||||
|
||||
function filterOptions(items: Option[], keyword: string): Option[] {
|
||||
const q = keyword.trim().toLowerCase();
|
||||
if (!q) return items;
|
||||
return items.filter((item) => `${item.label} ${item.value}`.toLowerCase().includes(q));
|
||||
}
|
||||
|
||||
function looksLikeRawId(value: string): boolean {
|
||||
const text = value.trim();
|
||||
return /^[0-9a-f]{32}$/i.test(text)
|
||||
|| /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(text)
|
||||
|| (text.length >= 24 && /^[0-9a-f-]+$/i.test(text));
|
||||
}
|
||||
|
||||
function fallbackLabel(id: string, index: number): string {
|
||||
const text = id.trim();
|
||||
return looksLikeRawId(text) ? `已选人员${index + 1}` : text;
|
||||
}
|
||||
|
||||
function chunksByLength(ids: string[], delimiter: string, maxLength = 1400): string[][] {
|
||||
const chunks: string[][] = [];
|
||||
let current: string[] = [];
|
||||
let currentLength = 0;
|
||||
for (const id of ids) {
|
||||
const nextLength = currentLength + id.length + (current.length ? delimiter.length : 0);
|
||||
if (current.length > 0 && nextLength > maxLength) {
|
||||
chunks.push(current);
|
||||
current = [];
|
||||
currentLength = 0;
|
||||
}
|
||||
current.push(id);
|
||||
currentLength += id.length + (current.length > 1 ? delimiter.length : 0);
|
||||
}
|
||||
if (current.length > 0) chunks.push(current);
|
||||
return chunks;
|
||||
}
|
||||
|
||||
function displayTextFor(items: Option[], placeholder: string): string {
|
||||
if (items.length === 0) return placeholder;
|
||||
const labels = items.map((item) => item.label.trim()).filter(Boolean);
|
||||
if (labels.length === 0) return placeholder;
|
||||
if (labels.every(looksLikeRawId)) {
|
||||
return labels.length === 1 ? '已选择 1 人' : `已选择 ${labels.length} 人`;
|
||||
}
|
||||
const previewSize = 6;
|
||||
const preview = labels.slice(0, previewSize).join(', ');
|
||||
return labels.length > previewSize ? `${preview} 等 ${labels.length} 人` : preview;
|
||||
}
|
||||
|
||||
function selectedValues(event: ChangeEvent<HTMLSelectElement>): string[] {
|
||||
return Array.from(event.currentTarget.selectedOptions).map((option) => option.value);
|
||||
}
|
||||
|
||||
export class UserTransferPicker extends Component<UserTransferPickerProps, UserTransferPickerState> {
|
||||
override state: UserTransferPickerState = {
|
||||
open: false,
|
||||
labels: [],
|
||||
draft: [],
|
||||
bootstrap: { departGroups: [], positionTypes: [], categories: [] },
|
||||
activePane: 'all',
|
||||
available: [],
|
||||
availableSearch: '',
|
||||
selectedSearch: '',
|
||||
groupSearch: '',
|
||||
selectedGroup: {},
|
||||
leftPicked: [],
|
||||
rightPicked: [],
|
||||
loading: false,
|
||||
};
|
||||
|
||||
override componentDidMount() {
|
||||
void this.resolveCurrentValue();
|
||||
}
|
||||
|
||||
override componentDidUpdate(prevProps: UserTransferPickerProps) {
|
||||
const delimiter = this.delimiter();
|
||||
const before = normalizeValue(this.effectiveValue(prevProps), delimiter).join('\u0000');
|
||||
const after = normalizeValue(this.effectiveValue(this.props), delimiter).join('\u0000');
|
||||
if (before !== after || prevProps.mode !== this.props.mode) {
|
||||
void this.resolveCurrentValue();
|
||||
}
|
||||
}
|
||||
|
||||
private delimiter() {
|
||||
return this.props.delimiter ?? ',';
|
||||
}
|
||||
|
||||
private mode() {
|
||||
return this.props.userSelectMode ?? this.props.mode ?? 'controlled';
|
||||
}
|
||||
|
||||
private effectiveValue(props: UserTransferPickerProps = this.props): PickerValue {
|
||||
if (props.value !== undefined) return props.value;
|
||||
if (props.defaultValue !== undefined) return props.defaultValue;
|
||||
if (props.name && props.data && Object.prototype.hasOwnProperty.call(props.data, props.name)) {
|
||||
return props.data[props.name] as PickerValue;
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
||||
private valueIds() {
|
||||
return normalizeValue(this.effectiveValue(), this.delimiter());
|
||||
}
|
||||
|
||||
private panes() {
|
||||
return this.mode() === 'org' ? [...BASE_PANES, ...ORG_PANES] : BASE_PANES;
|
||||
}
|
||||
|
||||
private async resolveCurrentValue() {
|
||||
const ids = this.valueIds();
|
||||
if (ids.length === 0) {
|
||||
this.setState({ labels: [] });
|
||||
return;
|
||||
}
|
||||
const existing = new Map(this.state.labels.map((item) => [optionKey(item.value), item]));
|
||||
try {
|
||||
const resolvedParts: Option[] = [];
|
||||
for (const chunk of chunksByLength(ids, this.delimiter())) {
|
||||
const resp = await http.get('/api/user-select/resolve', {
|
||||
params: { mode: this.mode(), ids: chunk.join(this.delimiter()) },
|
||||
});
|
||||
resolvedParts.push(...getOptions(resp));
|
||||
}
|
||||
const resolved = dedupeOptions(resolvedParts);
|
||||
const byValue = new Map(resolved.map((item) => [optionKey(item.value), item]));
|
||||
this.setState({
|
||||
labels: ids.map((id, index) => (
|
||||
byValue.get(optionKey(id))
|
||||
?? existing.get(optionKey(id))
|
||||
?? { label: fallbackLabel(id, index), value: id }
|
||||
)),
|
||||
});
|
||||
} catch {
|
||||
this.setState({
|
||||
labels: ids.map((id, index) => (
|
||||
existing.get(optionKey(id)) ?? { label: fallbackLabel(id, index), value: id }
|
||||
)),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
private async loadBootstrap() {
|
||||
const resp = await http.get('/api/user-select/bootstrap', { params: { mode: this.mode() } });
|
||||
const data = getBootstrap(resp);
|
||||
await new Promise<void>((resolve) => {
|
||||
this.setState((current) => ({
|
||||
bootstrap: data,
|
||||
selectedGroup: {
|
||||
...current.selectedGroup,
|
||||
depart: current.selectedGroup.depart
|
||||
|| (data.departGroups[0] ? String(data.departGroups[0].value) : ''),
|
||||
positionType: current.selectedGroup.positionType
|
||||
|| (data.positionTypes[0] ? `positionType:${data.positionTypes[0].value}` : ''),
|
||||
category: current.selectedGroup.category
|
||||
|| (data.categories[0] ? `category:${data.categories[0].value}` : ''),
|
||||
},
|
||||
}), resolve);
|
||||
});
|
||||
}
|
||||
|
||||
private objectPaneOptions(pane: PaneKey): Option[] {
|
||||
const { bootstrap } = this.state;
|
||||
if (pane === 'allUsers') return bootstrap.allUsers ?? [];
|
||||
if (pane === 'orgs') return bootstrap.orgs ?? [];
|
||||
if (pane === 'departs') return bootstrap.departs ?? [];
|
||||
if (pane === 'positionTypes') return bootstrap.positionTypes ?? [];
|
||||
return [];
|
||||
}
|
||||
|
||||
private async loadAvailable() {
|
||||
const { activePane, availableSearch, selectedGroup } = this.state;
|
||||
this.setState({ loading: true, leftPicked: [] });
|
||||
try {
|
||||
if (activePane === 'all') {
|
||||
const resp = await http.get('/api/user-select/search', {
|
||||
params: { mode: this.mode(), term: availableSearch, limit: 500 },
|
||||
});
|
||||
this.setState({ available: getOptions(resp) });
|
||||
return;
|
||||
}
|
||||
|
||||
if (activePane === 'depart' || activePane === 'positionType' || activePane === 'category') {
|
||||
const group = selectedGroup[activePane];
|
||||
if (!group) {
|
||||
this.setState({ available: [] });
|
||||
return;
|
||||
}
|
||||
const resp = await http.get('/api/user-select/group-users', {
|
||||
params: { mode: this.mode(), group, term: availableSearch, limit: 500 },
|
||||
});
|
||||
this.setState({ available: getOptions(resp) });
|
||||
return;
|
||||
}
|
||||
|
||||
this.setState({ available: filterOptions(this.objectPaneOptions(activePane), availableSearch) });
|
||||
} finally {
|
||||
this.setState({ loading: false });
|
||||
}
|
||||
}
|
||||
|
||||
private currentGroups(): Option[] {
|
||||
const { activePane, bootstrap } = this.state;
|
||||
if (activePane === 'depart') return bootstrap.departGroups;
|
||||
if (activePane === 'positionType') {
|
||||
return bootstrap.positionTypes.map((item) => ({ ...item, value: `positionType:${item.value}` }));
|
||||
}
|
||||
if (activePane === 'category') {
|
||||
return bootstrap.categories.map((item) => ({ ...item, value: `category:${item.value}` }));
|
||||
}
|
||||
return [];
|
||||
}
|
||||
|
||||
private availableWithoutSelected(): Option[] {
|
||||
const selectedKeys = new Set(this.state.draft.map((item) => optionKey(item.value)));
|
||||
return this.state.available.filter((item) => !selectedKeys.has(optionKey(item.value)));
|
||||
}
|
||||
|
||||
private openDialog = async () => {
|
||||
if (this.props.disabled || this.props.readOnly) return;
|
||||
const isMultiple = this.props.multiple === true;
|
||||
this.setState({
|
||||
open: true,
|
||||
draft: this.state.labels,
|
||||
availableSearch: '',
|
||||
selectedSearch: '',
|
||||
groupSearch: '',
|
||||
leftPicked: isMultiple ? [] : this.state.labels.slice(0, 1).map((item) => optionKey(item.value)),
|
||||
rightPicked: [],
|
||||
}, async () => {
|
||||
await this.loadBootstrap();
|
||||
await this.loadAvailable();
|
||||
});
|
||||
};
|
||||
|
||||
private closeDialog = () => {
|
||||
this.setState({ open: false });
|
||||
};
|
||||
|
||||
private commit = () => {
|
||||
const selected = dedupeOptions(this.state.draft);
|
||||
const ids = selected.map((item) => optionKey(item.value));
|
||||
this.setState({ labels: selected, open: false });
|
||||
if (!this.props.multiple) {
|
||||
this.props.onChange?.(ids[0] || undefined);
|
||||
} else {
|
||||
this.props.onChange?.(ids.join(this.delimiter()));
|
||||
}
|
||||
};
|
||||
|
||||
private addOptions(items: Option[]) {
|
||||
const normalized = dedupeOptions(items);
|
||||
if (!this.props.multiple) {
|
||||
this.setState({ draft: normalized.slice(0, 1) });
|
||||
return;
|
||||
}
|
||||
this.setState((current) => ({ draft: dedupeOptions([...current.draft, ...normalized]) }));
|
||||
}
|
||||
|
||||
private addPicked = () => {
|
||||
const picked = this.state.available.filter((item) => this.state.leftPicked.includes(optionKey(item.value)));
|
||||
this.addOptions(picked);
|
||||
};
|
||||
|
||||
private addAll = () => {
|
||||
this.addOptions(this.availableWithoutSelected());
|
||||
};
|
||||
|
||||
private removePicked = () => {
|
||||
this.setState((current) => ({
|
||||
draft: current.draft.filter((item) => !current.rightPicked.includes(optionKey(item.value))),
|
||||
rightPicked: [],
|
||||
}));
|
||||
};
|
||||
|
||||
private removeAll = () => {
|
||||
this.setState({ draft: [], rightPicked: [] });
|
||||
};
|
||||
|
||||
private clearValue = (event: MouseEvent<HTMLButtonElement>) => {
|
||||
event.stopPropagation();
|
||||
this.setState({ labels: [] });
|
||||
this.props.onChange?.(this.props.multiple ? '' : undefined);
|
||||
};
|
||||
|
||||
private changePane = (activePane: PaneKey) => {
|
||||
this.setState({
|
||||
activePane,
|
||||
availableSearch: '',
|
||||
groupSearch: '',
|
||||
leftPicked: [],
|
||||
}, () => {
|
||||
void this.loadAvailable();
|
||||
});
|
||||
};
|
||||
|
||||
private setGroupValue = (value: string) => {
|
||||
this.setState((current) => ({
|
||||
selectedGroup: { ...current.selectedGroup, [current.activePane]: value },
|
||||
}), () => {
|
||||
void this.loadAvailable();
|
||||
});
|
||||
};
|
||||
|
||||
private setAvailableSearch = (availableSearch: string) => {
|
||||
this.setState({ availableSearch }, () => {
|
||||
void this.loadAvailable();
|
||||
});
|
||||
};
|
||||
|
||||
override render() {
|
||||
const {
|
||||
className,
|
||||
disabled,
|
||||
readOnly,
|
||||
placeholder = '请选择',
|
||||
clearable = true,
|
||||
style,
|
||||
} = this.props;
|
||||
const {
|
||||
activePane,
|
||||
availableSearch,
|
||||
selectedSearch,
|
||||
groupSearch,
|
||||
selectedGroup,
|
||||
leftPicked,
|
||||
rightPicked,
|
||||
draft,
|
||||
labels,
|
||||
loading,
|
||||
open,
|
||||
} = this.state;
|
||||
|
||||
const isMultiple = this.props.multiple === true;
|
||||
const currentGroups = this.currentGroups();
|
||||
const filteredGroups = filterOptions(currentGroups, groupSearch);
|
||||
const availableWithoutSelected = this.availableWithoutSelected();
|
||||
const availableOptions = isMultiple ? availableWithoutSelected : this.state.available;
|
||||
const selectedFiltered = filterOptions(draft, selectedSearch);
|
||||
const displayText = displayTextFor(labels, placeholder);
|
||||
const fullTitle = labels.map((item) => item.label).join(', ');
|
||||
const controlClassName = [
|
||||
className,
|
||||
'eip4-user-transfer-control',
|
||||
disabled || readOnly ? 'is-disabled' : '',
|
||||
labels.length ? '' : 'is-empty',
|
||||
].filter(Boolean).join(' ');
|
||||
const dialog = open ? (
|
||||
<div className="eip4-user-transfer-mask" onMouseDown={(event) => {
|
||||
if (event.target === event.currentTarget) this.closeDialog();
|
||||
}}
|
||||
>
|
||||
<div className={`eip4-user-transfer-dialog${isMultiple ? '' : ' is-single'}`}>
|
||||
<div className="eip4-user-transfer-head">
|
||||
<h3>{isMultiple ? '用户选择框' : '选择用户'}</h3>
|
||||
<button type="button" onClick={this.closeDialog}>×</button>
|
||||
</div>
|
||||
<div className={`eip4-user-transfer-body${isMultiple ? '' : ' is-single'}`}>
|
||||
<section className="eip4-user-transfer-panel">
|
||||
<div className="eip4-user-transfer-title">-可选项-</div>
|
||||
<div className="eip4-user-transfer-tabs">
|
||||
{this.panes().map((pane) => (
|
||||
<button
|
||||
type="button"
|
||||
key={pane.key}
|
||||
className={activePane === pane.key ? 'is-active' : ''}
|
||||
onClick={() => this.changePane(pane.key)}
|
||||
>
|
||||
{pane.label}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
{currentGroups.length > 0 ? (
|
||||
<div className="eip4-user-transfer-group">
|
||||
<input
|
||||
value={groupSearch}
|
||||
onChange={(event) => this.setState({ groupSearch: event.target.value })}
|
||||
placeholder={activePane === 'depart' ? '搜索公司或部门' : '搜索分类'}
|
||||
/>
|
||||
<select
|
||||
value={selectedGroup[activePane] || ''}
|
||||
onChange={(event) => this.setGroupValue(event.target.value)}
|
||||
>
|
||||
<option value="">
|
||||
{activePane === 'depart' ? '下拉选择一个公司或部门' : '下拉选择一个分类'}
|
||||
</option>
|
||||
{filteredGroups.map((item) => (
|
||||
<option key={item.value} value={item.value}>{item.label}</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
) : null}
|
||||
<input
|
||||
className="eip4-user-transfer-search"
|
||||
value={availableSearch}
|
||||
onChange={(event) => this.setAvailableSearch(event.target.value)}
|
||||
placeholder="输入关键字过滤可选项"
|
||||
/>
|
||||
<select
|
||||
multiple={isMultiple}
|
||||
size={isMultiple ? undefined : 12}
|
||||
className="eip4-user-transfer-list"
|
||||
value={isMultiple ? leftPicked : (leftPicked[0] ?? '')}
|
||||
onChange={(event) => {
|
||||
const values = selectedValues(event);
|
||||
if (isMultiple) {
|
||||
this.setState({ leftPicked: values });
|
||||
return;
|
||||
}
|
||||
const picked = this.state.available.find((item) => values.includes(optionKey(item.value)));
|
||||
this.setState({ leftPicked: values, draft: picked ? [picked] : [] });
|
||||
}}
|
||||
onDoubleClick={this.addPicked}
|
||||
>
|
||||
{availableOptions.map((item) => (
|
||||
<option key={optionKey(item.value)} value={optionKey(item.value)}>{item.label}</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="eip4-user-transfer-count">
|
||||
{loading ? '加载中...' : `共${availableOptions.length}条`}
|
||||
</div>
|
||||
</section>
|
||||
|
||||
{isMultiple ? (
|
||||
<>
|
||||
<div className="eip4-user-transfer-actions">
|
||||
<button type="button" onClick={this.addPicked} disabled={leftPicked.length === 0}>></button>
|
||||
<button type="button" onClick={this.removePicked} disabled={rightPicked.length === 0}><</button>
|
||||
<button type="button" onClick={this.addAll} disabled={availableWithoutSelected.length === 0}>>></button>
|
||||
<button type="button" onClick={this.removeAll} disabled={draft.length === 0}><<</button>
|
||||
</div>
|
||||
|
||||
<section className="eip4-user-transfer-panel">
|
||||
<div className="eip4-user-transfer-title">-已选项-</div>
|
||||
<input
|
||||
className="eip4-user-transfer-search"
|
||||
value={selectedSearch}
|
||||
onChange={(event) => this.setState({ selectedSearch: event.target.value })}
|
||||
placeholder="输入关键字可过滤已选项"
|
||||
/>
|
||||
<select
|
||||
multiple
|
||||
className="eip4-user-transfer-list"
|
||||
value={rightPicked}
|
||||
onChange={(event) => this.setState({ rightPicked: selectedValues(event) })}
|
||||
onDoubleClick={this.removePicked}
|
||||
>
|
||||
{selectedFiltered.map((item) => (
|
||||
<option key={optionKey(item.value)} value={optionKey(item.value)}>{item.label}</option>
|
||||
))}
|
||||
</select>
|
||||
<div className="eip4-user-transfer-count">共{draft.length}条</div>
|
||||
</section>
|
||||
</>
|
||||
) : null}
|
||||
</div>
|
||||
<div className="eip4-user-transfer-foot">
|
||||
<button type="button" className="primary" onClick={this.commit}>确认</button>
|
||||
<button type="button" onClick={this.closeDialog}>取消</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
) : null;
|
||||
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={controlClassName}
|
||||
onClick={this.openDialog}
|
||||
role="button"
|
||||
style={style}
|
||||
tabIndex={disabled || readOnly ? -1 : 0}
|
||||
title={fullTitle || undefined}
|
||||
>
|
||||
<span className="eip4-user-transfer-text">{displayText}</span>
|
||||
{clearable && labels.length > 0 && !disabled && !readOnly ? (
|
||||
<button type="button" onClick={this.clearValue} aria-label="清空">
|
||||
×
|
||||
</button>
|
||||
) : null}
|
||||
<span className="eip4-user-transfer-icon" aria-hidden="true" />
|
||||
</div>
|
||||
|
||||
{dialog && typeof document !== 'undefined' ? createPortal(dialog, document.body) : dialog}
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -245,16 +245,6 @@
|
||||
color: #555c66;
|
||||
}
|
||||
|
||||
.amis-scope .cxd-Crud-filter .cxd-Form-item--inline:has(.eip4-user-transfer-control) .cxd-Form-value,
|
||||
.amis-scope .cxd-CRUD-filter .cxd-Form-item--inline:has(.eip4-user-transfer-control) .cxd-Form-value {
|
||||
width: var(--Form-control-widthSm);
|
||||
}
|
||||
|
||||
.amis-scope .cxd-Crud-filter .cxd-Form-item--inline > .cxd-Form-value > .eip4-user-transfer-control,
|
||||
.amis-scope .cxd-CRUD-filter .cxd-Form-item--inline > .cxd-Form-value > .eip4-user-transfer-control {
|
||||
display: inline-flex;
|
||||
}
|
||||
|
||||
/* 查询/重置按钮区紧凑 */
|
||||
.amis-scope .cxd-Crud-filter .cxd-Form-group--justify,
|
||||
.amis-scope .cxd-CRUD-filter .cxd-Form-group--justify {
|
||||
@@ -441,6 +431,27 @@
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
/* 12b-1. 多层 AMIS 弹窗显式递增层级,避免 picker/dialog 嵌套时第二层被第一层挡住 */
|
||||
.amis-dialog-widget.cxd-Modal--1th,
|
||||
.amis-dialog-widget.cxd-Drawer--1th {
|
||||
z-index: 1400;
|
||||
}
|
||||
|
||||
.amis-dialog-widget.cxd-Modal--2th,
|
||||
.amis-dialog-widget.cxd-Drawer--2th {
|
||||
z-index: 1500;
|
||||
}
|
||||
|
||||
.amis-dialog-widget.cxd-Modal--3th,
|
||||
.amis-dialog-widget.cxd-Drawer--3th {
|
||||
z-index: 1600;
|
||||
}
|
||||
|
||||
.amis-dialog-widget.cxd-Modal--4th,
|
||||
.amis-dialog-widget.cxd-Drawer--4th {
|
||||
z-index: 1700;
|
||||
}
|
||||
|
||||
/* 12c. 子表表头 sticky:随 body 滚动钉在顶部,列头不丢 */
|
||||
.amis-scope .cxd-InputTable .cxd-Table-table > thead > tr > th {
|
||||
position: sticky;
|
||||
@@ -460,294 +471,6 @@
|
||||
--Form-input-fontSize: 13px; /* 与表格正文 13px 一致(原 14px) */
|
||||
}
|
||||
|
||||
/* ============================================================================
|
||||
15. 旧 UserSelectWindow 等价选人弹窗
|
||||
左侧分组 + 双列穿梭 + 右侧已选过滤,替代普通 tabs-transfer-picker 的树选择误差。
|
||||
============================================================================ */
|
||||
.eip4-user-transfer-control {
|
||||
width: 100%;
|
||||
box-sizing: border-box;
|
||||
height: 32px;
|
||||
min-height: 32px;
|
||||
max-height: 32px;
|
||||
border: 1px solid var(--Form-input-borderColor, #d7dde8);
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
color: #1f2937;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 5px 0 5px 9px;
|
||||
cursor: pointer;
|
||||
max-width: 100%;
|
||||
overflow: hidden;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-control.is-empty {
|
||||
color: #9aa3b2;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-control.is-disabled {
|
||||
background: #f3f5f8;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-text {
|
||||
flex: 1 1 auto;
|
||||
min-width: 0;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-control > button {
|
||||
flex: 0 0 auto;
|
||||
margin-left: 8px;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #667085;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-icon {
|
||||
position: relative;
|
||||
flex: 0 0 34px;
|
||||
align-self: stretch;
|
||||
margin: -5px 0 -5px 8px;
|
||||
border-left: 1px solid #d7dde8;
|
||||
color: #7a8494;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-icon::before,
|
||||
.eip4-user-transfer-icon::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
box-sizing: border-box;
|
||||
border: 2px solid currentColor;
|
||||
border-radius: 2px;
|
||||
background: #fff;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-icon::before {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
left: 8px;
|
||||
top: 8px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-icon::after {
|
||||
width: 13px;
|
||||
height: 13px;
|
||||
left: 13px;
|
||||
top: 12px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-head > button {
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #667085;
|
||||
cursor: pointer;
|
||||
font-size: 18px;
|
||||
line-height: 1;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-mask {
|
||||
position: fixed;
|
||||
inset: 0;
|
||||
z-index: 6000;
|
||||
background: rgba(17, 24, 39, .38);
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-dialog {
|
||||
width: min(1120px, calc(100vw - 40px));
|
||||
height: min(720px, calc(100vh - 40px));
|
||||
background: #fff;
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 24px 72px rgba(15, 23, 42, .26);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-dialog.is-single {
|
||||
width: min(560px, calc(100vw - 40px));
|
||||
height: min(560px, calc(100vh - 40px));
|
||||
}
|
||||
|
||||
.eip4-user-transfer-head,
|
||||
.eip4-user-transfer-foot {
|
||||
flex: 0 0 auto;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
padding: 12px 16px;
|
||||
border-bottom: 1px solid #e5eaf2;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-head h3 {
|
||||
margin: 0;
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-foot {
|
||||
justify-content: flex-end;
|
||||
gap: 10px;
|
||||
border-top: 1px solid #e5eaf2;
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-foot button,
|
||||
.eip4-user-transfer-actions button {
|
||||
min-width: 72px;
|
||||
height: 34px;
|
||||
border: 1px solid #cfd6e3;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
color: #344054;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-foot button.primary {
|
||||
border-color: #2f63e6;
|
||||
background: #2f63e6;
|
||||
color: #fff;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-foot button:disabled,
|
||||
.eip4-user-transfer-actions button:disabled {
|
||||
opacity: .45;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-body {
|
||||
flex: 1 1 auto;
|
||||
min-height: 0;
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 104px minmax(0, 1fr);
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-body.is-single {
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
}
|
||||
|
||||
.eip4-user-transfer-panel {
|
||||
min-width: 0;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-title,
|
||||
.eip4-user-transfer-count {
|
||||
color: #344054;
|
||||
font-size: 13px;
|
||||
line-height: 24px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-tabs {
|
||||
border: 1px solid #d7dde8;
|
||||
border-radius: 6px;
|
||||
overflow: hidden;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-tabs button {
|
||||
width: 100%;
|
||||
min-height: 34px;
|
||||
border: 0;
|
||||
border-bottom: 1px solid #e5eaf2;
|
||||
background: #fff;
|
||||
color: #344054;
|
||||
display: block;
|
||||
text-align: left;
|
||||
padding: 7px 10px;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-tabs button:last-child {
|
||||
border-bottom: 0;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-tabs button.is-active {
|
||||
background: #eef4ff;
|
||||
color: #1f54d7;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-group {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr);
|
||||
gap: 8px;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-group input,
|
||||
.eip4-user-transfer-group select,
|
||||
.eip4-user-transfer-search {
|
||||
height: 32px;
|
||||
border: 1px solid #d7dde8;
|
||||
border-radius: 6px;
|
||||
padding: 0 9px;
|
||||
color: #1f2937;
|
||||
background: #fff;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-search {
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-list {
|
||||
flex: 1 1 auto;
|
||||
min-height: 220px;
|
||||
width: 100%;
|
||||
border: 1px solid #cfd6e3;
|
||||
border-radius: 6px;
|
||||
padding: 4px;
|
||||
font-size: 13px;
|
||||
color: #1f2937;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-body.is-single .eip4-user-transfer-list {
|
||||
min-height: 280px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-list option {
|
||||
padding: 5px 8px;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-actions {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: stretch;
|
||||
gap: 14px;
|
||||
}
|
||||
|
||||
@media (max-width: 760px) {
|
||||
.eip4-user-transfer-dialog {
|
||||
width: calc(100vw - 20px);
|
||||
height: calc(100vh - 20px);
|
||||
}
|
||||
|
||||
.eip4-user-transfer-body {
|
||||
grid-template-columns: 1fr;
|
||||
}
|
||||
|
||||
.eip4-user-transfer-actions {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
|
||||
/* ============================================================================
|
||||
14. 查看(只读/静态)态隐藏必填星号 * — 2026-06-15
|
||||
只读页的红 * 无意义(不可填、不校验)。静态渲染的必填项 value 部分是静态文本、
|
||||
@@ -755,7 +478,7 @@
|
||||
后隐藏 *;编辑态必填项 value 含 input/textarea/Select → 不命中,* 照常显示。
|
||||
(实测查看 5★全隐、修改 5★全显。)
|
||||
============================================================================ */
|
||||
.amis-scope .cxd-Form-item.is-required:not(:has(.cxd-Form-value input, .cxd-Form-value textarea, .cxd-Form-value .cxd-Select, .cxd-Form-value .eip4-user-transfer-control)) .cxd-Form-star {
|
||||
.amis-scope .cxd-Form-item.is-required:not(:has(.cxd-Form-value input, .cxd-Form-value textarea, .cxd-Form-value .cxd-Select)) .cxd-Form-star {
|
||||
display: none;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user