free-fe-core-modules 0.0.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 +7 -0
- package/components/.gitkeep +0 -0
- package/components/Basic/BreadCrumbs.vue +87 -0
- package/components/Basic/EIcon.vue +84 -0
- package/components/Basic/LeveledMenus.vue +92 -0
- package/components/Basic/SummaryHead.vue +312 -0
- package/components/Dialog/BasicDialog.vue +442 -0
- package/components/Dialog/index.js +38 -0
- package/components/Dialog/index1.js +49 -0
- package/components/FloatingWindow/index.vue +140 -0
- package/components/SelectLocales/index.vue +47 -0
- package/components/SlidingCarousel/index.vue +86 -0
- package/components/SlidingNews/index.vue +138 -0
- package/components/StickyButtons/index.vue +98 -0
- package/components/ThemeSwitch/index.vue +77 -0
- package/field-components/Display/index.js +3 -0
- package/field-components/Fields/AgreementCheck.vue +161 -0
- package/field-components/Fields/ApiCall.vue +139 -0
- package/field-components/Fields/Boolean.vue +112 -0
- package/field-components/Fields/Category.vue +33 -0
- package/field-components/Fields/Check.vue +131 -0
- package/field-components/Fields/Customize.vue +103 -0
- package/field-components/Fields/Date.vue +142 -0
- package/field-components/Fields/DateRange.vue +199 -0
- package/field-components/Fields/DynamicList.vue +575 -0
- package/field-components/Fields/FieldEditor.vue +379 -0
- package/field-components/Fields/File.vue +382 -0
- package/field-components/Fields/FileList.vue +405 -0
- package/field-components/Fields/FileListCombined.vue +142 -0
- package/field-components/Fields/FixedList.vue +372 -0
- package/field-components/Fields/Image.vue +328 -0
- package/field-components/Fields/ImageList.vue +285 -0
- package/field-components/Fields/ImageListCombined.vue +76 -0
- package/field-components/Fields/InputFieldList.vue +299 -0
- package/field-components/Fields/Labels.vue +182 -0
- package/field-components/Fields/MixedTable.vue +367 -0
- package/field-components/Fields/Number.vue +247 -0
- package/field-components/Fields/Password.vue +79 -0
- package/field-components/Fields/Permission.vue +83 -0
- package/field-components/Fields/PermissionEditor.vue +205 -0
- package/field-components/Fields/QueryFilters.vue +162 -0
- package/field-components/Fields/RadioList.vue +81 -0
- package/field-components/Fields/Rich.vue +369 -0
- package/field-components/Fields/Search.vue +499 -0
- package/field-components/Fields/Select.vue +376 -0
- package/field-components/Fields/SelectionChain.vue +198 -0
- package/field-components/Fields/Separator.vue +26 -0
- package/field-components/Fields/SingleList.vue +125 -0
- package/field-components/Fields/Static.vue +22 -0
- package/field-components/Fields/String.vue +185 -0
- package/field-components/Fields/Text.vue +89 -0
- package/field-components/Fields/Time.vue +160 -0
- package/field-components/Fields/TimeRange.vue +348 -0
- package/field-components/Fields/UltimateFile.vue +100 -0
- package/field-components/Fields/Year.vue +124 -0
- package/field-components/Fields/YearRange.vue +188 -0
- package/field-components/Fields/components/FieldTypeOptions.vue +248 -0
- package/field-components/Fields/index.js +117 -0
- package/field-components/components/FieldComponents.vue +246 -0
- package/field-components/index.js +13 -0
- package/field-components/style.sass +11 -0
- package/free-fields/AutoHide.js +66 -0
- package/free-fields/CenterContent.js +15 -0
- package/free-fields/Draggable.js +30 -0
- package/free-fields/Droppable.js +114 -0
- package/free-fields/EditableString.js +63 -0
- package/free-fields/FieldCategory.js +83 -0
- package/free-fields/FieldTypeSelect.js +94 -0
- package/free-fields/fieldEditors/arrayEditor.js +3 -0
- package/free-fields/fieldEditors/boolEditor.js +22 -0
- package/free-fields/fieldEditors/dateEditor.js +23 -0
- package/free-fields/fieldEditors/datetimeEditor.js +23 -0
- package/free-fields/fieldEditors/index.js +21 -0
- package/free-fields/fieldEditors/jsonEditor.js +371 -0
- package/free-fields/fieldEditors/labeledField.js +74 -0
- package/free-fields/fieldEditors/numberEditor.js +51 -0
- package/free-fields/fieldEditors/objectEditor.js +3 -0
- package/free-fields/fieldEditors/selectEditor.js +0 -0
- package/free-fields/fieldEditors/stringEditor.js +49 -0
- package/free-fields/fieldEditors/textEditor.js +50 -0
- package/free-fields/fieldEditors/timeEditor.js +23 -0
- package/free-fields/index.js +402 -0
- package/i18n/en-us/index.js +73 -0
- package/i18n/fields/en-us/index.js +9 -0
- package/i18n/fields/zh-cn/index.js +9 -0
- package/i18n/zh-cn/index.js +73 -0
- package/index.js +367 -0
- package/package.json +11 -0
- package/router/dict/api.js +18 -0
- package/router/dict/data.js +48 -0
- package/router/dict/index.js +7 -0
- package/router/error/api.js +14 -0
- package/router/error/data.js +33 -0
- package/router/error/index.js +9 -0
- package/router/index.js +13 -0
- package/router/menu/api.js +24 -0
- package/router/menu/data.js +85 -0
- package/router/menu/index.js +7 -0
- package/router/system/api.js +10 -0
- package/router/system/data.js +46 -0
- package/router/system/index.js +7 -0
- package/stores/index.js +17 -0
- package/stores/module-mourning/actions.js +3 -0
- package/stores/module-mourning/getters.js +1 -0
- package/stores/module-mourning/index.js +11 -0
- package/stores/module-mourning/state.js +3 -0
- package/stores/mourning.js +3 -0
- package/view/dict/index.vue +284 -0
- package/view/error/list.vue +197 -0
- package/view/menu/index.vue +332 -0
- package/view/mourning/mourning.vue +45 -0
- package/view/system/index.vue +149 -0
|
@@ -0,0 +1,499 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<span class="input-field-search">
|
|
3
|
+
<q-dialog v-model="showSearch" class="input-field-search-dialog" persistent>
|
|
4
|
+
<q-card class="input-field-search-dialog-card">
|
|
5
|
+
<q-toolbar>
|
|
6
|
+
<div class="simple-field full-width">
|
|
7
|
+
<q-input
|
|
8
|
+
autofocus
|
|
9
|
+
v-model="searchKey"
|
|
10
|
+
hide-bottom-space
|
|
11
|
+
:placeholder="Field &&
|
|
12
|
+
((Field.Options && Field.Options.SearchPlaceholder) || Field.Placeholder)"
|
|
13
|
+
@keydown.enter="search()"
|
|
14
|
+
class="full-width"
|
|
15
|
+
>
|
|
16
|
+
<template v-slot:append>
|
|
17
|
+
<q-btn :class="Field.Options.SearchBtnClasses" :flat="!Field.Options.SearchBtn3D" :round="!Field.Options.SearchBtnRect" icon="search" @click="search()" :disabled="Field.ReadOnly">{{Field.Options.SearchBtnText}}</q-btn>
|
|
18
|
+
</template>
|
|
19
|
+
</q-input>
|
|
20
|
+
</div>
|
|
21
|
+
</q-toolbar>
|
|
22
|
+
|
|
23
|
+
<q-card-section :style="`
|
|
24
|
+
width: ${Field.Options.Width|| '800px'};
|
|
25
|
+
max-width: ${Field.Options.MaxWidth|| '80vw'};
|
|
26
|
+
overflow-y: scroll`">
|
|
27
|
+
<q-table
|
|
28
|
+
:flat="Field.Options && Field.Options.Flat"
|
|
29
|
+
:bordered="Field.Options && Field.Options.Bordered"
|
|
30
|
+
:rows="searchData ? searchData.docs : []"
|
|
31
|
+
:columns="searchColumns"
|
|
32
|
+
row-key="id"
|
|
33
|
+
:pagination="searchPagination"
|
|
34
|
+
:selection="Field.Multiple ? 'multiple' : 'single'"
|
|
35
|
+
v-model:selected="searchSelected"
|
|
36
|
+
>
|
|
37
|
+
<template v-slot:header="props">
|
|
38
|
+
<q-tr :props="props">
|
|
39
|
+
<q-th auto-width v-if="!Field.Options || !Field.Options.checkOnRight"/>
|
|
40
|
+
<q-th
|
|
41
|
+
v-for="col in props.cols"
|
|
42
|
+
:key="col.name"
|
|
43
|
+
:props="props"
|
|
44
|
+
>
|
|
45
|
+
{{ col.label }}
|
|
46
|
+
</q-th>
|
|
47
|
+
<q-th auto-width v-if="Field.Options && Field.Options.checkOnRight"/>
|
|
48
|
+
</q-tr>
|
|
49
|
+
</template>
|
|
50
|
+
<template v-slot:body="props">
|
|
51
|
+
<q-tr class="table-row">
|
|
52
|
+
<q-td auto-width v-if="!Field.Options || !Field.Options.checkOnRight">
|
|
53
|
+
<q-toggle v-model="props.selected" v-if="Field.Options && Field.Options.useToggle"/>
|
|
54
|
+
<q-checkbox v-else v-model="props.selected"></q-checkbox>
|
|
55
|
+
</q-td>
|
|
56
|
+
<q-td
|
|
57
|
+
v-for="col in props.cols"
|
|
58
|
+
:key="col.name"
|
|
59
|
+
:props="props"
|
|
60
|
+
:class="`col-${col.name} col-${col.value}`"
|
|
61
|
+
>
|
|
62
|
+
{{col.value}}
|
|
63
|
+
</q-td>
|
|
64
|
+
<q-td auto-width v-if="Field.Options && Field.Options.checkOnRight">
|
|
65
|
+
<q-toggle v-model="props.selected" v-if="Field.Options && Field.Options.useToggle"/>
|
|
66
|
+
<q-checkbox v-else v-model="props.selected"></q-checkbox>
|
|
67
|
+
</q-td>
|
|
68
|
+
</q-tr>
|
|
69
|
+
</template>
|
|
70
|
+
<template v-slot:no-data>
|
|
71
|
+
<div class="full-width full-height row flex-center q-gutter-sm">
|
|
72
|
+
<span>暂 无 信 息</span>
|
|
73
|
+
</div>
|
|
74
|
+
</template>
|
|
75
|
+
|
|
76
|
+
<template v-slot:bottom>
|
|
77
|
+
<div class="full-width row flex-center">
|
|
78
|
+
共{{searchData.total}}条
|
|
79
|
+
<q-pagination
|
|
80
|
+
v-model="searchData.page"
|
|
81
|
+
:max="searchData.pages"
|
|
82
|
+
@input="searchPaginationChanged"
|
|
83
|
+
boundary-numbers
|
|
84
|
+
direction-links
|
|
85
|
+
:max-pages="2"
|
|
86
|
+
></q-pagination>
|
|
87
|
+
</div>
|
|
88
|
+
</template>
|
|
89
|
+
</q-table>
|
|
90
|
+
</q-card-section>
|
|
91
|
+
<q-card-actions>
|
|
92
|
+
<div class="buttons row full-width justify-center q-ma-sm">
|
|
93
|
+
<q-btn
|
|
94
|
+
:icon="(Field.Options && Field.Options.CancelIcon) || 'cancel'"
|
|
95
|
+
class="cancel-btn q-mr-md"
|
|
96
|
+
@click="showSearch = false; searchSelected=originalSelected; $emit('input')"
|
|
97
|
+
>{{$t('cancelButtonText')}}</q-btn>
|
|
98
|
+
<q-btn
|
|
99
|
+
:icon="(Field.Options && Field.Options.OkIcon) || 'check'"
|
|
100
|
+
class="ok-btn" @click="searchOK">{{$t('okButtonText')}}</q-btn>
|
|
101
|
+
</div>
|
|
102
|
+
</q-card-actions>
|
|
103
|
+
</q-card>
|
|
104
|
+
</q-dialog>
|
|
105
|
+
|
|
106
|
+
<span v-if="Field.ReadOnly" class="simple-field row">
|
|
107
|
+
<span
|
|
108
|
+
:class="`field-label field-label-readonly ${
|
|
109
|
+
(Field.Label && Field.Label.trim().length)
|
|
110
|
+
? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
|
|
111
|
+
v-if="typeof Field.Label !== 'undefined'"
|
|
112
|
+
>
|
|
113
|
+
<q-tooltip v-if="Field.Description" anchor="top right">{{Field.Description}}</q-tooltip>
|
|
114
|
+
{{Field.Label || ''}}
|
|
115
|
+
<span v-if="Field.Required" class="required-mark">*</span>
|
|
116
|
+
</span>
|
|
117
|
+
<span class="readonly-content">
|
|
118
|
+
<span :style="(Field.Info && Field.Info.Style) ? Field.Info.Style : ''">{{searchDisplay}}</span>
|
|
119
|
+
</span>
|
|
120
|
+
</span>
|
|
121
|
+
<q-input
|
|
122
|
+
v-else
|
|
123
|
+
v-model="searchDisplay"
|
|
124
|
+
:type="`${Field && Field.Multiple ? 'textarea' : ''}`"
|
|
125
|
+
hide-bottom-space
|
|
126
|
+
readonly
|
|
127
|
+
v-bind="$attrs"
|
|
128
|
+
:class="`${Field && Field.Multiple
|
|
129
|
+
? '' : 'simple-field'} ${searchDisplay ? 'has-data' : 'empty'}`"
|
|
130
|
+
:ref="`input_field_validator_${Field.Name || Field.Label}`"
|
|
131
|
+
@click="searchKey = '';searchData = {}; showSearch = true"
|
|
132
|
+
>
|
|
133
|
+
<template v-slot:prepend>
|
|
134
|
+
<q-chip
|
|
135
|
+
v-for="(selected, index) in searchSelected"
|
|
136
|
+
:key="index"
|
|
137
|
+
removable
|
|
138
|
+
:value="!!searchSelected[index]"
|
|
139
|
+
@remove="removeSelected(selected)"
|
|
140
|
+
:color="Field.BgColor || 'primary'"
|
|
141
|
+
:text-color="Field.Color || 'white'"
|
|
142
|
+
>
|
|
143
|
+
<q-tooltip
|
|
144
|
+
anchor="top right"
|
|
145
|
+
>{{selected[(Field.Options && Field.Options.SearchDisplayField) || 'id']}}</q-tooltip>
|
|
146
|
+
{{selected[(Field.Options && Field.Options.SearchDisplayField) || 'id']}}
|
|
147
|
+
</q-chip>
|
|
148
|
+
</template>
|
|
149
|
+
<template v-slot:before>
|
|
150
|
+
<span
|
|
151
|
+
:class="`field-label ${(Field.Label && Field.Label.trim().length)
|
|
152
|
+
? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
|
|
153
|
+
v-if="typeof Field.Label !== 'undefined'"
|
|
154
|
+
>
|
|
155
|
+
<q-tooltip v-if="Field.Description" anchor="top right">{{Field.Description}}</q-tooltip>
|
|
156
|
+
{{Field.Label || ''}}
|
|
157
|
+
<span v-if="Field.Required" class="required-mark">*</span>
|
|
158
|
+
</span>
|
|
159
|
+
</template>
|
|
160
|
+
<template v-slot:append>
|
|
161
|
+
<q-btn
|
|
162
|
+
flat
|
|
163
|
+
dense
|
|
164
|
+
icon="search"
|
|
165
|
+
class="search-btn"
|
|
166
|
+
style="width: 36px"
|
|
167
|
+
@click="searchKey = '';searchData = {}; showSearch = true"
|
|
168
|
+
></q-btn>
|
|
169
|
+
</template>
|
|
170
|
+
</q-input>
|
|
171
|
+
<slot name="warning"></slot>
|
|
172
|
+
</span>
|
|
173
|
+
</template>
|
|
174
|
+
|
|
175
|
+
<script>
|
|
176
|
+
import { defineComponent } from 'vue';
|
|
177
|
+
import mixins from 'free-fe-mixins';
|
|
178
|
+
|
|
179
|
+
export default defineComponent({
|
|
180
|
+
name: 'InputFieldSearch',
|
|
181
|
+
mixins: [mixins.InputFieldMixin],
|
|
182
|
+
emits:['input'],
|
|
183
|
+
fieldInfo: {
|
|
184
|
+
Category: 'Advanced',
|
|
185
|
+
Label: '搜索',
|
|
186
|
+
Value: 'Search',
|
|
187
|
+
Extra: [
|
|
188
|
+
{
|
|
189
|
+
Type: 'String',
|
|
190
|
+
Label: '搜索地址',
|
|
191
|
+
Name: 'Options.SearchUrl',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
Type: 'String',
|
|
195
|
+
Label: '搜索字段',
|
|
196
|
+
Name: 'Options.SearchField',
|
|
197
|
+
Default: 'id',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
Type: 'String',
|
|
201
|
+
Label: '显示字段',
|
|
202
|
+
Name: 'Options.SearchDisplayField',
|
|
203
|
+
Default: 'Name',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
Type: 'String',
|
|
207
|
+
Label: '弹窗宽度',
|
|
208
|
+
Name: 'Options.Width',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
Type: 'String',
|
|
212
|
+
Label: '弹窗最大宽度',
|
|
213
|
+
Name: 'Options.MaxWidth',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
Type: 'Boolean',
|
|
217
|
+
Label: '可多选',
|
|
218
|
+
Name: 'Multiple',
|
|
219
|
+
// Extra: [
|
|
220
|
+
// {
|
|
221
|
+
// Label: '最多可选',
|
|
222
|
+
// Type: 'Number',
|
|
223
|
+
// Name: 'Options.MaxSelection',
|
|
224
|
+
// Default: 2,
|
|
225
|
+
// MinValue: 1,
|
|
226
|
+
// // Options: {
|
|
227
|
+
// // Postfix: '个',
|
|
228
|
+
// // },
|
|
229
|
+
// },
|
|
230
|
+
// {
|
|
231
|
+
// Label: '换行显示',
|
|
232
|
+
// Type: 'Boolean',
|
|
233
|
+
// Default: false,
|
|
234
|
+
// Name: 'Options.AutoWrap',
|
|
235
|
+
// },
|
|
236
|
+
// ],
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
Label: '最多可选',
|
|
240
|
+
Type: 'Number',
|
|
241
|
+
Name: 'Options.MaxSelection',
|
|
242
|
+
Default: 2,
|
|
243
|
+
MinValue: 1,
|
|
244
|
+
// Options: {
|
|
245
|
+
// Postfix: '个',
|
|
246
|
+
// },
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
Label: '换行显示',
|
|
250
|
+
Type: 'Boolean',
|
|
251
|
+
Default: false,
|
|
252
|
+
Name: 'Options.AutoWrap',
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
Type: 'String',
|
|
256
|
+
Label: '搜索框占位符',
|
|
257
|
+
Name: 'Options.SearchPlaceholder',
|
|
258
|
+
},
|
|
259
|
+
{
|
|
260
|
+
Type: 'DynamicList',
|
|
261
|
+
Label: '搜索显示列',
|
|
262
|
+
Name: 'Options.SearchColumns',
|
|
263
|
+
Options: {
|
|
264
|
+
Columns: [
|
|
265
|
+
{
|
|
266
|
+
Label: 'Name',
|
|
267
|
+
Name: 'Name',
|
|
268
|
+
},
|
|
269
|
+
{
|
|
270
|
+
Label: 'Label',
|
|
271
|
+
Name: 'Label',
|
|
272
|
+
},
|
|
273
|
+
{
|
|
274
|
+
Label: 'Filters',
|
|
275
|
+
Name: 'filters',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
Label: 'Style',
|
|
279
|
+
Name: 'style',
|
|
280
|
+
},
|
|
281
|
+
],
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
],
|
|
285
|
+
Description: '',
|
|
286
|
+
},
|
|
287
|
+
data() {
|
|
288
|
+
return {
|
|
289
|
+
searchKey: '',
|
|
290
|
+
showSearch: false,
|
|
291
|
+
searchData: {},
|
|
292
|
+
searchSelected: [],
|
|
293
|
+
originalSelected: [],
|
|
294
|
+
searchDisplay: '',
|
|
295
|
+
searchPagination: {
|
|
296
|
+
rowsPerPage:
|
|
297
|
+
this.searchData && this.searchData.limit ? this.searchData.limit : 5,
|
|
298
|
+
rowsNumber:
|
|
299
|
+
this.searchData && this.searchData.total ? this.searchData.total : 0,
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
},
|
|
303
|
+
computed: {
|
|
304
|
+
searchColumns() {
|
|
305
|
+
if (
|
|
306
|
+
!this.Field
|
|
307
|
+
|| !this.Field.Options
|
|
308
|
+
|| !this.Field.Options.SearchColumns
|
|
309
|
+
) {
|
|
310
|
+
return [];
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
const cls = [];
|
|
314
|
+
this.Field.Options.SearchColumns.forEach((c) => {
|
|
315
|
+
const newC = { ...c };
|
|
316
|
+
newC.name = c.Name;
|
|
317
|
+
newC.label = c.Label;
|
|
318
|
+
newC.field = c.Name;
|
|
319
|
+
newC.required = c.required;
|
|
320
|
+
newC.align = c.align;
|
|
321
|
+
newC.sortable = c.sortable;
|
|
322
|
+
newC.sort = c.sort;
|
|
323
|
+
newC.style = c.style;
|
|
324
|
+
newC.classes = c.classes;
|
|
325
|
+
newC.headerStyle = c.headerStyle;
|
|
326
|
+
newC.headerClasses = c.headerClasses;
|
|
327
|
+
newC.format = c.format || ((val, row) => Object.nestValue(row, c.Name));
|
|
328
|
+
|
|
329
|
+
delete newC.Name;
|
|
330
|
+
delete newC.Label;
|
|
331
|
+
|
|
332
|
+
cls.push(newC);
|
|
333
|
+
});
|
|
334
|
+
|
|
335
|
+
return cls;
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
watch: {
|
|
339
|
+
data(n, o) {
|
|
340
|
+
// init search data from exist id
|
|
341
|
+
if (typeof this.fieldData === 'undefined') {
|
|
342
|
+
this.searchSelected = [];
|
|
343
|
+
this.searchData = {};
|
|
344
|
+
this.searchDisplay = '';
|
|
345
|
+
this.searchKey = '';
|
|
346
|
+
} else if (this.Field.Type === 'Search' && this.data) {
|
|
347
|
+
if (n && o) {
|
|
348
|
+
const nV = Object.nestValue(n, this.Field.Name);
|
|
349
|
+
const oV = Object.nestValue(o, this.Field.Name);
|
|
350
|
+
|
|
351
|
+
if (nV === oV || !nV) return;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
if (this.Field.Options && this.Field.Options.SearchUrl) {
|
|
355
|
+
const paramObj = {};
|
|
356
|
+
paramObj[this.Field.Options.SearchField || 'id'] = this.Field.Multiple
|
|
357
|
+
? JSON.stringify(Object.nestValue(this.data, this.Field.Name))
|
|
358
|
+
: Object.nestValue(this.data, this.Field.Name);
|
|
359
|
+
|
|
360
|
+
this.getRequest(
|
|
361
|
+
`${this.Field.Options.SearchUrl}`,
|
|
362
|
+
paramObj
|
|
363
|
+
)
|
|
364
|
+
.then((d) => {
|
|
365
|
+
if (d && d.msg === 'OK' && d.data.total) {
|
|
366
|
+
this.searchSelected = d.data.docs;
|
|
367
|
+
const selected = this.Field && this.Field.Multiple
|
|
368
|
+
? this.searchSelected : [this.searchSelected[0]];
|
|
369
|
+
const sdFieldName = this.Field.Options.SearchDisplayField || 'id';
|
|
370
|
+
this.searchDisplay = selected.map((ss) => Object.nestValue(ss, sdFieldName))
|
|
371
|
+
.join(this.Field && this.Field.Options && this.Field.Options.AutoWrap ? '\r\n' : ',');
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
},
|
|
377
|
+
searchSelected() {
|
|
378
|
+
if (this.Field && this.Field.Options && this.Field.Options.MaxSelection) {
|
|
379
|
+
if (this.searchSelected.length > this.Field.Options.MaxSelection) {
|
|
380
|
+
this.searchSelected.splice(this.Field.Options.MaxSelection);
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
},
|
|
384
|
+
showSearch(v) {
|
|
385
|
+
if (v && this.Field && this.Field.Options && this.Field.Options.AutoSearch) {
|
|
386
|
+
this.search();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
if(v) {
|
|
390
|
+
this.originalSelected = this.searchSelected;
|
|
391
|
+
}
|
|
392
|
+
},
|
|
393
|
+
},
|
|
394
|
+
created() {
|
|
395
|
+
// search, add filters to col
|
|
396
|
+
if (this.Field.Type === 'Search') {
|
|
397
|
+
this.searchColumns.forEach((col) => {
|
|
398
|
+
if (col.filters) {
|
|
399
|
+
col.format = this.ctx.filters[col.filters];
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
}
|
|
403
|
+
},
|
|
404
|
+
methods: {
|
|
405
|
+
search(p) {
|
|
406
|
+
if (
|
|
407
|
+
!this.Field.Options
|
|
408
|
+
|| !this.Field.Options.SearchUrl
|
|
409
|
+
|| (!this.searchKey && !this.Field.Options.AllowEmptySearch)
|
|
410
|
+
) {
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
this.getRequest(
|
|
415
|
+
this.Field.Options.SearchUrl,
|
|
416
|
+
{search: this.searchKey, ...(p ? {page: p} : {})}
|
|
417
|
+
)
|
|
418
|
+
.then((d) => {
|
|
419
|
+
if (d && d.msg === 'OK') {
|
|
420
|
+
const { data } = d;
|
|
421
|
+
if (data) {
|
|
422
|
+
for (let i = 0; i < data.docs.length; i += 1) {
|
|
423
|
+
const dc = data.docs[i];
|
|
424
|
+
|
|
425
|
+
dc.index = (data.page - 1) * data.limit + i + 1;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
this.searchData = data;
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
});
|
|
432
|
+
},
|
|
433
|
+
searchPaginationChanged(p) {
|
|
434
|
+
this.search(p);
|
|
435
|
+
},
|
|
436
|
+
searchOK() {
|
|
437
|
+
if (this.searchSelected.length) {
|
|
438
|
+
const selected = this.Field && this.Field.Multiple
|
|
439
|
+
? this.searchSelected : [this.searchSelected[0]];
|
|
440
|
+
|
|
441
|
+
const sFieldName = this.Field.SearchField || 'id';
|
|
442
|
+
this.fieldData = selected.map(
|
|
443
|
+
(ss) => Object.nestValue(ss, sFieldName),
|
|
444
|
+
).filter((ss) => !!ss);
|
|
445
|
+
if (!this.Field || !this.Field.Multiple) {
|
|
446
|
+
[this.fieldData] = this.fieldData;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
const sdFieldName = this.Field.Options.SearchDisplayField || 'id';
|
|
450
|
+
this.searchDisplay = selected.map((ss) => Object.nestValue(ss, sdFieldName))
|
|
451
|
+
.join(this.Field && this.Field.Options && this.Field.Options.AutoWrap ? '\r\n' : ',');
|
|
452
|
+
|
|
453
|
+
this.showSearch = false;
|
|
454
|
+
this.$emit('input');
|
|
455
|
+
}
|
|
456
|
+
},
|
|
457
|
+
removeSelected(item) {
|
|
458
|
+
if (!item) return;
|
|
459
|
+
|
|
460
|
+
if (!this.Field || !this.Field.Multiple) {
|
|
461
|
+
this.searchSelected = [];
|
|
462
|
+
this.fieldData = undefined;
|
|
463
|
+
|
|
464
|
+
this.$emit('input');
|
|
465
|
+
|
|
466
|
+
return;
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
const index = this.searchSelected.findIndex((ss) => ss[this.Field.SearchField || 'id'] === item[this.Field.SearchField || 'id']);
|
|
470
|
+
if (index >= 0) {
|
|
471
|
+
this.searchSelected.splice(index, 1);
|
|
472
|
+
|
|
473
|
+
const selected = this.Field && this.Field.Multiple
|
|
474
|
+
? this.searchSelected : [this.searchSelected[0]];
|
|
475
|
+
const sFieldName = this.Field.SearchField || 'id';
|
|
476
|
+
this.fieldData = selected.map(
|
|
477
|
+
(ss) => Object.nestValue(ss, sFieldName),
|
|
478
|
+
).filter((ss) => !!ss);
|
|
479
|
+
|
|
480
|
+
const sdFieldName = this.Field.Options.SearchDisplayField || 'id';
|
|
481
|
+
this.searchDisplay = selected.map((ss) => Object.nestValue(ss, sdFieldName))
|
|
482
|
+
.join(this.Field && this.Field.Options && this.Field.Options.AutoWrap ? '\r\n' : ',');
|
|
483
|
+
|
|
484
|
+
this.$emit('input');
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
</script>
|
|
490
|
+
|
|
491
|
+
<style lang="sass" scoped>
|
|
492
|
+
.input-field-search-dialog-card
|
|
493
|
+
max-width: unset !important
|
|
494
|
+
max-height: unset !important
|
|
495
|
+
|
|
496
|
+
.input-field-search
|
|
497
|
+
.simple-field
|
|
498
|
+
display: flex
|
|
499
|
+
</style>
|