free-fe-core-modules 0.0.41 → 0.0.43
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.
|
@@ -19,12 +19,11 @@
|
|
|
19
19
|
</div>
|
|
20
20
|
</template>
|
|
21
21
|
</q-img>
|
|
22
|
-
<!-- <q-icon v-else :name="ctx.config.defaultIcon">he</q-icon> -->
|
|
23
22
|
</span>
|
|
24
23
|
</template>
|
|
25
24
|
|
|
26
25
|
<script>
|
|
27
|
-
import { defineComponent } from 'vue';
|
|
26
|
+
import { ref, computed, defineComponent, getCurrentInstance, watchEffect, nextTick } from 'vue';
|
|
28
27
|
|
|
29
28
|
export default defineComponent({
|
|
30
29
|
name: 'EIcon',
|
|
@@ -36,28 +35,38 @@ export default defineComponent({
|
|
|
36
35
|
hideError: { type: Boolean, default: false },
|
|
37
36
|
defaultSize: { type: String, default: '@2x' },
|
|
38
37
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return this.name && (typeof this.name === 'string') && (this.name.startsWith('img:') || this.name.indexOf('/') < 0);
|
|
42
|
-
},
|
|
43
|
-
imgPath() {
|
|
44
|
-
if (typeof this.name !== 'string' || !this.name) return '';
|
|
38
|
+
setup(props) {
|
|
39
|
+
const { proxy:vm } = getCurrentInstance();
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
const imgPath = ref('');
|
|
42
|
+
watchEffect(() => {
|
|
43
|
+
if (typeof props.name !== 'string' || !props.name) return '';
|
|
47
44
|
|
|
48
|
-
if (
|
|
45
|
+
if (props.name.startsWith('data:')) return props.name;
|
|
49
46
|
|
|
50
|
-
if (
|
|
47
|
+
if (props.name.startsWith('http://')) return props.name;
|
|
51
48
|
|
|
52
|
-
if (
|
|
49
|
+
if (props.name.startsWith('https://')) return props.name;
|
|
50
|
+
|
|
51
|
+
if (props.name.startsWith('blob:')) return props.name;
|
|
53
52
|
|
|
54
53
|
// TODO:默认使用二倍图?
|
|
55
|
-
if (
|
|
54
|
+
if (props.relative) return `images/${props.name}${props.defaultSize}.png`;
|
|
55
|
+
|
|
56
|
+
const ret = props.thumb
|
|
57
|
+
? vm.$filter('serverThumb', props.name)
|
|
58
|
+
: vm.$filter('serverImage', props.name);
|
|
59
|
+
|
|
60
|
+
// 某些情况下不能及时显示缩略图,延迟设置图片路径
|
|
61
|
+
setTimeout(() => {
|
|
62
|
+
imgPath.value = ret;
|
|
63
|
+
}, 200);
|
|
64
|
+
})
|
|
56
65
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
}
|
|
66
|
+
return {
|
|
67
|
+
isIcon: computed(() => props.name && (typeof props.name === 'string') && (props.name.startsWith('img:') || props.name.indexOf('/') < 0)),
|
|
68
|
+
imgPath,
|
|
69
|
+
};
|
|
61
70
|
},
|
|
62
71
|
});
|
|
63
72
|
</script>
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
>
|
|
63
63
|
<q-uploader-add-trigger />
|
|
64
64
|
</q-btn>
|
|
65
|
-
|
|
65
|
+
|
|
66
66
|
<div v-else-if="(Field.onlyIcon || onlyIcon) && fieldData.value && fieldData.value[0]?.id">
|
|
67
67
|
<q-img
|
|
68
68
|
:src="$filter('serverThumb', `${fieldData.value[0].id}`)"
|
|
@@ -187,9 +187,9 @@
|
|
|
187
187
|
|
|
188
188
|
<script>
|
|
189
189
|
import { defineComponent, getCurrentInstance, ref } from 'vue';
|
|
190
|
-
import { useFreeField, freeFieldProps } from '
|
|
191
|
-
import { useFormValidator} from '
|
|
192
|
-
import { useUploader } from '
|
|
190
|
+
import { useFreeField, freeFieldProps } from 'free-fe-core-modules/free-field/composible/useFreeField';
|
|
191
|
+
import { useFormValidator} from 'free-fe-core-modules/composible/useFormValidator';
|
|
192
|
+
import { useUploader } from 'free-fe-core-modules/free-field/composible/useUploader';
|
|
193
193
|
|
|
194
194
|
export default defineComponent({
|
|
195
195
|
name: 'InputFieldImage',
|
|
@@ -333,17 +333,16 @@ export default defineComponent({
|
|
|
333
333
|
factoryFn,
|
|
334
334
|
uploaded,
|
|
335
335
|
|
|
336
|
-
removeFile: () => {
|
|
336
|
+
removeFile: (files = []) => {
|
|
337
337
|
setFieldData([], emit);
|
|
338
338
|
selfValidate();
|
|
339
|
+
|
|
340
|
+
uploader.value.files = uploader.value.files.filter((f) => {
|
|
341
|
+
return files.findIndex((file) => file.name === f.name && file.size === f.size) < 0;
|
|
342
|
+
});
|
|
339
343
|
},
|
|
340
344
|
};
|
|
341
345
|
},
|
|
342
|
-
// methods: {
|
|
343
|
-
// fileAdded(files) {
|
|
344
|
-
// this.$refs.uploader.files = files;
|
|
345
|
-
// },
|
|
346
|
-
// },
|
|
347
346
|
});
|
|
348
347
|
</script>
|
|
349
348
|
|
|
@@ -340,10 +340,14 @@ export default defineComponent({
|
|
|
340
340
|
return fieldData.value?.length < props.Field?.Options?.MaxCount;
|
|
341
341
|
}),
|
|
342
342
|
dense: computed(() => props.Field?.dense || props.Field?.Options?.Dense),
|
|
343
|
-
removeFile: (files) => {
|
|
343
|
+
removeFile: (files = []) => {
|
|
344
344
|
localFiles.value = localFiles.value.filter((f) => !files.includes(f));
|
|
345
345
|
setFieldData(fieldData.value.filter((f) => !files.includes(f)), emit);
|
|
346
346
|
selfValidate();
|
|
347
|
+
|
|
348
|
+
uploader.value.files = uploader.value.files.filter((f) => {
|
|
349
|
+
return files.findIndex((file) => file.name === f.name && file.size === f.size) < 0;
|
|
350
|
+
});
|
|
347
351
|
},
|
|
348
352
|
};
|
|
349
353
|
},
|
|
@@ -124,6 +124,7 @@
|
|
|
124
124
|
v-else
|
|
125
125
|
modelValue=""
|
|
126
126
|
:type="`${Field?.Multiple ? 'textarea' : ''}`"
|
|
127
|
+
rows="1"
|
|
127
128
|
hide-bottom-space
|
|
128
129
|
readonly
|
|
129
130
|
:class="`${Field?.Multiple
|
|
@@ -226,24 +227,6 @@ export default defineComponent({
|
|
|
226
227
|
Type: 'Boolean',
|
|
227
228
|
Label: '可多选',
|
|
228
229
|
Name: 'Multiple',
|
|
229
|
-
// Extra: [
|
|
230
|
-
// {
|
|
231
|
-
// Label: '最多可选',
|
|
232
|
-
// Type: 'Number',
|
|
233
|
-
// Name: 'Options.MaxSelection',
|
|
234
|
-
// Default: 2,
|
|
235
|
-
// MinValue: 1,
|
|
236
|
-
// // Options: {
|
|
237
|
-
// // Postfix: '个',
|
|
238
|
-
// // },
|
|
239
|
-
// },
|
|
240
|
-
// {
|
|
241
|
-
// Label: '换行显示',
|
|
242
|
-
// Type: 'Boolean',
|
|
243
|
-
// Default: false,
|
|
244
|
-
// Name: 'Options.AutoWrap',
|
|
245
|
-
// },
|
|
246
|
-
// ],
|
|
247
230
|
},
|
|
248
231
|
{
|
|
249
232
|
Label: '最多可选',
|
|
@@ -333,6 +316,12 @@ export default defineComponent({
|
|
|
333
316
|
if (nV === oV || !nV) return;
|
|
334
317
|
}
|
|
335
318
|
|
|
319
|
+
if (Array.isArray(fieldData.value) && fieldData.value.length === 0) {
|
|
320
|
+
searchSelected.value = [];
|
|
321
|
+
searchDisplay.value = '';
|
|
322
|
+
return;
|
|
323
|
+
}
|
|
324
|
+
|
|
336
325
|
if (props.Field.Options && props.Field.Options.SearchUrl) {
|
|
337
326
|
const paramObj = {};
|
|
338
327
|
paramObj[props.Field.Options.SearchField || 'id'] = props.Field.Multiple
|
|
@@ -499,9 +488,9 @@ export default defineComponent({
|
|
|
499
488
|
const selected = props.Field?.Multiple
|
|
500
489
|
? searchSelected.value : [searchSelected.value[0]];
|
|
501
490
|
const sFieldName = props.Field?.SearchField || 'id';
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
491
|
+
setFieldData(selected.map(
|
|
492
|
+
(ss) => Object.nestValue(ss, sFieldName),
|
|
493
|
+
).filter((ss) => !!ss));
|
|
505
494
|
|
|
506
495
|
const sdFieldName = props.Field?.Options?.SearchDisplayField || 'id';
|
|
507
496
|
searchDisplay.value = selected.map((ss) => Object.nestValue(ss, sdFieldName))
|
|
@@ -297,6 +297,9 @@ export function useUploader(props, ctx) {
|
|
|
297
297
|
filePreview,
|
|
298
298
|
|
|
299
299
|
filesRejected (rejectedEntries) {
|
|
300
|
+
// 忽略duplicate错误
|
|
301
|
+
rejectedEntries = rejectedEntries.filter((entry) => entry.failedPropValidation !== 'duplicate');
|
|
302
|
+
|
|
300
303
|
if (rejectedEntries && rejectedEntries.length > 0) {
|
|
301
304
|
const fName = rejectedEntries[0] && rejectedEntries[0].file && rejectedEntries[0].file.name;
|
|
302
305
|
const fSize = fileSizeNumberToStr(
|