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,372 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="input-field-fixed-list row">
|
|
3
|
+
<span
|
|
4
|
+
:class="`field-label ${(Field.Label && Field.Label.trim().length)
|
|
5
|
+
? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
|
|
6
|
+
v-if="typeof Field.Label !== 'undefined'"
|
|
7
|
+
>
|
|
8
|
+
<q-tooltip v-if="Field.Description" anchor="top right">{{Field.Description}}</q-tooltip>
|
|
9
|
+
{{Field.Label || ''}}
|
|
10
|
+
<span v-if="Field.Required" class="required-mark">*</span>
|
|
11
|
+
</span>
|
|
12
|
+
<q-table
|
|
13
|
+
class="q-ma-xs col"
|
|
14
|
+
:rows="tableData"
|
|
15
|
+
:columns="columns"
|
|
16
|
+
row-key="Name"
|
|
17
|
+
:hide-bottom="!summaryContent"
|
|
18
|
+
separator="cell"
|
|
19
|
+
:pagination="{rowsPerPage:100000}"
|
|
20
|
+
table-header-class="row-zebra-even"
|
|
21
|
+
>
|
|
22
|
+
<template v-slot:top v-if="Field.Warning">
|
|
23
|
+
<slot name="warning"></slot>
|
|
24
|
+
</template>
|
|
25
|
+
<template v-slot:body-cell="props">
|
|
26
|
+
<q-td
|
|
27
|
+
:props="props"
|
|
28
|
+
style="text-align: center;"
|
|
29
|
+
v-if="props.col.List &&
|
|
30
|
+
(props.col.List.length === 1) &&
|
|
31
|
+
props.row[props.col.List[0].Name] === 'NaN'"
|
|
32
|
+
:class="tableTdClass(props.rowIndex)"
|
|
33
|
+
>/</q-td>
|
|
34
|
+
<q-td
|
|
35
|
+
:props="props"
|
|
36
|
+
v-else-if="showCell(props)"
|
|
37
|
+
:colspan="props.value && props.value.colspan || 1"
|
|
38
|
+
:rowspan="props.value && props.value.rowspan || 1"
|
|
39
|
+
:class="`items-center justify-center ${tableTdClass(props.rowIndex)}`"
|
|
40
|
+
>
|
|
41
|
+
<span v-if="props.col.List && props.col.List.length > 1" class="full-width full-height">
|
|
42
|
+
<free-field
|
|
43
|
+
v-for="(col,index) in props.col.List"
|
|
44
|
+
:key="index"
|
|
45
|
+
:Field="columnField(col, true, props.col)"
|
|
46
|
+
:values="props.row"
|
|
47
|
+
@input="cellChanged()"
|
|
48
|
+
:ref="`input_field_validator_${
|
|
49
|
+
columnField(col, true, props.col).Name}-${index}-${props.row.auto__index}`"
|
|
50
|
+
></free-field>
|
|
51
|
+
</span>
|
|
52
|
+
<span v-else class="full-width full-height">
|
|
53
|
+
<free-field
|
|
54
|
+
:Field="columnField(props.col, false)"
|
|
55
|
+
:values="props.row"
|
|
56
|
+
@input="cellChanged()"
|
|
57
|
+
borderless
|
|
58
|
+
:ref="`input_field_validator_${
|
|
59
|
+
columnField(props.col, false).Name}-${props.row.auto__index}`"
|
|
60
|
+
></free-field>
|
|
61
|
+
</span>
|
|
62
|
+
</q-td>
|
|
63
|
+
</template>
|
|
64
|
+
|
|
65
|
+
<template v-slot:bottom>
|
|
66
|
+
<q-tr class="summary-tr">
|
|
67
|
+
<q-td colspan="100%" class="text-right summary-row">{{summaryContent}}</q-td>
|
|
68
|
+
</q-tr>
|
|
69
|
+
</template>
|
|
70
|
+
</q-table>
|
|
71
|
+
</div>
|
|
72
|
+
</template>
|
|
73
|
+
|
|
74
|
+
<script>
|
|
75
|
+
import { defineComponent } from 'vue';
|
|
76
|
+
import mixins from 'free-fe-mixins';
|
|
77
|
+
|
|
78
|
+
export default defineComponent({
|
|
79
|
+
name: 'InputFieldFixedList',
|
|
80
|
+
mixins: [mixins.InputFieldMixin],
|
|
81
|
+
emits:['input'],
|
|
82
|
+
fieldInfo: {
|
|
83
|
+
Category: 'Table',
|
|
84
|
+
Label: '固定列表',
|
|
85
|
+
Value: 'FixedList',
|
|
86
|
+
demoData: [],
|
|
87
|
+
Extra: [
|
|
88
|
+
{
|
|
89
|
+
Type: 'DynamicList',
|
|
90
|
+
Label: '列',
|
|
91
|
+
Name: 'Options.Columns',
|
|
92
|
+
Options: {
|
|
93
|
+
Columns: [
|
|
94
|
+
{
|
|
95
|
+
Label: '列标签',
|
|
96
|
+
Name: 'Label',
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
Label: '字段',
|
|
100
|
+
Name: 'List',
|
|
101
|
+
Type: 'FieldList',
|
|
102
|
+
Options: {
|
|
103
|
+
Columns: [
|
|
104
|
+
{
|
|
105
|
+
Label: '#',
|
|
106
|
+
Name: 'Index',
|
|
107
|
+
sortable: true,
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
Label: '类型',
|
|
111
|
+
Name: 'Type',
|
|
112
|
+
style: 'max-width: 120px;',
|
|
113
|
+
sortable: true,
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
Label: '名称',
|
|
117
|
+
Name: 'Name',
|
|
118
|
+
style: 'max-width: 200px;',
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
Label: '默认',
|
|
122
|
+
Name: 'Default',
|
|
123
|
+
style: 'max-width: 200px;',
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
Label: '标题',
|
|
127
|
+
Name: 'Label',
|
|
128
|
+
style: 'max-width: 200px;',
|
|
129
|
+
sortable: true,
|
|
130
|
+
},
|
|
131
|
+
],
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
{
|
|
135
|
+
Label: '样式',
|
|
136
|
+
Name: 'style',
|
|
137
|
+
Type: 'Text',
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
},
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
Type: 'DynamicList',
|
|
144
|
+
Label: '默认内容',
|
|
145
|
+
Name: 'Options.Default',
|
|
146
|
+
Options: {
|
|
147
|
+
Default: [{}],
|
|
148
|
+
},
|
|
149
|
+
},
|
|
150
|
+
{
|
|
151
|
+
Type: 'String',
|
|
152
|
+
Label: '统计信息模板',
|
|
153
|
+
Name: 'Options.Summary.Pattern',
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
Type: 'Number',
|
|
157
|
+
Label: '统计信息保留位数',
|
|
158
|
+
Name: 'Options.Summary.Digits',
|
|
159
|
+
Default: 2,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
Type: 'DynamicList',
|
|
163
|
+
Label: '统计信息字段',
|
|
164
|
+
Name: 'Options.Summary.Fields',
|
|
165
|
+
Options: {
|
|
166
|
+
Columns: [
|
|
167
|
+
{
|
|
168
|
+
Label: '字段',
|
|
169
|
+
Name: 'Field',
|
|
170
|
+
},
|
|
171
|
+
{
|
|
172
|
+
Label: '统计方式',
|
|
173
|
+
Name: 'Way',
|
|
174
|
+
Type: 'Select',
|
|
175
|
+
Options: [
|
|
176
|
+
{
|
|
177
|
+
Label: '计数',
|
|
178
|
+
Value: 'count',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
Label: '合计',
|
|
182
|
+
Value: 'sum',
|
|
183
|
+
},
|
|
184
|
+
],
|
|
185
|
+
},
|
|
186
|
+
],
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
],
|
|
190
|
+
Description: '',
|
|
191
|
+
onOptionsChanged: (editor, d, opt) => {
|
|
192
|
+
if (!editor || !d || !opt || !opt.Extra) return;
|
|
193
|
+
|
|
194
|
+
d.Options = d.Options || {};
|
|
195
|
+
const theDefault = opt.Extra.find((ex) => ex.Name === 'Options.Default');
|
|
196
|
+
if (theDefault) {
|
|
197
|
+
theDefault.Options.Columns = d.Options.Columns;
|
|
198
|
+
//editor.$set(
|
|
199
|
+
// theDefault.Options,
|
|
200
|
+
// 'Columns',
|
|
201
|
+
// d.Options.Columns,
|
|
202
|
+
//);
|
|
203
|
+
}
|
|
204
|
+
},
|
|
205
|
+
},
|
|
206
|
+
data() {
|
|
207
|
+
return {
|
|
208
|
+
tableData: [],
|
|
209
|
+
};
|
|
210
|
+
},
|
|
211
|
+
computed: {
|
|
212
|
+
tableTdClass() {
|
|
213
|
+
return (index) => (((index || 0) % 2) ? 'col-zebra-even' : 'col-zebra-odd');
|
|
214
|
+
},
|
|
215
|
+
showCell() {
|
|
216
|
+
return (p) => {
|
|
217
|
+
const colNum = Number(p.col.name);
|
|
218
|
+
|
|
219
|
+
// eslint-disable-next-line no-restricted-globals
|
|
220
|
+
if (isNaN(colNum)) return true;
|
|
221
|
+
|
|
222
|
+
if (typeof p.row.rowSize !== 'undefined') {
|
|
223
|
+
return colNum < p.row.rowSize && !!p.row[colNum];
|
|
224
|
+
}
|
|
225
|
+
return !!p.row[colNum];
|
|
226
|
+
};
|
|
227
|
+
},
|
|
228
|
+
columns() {
|
|
229
|
+
if (!this.Field || !this.Field.Options || !this.Field.Options.Columns) {
|
|
230
|
+
return [];
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
const cls = [];
|
|
234
|
+
this.Field.Options.Columns.forEach((c) => {
|
|
235
|
+
const newC = { ...c };
|
|
236
|
+
newC.name = c.Name;
|
|
237
|
+
newC.label = c.Label;
|
|
238
|
+
newC.field = c.Name;
|
|
239
|
+
newC.required = c.required;
|
|
240
|
+
newC.align = c.align || 'center';
|
|
241
|
+
newC.sortable = c.sortable;
|
|
242
|
+
newC.sort = c.sort;
|
|
243
|
+
newC.format = c.format;
|
|
244
|
+
newC.style = c.style;
|
|
245
|
+
newC.classes = c.classes;
|
|
246
|
+
newC.headerStyle = c.headerStyle;
|
|
247
|
+
newC.headerClasses = c.headerClasses;
|
|
248
|
+
|
|
249
|
+
delete newC.Name;
|
|
250
|
+
delete newC.Label;
|
|
251
|
+
|
|
252
|
+
// sort list
|
|
253
|
+
if (newC.List && newC.List.length > 1) {
|
|
254
|
+
newC.List = (newC.List || []).sort((a, b) => a.Index - b.Index);
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
cls.push(newC);
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
return cls;
|
|
261
|
+
},
|
|
262
|
+
columnField() {
|
|
263
|
+
return (col, withLabel = false, pCol) => {
|
|
264
|
+
const field = { ...(col.List ? col.List[0] : col) };
|
|
265
|
+
field.Name = field.Name || field.name || field.field;
|
|
266
|
+
|
|
267
|
+
if (withLabel) {
|
|
268
|
+
field.Name = `${(pCol && pCol.field) ? `${pCol.field}.` : ''}${field.Name}`;
|
|
269
|
+
} else {
|
|
270
|
+
delete field.Label;
|
|
271
|
+
delete field.label;
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
delete field.field;
|
|
275
|
+
|
|
276
|
+
field.ReadOnly = this.Field.ReadOnly || field.ReadOnly;
|
|
277
|
+
|
|
278
|
+
return field;
|
|
279
|
+
};
|
|
280
|
+
},
|
|
281
|
+
summaryContent() {
|
|
282
|
+
if (
|
|
283
|
+
!this.tableData
|
|
284
|
+
|| !this.Field
|
|
285
|
+
|| !this.Field.Options
|
|
286
|
+
|| !this.Field.Options.Summary
|
|
287
|
+
|| !this.Field.Options.Summary.Pattern
|
|
288
|
+
) {
|
|
289
|
+
return '';
|
|
290
|
+
}
|
|
291
|
+
let summaryText = this.Field.Options.Summary.Pattern;
|
|
292
|
+
|
|
293
|
+
for (let i = 0; i < this.Field.Options.Summary.Fields.length; i += 1) {
|
|
294
|
+
const sf = this.Field.Options.Summary.Fields[i];
|
|
295
|
+
const fdList = this.tableData.filter((fd) => !!fd[sf.Field]);
|
|
296
|
+
let vi = 0;
|
|
297
|
+
|
|
298
|
+
switch (sf.Way) {
|
|
299
|
+
case 'count':
|
|
300
|
+
vi = this.tableData.filter((fd) => !!fd[sf.Field]).length;
|
|
301
|
+
break;
|
|
302
|
+
case 'sum':
|
|
303
|
+
if (fdList) {
|
|
304
|
+
fdList.forEach((fdv) => {
|
|
305
|
+
vi += Number(fdv[sf.Field]) || 0;
|
|
306
|
+
});
|
|
307
|
+
}
|
|
308
|
+
break;
|
|
309
|
+
default:
|
|
310
|
+
break;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
// round vi
|
|
314
|
+
vi = vi.toFixed(
|
|
315
|
+
(this.Field
|
|
316
|
+
&& this.Field.Options
|
|
317
|
+
&& this.Field.Options.Summary
|
|
318
|
+
&& this.Field.Options.Summary.Digits)
|
|
319
|
+
|| 2,
|
|
320
|
+
);
|
|
321
|
+
|
|
322
|
+
summaryText = summaryText.replace(`$\{${i + 1}}`, vi);
|
|
323
|
+
}
|
|
324
|
+
return summaryText;
|
|
325
|
+
},
|
|
326
|
+
},
|
|
327
|
+
watch: {
|
|
328
|
+
fieldData() {
|
|
329
|
+
if (this.fieldData) {
|
|
330
|
+
this.tableData = this.fieldData;
|
|
331
|
+
const dd = [];
|
|
332
|
+
for (let i = 0; i < this.fieldData.length; i += 1) {
|
|
333
|
+
const fd = this.fieldData[i];
|
|
334
|
+
|
|
335
|
+
dd[i] = fd;
|
|
336
|
+
if (typeof fd.rowSize !== 'undefined') {
|
|
337
|
+
Object.keys(dd[i]).forEach((ddk) => {
|
|
338
|
+
if (Number(ddk) && Number(ddk) > fd.rowSize) {
|
|
339
|
+
delete dd[i][ddk];
|
|
340
|
+
}
|
|
341
|
+
});
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
this.tableData = dd;
|
|
346
|
+
}
|
|
347
|
+
},
|
|
348
|
+
},
|
|
349
|
+
created() {
|
|
350
|
+
if (!this.fieldData && this.Field.Options) {
|
|
351
|
+
this.tableData = this.Field.Options.Default || [];
|
|
352
|
+
}
|
|
353
|
+
},
|
|
354
|
+
methods: {
|
|
355
|
+
cellChanged() {
|
|
356
|
+
this.fieldData = this.tableData;
|
|
357
|
+
this.$emit('input');
|
|
358
|
+
},
|
|
359
|
+
},
|
|
360
|
+
});
|
|
361
|
+
</script>
|
|
362
|
+
<style lang="sass">
|
|
363
|
+
.input-field-fixed-list
|
|
364
|
+
.field-label
|
|
365
|
+
margin-top: auto
|
|
366
|
+
margin-bottom: auto
|
|
367
|
+
margin-right: 8px
|
|
368
|
+
.simple-field
|
|
369
|
+
.q-field__control
|
|
370
|
+
width: auto !important
|
|
371
|
+
// max-width: 100% !important
|
|
372
|
+
</style>
|
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="row input-field-image">
|
|
3
|
+
<span
|
|
4
|
+
:class="`field-label ${(Field.Label && Field.Label.trim().length)
|
|
5
|
+
? '' : 'field-label-empty'} ${Field.Required ? 'required' : ''}`"
|
|
6
|
+
v-if="Field.Label && !Field.dense">
|
|
7
|
+
<q-tooltip v-if="Field.Description" anchor="top right">
|
|
8
|
+
{{
|
|
9
|
+
Field.Description
|
|
10
|
+
}}
|
|
11
|
+
</q-tooltip>
|
|
12
|
+
{{ Field.Label || '' }}
|
|
13
|
+
<span v-if="Field.Required" class="required-mark">*</span>
|
|
14
|
+
</span>
|
|
15
|
+
<q-uploader
|
|
16
|
+
@uploaded="uploaded"
|
|
17
|
+
@removed="
|
|
18
|
+
fieldData = '';
|
|
19
|
+
$emit('input');
|
|
20
|
+
"
|
|
21
|
+
@added="fileAdded"
|
|
22
|
+
@rejected="filesRejected"
|
|
23
|
+
ref="uploader"
|
|
24
|
+
:factory="factoryFn"
|
|
25
|
+
auto-upload
|
|
26
|
+
:max-file-size="maxFileSize"
|
|
27
|
+
:class="(Field.dense ?
|
|
28
|
+
`no-shadow dense` : `${Field.onlyIcon ? 'only-icon' : ''}`)
|
|
29
|
+
+ (hasError ? ' input-field--error' : '')"
|
|
30
|
+
>
|
|
31
|
+
<template v-slot:list="scope">
|
|
32
|
+
<div class="uploader-btns row no-wrap items-center" v-if="!Field.dense && !onlyIcon">
|
|
33
|
+
<q-spinner v-if="scope.isUploading" class="q-uploader__spinner" />
|
|
34
|
+
<q-btn
|
|
35
|
+
v-if="!scope.isUploading"
|
|
36
|
+
type="a"
|
|
37
|
+
icon="cloud_upload"
|
|
38
|
+
dense
|
|
39
|
+
flat
|
|
40
|
+
class="upload-btn"
|
|
41
|
+
label="点击上传"
|
|
42
|
+
:disabled="Field.ReadOnly"
|
|
43
|
+
>
|
|
44
|
+
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
45
|
+
</q-btn>
|
|
46
|
+
<q-btn
|
|
47
|
+
v-if="scope.isUploading"
|
|
48
|
+
icon="clear"
|
|
49
|
+
@click="scope.abort"
|
|
50
|
+
round
|
|
51
|
+
class="clear-btn"
|
|
52
|
+
dense
|
|
53
|
+
flat
|
|
54
|
+
:disabled="Field.ReadOnly"
|
|
55
|
+
></q-btn>
|
|
56
|
+
<slot name="warning"></slot>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<q-btn
|
|
60
|
+
v-if="onlyIcon && scope.files.length <= 0"
|
|
61
|
+
type="a"
|
|
62
|
+
:icon="scope.files.length ? 'check' : 'cloud_upload'"
|
|
63
|
+
dense
|
|
64
|
+
flat
|
|
65
|
+
:disabled="Field.ReadOnly"
|
|
66
|
+
>
|
|
67
|
+
<q-uploader-add-trigger />
|
|
68
|
+
</q-btn>
|
|
69
|
+
<q-img
|
|
70
|
+
v-if="onlyIcon && scope.files.length > 0"
|
|
71
|
+
:src="runFilter('serverThumb',`${scope.files[0].id}`)"
|
|
72
|
+
style="width: 32px; max-height: 32px;"
|
|
73
|
+
>
|
|
74
|
+
<q-uploader-add-trigger/>
|
|
75
|
+
</q-img>
|
|
76
|
+
|
|
77
|
+
<q-item v-else-if="Field.dense" class="items-center q-pa-none">
|
|
78
|
+
<q-item-section v-if="scope.files.length && scope.files[0].id" thumbnail>
|
|
79
|
+
<q-img
|
|
80
|
+
:src="`${ctx.config.thumbUrlBase}${scope.files[0].id}`"
|
|
81
|
+
style="width: 48px; max-height: 48px;"
|
|
82
|
+
>
|
|
83
|
+
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
84
|
+
</q-img>
|
|
85
|
+
</q-item-section>
|
|
86
|
+
|
|
87
|
+
<q-item-section v-if="scope.files.length && scope.files[0].__img" thumbnail class="gt-xs">
|
|
88
|
+
<q-img :src="scope.files[0].__img.src">
|
|
89
|
+
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
90
|
+
</q-img>
|
|
91
|
+
</q-item-section>
|
|
92
|
+
|
|
93
|
+
<q-item-section v-if="!scope.files.length">
|
|
94
|
+
<q-btn
|
|
95
|
+
v-if="!scope.isUploading"
|
|
96
|
+
type="a"
|
|
97
|
+
icon="cloud_upload"
|
|
98
|
+
class="upload-btn"
|
|
99
|
+
dense
|
|
100
|
+
flat
|
|
101
|
+
:disabled="Field.ReadOnly"
|
|
102
|
+
>
|
|
103
|
+
<q-uploader-add-trigger v-if="!Field.ReadOnly" />
|
|
104
|
+
</q-btn>
|
|
105
|
+
</q-item-section>
|
|
106
|
+
</q-item>
|
|
107
|
+
|
|
108
|
+
<div v-else-if="scope.files.length" class="file-list row items-start justify-start">
|
|
109
|
+
<q-card
|
|
110
|
+
flat
|
|
111
|
+
class="file-list-item"
|
|
112
|
+
v-for="(file, index) in scope.files" :key="index">
|
|
113
|
+
<e-icon class="file-image" :name="fileThumb(file)" thumb
|
|
114
|
+
:relative="filePreviewType(file) !== 'image'"
|
|
115
|
+
@click="preview(file)">
|
|
116
|
+
<div class="view-btn-wrapper absolute-full justify-center text-center">
|
|
117
|
+
<q-btn
|
|
118
|
+
flat
|
|
119
|
+
class="view-btn full-height full-width"
|
|
120
|
+
@click="preview(file)"
|
|
121
|
+
>查看</q-btn>
|
|
122
|
+
</div>
|
|
123
|
+
</e-icon>
|
|
124
|
+
<span class="file-name full-width ellipsis">
|
|
125
|
+
<a
|
|
126
|
+
v-if="file && file.id"
|
|
127
|
+
target="_blank"
|
|
128
|
+
:href="runFilter('serverPath',file.id)"
|
|
129
|
+
:download="file.name">
|
|
130
|
+
{{ file.name }}
|
|
131
|
+
</a>
|
|
132
|
+
<span v-else-if="file && file.name">
|
|
133
|
+
{{file.name}}
|
|
134
|
+
</span>
|
|
135
|
+
<q-tooltip>{{ file.name }}</q-tooltip>
|
|
136
|
+
</span>
|
|
137
|
+
|
|
138
|
+
<span class="file-size full-width ellipsis">
|
|
139
|
+
Size: {{ file.sizeLabel || file.__sizeLabel }}
|
|
140
|
+
</span>
|
|
141
|
+
|
|
142
|
+
<q-btn
|
|
143
|
+
flat
|
|
144
|
+
dense
|
|
145
|
+
round
|
|
146
|
+
class="delete-btn"
|
|
147
|
+
icon="close"
|
|
148
|
+
@click="scope.removeFile(file)"
|
|
149
|
+
:disabled="Field.ReadOnly"
|
|
150
|
+
/>
|
|
151
|
+
</q-card>
|
|
152
|
+
</div>
|
|
153
|
+
|
|
154
|
+
<div class="input-field--error-tag" v-if="hasError">
|
|
155
|
+
<e-icon name="error"></e-icon>
|
|
156
|
+
</div>
|
|
157
|
+
</template>
|
|
158
|
+
</q-uploader>
|
|
159
|
+
<q-dialog class="image-preview-dialog"
|
|
160
|
+
flat
|
|
161
|
+
full-width full-height v-model="showPreview"
|
|
162
|
+
style="background: rgba(0,0,0,0)">
|
|
163
|
+
<div class="image-preview">
|
|
164
|
+
<q-img
|
|
165
|
+
v-if="previewType=== 'image'"
|
|
166
|
+
contain :src="previewFile"
|
|
167
|
+
@click="showPreview=false"
|
|
168
|
+
style="height: 100%; max-width: 100%;">
|
|
169
|
+
</q-img>
|
|
170
|
+
|
|
171
|
+
<q-pdfviewer
|
|
172
|
+
v-if="previewType === 'pdf'"
|
|
173
|
+
v-model="showPreview"
|
|
174
|
+
@click="showPreview=false"
|
|
175
|
+
:src="previewFile"
|
|
176
|
+
type="pdfjs"
|
|
177
|
+
style="height: 100%; max-width: 100%;"
|
|
178
|
+
/>
|
|
179
|
+
</div>
|
|
180
|
+
</q-dialog>
|
|
181
|
+
</div>
|
|
182
|
+
</template>
|
|
183
|
+
|
|
184
|
+
<script>
|
|
185
|
+
import { defineComponent } from 'vue';
|
|
186
|
+
import mixnins from 'free-fe-mixins';
|
|
187
|
+
|
|
188
|
+
export default defineComponent({
|
|
189
|
+
name: 'InputFieldImage',
|
|
190
|
+
mixins: [mixnins.UploaderMixin, mixnins.InputFieldMixin],
|
|
191
|
+
emits:['input'],
|
|
192
|
+
fieldInfo: {
|
|
193
|
+
Category: 'Upload',
|
|
194
|
+
Label: '图片',
|
|
195
|
+
Value: 'Image',
|
|
196
|
+
Extra: [
|
|
197
|
+
{
|
|
198
|
+
Type: 'String',
|
|
199
|
+
Label: '支持的文件类型',
|
|
200
|
+
Name: 'Options.Ext',
|
|
201
|
+
Default: 'jpg,png,bmp',
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
Type: 'String',
|
|
205
|
+
Label: '最大文件大小',
|
|
206
|
+
Name: 'MaxValue',
|
|
207
|
+
Default: '10m',
|
|
208
|
+
},
|
|
209
|
+
],
|
|
210
|
+
Description: '',
|
|
211
|
+
},
|
|
212
|
+
props: {
|
|
213
|
+
dense: { type: Boolean, default: false },
|
|
214
|
+
onlyIcon: { type: Boolean, default: false },
|
|
215
|
+
},
|
|
216
|
+
data() {
|
|
217
|
+
return {
|
|
218
|
+
hasError: false,
|
|
219
|
+
};
|
|
220
|
+
},
|
|
221
|
+
watch: {
|
|
222
|
+
fieldData() {
|
|
223
|
+
if (this.fieldData) {
|
|
224
|
+
try {
|
|
225
|
+
this.$refs.uploader.files = (typeof this.fieldData === 'string') ? [JSON.parse(this.fieldData)] : [this.fieldData];
|
|
226
|
+
} catch (ex) {
|
|
227
|
+
//
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
mounted() {
|
|
233
|
+
if (this.fieldData) {
|
|
234
|
+
try {
|
|
235
|
+
this.$refs.uploader.files = (typeof this.fieldData === 'string') ? [JSON.parse(this.fieldData)] : [this.fieldData];
|
|
236
|
+
} catch (ex) {
|
|
237
|
+
//
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
methods: {
|
|
242
|
+
validate() {
|
|
243
|
+
if (this.Field.Required) {
|
|
244
|
+
this.hasError = this.$refs.uploader.files.length <= 0;
|
|
245
|
+
return this.$refs.uploader.files.length > 0;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
const rules = Array.isArray(typeof this.Field.Rules) ? this.Field.Rules : [this.Field.Rules];
|
|
249
|
+
|
|
250
|
+
let isValid = true;
|
|
251
|
+
for (let i = 0; i < rules.length; i += 1) {
|
|
252
|
+
const r = rules[i];
|
|
253
|
+
|
|
254
|
+
if (typeof r === 'function') {
|
|
255
|
+
isValid = isValid && r(this.$refs.uploader.files);
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
this.hasError = !isValid;
|
|
260
|
+
return isValid;
|
|
261
|
+
},
|
|
262
|
+
factoryFn() {
|
|
263
|
+
return {
|
|
264
|
+
url: this.Field.url || `${this.ctx.config.baseUrl}/upload`,
|
|
265
|
+
fieldName: 'file',
|
|
266
|
+
};
|
|
267
|
+
},
|
|
268
|
+
fileAdded(files) {
|
|
269
|
+
this.$refs.uploader.files = files;
|
|
270
|
+
},
|
|
271
|
+
uploaded(info) {
|
|
272
|
+
if (info && info.files && info.files.length && info.files[0].xhr) {
|
|
273
|
+
const { xhr } = info.files[0];
|
|
274
|
+
let res;
|
|
275
|
+
if (xhr.response) {
|
|
276
|
+
if (typeof xhr.response === 'string') {
|
|
277
|
+
//
|
|
278
|
+
res = JSON.parse(xhr.response);
|
|
279
|
+
} else if (typeof xhr.response === 'object') {
|
|
280
|
+
//
|
|
281
|
+
res = xhr.response;
|
|
282
|
+
} else {
|
|
283
|
+
//
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
if (res && res.msg === 'OK') {
|
|
288
|
+
// this.fieldData = JSON.stringify({
|
|
289
|
+
// id: res.data.id,
|
|
290
|
+
// // eslint-disable-next-line no-underscore-dangle
|
|
291
|
+
// sizeLabel: info.files[0].__sizeLabel,
|
|
292
|
+
// name: info.files[0].name,
|
|
293
|
+
// size: info.files[0].size,
|
|
294
|
+
// type: info.files[0].type,
|
|
295
|
+
// });
|
|
296
|
+
this.fieldData = {
|
|
297
|
+
id: res.data.id,
|
|
298
|
+
// eslint-disable-next-line no-underscore-dangle
|
|
299
|
+
sizeLabel: info.files[0].__sizeLabel,
|
|
300
|
+
name: info.files[0].name,
|
|
301
|
+
size: info.files[0].size,
|
|
302
|
+
type: info.files[0].type,
|
|
303
|
+
};
|
|
304
|
+
|
|
305
|
+
this.$emit('input');
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
this.validate();
|
|
311
|
+
},
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
</script>
|
|
315
|
+
|
|
316
|
+
<style lang="sass">
|
|
317
|
+
.input-field-image
|
|
318
|
+
.only-icon
|
|
319
|
+
text-align: center
|
|
320
|
+
width: 32px
|
|
321
|
+
.q-btn
|
|
322
|
+
max-width: 32px
|
|
323
|
+
.q-uploader__header
|
|
324
|
+
display: none
|
|
325
|
+
.q-uploader__list
|
|
326
|
+
min-height: 32px
|
|
327
|
+
padding: 0
|
|
328
|
+
</style>
|