@ebiz/designer-components 0.0.18-beta.4 → 0.0.18-beta.41
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 +1 -1
- package/src/apiService/mockDataService.js +116 -0
- package/src/apiService/simpleDataService.js +7 -5
- package/src/components/Button.vue +72 -24
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizPageHeader.vue +96 -0
- package/src/components/EbizRemoteSelect.vue +106 -41
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTree.vue +147 -0
- package/src/components/EbizTreeSelector.vue +513 -0
- package/src/components/TdesignCalendar/index.vue +6 -3
- package/src/components/TdesignDialog.vue +226 -0
- package/src/components/TdesignInput.vue +23 -23
- package/src/components/TdesignUpload.vue +68 -100
- package/src/index.js +23 -1
- package/src/main.js +2 -2
- package/src/router/index.js +64 -5
- package/src/views/Button.vue +7 -3
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/Home.vue +33 -2
- package/src/views/PageHeaderDemo.vue +105 -0
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/TableDemo.vue +335 -0
- package/src/views/TableSortDemo.vue +144 -0
- package/src/views/TableView.vue +69 -0
- package/src/views/TreeDemo.vue +255 -0
- package/src/views/TreeSelectorDemo.vue +246 -0
package/package.json
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
/**
|
2
|
+
* 模拟数据服务
|
3
|
+
* 用于组件演示,提供模拟的远程数据查询
|
4
|
+
*/
|
5
|
+
|
6
|
+
// 模拟用户数据
|
7
|
+
const mockUsers = [
|
8
|
+
{ id: '1', name: '张三', email: 'zhangsan@example.com', department: '研发部' },
|
9
|
+
{ id: '2', name: '李四', email: 'lisi@example.com', department: '市场部' },
|
10
|
+
{ id: '3', name: '王五', email: 'wangwu@example.com', department: '设计部' },
|
11
|
+
{ id: '4', name: '赵六', email: 'zhaoliu@example.com', department: '人力资源部' },
|
12
|
+
{ id: '5', name: '钱七', email: 'qianqi@example.com', department: '财务部' },
|
13
|
+
{ id: '6', name: '孙八', email: 'sunba@example.com', department: '行政部' },
|
14
|
+
{ id: '7', name: '周九', email: 'zhoujiu@example.com', department: '销售部' },
|
15
|
+
{ id: '8', name: '吴十', email: 'wushi@example.com', department: '客服部' },
|
16
|
+
{ id: '9', name: '郑十一', email: 'zhengshiyi@example.com', department: '研发部' },
|
17
|
+
{ id: '10', name: '王十二', email: 'wangshier@example.com', department: '市场部' },
|
18
|
+
{ id: '11', name: '刘十三', email: 'liushisan@example.com', department: '设计部' },
|
19
|
+
{ id: '12', name: '陈十四', email: 'chenshisi@example.com', department: '人力资源部' },
|
20
|
+
{ id: '13', name: '杨十五', email: 'yangshiwu@example.com', department: '财务部' },
|
21
|
+
{ id: '14', name: '黄十六', email: 'huangshiliu@example.com', department: '行政部' },
|
22
|
+
{ id: '15', name: '赵十七', email: 'zhaoshiqi@example.com', department: '销售部' }
|
23
|
+
];
|
24
|
+
|
25
|
+
// 模拟产品数据
|
26
|
+
const mockProducts = [
|
27
|
+
{ id: 'p1', name: '笔记本电脑', price: 5999, category: '电子产品' },
|
28
|
+
{ id: 'p2', name: '智能手机', price: 3999, category: '电子产品' },
|
29
|
+
{ id: 'p3', name: '平板电脑', price: 2999, category: '电子产品' },
|
30
|
+
{ id: 'p4', name: '智能手表', price: 1999, category: '电子产品' },
|
31
|
+
{ id: 'p5', name: '耳机', price: 799, category: '电子产品' },
|
32
|
+
{ id: 'p6', name: '办公桌', price: 1299, category: '办公家具' },
|
33
|
+
{ id: 'p7', name: '办公椅', price: 899, category: '办公家具' },
|
34
|
+
{ id: 'p8', name: '文件柜', price: 1099, category: '办公家具' },
|
35
|
+
{ id: 'p9', name: '书架', price: 799, category: '办公家具' },
|
36
|
+
{ id: 'p10', name: '打印机', price: 1599, category: '办公设备' }
|
37
|
+
];
|
38
|
+
|
39
|
+
// 模拟城市数据
|
40
|
+
const mockCities = [
|
41
|
+
{ id: 'c1', name: '北京', code: 'BJ', population: 21893095 },
|
42
|
+
{ id: 'c2', name: '上海', code: 'SH', population: 24870895 },
|
43
|
+
{ id: 'c3', name: '广州', code: 'GZ', population: 18676605 },
|
44
|
+
{ id: 'c4', name: '深圳', code: 'SZ', population: 17494398 },
|
45
|
+
{ id: 'c5', name: '成都', code: 'CD', population: 16580376 },
|
46
|
+
{ id: 'c6', name: '杭州', code: 'HZ', population: 10360391 },
|
47
|
+
{ id: 'c7', name: '武汉', code: 'WH', population: 12326500 },
|
48
|
+
{ id: 'c8', name: '西安', code: 'XA', population: 12952907 },
|
49
|
+
{ id: 'c9', name: '重庆', code: 'CQ', population: 31243200 },
|
50
|
+
{ id: 'c10', name: '南京', code: 'NJ', population: 8335000 }
|
51
|
+
];
|
52
|
+
|
53
|
+
// 数据映射
|
54
|
+
const dataMap = {
|
55
|
+
mockUserList: mockUsers.map(user => ({
|
56
|
+
id: user.id,
|
57
|
+
name: user.name,
|
58
|
+
label: `${user.name} (${user.department})`,
|
59
|
+
value: user.id
|
60
|
+
})),
|
61
|
+
mockProductList: mockProducts.map(product => ({
|
62
|
+
id: product.id,
|
63
|
+
name: product.name,
|
64
|
+
label: `${product.name} - ¥${product.price}`,
|
65
|
+
value: product.id
|
66
|
+
})),
|
67
|
+
mockCityList: mockCities.map(city => ({
|
68
|
+
id: city.id,
|
69
|
+
name: city.name,
|
70
|
+
label: city.name,
|
71
|
+
value: city.id
|
72
|
+
}))
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* 模拟数据获取函数
|
77
|
+
* @param {Object} params - 请求参数
|
78
|
+
* @param {Object} apiConfig - API配置
|
79
|
+
* @returns {Promise<Object>} 响应数据
|
80
|
+
*/
|
81
|
+
const mockFetch = (params, apiConfig) => {
|
82
|
+
return new Promise((resolve) => {
|
83
|
+
console.log('Mock fetch params:', params);
|
84
|
+
console.log('Mock fetch apiConfig:', apiConfig);
|
85
|
+
|
86
|
+
// 模拟网络延迟
|
87
|
+
setTimeout(() => {
|
88
|
+
let result = [];
|
89
|
+
const { apiId } = apiConfig;
|
90
|
+
const keyword = params?.queryParams?.keyword || '';
|
91
|
+
|
92
|
+
// 根据API ID获取对应的数据
|
93
|
+
if (dataMap[apiId]) {
|
94
|
+
result = dataMap[apiId];
|
95
|
+
|
96
|
+
// 如果有关键字,进行筛选
|
97
|
+
if (keyword) {
|
98
|
+
result = result.filter(item =>
|
99
|
+
item.label.toLowerCase().includes(keyword.toLowerCase()) ||
|
100
|
+
item.name.toLowerCase().includes(keyword.toLowerCase())
|
101
|
+
);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
resolve({
|
106
|
+
code: 0,
|
107
|
+
data: result,
|
108
|
+
message: 'success'
|
109
|
+
});
|
110
|
+
}, 500); // 模拟 500ms 延迟
|
111
|
+
});
|
112
|
+
};
|
113
|
+
|
114
|
+
export default {
|
115
|
+
fetch: mockFetch
|
116
|
+
};
|
@@ -6,9 +6,8 @@
|
|
6
6
|
|
7
7
|
import axios from 'axios'
|
8
8
|
import { TinyNotify } from '@opentiny/vue'
|
9
|
-
|
10
9
|
// 从环境变量获取API基础URL
|
11
|
-
const API_BASE_URL = 'http://
|
10
|
+
const API_BASE_URL = 'http://' + window.location.host + '/api'
|
12
11
|
|
13
12
|
/**
|
14
13
|
* 创建axios实例
|
@@ -30,7 +29,7 @@ axiosInstance.interceptors.request.use(
|
|
30
29
|
// 添加认证信息
|
31
30
|
const token = localStorage.getItem('token')
|
32
31
|
if (token) {
|
33
|
-
config.headers['
|
32
|
+
config.headers['AppDataAuthorization'] = `Bearer ${token}`
|
34
33
|
}
|
35
34
|
|
36
35
|
// 如果是FormData格式,不设置Content-Type,让浏览器自动设置
|
@@ -57,7 +56,10 @@ axiosInstance.interceptors.response.use(
|
|
57
56
|
return data.data
|
58
57
|
} else {
|
59
58
|
// message.error(data.message || '请求失败');
|
60
|
-
return Promise.reject(
|
59
|
+
return Promise.reject({
|
60
|
+
code: data.code,
|
61
|
+
message: data.message || data.msg || '请求失败'
|
62
|
+
})
|
61
63
|
}
|
62
64
|
},
|
63
65
|
(error) => {
|
@@ -173,7 +175,7 @@ const dataService = {
|
|
173
175
|
}
|
174
176
|
params.apiId = apiConfig.apiId
|
175
177
|
if (apiConfig.key) {
|
176
|
-
params.
|
178
|
+
params.apiKey = apiConfig.key
|
177
179
|
}
|
178
180
|
|
179
181
|
const config = { ...defaultConfig, ...restConfig }
|
@@ -1,11 +1,9 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
|
4
|
-
<tiny-button :disabled="disabled" :type="type" :size="size" @click="click">
|
2
|
+
<t-tooltip :content="!isNormal && !apiConfig.apiId ? tooltipText : ''" placement="top">
|
3
|
+
<t-button :disabled="disabled || loading" :theme="type" :size="size" @click="click">
|
5
4
|
<slot>{{ text }}</slot>
|
6
|
-
</
|
7
|
-
|
8
|
-
</tiny-tooltip>
|
5
|
+
</t-button>
|
6
|
+
</t-tooltip>
|
9
7
|
</template>
|
10
8
|
|
11
9
|
|
@@ -18,10 +16,9 @@ export default {
|
|
18
16
|
<script lang='js' setup>
|
19
17
|
|
20
18
|
import { ref, reactive, computed, toRef, toRefs } from 'vue';
|
21
|
-
import {
|
19
|
+
import { Button as TButton,Tooltip as TTooltip } from 'tdesign-vue-next';
|
22
20
|
import dataService from '../apiService/simpleDataService';
|
23
21
|
|
24
|
-
|
25
22
|
const props = defineProps({
|
26
23
|
text: {
|
27
24
|
type: String,
|
@@ -35,25 +32,25 @@ const props = defineProps({
|
|
35
32
|
type: Boolean,
|
36
33
|
default: false
|
37
34
|
},
|
38
|
-
type: {//'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
35
|
+
type: {//'default' | 'primary' | 'success' | 'warning' | 'danger' | 'info'
|
39
36
|
type: String,
|
40
|
-
default: '
|
37
|
+
default: 'primary'
|
41
38
|
},
|
42
|
-
size: {//'large' | 'medium' | 'small'
|
39
|
+
size: {//'large' | 'medium' | 'small'
|
43
40
|
type: String,
|
44
41
|
default: 'medium'
|
45
42
|
},
|
46
43
|
apiConfig: {//接口配置
|
47
44
|
type: Object,
|
48
|
-
default: {
|
45
|
+
default: () => ({
|
49
46
|
key: null,
|
50
47
|
apiId: null,
|
51
48
|
apiType: ''
|
52
|
-
}
|
49
|
+
})
|
53
50
|
},
|
54
51
|
data: {
|
55
52
|
type: Object,
|
56
|
-
default: {}
|
53
|
+
default: () => ({})
|
57
54
|
},
|
58
55
|
onClick: {
|
59
56
|
type: Function,
|
@@ -61,11 +58,15 @@ const props = defineProps({
|
|
61
58
|
},
|
62
59
|
onPrepare: {//调用接口前置事件
|
63
60
|
type: Function,
|
64
|
-
default: () =>
|
61
|
+
default: () => true // 默认返回true,允许继续执行
|
65
62
|
},
|
66
63
|
onFinish: {//调用接口后置事件
|
67
64
|
type: Function,
|
68
65
|
default: () => { }
|
66
|
+
},
|
67
|
+
onError: {
|
68
|
+
type: Function,
|
69
|
+
default: () => { }
|
69
70
|
}
|
70
71
|
})
|
71
72
|
|
@@ -82,23 +83,70 @@ const apiMap = [
|
|
82
83
|
'MULTIPLE_DATA_LINK_SEARCH'
|
83
84
|
];
|
84
85
|
|
85
|
-
const emit = defineEmits(['click'])
|
86
|
+
const emit = defineEmits(['click', 'success', 'error', 'loading', 'prepare'])
|
86
87
|
|
87
|
-
const { text, isNormal, disabled, type, size, apiConfig, data
|
88
|
+
const { text, isNormal, disabled, type, size, variant, apiConfig, data } = toRefs(props)
|
88
89
|
|
89
90
|
const tooltipText = ref('请先设置接口配置')
|
91
|
+
const loading = ref(false)
|
92
|
+
|
93
|
+
// 检查API配置是否有效
|
94
|
+
const isValidApiConfig = () => {
|
95
|
+
return apiConfig.value && apiConfig.value.apiId &&
|
96
|
+
typeof apiConfig.value.apiType === 'number' &&
|
97
|
+
apiConfig.value.apiType >= 0 &&
|
98
|
+
apiConfig.value.apiType < apiMap.length;
|
99
|
+
}
|
90
100
|
|
91
|
-
const click = () => {
|
101
|
+
const click = async (e) => {
|
102
|
+
// 总是调用onClick回调
|
92
103
|
props.onClick()
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
104
|
+
emit('click', e)
|
105
|
+
|
106
|
+
// 如果是普通按钮或API配置无效,不调用接口
|
107
|
+
if (isNormal.value || !isValidApiConfig()) {
|
108
|
+
return
|
109
|
+
}
|
110
|
+
|
111
|
+
try {
|
112
|
+
// 设置加载状态
|
113
|
+
loading.value = true
|
114
|
+
emit('loading', true)
|
115
|
+
|
116
|
+
// 调用前置处理并获取返回值
|
117
|
+
const shouldContinue = props.onPrepare()
|
118
|
+
emit('prepare', shouldContinue)
|
119
|
+
|
120
|
+
// 只有当返回值明确为false时才中断,undefined或其他值都继续执行
|
121
|
+
if (shouldContinue === false) {
|
122
|
+
return null
|
123
|
+
}
|
124
|
+
|
125
|
+
// 调用接口
|
126
|
+
const apiType = apiMap[apiConfig.value.apiType]
|
127
|
+
const res = await dataService.fetch(data.value, {
|
128
|
+
key: apiConfig.value.key,
|
129
|
+
apiId: apiConfig.value.apiId,
|
130
|
+
apiType
|
98
131
|
})
|
132
|
+
|
133
|
+
// 成功处理
|
134
|
+
emit('success', res)
|
135
|
+
props.onFinish(res)
|
136
|
+
|
137
|
+
return res
|
138
|
+
} catch (error) {
|
139
|
+
// 错误处理
|
140
|
+
emit('error', error)
|
141
|
+
props.onError(error)
|
142
|
+
|
143
|
+
return null
|
144
|
+
} finally {
|
145
|
+
// 清除加载状态
|
146
|
+
loading.value = false
|
147
|
+
emit('loading', false)
|
99
148
|
}
|
100
149
|
}
|
101
|
-
|
102
150
|
</script>
|
103
151
|
|
104
152
|
<style lang='less' scoped></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>
|
@@ -0,0 +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
|
+
|
56
|
+
<script setup>
|
57
|
+
import { ref, defineProps, defineEmits, watch } from 'vue';
|
58
|
+
import { Dialog as TDialog } from 'tdesign-vue-next';
|
59
|
+
|
60
|
+
// 定义组件接收的属性
|
61
|
+
const props = defineProps({
|
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
|
+
});
|
190
|
+
|
191
|
+
// 定义组件的事件
|
192
|
+
const emit = defineEmits([
|
193
|
+
'cancel',
|
194
|
+
'close',
|
195
|
+
'closed',
|
196
|
+
'confirm',
|
197
|
+
'opened',
|
198
|
+
'overlay-click',
|
199
|
+
'update:visible'
|
200
|
+
]);
|
201
|
+
|
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>
|
246
|
+
|
247
|
+
<style lang="less" scoped>
|
248
|
+
/* 自定义样式 */
|
249
|
+
</style>
|