@ebiz/designer-components 0.0.18 → 0.0.19
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/package.json +3 -2
- package/src/apiService/mockDataService.js +116 -0
- package/src/apiService/simpleDataService.js +186 -80
- package/src/components/Button.vue +72 -22
- package/src/components/EbizAvatar.vue +116 -0
- package/src/components/EbizCheckbox.vue +94 -0
- package/src/components/EbizCheckboxGroup.vue +70 -0
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +244 -56
- package/src/components/EbizEmployeeInfo.vue +139 -0
- package/src/components/EbizFileUpload.vue +202 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizPagination.vue +163 -0
- package/src/components/EbizRadio.vue +87 -0
- package/src/components/EbizRadioGroup.vue +84 -0
- package/src/components/EbizRemoteSelect.vue +118 -40
- package/src/components/EbizSpace.vue +101 -0
- package/src/components/EbizStatistic.vue +150 -0
- package/src/components/EbizSwiper.vue +114 -0
- package/src/components/EbizSwiperItem.vue +14 -0
- package/src/components/EbizSwitch.vue +86 -0
- package/src/components/EbizTabHeader.vue +145 -0
- package/src/components/EbizTabPanel.vue +23 -0
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTabs.vue +133 -91
- package/src/components/EbizTimePicker.vue +144 -0
- package/src/components/EbizTitle.vue +3 -10
- package/src/components/EbizTree.vue +153 -0
- package/src/components/EbizTreeSelector.vue +423 -0
- package/src/components/Home.vue +8 -0
- package/src/components/TdesignAlert.vue +116 -0
- package/src/components/TdesignButton.vue +130 -0
- package/src/components/TdesignCalendar/index.vue +146 -0
- package/src/components/TdesignCard.vue +196 -0
- package/src/components/TdesignCol.vue +102 -0
- package/src/components/TdesignCollapse.vue +143 -0
- package/src/components/TdesignCollapsePanel.vue +80 -0
- package/src/components/TdesignDatePicker.vue +125 -0
- package/src/components/TdesignDialog.vue +226 -0
- package/src/components/TdesignForm.vue +134 -0
- package/src/components/TdesignFormItem.vue +106 -0
- package/src/components/TdesignGrid.vue +56 -0
- package/src/components/TdesignIcon.vue +68 -0
- package/src/components/TdesignImage.vue +163 -0
- package/src/components/TdesignImageViewer.vue +201 -0
- package/src/components/TdesignInput.vue +243 -0
- package/src/components/TdesignSelect.vue +445 -0
- package/src/components/TdesignTag.vue +118 -0
- package/src/components/TdesignTextarea.vue +143 -0
- package/src/components/TdesignTimeline.vue +58 -0
- package/src/components/TdesignTimelineItem.vue +72 -0
- package/src/components/TdesignUpload.vue +757 -0
- package/src/components/TdesignWatermark.vue +108 -0
- package/src/index.js +130 -0
- package/src/main.js +20 -4
- package/src/router/index.js +244 -5
- package/src/views/Button.vue +7 -3
- package/src/views/CheckboxDemo.vue +105 -0
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizAvatar.vue +224 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/EbizEmployeeInfo.vue +250 -0
- package/src/views/EbizRadioDemo.vue +152 -0
- package/src/views/EbizSpace.vue +186 -0
- package/src/views/EbizSwiper.vue +158 -0
- package/src/views/GridDemo.vue +239 -0
- package/src/views/Home.vue +63 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/PaginationDemo.vue +97 -0
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/StatisticDemo.vue +191 -0
- package/src/views/SwitchDemo.vue +80 -0
- package/src/views/TableDemo.vue +335 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TabsDemo.vue +283 -0
- package/src/views/TagDemo.vue +102 -0
- package/src/views/TdesignAlert.vue +99 -0
- package/src/views/TdesignButton.vue +191 -0
- package/src/views/TdesignCalendar.vue +95 -0
- package/src/views/TdesignCard.vue +297 -0
- package/src/views/TdesignCollapse.vue +294 -0
- package/src/views/TdesignDatePicker.vue +188 -0
- package/src/views/TdesignForm.vue +249 -0
- package/src/views/TdesignIcon.vue +204 -0
- package/src/views/TdesignImage.vue +216 -0
- package/src/views/TdesignImageViewer.vue +199 -0
- package/src/views/TdesignInput.vue +253 -0
- package/src/views/TdesignSelect.vue +474 -0
- package/src/views/TdesignSwiper.vue +158 -0
- package/src/views/TextareaDemo.vue +94 -0
- package/src/views/TimePickerDemo.vue +147 -0
- package/src/views/TimelineDemo.vue +161 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
- package/src/views/UploadDemo.vue +122 -0
- package/src/views/WatermarkDemo.vue +86 -0
@@ -0,0 +1,116 @@
|
|
1
|
+
<template>
|
2
|
+
<t-avatar
|
3
|
+
:alt="alt"
|
4
|
+
:badge-props="badgeProps"
|
5
|
+
:content="content"
|
6
|
+
:hide-on-load-error="hideOnLoadError"
|
7
|
+
:image="image"
|
8
|
+
:image-props="imageProps"
|
9
|
+
:shape="shape"
|
10
|
+
:size="size"
|
11
|
+
:style="customStyle"
|
12
|
+
@error="handleError"
|
13
|
+
>
|
14
|
+
<!-- 图标插槽 -->
|
15
|
+
<template v-if="$slots.icon" #icon>
|
16
|
+
<slot name="icon"></slot>
|
17
|
+
</template>
|
18
|
+
|
19
|
+
<!-- 内容插槽 -->
|
20
|
+
<template v-if="$slots.content" #content>
|
21
|
+
<slot name="content"></slot>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<!-- 默认插槽 -->
|
25
|
+
<slot>{{ content }}</slot>
|
26
|
+
</t-avatar>
|
27
|
+
</template>
|
28
|
+
|
29
|
+
<script>
|
30
|
+
export default {
|
31
|
+
name: "EbizAvatar"
|
32
|
+
}
|
33
|
+
</script>
|
34
|
+
|
35
|
+
<script setup>
|
36
|
+
import { defineProps, defineEmits, computed } from 'vue';
|
37
|
+
import { Avatar as TAvatar } from 'tdesign-vue-next';
|
38
|
+
|
39
|
+
const props = defineProps({
|
40
|
+
// 头像替代文本
|
41
|
+
alt: {
|
42
|
+
type: String,
|
43
|
+
default: ''
|
44
|
+
},
|
45
|
+
// 徽标属性
|
46
|
+
badgeProps: {
|
47
|
+
type: Object,
|
48
|
+
default: () => ({})
|
49
|
+
},
|
50
|
+
// 头像内容
|
51
|
+
content: {
|
52
|
+
type: [String, Function],
|
53
|
+
default: ''
|
54
|
+
},
|
55
|
+
// 图片加载失败时是否隐藏
|
56
|
+
hideOnLoadError: {
|
57
|
+
type: Boolean,
|
58
|
+
default: false
|
59
|
+
},
|
60
|
+
// 头像图片地址
|
61
|
+
image: {
|
62
|
+
type: String,
|
63
|
+
default: ''
|
64
|
+
},
|
65
|
+
// 图片属性
|
66
|
+
imageProps: {
|
67
|
+
type: Object,
|
68
|
+
default: () => ({})
|
69
|
+
},
|
70
|
+
// 头像形状
|
71
|
+
shape: {
|
72
|
+
type: String,
|
73
|
+
default: 'circle',
|
74
|
+
validator: (val) => ['circle', 'round'].includes(val)
|
75
|
+
},
|
76
|
+
// 头像尺寸
|
77
|
+
size: {
|
78
|
+
type: String,
|
79
|
+
default: 'medium',
|
80
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val) || /^(\d+px|\d+em|\d+rem|\d+%)$/.test(val)
|
81
|
+
},
|
82
|
+
// 自定义宽度
|
83
|
+
width: {
|
84
|
+
type: [String, Number],
|
85
|
+
default: ''
|
86
|
+
},
|
87
|
+
// 自定义高度
|
88
|
+
height: {
|
89
|
+
type: [String, Number],
|
90
|
+
default: ''
|
91
|
+
}
|
92
|
+
});
|
93
|
+
|
94
|
+
const emit = defineEmits(['error']);
|
95
|
+
|
96
|
+
// 处理图片加载错误事件
|
97
|
+
const handleError = (context) => {
|
98
|
+
emit('error', context);
|
99
|
+
};
|
100
|
+
|
101
|
+
// 计算样式
|
102
|
+
const customStyle = computed(() => {
|
103
|
+
const style = {};
|
104
|
+
if (props.width) {
|
105
|
+
style.width = typeof props.width === 'number' ? `${props.width}px` : props.width;
|
106
|
+
}
|
107
|
+
if (props.height) {
|
108
|
+
style.height = typeof props.height === 'number' ? `${props.height}px` : props.height;
|
109
|
+
}
|
110
|
+
return style;
|
111
|
+
});
|
112
|
+
</script>
|
113
|
+
|
114
|
+
<style lang="less" scoped>
|
115
|
+
/* 自定义样式 */
|
116
|
+
</style>
|
@@ -0,0 +1,94 @@
|
|
1
|
+
<template>
|
2
|
+
<t-checkbox
|
3
|
+
:checked="modelValue"
|
4
|
+
:default-checked="defaultChecked"
|
5
|
+
:disabled="disabled"
|
6
|
+
:indeterminate="indeterminate"
|
7
|
+
:label="label"
|
8
|
+
:name="name"
|
9
|
+
:readonly="readonly"
|
10
|
+
:value="value"
|
11
|
+
:check-all="checkAll"
|
12
|
+
:lazy-load="lazyLoad"
|
13
|
+
@change="handleChange"
|
14
|
+
>
|
15
|
+
<!-- 默认插槽 -->
|
16
|
+
<slot>{{ label }}</slot>
|
17
|
+
</t-checkbox>
|
18
|
+
</template>
|
19
|
+
|
20
|
+
<script>
|
21
|
+
export default {
|
22
|
+
name: "EbizCheckbox"
|
23
|
+
}
|
24
|
+
</script>
|
25
|
+
|
26
|
+
<script setup>
|
27
|
+
import { defineProps, defineEmits } from 'vue';
|
28
|
+
import { Checkbox as TCheckbox } from 'tdesign-vue-next';
|
29
|
+
|
30
|
+
const props = defineProps({
|
31
|
+
// 是否选中 (v-model)
|
32
|
+
modelValue: {
|
33
|
+
type: Boolean,
|
34
|
+
default: false
|
35
|
+
},
|
36
|
+
// 默认是否选中
|
37
|
+
defaultChecked: {
|
38
|
+
type: Boolean,
|
39
|
+
default: false
|
40
|
+
},
|
41
|
+
// 是否禁用组件
|
42
|
+
disabled: {
|
43
|
+
type: Boolean,
|
44
|
+
default: undefined
|
45
|
+
},
|
46
|
+
// 是否为半选
|
47
|
+
indeterminate: {
|
48
|
+
type: Boolean,
|
49
|
+
default: false
|
50
|
+
},
|
51
|
+
// 主文案
|
52
|
+
label: {
|
53
|
+
type: String,
|
54
|
+
default: ''
|
55
|
+
},
|
56
|
+
// HTML 元素原生属性
|
57
|
+
name: {
|
58
|
+
type: String,
|
59
|
+
default: ''
|
60
|
+
},
|
61
|
+
// 只读状态
|
62
|
+
readonly: {
|
63
|
+
type: Boolean,
|
64
|
+
default: false
|
65
|
+
},
|
66
|
+
// 单个选项的值
|
67
|
+
value: {
|
68
|
+
type: [String, Number, Boolean],
|
69
|
+
default: undefined
|
70
|
+
},
|
71
|
+
// 用于标识是否为「全选选项」
|
72
|
+
checkAll: {
|
73
|
+
type: Boolean,
|
74
|
+
default: false
|
75
|
+
},
|
76
|
+
// 是否启用懒加载
|
77
|
+
lazyLoad: {
|
78
|
+
type: Boolean,
|
79
|
+
default: false
|
80
|
+
}
|
81
|
+
});
|
82
|
+
|
83
|
+
const emit = defineEmits(['change', 'update:modelValue']);
|
84
|
+
|
85
|
+
// 选中状态变化事件
|
86
|
+
const handleChange = (checked, context) => {
|
87
|
+
emit('update:modelValue', checked);
|
88
|
+
emit('change', checked, context);
|
89
|
+
};
|
90
|
+
</script>
|
91
|
+
|
92
|
+
<style lang="less" scoped>
|
93
|
+
/* 自定义样式 */
|
94
|
+
</style>
|
@@ -0,0 +1,70 @@
|
|
1
|
+
<template>
|
2
|
+
<t-checkbox-group
|
3
|
+
:disabled="disabled"
|
4
|
+
:value="modelValue"
|
5
|
+
:default-value="defaultValue"
|
6
|
+
:options="options"
|
7
|
+
:max="max"
|
8
|
+
:name="name"
|
9
|
+
@change="handleChange"
|
10
|
+
>
|
11
|
+
<!-- 默认插槽 -->
|
12
|
+
<slot></slot>
|
13
|
+
</t-checkbox-group>
|
14
|
+
</template>
|
15
|
+
|
16
|
+
<script>
|
17
|
+
export default {
|
18
|
+
name: "EbizCheckboxGroup"
|
19
|
+
}
|
20
|
+
</script>
|
21
|
+
|
22
|
+
<script setup>
|
23
|
+
import { defineProps, defineEmits } from 'vue';
|
24
|
+
import { CheckboxGroup as TCheckboxGroup } from 'tdesign-vue-next';
|
25
|
+
|
26
|
+
const props = defineProps({
|
27
|
+
// 是否禁用组件
|
28
|
+
disabled: {
|
29
|
+
type: Boolean,
|
30
|
+
default: undefined
|
31
|
+
},
|
32
|
+
// 选中值 (v-model)
|
33
|
+
modelValue: {
|
34
|
+
type: Array,
|
35
|
+
default: () => []
|
36
|
+
},
|
37
|
+
// 默认选中值
|
38
|
+
defaultValue: {
|
39
|
+
type: Array,
|
40
|
+
default: () => []
|
41
|
+
},
|
42
|
+
// 最大可选数量
|
43
|
+
max: {
|
44
|
+
type: Number,
|
45
|
+
default: undefined
|
46
|
+
},
|
47
|
+
// HTML 元素原生属性
|
48
|
+
name: {
|
49
|
+
type: String,
|
50
|
+
default: ''
|
51
|
+
},
|
52
|
+
// 以配置形式设置子元素
|
53
|
+
options: {
|
54
|
+
type: Array,
|
55
|
+
default: () => []
|
56
|
+
}
|
57
|
+
});
|
58
|
+
|
59
|
+
const emit = defineEmits(['change', 'update:modelValue']);
|
60
|
+
|
61
|
+
// 选中值变化事件
|
62
|
+
const handleChange = (value, context) => {
|
63
|
+
emit('update:modelValue', value);
|
64
|
+
emit('change', value, context);
|
65
|
+
};
|
66
|
+
</script>
|
67
|
+
|
68
|
+
<style lang="less" scoped>
|
69
|
+
/* 自定义样式 */
|
70
|
+
</style>
|
@@ -0,0 +1,82 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-detail-block">
|
3
|
+
<t-row v-for="(item, index) in detailItems" :key="index" class="detail-item">
|
4
|
+
<t-col :span="6" class="label" :style="labelStyle">{{ item.label }}</t-col>
|
5
|
+
<t-col :span="18" class="value" :style="valueStyle">{{ item.value }}</t-col>
|
6
|
+
</t-row>
|
7
|
+
</div>
|
8
|
+
</template>
|
9
|
+
|
10
|
+
<script lang="js" setup>
|
11
|
+
import { computed, toRefs } from 'vue'
|
12
|
+
import { Row as TRow, Col as TCol } from 'tdesign-vue-next'
|
13
|
+
|
14
|
+
const props = defineProps({
|
15
|
+
model: {
|
16
|
+
type: Object,
|
17
|
+
default: () => { }
|
18
|
+
},
|
19
|
+
labelMap: {
|
20
|
+
type: Object,
|
21
|
+
default: () => { }
|
22
|
+
},
|
23
|
+
gap: {
|
24
|
+
type: [String, Number],
|
25
|
+
default: '0'
|
26
|
+
},
|
27
|
+
labelSize: {
|
28
|
+
type: [String, Number],
|
29
|
+
default: '14'
|
30
|
+
},
|
31
|
+
labelColor: {
|
32
|
+
type: String,
|
33
|
+
default: '#86909C'
|
34
|
+
},
|
35
|
+
valueSize: {
|
36
|
+
type: [String, Number],
|
37
|
+
default: '14'
|
38
|
+
},
|
39
|
+
valueColor: {
|
40
|
+
type: String,
|
41
|
+
default: '#0A0A0A'
|
42
|
+
}
|
43
|
+
})
|
44
|
+
|
45
|
+
const { model, labelMap, gap, labelSize, labelColor, valueSize, valueColor } = toRefs(props)
|
46
|
+
|
47
|
+
const labelStyle = computed(() => ({
|
48
|
+
fontSize: typeof labelSize.value === 'number' ? `${labelSize.value}px` : labelSize.value,
|
49
|
+
color: labelColor.value,
|
50
|
+
marginBottom: typeof gap.value === 'number' ? `${gap.value}px` : gap.value
|
51
|
+
}))
|
52
|
+
|
53
|
+
const valueStyle = computed(() => ({
|
54
|
+
fontSize: typeof valueSize.value === 'number' ? `${valueSize.value}px` : valueSize.value,
|
55
|
+
color: valueColor.value
|
56
|
+
}))
|
57
|
+
|
58
|
+
const detailItems = computed(() => {
|
59
|
+
return Object.entries(model.value).map(([key, value]) => ({
|
60
|
+
label: labelMap.value[key] || key,
|
61
|
+
value: value || '--'
|
62
|
+
}))
|
63
|
+
})
|
64
|
+
</script>
|
65
|
+
|
66
|
+
<style scoped>
|
67
|
+
.ebiz-detail-block {
|
68
|
+
padding: 16px;
|
69
|
+
}
|
70
|
+
|
71
|
+
.detail-item {
|
72
|
+
line-height: 32px;
|
73
|
+
}
|
74
|
+
|
75
|
+
.label {
|
76
|
+
width: 50%;
|
77
|
+
}
|
78
|
+
|
79
|
+
.value {
|
80
|
+
width: 50%;
|
81
|
+
}
|
82
|
+
</style>
|
@@ -1,61 +1,249 @@
|
|
1
|
+
<template>
|
2
|
+
<t-dialog
|
3
|
+
v-model:visible="dialogVisible"
|
4
|
+
:attach="attach"
|
5
|
+
:body-class="bodyClass"
|
6
|
+
:body-scroll-lock="bodyScrollLock"
|
7
|
+
:cancel-btn="cancelBtn"
|
8
|
+
:class-prefix="classPrefix"
|
9
|
+
:close-btn="closeBtn"
|
10
|
+
:close-on-esc-keydown="closeOnEscKeydown"
|
11
|
+
:close-on-overlay-click="closeOnOverlayClick"
|
12
|
+
:confirm-btn="confirmBtn"
|
13
|
+
:content="content"
|
14
|
+
:default-visible="defaultVisible"
|
15
|
+
:destroy-on-close="destroyOnClose"
|
16
|
+
:dialog-class="dialogClass"
|
17
|
+
:draggable="draggable"
|
18
|
+
:footer="footer"
|
19
|
+
:header="header"
|
20
|
+
:mode="mode"
|
21
|
+
:placement="placement"
|
22
|
+
:prevent-scroll-through="preventScrollThrough"
|
23
|
+
:show-overlay="showOverlay"
|
24
|
+
:top="top"
|
25
|
+
:width="width"
|
26
|
+
:zIndex="zIndex"
|
27
|
+
@cancel="handleCancel"
|
28
|
+
@close="handleClose"
|
29
|
+
@closed="handleClosed"
|
30
|
+
@confirm="handleConfirm"
|
31
|
+
@opened="handleOpened"
|
32
|
+
@overlay-click="handleOverlayClick"
|
33
|
+
@update:visible="handleUpdateVisible"
|
34
|
+
>
|
35
|
+
<!-- 默认插槽 -->
|
36
|
+
<slot></slot>
|
37
|
+
|
38
|
+
<!-- 页脚插槽 -->
|
39
|
+
<template v-if="$slots.footer" #footer>
|
40
|
+
<slot name="footer"></slot>
|
41
|
+
</template>
|
42
|
+
|
43
|
+
<!-- 头部插槽 -->
|
44
|
+
<template #header>
|
45
|
+
<slot name="header">{{ title }}</slot>
|
46
|
+
</template>
|
47
|
+
</t-dialog>
|
48
|
+
</template>
|
49
|
+
|
50
|
+
<script>
|
51
|
+
export default {
|
52
|
+
name: "EbizDialog"
|
53
|
+
}
|
54
|
+
</script>
|
55
|
+
|
1
56
|
<script setup>
|
2
|
-
import {
|
3
|
-
import {
|
57
|
+
import { ref, defineProps, defineEmits, watch } from 'vue';
|
58
|
+
import { Dialog as TDialog } from 'tdesign-vue-next';
|
59
|
+
|
60
|
+
// 定义组件接收的属性
|
4
61
|
const props = defineProps({
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
}
|
45
|
-
|
46
|
-
|
62
|
+
// 对话框挂载的节点
|
63
|
+
attach: {
|
64
|
+
type: [String, Function, Element],
|
65
|
+
default: 'body'
|
66
|
+
},
|
67
|
+
// 对话框内容的类名
|
68
|
+
bodyClass: {
|
69
|
+
type: String,
|
70
|
+
default: ''
|
71
|
+
},
|
72
|
+
// 是否锁定body滚动
|
73
|
+
bodyScrollLock: {
|
74
|
+
type: Boolean,
|
75
|
+
default: true
|
76
|
+
},
|
77
|
+
// 取消按钮配置
|
78
|
+
cancelBtn: {
|
79
|
+
type: [String, Object, Boolean],
|
80
|
+
default: null
|
81
|
+
},
|
82
|
+
// 类名前缀
|
83
|
+
classPrefix: {
|
84
|
+
type: String,
|
85
|
+
default: 't'
|
86
|
+
},
|
87
|
+
// 关闭按钮配置
|
88
|
+
closeBtn: {
|
89
|
+
type: [String, Object, Boolean],
|
90
|
+
default: true
|
91
|
+
},
|
92
|
+
// 是否支持按ESC键关闭对话框
|
93
|
+
closeOnEscKeydown: {
|
94
|
+
type: Boolean,
|
95
|
+
default: true
|
96
|
+
},
|
97
|
+
// 点击蒙层是否关闭
|
98
|
+
closeOnOverlayClick: {
|
99
|
+
type: Boolean,
|
100
|
+
default: true
|
101
|
+
},
|
102
|
+
// 确认按钮配置
|
103
|
+
confirmBtn: {
|
104
|
+
type: [String, Object, Boolean],
|
105
|
+
default: '确认'
|
106
|
+
},
|
107
|
+
// 对话框内容
|
108
|
+
content: {
|
109
|
+
type: [String, Function],
|
110
|
+
default: ''
|
111
|
+
},
|
112
|
+
// 默认是否显示对话框
|
113
|
+
defaultVisible: {
|
114
|
+
type: Boolean,
|
115
|
+
default: false
|
116
|
+
},
|
117
|
+
// 关闭时是否销毁对话框
|
118
|
+
destroyOnClose: {
|
119
|
+
type: Boolean,
|
120
|
+
default: false
|
121
|
+
},
|
122
|
+
// 对话框样式类
|
123
|
+
dialogClass: {
|
124
|
+
type: String,
|
125
|
+
default: ''
|
126
|
+
},
|
127
|
+
// 是否可拖拽
|
128
|
+
draggable: {
|
129
|
+
type: Boolean,
|
130
|
+
default: false
|
131
|
+
},
|
132
|
+
// 底部内容
|
133
|
+
footer: {
|
134
|
+
type: [Boolean, Function],
|
135
|
+
default: true
|
136
|
+
},
|
137
|
+
// 头部内容
|
138
|
+
header: {
|
139
|
+
type: [Boolean, Function],
|
140
|
+
default: true
|
141
|
+
},
|
142
|
+
// 对话框类型
|
143
|
+
mode: {
|
144
|
+
type: String,
|
145
|
+
default: 'modal',
|
146
|
+
validator: (val) => ['modal', 'modeless', 'full-screen'].includes(val)
|
147
|
+
},
|
148
|
+
// 对话框位置
|
149
|
+
placement: {
|
150
|
+
type: String,
|
151
|
+
default: 'top',
|
152
|
+
validator: (val) => ['top', 'center'].includes(val)
|
153
|
+
},
|
154
|
+
// 防止滚动穿透
|
155
|
+
preventScrollThrough: {
|
156
|
+
type: Boolean,
|
157
|
+
default: true
|
158
|
+
},
|
159
|
+
// 是否显示遮罩层
|
160
|
+
showOverlay: {
|
161
|
+
type: Boolean,
|
162
|
+
default: true
|
163
|
+
},
|
164
|
+
// 对话框标题
|
165
|
+
title: {
|
166
|
+
type: [String, Function],
|
167
|
+
default: ''
|
168
|
+
},
|
169
|
+
// 距离顶部的位置
|
170
|
+
top: {
|
171
|
+
type: [String, Number],
|
172
|
+
default: '15%'
|
173
|
+
},
|
174
|
+
// 对话框可见性
|
175
|
+
visible: {
|
176
|
+
type: Boolean,
|
177
|
+
default: undefined
|
178
|
+
},
|
179
|
+
// 对话框宽度
|
180
|
+
width: {
|
181
|
+
type: [String, Number],
|
182
|
+
default: '500px'
|
183
|
+
},
|
184
|
+
// 对话框层级
|
185
|
+
zIndex: {
|
186
|
+
type: Number,
|
187
|
+
default: 2500
|
188
|
+
}
|
189
|
+
});
|
47
190
|
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
191
|
+
// 定义组件的事件
|
192
|
+
const emit = defineEmits([
|
193
|
+
'cancel',
|
194
|
+
'close',
|
195
|
+
'closed',
|
196
|
+
'confirm',
|
197
|
+
'opened',
|
198
|
+
'overlay-click',
|
199
|
+
'update:visible'
|
200
|
+
]);
|
58
201
|
|
59
|
-
|
202
|
+
// 内部维护的可见性状态
|
203
|
+
const dialogVisible = ref(props.visible !== undefined ? props.visible : props.defaultVisible);
|
204
|
+
|
205
|
+
// 监听visible属性变化
|
206
|
+
watch(() => props.visible, (newValue) => {
|
207
|
+
dialogVisible.value = newValue;
|
208
|
+
});
|
209
|
+
|
210
|
+
// 取消按钮点击事件
|
211
|
+
const handleCancel = (e) => {
|
212
|
+
emit('cancel', e);
|
213
|
+
};
|
214
|
+
|
215
|
+
// 关闭事件
|
216
|
+
const handleClose = (e) => {
|
217
|
+
emit('close', e);
|
218
|
+
};
|
219
|
+
|
220
|
+
// 关闭动画结束后触发
|
221
|
+
const handleClosed = () => {
|
222
|
+
emit('closed');
|
223
|
+
};
|
224
|
+
|
225
|
+
// 确认按钮点击事件
|
226
|
+
const handleConfirm = (e) => {
|
227
|
+
emit('confirm', e);
|
228
|
+
};
|
229
|
+
|
230
|
+
// 对话框打开动画结束后触发
|
231
|
+
const handleOpened = () => {
|
232
|
+
emit('opened');
|
233
|
+
};
|
234
|
+
|
235
|
+
// 点击遮罩层触发
|
236
|
+
const handleOverlayClick = (context) => {
|
237
|
+
emit('overlay-click', context);
|
238
|
+
};
|
239
|
+
|
240
|
+
// 可见性变化事件
|
241
|
+
const handleUpdateVisible = (visible) => {
|
242
|
+
dialogVisible.value = visible;
|
243
|
+
emit('update:visible', visible);
|
244
|
+
};
|
245
|
+
</script>
|
60
246
|
|
61
|
-
|
247
|
+
<style lang="less" scoped>
|
248
|
+
/* 自定义样式 */
|
249
|
+
</style>
|