af-mobile-client-vue3 1.4.2 → 1.4.3

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.
@@ -1,958 +1,958 @@
1
- <script setup lang="ts">
2
- import { getConfigByName, openApiLogic } from '@af-mobile-client-vue3/services/api/common'
3
- import { useSettingStore } from '@af-mobile-client-vue3/stores/modules/setting'
4
- import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
5
- import {
6
- showFailToast,
7
- showSuccessToast,
8
- showToast,
9
- Button as VanButton,
10
- Empty as VanEmpty,
11
- Field as VanField,
12
- Form as VanForm,
13
- Icon as VanIcon,
14
- Loading as VanLoading,
15
- NavBar as VanNavBar,
16
- Popup as VanPopup,
17
- Radio as VanRadio,
18
- RadioGroup as VanRadioGroup,
19
- } from 'vant'
20
-
21
- import { onMounted, ref } from 'vue'
22
- import { useRoute, useRouter } from 'vue-router'
23
-
24
- interface FormData {
25
- name: string
26
- phone: string
27
- gender: string
28
- code: string
29
- email: string
30
- username: string
31
- password: string
32
- confirmPassword: string
33
- roles: string
34
- dept_name: string
35
- org_name: string
36
- strategyId: string
37
- openId: string
38
- }
39
- interface Errors {
40
- [key: string]: string | undefined
41
- name?: string
42
- phone?: string
43
- gender?: string
44
- email?: string
45
- username?: string
46
- password?: string
47
- confirmPassword?: string
48
- }
49
-
50
- interface OrganizationInfo {
51
- roles: string
52
- dept_name: string
53
- org_name: string
54
- }
55
-
56
- type UsernameStatus = 'initial' | 'checking' | 'available' | 'unavailable'
57
-
58
- const route = useRoute()
59
- const router = useRouter()
60
- const setting = useSettingStore()
61
-
62
- // 表单数据
63
- const formData = ref<FormData>({
64
- name: '',
65
- phone: '',
66
- gender: '',
67
- code: '',
68
- email: '',
69
- username: '',
70
- password: '',
71
- confirmPassword: '',
72
- roles: '',
73
- dept_name: '',
74
- org_name: '',
75
- strategyId: '',
76
- openId: '',
77
- })
78
- const initSuccess = ref(false)
79
- const showPassword = ref(false)
80
- const showConfirmPassword = ref(false)
81
- const openId = ref('')
82
- // 错误信息
83
- const errors = ref<Errors>({})
84
-
85
- const registerConfig = ref({})
86
-
87
- // 状态管理
88
- const isSubmitting = ref<boolean>(false)
89
- const showSuccess = ref<boolean>(false)
90
- const usernameStatus = ref<UsernameStatus>('initial')
91
-
92
- // 组织信息(从策略获取)
93
- const organizationInfo = ref<OrganizationInfo>({
94
- roles: '',
95
- dept_name: '',
96
- org_name: '',
97
- })
98
- // 防抖检查用户名
99
- let usernameCheckTimeout = null
100
-
101
- // 验证函数
102
- function validateName(): boolean {
103
- if (!formData.value.name.trim()) {
104
- errors.value.name = '员工姓名不能为空'
105
- return false
106
- }
107
- if (formData.value.name.length < 2) {
108
- errors.value.name = '员工姓名至少2个字符'
109
- return false
110
- }
111
- delete errors.value.name
112
- return true
113
- }
114
- function validateCode(): boolean {
115
- if (!formData.value.code.trim()) {
116
- errors.value.code = '员工编号不能为空'
117
- return false
118
- }
119
- delete errors.value.code
120
- return true
121
- }
122
-
123
- function validatePhone(): boolean {
124
- const phoneRegex = /^1[3-9]\d{9}$/
125
- if (!formData.value.phone.trim()) {
126
- errors.value.phone = '手机号码不能为空'
127
- return false
128
- }
129
- if (!phoneRegex.test(formData.value.phone)) {
130
- errors.value.phone = '请输入正确的手机号码'
131
- return false
132
- }
133
- delete errors.value.phone
134
- return true
135
- }
136
-
137
- function validateEmail(): boolean {
138
- if (formData.value.email.trim()) {
139
- const emailRegex = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/
140
- if (!emailRegex.test(formData.value.email)) {
141
- errors.value.email = '请输入正确的邮箱地址'
142
- return false
143
- }
144
- }
145
- delete errors.value.email
146
- return true
147
- }
148
-
149
- function validateUsername(): boolean {
150
- if (!formData.value.username.trim()) {
151
- errors.value.username = '登录名不能为空'
152
- return false
153
- }
154
- if (formData.value.username.length < 3) {
155
- errors.value.username = '登录名至少3个字符'
156
- return false
157
- }
158
- if (!/^\w+$/.test(formData.value.username)) {
159
- errors.value.username = '登录名只能包含字母、数字和下划线'
160
- return false
161
- }
162
-
163
- if (usernameStatus.value === 'unavailable') {
164
- errors.value.username = '该登录名已被使用,请选择其他登录名'
165
- return false
166
- }
167
-
168
- if (usernameStatus.value === 'checking') {
169
- errors.value.username = '正在检查登录名可用性,请稍候'
170
- return false
171
- }
172
-
173
- if (usernameStatus.value === 'initial') {
174
- checkUsernameAvailability()
175
- errors.value.username = '正在检查登录名可用性,请稍候'
176
- return false
177
- }
178
-
179
- delete errors.value.username
180
- return true
181
- }
182
-
183
- function validatePassword(): boolean {
184
- if (!formData.value.password) {
185
- errors.value.password = '登录密码不能为空'
186
- return false
187
- }
188
- if (formData.value.password.length < 6) {
189
- errors.value.password = '登录密码至少6个字符'
190
- return false
191
- }
192
- delete errors.value.password
193
- return true
194
- }
195
-
196
- function validateConfirmPassword(): boolean {
197
- if (!formData.value.confirmPassword) {
198
- errors.value.confirmPassword = '确认密码不能为空'
199
- return false
200
- }
201
- if (formData.value.password !== formData.value.confirmPassword) {
202
- errors.value.confirmPassword = '两次输入的密码不一致'
203
- return false
204
- }
205
- delete errors.value.confirmPassword
206
- return true
207
- }
208
-
209
- function validateGender(): boolean {
210
- if (!formData.value.gender) {
211
- errors.value.gender = '请选择性别'
212
- return false
213
- }
214
- delete errors.value.gender
215
- return true
216
- }
217
-
218
- function validateAll(): boolean {
219
- const validations = [
220
- validateName(),
221
- validateCode(),
222
- validatePhone(),
223
- validateEmail(),
224
- validateUsername(),
225
- validatePassword(),
226
- validateConfirmPassword(),
227
- validateGender(),
228
- ]
229
- return validations.every(v => v)
230
- }
231
-
232
- // 检查用户名可用性
233
- async function checkUsernameAvailability(): Promise<void> {
234
- usernameStatus.value = 'checking'
235
-
236
- try {
237
- const response = await openApiLogic({ username: formData.value.username }, 'checkUserName', 'af-system')
238
- console.log('response', response)
239
- if (response.success) {
240
- usernameStatus.value = 'available'
241
- delete errors.value.username
242
- }
243
- else {
244
- errors.value.username = '该登录名已被使用,请选择其他登录名'
245
- usernameStatus.value = 'unavailable'
246
- }
247
- }
248
- catch (error) {
249
- // 模拟检查逻辑
250
- const existingUsernames = ['admin', 'user001', 'zhangsan', 'lisi', 'wangwu']
251
- if (existingUsernames.includes(formData.value.username.toLowerCase())) {
252
- errors.value.username = '该登录名已被使用,请选择其他登录名'
253
- usernameStatus.value = 'unavailable'
254
- }
255
- else {
256
- usernameStatus.value = 'available'
257
- delete errors.value.username
258
- }
259
- }
260
- }
261
-
262
- // 获取组织信息
263
- async function fetchOrganizationInfo(strategyId: any): Promise<void> {
264
- try {
265
- const response = await openApiLogic({ strategyId }, 'getOrganizationInfo', 'af-system')
266
- if (response.success) {
267
- initSuccess.value = true
268
- Object.assign(organizationInfo.value, response.data)
269
- // 更新表单数据
270
- formData.value.roles = organizationInfo.value.roles
271
- formData.value.dept_name = organizationInfo.value.dept_name
272
- formData.value.org_name = organizationInfo.value.org_name
273
- formData.value.strategyId = strategyId
274
- }
275
- else {
276
- showFailToast(response.msg)
277
- }
278
- }
279
- catch (error) {
280
- console.error('获取组织信息失败:', error)
281
- showToast('获取组织信息失败')
282
- }
283
- }
284
-
285
- async function initConfig(): Promise<void> {
286
- try {
287
- getConfigByName('registerConfig', (res: any) => {
288
- console.log('res', res)
289
- }, 'af-system')
290
- }
291
- catch (error) {
292
- console.error('获取组织信息失败:', error)
293
- showToast('获取组织信息失败')
294
- }
295
- }
296
-
297
- // 提交注册
298
- async function submitRegistration(): Promise<void> {
299
- if (usernameStatus.value === 'checking') {
300
- showToast('请等待登录名检查完成')
301
- return
302
- }
303
-
304
- if (!validateAll()) {
305
- showToast('请填写必填信息!')
306
- return
307
- }
308
-
309
- isSubmitting.value = true
310
-
311
- try {
312
- console.log('formData', formData.value)
313
- const response = await openApiLogic(formData.value, 'registrationUser', 'af-system')
314
- if (response.success) {
315
- showSuccess.value = true
316
- showSuccessToast('注册成功')
317
- await useUserStore().registerClean()
318
- }
319
- else {
320
- showSuccessToast(`注册失败,${response.msg}!`)
321
- }
322
- isSubmitting.value = false
323
- }
324
- catch (error) {
325
- isSubmitting.value = false
326
- showToast('注册失败,请重试')
327
- }
328
- }
329
-
330
- // 重置表单
331
- function resetForm(): void {
332
- Object.assign(formData.value, {
333
- name: '',
334
- phone: '',
335
- gender: '',
336
- code: '',
337
- email: '',
338
- username: '',
339
- password: '',
340
- confirmPassword: '',
341
- })
342
- Object.keys(errors.value).forEach(key => delete errors.value[key])
343
- showPassword.value = false
344
- showConfirmPassword.value = false
345
- showSuccess.value = false
346
- usernameStatus.value = 'initial'
347
- }
348
-
349
- function debounceUsernameCheck() {
350
- if (usernameCheckTimeout) {
351
- clearTimeout(usernameCheckTimeout)
352
- }
353
-
354
- // 重置状态
355
- usernameStatus.value = 'initial'
356
- delete errors.value.username
357
-
358
- // 基本验证
359
- if (!formData.value.username.trim()) {
360
- return
361
- }
362
- if (formData.value.username.length < 3) {
363
- return
364
- }
365
- if (!/^\w+$/.test(formData.value.username)) {
366
- return
367
- }
368
-
369
- // 设置新的定时器
370
- usernameCheckTimeout = setTimeout(() => {
371
- checkUsernameAvailability()
372
- }, 500) // 500ms 防抖延迟
373
- }
374
-
375
- // 提交注册
376
- async function handleSubmit() {
377
- if (usernameStatus.value === 'checking') {
378
- showToast('请等待登录名检查完成')
379
- return
380
- }
381
-
382
- await submitRegistration()
383
- }
384
-
385
- // 返回上一页
386
- function goBack() {
387
- router.push('/login')
388
- }
389
-
390
- // 组件挂载时获取组织信息
391
- onMounted(async () => {
392
- console.log('route.query', route.query)
393
- console.log('route.params', route.params)
394
- const strategyId = route.query.strategyId || route.params.strategyId
395
- openId.value = route.query.openId as string || route.params.openId as string
396
- formData.value.openId = openId.value
397
- if (strategyId) {
398
- await fetchOrganizationInfo(strategyId)
399
- }
400
- else {
401
- if (setting.getSetting()?.registerRequire) {
402
- showFailToast('缺少组织信息,请确二维码准确性')
403
- }
404
- }
405
- })
406
- </script>
407
-
408
- <template>
409
- <div class="employee-registration">
410
- <!-- 顶部导航栏 -->
411
- <VanNavBar
412
- title="员工注册"
413
-
414
- placeholder fixed
415
- />
416
- <div v-show="!initSuccess">
417
- <VanEmpty image="error" description="推广码无效/已过期" />
418
- </div>
419
- <!-- 主要内容区域 -->
420
- <div v-show="initSuccess" class="main-content">
421
- <div class="form-container">
422
- <!-- 表单标题 -->
423
- <div class="form-header">
424
- <h2 class="form-title">
425
- 员工信息录入
426
- </h2>
427
- <p class="form-subtitle">
428
- 请填写员工基本信息完成账号注册
429
- </p>
430
- </div>
431
-
432
- <!-- 注册表单 -->
433
- <VanForm @submit="submitRegistration">
434
- <!-- 基本信息 -->
435
- <div class="form-section">
436
- <div class="section-header">
437
- <span class="section-title">基本信息</span>
438
- </div>
439
-
440
- <!-- 员工姓名 -->
441
- <VanField
442
- v-model="formData.name"
443
- label="员工姓名"
444
- placeholder="请输入员工姓名"
445
- :error="!!errors.name"
446
- :error-message="errors.name"
447
- label-align="top"
448
- :border="true"
449
- @blur="validateName"
450
- >
451
- <template #label>
452
- <i class="i-material-symbols-person text-blue-500" />
453
- 员工姓名 <span class="required">*</span>
454
- </template>
455
- </VanField>
456
-
457
- <!-- 手机号码 -->
458
- <VanField
459
- v-model="formData.phone"
460
- label="手机号码"
461
- type="tel"
462
- placeholder="请输入手机号码"
463
- :error="!!errors.phone"
464
- :error-message="errors.phone"
465
- label-align="top"
466
- @blur="validatePhone"
467
- >
468
- <template #label>
469
- <i class="i-flowbite-mobile-phone-solid text-green-500" />
470
- 手机号码 <span class="required">*</span>
471
- </template>
472
- </VanField>
473
-
474
- <!-- 性别 -->
475
- <VanField
476
- label="性别"
477
- :error="!!errors.gender"
478
- :error-message="errors.gender"
479
- label-align="top"
480
- >
481
- <template #label>
482
- <i class="i-fa6-solid-venus-mars text-pink-500" />
483
- 性别 <span class="required">*</span>
484
- </template>
485
- <template #input>
486
- <VanRadioGroup v-model="formData.gender" @change="validateGender">
487
- <VanRadio name="男">
488
-
489
- </VanRadio>
490
- <VanRadio name="女">
491
-
492
- </VanRadio>
493
- </VanRadioGroup>
494
- </template>
495
- </VanField>
496
- <!-- 员工编号 -->
497
- <VanField
498
- v-model="formData.code"
499
- label="员工编号"
500
- placeholder="请输入员工编号"
501
- :error="!!errors.code"
502
- :error-message="errors.code"
503
- label-align="top"
504
- @blur="validateCode"
505
- >
506
- <template #label>
507
- <i class="i-solar-user-id-bold text-purple-500" />
508
- 员工编号 <span class="required">*</span>
509
- </template>
510
- </VanField>
511
- <!-- 邮箱 -->
512
- <VanField
513
- v-model="formData.email"
514
- label="邮箱"
515
- type="email"
516
- placeholder="请输入邮箱地址(可选)"
517
- :error="!!errors.email"
518
- :error-message="errors.email"
519
- label-align="top"
520
- @blur="validateEmail"
521
- >
522
- <template #label>
523
- <i class="i-material-symbols-mail text-purple-500" />
524
- 邮箱
525
- </template>
526
- </VanField>
527
- </div>
528
-
529
- <!-- 账号信息 -->
530
- <div class="form-section">
531
- <div class="section-header">
532
- <span class="section-title">账号信息</span>
533
- </div>
534
-
535
- <!-- 登录名 -->
536
- <VanField
537
- v-model="formData.username"
538
- label="登录名"
539
- placeholder="请输入登录名"
540
- :error="!!errors.username"
541
- :error-message="errors.username"
542
- label-align="top"
543
- @blur="validateUsername"
544
- @input="debounceUsernameCheck"
545
- >
546
- <template #label>
547
- <i class="i-material-symbols-id-card text-indigo-500" />
548
- 登录名 <span class="required">*</span>
549
- </template>
550
- <template #right-icon>
551
- <!-- 检查中状态 -->
552
- <VanLoading v-if="usernameStatus === 'checking'" size="16px" />
553
- <!-- 可用状态 -->
554
- <i v-else-if="usernameStatus === 'available'" class="i-material-symbols-check-circle text-green-500" />
555
- <i v-else-if="usernameStatus === 'unavailable'" class="i-iconamoon-sign-times-circle text-red-500" />
556
- </template>
557
- </VanField>
558
-
559
- <!-- 登录密码 -->
560
- <VanField
561
- v-model="formData.password"
562
- label="登录密码"
563
- :type="showPassword ? 'text' : 'password'"
564
- placeholder="请输入登录密码"
565
- :error="!!errors.password"
566
- :error-message="errors.password"
567
- label-align="top"
568
- @blur="validatePassword"
569
- >
570
- <template #label>
571
- <i class="i-material-symbols-lock text-orange-500" />
572
- 登录密码 <span class="required">*</span>
573
- </template>
574
- <template #right-icon>
575
- <VanIcon
576
- :name="showPassword ? 'eye-o' : 'closed-eye'"
577
- @click="showPassword = !showPassword"
578
- />
579
- </template>
580
- </VanField>
581
-
582
- <!-- 确认密码 -->
583
- <VanField
584
- v-model="formData.confirmPassword"
585
- label="确认密码"
586
- :type="showConfirmPassword ? 'text' : 'password'"
587
- placeholder="请再次输入登录密码"
588
- :error="!!errors.confirmPassword"
589
- :error-message="errors.confirmPassword"
590
- label-align="top"
591
- @blur="validateConfirmPassword"
592
- >
593
- <template #label>
594
- <i class="i-bxs-shield-alt-2 text-teal-500" />
595
- 确认密码 <span class="required">*</span>
596
- </template>
597
- <template #right-icon>
598
- <VanIcon
599
- :name="showConfirmPassword ? 'eye-o' : 'closed-eye'"
600
- @click="showConfirmPassword = !showConfirmPassword"
601
- />
602
- </template>
603
- </VanField>
604
- </div>
605
-
606
- <!-- 组织信息 -->
607
- <div class="form-section">
608
- <div class="section-header">
609
- <span class="section-title">组织信息</span>
610
- </div>
611
-
612
- <!-- 所属角色 -->
613
- <VanField
614
- v-model="formData.roles"
615
- label="所属角色"
616
- readonly
617
- disabled
618
- label-align="top"
619
- >
620
- <template #label>
621
- <i class="i-fa6-solid-user-tag text-blue-600" />
622
- 所属角色
623
- </template>
624
- </VanField>
625
- <div class="field-hint">
626
- 系统默认分配,不可修改
627
- </div>
628
-
629
- <!-- 所属部门 -->
630
- <VanField
631
- v-model="formData.dept_name"
632
- label="所属部门"
633
- readonly
634
- disabled
635
- label-align="top"
636
- >
637
- <template #label>
638
- <i class="i-material-symbols-home-work text-gray-600" />
639
- 所属部门
640
- </template>
641
- </VanField>
642
- <div class="field-hint">
643
- 系统默认分配,不可修改
644
- </div>
645
-
646
- <!-- 所属分公司 -->
647
- <VanField
648
- v-model="formData.org_name"
649
- label="所属分公司"
650
- readonly
651
- disabled
652
- label-align="top"
653
- >
654
- <template #label>
655
- <i class="i-line-md-map-marker-alt-filled text-red-500" />
656
- 所属分公司
657
- </template>
658
- </VanField>
659
- <div class="field-hint">
660
- 系统默认分配,不可修改
661
- </div>
662
- </div>
663
-
664
- <!-- 提交按钮 -->
665
- <div class="form-actions">
666
- <VanButton
667
- type="default"
668
- size="large"
669
- :disabled="isSubmitting"
670
- class="reset-btn"
671
- @click="resetForm"
672
- >
673
- <i class="i-hugeicons-redo" />
674
- 重置
675
- </VanButton>
676
- <VanButton
677
- type="primary"
678
- size="large"
679
- native-type="submit"
680
- :loading="isSubmitting"
681
- :disabled="isSubmitting"
682
- class="submit-btn"
683
- @click="handleSubmit"
684
- >
685
- <i class="i-iconoir-user-plus" />
686
- {{ isSubmitting ? '注册中...' : '提交注册' }}
687
- </VanButton>
688
- </div>
689
- </VanForm>
690
- </div>
691
- </div>
692
-
693
- <!-- 注册成功弹窗 -->
694
- <VanPopup
695
- v-model:show="showSuccess"
696
- round
697
- closeable
698
- class="success-popup"
699
- >
700
- <div class="success-content">
701
- <VanIcon name="success" class="success-icon" />
702
- <h3 class="success-title">
703
- 注册成功
704
- </h3>
705
- <p class="success-message">
706
- 员工账号已成功创建,请等待管理员审核。
707
- </p>
708
- <div class="success-info">
709
- <p><strong>员工姓名:</strong>{{ formData.name }}</p>
710
- <p><strong>登录名:</strong>{{ formData.username }}</p>
711
- <p><strong>手机号码:</strong>{{ formData.phone }}</p>
712
- </div>
713
- <div class="success-actions">
714
- <!-- <VanButton type="default" @click="resetForm"> -->
715
- <!-- 继续注册 -->
716
- <!-- </VanButton> -->
717
- <!-- <VanButton type="primary" @click="goBack"> -->
718
- <!-- 去登录 -->
719
- <!-- </VanButton> -->
720
- </div>
721
- </div>
722
- </VanPopup>
723
- </div>
724
- </template>
725
-
726
- <style scoped lang="less">
727
- .employee-registration {
728
- min-height: 100vh;
729
- background-color: #f5f5f5;
730
- }
731
-
732
- .main-content {
733
- padding: 16px;
734
- padding-bottom: 80px;
735
- }
736
-
737
- .form-container {
738
- background: white;
739
- border-radius: 8px;
740
- overflow: hidden;
741
- box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
742
- }
743
-
744
- /* 表单标题样式 */
745
- .form-header {
746
- padding: 20px 16px 16px;
747
- border-bottom: 1px solid #e9ecef;
748
- }
749
-
750
- .form-title {
751
- font-size: 18px;
752
- font-weight: 600;
753
- color: #333;
754
- margin: 0 0 4px 0;
755
- }
756
-
757
- .form-subtitle {
758
- font-size: 14px;
759
- color: #666;
760
- margin: 0;
761
- }
762
-
763
- .form-section {
764
- margin-bottom: 0;
765
- }
766
-
767
- .section-header {
768
- display: flex;
769
- align-items: center;
770
- padding: 16px;
771
- background-color: #f8f9fa;
772
- border-bottom: 1px solid #e9ecef;
773
- }
774
-
775
- .section-icon {
776
- margin-right: 8px;
777
- color: #007bff;
778
- font-size: 16px;
779
- }
780
-
781
- .section-title {
782
- font-size: 16px;
783
- font-weight: 500;
784
- color: #333;
785
- }
786
-
787
- .field-icon {
788
- margin-right: 4px;
789
- color: #666;
790
- font-size: 14px;
791
- }
792
-
793
- .required {
794
- color: #ee0a24;
795
- font-weight: 500;
796
- }
797
-
798
- /* 字段提示文字 */
799
- .field-hint {
800
- font-size: 12px;
801
- color: #999;
802
- padding: 0 16px 8px;
803
- }
804
-
805
- /* 按钮样式 */
806
- .form-actions {
807
- display: flex;
808
- gap: 12px;
809
- padding: 20px 16px;
810
- background-color: #f8f9fa;
811
- border-top: 1px solid #e9ecef;
812
- }
813
-
814
- .reset-btn {
815
- flex: 1;
816
- background-color: #6c757d !important;
817
- border-color: #6c757d !important;
818
- color: white !important;
819
- }
820
-
821
- .reset-btn:hover {
822
- background-color: #5a6268 !important;
823
- }
824
-
825
- .submit-btn {
826
- flex: 1;
827
- background-color: #007bff !important;
828
- border-color: #007bff !important;
829
- color: white !important;
830
- }
831
-
832
- .submit-btn:hover {
833
- background-color: #0056b3 !important;
834
- }
835
-
836
- /* 成功弹窗样式 */
837
- .success-popup {
838
- width: 90%;
839
- max-width: 400px;
840
- }
841
-
842
- .success-content {
843
- padding: 24px;
844
- text-align: center;
845
- }
846
-
847
- .success-icon {
848
- font-size: 48px;
849
- color: #07c160;
850
- margin-bottom: 16px;
851
- }
852
-
853
- .success-title {
854
- font-size: 18px;
855
- font-weight: 500;
856
- color: #333;
857
- margin-bottom: 8px;
858
- }
859
-
860
- .success-message {
861
- color: #666;
862
- margin-bottom: 16px;
863
- }
864
-
865
- .success-info {
866
- text-align: left;
867
- background-color: #f8f9fa;
868
- padding: 12px;
869
- border-radius: 4px;
870
- margin-bottom: 16px;
871
- }
872
-
873
- .success-info p {
874
- margin: 4px 0;
875
- font-size: 14px;
876
- }
877
-
878
- .success-actions {
879
- display: flex;
880
- gap: 12px;
881
- }
882
-
883
- .success-actions .van-button {
884
- flex: 1;
885
- }
886
-
887
- /* 自定义字段样式 */
888
- :deep(.van-field__label) {
889
- display: flex;
890
- align-items: center;
891
- font-weight: 500;
892
- }
893
-
894
- :deep(.van-field--error .van-field__control) {
895
- color: #ee0a24;
896
- }
897
-
898
- :deep(.van-field--disabled .van-field__control) {
899
- color: #999;
900
- background-color: #f5f5f5;
901
- }
902
-
903
- :deep(.van-field--disabled .van-field__label) {
904
- color: #666;
905
- }
906
-
907
- /* 单选按钮样式 */
908
- :deep(.van-radio-group) {
909
- display: flex;
910
- gap: 20px;
911
- }
912
-
913
- :deep(.van-radio) {
914
- margin: 0;
915
- }
916
-
917
- /* 导航栏样式 */
918
- :deep(.van-nav-bar) {
919
- background-color: #f8f9fa;
920
- border-bottom: 1px solid #e9ecef;
921
- }
922
-
923
- :deep(.van-nav-bar__title) {
924
- font-weight: 600;
925
- color: #333;
926
- }
927
-
928
- /* 错误信息样式 */
929
- :deep(.van-field__error-message) {
930
- color: #ee0a24;
931
- font-size: 12px;
932
- margin-top: 4px;
933
- }
934
-
935
- /* 密码字段右侧图标样式 */
936
- :deep(.van-field__right-icon) {
937
- color: #999;
938
- cursor: pointer;
939
- }
940
-
941
- :deep(.van-field__right-icon:hover) {
942
- color: #666;
943
- }
944
- /* 修改整个输入框容器的样式 */
945
- :deep(.van-field__body) {
946
- margin: 10px 0;
947
- padding: 10px 15px;
948
- --tw-border-opacity: 1;
949
- border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
950
- border-radius: 0.375rem;
951
- border-width: 1px;
952
- font-size: 100%;
953
- }
954
-
955
- :deep(.van-field--disabled .van-field__control) {
956
- background-color: #ffffff;
957
- }
958
- </style>
1
+ <script setup lang="ts">
2
+ import { getConfigByName, openApiLogic } from '@af-mobile-client-vue3/services/api/common'
3
+ import { useSettingStore } from '@af-mobile-client-vue3/stores/modules/setting'
4
+ import useUserStore from '@af-mobile-client-vue3/stores/modules/user'
5
+ import {
6
+ showFailToast,
7
+ showSuccessToast,
8
+ showToast,
9
+ Button as VanButton,
10
+ Empty as VanEmpty,
11
+ Field as VanField,
12
+ Form as VanForm,
13
+ Icon as VanIcon,
14
+ Loading as VanLoading,
15
+ NavBar as VanNavBar,
16
+ Popup as VanPopup,
17
+ Radio as VanRadio,
18
+ RadioGroup as VanRadioGroup,
19
+ } from 'vant'
20
+
21
+ import { onMounted, ref } from 'vue'
22
+ import { useRoute, useRouter } from 'vue-router'
23
+
24
+ interface FormData {
25
+ name: string
26
+ phone: string
27
+ gender: string
28
+ code: string
29
+ email: string
30
+ username: string
31
+ password: string
32
+ confirmPassword: string
33
+ roles: string
34
+ dept_name: string
35
+ org_name: string
36
+ strategyId: string
37
+ openId: string
38
+ }
39
+ interface Errors {
40
+ [key: string]: string | undefined
41
+ name?: string
42
+ phone?: string
43
+ gender?: string
44
+ email?: string
45
+ username?: string
46
+ password?: string
47
+ confirmPassword?: string
48
+ }
49
+
50
+ interface OrganizationInfo {
51
+ roles: string
52
+ dept_name: string
53
+ org_name: string
54
+ }
55
+
56
+ type UsernameStatus = 'initial' | 'checking' | 'available' | 'unavailable'
57
+
58
+ const route = useRoute()
59
+ const router = useRouter()
60
+ const setting = useSettingStore()
61
+
62
+ // 表单数据
63
+ const formData = ref<FormData>({
64
+ name: '',
65
+ phone: '',
66
+ gender: '',
67
+ code: '',
68
+ email: '',
69
+ username: '',
70
+ password: '',
71
+ confirmPassword: '',
72
+ roles: '',
73
+ dept_name: '',
74
+ org_name: '',
75
+ strategyId: '',
76
+ openId: '',
77
+ })
78
+ const initSuccess = ref(false)
79
+ const showPassword = ref(false)
80
+ const showConfirmPassword = ref(false)
81
+ const openId = ref('')
82
+ // 错误信息
83
+ const errors = ref<Errors>({})
84
+
85
+ const registerConfig = ref({})
86
+
87
+ // 状态管理
88
+ const isSubmitting = ref<boolean>(false)
89
+ const showSuccess = ref<boolean>(false)
90
+ const usernameStatus = ref<UsernameStatus>('initial')
91
+
92
+ // 组织信息(从策略获取)
93
+ const organizationInfo = ref<OrganizationInfo>({
94
+ roles: '',
95
+ dept_name: '',
96
+ org_name: '',
97
+ })
98
+ // 防抖检查用户名
99
+ let usernameCheckTimeout = null
100
+
101
+ // 验证函数
102
+ function validateName(): boolean {
103
+ if (!formData.value.name.trim()) {
104
+ errors.value.name = '员工姓名不能为空'
105
+ return false
106
+ }
107
+ if (formData.value.name.length < 2) {
108
+ errors.value.name = '员工姓名至少2个字符'
109
+ return false
110
+ }
111
+ delete errors.value.name
112
+ return true
113
+ }
114
+ function validateCode(): boolean {
115
+ if (!formData.value.code.trim()) {
116
+ errors.value.code = '员工编号不能为空'
117
+ return false
118
+ }
119
+ delete errors.value.code
120
+ return true
121
+ }
122
+
123
+ function validatePhone(): boolean {
124
+ const phoneRegex = /^1[3-9]\d{9}$/
125
+ if (!formData.value.phone.trim()) {
126
+ errors.value.phone = '手机号码不能为空'
127
+ return false
128
+ }
129
+ if (!phoneRegex.test(formData.value.phone)) {
130
+ errors.value.phone = '请输入正确的手机号码'
131
+ return false
132
+ }
133
+ delete errors.value.phone
134
+ return true
135
+ }
136
+
137
+ function validateEmail(): boolean {
138
+ if (formData.value.email.trim()) {
139
+ const emailRegex = /^[^\s@]+@[^\s@][^\s.@]*\.[^\s@]+$/
140
+ if (!emailRegex.test(formData.value.email)) {
141
+ errors.value.email = '请输入正确的邮箱地址'
142
+ return false
143
+ }
144
+ }
145
+ delete errors.value.email
146
+ return true
147
+ }
148
+
149
+ function validateUsername(): boolean {
150
+ if (!formData.value.username.trim()) {
151
+ errors.value.username = '登录名不能为空'
152
+ return false
153
+ }
154
+ if (formData.value.username.length < 3) {
155
+ errors.value.username = '登录名至少3个字符'
156
+ return false
157
+ }
158
+ if (!/^\w+$/.test(formData.value.username)) {
159
+ errors.value.username = '登录名只能包含字母、数字和下划线'
160
+ return false
161
+ }
162
+
163
+ if (usernameStatus.value === 'unavailable') {
164
+ errors.value.username = '该登录名已被使用,请选择其他登录名'
165
+ return false
166
+ }
167
+
168
+ if (usernameStatus.value === 'checking') {
169
+ errors.value.username = '正在检查登录名可用性,请稍候'
170
+ return false
171
+ }
172
+
173
+ if (usernameStatus.value === 'initial') {
174
+ checkUsernameAvailability()
175
+ errors.value.username = '正在检查登录名可用性,请稍候'
176
+ return false
177
+ }
178
+
179
+ delete errors.value.username
180
+ return true
181
+ }
182
+
183
+ function validatePassword(): boolean {
184
+ if (!formData.value.password) {
185
+ errors.value.password = '登录密码不能为空'
186
+ return false
187
+ }
188
+ if (formData.value.password.length < 6) {
189
+ errors.value.password = '登录密码至少6个字符'
190
+ return false
191
+ }
192
+ delete errors.value.password
193
+ return true
194
+ }
195
+
196
+ function validateConfirmPassword(): boolean {
197
+ if (!formData.value.confirmPassword) {
198
+ errors.value.confirmPassword = '确认密码不能为空'
199
+ return false
200
+ }
201
+ if (formData.value.password !== formData.value.confirmPassword) {
202
+ errors.value.confirmPassword = '两次输入的密码不一致'
203
+ return false
204
+ }
205
+ delete errors.value.confirmPassword
206
+ return true
207
+ }
208
+
209
+ function validateGender(): boolean {
210
+ if (!formData.value.gender) {
211
+ errors.value.gender = '请选择性别'
212
+ return false
213
+ }
214
+ delete errors.value.gender
215
+ return true
216
+ }
217
+
218
+ function validateAll(): boolean {
219
+ const validations = [
220
+ validateName(),
221
+ validateCode(),
222
+ validatePhone(),
223
+ validateEmail(),
224
+ validateUsername(),
225
+ validatePassword(),
226
+ validateConfirmPassword(),
227
+ validateGender(),
228
+ ]
229
+ return validations.every(v => v)
230
+ }
231
+
232
+ // 检查用户名可用性
233
+ async function checkUsernameAvailability(): Promise<void> {
234
+ usernameStatus.value = 'checking'
235
+
236
+ try {
237
+ const response = await openApiLogic({ username: formData.value.username }, 'checkUserName', 'af-system')
238
+ console.log('response', response)
239
+ if (response.success) {
240
+ usernameStatus.value = 'available'
241
+ delete errors.value.username
242
+ }
243
+ else {
244
+ errors.value.username = '该登录名已被使用,请选择其他登录名'
245
+ usernameStatus.value = 'unavailable'
246
+ }
247
+ }
248
+ catch (error) {
249
+ // 模拟检查逻辑
250
+ const existingUsernames = ['admin', 'user001', 'zhangsan', 'lisi', 'wangwu']
251
+ if (existingUsernames.includes(formData.value.username.toLowerCase())) {
252
+ errors.value.username = '该登录名已被使用,请选择其他登录名'
253
+ usernameStatus.value = 'unavailable'
254
+ }
255
+ else {
256
+ usernameStatus.value = 'available'
257
+ delete errors.value.username
258
+ }
259
+ }
260
+ }
261
+
262
+ // 获取组织信息
263
+ async function fetchOrganizationInfo(strategyId: any): Promise<void> {
264
+ try {
265
+ const response = await openApiLogic({ strategyId }, 'getOrganizationInfo', 'af-system')
266
+ if (response.success) {
267
+ initSuccess.value = true
268
+ Object.assign(organizationInfo.value, response.data)
269
+ // 更新表单数据
270
+ formData.value.roles = organizationInfo.value.roles
271
+ formData.value.dept_name = organizationInfo.value.dept_name
272
+ formData.value.org_name = organizationInfo.value.org_name
273
+ formData.value.strategyId = strategyId
274
+ }
275
+ else {
276
+ showFailToast(response.msg)
277
+ }
278
+ }
279
+ catch (error) {
280
+ console.error('获取组织信息失败:', error)
281
+ showToast('获取组织信息失败')
282
+ }
283
+ }
284
+
285
+ async function initConfig(): Promise<void> {
286
+ try {
287
+ getConfigByName('registerConfig', (res: any) => {
288
+ console.log('res', res)
289
+ }, 'af-system')
290
+ }
291
+ catch (error) {
292
+ console.error('获取组织信息失败:', error)
293
+ showToast('获取组织信息失败')
294
+ }
295
+ }
296
+
297
+ // 提交注册
298
+ async function submitRegistration(): Promise<void> {
299
+ if (usernameStatus.value === 'checking') {
300
+ showToast('请等待登录名检查完成')
301
+ return
302
+ }
303
+
304
+ if (!validateAll()) {
305
+ showToast('请填写必填信息!')
306
+ return
307
+ }
308
+
309
+ isSubmitting.value = true
310
+
311
+ try {
312
+ console.log('formData', formData.value)
313
+ const response = await openApiLogic(formData.value, 'registrationUser', 'af-system')
314
+ if (response.success) {
315
+ showSuccess.value = true
316
+ showSuccessToast('注册成功')
317
+ await useUserStore().registerClean()
318
+ }
319
+ else {
320
+ showSuccessToast(`注册失败,${response.msg}!`)
321
+ }
322
+ isSubmitting.value = false
323
+ }
324
+ catch (error) {
325
+ isSubmitting.value = false
326
+ showToast('注册失败,请重试')
327
+ }
328
+ }
329
+
330
+ // 重置表单
331
+ function resetForm(): void {
332
+ Object.assign(formData.value, {
333
+ name: '',
334
+ phone: '',
335
+ gender: '',
336
+ code: '',
337
+ email: '',
338
+ username: '',
339
+ password: '',
340
+ confirmPassword: '',
341
+ })
342
+ Object.keys(errors.value).forEach(key => delete errors.value[key])
343
+ showPassword.value = false
344
+ showConfirmPassword.value = false
345
+ showSuccess.value = false
346
+ usernameStatus.value = 'initial'
347
+ }
348
+
349
+ function debounceUsernameCheck() {
350
+ if (usernameCheckTimeout) {
351
+ clearTimeout(usernameCheckTimeout)
352
+ }
353
+
354
+ // 重置状态
355
+ usernameStatus.value = 'initial'
356
+ delete errors.value.username
357
+
358
+ // 基本验证
359
+ if (!formData.value.username.trim()) {
360
+ return
361
+ }
362
+ if (formData.value.username.length < 3) {
363
+ return
364
+ }
365
+ if (!/^\w+$/.test(formData.value.username)) {
366
+ return
367
+ }
368
+
369
+ // 设置新的定时器
370
+ usernameCheckTimeout = setTimeout(() => {
371
+ checkUsernameAvailability()
372
+ }, 500) // 500ms 防抖延迟
373
+ }
374
+
375
+ // 提交注册
376
+ async function handleSubmit() {
377
+ if (usernameStatus.value === 'checking') {
378
+ showToast('请等待登录名检查完成')
379
+ return
380
+ }
381
+
382
+ await submitRegistration()
383
+ }
384
+
385
+ // 返回上一页
386
+ function goBack() {
387
+ router.push('/login')
388
+ }
389
+
390
+ // 组件挂载时获取组织信息
391
+ onMounted(async () => {
392
+ console.log('route.query', route.query)
393
+ console.log('route.params', route.params)
394
+ const strategyId = route.query.strategyId || route.params.strategyId
395
+ openId.value = route.query.openId as string || route.params.openId as string
396
+ formData.value.openId = openId.value
397
+ if (strategyId) {
398
+ await fetchOrganizationInfo(strategyId)
399
+ }
400
+ else {
401
+ if (setting.getSetting()?.registerRequire) {
402
+ showFailToast('缺少组织信息,请确二维码准确性')
403
+ }
404
+ }
405
+ })
406
+ </script>
407
+
408
+ <template>
409
+ <div class="employee-registration">
410
+ <!-- 顶部导航栏 -->
411
+ <VanNavBar
412
+ title="员工注册"
413
+
414
+ placeholder fixed
415
+ />
416
+ <div v-show="!initSuccess">
417
+ <VanEmpty image="error" description="推广码无效/已过期" />
418
+ </div>
419
+ <!-- 主要内容区域 -->
420
+ <div v-show="initSuccess" class="main-content">
421
+ <div class="form-container">
422
+ <!-- 表单标题 -->
423
+ <div class="form-header">
424
+ <h2 class="form-title">
425
+ 员工信息录入
426
+ </h2>
427
+ <p class="form-subtitle">
428
+ 请填写员工基本信息完成账号注册
429
+ </p>
430
+ </div>
431
+
432
+ <!-- 注册表单 -->
433
+ <VanForm @submit="submitRegistration">
434
+ <!-- 基本信息 -->
435
+ <div class="form-section">
436
+ <div class="section-header">
437
+ <span class="section-title">基本信息</span>
438
+ </div>
439
+
440
+ <!-- 员工姓名 -->
441
+ <VanField
442
+ v-model="formData.name"
443
+ label="员工姓名"
444
+ placeholder="请输入员工姓名"
445
+ :error="!!errors.name"
446
+ :error-message="errors.name"
447
+ label-align="top"
448
+ :border="true"
449
+ @blur="validateName"
450
+ >
451
+ <template #label>
452
+ <i class="i-material-symbols-person text-blue-500" />
453
+ 员工姓名 <span class="required">*</span>
454
+ </template>
455
+ </VanField>
456
+
457
+ <!-- 手机号码 -->
458
+ <VanField
459
+ v-model="formData.phone"
460
+ label="手机号码"
461
+ type="tel"
462
+ placeholder="请输入手机号码"
463
+ :error="!!errors.phone"
464
+ :error-message="errors.phone"
465
+ label-align="top"
466
+ @blur="validatePhone"
467
+ >
468
+ <template #label>
469
+ <i class="i-flowbite-mobile-phone-solid text-green-500" />
470
+ 手机号码 <span class="required">*</span>
471
+ </template>
472
+ </VanField>
473
+
474
+ <!-- 性别 -->
475
+ <VanField
476
+ label="性别"
477
+ :error="!!errors.gender"
478
+ :error-message="errors.gender"
479
+ label-align="top"
480
+ >
481
+ <template #label>
482
+ <i class="i-fa6-solid-venus-mars text-pink-500" />
483
+ 性别 <span class="required">*</span>
484
+ </template>
485
+ <template #input>
486
+ <VanRadioGroup v-model="formData.gender" @change="validateGender">
487
+ <VanRadio name="男">
488
+
489
+ </VanRadio>
490
+ <VanRadio name="女">
491
+
492
+ </VanRadio>
493
+ </VanRadioGroup>
494
+ </template>
495
+ </VanField>
496
+ <!-- 员工编号 -->
497
+ <VanField
498
+ v-model="formData.code"
499
+ label="员工编号"
500
+ placeholder="请输入员工编号"
501
+ :error="!!errors.code"
502
+ :error-message="errors.code"
503
+ label-align="top"
504
+ @blur="validateCode"
505
+ >
506
+ <template #label>
507
+ <i class="i-solar-user-id-bold text-purple-500" />
508
+ 员工编号 <span class="required">*</span>
509
+ </template>
510
+ </VanField>
511
+ <!-- 邮箱 -->
512
+ <VanField
513
+ v-model="formData.email"
514
+ label="邮箱"
515
+ type="email"
516
+ placeholder="请输入邮箱地址(可选)"
517
+ :error="!!errors.email"
518
+ :error-message="errors.email"
519
+ label-align="top"
520
+ @blur="validateEmail"
521
+ >
522
+ <template #label>
523
+ <i class="i-material-symbols-mail text-purple-500" />
524
+ 邮箱
525
+ </template>
526
+ </VanField>
527
+ </div>
528
+
529
+ <!-- 账号信息 -->
530
+ <div class="form-section">
531
+ <div class="section-header">
532
+ <span class="section-title">账号信息</span>
533
+ </div>
534
+
535
+ <!-- 登录名 -->
536
+ <VanField
537
+ v-model="formData.username"
538
+ label="登录名"
539
+ placeholder="请输入登录名"
540
+ :error="!!errors.username"
541
+ :error-message="errors.username"
542
+ label-align="top"
543
+ @blur="validateUsername"
544
+ @input="debounceUsernameCheck"
545
+ >
546
+ <template #label>
547
+ <i class="i-material-symbols-id-card text-indigo-500" />
548
+ 登录名 <span class="required">*</span>
549
+ </template>
550
+ <template #right-icon>
551
+ <!-- 检查中状态 -->
552
+ <VanLoading v-if="usernameStatus === 'checking'" size="16px" />
553
+ <!-- 可用状态 -->
554
+ <i v-else-if="usernameStatus === 'available'" class="i-material-symbols-check-circle text-green-500" />
555
+ <i v-else-if="usernameStatus === 'unavailable'" class="i-iconamoon-sign-times-circle text-red-500" />
556
+ </template>
557
+ </VanField>
558
+
559
+ <!-- 登录密码 -->
560
+ <VanField
561
+ v-model="formData.password"
562
+ label="登录密码"
563
+ :type="showPassword ? 'text' : 'password'"
564
+ placeholder="请输入登录密码"
565
+ :error="!!errors.password"
566
+ :error-message="errors.password"
567
+ label-align="top"
568
+ @blur="validatePassword"
569
+ >
570
+ <template #label>
571
+ <i class="i-material-symbols-lock text-orange-500" />
572
+ 登录密码 <span class="required">*</span>
573
+ </template>
574
+ <template #right-icon>
575
+ <VanIcon
576
+ :name="showPassword ? 'eye-o' : 'closed-eye'"
577
+ @click="showPassword = !showPassword"
578
+ />
579
+ </template>
580
+ </VanField>
581
+
582
+ <!-- 确认密码 -->
583
+ <VanField
584
+ v-model="formData.confirmPassword"
585
+ label="确认密码"
586
+ :type="showConfirmPassword ? 'text' : 'password'"
587
+ placeholder="请再次输入登录密码"
588
+ :error="!!errors.confirmPassword"
589
+ :error-message="errors.confirmPassword"
590
+ label-align="top"
591
+ @blur="validateConfirmPassword"
592
+ >
593
+ <template #label>
594
+ <i class="i-bxs-shield-alt-2 text-teal-500" />
595
+ 确认密码 <span class="required">*</span>
596
+ </template>
597
+ <template #right-icon>
598
+ <VanIcon
599
+ :name="showConfirmPassword ? 'eye-o' : 'closed-eye'"
600
+ @click="showConfirmPassword = !showConfirmPassword"
601
+ />
602
+ </template>
603
+ </VanField>
604
+ </div>
605
+
606
+ <!-- 组织信息 -->
607
+ <div class="form-section">
608
+ <div class="section-header">
609
+ <span class="section-title">组织信息</span>
610
+ </div>
611
+
612
+ <!-- 所属角色 -->
613
+ <VanField
614
+ v-model="formData.roles"
615
+ label="所属角色"
616
+ readonly
617
+ disabled
618
+ label-align="top"
619
+ >
620
+ <template #label>
621
+ <i class="i-fa6-solid-user-tag text-blue-600" />
622
+ 所属角色
623
+ </template>
624
+ </VanField>
625
+ <div class="field-hint">
626
+ 系统默认分配,不可修改
627
+ </div>
628
+
629
+ <!-- 所属部门 -->
630
+ <VanField
631
+ v-model="formData.dept_name"
632
+ label="所属部门"
633
+ readonly
634
+ disabled
635
+ label-align="top"
636
+ >
637
+ <template #label>
638
+ <i class="i-material-symbols-home-work text-gray-600" />
639
+ 所属部门
640
+ </template>
641
+ </VanField>
642
+ <div class="field-hint">
643
+ 系统默认分配,不可修改
644
+ </div>
645
+
646
+ <!-- 所属分公司 -->
647
+ <VanField
648
+ v-model="formData.org_name"
649
+ label="所属分公司"
650
+ readonly
651
+ disabled
652
+ label-align="top"
653
+ >
654
+ <template #label>
655
+ <i class="i-line-md-map-marker-alt-filled text-red-500" />
656
+ 所属分公司
657
+ </template>
658
+ </VanField>
659
+ <div class="field-hint">
660
+ 系统默认分配,不可修改
661
+ </div>
662
+ </div>
663
+
664
+ <!-- 提交按钮 -->
665
+ <div class="form-actions">
666
+ <VanButton
667
+ type="default"
668
+ size="large"
669
+ :disabled="isSubmitting"
670
+ class="reset-btn"
671
+ @click="resetForm"
672
+ >
673
+ <i class="i-hugeicons-redo" />
674
+ 重置
675
+ </VanButton>
676
+ <VanButton
677
+ type="primary"
678
+ size="large"
679
+ native-type="submit"
680
+ :loading="isSubmitting"
681
+ :disabled="isSubmitting"
682
+ class="submit-btn"
683
+ @click="handleSubmit"
684
+ >
685
+ <i class="i-iconoir-user-plus" />
686
+ {{ isSubmitting ? '注册中...' : '提交注册' }}
687
+ </VanButton>
688
+ </div>
689
+ </VanForm>
690
+ </div>
691
+ </div>
692
+
693
+ <!-- 注册成功弹窗 -->
694
+ <VanPopup
695
+ v-model:show="showSuccess"
696
+ round
697
+ closeable
698
+ class="success-popup"
699
+ >
700
+ <div class="success-content">
701
+ <VanIcon name="success" class="success-icon" />
702
+ <h3 class="success-title">
703
+ 注册成功
704
+ </h3>
705
+ <p class="success-message">
706
+ 员工账号已成功创建,请等待管理员审核。
707
+ </p>
708
+ <div class="success-info">
709
+ <p><strong>员工姓名:</strong>{{ formData.name }}</p>
710
+ <p><strong>登录名:</strong>{{ formData.username }}</p>
711
+ <p><strong>手机号码:</strong>{{ formData.phone }}</p>
712
+ </div>
713
+ <div class="success-actions">
714
+ <!-- <VanButton type="default" @click="resetForm"> -->
715
+ <!-- 继续注册 -->
716
+ <!-- </VanButton> -->
717
+ <!-- <VanButton type="primary" @click="goBack"> -->
718
+ <!-- 去登录 -->
719
+ <!-- </VanButton> -->
720
+ </div>
721
+ </div>
722
+ </VanPopup>
723
+ </div>
724
+ </template>
725
+
726
+ <style scoped lang="less">
727
+ .employee-registration {
728
+ min-height: 100vh;
729
+ background-color: #f5f5f5;
730
+ }
731
+
732
+ .main-content {
733
+ padding: 16px;
734
+ padding-bottom: 80px;
735
+ }
736
+
737
+ .form-container {
738
+ background: white;
739
+ border-radius: 8px;
740
+ overflow: hidden;
741
+ box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
742
+ }
743
+
744
+ /* 表单标题样式 */
745
+ .form-header {
746
+ padding: 20px 16px 16px;
747
+ border-bottom: 1px solid #e9ecef;
748
+ }
749
+
750
+ .form-title {
751
+ font-size: 18px;
752
+ font-weight: 600;
753
+ color: #333;
754
+ margin: 0 0 4px 0;
755
+ }
756
+
757
+ .form-subtitle {
758
+ font-size: 14px;
759
+ color: #666;
760
+ margin: 0;
761
+ }
762
+
763
+ .form-section {
764
+ margin-bottom: 0;
765
+ }
766
+
767
+ .section-header {
768
+ display: flex;
769
+ align-items: center;
770
+ padding: 16px;
771
+ background-color: #f8f9fa;
772
+ border-bottom: 1px solid #e9ecef;
773
+ }
774
+
775
+ .section-icon {
776
+ margin-right: 8px;
777
+ color: #007bff;
778
+ font-size: 16px;
779
+ }
780
+
781
+ .section-title {
782
+ font-size: 16px;
783
+ font-weight: 500;
784
+ color: #333;
785
+ }
786
+
787
+ .field-icon {
788
+ margin-right: 4px;
789
+ color: #666;
790
+ font-size: 14px;
791
+ }
792
+
793
+ .required {
794
+ color: #ee0a24;
795
+ font-weight: 500;
796
+ }
797
+
798
+ /* 字段提示文字 */
799
+ .field-hint {
800
+ font-size: 12px;
801
+ color: #999;
802
+ padding: 0 16px 8px;
803
+ }
804
+
805
+ /* 按钮样式 */
806
+ .form-actions {
807
+ display: flex;
808
+ gap: 12px;
809
+ padding: 20px 16px;
810
+ background-color: #f8f9fa;
811
+ border-top: 1px solid #e9ecef;
812
+ }
813
+
814
+ .reset-btn {
815
+ flex: 1;
816
+ background-color: #6c757d !important;
817
+ border-color: #6c757d !important;
818
+ color: white !important;
819
+ }
820
+
821
+ .reset-btn:hover {
822
+ background-color: #5a6268 !important;
823
+ }
824
+
825
+ .submit-btn {
826
+ flex: 1;
827
+ background-color: #007bff !important;
828
+ border-color: #007bff !important;
829
+ color: white !important;
830
+ }
831
+
832
+ .submit-btn:hover {
833
+ background-color: #0056b3 !important;
834
+ }
835
+
836
+ /* 成功弹窗样式 */
837
+ .success-popup {
838
+ width: 90%;
839
+ max-width: 400px;
840
+ }
841
+
842
+ .success-content {
843
+ padding: 24px;
844
+ text-align: center;
845
+ }
846
+
847
+ .success-icon {
848
+ font-size: 48px;
849
+ color: #07c160;
850
+ margin-bottom: 16px;
851
+ }
852
+
853
+ .success-title {
854
+ font-size: 18px;
855
+ font-weight: 500;
856
+ color: #333;
857
+ margin-bottom: 8px;
858
+ }
859
+
860
+ .success-message {
861
+ color: #666;
862
+ margin-bottom: 16px;
863
+ }
864
+
865
+ .success-info {
866
+ text-align: left;
867
+ background-color: #f8f9fa;
868
+ padding: 12px;
869
+ border-radius: 4px;
870
+ margin-bottom: 16px;
871
+ }
872
+
873
+ .success-info p {
874
+ margin: 4px 0;
875
+ font-size: 14px;
876
+ }
877
+
878
+ .success-actions {
879
+ display: flex;
880
+ gap: 12px;
881
+ }
882
+
883
+ .success-actions .van-button {
884
+ flex: 1;
885
+ }
886
+
887
+ /* 自定义字段样式 */
888
+ :deep(.van-field__label) {
889
+ display: flex;
890
+ align-items: center;
891
+ font-weight: 500;
892
+ }
893
+
894
+ :deep(.van-field--error .van-field__control) {
895
+ color: #ee0a24;
896
+ }
897
+
898
+ :deep(.van-field--disabled .van-field__control) {
899
+ color: #999;
900
+ background-color: #f5f5f5;
901
+ }
902
+
903
+ :deep(.van-field--disabled .van-field__label) {
904
+ color: #666;
905
+ }
906
+
907
+ /* 单选按钮样式 */
908
+ :deep(.van-radio-group) {
909
+ display: flex;
910
+ gap: 20px;
911
+ }
912
+
913
+ :deep(.van-radio) {
914
+ margin: 0;
915
+ }
916
+
917
+ /* 导航栏样式 */
918
+ :deep(.van-nav-bar) {
919
+ background-color: #f8f9fa;
920
+ border-bottom: 1px solid #e9ecef;
921
+ }
922
+
923
+ :deep(.van-nav-bar__title) {
924
+ font-weight: 600;
925
+ color: #333;
926
+ }
927
+
928
+ /* 错误信息样式 */
929
+ :deep(.van-field__error-message) {
930
+ color: #ee0a24;
931
+ font-size: 12px;
932
+ margin-top: 4px;
933
+ }
934
+
935
+ /* 密码字段右侧图标样式 */
936
+ :deep(.van-field__right-icon) {
937
+ color: #999;
938
+ cursor: pointer;
939
+ }
940
+
941
+ :deep(.van-field__right-icon:hover) {
942
+ color: #666;
943
+ }
944
+ /* 修改整个输入框容器的样式 */
945
+ :deep(.van-field__body) {
946
+ margin: 10px 0;
947
+ padding: 10px 15px;
948
+ --tw-border-opacity: 1;
949
+ border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
950
+ border-radius: 0.375rem;
951
+ border-width: 1px;
952
+ font-size: 100%;
953
+ }
954
+
955
+ :deep(.van-field--disabled .van-field__control) {
956
+ background-color: #ffffff;
957
+ }
958
+ </style>