gbflowengine 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +271 -271
- package/dist/gbflowengine.css +1 -1
- package/dist/gbflowengine.js +8232 -6913
- package/dist/gbflowengine.js.map +1 -1
- package/dist/gbflowengine.umd.cjs +2 -2
- package/dist/gbflowengine.umd.cjs.map +1 -1
- package/package.json +85 -84
- package/src/center/DefinitionInspect.vue +291 -291
- package/src/center/FlowCenter.vue +33 -33
- package/src/center/index.js +29 -29
- package/src/center/storage.js +748 -748
- package/src/core/flow/condition.js +160 -160
- package/src/core/flow/customNode.js +385 -385
- package/src/core/flow/defaults.js +124 -124
- package/src/core/flow/flowConstant.js +265 -265
- package/src/core/flow/flowNodeUtils.js +29 -29
- package/src/core/flow/index.js +47 -47
- package/src/core/flow/node.js +44 -44
- package/src/core/flow/nodeFactory.js +58 -58
- package/src/core/flow/prediction.js +325 -325
- package/src/core/flow/schema.js +864 -864
- package/src/definition/FlowDefinitionDesigner.vue +338 -338
- package/src/definition/index.js +9 -9
- package/src/index.js +39 -39
- package/src/storage.js +200 -200
- package/src/testing/FlowTestPanel.vue +2502 -2502
- package/src/testing/UserConfigDrawer.vue +376 -376
- package/src/testing/diagram/FlowProgressDiagram.vue +318 -318
- package/src/testing/diagramModel.js +517 -517
- package/src/testing/index.js +23 -23
- package/src/testing/mock.js +246 -246
- package/src/testing/oaExecutors.js +51 -51
- package/src/testing/oaSeed.js +467 -467
- package/src/testing/sample.js +412 -412
- package/src/testing/seed.js +122 -122
- package/src/utils/format.js +27 -27
- package/src/visual/FlowCanvas.vue +440 -440
- package/src/visual/NodeProgressDetail.vue +43 -43
- package/src/visual/NodeStatusBadge.vue +17 -17
- package/src/visual/NodeWrap.vue +46 -46
- package/src/visual/ScWorkflow.vue +49 -49
- package/src/visual/SelectDialog.vue +459 -459
- package/src/visual/conditionHelpers.js +116 -116
- package/src/visual/index.js +6 -6
- package/src/visual/nodes/AddNode.vue +222 -222
- package/src/visual/nodes/ApproverNode.vue +347 -347
- package/src/visual/nodes/BranchNode.vue +441 -441
- package/src/visual/nodes/CustomNode.vue +339 -339
- package/src/visual/nodes/EndNode.vue +21 -21
- package/src/visual/nodes/PassNode.vue +100 -100
- package/src/visual/nodes/PromoterNode.vue +134 -134
- package/src/visual/nodes/RejectNode.vue +100 -100
- package/src/visual/nodes/SendNode.vue +151 -151
- package/src/visual/styles.scss +879 -879
- package/src/visual/useScNodeStatus.js +18 -18
- package/src/workbench/OaWorkbench.vue +1341 -1341
- package/src/workbench/components/ApprovalWorkspace.vue +2090 -2090
- package/src/workbench/components/CategoryIcon.vue +74 -74
- package/src/workbench/components/NotificationIcon.vue +73 -73
- package/src/workbench/components/ProcessSteps.vue +557 -557
- package/src/workbench/components/ResubmitDialog.vue +227 -227
- package/src/workbench/components/SidebarNav.vue +138 -138
- package/src/workbench/components/StartFlowDialog.vue +1058 -1058
- package/src/workbench/components/UserAvatar.vue +68 -68
- package/src/workbench/model.js +1080 -1080
- package/src/workbench/pages/DesignPage.vue +798 -798
- package/src/workbench/pages/HomePage.vue +1050 -1050
- package/src/workbench/pages/MonitorPage.vue +1029 -1029
- package/src/workbench/pages/NotificationsPage.vue +554 -554
- package/src/workbench/pages/RequestsPage.vue +644 -644
- package/src/workbench/pages/TaskCenterPage.vue +1155 -1155
- package/src/workbench/pages/TemplatesPage.vue +680 -680
- package/src/workbench/styles.scss +555 -555
- package/types/center.d.ts +5 -5
- package/types/core.d.ts +479 -479
- package/types/definition.d.ts +4 -4
- package/types/index.d.ts +34 -34
- package/types/testing.d.ts +20 -20
- package/types/visual.d.ts +20 -20
|
@@ -1,376 +1,376 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<el-drawer
|
|
3
|
-
:model-value="modelValue"
|
|
4
|
-
title="组织配置"
|
|
5
|
-
size="760px"
|
|
6
|
-
append-to-body
|
|
7
|
-
destroy-on-close
|
|
8
|
-
@update:model-value="emit('update:modelValue', $event)"
|
|
9
|
-
>
|
|
10
|
-
<div class="user-config">
|
|
11
|
-
<el-alert
|
|
12
|
-
type="info"
|
|
13
|
-
:closable="false"
|
|
14
|
-
show-icon
|
|
15
|
-
title="组织数据保存于本机浏览器;保存后对后续审批人解析生效,已生成的任务保持不变。"
|
|
16
|
-
/>
|
|
17
|
-
|
|
18
|
-
<el-tabs v-model="activeTab" class="user-config__tabs">
|
|
19
|
-
<el-tab-pane label="用户" name="users">
|
|
20
|
-
<div class="user-config__toolbar">
|
|
21
|
-
<span class="user-config__count">{{ draft.users.length }} 位用户</span>
|
|
22
|
-
<div class="user-config__actions">
|
|
23
|
-
<el-button size="small" @click="resetOrg">恢复内置组织</el-button>
|
|
24
|
-
<el-button size="small" type="primary" plain @click="addUser">新增用户</el-button>
|
|
25
|
-
</div>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<div class="user-config__list">
|
|
29
|
-
<div v-for="(user, index) in draft.users" :key="user.id" class="user-row">
|
|
30
|
-
<div class="user-row__head">
|
|
31
|
-
<el-tag size="small" type="info" effect="plain">#{{ user.id }}</el-tag>
|
|
32
|
-
<strong>{{ user.realName || '未命名用户' }}</strong>
|
|
33
|
-
<span class="user-row__dept">{{ deptNameOf(user.deptId) }}</span>
|
|
34
|
-
<el-button
|
|
35
|
-
class="user-row__delete"
|
|
36
|
-
link
|
|
37
|
-
type="danger"
|
|
38
|
-
@click="removeUser(index)"
|
|
39
|
-
>
|
|
40
|
-
删除
|
|
41
|
-
</el-button>
|
|
42
|
-
</div>
|
|
43
|
-
<div class="user-row__fields">
|
|
44
|
-
<el-input v-model="user.realName" size="small" placeholder="姓名">
|
|
45
|
-
<template #prepend>姓名</template>
|
|
46
|
-
</el-input>
|
|
47
|
-
<el-input v-model="user.username" size="small" placeholder="账号">
|
|
48
|
-
<template #prepend>账号</template>
|
|
49
|
-
</el-input>
|
|
50
|
-
<el-input v-model="user.title" size="small" placeholder="职务">
|
|
51
|
-
<template #prepend>职务</template>
|
|
52
|
-
</el-input>
|
|
53
|
-
<el-select
|
|
54
|
-
v-model="user.deptId"
|
|
55
|
-
size="small"
|
|
56
|
-
placeholder="部门"
|
|
57
|
-
@change="syncUserDept(user)"
|
|
58
|
-
>
|
|
59
|
-
<el-option
|
|
60
|
-
v-for="dept in departmentOptions"
|
|
61
|
-
:key="dept.id"
|
|
62
|
-
:label="dept.label"
|
|
63
|
-
:value="dept.id"
|
|
64
|
-
/>
|
|
65
|
-
</el-select>
|
|
66
|
-
<el-select v-model="user.roleIds" size="small" multiple placeholder="角色">
|
|
67
|
-
<el-option
|
|
68
|
-
v-for="role in draft.roles"
|
|
69
|
-
:key="role.id"
|
|
70
|
-
:label="role.roleName"
|
|
71
|
-
:value="role.id"
|
|
72
|
-
/>
|
|
73
|
-
</el-select>
|
|
74
|
-
</div>
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
</el-tab-pane>
|
|
78
|
-
|
|
79
|
-
<el-tab-pane label="部门" name="departments">
|
|
80
|
-
<div class="group-list">
|
|
81
|
-
<div v-for="dept in departmentOptions" :key="dept.id" class="group-row">
|
|
82
|
-
<span class="group-row__name" :style="{ paddingLeft: `${dept.depth * 16}px` }">
|
|
83
|
-
{{ dept.name }}
|
|
84
|
-
</span>
|
|
85
|
-
<span class="group-row__meta">ID {{ dept.id }}</span>
|
|
86
|
-
<span class="group-row__meta">负责人:{{ userNameOf(dept.leaderId) }}</span>
|
|
87
|
-
<span class="group-row__meta">成员 {{ dept.memberCount }} 人</span>
|
|
88
|
-
</div>
|
|
89
|
-
</div>
|
|
90
|
-
</el-tab-pane>
|
|
91
|
-
|
|
92
|
-
<el-tab-pane label="角色" name="roles">
|
|
93
|
-
<div class="group-list">
|
|
94
|
-
<div v-for="role in draft.roles" :key="role.id" class="group-row">
|
|
95
|
-
<span class="group-row__name">{{ role.roleName }}</span>
|
|
96
|
-
<span class="group-row__meta">{{ role.roleKey }}</span>
|
|
97
|
-
<span class="group-row__meta">成员:{{ roleMembers(role.id) }}</span>
|
|
98
|
-
</div>
|
|
99
|
-
</div>
|
|
100
|
-
</el-tab-pane>
|
|
101
|
-
</el-tabs>
|
|
102
|
-
</div>
|
|
103
|
-
|
|
104
|
-
<template #footer>
|
|
105
|
-
<div class="user-config__footer">
|
|
106
|
-
<span class="user-config__hint">用户配置保存在本机浏览器,刷新后仍保留</span>
|
|
107
|
-
<el-button @click="emit('update:modelValue', false)">取消</el-button>
|
|
108
|
-
<el-button type="primary" @click="save">保存配置</el-button>
|
|
109
|
-
</div>
|
|
110
|
-
</template>
|
|
111
|
-
</el-drawer>
|
|
112
|
-
</template>
|
|
113
|
-
|
|
114
|
-
<script setup>
|
|
115
|
-
import { computed, ref, watch } from 'vue'
|
|
116
|
-
import { ElMessage } from 'element-plus'
|
|
117
|
-
|
|
118
|
-
defineOptions({ name: 'GbFlowUserConfigDrawer' })
|
|
119
|
-
|
|
120
|
-
const props = defineProps({
|
|
121
|
-
modelValue: { type: Boolean, default: false },
|
|
122
|
-
users: { type: Array, default: () => [] },
|
|
123
|
-
departments: { type: Array, default: () => [] },
|
|
124
|
-
roles: { type: Array, default: () => [] },
|
|
125
|
-
defaults: { type: Object, default: null }
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
const emit = defineEmits(['update:modelValue', 'save'])
|
|
129
|
-
|
|
130
|
-
const activeTab = ref('users')
|
|
131
|
-
const draft = ref({ users: [], departments: [], roles: [] })
|
|
132
|
-
|
|
133
|
-
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
134
|
-
|
|
135
|
-
const resetDraft = () => {
|
|
136
|
-
draft.value = {
|
|
137
|
-
users: clone(props.users),
|
|
138
|
-
departments: clone(props.departments),
|
|
139
|
-
roles: clone(props.roles)
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
watch(
|
|
144
|
-
() => props.modelValue,
|
|
145
|
-
(visible) => {
|
|
146
|
-
if (visible) {
|
|
147
|
-
resetDraft()
|
|
148
|
-
activeTab.value = 'users'
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
|
-
)
|
|
152
|
-
|
|
153
|
-
const deptMap = computed(
|
|
154
|
-
() => new Map(draft.value.departments.map((dept) => [String(dept.id), dept]))
|
|
155
|
-
)
|
|
156
|
-
const userNameOf = (userId) =>
|
|
157
|
-
draft.value.users.find((user) => String(user.id) === String(userId))?.realName ||
|
|
158
|
-
'未指定'
|
|
159
|
-
const deptNameOf = (deptId) => deptMap.value.get(String(deptId))?.name || '未分配'
|
|
160
|
-
const roleMembers = (roleId) =>
|
|
161
|
-
draft.value.users
|
|
162
|
-
.filter((user) => (user.roleIds || []).some((id) => String(id) === String(roleId)))
|
|
163
|
-
.map((user) => user.realName)
|
|
164
|
-
.join('、') || '无'
|
|
165
|
-
|
|
166
|
-
const departmentOptions = computed(() => {
|
|
167
|
-
const children = new Map()
|
|
168
|
-
draft.value.departments.forEach((dept) => {
|
|
169
|
-
const key = String(dept.parentId || 0)
|
|
170
|
-
if (!children.has(key)) children.set(key, [])
|
|
171
|
-
children.get(key).push(dept)
|
|
172
|
-
})
|
|
173
|
-
const rows = []
|
|
174
|
-
const walk = (parentId, depth) => {
|
|
175
|
-
;(children.get(String(parentId)) || []).forEach((dept) => {
|
|
176
|
-
rows.push({
|
|
177
|
-
...dept,
|
|
178
|
-
depth,
|
|
179
|
-
label: `${' '.repeat(depth)}${dept.name}`,
|
|
180
|
-
memberCount: draft.value.users.filter((user) => String(user.deptId) === String(dept.id))
|
|
181
|
-
.length
|
|
182
|
-
})
|
|
183
|
-
walk(dept.id, depth + 1)
|
|
184
|
-
})
|
|
185
|
-
}
|
|
186
|
-
walk(0, 0)
|
|
187
|
-
return rows
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
const syncUserDept = (user) => {
|
|
191
|
-
user.deptName = deptNameOf(user.deptId)
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
const addUser = () => {
|
|
195
|
-
const nextId = draft.value.users.reduce((max, user) => Math.max(max, Number(user.id) || 0), 0) + 1
|
|
196
|
-
const defaultDept = departmentOptions.value[0]
|
|
197
|
-
draft.value.users.push({
|
|
198
|
-
id: nextId,
|
|
199
|
-
username: `testuser${nextId}`,
|
|
200
|
-
realName: `新用户${nextId}`,
|
|
201
|
-
title: '测试成员',
|
|
202
|
-
deptId: defaultDept?.id ?? null,
|
|
203
|
-
deptName: defaultDept?.name || '',
|
|
204
|
-
roleIds: []
|
|
205
|
-
})
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
const removeUser = (index) => {
|
|
209
|
-
if (draft.value.users.length <= 1) {
|
|
210
|
-
ElMessage.warning('至少保留一位用户')
|
|
211
|
-
return
|
|
212
|
-
}
|
|
213
|
-
draft.value.users.splice(index, 1)
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
const resetOrg = () => {
|
|
217
|
-
if (!props.defaults) {
|
|
218
|
-
ElMessage.warning('没有可用的默认组织数据')
|
|
219
|
-
return
|
|
220
|
-
}
|
|
221
|
-
draft.value = {
|
|
222
|
-
users: clone(props.defaults.users),
|
|
223
|
-
departments: clone(props.defaults.departments),
|
|
224
|
-
roles: clone(props.defaults.roles)
|
|
225
|
-
}
|
|
226
|
-
ElMessage.success('已恢复内置组织,保存后生效')
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
const save = () => {
|
|
230
|
-
const users = draft.value.users.filter((user) => String(user.realName || '').trim())
|
|
231
|
-
if (!users.length) {
|
|
232
|
-
ElMessage.warning('至少保留一位有姓名的用户')
|
|
233
|
-
return
|
|
234
|
-
}
|
|
235
|
-
const ids = new Set()
|
|
236
|
-
for (const user of users) {
|
|
237
|
-
if (ids.has(String(user.id))) {
|
|
238
|
-
ElMessage.warning(`用户 ID ${user.id} 重复`)
|
|
239
|
-
return
|
|
240
|
-
}
|
|
241
|
-
ids.add(String(user.id))
|
|
242
|
-
user.deptName = deptNameOf(user.deptId)
|
|
243
|
-
}
|
|
244
|
-
emit('save', {
|
|
245
|
-
users: clone(users),
|
|
246
|
-
departments: clone(draft.value.departments),
|
|
247
|
-
roles: clone(draft.value.roles)
|
|
248
|
-
})
|
|
249
|
-
emit('update:modelValue', false)
|
|
250
|
-
}
|
|
251
|
-
</script>
|
|
252
|
-
|
|
253
|
-
<style scoped lang="scss">
|
|
254
|
-
.user-config {
|
|
255
|
-
height: 100%;
|
|
256
|
-
display: flex;
|
|
257
|
-
flex-direction: column;
|
|
258
|
-
|
|
259
|
-
&__tabs {
|
|
260
|
-
margin-top: 12px;
|
|
261
|
-
flex: 1;
|
|
262
|
-
min-height: 0;
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
&__toolbar {
|
|
266
|
-
display: flex;
|
|
267
|
-
align-items: center;
|
|
268
|
-
justify-content: space-between;
|
|
269
|
-
margin-bottom: 10px;
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
&__count {
|
|
273
|
-
font-size: 12px;
|
|
274
|
-
color: #94a3b8;
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
&__actions {
|
|
278
|
-
display: flex;
|
|
279
|
-
gap: 8px;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
&__list {
|
|
283
|
-
display: flex;
|
|
284
|
-
flex-direction: column;
|
|
285
|
-
gap: 10px;
|
|
286
|
-
max-height: calc(100vh - 280px);
|
|
287
|
-
overflow: auto;
|
|
288
|
-
padding-right: 4px;
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
&__footer {
|
|
292
|
-
display: flex;
|
|
293
|
-
align-items: center;
|
|
294
|
-
justify-content: flex-end;
|
|
295
|
-
gap: 8px;
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
&__hint {
|
|
299
|
-
margin-right: auto;
|
|
300
|
-
font-size: 12px;
|
|
301
|
-
color: #94a3b8;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
.user-row {
|
|
306
|
-
border: 1px solid #e2e8f0;
|
|
307
|
-
border-radius: 8px;
|
|
308
|
-
padding: 10px 12px;
|
|
309
|
-
background: #fbfdff;
|
|
310
|
-
|
|
311
|
-
&__head {
|
|
312
|
-
display: flex;
|
|
313
|
-
align-items: center;
|
|
314
|
-
gap: 8px;
|
|
315
|
-
margin-bottom: 8px;
|
|
316
|
-
|
|
317
|
-
strong {
|
|
318
|
-
font-size: 13px;
|
|
319
|
-
color: #1e293b;
|
|
320
|
-
}
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
&__dept {
|
|
324
|
-
font-size: 12px;
|
|
325
|
-
color: #94a3b8;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
&__delete {
|
|
329
|
-
margin-left: auto;
|
|
330
|
-
}
|
|
331
|
-
|
|
332
|
-
&__fields {
|
|
333
|
-
display: grid;
|
|
334
|
-
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
335
|
-
gap: 8px;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
.group-list {
|
|
340
|
-
display: flex;
|
|
341
|
-
flex-direction: column;
|
|
342
|
-
gap: 1px;
|
|
343
|
-
border: 1px solid #eef2f7;
|
|
344
|
-
border-radius: 8px;
|
|
345
|
-
overflow: hidden;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
.group-row {
|
|
349
|
-
display: flex;
|
|
350
|
-
align-items: center;
|
|
351
|
-
gap: 12px;
|
|
352
|
-
padding: 10px 12px;
|
|
353
|
-
background: #fff;
|
|
354
|
-
|
|
355
|
-
&:nth-child(even) {
|
|
356
|
-
background: #fbfdff;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
&__name {
|
|
360
|
-
min-width: 180px;
|
|
361
|
-
font-weight: 500;
|
|
362
|
-
color: #334155;
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
&__meta {
|
|
366
|
-
font-size: 12px;
|
|
367
|
-
color: #94a3b8;
|
|
368
|
-
}
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
@media (max-width: 760px) {
|
|
372
|
-
.user-row__fields {
|
|
373
|
-
grid-template-columns: 1fr;
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<el-drawer
|
|
3
|
+
:model-value="modelValue"
|
|
4
|
+
title="组织配置"
|
|
5
|
+
size="760px"
|
|
6
|
+
append-to-body
|
|
7
|
+
destroy-on-close
|
|
8
|
+
@update:model-value="emit('update:modelValue', $event)"
|
|
9
|
+
>
|
|
10
|
+
<div class="user-config">
|
|
11
|
+
<el-alert
|
|
12
|
+
type="info"
|
|
13
|
+
:closable="false"
|
|
14
|
+
show-icon
|
|
15
|
+
title="组织数据保存于本机浏览器;保存后对后续审批人解析生效,已生成的任务保持不变。"
|
|
16
|
+
/>
|
|
17
|
+
|
|
18
|
+
<el-tabs v-model="activeTab" class="user-config__tabs">
|
|
19
|
+
<el-tab-pane label="用户" name="users">
|
|
20
|
+
<div class="user-config__toolbar">
|
|
21
|
+
<span class="user-config__count">{{ draft.users.length }} 位用户</span>
|
|
22
|
+
<div class="user-config__actions">
|
|
23
|
+
<el-button size="small" @click="resetOrg">恢复内置组织</el-button>
|
|
24
|
+
<el-button size="small" type="primary" plain @click="addUser">新增用户</el-button>
|
|
25
|
+
</div>
|
|
26
|
+
</div>
|
|
27
|
+
|
|
28
|
+
<div class="user-config__list">
|
|
29
|
+
<div v-for="(user, index) in draft.users" :key="user.id" class="user-row">
|
|
30
|
+
<div class="user-row__head">
|
|
31
|
+
<el-tag size="small" type="info" effect="plain">#{{ user.id }}</el-tag>
|
|
32
|
+
<strong>{{ user.realName || '未命名用户' }}</strong>
|
|
33
|
+
<span class="user-row__dept">{{ deptNameOf(user.deptId) }}</span>
|
|
34
|
+
<el-button
|
|
35
|
+
class="user-row__delete"
|
|
36
|
+
link
|
|
37
|
+
type="danger"
|
|
38
|
+
@click="removeUser(index)"
|
|
39
|
+
>
|
|
40
|
+
删除
|
|
41
|
+
</el-button>
|
|
42
|
+
</div>
|
|
43
|
+
<div class="user-row__fields">
|
|
44
|
+
<el-input v-model="user.realName" size="small" placeholder="姓名">
|
|
45
|
+
<template #prepend>姓名</template>
|
|
46
|
+
</el-input>
|
|
47
|
+
<el-input v-model="user.username" size="small" placeholder="账号">
|
|
48
|
+
<template #prepend>账号</template>
|
|
49
|
+
</el-input>
|
|
50
|
+
<el-input v-model="user.title" size="small" placeholder="职务">
|
|
51
|
+
<template #prepend>职务</template>
|
|
52
|
+
</el-input>
|
|
53
|
+
<el-select
|
|
54
|
+
v-model="user.deptId"
|
|
55
|
+
size="small"
|
|
56
|
+
placeholder="部门"
|
|
57
|
+
@change="syncUserDept(user)"
|
|
58
|
+
>
|
|
59
|
+
<el-option
|
|
60
|
+
v-for="dept in departmentOptions"
|
|
61
|
+
:key="dept.id"
|
|
62
|
+
:label="dept.label"
|
|
63
|
+
:value="dept.id"
|
|
64
|
+
/>
|
|
65
|
+
</el-select>
|
|
66
|
+
<el-select v-model="user.roleIds" size="small" multiple placeholder="角色">
|
|
67
|
+
<el-option
|
|
68
|
+
v-for="role in draft.roles"
|
|
69
|
+
:key="role.id"
|
|
70
|
+
:label="role.roleName"
|
|
71
|
+
:value="role.id"
|
|
72
|
+
/>
|
|
73
|
+
</el-select>
|
|
74
|
+
</div>
|
|
75
|
+
</div>
|
|
76
|
+
</div>
|
|
77
|
+
</el-tab-pane>
|
|
78
|
+
|
|
79
|
+
<el-tab-pane label="部门" name="departments">
|
|
80
|
+
<div class="group-list">
|
|
81
|
+
<div v-for="dept in departmentOptions" :key="dept.id" class="group-row">
|
|
82
|
+
<span class="group-row__name" :style="{ paddingLeft: `${dept.depth * 16}px` }">
|
|
83
|
+
{{ dept.name }}
|
|
84
|
+
</span>
|
|
85
|
+
<span class="group-row__meta">ID {{ dept.id }}</span>
|
|
86
|
+
<span class="group-row__meta">负责人:{{ userNameOf(dept.leaderId) }}</span>
|
|
87
|
+
<span class="group-row__meta">成员 {{ dept.memberCount }} 人</span>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</el-tab-pane>
|
|
91
|
+
|
|
92
|
+
<el-tab-pane label="角色" name="roles">
|
|
93
|
+
<div class="group-list">
|
|
94
|
+
<div v-for="role in draft.roles" :key="role.id" class="group-row">
|
|
95
|
+
<span class="group-row__name">{{ role.roleName }}</span>
|
|
96
|
+
<span class="group-row__meta">{{ role.roleKey }}</span>
|
|
97
|
+
<span class="group-row__meta">成员:{{ roleMembers(role.id) }}</span>
|
|
98
|
+
</div>
|
|
99
|
+
</div>
|
|
100
|
+
</el-tab-pane>
|
|
101
|
+
</el-tabs>
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<template #footer>
|
|
105
|
+
<div class="user-config__footer">
|
|
106
|
+
<span class="user-config__hint">用户配置保存在本机浏览器,刷新后仍保留</span>
|
|
107
|
+
<el-button @click="emit('update:modelValue', false)">取消</el-button>
|
|
108
|
+
<el-button type="primary" @click="save">保存配置</el-button>
|
|
109
|
+
</div>
|
|
110
|
+
</template>
|
|
111
|
+
</el-drawer>
|
|
112
|
+
</template>
|
|
113
|
+
|
|
114
|
+
<script setup>
|
|
115
|
+
import { computed, ref, watch } from 'vue'
|
|
116
|
+
import { ElMessage } from 'element-plus'
|
|
117
|
+
|
|
118
|
+
defineOptions({ name: 'GbFlowUserConfigDrawer' })
|
|
119
|
+
|
|
120
|
+
const props = defineProps({
|
|
121
|
+
modelValue: { type: Boolean, default: false },
|
|
122
|
+
users: { type: Array, default: () => [] },
|
|
123
|
+
departments: { type: Array, default: () => [] },
|
|
124
|
+
roles: { type: Array, default: () => [] },
|
|
125
|
+
defaults: { type: Object, default: null }
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
const emit = defineEmits(['update:modelValue', 'save'])
|
|
129
|
+
|
|
130
|
+
const activeTab = ref('users')
|
|
131
|
+
const draft = ref({ users: [], departments: [], roles: [] })
|
|
132
|
+
|
|
133
|
+
const clone = (value) => JSON.parse(JSON.stringify(value))
|
|
134
|
+
|
|
135
|
+
const resetDraft = () => {
|
|
136
|
+
draft.value = {
|
|
137
|
+
users: clone(props.users),
|
|
138
|
+
departments: clone(props.departments),
|
|
139
|
+
roles: clone(props.roles)
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
watch(
|
|
144
|
+
() => props.modelValue,
|
|
145
|
+
(visible) => {
|
|
146
|
+
if (visible) {
|
|
147
|
+
resetDraft()
|
|
148
|
+
activeTab.value = 'users'
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
)
|
|
152
|
+
|
|
153
|
+
const deptMap = computed(
|
|
154
|
+
() => new Map(draft.value.departments.map((dept) => [String(dept.id), dept]))
|
|
155
|
+
)
|
|
156
|
+
const userNameOf = (userId) =>
|
|
157
|
+
draft.value.users.find((user) => String(user.id) === String(userId))?.realName ||
|
|
158
|
+
'未指定'
|
|
159
|
+
const deptNameOf = (deptId) => deptMap.value.get(String(deptId))?.name || '未分配'
|
|
160
|
+
const roleMembers = (roleId) =>
|
|
161
|
+
draft.value.users
|
|
162
|
+
.filter((user) => (user.roleIds || []).some((id) => String(id) === String(roleId)))
|
|
163
|
+
.map((user) => user.realName)
|
|
164
|
+
.join('、') || '无'
|
|
165
|
+
|
|
166
|
+
const departmentOptions = computed(() => {
|
|
167
|
+
const children = new Map()
|
|
168
|
+
draft.value.departments.forEach((dept) => {
|
|
169
|
+
const key = String(dept.parentId || 0)
|
|
170
|
+
if (!children.has(key)) children.set(key, [])
|
|
171
|
+
children.get(key).push(dept)
|
|
172
|
+
})
|
|
173
|
+
const rows = []
|
|
174
|
+
const walk = (parentId, depth) => {
|
|
175
|
+
;(children.get(String(parentId)) || []).forEach((dept) => {
|
|
176
|
+
rows.push({
|
|
177
|
+
...dept,
|
|
178
|
+
depth,
|
|
179
|
+
label: `${' '.repeat(depth)}${dept.name}`,
|
|
180
|
+
memberCount: draft.value.users.filter((user) => String(user.deptId) === String(dept.id))
|
|
181
|
+
.length
|
|
182
|
+
})
|
|
183
|
+
walk(dept.id, depth + 1)
|
|
184
|
+
})
|
|
185
|
+
}
|
|
186
|
+
walk(0, 0)
|
|
187
|
+
return rows
|
|
188
|
+
})
|
|
189
|
+
|
|
190
|
+
const syncUserDept = (user) => {
|
|
191
|
+
user.deptName = deptNameOf(user.deptId)
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
const addUser = () => {
|
|
195
|
+
const nextId = draft.value.users.reduce((max, user) => Math.max(max, Number(user.id) || 0), 0) + 1
|
|
196
|
+
const defaultDept = departmentOptions.value[0]
|
|
197
|
+
draft.value.users.push({
|
|
198
|
+
id: nextId,
|
|
199
|
+
username: `testuser${nextId}`,
|
|
200
|
+
realName: `新用户${nextId}`,
|
|
201
|
+
title: '测试成员',
|
|
202
|
+
deptId: defaultDept?.id ?? null,
|
|
203
|
+
deptName: defaultDept?.name || '',
|
|
204
|
+
roleIds: []
|
|
205
|
+
})
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
const removeUser = (index) => {
|
|
209
|
+
if (draft.value.users.length <= 1) {
|
|
210
|
+
ElMessage.warning('至少保留一位用户')
|
|
211
|
+
return
|
|
212
|
+
}
|
|
213
|
+
draft.value.users.splice(index, 1)
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const resetOrg = () => {
|
|
217
|
+
if (!props.defaults) {
|
|
218
|
+
ElMessage.warning('没有可用的默认组织数据')
|
|
219
|
+
return
|
|
220
|
+
}
|
|
221
|
+
draft.value = {
|
|
222
|
+
users: clone(props.defaults.users),
|
|
223
|
+
departments: clone(props.defaults.departments),
|
|
224
|
+
roles: clone(props.defaults.roles)
|
|
225
|
+
}
|
|
226
|
+
ElMessage.success('已恢复内置组织,保存后生效')
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
const save = () => {
|
|
230
|
+
const users = draft.value.users.filter((user) => String(user.realName || '').trim())
|
|
231
|
+
if (!users.length) {
|
|
232
|
+
ElMessage.warning('至少保留一位有姓名的用户')
|
|
233
|
+
return
|
|
234
|
+
}
|
|
235
|
+
const ids = new Set()
|
|
236
|
+
for (const user of users) {
|
|
237
|
+
if (ids.has(String(user.id))) {
|
|
238
|
+
ElMessage.warning(`用户 ID ${user.id} 重复`)
|
|
239
|
+
return
|
|
240
|
+
}
|
|
241
|
+
ids.add(String(user.id))
|
|
242
|
+
user.deptName = deptNameOf(user.deptId)
|
|
243
|
+
}
|
|
244
|
+
emit('save', {
|
|
245
|
+
users: clone(users),
|
|
246
|
+
departments: clone(draft.value.departments),
|
|
247
|
+
roles: clone(draft.value.roles)
|
|
248
|
+
})
|
|
249
|
+
emit('update:modelValue', false)
|
|
250
|
+
}
|
|
251
|
+
</script>
|
|
252
|
+
|
|
253
|
+
<style scoped lang="scss">
|
|
254
|
+
.user-config {
|
|
255
|
+
height: 100%;
|
|
256
|
+
display: flex;
|
|
257
|
+
flex-direction: column;
|
|
258
|
+
|
|
259
|
+
&__tabs {
|
|
260
|
+
margin-top: 12px;
|
|
261
|
+
flex: 1;
|
|
262
|
+
min-height: 0;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
&__toolbar {
|
|
266
|
+
display: flex;
|
|
267
|
+
align-items: center;
|
|
268
|
+
justify-content: space-between;
|
|
269
|
+
margin-bottom: 10px;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
&__count {
|
|
273
|
+
font-size: 12px;
|
|
274
|
+
color: #94a3b8;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
&__actions {
|
|
278
|
+
display: flex;
|
|
279
|
+
gap: 8px;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
&__list {
|
|
283
|
+
display: flex;
|
|
284
|
+
flex-direction: column;
|
|
285
|
+
gap: 10px;
|
|
286
|
+
max-height: calc(100vh - 280px);
|
|
287
|
+
overflow: auto;
|
|
288
|
+
padding-right: 4px;
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
&__footer {
|
|
292
|
+
display: flex;
|
|
293
|
+
align-items: center;
|
|
294
|
+
justify-content: flex-end;
|
|
295
|
+
gap: 8px;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
&__hint {
|
|
299
|
+
margin-right: auto;
|
|
300
|
+
font-size: 12px;
|
|
301
|
+
color: #94a3b8;
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
.user-row {
|
|
306
|
+
border: 1px solid #e2e8f0;
|
|
307
|
+
border-radius: 8px;
|
|
308
|
+
padding: 10px 12px;
|
|
309
|
+
background: #fbfdff;
|
|
310
|
+
|
|
311
|
+
&__head {
|
|
312
|
+
display: flex;
|
|
313
|
+
align-items: center;
|
|
314
|
+
gap: 8px;
|
|
315
|
+
margin-bottom: 8px;
|
|
316
|
+
|
|
317
|
+
strong {
|
|
318
|
+
font-size: 13px;
|
|
319
|
+
color: #1e293b;
|
|
320
|
+
}
|
|
321
|
+
}
|
|
322
|
+
|
|
323
|
+
&__dept {
|
|
324
|
+
font-size: 12px;
|
|
325
|
+
color: #94a3b8;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
&__delete {
|
|
329
|
+
margin-left: auto;
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
&__fields {
|
|
333
|
+
display: grid;
|
|
334
|
+
grid-template-columns: repeat(3, minmax(0, 1fr));
|
|
335
|
+
gap: 8px;
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
.group-list {
|
|
340
|
+
display: flex;
|
|
341
|
+
flex-direction: column;
|
|
342
|
+
gap: 1px;
|
|
343
|
+
border: 1px solid #eef2f7;
|
|
344
|
+
border-radius: 8px;
|
|
345
|
+
overflow: hidden;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
.group-row {
|
|
349
|
+
display: flex;
|
|
350
|
+
align-items: center;
|
|
351
|
+
gap: 12px;
|
|
352
|
+
padding: 10px 12px;
|
|
353
|
+
background: #fff;
|
|
354
|
+
|
|
355
|
+
&:nth-child(even) {
|
|
356
|
+
background: #fbfdff;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
&__name {
|
|
360
|
+
min-width: 180px;
|
|
361
|
+
font-weight: 500;
|
|
362
|
+
color: #334155;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
&__meta {
|
|
366
|
+
font-size: 12px;
|
|
367
|
+
color: #94a3b8;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
@media (max-width: 760px) {
|
|
372
|
+
.user-row__fields {
|
|
373
|
+
grid-template-columns: 1fr;
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
</style>
|