|
1 |
| -# @codingapi/flow-mobile |
| 1 | +# Flow-Mobile |
2 | 2 |
|
3 |
| -[English](#english) | [中文](#chinese) |
| 3 | +基于Mobile的流程引擎 |
4 | 4 |
|
5 |
| -## English |
6 |
| - |
7 |
| -A mobile-friendly flow designer component library built with React and TypeScript, based on LogicFlow. |
8 |
| - |
9 |
| -### Installation |
| 5 | +## 安装 |
10 | 6 |
|
11 | 7 | ```bash
|
| 8 | +# npm |
12 | 9 | npm install @codingapi/flow-mobile
|
13 |
| -# or |
14 |
| -yarn add @codingapi/flow-mobile |
15 |
| -``` |
16 | 10 |
|
17 |
| -### Features |
18 |
| - |
19 |
| -- 🎯 Mobile-optimized flow designer |
20 |
| -- 📱 Built on LogicFlow core |
21 |
| -- 🎨 Integrated with antd-mobile UI components |
22 |
| -- 🔧 Full TypeScript support |
23 |
| -- ⚡️ Redux state management |
24 |
| -- 🛠 Easy integration with React applications |
| 11 | +# yarn |
| 12 | +yarn add @codingapi/flow-mobile |
25 | 13 |
|
26 |
| -### Dependencies |
| 14 | +# pnpm |
| 15 | +pnpm add @codingapi/flow-mobile |
| 16 | +``` |
27 | 17 |
|
28 |
| -- React 16.8+ / 17 / 18 |
29 |
| -- React DOM 16.8+ / 17 / 18 |
30 |
| -- @codingapi/ui-framework |
31 |
| -- @codingapi/form-mobile |
32 |
| -- @logicflow/core |
33 |
| -- @logicflow/extension |
34 |
| -- antd-mobile |
| 18 | +## 使用 |
35 | 19 |
|
36 |
| -### Quick Start |
| 20 | +### 流程审批 |
37 | 21 |
|
38 | 22 | ```tsx
|
39 |
| -import { FlowDesigner } from '@codingapi/flow-mobile'; |
40 |
| - |
41 |
| -function App() { |
42 |
| - return ( |
43 |
| - <FlowDesigner |
44 |
| - // Add your flow configuration here |
45 |
| - /> |
46 |
| - ); |
| 23 | +import React from "react"; |
| 24 | +import {useLocation, useNavigate} from "react-router"; |
| 25 | +import {FlowView} from "@codingapi/flow-mobile"; |
| 26 | +import {Result} from "antd-mobile"; |
| 27 | +import {flowViews} from "@/config/flows"; |
| 28 | + |
| 29 | +const FlowDetailPage = () => { |
| 30 | + |
| 31 | + const location = useLocation(); |
| 32 | + const state = location.state; |
| 33 | + const navigate = useNavigate(); |
| 34 | + |
| 35 | + if (state) { |
| 36 | + return ( |
| 37 | + <> |
| 38 | + <FlowView |
| 39 | + view={flowViews} |
| 40 | + id={state.id} |
| 41 | + visible={true} |
| 42 | + setVisible={()=>{ |
| 43 | + navigate(-1); |
| 44 | + }} |
| 45 | + /> |
| 46 | + </> |
| 47 | + ) |
| 48 | + } |
| 49 | + |
| 50 | + return ( |
| 51 | + <> |
| 52 | + <Result |
| 53 | + status={"error"} |
| 54 | + title={"页面参数错误"} |
| 55 | + /> |
| 56 | + </> |
| 57 | + ) |
47 | 58 | }
|
48 |
| -``` |
49 |
| - |
50 |
| -### Documentation |
51 | 59 |
|
52 |
| -For detailed documentation and examples, please visit our [GitHub repository](https://github.com/codingapi/flow-mobile). |
| 60 | +export default FlowDetailPage; |
53 | 61 |
|
54 |
| -### Contributing |
| 62 | +``` |
55 | 63 |
|
56 |
| -We welcome contributions! Please see our [GitHub Issues](https://github.com/codingapi/flow-mobile/issues) for details. |
| 64 | +### 自定义视图拓展 |
57 | 65 |
|
58 |
| -### License |
| 66 | +* 自定义延期提醒 |
| 67 | +```tsx |
| 68 | +import React from "react"; |
| 69 | +import {PostponedFormProps} from "@codingapi/ui-framework"; |
| 70 | +import Popup from "@/components/popup"; |
| 71 | +import {DatePickerView} from "antd-mobile"; |
| 72 | +import dayjs from "dayjs"; |
| 73 | +import {dateLabelRenderer} from "@codingapi/form-mobile"; |
| 74 | + |
| 75 | +const PostponedFormView: React.FC<PostponedFormProps> = (props) => { |
| 76 | + |
| 77 | + const [value, setValue] = React.useState(new Date()); |
| 78 | + // 获取一小时后的日期 |
| 79 | + const now = dayjs().add(1, 'hour').toDate(); |
| 80 | + |
| 81 | + return ( |
| 82 | + <Popup |
| 83 | + visible={props.visible} |
| 84 | + setVisible={props.setVisible} |
| 85 | + position='bottom' |
| 86 | + title={"延期截止日期"} |
| 87 | + bodyStyle={{height: '50vh'}} |
| 88 | + onOk={() => { |
| 89 | + const diff = dayjs(value).diff(dayjs(now), 'hour') + 1; |
| 90 | + props.onFinish(diff); |
| 91 | + }} |
| 92 | + > |
| 93 | + <div> |
| 94 | + <DatePickerView |
| 95 | + precision={"hour"} |
| 96 | + renderLabel={dateLabelRenderer} |
| 97 | + value={value} |
| 98 | + min={now} |
| 99 | + onChange={(value) => { |
| 100 | + setValue(value); |
| 101 | + }} |
| 102 | + /> |
| 103 | + </div> |
| 104 | + </Popup> |
| 105 | + ) |
| 106 | +} |
59 | 107 |
|
60 |
| -Apache-2.0 © CodingAPI |
| 108 | +export default PostponedFormView; |
61 | 109 |
|
62 |
| ---- |
63 | 110 |
|
64 |
| -## Chinese |
| 111 | +``` |
| 112 | +添加自定义视图到配置中 |
| 113 | +``` |
| 114 | +import {PostponedFormViewKey} from "@codingapi/ui-framework"; |
| 115 | +import {ComponentBus} from "@codingapi/ui-framework"; |
| 116 | +import {FlowApiContent,FlowApi} from "@codingapi/flow-mobile"; |
| 117 | +import PostponedFormView from "@/components/flow/PostponedFormView"; |
65 | 118 |
|
66 |
| -一个基于 LogicFlow 的移动端流程设计器组件库,使用 React 和 TypeScript 构建。 |
| 119 | +ComponentBus.getInstance().registerComponent(PostponedFormViewKey,PostponedFormView); |
| 120 | +``` |
| 121 | +* 自定义选人组件 |
| 122 | +``` |
| 123 | +import React, {useEffect} from "react"; |
| 124 | +import {UserSelectFormProps} from "@codingapi/ui-framework"; |
| 125 | +import Popup from "@/components/popup"; |
| 126 | +import {Form,FormInput} from "@codingapi/form-mobile"; |
| 127 | +
|
| 128 | +const UserSelectFormView: React.FC<UserSelectFormProps> = (props) => { |
| 129 | +
|
| 130 | + const formInstance = Form.useForm(); |
| 131 | +
|
| 132 | + useEffect(() => { |
| 133 | + if(props.visible){ |
| 134 | + if(props.specifyUserIds){ |
| 135 | + formInstance.setFieldValue("users", props.specifyUserIds.join(",")); |
| 136 | + } |
| 137 | + } |
| 138 | + }, [props.visible]); |
| 139 | +
|
| 140 | + return ( |
| 141 | + <Popup |
| 142 | + visible={props.visible} |
| 143 | + setVisible={props.setVisible} |
| 144 | + position='bottom' |
| 145 | + title={"选人人员"} |
| 146 | + bodyStyle={{height: '50vh'}} |
| 147 | + onOk={() => { |
| 148 | + const users = formInstance.getFieldValue("users"); |
| 149 | + if(users){ |
| 150 | + const userIds = Array.of(...users.split(",")).map(item =>{ |
| 151 | + return { |
| 152 | + id: item, |
| 153 | + name: item |
| 154 | + } |
| 155 | + }); |
| 156 | + props.onFinish(userIds); |
| 157 | + } |
| 158 | + }} |
| 159 | + > |
| 160 | + <div> |
| 161 | + <Form |
| 162 | + form={formInstance} |
| 163 | + > |
| 164 | + <FormInput |
| 165 | + name={"users"} |
| 166 | + label={"人员"} |
| 167 | + placeholder={"请选择人员"} |
| 168 | + /> |
| 169 | + </Form> |
| 170 | +
|
| 171 | + </div> |
| 172 | + </Popup> |
| 173 | + ) |
| 174 | +} |
67 | 175 |
|
68 |
| -### 安装 |
| 176 | +export default UserSelectFormView; |
69 | 177 |
|
70 |
| -```bash |
71 |
| -npm install @codingapi/flow-mobile |
72 |
| -# 或 |
73 |
| -yarn add @codingapi/flow-mobile |
74 | 178 | ```
|
| 179 | +然后再注册到配置中。 |
75 | 180 |
|
76 |
| -### 特性 |
| 181 | +更多的实例请参考:https://github.com/codingapi/flow-mobile/tree/main/playground |
77 | 182 |
|
78 |
| -- 🎯 移动端优化的流程设计器 |
79 |
| -- 📱 基于 LogicFlow 核心 |
80 |
| -- 🎨 集成 antd-mobile UI 组件 |
81 |
| -- 🔧 完整的 TypeScript 支持 |
82 |
| -- ⚡️ Redux 状态管理 |
83 |
| -- 🛠 易于与 React 应用集成 |
| 183 | +## 开发 |
84 | 184 |
|
85 |
| -### 依赖 |
| 185 | +```bash |
| 186 | +# Install dependencies |
| 187 | +yarn install |
86 | 188 |
|
87 |
| -- React 16.8+ / 17 / 18 |
88 |
| -- React DOM 16.8+ / 17 / 18 |
89 |
| -- @codingapi/ui-framework |
90 |
| -- @codingapi/form-mobile |
91 |
| -- @logicflow/core |
92 |
| -- @logicflow/extension |
93 |
| -- antd-mobile |
| 189 | +# Start development server |
| 190 | +yarn dev |
94 | 191 |
|
95 |
| -### 快速开始 |
| 192 | +# Build for production |
| 193 | +yarn build |
96 | 194 |
|
97 |
| -```tsx |
98 |
| -import { FlowDesigner } from '@codingapi/flow-mobile'; |
99 |
| - |
100 |
| -function App() { |
101 |
| - return ( |
102 |
| - <FlowDesigner |
103 |
| - // 在这里添加流程配置 |
104 |
| - /> |
105 |
| - ); |
106 |
| -} |
| 195 | +# Run tests |
| 196 | +yarn test |
107 | 197 | ```
|
| 198 | +## 许可 |
108 | 199 |
|
109 |
| -### 文档 |
110 |
| - |
111 |
| -详细的文档和示例,请访问我们的 [GitHub 仓库](https://github.com/codingapi/flow-mobile)。 |
112 |
| - |
113 |
| -### 贡献 |
114 |
| - |
115 |
| -我们欢迎各种形式的贡献!详情请查看我们的 [GitHub Issues](https://github.com/codingapi/flow-mobile/issues)。 |
| 200 | +Apache-2.0 © [CodingAPI](https://github.com/codingapi/flow-mobile/blob/main/LICENSE) |
116 | 201 |
|
117 |
| -### 许可证 |
118 | 202 |
|
119 |
| -Apache-2.0 © CodingAPI |
|
0 commit comments