@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,106 @@
|
|
1
|
+
<template>
|
2
|
+
<t-form-item
|
3
|
+
:for="htmlFor"
|
4
|
+
:help="help"
|
5
|
+
:label="label"
|
6
|
+
:label-align="labelAlign"
|
7
|
+
:label-width="labelWidth"
|
8
|
+
:name="name"
|
9
|
+
:required-mark="requiredMark"
|
10
|
+
:rules="rules"
|
11
|
+
:show-error-message="showErrorMessage"
|
12
|
+
:status="status"
|
13
|
+
:success-border="successBorder"
|
14
|
+
:status-icon="statusIcon"
|
15
|
+
>
|
16
|
+
<template v-if="$slots.label" #label>
|
17
|
+
<slot name="label"></slot>
|
18
|
+
</template>
|
19
|
+
|
20
|
+
<template v-if="$slots.help" #help>
|
21
|
+
<slot name="help"></slot>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<slot></slot>
|
25
|
+
</t-form-item>
|
26
|
+
</template>
|
27
|
+
|
28
|
+
<script>
|
29
|
+
export default {
|
30
|
+
name: "EbizTdesignFormItem"
|
31
|
+
}
|
32
|
+
</script>
|
33
|
+
|
34
|
+
<script setup>
|
35
|
+
import { defineProps } from 'vue';
|
36
|
+
import { FormItem as TFormItem } from 'tdesign-vue-next';
|
37
|
+
|
38
|
+
defineProps({
|
39
|
+
// label原生属性
|
40
|
+
htmlFor: {
|
41
|
+
type: String,
|
42
|
+
default: ''
|
43
|
+
},
|
44
|
+
// 表单项说明内容
|
45
|
+
help: {
|
46
|
+
type: String,
|
47
|
+
default: ''
|
48
|
+
},
|
49
|
+
// 字段标签名称
|
50
|
+
label: {
|
51
|
+
type: String,
|
52
|
+
default: ''
|
53
|
+
},
|
54
|
+
// 表单字段标签对齐方式
|
55
|
+
labelAlign: {
|
56
|
+
type: String,
|
57
|
+
default: undefined,
|
58
|
+
validator: (val) => ['left', 'right', 'top'].includes(val)
|
59
|
+
},
|
60
|
+
// 标签宽度
|
61
|
+
labelWidth: {
|
62
|
+
type: [String, Number],
|
63
|
+
default: undefined
|
64
|
+
},
|
65
|
+
// 表单字段名称
|
66
|
+
name: {
|
67
|
+
type: String,
|
68
|
+
default: ''
|
69
|
+
},
|
70
|
+
// 是否显示必填符号
|
71
|
+
requiredMark: {
|
72
|
+
type: Boolean,
|
73
|
+
default: false
|
74
|
+
},
|
75
|
+
// 表单字段校验规则
|
76
|
+
rules: {
|
77
|
+
type: Array,
|
78
|
+
default: () => []
|
79
|
+
},
|
80
|
+
// 校验不通过时,是否显示错误提示信息
|
81
|
+
showErrorMessage: {
|
82
|
+
type: Boolean,
|
83
|
+
default: undefined
|
84
|
+
},
|
85
|
+
// 校验状态
|
86
|
+
status: {
|
87
|
+
type: String,
|
88
|
+
default: '',
|
89
|
+
validator: (val) => ['', 'success', 'warning', 'error', 'validating'].includes(val)
|
90
|
+
},
|
91
|
+
// 是否显示校验成功的边框
|
92
|
+
successBorder: {
|
93
|
+
type: Boolean,
|
94
|
+
default: false
|
95
|
+
},
|
96
|
+
// 是否显示校验状态图标
|
97
|
+
statusIcon: {
|
98
|
+
type: [Boolean, Function],
|
99
|
+
default: undefined
|
100
|
+
}
|
101
|
+
});
|
102
|
+
</script>
|
103
|
+
|
104
|
+
<style lang="less" scoped>
|
105
|
+
/* 自定义样式 */
|
106
|
+
</style>
|
@@ -0,0 +1,56 @@
|
|
1
|
+
<template>
|
2
|
+
<t-row
|
3
|
+
:align="align"
|
4
|
+
:justify="justify"
|
5
|
+
:gutter="gutter"
|
6
|
+
:tag="tag"
|
7
|
+
:gap="gap"
|
8
|
+
>
|
9
|
+
<slot></slot>
|
10
|
+
</t-row>
|
11
|
+
</template>
|
12
|
+
|
13
|
+
<script>
|
14
|
+
export default {
|
15
|
+
name: "EbizGrid"
|
16
|
+
}
|
17
|
+
</script>
|
18
|
+
|
19
|
+
<script setup>
|
20
|
+
import { defineProps, defineEmits } from 'vue';
|
21
|
+
import { Row as TRow } from 'tdesign-vue-next';
|
22
|
+
|
23
|
+
defineProps({
|
24
|
+
// 垂直对齐方式
|
25
|
+
align: {
|
26
|
+
type: String,
|
27
|
+
default: undefined,
|
28
|
+
validator: (val) => ['start', 'end', 'center', 'stretch', 'baseline'].includes(val)
|
29
|
+
},
|
30
|
+
// 水平排列方式
|
31
|
+
justify: {
|
32
|
+
type: String,
|
33
|
+
default: undefined,
|
34
|
+
validator: (val) => ['start', 'end', 'center', 'space-around', 'space-between'].includes(val)
|
35
|
+
},
|
36
|
+
// 栅格间隔,示例:16、[16, 16]
|
37
|
+
gutter: {
|
38
|
+
type: [Number, Array, Object],
|
39
|
+
default: 0
|
40
|
+
},
|
41
|
+
// 自定义元素标签
|
42
|
+
tag: {
|
43
|
+
type: String,
|
44
|
+
default: 'div'
|
45
|
+
},
|
46
|
+
// 间隔,示例:'0'、'xs' 或 { xs: '4px', sm: '6px', md: '12px' }
|
47
|
+
gap: {
|
48
|
+
type: [String, Number, Object, Array],
|
49
|
+
default: undefined
|
50
|
+
}
|
51
|
+
});
|
52
|
+
</script>
|
53
|
+
|
54
|
+
<style lang="less" scoped>
|
55
|
+
/* 自定义样式 */
|
56
|
+
</style>
|
@@ -0,0 +1,68 @@
|
|
1
|
+
<template>
|
2
|
+
<t-icon
|
3
|
+
:name="name"
|
4
|
+
:size="size"
|
5
|
+
:url="url"
|
6
|
+
:style="customStyle"
|
7
|
+
@click="handleClick"
|
8
|
+
/>
|
9
|
+
</template>
|
10
|
+
|
11
|
+
<script>
|
12
|
+
export default {
|
13
|
+
name: "EbizTdesignIcon"
|
14
|
+
}
|
15
|
+
</script>
|
16
|
+
|
17
|
+
<script setup>
|
18
|
+
import { defineProps, defineEmits, computed } from 'vue';
|
19
|
+
import { Icon as TIcon } from 'tdesign-vue-next';
|
20
|
+
|
21
|
+
const props = defineProps({
|
22
|
+
// 图标名称
|
23
|
+
name: {
|
24
|
+
type: String,
|
25
|
+
required: true
|
26
|
+
},
|
27
|
+
// 图标尺寸
|
28
|
+
size: {
|
29
|
+
type: String,
|
30
|
+
default: 'medium',
|
31
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val) || /^(\d+px|\d+em|\d+rem|\d+%)$/.test(val)
|
32
|
+
},
|
33
|
+
// 图标颜色
|
34
|
+
color: {
|
35
|
+
type: String,
|
36
|
+
default: ''
|
37
|
+
},
|
38
|
+
// 图标地址
|
39
|
+
url: {
|
40
|
+
type: [String, Array],
|
41
|
+
default: undefined
|
42
|
+
},
|
43
|
+
// 是否加载组件库内置图标
|
44
|
+
loadDefaultIcons: {
|
45
|
+
type: Boolean,
|
46
|
+
default: true
|
47
|
+
}
|
48
|
+
});
|
49
|
+
|
50
|
+
const emit = defineEmits(['click']);
|
51
|
+
|
52
|
+
// 处理点击事件
|
53
|
+
const handleClick = (e) => {
|
54
|
+
emit('click', { e });
|
55
|
+
};
|
56
|
+
|
57
|
+
// 计算样式
|
58
|
+
const customStyle = computed(() => {
|
59
|
+
if (props.color) {
|
60
|
+
return { color: props.color };
|
61
|
+
}
|
62
|
+
return {};
|
63
|
+
});
|
64
|
+
</script>
|
65
|
+
|
66
|
+
<style lang="less" scoped>
|
67
|
+
/* 自定义样式 */
|
68
|
+
</style>
|
@@ -0,0 +1,163 @@
|
|
1
|
+
<template>
|
2
|
+
<t-image
|
3
|
+
:alt="alt"
|
4
|
+
:error="error"
|
5
|
+
:fit="fit"
|
6
|
+
:gallery="gallery"
|
7
|
+
:lazy="lazy"
|
8
|
+
:loading="loading"
|
9
|
+
:overlay-content="overlayContent"
|
10
|
+
:overlay-trigger="overlayTrigger"
|
11
|
+
:placeholder="placeholder"
|
12
|
+
:position="position"
|
13
|
+
:referrer-policy="referrerPolicy"
|
14
|
+
:shape="shape"
|
15
|
+
:src="src"
|
16
|
+
:style="customStyle"
|
17
|
+
@error="handleError"
|
18
|
+
@load="handleLoad"
|
19
|
+
@click="handleClick"
|
20
|
+
>
|
21
|
+
<!-- 默认插槽 -->
|
22
|
+
<slot></slot>
|
23
|
+
|
24
|
+
<!-- 加载中占位内容插槽 -->
|
25
|
+
<template v-if="$slots.loading" #loading>
|
26
|
+
<slot name="loading"></slot>
|
27
|
+
</template>
|
28
|
+
|
29
|
+
<!-- 加载失败占位内容插槽 -->
|
30
|
+
<template v-if="$slots.error" #error>
|
31
|
+
<slot name="error"></slot>
|
32
|
+
</template>
|
33
|
+
|
34
|
+
<!-- 自定义悬浮内容插槽 -->
|
35
|
+
<template v-if="$slots.overlayContent" #overlay-content>
|
36
|
+
<slot name="overlayContent"></slot>
|
37
|
+
</template>
|
38
|
+
|
39
|
+
<!-- 自定义占位符插槽 -->
|
40
|
+
<template v-if="$slots.placeholder" #placeholder>
|
41
|
+
<slot name="placeholder"></slot>
|
42
|
+
</template>
|
43
|
+
</t-image>
|
44
|
+
</template>
|
45
|
+
|
46
|
+
<script setup>
|
47
|
+
import { defineProps, defineEmits, computed } from 'vue';
|
48
|
+
import { Image as TImage } from 'tdesign-vue-next';
|
49
|
+
|
50
|
+
const props = defineProps({
|
51
|
+
// 图片描述
|
52
|
+
alt: {
|
53
|
+
type: String,
|
54
|
+
default: ''
|
55
|
+
},
|
56
|
+
// 图片加载失败时显示的内容,默认为空
|
57
|
+
error: {
|
58
|
+
type: [String, Function],
|
59
|
+
default: ''
|
60
|
+
},
|
61
|
+
// 图片填充模式
|
62
|
+
fit: {
|
63
|
+
type: String,
|
64
|
+
default: 'fill',
|
65
|
+
validator: (val) => ['contain', 'cover', 'fill', 'none', 'scale-down'].includes(val)
|
66
|
+
},
|
67
|
+
// 是否展示为图集模式
|
68
|
+
gallery: {
|
69
|
+
type: Boolean,
|
70
|
+
default: false
|
71
|
+
},
|
72
|
+
// 是否开启图片懒加载
|
73
|
+
lazy: {
|
74
|
+
type: Boolean,
|
75
|
+
default: false
|
76
|
+
},
|
77
|
+
// 图片加载中时显示的内容,默认为空
|
78
|
+
loading: {
|
79
|
+
type: [String, Function],
|
80
|
+
default: ''
|
81
|
+
},
|
82
|
+
// 自定义图片的宽度
|
83
|
+
width: {
|
84
|
+
type: [String, Number],
|
85
|
+
default: ''
|
86
|
+
},
|
87
|
+
// 自定义图片的高度
|
88
|
+
height: {
|
89
|
+
type: [String, Number],
|
90
|
+
default: ''
|
91
|
+
},
|
92
|
+
// 悬浮显示的内容
|
93
|
+
overlayContent: {
|
94
|
+
type: [String, Function],
|
95
|
+
default: ''
|
96
|
+
},
|
97
|
+
// 悬浮内容出现的时机
|
98
|
+
overlayTrigger: {
|
99
|
+
type: String,
|
100
|
+
default: 'hover',
|
101
|
+
validator: (val) => ['hover', 'always'].includes(val)
|
102
|
+
},
|
103
|
+
// 占位符
|
104
|
+
placeholder: {
|
105
|
+
type: [String, Function],
|
106
|
+
default: ''
|
107
|
+
},
|
108
|
+
// 等同于原生的 object-position
|
109
|
+
position: {
|
110
|
+
type: String,
|
111
|
+
default: 'center'
|
112
|
+
},
|
113
|
+
// 等同于原生的 referrerPolicy
|
114
|
+
referrerPolicy: {
|
115
|
+
type: String,
|
116
|
+
default: ''
|
117
|
+
},
|
118
|
+
// 图片圆角类型
|
119
|
+
shape: {
|
120
|
+
type: String,
|
121
|
+
default: 'square',
|
122
|
+
validator: (val) => ['circle', 'round', 'square'].includes(val)
|
123
|
+
},
|
124
|
+
// 图片链接
|
125
|
+
src: {
|
126
|
+
type: String,
|
127
|
+
default: ''
|
128
|
+
}
|
129
|
+
});
|
130
|
+
|
131
|
+
const emit = defineEmits(['error', 'load', 'click']);
|
132
|
+
|
133
|
+
// 处理加载失败事件
|
134
|
+
const handleError = (context) => {
|
135
|
+
emit('error', context);
|
136
|
+
};
|
137
|
+
|
138
|
+
// 处理加载成功事件
|
139
|
+
const handleLoad = (context) => {
|
140
|
+
emit('load', context);
|
141
|
+
};
|
142
|
+
|
143
|
+
// 处理点击事件
|
144
|
+
const handleClick = (context) => {
|
145
|
+
emit('click', context);
|
146
|
+
};
|
147
|
+
|
148
|
+
// 计算样式
|
149
|
+
const customStyle = computed(() => {
|
150
|
+
const style = {};
|
151
|
+
if (props.width) {
|
152
|
+
style.width = typeof props.width === 'number' ? `${props.width}px` : props.width;
|
153
|
+
}
|
154
|
+
if (props.height) {
|
155
|
+
style.height = typeof props.height === 'number' ? `${props.height}px` : props.height;
|
156
|
+
}
|
157
|
+
return style;
|
158
|
+
});
|
159
|
+
</script>
|
160
|
+
|
161
|
+
<style lang="less" scoped>
|
162
|
+
/* 自定义样式 */
|
163
|
+
</style>
|
@@ -0,0 +1,201 @@
|
|
1
|
+
<template>
|
2
|
+
<div>
|
3
|
+
<!-- 触发器 -->
|
4
|
+
<div @click="toggleShow" class="image-viewer-trigger">
|
5
|
+
<slot>
|
6
|
+
<t-button v-if="!triggerElement" theme="primary">
|
7
|
+
{{ triggerText }}
|
8
|
+
</t-button>
|
9
|
+
</slot>
|
10
|
+
</div>
|
11
|
+
|
12
|
+
<!-- 图片查看器 -->
|
13
|
+
<t-image-viewer
|
14
|
+
v-model:visible="visible"
|
15
|
+
:closeBtn="closeBtn"
|
16
|
+
:closeOnEscKeydown="closeOnEscKeydown"
|
17
|
+
:closeOnOverlay="closeOnOverlay"
|
18
|
+
:draggable="draggable"
|
19
|
+
:imageReferrerpolicy="imageReferrerpolicy"
|
20
|
+
:imageScale="imageScale"
|
21
|
+
:images="images"
|
22
|
+
:index="currentIndex"
|
23
|
+
:mode="mode"
|
24
|
+
:showOverlay="showOverlay"
|
25
|
+
:title="title"
|
26
|
+
:viewerScale="viewerScale"
|
27
|
+
:zIndex="zIndex"
|
28
|
+
@change="handleChange"
|
29
|
+
@close="handleClose"
|
30
|
+
@scale="handleScale"
|
31
|
+
>
|
32
|
+
<!-- 控制按钮插槽 -->
|
33
|
+
<template v-if="$slots.control" #control>
|
34
|
+
<slot name="control"></slot>
|
35
|
+
</template>
|
36
|
+
|
37
|
+
<!-- 额外操作按钮插槽 -->
|
38
|
+
<template v-if="$slots.operation" #operation>
|
39
|
+
<slot name="operation"></slot>
|
40
|
+
</template>
|
41
|
+
|
42
|
+
<!-- 缩略图底部插槽 -->
|
43
|
+
<template v-if="$slots.thumbnailsBottom" #thumbnails-bottom>
|
44
|
+
<slot name="thumbnailsBottom"></slot>
|
45
|
+
</template>
|
46
|
+
|
47
|
+
<!-- 标题插槽 -->
|
48
|
+
<template v-if="$slots.title" #title>
|
49
|
+
<slot name="title"></slot>
|
50
|
+
</template>
|
51
|
+
</t-image-viewer>
|
52
|
+
</div>
|
53
|
+
</template>
|
54
|
+
|
55
|
+
<script setup>
|
56
|
+
import { defineProps, defineEmits, ref, watch } from 'vue';
|
57
|
+
import { ImageViewer as TImageViewer, Button as TButton } from 'tdesign-vue-next';
|
58
|
+
|
59
|
+
const props = defineProps({
|
60
|
+
// 是否显示关闭按钮
|
61
|
+
closeBtn: {
|
62
|
+
type: Boolean,
|
63
|
+
default: true
|
64
|
+
},
|
65
|
+
// 按下 ESC 时是否触发图片预览器关闭
|
66
|
+
closeOnEscKeydown: {
|
67
|
+
type: Boolean,
|
68
|
+
default: true
|
69
|
+
},
|
70
|
+
// 点击遮罩层时是否触发关闭
|
71
|
+
closeOnOverlay: {
|
72
|
+
type: Boolean,
|
73
|
+
default: true
|
74
|
+
},
|
75
|
+
// 缩略图默认显示下标
|
76
|
+
defaultIndex: {
|
77
|
+
type: Number,
|
78
|
+
default: 0
|
79
|
+
},
|
80
|
+
// 是否允许拖拽调整位置
|
81
|
+
draggable: {
|
82
|
+
type: Boolean,
|
83
|
+
default: true
|
84
|
+
},
|
85
|
+
// 图片预览中的图片引用策略
|
86
|
+
imageReferrerpolicy: {
|
87
|
+
type: String,
|
88
|
+
default: 'never'
|
89
|
+
},
|
90
|
+
// 图片缩放相关配置
|
91
|
+
imageScale: {
|
92
|
+
type: Object,
|
93
|
+
default: () => ({
|
94
|
+
max: 3,
|
95
|
+
min: 0.1,
|
96
|
+
step: 0.1
|
97
|
+
})
|
98
|
+
},
|
99
|
+
// 图片数组
|
100
|
+
images: {
|
101
|
+
type: Array,
|
102
|
+
default: () => []
|
103
|
+
},
|
104
|
+
// 特殊的模式,包括常规模式和简洁模式
|
105
|
+
mode: {
|
106
|
+
type: String,
|
107
|
+
default: 'normal',
|
108
|
+
validator: (val) => ['normal', 'simple'].includes(val)
|
109
|
+
},
|
110
|
+
// 是否显示遮罩层
|
111
|
+
showOverlay: {
|
112
|
+
type: Boolean,
|
113
|
+
default: true
|
114
|
+
},
|
115
|
+
// 自定义触发元素
|
116
|
+
triggerElement: {
|
117
|
+
type: [String, Function],
|
118
|
+
default: ''
|
119
|
+
},
|
120
|
+
// 触发按钮文本
|
121
|
+
triggerText: {
|
122
|
+
type: String,
|
123
|
+
default: '查看图片'
|
124
|
+
},
|
125
|
+
// 标题
|
126
|
+
title: {
|
127
|
+
type: [String, Function],
|
128
|
+
default: ''
|
129
|
+
},
|
130
|
+
// 是否显示(非受控)
|
131
|
+
defaultVisible: {
|
132
|
+
type: Boolean,
|
133
|
+
default: false
|
134
|
+
},
|
135
|
+
// 是否显示(受控)
|
136
|
+
visible: {
|
137
|
+
type: Boolean,
|
138
|
+
default: undefined
|
139
|
+
},
|
140
|
+
// 查看器缩放相关配置
|
141
|
+
viewerScale: {
|
142
|
+
type: Object,
|
143
|
+
default: () => ({
|
144
|
+
max: 10,
|
145
|
+
min: 0.1,
|
146
|
+
step: 0.1
|
147
|
+
})
|
148
|
+
},
|
149
|
+
// 层级
|
150
|
+
zIndex: {
|
151
|
+
type: Number,
|
152
|
+
default: 2000
|
153
|
+
}
|
154
|
+
});
|
155
|
+
|
156
|
+
const emit = defineEmits(['change', 'close', 'scale', 'update:visible']);
|
157
|
+
|
158
|
+
// 内部可见状态
|
159
|
+
const visible = ref(props.defaultVisible);
|
160
|
+
|
161
|
+
// 同步外部visible和内部visible
|
162
|
+
watch(() => props.visible, (newValue) => {
|
163
|
+
if (newValue !== undefined) {
|
164
|
+
visible.value = newValue;
|
165
|
+
}
|
166
|
+
});
|
167
|
+
|
168
|
+
// 当前索引
|
169
|
+
const currentIndex = ref(props.defaultIndex);
|
170
|
+
|
171
|
+
// 切换显示状态
|
172
|
+
const toggleShow = () => {
|
173
|
+
visible.value = !visible.value;
|
174
|
+
emit('update:visible', visible.value);
|
175
|
+
};
|
176
|
+
|
177
|
+
// 处理图片切换事件
|
178
|
+
const handleChange = (index, context) => {
|
179
|
+
currentIndex.value = index;
|
180
|
+
emit('change', index, context);
|
181
|
+
};
|
182
|
+
|
183
|
+
// 处理关闭事件
|
184
|
+
const handleClose = (context) => {
|
185
|
+
visible.value = false;
|
186
|
+
emit('update:visible', false);
|
187
|
+
emit('close', context);
|
188
|
+
};
|
189
|
+
|
190
|
+
// 处理缩放事件
|
191
|
+
const handleScale = (scale, context) => {
|
192
|
+
emit('scale', scale, context);
|
193
|
+
};
|
194
|
+
</script>
|
195
|
+
|
196
|
+
<style lang="less" scoped>
|
197
|
+
.image-viewer-trigger {
|
198
|
+
display: inline-block;
|
199
|
+
cursor: pointer;
|
200
|
+
}
|
201
|
+
</style>
|