@ant-design/icons#PlusSquareOutlined TypeScript Examples
The following examples show how to use
@ant-design/icons#PlusSquareOutlined.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: index.tsx From XFlow with MIT License | 6 votes |
XFlowDefaultGroupNode: NsGraph.INodeRender = props => {
const { cell } = props
const app = useXFlowApp()
const isCollapsed = props.data.isCollapsed || false
const onExpand = (e: React.MouseEvent) => {
e.preventDefault()
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
})
}
const onCollapse = (e: React.MouseEvent) => {
e.preventDefault()
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
gap: 3,
})
}
return (
<div className="xflow-default-group-node">
<div className="xflow-group-header">
<div className="header-left">{props.data.label}</div>
<div className="header-right">
{isCollapsed && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapsed && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #2
Source File: index.tsx From XFlow with MIT License | 6 votes |
GroupNode: NsGraph.INodeRender = props => {
const { cell } = props
const app = useXFlowApp()
const isCollapsed = props.data.isCollapsed || false
const onExpand = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
})
}
const onCollapse = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
gap: 3,
})
}
return (
<div className="xflow-group-node">
<div className="xflow-group-header">
<div className="header-left">{props.data.label}</div>
<div className="header-right">
{isCollapsed && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapsed && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #3
Source File: index.tsx From XFlow with MIT License | 6 votes |
GroupNode: NsGraph.INodeRender = props => {
const { cell } = props
const app = useXFlowApp()
const isCollapse = cell.getProp('isCollapsed') || false
const onExpand = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
})
}
const onCollapse = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
gap: 3,
})
}
return (
<div className="xflow-group-node">
<div className="xflow-group-header">
<div className="header-left">{props.data.label}</div>
<div className="header-right">
{isCollapse && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapse && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #4
Source File: group.tsx From XFlow with MIT License | 6 votes |
GroupNode: NsGraph.INodeRender = props => {
const { cell } = props
const app = useXFlowApp()
const isCollapsed = props.data.isCollapsed || false
const onExpand = () => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
collapsedSize: { width: 200, height: 40 },
})
}
const onCollapse = () => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
collapsedSize: { width: 200, height: 40 },
gap: 3,
})
}
return (
<div className="xflow-group-node">
<div className="xflow-group-header">
<div className="header-left">{props.data.label}</div>
<div className="header-right">
{isCollapsed && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapsed && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #5
Source File: group.tsx From XFlow with MIT License | 6 votes |
GroupNode: NsGraph.INodeRender = props => {
const { cell } = props
const app = useXFlowApp()
const isCollapsed = props.data.isCollapsed || false
const onExpand = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
collapsedSize: { width: 200, height: 40 },
})
}
const onCollapse = e => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
collapsedSize: { width: 200, height: 40 },
gap: 3,
})
}
return (
<div className="xflow-group-node">
<div className="xflow-group-header">
<div className="header-left">{props.data.label}</div>
<div className="header-right">
{isCollapsed && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapsed && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #6
Source File: group.tsx From XFlow with MIT License | 5 votes |
GroupNode: NsGraph.INodeRender = props => {
const {
cell,
data: { label, stroke, fill, fontSize, fontFill, width = 200, isCollapsed = false },
} = props
const app = useXFlowApp()
const onExpand = () => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: false,
collapsedSize: { width, height: 40 },
})
}
const onCollapse = () => {
app.executeCommand(XFlowGroupCommands.COLLAPSE_GROUP.id, {
nodeId: cell.id,
isCollapsed: true,
collapsedSize: { width, height: 40 },
gap: 3,
})
}
return (
<div
className="xflow-group-node"
style={{
borderColor: stroke,
backgroundColor: fill,
fontSize,
color: fontFill,
}}
>
<div className="xflow-group-header">
<div className="header-left">{label}</div>
<div className="header-right">
{isCollapsed && <PlusSquareOutlined onClick={onExpand} />}
{!isCollapsed && <MinusSquareOutlined onClick={onCollapse} />}
</div>
</div>
</div>
)
}
Example #7
Source File: ZoomControl.tsx From datart with Apache License 2.0 | 5 votes |
ZoomControl: React.FC<ZoomControlProps> = props => {
const { sliderValue, scale, zoomIn, zoomOut, sliderChange } = props;
const percentage = useMemo(() => {
if (!scale) {
return '';
}
if (scale[0] === scale[1]) {
return `${Math.floor(scale[0] * 100)}%`;
}
return scale.map((s: number) => `${Math.floor(s * 100)}%`).join('/');
}, [scale]);
return (
<Wrapper>
<div className="bottom-box">
<Space>
<Tooltip title="缩小视图">
<Button
size="small"
type="text"
onClick={zoomIn}
icon={<MinusSquareOutlined />}
></Button>
</Tooltip>
<Slider
className="bottom-slider"
onChange={sliderChange}
value={sliderValue}
/>
<Tooltip title="放大视图">
<Button
size="small"
type="text"
onClick={zoomOut}
icon={<PlusSquareOutlined />}
></Button>
</Tooltip>
<label className="value-label">{percentage}</label>
</Space>
</div>
</Wrapper>
);
}
Example #8
Source File: Icon.tsx From html2sketch with MIT License | 4 votes |
IconSymbol: FC = () => {
return (
<Row>
{/*<CaretUpOutlined*/}
{/* className="icon"*/}
{/* symbolName={'1.General/2.Icons/1.CaretUpOutlined'}*/}
{/*/>*/}
{/* className="icon"*/}
{/* symbolName={'1.General/2.Icons/2.MailOutlined'}*/}
{/*/>*/}
{/*<StepBackwardOutlined*/}
{/* className="icon"*/}
{/* symbolName={'1.General/2.Icons/2.StepBackwardOutlined'}*/}
{/*/>*/}
{/*<StepForwardOutlined*/}
{/* className="icon"*/}
{/* symbolName={'1.General/2.Icons/2.StepBackwardOutlined'}*/}
{/*/>*/}
<StepForwardOutlined />
<ShrinkOutlined />
<ArrowsAltOutlined />
<DownOutlined />
<UpOutlined />
<LeftOutlined />
<RightOutlined />
<CaretUpOutlined />
<CaretDownOutlined />
<CaretLeftOutlined />
<CaretRightOutlined />
<VerticalAlignTopOutlined />
<RollbackOutlined />
<FastBackwardOutlined />
<FastForwardOutlined />
<DoubleRightOutlined />
<DoubleLeftOutlined />
<VerticalLeftOutlined />
<VerticalRightOutlined />
<VerticalAlignMiddleOutlined />
<VerticalAlignBottomOutlined />
<ForwardOutlined />
<BackwardOutlined />
<EnterOutlined />
<RetweetOutlined />
<SwapOutlined />
<SwapLeftOutlined />
<SwapRightOutlined />
<ArrowUpOutlined />
<ArrowDownOutlined />
<ArrowLeftOutlined />
<ArrowRightOutlined />
<LoginOutlined />
<LogoutOutlined />
<MenuFoldOutlined />
<MenuUnfoldOutlined />
<BorderBottomOutlined />
<BorderHorizontalOutlined />
<BorderInnerOutlined />
<BorderOuterOutlined />
<BorderLeftOutlined />
<BorderRightOutlined />
<BorderTopOutlined />
<BorderVerticleOutlined />
<PicCenterOutlined />
<PicLeftOutlined />
<PicRightOutlined />
<RadiusBottomleftOutlined />
<RadiusBottomrightOutlined />
<RadiusUpleftOutlined />
<RadiusUprightOutlined />
<FullscreenOutlined />
<FullscreenExitOutlined />
<QuestionOutlined />
<PauseOutlined />
<MinusOutlined />
<PauseCircleOutlined />
<InfoOutlined />
<CloseOutlined />
<ExclamationOutlined />
<CheckOutlined />
<WarningOutlined />
<IssuesCloseOutlined />
<StopOutlined />
<EditOutlined />
<CopyOutlined />
<ScissorOutlined />
<DeleteOutlined />
<SnippetsOutlined />
<DiffOutlined />
<HighlightOutlined />
<AlignCenterOutlined />
<AlignLeftOutlined />
<AlignRightOutlined />
<BgColorsOutlined />
<BoldOutlined />
<ItalicOutlined />
<UnderlineOutlined />
<StrikethroughOutlined />
<RedoOutlined />
<UndoOutlined />
<ZoomInOutlined />
<ZoomOutOutlined />
<FontColorsOutlined />
<FontSizeOutlined />
<LineHeightOutlined />
<SortAscendingOutlined />
<SortDescendingOutlined />
<DragOutlined />
<OrderedListOutlined />
<UnorderedListOutlined />
<RadiusSettingOutlined />
<ColumnWidthOutlined />
<ColumnHeightOutlined />
<AreaChartOutlined />
<PieChartOutlined />
<BarChartOutlined />
<DotChartOutlined />
<LineChartOutlined />
<RadarChartOutlined />
<HeatMapOutlined />
<FallOutlined />
<RiseOutlined />
<StockOutlined />
<BoxPlotOutlined />
<FundOutlined />
<SlidersOutlined />
<AndroidOutlined />
<AppleOutlined />
<WindowsOutlined />
<IeOutlined />
<ChromeOutlined />
<GithubOutlined />
<AliwangwangOutlined />
<DingdingOutlined />
<WeiboSquareOutlined />
<WeiboCircleOutlined />
<TaobaoCircleOutlined />
<Html5Outlined />
<WeiboOutlined />
<TwitterOutlined />
<WechatOutlined />
<AlipayCircleOutlined />
<TaobaoOutlined />
<SkypeOutlined />
<FacebookOutlined />
<CodepenOutlined />
<CodeSandboxOutlined />
<AmazonOutlined />
<GoogleOutlined />
<AlipayOutlined />
<AntDesignOutlined />
<AntCloudOutlined />
<ZhihuOutlined />
<SlackOutlined />
<SlackSquareOutlined />
<BehanceSquareOutlined />
<DribbbleOutlined />
<DribbbleSquareOutlined />
<InstagramOutlined />
<YuqueOutlined />
<AlibabaOutlined />
<YahooOutlined />
<RedditOutlined />
<SketchOutlined />
<AccountBookOutlined />
<AlertOutlined />
<ApartmentOutlined />
<ApiOutlined />
<QqOutlined />
<MediumWorkmarkOutlined />
<GitlabOutlined />
<MediumOutlined />
<GooglePlusOutlined />
<AppstoreAddOutlined />
<AppstoreOutlined />
<AudioOutlined />
<AudioMutedOutlined />
<AuditOutlined />
<BankOutlined />
<BarcodeOutlined />
<BarsOutlined />
<BellOutlined />
<BlockOutlined />
<BookOutlined />
<BorderOutlined />
<BranchesOutlined />
<BuildOutlined />
<BulbOutlined />
<CalculatorOutlined />
<CalendarOutlined />
<CameraOutlined />
<CarOutlined />
<CarryOutOutlined />
<CiCircleOutlined />
<CiOutlined />
<CloudOutlined />
<ClearOutlined />
<ClusterOutlined />
<CodeOutlined />
<CoffeeOutlined />
<CompassOutlined />
<CompressOutlined />
<ContactsOutlined />
<ContainerOutlined />
<ControlOutlined />
<CopyrightCircleOutlined />
<CopyrightOutlined />
<CreditCardOutlined />
<CrownOutlined />
<CustomerServiceOutlined />
<DashboardOutlined />
<DatabaseOutlined />
<DeleteColumnOutlined />
<DeleteRowOutlined />
<DisconnectOutlined />
<DislikeOutlined />
<DollarCircleOutlined />
<DollarOutlined />
<DownloadOutlined />
<EllipsisOutlined />
<EnvironmentOutlined />
<EuroCircleOutlined />
<EuroOutlined />
<ExceptionOutlined />
<ExpandAltOutlined />
<ExpandOutlined />
<ExperimentOutlined />
<ExportOutlined />
<EyeOutlined />
<FieldBinaryOutlined />
<FieldNumberOutlined />
<FieldStringOutlined />
<DesktopOutlined />
<DingtalkOutlined />
<FileAddOutlined />
<FileDoneOutlined />
<FileExcelOutlined />
<FileExclamationOutlined />
<FileOutlined />
<FileImageOutlined />
<FileJpgOutlined />
<FileMarkdownOutlined />
<FilePdfOutlined />
<FilePptOutlined />
<FileProtectOutlined />
<FileSearchOutlined />
<FileSyncOutlined />
<FileTextOutlined />
<FileUnknownOutlined />
<FileWordOutlined />
<FilterOutlined />
<FireOutlined />
<FlagOutlined />
<FolderAddOutlined />
<FolderOutlined />
<FolderOpenOutlined />
<ForkOutlined />
<FormatPainterOutlined />
<FrownOutlined />
<FunctionOutlined />
<FunnelPlotOutlined />
<GatewayOutlined />
<GifOutlined />
<GiftOutlined />
<GlobalOutlined />
<GoldOutlined />
<GroupOutlined />
<HddOutlined />
<HeartOutlined />
<HistoryOutlined />
<HomeOutlined />
<HourglassOutlined />
<IdcardOutlined />
<ImportOutlined />
<InboxOutlined />
<InsertRowAboveOutlined />
<InsertRowBelowOutlined />
<InsertRowLeftOutlined />
<InsertRowRightOutlined />
<InsuranceOutlined />
<InteractionOutlined />
<KeyOutlined />
<LaptopOutlined />
<LayoutOutlined />
<LikeOutlined />
<LineOutlined />
<LinkOutlined />
<Loading3QuartersOutlined />
<LoadingOutlined />
<LockOutlined />
<MailOutlined />
<ManOutlined />
<MedicineBoxOutlined />
<MehOutlined />
<MenuOutlined />
<MergeCellsOutlined />
<MessageOutlined />
<MobileOutlined />
<MoneyCollectOutlined />
<MonitorOutlined />
<MoreOutlined />
<NodeCollapseOutlined />
<NodeExpandOutlined />
<NodeIndexOutlined />
<NotificationOutlined />
<NumberOutlined />
<PaperClipOutlined />
<PartitionOutlined />
<PayCircleOutlined />
<PercentageOutlined />
<PhoneOutlined />
<PictureOutlined />
<PoundCircleOutlined />
<PoundOutlined />
<PoweroffOutlined />
<PrinterOutlined />
<ProfileOutlined />
<ProjectOutlined />
<PropertySafetyOutlined />
<PullRequestOutlined />
<PushpinOutlined />
<QrcodeOutlined />
<ReadOutlined />
<ReconciliationOutlined />
<RedEnvelopeOutlined />
<ReloadOutlined />
<RestOutlined />
<RobotOutlined />
<RocketOutlined />
<SafetyCertificateOutlined />
<SafetyOutlined />
<ScanOutlined />
<ScheduleOutlined />
<SearchOutlined />
<SecurityScanOutlined />
<SelectOutlined />
<SendOutlined />
<SettingOutlined />
<ShakeOutlined />
<ShareAltOutlined />
<ShopOutlined />
<ShoppingCartOutlined />
<ShoppingOutlined />
<SisternodeOutlined />
<SkinOutlined />
<SmileOutlined />
<SolutionOutlined />
<SoundOutlined />
<SplitCellsOutlined />
<StarOutlined />
<SubnodeOutlined />
<SyncOutlined />
<TableOutlined />
<TabletOutlined />
<TagOutlined />
<TagsOutlined />
<TeamOutlined />
<ThunderboltOutlined />
<ToTopOutlined />
<ToolOutlined />
<TrademarkCircleOutlined />
<TrademarkOutlined />
<TransactionOutlined />
<TrophyOutlined />
<UngroupOutlined />
<UnlockOutlined />
<UploadOutlined />
<UsbOutlined />
<UserAddOutlined />
<UserDeleteOutlined />
<UserOutlined />
<UserSwitchOutlined />
<UsergroupAddOutlined />
<UsergroupDeleteOutlined />
<VideoCameraOutlined />
<WalletOutlined />
<WifiOutlined />
<BorderlessTableOutlined />
<WomanOutlined />
<BehanceOutlined />
<DropboxOutlined />
<DeploymentUnitOutlined />
<UpCircleOutlined />
<DownCircleOutlined />
<LeftCircleOutlined />
<RightCircleOutlined />
<UpSquareOutlined />
<DownSquareOutlined />
<LeftSquareOutlined />
<RightSquareOutlined />
<PlayCircleOutlined />
<QuestionCircleOutlined />
<PlusCircleOutlined />
<PlusSquareOutlined />
<MinusSquareOutlined />
<MinusCircleOutlined />
<InfoCircleOutlined />
<ExclamationCircleOutlined />
<CloseCircleOutlined />
<CloseSquareOutlined />
<CheckCircleOutlined />
<CheckSquareOutlined />
<ClockCircleOutlined />
<FormOutlined />
<DashOutlined />
<SmallDashOutlined />
<YoutubeOutlined />
<CodepenCircleOutlined />
<AliyunOutlined />
<PlusOutlined />
<LinkedinOutlined />
<AimOutlined />
<BugOutlined />
<CloudDownloadOutlined />
<CloudServerOutlined />
<CloudSyncOutlined />
<CloudUploadOutlined />
<CommentOutlined />
<ConsoleSqlOutlined />
<EyeInvisibleOutlined />
<FileGifOutlined />
<DeliveredProcedureOutlined />
<FieldTimeOutlined />
<FileZipOutlined />
<FolderViewOutlined />
<FundProjectionScreenOutlined />
<FundViewOutlined />
<MacCommandOutlined />
<PlaySquareOutlined />
<OneToOneOutlined />
<RotateLeftOutlined />
<RotateRightOutlined />
<SaveOutlined />
<SwitcherOutlined />
<TranslationOutlined />
<VerifiedOutlined />
<VideoCameraAddOutlined />
<WhatsAppOutlined />
{/*</Col>*/}
</Row>
);
}
Example #9
Source File: cardLeft.tsx From fe-v5 with Apache License 2.0 | 4 votes |
export default function CardLeft(props: Props) {
const { onRefreshRule } = props;
const [form] = Form.useForm();
const [alertList, setAlertList] = useState<CardAlertType[]>();
const [visible, setVisible] = useState(false);
const [editForm, setEditForm] = useState<CardAlertType>();
const localSelectId = localStorage.getItem('selectedAlertRule');
const [activeId, setActiveId] = useState<number>(localSelectId ? Number(localSelectId) : 0);
const [search, setSearch] = useState('');
useEffect(() => {
getList(true).then((res) => {
if (activeId && res && res.length > 0) {
const currentAlert = res?.find((item) => item.id === activeId) as CardAlertType;
if (currentAlert) {
onRefreshRule(currentAlert.rule);
} else {
saveActiveId(res[0].id);
}
}
});
}, []);
useEffect(() => {
if (activeId && alertList && alertList.length > 0) {
const currentAlert = alertList?.find((item) => item.id === activeId) as CardAlertType;
if (currentAlert) {
onRefreshRule(currentAlert.rule);
} else {
saveActiveId(alertList[0].id);
}
}
}, [activeId]);
function saveActiveId(id: number) {
if (!id) return;
setActiveId(id);
localStorage.setItem('selectedAlertRule', String(id));
}
const getList = (selectTheFirst = false) => {
return getAggrAlerts().then((res) => {
const sortedList = res.dat.sort((a: CardAlertType, b: CardAlertType) => a.cate - b.cate);
setAlertList(sortedList);
selectTheFirst && sortedList.length > 0 && !sortedList.find((item) => item.id === activeId) && saveActiveId(sortedList[0].id);
return sortedList;
});
};
const handleOk = async () => {
await form.validateFields();
const func = editForm ? updateAggrAlerts : AddAggrAlerts;
const cur = await func(form.getFieldsValue());
setVisible(false);
await getList();
saveActiveId(editForm ? editForm.id : cur.dat.id);
};
const handleCancel = () => {
setVisible(false);
setEditForm(undefined);
};
const handleDelete = (alert) => {
Modal.confirm({
title: `确定要删除聚合策略 ${alert.name} 吗?`,
onOk: async () => {
await deleteAggrAlerts([alert.id]);
message.success('删除成功');
getList(true);
},
onCancel: () => {},
});
};
return (
<div className='left-area' style={{ width: 240, background: '#fff' }}>
<div className='event-page-title'>
<span>聚合规则</span>
<a onClick={() => setVisible(true)}>
<PlusSquareOutlined />
</a>
</div>
<Input
style={{ margin: '10px 0' }}
prefix={<SearchOutlined />}
value={search}
onChange={(e) => {
setSearch(e.target.value);
}}
/>
{alertList
?.filter((alert) => alert.name.includes(search))
.map((alert) => (
<div className={alert.id === activeId ? 'card-menu-item is-active' : 'card-menu-item'} onClick={() => saveActiveId(alert.id)} key={alert.id}>
<div className='label-area'>
<div className='title'>{alert.name}</div>
{/* <div className='desc'>{alert.rule}</div> */}
</div>
{alert.cate === 0 ? (
<div className='default-holder'>内置</div>
) : (
<div className='icon-area'>
<EditOutlined
onClick={() => {
setEditForm(alert);
setVisible(true);
form.setFieldsValue(alert);
}}
/>
<DeleteOutlined
onClick={(e) => {
e.stopPropagation();
handleDelete(alert);
}}
/>
</div>
)}
</div>
))}
<Modal title={(editForm ? '编辑' : '新增') + '聚合规则'} visible={visible} onOk={handleOk} onCancel={handleCancel} destroyOnClose>
<Form form={form} layout='vertical' preserve={false}>
<Form.Item
label='Name'
name='name'
rules={[
({ getFieldValue }) => ({
validator(_, value) {
if (!value || value.length === 0) {
return Promise.reject(new Error('请输入聚合规则名称'));
}
return Promise.resolve();
},
}),
]}
>
<Input />
</Form.Item>
<Form.Item name='id' hidden>
<Input />
</Form.Item>
<Form.Item
label='Rule'
name='rule'
rules={[
({ getFieldValue }) => ({
validator(_, value) {
if (!value || value.length === 0) {
return Promise.reject(new Error('请输入Rule'));
}
return Promise.resolve();
},
}),
]}
style={{ marginBottom: 5 }}
>
<Input />
</Form.Item>
</Form>
</Modal>
</div>
);
}
Example #10
Source File: List.tsx From fe-v5 with Apache License 2.0 | 4 votes |
export default function List(props: IProps) {
const [list, setList] = useState([]);
const [active, setActive] = useState<number>();
const [search, setSearch] = useState('');
const [refreshFlag, setRefreshFlag] = useState(_.uniqueId('refreshFlag_'));
const { profile } = useSelector<AccountRootState, accountStoreState>((state) => state.account);
useEffect(() => {
const defaultMetricViewId = localStorage.getItem('metric-view-id') !== null ? Number(localStorage.getItem('metric-view-id')) : null;
getList().then((res) => {
setList(res);
let curId;
if (!defaultMetricViewId || !_.find(res, { id: defaultMetricViewId })) {
curId = _.get(_.head(res), 'id');
} else {
curId = defaultMetricViewId;
}
if (curId) {
setActive(curId);
const curItem = _.find(res, { id: curId });
let configs = {} as IMatch;
try {
configs = JSON.parse(curItem.configs);
configs.id = curId;
configs.refreshFlag = refreshFlag;
} catch (e) {
console.error(e);
}
props.onSelect({
...configs,
});
}
});
}, [refreshFlag]);
return (
<div className='n9e-metric-views-list'>
<div className='n9e-metric-views-list-header'>
<div className='metric-page-title'>快捷视图列表</div>
<a>
<PlusSquareOutlined
onClick={() => {
Form({
admin: profile.admin,
action: 'add',
visible: true,
range: props.range,
onOk: (record) => {
localStorage.setItem('metric-view-id', record.id);
setRefreshFlag(_.uniqueId('refreshFlag_'));
},
});
}}
/>
</a>
</div>
<Input
prefix={<SearchOutlined />}
value={search}
onChange={(e) => {
setSearch(e.target.value);
}}
/>
<div className='n9e-metric-views-list-content'>
{_.isEmpty(list)
? '暂无数据'
: _.map(
_.filter(list, (item) => {
if (search) {
let result = true;
try {
const reg = new RegExp(search, 'gi');
result = reg.test(item.name);
} catch (e) {
console.log(e);
}
return result;
}
return true;
}),
(item) => {
return (
<div
className={classNames({
'n9e-metric-views-list-content-item': true,
active: item.id === active,
})}
key={item.id}
onClick={() => {
setActive(item.id);
localStorage.setItem('metric-view-id', item.id);
const curItem = _.find(list, { id: item.id });
let configs = {} as IMatch;
try {
configs = JSON.parse(curItem.configs);
configs.id = item.id;
} catch (e) {
console.error(e);
}
props.onSelect({
...configs,
});
}}
>
<span className='name'>{item.name}</span>
{item.cate === 1 || profile.admin ? (
<span>
{item.cate === 0 && (
<span className='n9e-metric-views-list-content-item-cate' style={{ color: '#ccc' }}>
公开
</span>
)}
<div className='n9e-metric-views-list-content-item-opes'>
<EditOutlined
onClick={(e) => {
e.stopPropagation();
let configs = {} as any;
try {
configs = JSON.parse(item.configs);
configs.dynamicLabels = _.map(configs.dynamicLabels, 'label');
configs.dimensionLabels = _.map(configs.dimensionLabels, 'label');
} catch (e) {
console.error(e);
}
const initialValues = {
id: item.id,
name: item.name,
cate: item.cate === 0,
...configs,
};
Form({
admin: profile.admin,
action: 'edit',
visible: true,
range: props.range,
initialValues,
onOk: () => {
localStorage.setItem('metric-view-id', item.id);
setRefreshFlag(_.uniqueId('refreshFlag_'));
},
});
}}
/>
<DeleteOutlined
onClick={(e) => {
e.stopPropagation();
Modal.confirm({
title: '是否要删除?',
onOk: () => {
deleteMetricView({
ids: [item.id],
}).then(() => {
message.success('删除成功');
setRefreshFlag(_.uniqueId('refreshFlag_'));
});
},
});
}}
/>
<Tooltip title='导出配置' placement='right'>
<ExportOutlined
onClick={() => {
Export({
visible: true,
data: item.configs,
});
}}
/>
</Tooltip>
</div>
</span>
) : (
<span style={{ color: '#ccc' }}>公开</span>
)}
</div>
);
},
)}
</div>
</div>
);
}
Example #11
Source File: ServicesModal.tsx From condo with MIT License | 4 votes |
ServicesModal: React.FC<IServicesModalProps> = ({
visible,
onCancel,
onOk,
receipt,
currencyCode,
isDetailed,
}) => {
const intl = useIntl()
const AccountMessage = intl.formatMessage({ id: 'field.AccountNumberShort' })
const ShortFlatNumber = intl.formatMessage({ id: 'field.ShortFlatNumber' })
const moneyRender = useMemo(() => {
return getMoneyRender(intl, currencyCode)
}, [currencyCode])
const accountNumber = get(receipt, ['account', 'number'])
const address = get(receipt, ['property', 'address'])
const unitName = get(receipt, ['account', 'unitName'])
const configSize = useContext<SizeType>(ConfigProvider.SizeContext)
const modalTitleMessage = `${AccountMessage} ${accountNumber}`
const title = (
<Space direction={'vertical'} size={4}>
<Typography.Title level={3}>
{modalTitleMessage}
</Typography.Title>
<SubText size={configSize}>
{address}{unitName ? `, ${ShortFlatNumber} ${unitName}` : ''}
</SubText>
</Space>
)
const columns = useServicesTableColumns(isDetailed, currencyCode)
const { significantServices, insignificantServices } = splitServices(receipt)
const ExpandMessage = intl.formatMessage({ id: 'MoreReceiptsWithZeroCharge' }, {
count: insignificantServices.length,
})
const dataSource = formatRows(significantServices, insignificantServices, ExpandMessage)
const [expanded, setExpanded] = useState(false)
const handleRowExpand = () => setExpanded(!expanded)
// TODO (savelevMatthew): Move modal to common width-expandable component?
return (
<>
{isDetailed && <Global styles={WideModalStyles}/>}
<Modal
title={title}
visible={visible}
onOk={() => {
setExpanded(false)
onOk()
}}
onCancel={() => {
setExpanded(false)
onCancel()
}}
footer={null}
centered
className={'services-modal'}
style={{ marginTop:40 }}
>
<Table
bordered
tableLayout={'auto'}
columns={columns}
dataSource={dataSource}
pagination={false}
expandable={{
indentSize: 0,
// eslint-disable-next-line react/display-name
expandIcon: ({ expanded, onExpand, record }) => {
if (record.name !== ExpandMessage) return
if (expanded) return (
<ExpandIconWrapper>
<MinusSquareOutlined onClick={(e) => onExpand(record, e)}/>
</ExpandIconWrapper>
)
return (
<ExpandIconWrapper>
<PlusSquareOutlined onClick={(e) => onExpand(record, e)}/>
</ExpandIconWrapper>
)
},
}}
onExpand={handleRowExpand}
expandedRowKeys={expanded ? [ExpandMessage] : []}
rowKey={(record) => record.name}
onRow={(record) => ({
onClick: () => {
if (record.name === ExpandMessage) {
setExpanded(!expanded)
}
},
})}
summary={(pageData) => {
let totalToPay = 0
pageData.forEach(({ toPay }) => {
totalToPay += parseFloat(toPay || '0')
})
const pointedNumber = totalToPay.toFixed(2)
return (
<Table.Summary.Row>
<Table.Summary.Cell index={0} align={'right'} colSpan={columns.length}>
<Typography.Text strong>
{moneyRender(pointedNumber)}
</Typography.Text>
</Table.Summary.Cell>
</Table.Summary.Row>
)
}}
/>
</Modal>
</>
)
}