bootstrap-vue-top 1.0.7 → 1.0.9
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/.browserslistrc +12 -0
- package/README.md +4 -6
- package/package.json +17 -12
- package/postcss.config.js +6 -0
- package/src/components/accordion/accordion-item.vue +27 -0
- package/src/components/accordion/accordion-keys.js +1 -0
- package/src/components/accordion/accordion.vue +84 -0
- package/src/components/alert/alert.js +10 -0
- package/src/components/alert-box/alert-box.vue +73 -0
- package/src/components/alert-box/index.js +25 -0
- package/src/components/alert-confirm/alert-confirm.vue +80 -0
- package/src/components/alert-confirm/index.js +26 -0
- package/src/components/alert-message/alert-message.vue +63 -0
- package/src/components/alert-message/index.js +27 -0
- package/src/components/backtop/backtop.vue +61 -0
- package/src/components/carousel/carousel.vue +107 -0
- package/src/components/collapse/collapse.js +8 -0
- package/src/components/dropdown/dropdown.js +11 -0
- package/src/components/image-preview/image-preview.vue +261 -0
- package/src/components/image-preview/index.js +26 -0
- package/src/components/loading/index.js +45 -0
- package/src/components/loading/loading-fullscreen.vue +47 -0
- package/src/components/loading/loading.vue +47 -0
- package/src/components/modal/modal.vue +83 -0
- package/src/components/modal-2/counter.js +25 -0
- package/src/components/modal-2/modal-2.vue +256 -0
- package/src/components/offcanvas/offcanvas.vue +71 -0
- package/src/components/pagination/pagination.vue +216 -0
- package/src/components/popover/popover.js +10 -0
- package/src/components/scrollspy/scrollspy.js +16 -0
- package/src/components/table/table-col.vue +61 -0
- package/src/components/table/table-keys.js +2 -0
- package/src/components/table/table.vue +320 -0
- package/src/components/tabs/tab-pane.vue +32 -0
- package/src/components/tabs/tabs-keys.js +1 -0
- package/src/components/tabs/tabs.vue +240 -0
- package/src/components/toast/index.js +29 -0
- package/src/components/toast/toast.vue +91 -0
- package/src/components/tooltip/tooltip.js +10 -0
- package/src/components/tree/tree-keys.js +7 -0
- package/src/components/tree/tree-node.vue +144 -0
- package/src/components/tree/tree.vue +92 -0
- package/src/components/treetable/treetable-col.vue +37 -0
- package/src/components/treetable/treetable-keys.js +3 -0
- package/src/components/treetable/treetable-node.vue +104 -0
- package/src/components/treetable/treetable.vue +114 -0
- package/src/components/uploader/file-uploader.vue +67 -0
- package/src/components/uploader/image-many-uploader.vue +173 -0
- package/src/components/uploader/image-one-uploader.vue +78 -0
- package/src/index.js +64 -0
- package/src/styles/alert.scss +33 -0
- package/src/styles/backtop.scss +7 -0
- package/src/styles/image-preview.scss +11 -0
- package/src/styles/index.scss +97 -0
- package/src/styles/loading.scss +12 -0
- package/src/styles/modal-2.scss +8 -0
- package/src/styles/uploader.scss +29 -0
- package/vite.config.js +58 -0
- package/dist/bootstrap-vue.css +0 -2
- package/dist/bootstrap-vue.js +0 -7310
- package/dist/bootstrap-vue.umd.cjs +0 -1
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="toast-container position-fixed p-3" :class="containerClass">
|
|
3
|
+
<div ref="toastRef" class="toast" role="alert" aria-live="polite" aria-atomic="true">
|
|
4
|
+
<div class="toast-header">
|
|
5
|
+
<BiCheckCircleFill v-if="type === 'success'" class="fs-6 text-success" />
|
|
6
|
+
<BiXCircleFill v-else-if="type === 'danger'" class="fs-6 text-danger" />
|
|
7
|
+
<BiExclamationCircleFill v-else-if="type === 'warning'" class="fs-6 text-warning" />
|
|
8
|
+
<BiInfoCircleFill v-else class="fs-6 text-info" />
|
|
9
|
+
<strong class="ms-2 me-auto">{{ title }}</strong>
|
|
10
|
+
<button type="button" class="btn-close" data-bs-dismiss="toast" aria-label="Close"></button>
|
|
11
|
+
</div>
|
|
12
|
+
<div class="toast-body" v-html="message"></div>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { shallowRef, onMounted, onBeforeUnmount, computed } from 'vue';
|
|
19
|
+
import Toast from 'bootstrap/js/dist/toast';
|
|
20
|
+
|
|
21
|
+
const emit = defineEmits(['destroy']);
|
|
22
|
+
|
|
23
|
+
const toastRef = shallowRef(null);
|
|
24
|
+
const props = defineProps({
|
|
25
|
+
type: {
|
|
26
|
+
type: String,
|
|
27
|
+
default: 'info',
|
|
28
|
+
validator(value) {
|
|
29
|
+
return ['success', 'danger', 'warning', 'info'].includes(value);
|
|
30
|
+
}
|
|
31
|
+
},
|
|
32
|
+
title: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: 'Toast'
|
|
35
|
+
},
|
|
36
|
+
message: {
|
|
37
|
+
type: String,
|
|
38
|
+
default: 'Toast message'
|
|
39
|
+
},
|
|
40
|
+
duration: {
|
|
41
|
+
type: Number,
|
|
42
|
+
default: 5000
|
|
43
|
+
},
|
|
44
|
+
position: {
|
|
45
|
+
type: String,
|
|
46
|
+
default: 'top-right',
|
|
47
|
+
validator(value) {
|
|
48
|
+
return ['top-right', 'top-left', 'top-center', 'bottom-right', 'bottom-left'].includes(value);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
const containerClass = computed(() => {
|
|
54
|
+
if (props.position === 'top-right') {
|
|
55
|
+
return 'top-0 end-0';
|
|
56
|
+
} else if (props.position === 'top-left') {
|
|
57
|
+
return 'top-0 start-0';
|
|
58
|
+
} else if (props.position === 'top-center') {
|
|
59
|
+
return 'top-0 start-50 translate-middle-x';
|
|
60
|
+
} else if (props.position === 'bottom-right') {
|
|
61
|
+
return 'bottom-0 end-0';
|
|
62
|
+
} else if (props.position === 'bottom-left') {
|
|
63
|
+
return 'bottom-0 start-0';
|
|
64
|
+
} else {
|
|
65
|
+
return 'top-0 end-0';
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
|
|
69
|
+
let toast = null;
|
|
70
|
+
onMounted(() => {
|
|
71
|
+
if (toast === null) {
|
|
72
|
+
toast = new Toast(toastRef.value, {
|
|
73
|
+
autohide: props.duration === 0 ? false : true,
|
|
74
|
+
delay: props.duration
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
toastRef.value.addEventListener('hidden.bs.toast', () => {
|
|
78
|
+
emit('destroy');
|
|
79
|
+
});
|
|
80
|
+
|
|
81
|
+
toast.show();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
onBeforeUnmount(() => {
|
|
86
|
+
if (toast !== null) {
|
|
87
|
+
toast.dispose();
|
|
88
|
+
toast = null;
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
</script>
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<li>
|
|
3
|
+
<div class="node" :style="{ 'padding-left': level + 'rem' }">
|
|
4
|
+
<a
|
|
5
|
+
v-if="isFolder"
|
|
6
|
+
href="#"
|
|
7
|
+
@click.prevent="toggle"
|
|
8
|
+
class="link-body-emphasis node-switcher"
|
|
9
|
+
:class="{ 'rotate-90': isExpand }"
|
|
10
|
+
>
|
|
11
|
+
<BiCaretRight />
|
|
12
|
+
</a>
|
|
13
|
+
<div v-else class="node-placeholder"></div>
|
|
14
|
+
<div class="node-content">
|
|
15
|
+
<template v-if="mode === 'base'">
|
|
16
|
+
<a href="#" class="node-content_link focus-ring p-1" @click.prevent="handleNodeClick(data[attrs.key])">{{
|
|
17
|
+
data[attrs.label]
|
|
18
|
+
}}</a>
|
|
19
|
+
</template>
|
|
20
|
+
<template v-else-if="mode === 'checkbox'">
|
|
21
|
+
<div class="p-1">
|
|
22
|
+
<input
|
|
23
|
+
class="form-check-input"
|
|
24
|
+
type="checkbox"
|
|
25
|
+
:value="data[attrs.key]"
|
|
26
|
+
:id="boxId"
|
|
27
|
+
v-model="checkboxSelectedKeys"
|
|
28
|
+
/>
|
|
29
|
+
<label class="form-check-label px-2" :for="boxId">
|
|
30
|
+
{{ data[attrs.label] }}
|
|
31
|
+
</label>
|
|
32
|
+
</div>
|
|
33
|
+
</template>
|
|
34
|
+
<template v-else-if="mode === 'radio'">
|
|
35
|
+
<div class="p-1">
|
|
36
|
+
<input
|
|
37
|
+
class="form-check-input"
|
|
38
|
+
type="radio"
|
|
39
|
+
:value="data[attrs.key]"
|
|
40
|
+
:id="boxId"
|
|
41
|
+
v-model="radioSelectedKey"
|
|
42
|
+
/>
|
|
43
|
+
<label class="form-check-label px-2" :for="boxId">
|
|
44
|
+
{{ data[attrs.label] }}
|
|
45
|
+
</label>
|
|
46
|
+
</div>
|
|
47
|
+
</template>
|
|
48
|
+
</div>
|
|
49
|
+
</div>
|
|
50
|
+
<template v-if="isFolder">
|
|
51
|
+
<ul v-show="isExpand" class="list-unstyled">
|
|
52
|
+
<TreeNode v-for="data in data[attrs.children]" :data="data" :level="level + 1" :key="data[attrs.key]" />
|
|
53
|
+
</ul>
|
|
54
|
+
</template>
|
|
55
|
+
</li>
|
|
56
|
+
</template>
|
|
57
|
+
|
|
58
|
+
<script setup>
|
|
59
|
+
import { ref, computed, inject, useId } from 'vue';
|
|
60
|
+
import {
|
|
61
|
+
attrs_key,
|
|
62
|
+
mode_key,
|
|
63
|
+
expand_level_key,
|
|
64
|
+
radio_selected_Key,
|
|
65
|
+
checkbox_selected_keys,
|
|
66
|
+
node_click_key
|
|
67
|
+
} from './tree-keys.js';
|
|
68
|
+
|
|
69
|
+
const props = defineProps({
|
|
70
|
+
data: {
|
|
71
|
+
type: Object,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
level: {
|
|
75
|
+
type: Number,
|
|
76
|
+
default: 0
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const mode = inject(mode_key);
|
|
81
|
+
const expandLevel = inject(expand_level_key);
|
|
82
|
+
const radioSelectedKey = inject(radio_selected_Key);
|
|
83
|
+
const checkboxSelectedKeys = inject(checkbox_selected_keys);
|
|
84
|
+
const attrs = inject(attrs_key);
|
|
85
|
+
const handleNodeClick = inject(node_click_key);
|
|
86
|
+
|
|
87
|
+
const isExpand = ref(props.level < expandLevel + 1);
|
|
88
|
+
const isFolder = computed(() => {
|
|
89
|
+
return props.data[attrs.children] && props.data[attrs.children].length;
|
|
90
|
+
});
|
|
91
|
+
function toggle() {
|
|
92
|
+
isExpand.value = !isExpand.value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
let boxId = null;
|
|
96
|
+
if (mode === 'checkbox' || mode === 'radio') {
|
|
97
|
+
boxId = useId();
|
|
98
|
+
}
|
|
99
|
+
</script>
|
|
100
|
+
|
|
101
|
+
<style scoped>
|
|
102
|
+
.node {
|
|
103
|
+
display: flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
.node-switcher {
|
|
108
|
+
flex-grow: 0;
|
|
109
|
+
flex-shrink: 0;
|
|
110
|
+
transition: transform 0.3s ease;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.node-switcher.rotate-90 {
|
|
114
|
+
transform: rotate(90deg);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.node-placeholder {
|
|
118
|
+
flex-grow: 0;
|
|
119
|
+
flex-shrink: 0;
|
|
120
|
+
width: 1rem;
|
|
121
|
+
height: 1px;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.node-content {
|
|
125
|
+
flex-grow: 0;
|
|
126
|
+
flex-shrink: 0;
|
|
127
|
+
margin-left: 0.125rem;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
.node-content_link {
|
|
131
|
+
display: block;
|
|
132
|
+
color: var(--bs-body-color);
|
|
133
|
+
text-decoration: none;
|
|
134
|
+
border-radius: var(--bs-border-radius);
|
|
135
|
+
white-space: nowrap;
|
|
136
|
+
overflow: hidden;
|
|
137
|
+
text-overflow: ellipsis;
|
|
138
|
+
max-width: 15rem;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
.node-content_link:hover {
|
|
142
|
+
background-color: var(--bs-secondary-bg);
|
|
143
|
+
}
|
|
144
|
+
</style>
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<ul class="list-unstyled">
|
|
3
|
+
<TreeItem :data="data"></TreeItem>
|
|
4
|
+
</ul>
|
|
5
|
+
</template>
|
|
6
|
+
|
|
7
|
+
<script setup>
|
|
8
|
+
import { provide, ref, watch } from 'vue';
|
|
9
|
+
import TreeItem from './tree-node.vue';
|
|
10
|
+
import {
|
|
11
|
+
attrs_key,
|
|
12
|
+
mode_key,
|
|
13
|
+
expand_level_key,
|
|
14
|
+
radio_selected_Key,
|
|
15
|
+
checkbox_selected_keys,
|
|
16
|
+
node_click_key
|
|
17
|
+
} from './tree-keys.js';
|
|
18
|
+
|
|
19
|
+
const emit = defineEmits(['node-click', 'radio-change', 'checkbox-change']);
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
data: {
|
|
23
|
+
type: Object,
|
|
24
|
+
required: true
|
|
25
|
+
},
|
|
26
|
+
mode: {
|
|
27
|
+
type: String,
|
|
28
|
+
default: 'base',
|
|
29
|
+
validator(value) {
|
|
30
|
+
return ['base', 'checkbox', 'radio'].includes(value);
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
expandLevel: {
|
|
34
|
+
type: Number,
|
|
35
|
+
default: 0
|
|
36
|
+
},
|
|
37
|
+
attrKey: {
|
|
38
|
+
type: String,
|
|
39
|
+
required: true
|
|
40
|
+
},
|
|
41
|
+
attrLabel: {
|
|
42
|
+
type: String,
|
|
43
|
+
required: true
|
|
44
|
+
},
|
|
45
|
+
attrChildren: {
|
|
46
|
+
type: String,
|
|
47
|
+
required: true
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
provide(mode_key, props.mode);
|
|
52
|
+
provide(expand_level_key, props.expandLevel);
|
|
53
|
+
|
|
54
|
+
const radioSelectedKey = ref(null);
|
|
55
|
+
provide(radio_selected_Key, radioSelectedKey);
|
|
56
|
+
const checkboxSelectedKeys = ref([]);
|
|
57
|
+
|
|
58
|
+
provide(checkbox_selected_keys, checkboxSelectedKeys);
|
|
59
|
+
provide(attrs_key, {
|
|
60
|
+
key: props.attrKey,
|
|
61
|
+
label: props.attrLabel,
|
|
62
|
+
children: props.attrChildren
|
|
63
|
+
});
|
|
64
|
+
provide(node_click_key, handleNodeClick);
|
|
65
|
+
|
|
66
|
+
function handleNodeClick(key) {
|
|
67
|
+
emit('node-click', key);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
watch(radioSelectedKey, (newKey) => {
|
|
71
|
+
emit('radio-change', newKey);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
watch(checkboxSelectedKeys, (newKeys) => {
|
|
75
|
+
emit('checkbox-change', newKeys);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
defineExpose({
|
|
79
|
+
getCheckboxSelectedKeys: function () {
|
|
80
|
+
return checkboxSelectedKeys.value;
|
|
81
|
+
},
|
|
82
|
+
setCheckboxSelectedKeys: function (val) {
|
|
83
|
+
checkboxSelectedKeys.value = val;
|
|
84
|
+
},
|
|
85
|
+
getRadioSelectedKey: function () {
|
|
86
|
+
return radioSelectedKey.value;
|
|
87
|
+
},
|
|
88
|
+
setRadioSelectedKey: function (val) {
|
|
89
|
+
radioSelectedKey.value = val;
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
</script>
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
<template></template>
|
|
2
|
+
<script setup>
|
|
3
|
+
import { inject, onMounted, onBeforeUnmount, useId } from 'vue';
|
|
4
|
+
import { cols_key } from './treetable-keys.js';
|
|
5
|
+
|
|
6
|
+
const props = defineProps({
|
|
7
|
+
header: {
|
|
8
|
+
type: String,
|
|
9
|
+
default: null
|
|
10
|
+
},
|
|
11
|
+
field: {
|
|
12
|
+
type: String,
|
|
13
|
+
default: null
|
|
14
|
+
},
|
|
15
|
+
width: {
|
|
16
|
+
type: String,
|
|
17
|
+
default: 'auto'
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const cols = inject(cols_key);
|
|
22
|
+
const keyId = useId();
|
|
23
|
+
onMounted(() => {
|
|
24
|
+
const col = {
|
|
25
|
+
keyId: keyId,
|
|
26
|
+
header: props.header,
|
|
27
|
+
field: props.field,
|
|
28
|
+
width: props.width
|
|
29
|
+
};
|
|
30
|
+
cols.push(col);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
onBeforeUnmount(() => {
|
|
34
|
+
const index = cols.findIndex((item) => item.keyId === keyId);
|
|
35
|
+
cols.splice(index, 1);
|
|
36
|
+
});
|
|
37
|
+
</script>
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<tr>
|
|
3
|
+
<template v-for="(col, index) in cols">
|
|
4
|
+
<td v-if="index === 0">
|
|
5
|
+
<div class="node" :style="{ 'padding-left': level + 'rem' }">
|
|
6
|
+
<a
|
|
7
|
+
v-if="isFolder"
|
|
8
|
+
href="#"
|
|
9
|
+
role="button"
|
|
10
|
+
@click.prevent="toggle"
|
|
11
|
+
class="link-body-emphasis node-switcher"
|
|
12
|
+
:class="{ 'rotate-90': isExpand }"
|
|
13
|
+
>
|
|
14
|
+
<BiCaretRight />
|
|
15
|
+
</a>
|
|
16
|
+
<div v-else class="node-placeholder"></div>
|
|
17
|
+
<div class="node-content">
|
|
18
|
+
<template v-if="col.body === null">
|
|
19
|
+
{{ get(data, col.field) }}
|
|
20
|
+
</template>
|
|
21
|
+
<component v-else :is="col.body" :item="data" />
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
</td>
|
|
25
|
+
<td v-else>
|
|
26
|
+
<template v-if="col.body === null">
|
|
27
|
+
{{ get(data, col.field) }}
|
|
28
|
+
</template>
|
|
29
|
+
<component v-else :is="col.body" :item="data" />
|
|
30
|
+
</td>
|
|
31
|
+
</template>
|
|
32
|
+
</tr>
|
|
33
|
+
<template v-if="isExpand && isFolder">
|
|
34
|
+
<TreetableNode v-for="data in data[attrs.children]" :data="data" :level="level + 1" :key="data[attrs.key]" />
|
|
35
|
+
</template>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup>
|
|
39
|
+
import { computed, inject } from 'vue';
|
|
40
|
+
import { get } from 'lodash-es';
|
|
41
|
+
import { cols_key, attrs_key, expand_keys } from './treetable-keys.js';
|
|
42
|
+
|
|
43
|
+
const props = defineProps({
|
|
44
|
+
data: {
|
|
45
|
+
type: Object,
|
|
46
|
+
required: true
|
|
47
|
+
},
|
|
48
|
+
level: {
|
|
49
|
+
type: Number,
|
|
50
|
+
default: 0
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
const cols = inject(cols_key);
|
|
55
|
+
const attrs = inject(attrs_key);
|
|
56
|
+
const expandKeys = inject(expand_keys);
|
|
57
|
+
|
|
58
|
+
const key = props.data[attrs.key];
|
|
59
|
+
|
|
60
|
+
const isExpand = computed(() => {
|
|
61
|
+
return expandKeys.value[key] === true;
|
|
62
|
+
});
|
|
63
|
+
const isFolder = computed(() => {
|
|
64
|
+
return props.data[attrs.children] && props.data[attrs.children].length;
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
function toggle() {
|
|
68
|
+
if (expandKeys.value[key]) {
|
|
69
|
+
expandKeys.value[key] = false;
|
|
70
|
+
} else {
|
|
71
|
+
expandKeys.value[key] = true;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<style scoped>
|
|
77
|
+
.node {
|
|
78
|
+
display: flex;
|
|
79
|
+
align-items: center;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
.node-switcher {
|
|
83
|
+
flex-grow: 0;
|
|
84
|
+
flex-shrink: 0;
|
|
85
|
+
transition: transform 0.3s;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.node-switcher.rotate-90 {
|
|
89
|
+
transform: rotate(90deg);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.node-placeholder {
|
|
93
|
+
flex-grow: 0;
|
|
94
|
+
flex-shrink: 0;
|
|
95
|
+
width: 1rem;
|
|
96
|
+
height: 1px;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
.node-content {
|
|
100
|
+
flex-grow: 0;
|
|
101
|
+
flex-shrink: 0;
|
|
102
|
+
margin-left: 0.25rem;
|
|
103
|
+
}
|
|
104
|
+
</style>
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<table class="table" :class="tableClass">
|
|
3
|
+
<caption v-if="caption">
|
|
4
|
+
{{
|
|
5
|
+
caption
|
|
6
|
+
}}
|
|
7
|
+
</caption>
|
|
8
|
+
<slot></slot>
|
|
9
|
+
<template v-if="ready">
|
|
10
|
+
<colgroup>
|
|
11
|
+
<template v-for="col in cols">
|
|
12
|
+
<col :style="{ width: col.width }" />
|
|
13
|
+
</template>
|
|
14
|
+
</colgroup>
|
|
15
|
+
<thead :class="theadClass">
|
|
16
|
+
<tr>
|
|
17
|
+
<template v-for="col in cols">
|
|
18
|
+
<th scope="col">
|
|
19
|
+
{{ col.header }}
|
|
20
|
+
</th>
|
|
21
|
+
</template>
|
|
22
|
+
</tr>
|
|
23
|
+
</thead>
|
|
24
|
+
<tbody :class="tbodyClass">
|
|
25
|
+
<TreetableNode :data="data"></TreetableNode>
|
|
26
|
+
</tbody>
|
|
27
|
+
<tfoot :class="tfootClass" v-if="tfootData !== null">
|
|
28
|
+
<tr>
|
|
29
|
+
<td v-for="item in tfootData">{{ item }}</td>
|
|
30
|
+
</tr>
|
|
31
|
+
</tfoot>
|
|
32
|
+
</template>
|
|
33
|
+
</table>
|
|
34
|
+
</template>
|
|
35
|
+
|
|
36
|
+
<script setup>
|
|
37
|
+
import { useSlots, ref, provide, onMounted } from 'vue';
|
|
38
|
+
import { cols_key, attrs_key, expand_keys } from './treetable-keys.js';
|
|
39
|
+
import TreetableNode from './treetable-node.vue';
|
|
40
|
+
|
|
41
|
+
const props = defineProps({
|
|
42
|
+
data: {
|
|
43
|
+
type: Object,
|
|
44
|
+
required: true
|
|
45
|
+
},
|
|
46
|
+
tableClass: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: null
|
|
49
|
+
},
|
|
50
|
+
theadClass: {
|
|
51
|
+
type: String,
|
|
52
|
+
default: null
|
|
53
|
+
},
|
|
54
|
+
tbodyClass: {
|
|
55
|
+
type: String,
|
|
56
|
+
default: null
|
|
57
|
+
},
|
|
58
|
+
tfootClass: {
|
|
59
|
+
type: String,
|
|
60
|
+
default: null
|
|
61
|
+
},
|
|
62
|
+
tfootData: {
|
|
63
|
+
type: Array,
|
|
64
|
+
default: null
|
|
65
|
+
},
|
|
66
|
+
attrKey: {
|
|
67
|
+
type: String,
|
|
68
|
+
required: true
|
|
69
|
+
},
|
|
70
|
+
attrChildren: {
|
|
71
|
+
type: String,
|
|
72
|
+
required: true
|
|
73
|
+
},
|
|
74
|
+
caption: {
|
|
75
|
+
type: String,
|
|
76
|
+
default: null
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
const ready = ref(false);
|
|
81
|
+
|
|
82
|
+
const cols = [];
|
|
83
|
+
provide(cols_key, cols);
|
|
84
|
+
provide(attrs_key, { key: props.attrKey, children: props.attrChildren });
|
|
85
|
+
const expandKeys = ref({});
|
|
86
|
+
expandKeys.value[props.data[props.attrKey]] = true;
|
|
87
|
+
provide(expand_keys, expandKeys);
|
|
88
|
+
|
|
89
|
+
onMounted(() => {
|
|
90
|
+
_initCols();
|
|
91
|
+
|
|
92
|
+
ready.value = true;
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
function _initCols() {
|
|
96
|
+
const slots = useSlots();
|
|
97
|
+
const vNodes = slots.default();
|
|
98
|
+
|
|
99
|
+
const colVNodes = [];
|
|
100
|
+
for (const vNode of vNodes) {
|
|
101
|
+
if (vNode.type.__name === 'treetable-col') {
|
|
102
|
+
colVNodes.push(vNode);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
for (let i = 0; i < cols.length; i++) {
|
|
107
|
+
if (colVNodes[i].children !== null && colVNodes[i].children.body !== 'undefined') {
|
|
108
|
+
cols[i].body = colVNodes[i].children.body;
|
|
109
|
+
} else {
|
|
110
|
+
cols[i].body = null;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
</script>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div ref="elementRef">
|
|
3
|
+
<slot name="trigger"></slot>
|
|
4
|
+
<slot v-if="$slots.tip" name="tip"></slot>
|
|
5
|
+
<ul v-if="fileList.length > 0" class="list-unstyled mb-0">
|
|
6
|
+
<li v-for="(file, index) in fileList" class="d-flex align-items-center border-bottom py-2">
|
|
7
|
+
<span class="me-3">{{ index + 1 }}. {{ file.name }}</span>
|
|
8
|
+
<small class="text-body-secondary me-3 d-none d-sm-block">[{{ formatFileSize(file.size) }}]</small>
|
|
9
|
+
<a class="ms-auto me-3" :href="file.url" target="_blank"><bi-eye /></a>
|
|
10
|
+
<a href="#" @click.prevent="handleRemove(index)"><bi-x-lg /></a>
|
|
11
|
+
</li>
|
|
12
|
+
</ul>
|
|
13
|
+
<input ref="fileRef" type="file" :multiple="multiple" name="file" style="display: none" @change="handleChange" />
|
|
14
|
+
</div>
|
|
15
|
+
</template>
|
|
16
|
+
|
|
17
|
+
<script setup>
|
|
18
|
+
import { shallowRef, onMounted } from 'vue';
|
|
19
|
+
const emit = defineEmits(['file-change', 'file-remove']);
|
|
20
|
+
|
|
21
|
+
const props = defineProps({
|
|
22
|
+
fileList: {
|
|
23
|
+
type: Array,
|
|
24
|
+
default: []
|
|
25
|
+
},
|
|
26
|
+
multiple: {
|
|
27
|
+
type: Boolean,
|
|
28
|
+
default: false
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
const elementRef = shallowRef(null);
|
|
33
|
+
const fileRef = shallowRef(null);
|
|
34
|
+
|
|
35
|
+
onMounted(() => {
|
|
36
|
+
elementRef.value.children[0].addEventListener('click', function () {
|
|
37
|
+
fileRef.value.click();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function handleChange(event) {
|
|
42
|
+
emit('file-change', event.target);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
function handleRemove(index) {
|
|
46
|
+
emit('file-remove', index);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 格式化文件大小
|
|
51
|
+
* @param {number} bytes - 文件大小的字节数
|
|
52
|
+
* @param {number} [decimals=2] - 保留的小数位数,默认为 2
|
|
53
|
+
* @returns {string} 格式化后的文件大小
|
|
54
|
+
*/
|
|
55
|
+
function formatFileSize(bytes, decimals = 2) {
|
|
56
|
+
if (bytes === 0) return '0 Bytes';
|
|
57
|
+
|
|
58
|
+
const k = 1024;
|
|
59
|
+
const sizes = ['Bytes', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB'];
|
|
60
|
+
const i = Math.floor(Math.log(bytes) / Math.log(k));
|
|
61
|
+
|
|
62
|
+
// 保留指定小数位数
|
|
63
|
+
const size = parseFloat((bytes / Math.pow(k, i)).toFixed(decimals));
|
|
64
|
+
|
|
65
|
+
return `${size} ${sizes[i]}`;
|
|
66
|
+
}
|
|
67
|
+
</script>
|