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
| <template>
| <ArtSearchBar
| ref="searchBarRef"
| v-model="formData"
| :items="formItems"
| @reset="handleReset"
| @search="handleSearch"
| />
| </template>
|
| <script setup>
| import { createUserSearchState } from '../userPage.helpers'
|
| const props = defineProps({
| modelValue: { required: true },
| deptTreeOptions: { required: false, default: () => [] },
| roleOptions: { required: false, default: () => [] }
| })
|
| const emit = defineEmits(['update:modelValue', 'search', 'reset'])
| const searchBarRef = ref()
|
| const formData = computed({
| get: () => props.modelValue,
| set: (val) => emit('update:modelValue', val)
| })
|
| const formItems = computed(() => [
| {
| label: '用户名',
| key: 'username',
| type: 'input',
| props: {
| placeholder: '请输入用户名',
| clearable: true
| }
| },
| {
| label: '昵称',
| key: 'nickname',
| type: 'input',
| props: {
| placeholder: '请输入昵称',
| clearable: true
| }
| },
| {
| label: '手机号',
| key: 'phone',
| type: 'input',
| props: {
| placeholder: '请输入手机号',
| clearable: true
| }
| },
| {
| label: '邮箱',
| key: 'email',
| type: 'input',
| props: {
| placeholder: '请输入邮箱',
| clearable: true
| }
| },
| {
| label: '工号',
| key: 'code',
| type: 'input',
| props: {
| placeholder: '请输入工号',
| clearable: true
| }
| },
| {
| label: '部门',
| key: 'deptId',
| type: 'treeselect',
| props: {
| data: props.deptTreeOptions,
| props: {
| label: 'label',
| value: 'value',
| children: 'children'
| },
| placeholder: '请选择部门',
| clearable: true,
| checkStrictly: true
| }
| },
| {
| label: '角色',
| key: 'roleIds',
| type: 'select',
| props: {
| placeholder: '请选择角色',
| clearable: true,
| multiple: true,
| collapseTags: true,
| filterable: true,
| options: props.roleOptions
| }
| },
| {
| label: '性别',
| key: 'sex',
| type: 'select',
| props: {
| placeholder: '请选择性别',
| clearable: true,
| options: [
| { label: '未知', value: 0 },
| { label: '男', value: 1 },
| { label: '女', value: 2 }
| ]
| }
| },
| {
| label: '真实姓名',
| key: 'realName',
| type: 'input',
| props: {
| placeholder: '请输入真实姓名',
| clearable: true
| }
| },
| {
| label: '身份证号',
| key: 'idCard',
| type: 'input',
| props: {
| placeholder: '请输入身份证号',
| clearable: true
| }
| },
| {
| label: '关键字',
| key: 'condition',
| type: 'input',
| props: {
| placeholder: '输入关键字搜索',
| clearable: true
| }
| },
| {
| label: '状态',
| key: 'status',
| type: 'select',
| props: {
| placeholder: '请选择状态',
| clearable: true,
| options: [
| { label: '正常', value: 1 },
| { label: '禁用', value: 0 }
| ]
| }
| }
| ])
|
| function handleReset() {
| emit('update:modelValue', createUserSearchState())
| emit('reset')
| }
|
| async function handleSearch(params) {
| await searchBarRef.value.validate()
| emit('search', params)
| }
| </script>
|
|