lgq
2026-03-31 e491cdb48129752324c4e3764f99bd9203c56dec
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
import dxui from '../../../../../dxmodules/dxUi.js'
import std from '../../../../../dxmodules/dxStd.js'
import viewUtils from "../../../viewUtils.js"
import topView from "../../../topView.js"
import localUserView from '../localUserView.js'
import faceEnterView from './faceEnterView.js'
import i18n from "../../../i18n.js"
import pinyin from '../../../pinyin/pinyin.js'
import screen from '../../../../screen.js'
const localUserAddView = {}
const dropdownData = ['保管员', '科长']
const dropdownData2 = ['User', 'Administrator']
 
localUserAddView.init = function () {
    /**************************************************创建屏幕*****************************************************/
    const screenMain = dxui.View.build('localUserAddView', dxui.Utils.LAYER.MAIN)
    localUserAddView.screenMain = screenMain
    screenMain.scroll(false)
    screenMain.bgColor(0xffffff)
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_LOADED, () => {
        topView.changeTheme(true)
        refreshType()
        if (!localUserAddView.deleteBtn.isHide()) {
            //修改用户不允许改id
            localUserAddView.userInfo[0].input.disable(true)
        } else {
            localUserAddView.userInfo[0].input.disable(false)
        }
    })
 
    screenMain.on(dxui.Utils.ENUM.LV_EVENT_SCREEN_UNLOADED, () => {
    })
 
    const titleBox = viewUtils.title(screenMain, localUserView.screenMain, 'localUserAddViewTitle', 'localUserAddView.title', undefined)
    localUserAddView.titleBox = titleBox
    titleBox.align(dxui.Utils.ALIGN.TOP_MID, 0, 70)
 
    const titleBox2 = viewUtils.title(screenMain, localUserView.screenMain, 'localUserAddViewTitle2', 'localUserAddView.title2', undefined)
    localUserAddView.titleBox2 = titleBox2
    titleBox2.align(dxui.Utils.ALIGN.TOP_MID, 0, 70)
    titleBox2.hide()
 
    const addUserBox = dxui.View.build('addUserBox', screenMain)
    viewUtils._clearStyle(addUserBox)
    addUserBox.setSize(screen.screenSize.width, 700)
    addUserBox.align(dxui.Utils.ALIGN.TOP_MID, 0, 142)
    addUserBox.borderWidth(1)
    addUserBox.setBorderColor(0xDEDEDE)
    addUserBox.obj.setStyleBorderSide(dxui.Utils.ENUM.LV_BORDER_SIDE_TOP, 0)
    addUserBox.bgOpa(0)
 
    addUserBox.flexFlow(dxui.Utils.FLEX_FLOW.ROW_WRAP)
    addUserBox.flexAlign(dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.START)
    addUserBox.obj.lvObjSetStylePadGap(0, dxui.Utils.ENUM._LV_STYLE_STATE_CMP_SAME)
 
    localUserAddView.userInfo = [
        {
            title: 'localUserAddView.id',
            value: null,
            required: true,
            type: 'input',
            input: null
        },
        {
            title: 'localUserAddView.name',
            value: null,
            required: true,
            type: 'input',
            input: null
        },
        {
            title: 'localUserAddView.idCard',
            value: null,
            type: 'input',
            input: null
        },
        {
            title: 'localUserAddView.face',
            value: null,
            type: 'button',
            btn: null,
            btnEdit: null,
            faceImg: null,
            deleteBtn: null
        },
        {
            title: 'localUserAddView.pwd',
            value: null,
            type: 'button',
            btn: null,
            btnEdit: null,
            pwdLbl: null,
            deleteBtn: null
        },
        {
            title: 'localUserAddView.card',
            value: null,
            type: 'button',
            btn: null,
            btnEdit: null,
            cardLbl: null,
            deleteBtn: null
        },
        {
            title: 'localUserAddView.type',
            value: null,
            type: 'dropdown'
        }
    ]
 
    localUserAddView.userInfo.forEach((item, index) => {
        const userBox = dxui.View.build('userInfo' + index, addUserBox)
        viewUtils._clearStyle(userBox)
        userBox.setSize(700, 65)
        userBox.borderWidth(1)
        userBox.setBorderColor(0xDEDEDE)
        userBox.obj.setStyleBorderSide(dxui.Utils.ENUM.LV_BORDER_SIDE_BOTTOM, 0)
        userBox.bgOpa(0)
 
        if (item.required) {
            const titleLbl = dxui.Label.build('titleLblRequired' + index, userBox)
            titleLbl.textFont(viewUtils.font(22))
            titleLbl.align(dxui.Utils.ALIGN.LEFT_MID, 0, 0)
            titleLbl.text('*')
            titleLbl.textColor(0xFD5353)
        }
 
        const titleLbl = dxui.Label.build('titleLbl' + index, userBox)
        titleLbl.textFont(viewUtils.font(22))
        titleLbl.align(dxui.Utils.ALIGN.LEFT_MID, 10, 0)
        titleLbl.dataI18n = item.title
 
        if (item.type === 'input') {
            const input = viewUtils.input(userBox, item.title, item.mode, undefined, "localUserAddView.input")
            input.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
            input.textFont(viewUtils.font(22))
            input.setSize(260, 50)
            item.input = input
 
            input.on(dxui.Utils.EVENT.VALUE_CHANGED, () => {
                if (input.text() === "") {
                    return
                }
                switch (item.title) {
                    case 'localUserAddView.id':
                        localUserAddView.nowUser.id = input.text()
                        localUserAddView.nowUser.userId = input.text()
                        break;
                    case 'localUserAddView.name':
                        localUserAddView.nowUser.name = input.text()
                        break;
                    case 'localUserAddView.idCard':
                        localUserAddView.nowUser.idCard = input.text()
                        break;
                    default:
                        break;
                }
            })
        } else if (item.type === 'button') {
            const btn = dxui.Button.build(item.title, userBox)
            item.btn = btn
            btn.setSize(150, 50)
            btn.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
            btn.bgColor(0xEEEEEE)
            btn.radius(10)
            const btnLbl = dxui.Label.build(item.title + 'btnLbl', btn)
            btnLbl.textFont(viewUtils.font(22))
            btnLbl.textColor(0x05AA8D)
            btnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
 
            const btnEdit = dxui.Button.build(item.title + 'edit', userBox)
            item.btnEdit = btnEdit
            btnEdit.setSize(150, 50)
            btnEdit.align(dxui.Utils.ALIGN.RIGHT_MID, -60, 0)
            btnEdit.bgColor(0xEEEEEE)
            btnEdit.radius(10)
            btnEdit.hide()
            const btnEditLbl = dxui.Label.build(item.title + 'btnEditLbl', btnEdit)
            btnEditLbl.textFont(viewUtils.font(22))
            btnEditLbl.textColor(0x05AA8D)
            btnEditLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
 
            const deleteBtn = viewUtils.imageBtn(userBox, item.title + 'deleteBtn', '/app/code/resource/image/delete.png')
            item.deleteBtn = deleteBtn
            deleteBtn.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
            deleteBtn.hide()
 
            if (item.title === 'localUserAddView.pwd') {
                btnLbl.dataI18n = 'localUserAddView.generate'
                btnEditLbl.dataI18n = 'localUserAddView.reset'
 
                // 密码
                const pwdLbl = dxui.Label.build(userBox.id + 'pwdLbl', userBox)
                item.pwdLbl = pwdLbl
                pwdLbl.align(dxui.Utils.ALIGN.LEFT_MID, 180, 0)
                pwdLbl.textColor(0x767676)
                pwdLbl.textFont(viewUtils.font(26))
                pwdLbl.hide()
 
                btn.on(dxui.Utils.EVENT.CLICK, () => {
                    pwdBoxBg.show()
                    pwdBoxBg.moveForeground()
                    topView.changeTheme(false)
                    localUserAddView.changePwd()
                })
 
                btnEdit.on(dxui.Utils.EVENT.CLICK, () => {
                    btn.send(dxui.Utils.EVENT.CLICK)
                })
 
                deleteBtn.on(dxui.Utils.EVENT.CLICK, () => {
                    viewUtils.confirmOpen('localUserAddView.confirm', 'localUserAddView.confirmPwd', () => {
                        localUserAddView.removePwd()
                    }, () => { })
                })
 
            } else {
                btnLbl.dataI18n = 'localUserAddView.enter'
                btnEditLbl.dataI18n = 'localUserAddView.edit'
            }
 
            if (item.title === 'localUserAddView.card') {
                // 卡
                const cardLbl = dxui.Label.build(userBox.id + 'cardLbl', userBox)
                item.cardLbl = cardLbl
                cardLbl.align(dxui.Utils.ALIGN.LEFT_MID, 180, 0)
                cardLbl.textColor(0x767676)
                cardLbl.textFont(viewUtils.font(26))
                cardLbl.hide()
                cardLbl.longMode(dxui.Utils.LABEL_LONG_MODE.SCROLL_CIRCULAR)
                cardLbl.width(150)
 
                btn.on(dxui.Utils.EVENT.CLICK, () => {
                    cardBoxBg.show()
                    cardBoxBg.moveForeground()
                    topView.changeTheme(false)
                    // 开启刷卡识别
                    screen.getCardStart()
                })
 
                btnEdit.on(dxui.Utils.EVENT.CLICK, () => {
                    btn.send(dxui.Utils.EVENT.CLICK)
                })
 
                deleteBtn.on(dxui.Utils.EVENT.CLICK, () => {
                    viewUtils.confirmOpen('localUserAddView.confirm', 'localUserAddView.confirmCard', () => {
                        localUserAddView.removeCard()
                    }, () => { })
                })
            }
 
            if (item.title === 'localUserAddView.face') {
                // userBox.height(220)
                btn.on(dxui.Utils.EVENT.CLICK, () => {
                    if (!checkRequired()) {
                        return
                    }
                    dxui.loadMain(faceEnterView.screenMain)
                })
 
                btnEdit.on(dxui.Utils.EVENT.CLICK, () => {
                    if (!checkRequired()) {
                        return
                    }
                    dxui.loadMain(faceEnterView.screenMain)
                })
 
                // 人脸图片
                const facePreview = dxui.Button.build('facePreview', userBox)
                item.facePreview = facePreview
                facePreview.bgColor(0x000000)
                facePreview.align(dxui.Utils.ALIGN.LEFT_MID, 180, 0)
                const facePreviewLbl = dxui.Label.build('facePreviewLbl', facePreview)
                facePreviewLbl.textFont(viewUtils.font(22))
                facePreviewLbl.dataI18n = "localUserAddView.preview"
                facePreview.on(dxui.Utils.EVENT.CLICK, () => {
                    facePreviewBox.show()
                    facePreviewBox.moveForeground()
                })
 
                const facePreviewBox = dxui.View.build('facePreviewBox', screenMain)
                viewUtils._clearStyle(facePreviewBox)
                facePreviewBox.hide()
                facePreviewBox.setSize(screenMain.width(), screenMain.height())
                facePreviewBox.on(dxui.Utils.EVENT.CLICK, () => {
                    facePreviewBox.hide()
                })
 
                const faceImg = dxui.Image.build('faceImg', facePreviewBox)
                faceImg.align(dxui.Utils.ALIGN.CENTER, 0, 0)
                item.faceImg = faceImg
 
 
                deleteBtn.on(dxui.Utils.EVENT.CLICK, () => {
                    if (!checkRequired()) {
                        return
                    }
                    viewUtils.confirmOpen('localUserAddView.confirm', 'localUserAddView.confirmFace', () => {
                        localUserAddView.removeFace()
                    }, () => { })
                })
            }
        } else if (item.type === 'dropdown') {
            const dropdown = dxui.Dropdown.build(item.title, userBox)
            item.dropdown = dropdown
            dropdown.setSize(260, 50)
            dropdown.align(dxui.Utils.ALIGN.RIGHT_MID, 0, 0)
            dropdown.textFont(viewUtils.font(22))
            dropdown.getList().textFont(viewUtils.font(22))
            dropdown.setSymbol('/app/code/resource/image/down.png')
            dropdown.on(dxui.Utils.EVENT.VALUE_CHANGED, () => {
                localUserAddView.nowUser.type = dropdown.getSelected()
            })
        }
    })
 
    // 密码生成页
    const pwdBoxBg = dxui.View.build('pwdBoxBg', screenMain)
    viewUtils._clearStyle(pwdBoxBg)
    pwdBoxBg.bgColor(0x000000)
    pwdBoxBg.bgOpa(50)
    pwdBoxBg.setSize(screen.screenSize.width, screen.screenSize.height)
    pwdBoxBg.scroll(false)
    pwdBoxBg.hide()
    pwdBoxBg.on(dxui.Utils.EVENT.CLICK, () => {
        pwdBoxCloseBtn.send(dxui.Utils.EVENT.CLICK)
    })
 
    const pwdBox = dxui.View.build('pwdBox', pwdBoxBg)
    viewUtils._clearStyle(pwdBox)
    pwdBox.setSize(screen.screenSize.width, 694)
    pwdBox.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 50)
    pwdBox.bgColor(0xffffff)
    pwdBox.radius(50)
 
    const pwdBoxLbl = dxui.Label.build('pwdBoxLbl', pwdBox)
    pwdBoxLbl.dataI18n = 'localUserAddView.pwdBoxLbl'
    pwdBoxLbl.textFont(viewUtils.font(36))
    pwdBoxLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, 39)
 
    const pwdBoxCloseBtn = viewUtils.imageBtn(pwdBox, 'pwdBoxCloseBtn', '/app/code/resource/image/close_small.png')
    pwdBoxCloseBtn.align(dxui.Utils.ALIGN.TOP_RIGHT, -55, 18)
    pwdBoxCloseBtn.on(dxui.Utils.EVENT.CLICK, () => {
        pwdBoxBg.hide()
        topView.changeTheme(true)
    })
 
    const pwdBoxContent = dxui.View.build('pwdBoxContent', pwdBox)
    viewUtils._clearStyle(pwdBoxContent)
    pwdBoxContent.setSize(650, 100)
    pwdBoxContent.align(dxui.Utils.ALIGN.TOP_MID, 0, 172)
    pwdBoxContent.flexFlow(dxui.Utils.FLEX_FLOW.ROW_WRAP)
    pwdBoxContent.flexAlign(dxui.Utils.FLEX_ALIGN.SPACE_AROUND, dxui.Utils.FLEX_ALIGN.CENTER, dxui.Utils.FLEX_ALIGN.CENTER)
 
    localUserAddView.pwdBoxContentItem = []
    for (let i = 0; i < 6; i++) {
        const pwdBoxContentItem = dxui.View.build('pwdBoxContentItem' + i, pwdBoxContent)
        pwdBoxContentItem.setSize(78, 90)
        pwdBoxContentItem.radius(13)
        pwdBoxContentItem.borderWidth(1)
        pwdBoxContentItem.setBorderColor(0xEAEAEA)
 
        const pwdBoxContentItemLbl = dxui.Label.build('pwdBoxContentItemLbl' + i, pwdBoxContentItem)
        pwdBoxContentItemLbl.textFont(viewUtils.font(30))
        pwdBoxContentItemLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
        pwdBoxContentItemLbl.text('0')
        localUserAddView.pwdBoxContentItem.push(pwdBoxContentItemLbl)
    }
 
    const pwdBoxSaveBtn = dxui.Button.build('pwdBoxSaveBtn', pwdBox)
    pwdBoxSaveBtn.setSize(210, 60)
    pwdBoxSaveBtn.align(dxui.Utils.ALIGN.TOP_LEFT, 87, 340)
    pwdBoxSaveBtn.bgColor(0xEAEAEA)
    pwdBoxSaveBtn.radius(10)
    pwdBoxSaveBtn.on(dxui.Utils.EVENT.CLICK, () => {
        localUserAddView.changePwd()
    })
 
    const pwdBoxSaveBtnLbl = dxui.Label.build('pwdBoxSaveBtnLbl', pwdBoxSaveBtn)
    pwdBoxSaveBtnLbl.dataI18n = 'localUserAddView.pwdBoxSaveBtnLbl'
    pwdBoxSaveBtnLbl.textFont(viewUtils.font(24))
    pwdBoxSaveBtnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
    pwdBoxSaveBtnLbl.textColor(0x000000)
 
    const pwdBoxConfirmBtn = dxui.Button.build('pwdBoxConfirmBtn', pwdBox)
    pwdBoxConfirmBtn.setSize(210, 60)
    pwdBoxConfirmBtn.align(dxui.Utils.ALIGN.TOP_RIGHT, -76, 340)
    pwdBoxConfirmBtn.bgColor(0x000000)
    pwdBoxConfirmBtn.radius(10)
    pwdBoxConfirmBtn.on(dxui.Utils.EVENT.CLICK, () => {
        localUserAddView.addPwd(localUserAddView.pwdBoxContentFin)
        pwdBoxCloseBtn.send(dxui.Utils.EVENT.CLICK)
    })
 
    const pwdBoxConfirmBtnLbl = dxui.Label.build('pwdBoxConfirmBtnLbl', pwdBoxConfirmBtn)
    pwdBoxConfirmBtnLbl.dataI18n = 'localUserAddView.pwdBoxConfirmBtnLbl'
    pwdBoxConfirmBtnLbl.textFont(viewUtils.font(24))
    pwdBoxConfirmBtnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
 
    // 读取卡片中
    const cardBoxBg = dxui.View.build('cardBoxBg', screenMain)
    viewUtils._clearStyle(cardBoxBg)
    cardBoxBg.setSize(screen.screenSize.width, screen.screenSize.height)
    cardBoxBg.align(dxui.Utils.ALIGN.TOP_MID, 0, 0)
    cardBoxBg.bgColor(0x000000)
    cardBoxBg.bgOpa(50)
    cardBoxBg.scroll(false)
    cardBoxBg.hide()
    cardBoxBg.on(dxui.Utils.EVENT.CLICK, () => {
        cardBoxCloseBtn.send(dxui.Utils.EVENT.CLICK)
    })
 
    const cardBox = dxui.View.build('cardBox', cardBoxBg)
    viewUtils._clearStyle(cardBox)
    cardBox.setSize(screen.screenSize.width, 694)
    cardBox.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, 50)
    cardBox.bgColor(0xffffff)
    cardBox.radius(50)
    cardBox.on(dxui.Utils.EVENT.CLICK, () => {
    })
 
    const cardBoxLbl = dxui.Label.build('cardBoxLbl', cardBox)
    cardBoxLbl.dataI18n = 'localUserAddView.cardBoxLbl'
    cardBoxLbl.textFont(viewUtils.font(36))
    cardBoxLbl.align(dxui.Utils.ALIGN.TOP_MID, 0, 39)
 
    const cardBoxCloseBtn = viewUtils.imageBtn(cardBox, 'cardBoxCloseBtn', '/app/code/resource/image/close_small.png')
    cardBoxCloseBtn.align(dxui.Utils.ALIGN.TOP_RIGHT, -55, 18)
    cardBoxCloseBtn.on(dxui.Utils.EVENT.CLICK, () => {
        cardBoxBg.hide()
        topView.changeTheme(true)
        // 关闭刷卡识别
        screen.endCardEnd()
    })
 
    const cardBoxInput = viewUtils.input(cardBox, 'localUserAddView.cardBoxInput', undefined, undefined, 'localUserAddView.cardBoxInput')
    localUserAddView.cardBoxInput = cardBoxInput
    cardBoxInput.align(dxui.Utils.ALIGN.TOP_MID, 0, 183)
    cardBoxInput.setSize(630, 75)
    cardBoxInput.on(dxui.Utils.EVENT.CLICK, () => {
        cardBoxInput.align(dxui.Utils.ALIGN.TOP_MID, 0, 90)
        pinyin.hideCb(() => {
            cardBoxInput.align(dxui.Utils.ALIGN.TOP_MID, 0, 183)
        })
    })
 
    const cardBoxResetBtn = dxui.Button.build('cardBoxResetBtn', cardBox)
    cardBoxResetBtn.setSize(210, 60)
    cardBoxResetBtn.align(dxui.Utils.ALIGN.TOP_LEFT, 87, 340)
    cardBoxResetBtn.bgColor(0xEAEAEA)
    cardBoxResetBtn.radius(10)
    cardBoxResetBtn.on(dxui.Utils.EVENT.CLICK, () => {
        cardBoxInput.text('')
    })
 
    const cardBoxResetBtnLbl = dxui.Label.build('cardBoxResetBtnLbl', cardBoxResetBtn)
    cardBoxResetBtnLbl.dataI18n = 'localUserAddView.cardBoxResetBtnLbl'
    cardBoxResetBtnLbl.textFont(viewUtils.font(24))
    cardBoxResetBtnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
    cardBoxResetBtnLbl.textColor(0x000000)
 
    const cardBoxSaveBtn = dxui.Button.build('cardBoxSaveBtn', cardBox)
    cardBoxSaveBtn.setSize(210, 60)
    cardBoxSaveBtn.align(dxui.Utils.ALIGN.TOP_RIGHT, -76, 340)
    cardBoxSaveBtn.bgColor(0x000000)
    cardBoxSaveBtn.radius(10)
    cardBoxSaveBtn.on(dxui.Utils.EVENT.CLICK, () => {
        cardBoxCloseBtn.send(dxui.Utils.EVENT.CLICK)
        if (cardBoxInput.text()) {
            localUserAddView.addCard(cardBoxInput.text())
        }
    })
 
    const cardBoxSaveBtnLbl = dxui.Label.build('cardBoxSaveBtnLbl', cardBoxSaveBtn)
    cardBoxSaveBtnLbl.dataI18n = 'localUserAddView.cardBoxSaveBtnLbl'
    cardBoxSaveBtnLbl.textFont(viewUtils.font(24))
    cardBoxSaveBtnLbl.align(dxui.Utils.ALIGN.CENTER, 0, 0)
 
    const deleteBtn = viewUtils.bottomBtn(screenMain, screenMain.id + 'deleteBtn', 'localUserAddView.delete', () => {
        if (!checkRequired()) {
            return
        }
 
        viewUtils.confirmOpen('localUserAddView.confirmDelete', 'localUserAddView.confirmDeleteContent', () => {
            // 删除用户
            const res = screen.deleteUser(localUserAddView.nowUser)
            if (res) {
                dxui.loadMain(localUserView.screenMain)
            } else {
                localUserAddView.statusPanel.fail()
            }
        }, () => { })
 
    }, 0xEAEAEA, 0xEA0000)
    deleteBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -200)
    localUserAddView.deleteBtn = deleteBtn
    deleteBtn.hide()
 
    const saveBtn = viewUtils.bottomBtn(screenMain, screenMain.id + 'saveBtn', 'localUserAddView.save', async () => {
        if (!checkRequired()) {
            return
        }
        let res = false
        if (localUserAddView.deleteBtn.isHide()) {
            // 新增用户
            res = await screen.insertUser(localUserAddView.nowUser)
        } else {
            // 修改用户
            res = screen.updateUser(localUserAddView.nowUser)
        }
 
        if (res === true) {
            localUserAddView.statusPanel.success()
            std.setTimeout(() => {
                // 成功返回上一层界面
                dxui.loadMain(localUserView.screenMain)
            }, 500)
        } else {
            if (typeof res === "string") {
                localUserAddView.statusPanel.fail(res)
            } else {
                localUserAddView.statusPanel.fail()
            }
        }
    })
    saveBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -83)
    localUserAddView.saveBtn = saveBtn
 
    localUserAddView.statusPanel = viewUtils.statusPanel(screenMain, 'localUserAddView.success', 'localUserAddView.fail')
}
 
localUserAddView.addID = function (id) {
    localUserAddView.userInfo[0].input.text(id)
    localUserAddView.nowUser.id = id
}
 
localUserAddView.removeID = function () {
    localUserAddView.userInfo[0].input.text('')
}
 
localUserAddView.addName = function (name) {
    localUserAddView.userInfo[1].input.text(name)
    localUserAddView.nowUser.name = name
}
 
localUserAddView.removeName = function () {
    localUserAddView.userInfo[1].input.text('')
}
 
localUserAddView.addIDCard = function (idCard) {
    localUserAddView.userInfo[2].input.text(idCard)
    localUserAddView.nowUser.idCard = idCard
}
 
localUserAddView.removeIDCard = function () {
    localUserAddView.userInfo[2].input.text('')
}
 
localUserAddView.addFace = function (face) {
    localUserAddView.userInfo[3].btnEdit.show()
    localUserAddView.userInfo[3].btn.hide()
 
    const faceImg = localUserAddView.userInfo[3].faceImg
    faceImg.source(face)
    faceImg.show()
 
    // let header = dxui.Utils.GG.NativeDraw.lvImgDecoderGetInfo(face)
    // let zoom = 60 / header.h * 256
    // faceImg.obj.lvImgSetZoom(zoom)
    // faceImg.obj.lvImgSetSizeMode(dxui.Utils.ENUM.LV_IMG_SIZE_MODE_REAL)
    // faceImg.setSize(Math.ceil(zoom / 256 * header.w), 60)
 
    localUserAddView.userInfo[3].deleteBtn.show()
    localUserAddView.nowUser.face = face
}
 
localUserAddView.removeFace = function () {
    localUserAddView.userInfo[3].btn.show()
    localUserAddView.userInfo[3].btnEdit.hide()
    localUserAddView.userInfo[3].deleteBtn.hide()
    localUserAddView.userInfo[3].faceImg.hide()
    if (localUserAddView.nowUser && localUserAddView.nowUser.face) {
        delete localUserAddView.nowUser.face
    }
}
 
localUserAddView.addPwd = function (pwd) {
    localUserAddView.userInfo[4].btn.hide()
    localUserAddView.userInfo[4].btnEdit.show()
    localUserAddView.userInfo[4].deleteBtn.show()
    localUserAddView.userInfo[4].pwdLbl.show()
    localUserAddView.userInfo[4].pwdLbl.text(pwd)
    localUserAddView.nowUser.pwd = pwd
}
 
localUserAddView.removePwd = function () {
    localUserAddView.userInfo[4].btn.show()
    localUserAddView.userInfo[4].btnEdit.hide()
    localUserAddView.userInfo[4].deleteBtn.hide()
    localUserAddView.userInfo[4].pwdLbl.hide()
    if (localUserAddView.nowUser && localUserAddView.nowUser.pwd) {
        delete localUserAddView.nowUser.pwd
    }
}
 
localUserAddView.addCard = function (card) {
    localUserAddView.userInfo[5].btn.hide()
    localUserAddView.userInfo[5].btnEdit.show()
    localUserAddView.userInfo[5].deleteBtn.show()
    localUserAddView.userInfo[5].cardLbl.show()
    localUserAddView.userInfo[5].cardLbl.text(card)
    localUserAddView.nowUser.card = card
}
 
localUserAddView.removeCard = function () {
    localUserAddView.userInfo[5].btn.show()
    localUserAddView.userInfo[5].btnEdit.hide()
    localUserAddView.userInfo[5].deleteBtn.hide()
    localUserAddView.userInfo[5].cardLbl.hide()
    if (localUserAddView.nowUser && localUserAddView.nowUser.card) {
        delete localUserAddView.nowUser.card
    }
}
 
localUserAddView.addType = function (type) {
    localUserAddView.userInfo[6].dropdown.setSelected(type)
}
 
localUserAddView.changePwd = function () {
    const randomPwd = Math.floor(Math.random() * 900000 + 100000).toString()
    localUserAddView.pwdBoxContentFin = randomPwd
    localUserAddView.pwdBoxContentItem.forEach((item, index) => {
        item.text(randomPwd[index])
    })
}
 
localUserAddView.isEdit = function (flag) {
    localUserAddView.removeFace()
    localUserAddView.removePwd()
    localUserAddView.removeCard()
    localUserAddView.removeID()
    localUserAddView.removeName()
    localUserAddView.removeIDCard()
    if (flag) {
        localUserAddView.saveBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -53)
        localUserAddView.deleteBtn.show()
        localUserAddView.titleBox2.show()
    } else {
        localUserAddView.saveBtn.align(dxui.Utils.ALIGN.BOTTOM_MID, 0, -83)
        localUserAddView.deleteBtn.hide()
        localUserAddView.titleBox2.hide()
        localUserAddView.nowUser = {}
    }
}
 
// 检查必填项
function checkRequired() {
    if (!localUserAddView.userInfo[0].input.text()) {
        localUserAddView.statusPanel.fail("localUserAddView.requiredInfo")
        return false
    }
    if (!localUserAddView.userInfo[1].input.text()) {
        localUserAddView.statusPanel.fail("localUserAddView.requiredInfo")
        return false
    }
    return true
}
 
function refreshType() {
    switch (screen.getConfig()['base.language']) {
        case 'CN':
            localUserAddView.userInfo[6].dropdown.setOptions(dropdownData)
            break;
        case 'EN':
            localUserAddView.userInfo[6].dropdown.setOptions(dropdownData2)
            break;
        default:
            break;
    }
}
 
export default localUserAddView