free-fe-core-modules 0.0.3 → 0.0.5
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/components/Basic/SummaryHead.vue +13 -2
- package/components/Dialog/BasicDialog.vue +11 -3
- package/components/SlidingCarousel/index.vue +13 -2
- package/components/SlidingNews/index.vue +13 -2
- package/composible/useFormValidator.js +56 -0
- package/free-field/Fields/AgreementCheck.js +6 -2
- package/free-field/Fields/Date.js +13 -5
- package/free-field/Fields/DateRange.js +14 -8
- package/free-field/Fields/DynamicList.js +33 -33
- package/free-field/Fields/FixedList.vue +9 -5
- package/free-field/Fields/Labels.vue +7 -1
- package/free-field/Fields/MixedTable.vue +9 -3
- package/free-field/Fields/Number.js +12 -6
- package/free-field/Fields/Password.js +12 -6
- package/free-field/Fields/PermissionEditor.vue +0 -1
- package/free-field/Fields/Search.vue +8 -2
- package/free-field/Fields/Select.vue +4 -1
- package/free-field/Fields/SelectionChain.vue +8 -2
- package/free-field/Fields/String.js +11 -5
- package/free-field/Fields/Text.js +12 -6
- package/free-field/Fields/Time.vue +8 -2
- package/free-field/Fields/TimeRange.vue +9 -3
- package/free-field/Fields/Year.js +12 -6
- package/free-field/Fields/YearRange.vue +9 -6
- package/free-field/Fields/index.js +12 -12
- package/free-field/composible/fieldWrapper.js +59 -51
- package/package.json +2 -2
- package/view/menu/index.vue +15 -11
- package/free-field/Fields/File.vue +0 -382
- package/free-field/Fields/FileList.vue +0 -405
- package/free-field/Fields/FileListCombined.vue +0 -142
- package/free-field/Fields/Image.vue +0 -328
- package/free-field/Fields/ImageList.vue +0 -285
- package/free-field/Fields/ImageListCombined.vue +0 -76
- package/free-field/Fields/UltimateFile.vue +0 -100
|
@@ -1,382 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="row input-field-file">
|
|
3
|
-
<span
|
|
4
|
-
:class="`field-label ${(Field.Label && Field.Label.trim().length)
|
|
5
|
-
? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
|
|
6
|
-
v-if="Field.Label !== void 0"
|
|
7
|
-
>
|
|
8
|
-
<q-tooltip
|
|
9
|
-
v-if="Field.Description"
|
|
10
|
-
anchor="top right"
|
|
11
|
-
>{{Field.Description}}</q-tooltip>
|
|
12
|
-
{{Field.Label || ''}}
|
|
13
|
-
<span
|
|
14
|
-
v-if="Field.Required"
|
|
15
|
-
class="required-mark"
|
|
16
|
-
>*</span>
|
|
17
|
-
</span>
|
|
18
|
-
|
|
19
|
-
<q-uploader
|
|
20
|
-
@uploaded="uploaded"
|
|
21
|
-
@removed="fieldData = ''; $emit('input')"
|
|
22
|
-
@rejected="filesRejected"
|
|
23
|
-
ref="uploader"
|
|
24
|
-
:factory="factoryFn"
|
|
25
|
-
auto-upload
|
|
26
|
-
:max-file-size="maxFileSize"
|
|
27
|
-
:accept="acceptedFileTypes"
|
|
28
|
-
:class="`q-ma-xs ${hasError ? 'input-field--error' : ''}`"
|
|
29
|
-
>
|
|
30
|
-
<template v-slot:list="scope">
|
|
31
|
-
<div
|
|
32
|
-
v-if="Field.Options && Field.Options.AsLink && scope.files.length"
|
|
33
|
-
class="file-link row full-width ellipsis items-center"
|
|
34
|
-
>
|
|
35
|
-
<div
|
|
36
|
-
class="row ellipsis full-width"
|
|
37
|
-
v-for="(file, index) in scope.files"
|
|
38
|
-
:key="index"
|
|
39
|
-
>
|
|
40
|
-
<q-btn
|
|
41
|
-
icon="cloud_download"
|
|
42
|
-
dense
|
|
43
|
-
flat
|
|
44
|
-
></q-btn>
|
|
45
|
-
<a
|
|
46
|
-
class="ellipsis"
|
|
47
|
-
target="_blank"
|
|
48
|
-
:href="$filter('serverPath',file.id)"
|
|
49
|
-
:download="file.name"
|
|
50
|
-
>
|
|
51
|
-
{{ file.name }}
|
|
52
|
-
<q-tooltip>{{ file.name }}</q-tooltip>
|
|
53
|
-
</a>
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
<div v-else>
|
|
57
|
-
<div
|
|
58
|
-
class="uploader-btns row no-wrap items-center"
|
|
59
|
-
v-if="!dense"
|
|
60
|
-
>
|
|
61
|
-
<q-spinner
|
|
62
|
-
v-if="scope.isUploading"
|
|
63
|
-
class="q-uploader__spinner"
|
|
64
|
-
/>
|
|
65
|
-
<q-btn
|
|
66
|
-
v-if="!scope.isUploading && !Field.ReadOnly"
|
|
67
|
-
type="a"
|
|
68
|
-
icon="cloud_upload"
|
|
69
|
-
dense
|
|
70
|
-
flat
|
|
71
|
-
class="upload-btn"
|
|
72
|
-
label="点击上传"
|
|
73
|
-
>
|
|
74
|
-
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
75
|
-
</q-btn>
|
|
76
|
-
<q-btn
|
|
77
|
-
v-if="scope.isUploading && !Field.ReadOnly"
|
|
78
|
-
icon="clear"
|
|
79
|
-
@click="scope.abort"
|
|
80
|
-
class="clear-btn"
|
|
81
|
-
round
|
|
82
|
-
dense
|
|
83
|
-
flat
|
|
84
|
-
></q-btn>
|
|
85
|
-
<slot name="warning"></slot>
|
|
86
|
-
</div>
|
|
87
|
-
|
|
88
|
-
<q-item v-if="dense && scope.files.length">
|
|
89
|
-
<q-item-section v-if="scope.files.length && scope.files[0].name">
|
|
90
|
-
<q-item-label class="full-width ellipsis">
|
|
91
|
-
{{ scope.files[0].name }}
|
|
92
|
-
<q-tooltip>{{ scope.files[0].name }}</q-tooltip>
|
|
93
|
-
</q-item-label>
|
|
94
|
-
</q-item-section>
|
|
95
|
-
|
|
96
|
-
<q-item-section side>
|
|
97
|
-
<q-btn
|
|
98
|
-
v-if="!scope.isUploading && !Field.ReadOnly"
|
|
99
|
-
type="a"
|
|
100
|
-
icon="cloud_upload"
|
|
101
|
-
class="upload-btn"
|
|
102
|
-
dense
|
|
103
|
-
flat
|
|
104
|
-
>
|
|
105
|
-
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
106
|
-
</q-btn>
|
|
107
|
-
</q-item-section>
|
|
108
|
-
</q-item>
|
|
109
|
-
|
|
110
|
-
<div
|
|
111
|
-
v-else-if="scope.files.length"
|
|
112
|
-
class="file-list row items-start justify-start"
|
|
113
|
-
>
|
|
114
|
-
<q-card
|
|
115
|
-
flat
|
|
116
|
-
class="file-list-item"
|
|
117
|
-
v-for="(file, index) in scope.files"
|
|
118
|
-
:key="index"
|
|
119
|
-
>
|
|
120
|
-
<e-icon
|
|
121
|
-
class="file-image"
|
|
122
|
-
:name="fileThumb(file)"
|
|
123
|
-
thumb
|
|
124
|
-
:relative="filePreviewType(file) !== 'image'"
|
|
125
|
-
@click="preview(file)"
|
|
126
|
-
>
|
|
127
|
-
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
128
|
-
<q-btn
|
|
129
|
-
flat
|
|
130
|
-
class="view-btn full-height full-width"
|
|
131
|
-
>查看</q-btn>
|
|
132
|
-
</div>
|
|
133
|
-
</e-icon>
|
|
134
|
-
<span class="file-name full-width ellipsis">
|
|
135
|
-
<a
|
|
136
|
-
v-if="file && file.id"
|
|
137
|
-
target="_blank"
|
|
138
|
-
:href="$filter('serverPath',file.id)"
|
|
139
|
-
:download="file.name">
|
|
140
|
-
{{ file.name }}
|
|
141
|
-
</a>
|
|
142
|
-
<span v-else-if="file && file.name">
|
|
143
|
-
{{file.name}}
|
|
144
|
-
</span>
|
|
145
|
-
<q-tooltip>{{ file.name }}</q-tooltip>
|
|
146
|
-
</span>
|
|
147
|
-
|
|
148
|
-
<span class="file-size full-width ellipsis">
|
|
149
|
-
Size: {{ file.sizeLabel || file.__sizeLabel }}
|
|
150
|
-
</span>
|
|
151
|
-
|
|
152
|
-
<q-btn
|
|
153
|
-
flat
|
|
154
|
-
dense
|
|
155
|
-
round
|
|
156
|
-
class="delete-btn"
|
|
157
|
-
icon="close"
|
|
158
|
-
@click="scope.removeFile(file)"
|
|
159
|
-
v-if="!Field.ReadOnly"
|
|
160
|
-
/>
|
|
161
|
-
</q-card>
|
|
162
|
-
</div>
|
|
163
|
-
<div
|
|
164
|
-
class="input-field--error-tag"
|
|
165
|
-
v-if="hasError"
|
|
166
|
-
>
|
|
167
|
-
<e-icon name="error"></e-icon>
|
|
168
|
-
</div>
|
|
169
|
-
</div>
|
|
170
|
-
</template>
|
|
171
|
-
</q-uploader>
|
|
172
|
-
<q-dialog
|
|
173
|
-
class="image-preview-dialog"
|
|
174
|
-
flat
|
|
175
|
-
full-width
|
|
176
|
-
full-height
|
|
177
|
-
v-model="showPreview"
|
|
178
|
-
style="background: rgba(0,0,0,0)"
|
|
179
|
-
>
|
|
180
|
-
<div class="image-preview">
|
|
181
|
-
<q-img
|
|
182
|
-
v-if="previewType=== 'image'"
|
|
183
|
-
contain
|
|
184
|
-
:src="previewFile"
|
|
185
|
-
@click="showPreview=false"
|
|
186
|
-
style="height: 100%; max-width: 100%;"
|
|
187
|
-
>
|
|
188
|
-
</q-img>
|
|
189
|
-
|
|
190
|
-
<q-pdfviewer
|
|
191
|
-
v-if="previewType === 'pdf'"
|
|
192
|
-
v-model="showPreview"
|
|
193
|
-
@click="showPreview=false"
|
|
194
|
-
@error="pdfError"
|
|
195
|
-
@load="pdfLoad"
|
|
196
|
-
:src="previewFile"
|
|
197
|
-
type="pdfjs"
|
|
198
|
-
style="height: 100%; max-width: 100%;"
|
|
199
|
-
/>
|
|
200
|
-
</div>
|
|
201
|
-
</q-dialog>
|
|
202
|
-
</div>
|
|
203
|
-
</template>
|
|
204
|
-
|
|
205
|
-
<script>
|
|
206
|
-
import { defineComponent } from 'vue';
|
|
207
|
-
import mixins from 'free-fe-mixins';
|
|
208
|
-
|
|
209
|
-
export default defineComponent({
|
|
210
|
-
name: 'InputFieldFile',
|
|
211
|
-
mixins: [mixins.UploaderMixin, mixins.InputFieldMixin],
|
|
212
|
-
emits:['input'],
|
|
213
|
-
fieldInfo: {
|
|
214
|
-
Category: 'Upload',
|
|
215
|
-
Label: '文件',
|
|
216
|
-
Value: 'File',
|
|
217
|
-
Extra: [
|
|
218
|
-
{
|
|
219
|
-
Type: 'String',
|
|
220
|
-
Label: '支持的文件类型',
|
|
221
|
-
Name: 'Options.Ext',
|
|
222
|
-
Default: 'pdf,doc,docx',
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
Type: 'String',
|
|
226
|
-
Label: '最大文件大小',
|
|
227
|
-
Name: 'MaxValue',
|
|
228
|
-
Default: '10m',
|
|
229
|
-
},
|
|
230
|
-
{
|
|
231
|
-
Type: 'Boolean',
|
|
232
|
-
Label: '紧凑样式',
|
|
233
|
-
Name: 'Options.Dense',
|
|
234
|
-
Default: false,
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
Type: 'Boolean',
|
|
238
|
-
Label: '显示为链接',
|
|
239
|
-
Name: 'Options.AsLink',
|
|
240
|
-
Default: false,
|
|
241
|
-
},
|
|
242
|
-
],
|
|
243
|
-
Description: '',
|
|
244
|
-
},
|
|
245
|
-
data() {
|
|
246
|
-
return {
|
|
247
|
-
hasError: false,
|
|
248
|
-
};
|
|
249
|
-
},
|
|
250
|
-
computed: {
|
|
251
|
-
dense() {
|
|
252
|
-
return (
|
|
253
|
-
!!this.Field
|
|
254
|
-
&& (!!this.Field.dense
|
|
255
|
-
|| (!!this.Field.Options && !!this.Field.Options.Dense))
|
|
256
|
-
);
|
|
257
|
-
},
|
|
258
|
-
},
|
|
259
|
-
watch: {
|
|
260
|
-
fieldData() {
|
|
261
|
-
if (this.fieldData) {
|
|
262
|
-
try {
|
|
263
|
-
this.$refs.uploader.files = typeof this.fieldData === 'string'
|
|
264
|
-
? [JSON.parse(this.fieldData)]
|
|
265
|
-
: [this.fieldData];
|
|
266
|
-
} catch (ex) {
|
|
267
|
-
//
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
},
|
|
271
|
-
},
|
|
272
|
-
mounted() {
|
|
273
|
-
if (this.fieldData) {
|
|
274
|
-
try {
|
|
275
|
-
this.$refs.uploader.files = typeof this.fieldData === 'string'
|
|
276
|
-
? [JSON.parse(this.fieldData)]
|
|
277
|
-
: [this.fieldData];
|
|
278
|
-
} catch (ex) {
|
|
279
|
-
//
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
},
|
|
283
|
-
methods: {
|
|
284
|
-
validate() {
|
|
285
|
-
if (this.Field.Required) {
|
|
286
|
-
this.hasError = this.$refs.uploader.files.length <= 0;
|
|
287
|
-
return this.$refs.uploader.files.length > 0;
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
const rules = Array.isArray(typeof this.Field.Rules)
|
|
291
|
-
? this.Field.Rules
|
|
292
|
-
: [this.Field.Rules];
|
|
293
|
-
|
|
294
|
-
let isValid = true;
|
|
295
|
-
for (let i = 0; i < rules.length; i += 1) {
|
|
296
|
-
const r = rules[i];
|
|
297
|
-
|
|
298
|
-
if (typeof r === 'function') {
|
|
299
|
-
isValid = isValid && r(this.$refs.uploader.files);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
this.hasError = !isValid;
|
|
304
|
-
return isValid;
|
|
305
|
-
},
|
|
306
|
-
factoryFn() {
|
|
307
|
-
return {
|
|
308
|
-
url: this.Field.url || `${this.ctx.config.baseUrl}/upload`,
|
|
309
|
-
fieldName: 'file',
|
|
310
|
-
};
|
|
311
|
-
},
|
|
312
|
-
// fileAdded(files) {
|
|
313
|
-
// this.$refs.uploader.files = files;
|
|
314
|
-
// },
|
|
315
|
-
pdfLoad() {
|
|
316
|
-
//
|
|
317
|
-
},
|
|
318
|
-
pdfError() {
|
|
319
|
-
//
|
|
320
|
-
},
|
|
321
|
-
uploaded(info) {
|
|
322
|
-
if (info && info.files && info.files.length && info.files[0].xhr) {
|
|
323
|
-
const { xhr } = info.files[0];
|
|
324
|
-
let res;
|
|
325
|
-
if (xhr.response) {
|
|
326
|
-
if (typeof xhr.response === 'string') {
|
|
327
|
-
//
|
|
328
|
-
res = JSON.parse(xhr.response);
|
|
329
|
-
} else if (typeof xhr.response === 'object') {
|
|
330
|
-
//
|
|
331
|
-
res = xhr.response;
|
|
332
|
-
} else {
|
|
333
|
-
//
|
|
334
|
-
return;
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
if (res && res.msg === 'OK') {
|
|
338
|
-
// this.fieldData = JSON.stringify({
|
|
339
|
-
// id: res.data.id,
|
|
340
|
-
// // eslint-disable-next-line no-underscore-dangle
|
|
341
|
-
// sizeLabel: info.files[0].__sizeLabel,
|
|
342
|
-
// name: info.files[0].name,
|
|
343
|
-
// size: info.files[0].size,
|
|
344
|
-
// type: info.files[0].type,
|
|
345
|
-
// });
|
|
346
|
-
|
|
347
|
-
this.fieldData = {
|
|
348
|
-
id: res.data.id,
|
|
349
|
-
date: res.data.date || new Date(),
|
|
350
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
351
|
-
sizeLabel: info.files[0].__sizeLabel,
|
|
352
|
-
name: info.files[0].name,
|
|
353
|
-
size: info.files[0].size,
|
|
354
|
-
type: info.files[0].type,
|
|
355
|
-
};
|
|
356
|
-
|
|
357
|
-
this.$emit('input');
|
|
358
|
-
}
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
this.validate();
|
|
362
|
-
}
|
|
363
|
-
},
|
|
364
|
-
},
|
|
365
|
-
});
|
|
366
|
-
</script>
|
|
367
|
-
|
|
368
|
-
<style lang="sass" scoped>
|
|
369
|
-
.file-link
|
|
370
|
-
&>div
|
|
371
|
-
display: inline-block
|
|
372
|
-
white-space: nowrap
|
|
373
|
-
overflow: hidden
|
|
374
|
-
& a
|
|
375
|
-
white-space: nowrap
|
|
376
|
-
overflow: hidden
|
|
377
|
-
</style>
|
|
378
|
-
|
|
379
|
-
<style lang="sass">
|
|
380
|
-
.q-uploader__header
|
|
381
|
-
display: none
|
|
382
|
-
</style>
|