@ebiz/designer-components 0.0.18-beta.3 → 0.0.18-beta.30
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 +136 -131
- package/src/components/Button.vue +2 -1
- package/src/components/EbizDetailBlock.vue +82 -0
- package/src/components/EbizDialog.vue +249 -0
- package/src/components/EbizRemoteSelect.vue +107 -41
- package/src/components/EbizTabHeader.vue +6 -10
- package/src/components/EbizTable.vue +466 -0
- package/src/components/EbizTableColumn.vue +117 -0
- package/src/components/EbizTableSort.vue +181 -0
- package/src/components/EbizTitle.vue +36 -37
- package/src/components/EbizTree.vue +125 -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 +66 -97
- package/src/index.js +18 -1
- package/src/main.js +2 -2
- package/src/router/index.js +44 -5
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizDetailBlockDemo.vue +31 -0
- package/src/views/Home.vue +7 -1
- 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 +243 -0
- package/dist/designer-components.css +0 -1
- package/dist/favicon.ico +0 -0
- package/dist/index.mjs +0 -118984
@@ -0,0 +1,181 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="ebiz-table-sort">
|
3
|
+
<t-popup :visible="sortVisible" trigger="click" placement="bottom-right" :overlay-style="{ width: '450px' }"
|
4
|
+
@visible-change="handleVisibleChange" :destroy-on-close="false">
|
5
|
+
<template #content>
|
6
|
+
<t-card :title="popupTitle" size="small" :bordered="false">
|
7
|
+
<div class="sort-content">
|
8
|
+
<div class="sort-item" v-for="(item, index) in sortItems" :key="index">
|
9
|
+
<div class="sort-item-content" style="display: flex; margin-bottom: 12px;">
|
10
|
+
<t-select v-model="item.type" :placeholder="fieldPlaceholder" :options="fieldOptions" :clearable="false"
|
11
|
+
:style="{ width: '170px' }" @change="handleSortChange" />
|
12
|
+
<t-select v-model="item.sort" :placeholder="orderPlaceholder" :options="orderOptions" :clearable="false"
|
13
|
+
:style="{ width: '170px', marginLeft: '8px' }" @change="handleSortChange" />
|
14
|
+
<t-button theme="default" variant="text" shape="circle" @click="removeSortItem(index)"
|
15
|
+
v-if="sortItems.length > 1" :style="{ marginLeft: '8px', flexShrink: 0 }">
|
16
|
+
<template #icon>
|
17
|
+
<t-icon name="close" />
|
18
|
+
</template>
|
19
|
+
</t-button>
|
20
|
+
</div>
|
21
|
+
</div>
|
22
|
+
<div class="sort-footer">
|
23
|
+
<t-button theme="default" variant="outline" @click="addSortItem"
|
24
|
+
v-if="sortItems.length < maxSortItems">
|
25
|
+
<template #icon>
|
26
|
+
<t-icon name="add" />
|
27
|
+
</template>
|
28
|
+
{{ addConditionText }}
|
29
|
+
</t-button>
|
30
|
+
</div>
|
31
|
+
</div>
|
32
|
+
</t-card>
|
33
|
+
</template>
|
34
|
+
<t-button block variant="outline" :title="title">
|
35
|
+
<template #icon>
|
36
|
+
<t-icon :name="icon" />
|
37
|
+
</template>
|
38
|
+
<div v-if="buttonText">
|
39
|
+
{{ buttonText }}
|
40
|
+
</div>
|
41
|
+
</t-button>
|
42
|
+
</t-popup>
|
43
|
+
</div>
|
44
|
+
</template>
|
45
|
+
|
46
|
+
<script>
|
47
|
+
export default {
|
48
|
+
name: "EbizTableSort"
|
49
|
+
}
|
50
|
+
</script>
|
51
|
+
|
52
|
+
<script setup>
|
53
|
+
import { ref, computed, defineProps, defineEmits, watch } from 'vue';
|
54
|
+
import { Button as TButton, Popup as TPopup, Card as TCard, Select as TSelect, Icon as TIcon } from 'tdesign-vue-next';
|
55
|
+
|
56
|
+
const props = defineProps({
|
57
|
+
// v-model绑定值
|
58
|
+
modelValue: {
|
59
|
+
type: Array,
|
60
|
+
default: () => []
|
61
|
+
},
|
62
|
+
// 按钮图标
|
63
|
+
icon: {
|
64
|
+
type: String,
|
65
|
+
default: 'sort'
|
66
|
+
},
|
67
|
+
// 按钮文本
|
68
|
+
buttonText: {
|
69
|
+
type: String,
|
70
|
+
default: ''
|
71
|
+
},
|
72
|
+
// 按钮标题
|
73
|
+
title: {
|
74
|
+
type: String,
|
75
|
+
default: '排序'
|
76
|
+
},
|
77
|
+
// 弹出层标题
|
78
|
+
popupTitle: {
|
79
|
+
type: String,
|
80
|
+
default: '排序'
|
81
|
+
},
|
82
|
+
// 字段选项
|
83
|
+
fieldOptions: {
|
84
|
+
type: Array,
|
85
|
+
default: () => []
|
86
|
+
},
|
87
|
+
// 字段占位符
|
88
|
+
fieldPlaceholder: {
|
89
|
+
type: String,
|
90
|
+
default: '选择字段'
|
91
|
+
},
|
92
|
+
// 排序选项
|
93
|
+
orderOptions: {
|
94
|
+
type: Array,
|
95
|
+
default: () => [
|
96
|
+
{ value: 'asc', label: '升序 ↑' },
|
97
|
+
{ value: 'desc', label: '降序 ↓' }
|
98
|
+
]
|
99
|
+
},
|
100
|
+
// 排序占位符
|
101
|
+
orderPlaceholder: {
|
102
|
+
type: String,
|
103
|
+
default: '选择排序'
|
104
|
+
},
|
105
|
+
// 最大排序条件数量
|
106
|
+
maxSortItems: {
|
107
|
+
type: Number,
|
108
|
+
default: 5
|
109
|
+
},
|
110
|
+
// 添加条件文本
|
111
|
+
addConditionText: {
|
112
|
+
type: String,
|
113
|
+
default: '添加排序条件'
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
const emit = defineEmits(['update:modelValue', 'sort', 'visible-change']);
|
118
|
+
|
119
|
+
// 排序弹出层显示状态
|
120
|
+
const sortVisible = ref(false);
|
121
|
+
|
122
|
+
// 排序条件列表
|
123
|
+
const sortItems = ref([]);
|
124
|
+
|
125
|
+
// 监听modelValue变化
|
126
|
+
watch(() => props.modelValue, (newVal) => {
|
127
|
+
if (newVal && newVal.length > 0) {
|
128
|
+
sortItems.value = JSON.parse(JSON.stringify(newVal));
|
129
|
+
} else {
|
130
|
+
// 默认添加一个空的排序条件
|
131
|
+
sortItems.value = [{ type: '', sort: 'desc' }];
|
132
|
+
}
|
133
|
+
}, { immediate: true });
|
134
|
+
|
135
|
+
// 添加排序条件
|
136
|
+
const addSortItem = () => {
|
137
|
+
if (sortItems.value.length < props.maxSortItems) {
|
138
|
+
sortItems.value.push({ type: '', sort: 'desc' });
|
139
|
+
}
|
140
|
+
};
|
141
|
+
|
142
|
+
// 移除排序条件
|
143
|
+
const removeSortItem = (index) => {
|
144
|
+
sortItems.value.splice(index, 1);
|
145
|
+
handleSortChange();
|
146
|
+
};
|
147
|
+
|
148
|
+
// 处理排序变更
|
149
|
+
const handleSortChange = () => {
|
150
|
+
// 过滤有效的排序条件(字段和排序方向都不为空)
|
151
|
+
const validSortItems = sortItems.value.filter(item => item.type && item.sort);
|
152
|
+
emit('update:modelValue', validSortItems);
|
153
|
+
emit('sort', validSortItems);
|
154
|
+
};
|
155
|
+
|
156
|
+
// 弹出层可见性变化
|
157
|
+
const handleVisibleChange = (visible) => {
|
158
|
+
sortVisible.value = visible;
|
159
|
+
emit('visible-change', visible);
|
160
|
+
};
|
161
|
+
</script>
|
162
|
+
|
163
|
+
<style lang="less" scoped>
|
164
|
+
.ebiz-table-sort {
|
165
|
+
display: inline-block;
|
166
|
+
|
167
|
+
.sort-content {
|
168
|
+
min-width: 400px;
|
169
|
+
width: 100%;
|
170
|
+
}
|
171
|
+
|
172
|
+
.sort-footer {
|
173
|
+
margin-top: 16px;
|
174
|
+
}
|
175
|
+
|
176
|
+
.sort-actions {
|
177
|
+
display: flex;
|
178
|
+
justify-content: flex-end;
|
179
|
+
}
|
180
|
+
}
|
181
|
+
</style>
|
@@ -1,52 +1,51 @@
|
|
1
1
|
<template>
|
2
2
|
<div class="ebiz-title">
|
3
|
-
|
4
|
-
|
3
|
+
<div class="color-block" :style="{ backgroundColor: color, width: `${blockWidth}px` }"></div>
|
4
|
+
<div class="title-text">
|
5
5
|
<slot name="title">
|
6
6
|
{{ displayTitle }}
|
7
7
|
</slot>
|
8
|
-
</div>
|
8
|
+
</div>
|
9
9
|
</div>
|
10
10
|
</template>
|
11
11
|
|
12
12
|
<script setup>
|
13
|
+
import { defineProps, computed } from 'vue';
|
13
14
|
|
14
|
-
|
15
|
+
/**
|
16
|
+
* EbizTitle 组件 - 带有色块的标题组件
|
17
|
+
* 支持自定义标题文本、色块颜色和色块宽度
|
18
|
+
* 包含一个按钮,点击时在标题后添加点号并触发事件
|
19
|
+
* 支持通过插槽自定义标题内容
|
20
|
+
*/
|
21
|
+
const props = defineProps({
|
22
|
+
/**
|
23
|
+
* 标题文本 (当不使用插槽时显示)
|
24
|
+
*/
|
25
|
+
title: {
|
26
|
+
type: String,
|
27
|
+
default: '标题'
|
28
|
+
},
|
29
|
+
/**
|
30
|
+
* 色块颜色,支持任何有效的CSS颜色值
|
31
|
+
*/
|
32
|
+
color: {
|
33
|
+
type: String,
|
34
|
+
default: '#1890ff'
|
35
|
+
},
|
36
|
+
/**
|
37
|
+
* 色块宽度,单位为像素
|
38
|
+
*/
|
39
|
+
blockWidth: {
|
40
|
+
type: Number,
|
41
|
+
default: 10
|
42
|
+
}
|
43
|
+
});
|
15
44
|
|
16
|
-
// /**
|
17
|
-
// * EbizTitle 组件 - 带有色块的标题组件
|
18
|
-
// * 支持自定义标题文本、色块颜色和色块宽度
|
19
|
-
// * 包含一个按钮,点击时在标题后添加点号并触发事件
|
20
|
-
// * 支持通过插槽自定义标题内容
|
21
|
-
// */
|
22
|
-
// const props = defineProps({
|
23
|
-
// /**
|
24
|
-
// * 标题文本 (当不使用插槽时显示)
|
25
|
-
// */
|
26
|
-
// title: {
|
27
|
-
// type: String,
|
28
|
-
// default: '标题'
|
29
|
-
// },
|
30
|
-
// /**
|
31
|
-
// * 色块颜色,支持任何有效的CSS颜色值
|
32
|
-
// */
|
33
|
-
// color: {
|
34
|
-
// type: String,
|
35
|
-
// default: '#1890ff'
|
36
|
-
// },
|
37
|
-
// /**
|
38
|
-
// * 色块宽度,单位为像素
|
39
|
-
// */
|
40
|
-
// blockWidth: {
|
41
|
-
// type: Number,
|
42
|
-
// default: 10
|
43
|
-
// }
|
44
|
-
// });
|
45
45
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
// });
|
46
|
+
const displayTitle = computed(() => {
|
47
|
+
return props.title;
|
48
|
+
});
|
50
49
|
</script>
|
51
50
|
|
52
51
|
<style scoped>
|
@@ -0,0 +1,125 @@
|
|
1
|
+
<template>
|
2
|
+
<t-tree
|
3
|
+
v-bind="$attrs"
|
4
|
+
:data="data"
|
5
|
+
:value="modelValue"
|
6
|
+
:expanded="expandedModel"
|
7
|
+
:actived="activedModel"
|
8
|
+
@change="handleChange"
|
9
|
+
@expand="handleExpand"
|
10
|
+
@active="handleActive"
|
11
|
+
@select="$emit('select', $event)"
|
12
|
+
@drag-start="$emit('drag-start', $event)"
|
13
|
+
@drag-end="$emit('drag-end', $event)"
|
14
|
+
@drag-over="$emit('drag-over', $event)"
|
15
|
+
@drag-leave="$emit('drag-leave', $event)"
|
16
|
+
@drag-drop="$emit('drag-drop', $event)"
|
17
|
+
@click="$emit('click', $event)"
|
18
|
+
@load="$emit('load', $event)"
|
19
|
+
>
|
20
|
+
<template v-if="$slots.default" #default="slotProps">
|
21
|
+
<slot :node="slotProps.node"></slot>
|
22
|
+
</template>
|
23
|
+
<template v-if="$slots.empty" #empty>
|
24
|
+
<slot name="empty"></slot>
|
25
|
+
</template>
|
26
|
+
<template v-if="$slots.icon" #icon="slotProps">
|
27
|
+
<slot name="icon" :node="slotProps.node"></slot>
|
28
|
+
</template>
|
29
|
+
<template v-if="$slots.label" #label="slotProps">
|
30
|
+
<slot name="label" :node="slotProps.node"></slot>
|
31
|
+
</template>
|
32
|
+
<template v-if="$slots.line" #line="slotProps">
|
33
|
+
<slot name="line" :node="slotProps.node"></slot>
|
34
|
+
</template>
|
35
|
+
<template v-if="$slots.operations" #operations="slotProps">
|
36
|
+
<slot name="operations" :node="slotProps.node"></slot>
|
37
|
+
</template>
|
38
|
+
</t-tree>
|
39
|
+
</template>
|
40
|
+
|
41
|
+
<script setup>
|
42
|
+
import { Tree as TTree } from 'tdesign-vue-next';
|
43
|
+
import { computed } from 'vue';
|
44
|
+
|
45
|
+
// 定义组件属性
|
46
|
+
const props = defineProps({
|
47
|
+
// 选中值
|
48
|
+
modelValue: {
|
49
|
+
type: Array,
|
50
|
+
default: () => []
|
51
|
+
},
|
52
|
+
// 展开节点
|
53
|
+
expanded: {
|
54
|
+
type: Array,
|
55
|
+
default: () => []
|
56
|
+
},
|
57
|
+
// 激活节点
|
58
|
+
actived: {
|
59
|
+
type: Array,
|
60
|
+
default: () => []
|
61
|
+
},
|
62
|
+
// 数据
|
63
|
+
items: {
|
64
|
+
type: Array,
|
65
|
+
default: () => []
|
66
|
+
}
|
67
|
+
});
|
68
|
+
|
69
|
+
// 定义组件事件
|
70
|
+
const emit = defineEmits([
|
71
|
+
'update:modelValue',
|
72
|
+
'update:expanded',
|
73
|
+
'update:actived',
|
74
|
+
'change',
|
75
|
+
'expand',
|
76
|
+
'active',
|
77
|
+
'select',
|
78
|
+
'click',
|
79
|
+
'load',
|
80
|
+
'drag-start',
|
81
|
+
'drag-end',
|
82
|
+
'drag-over',
|
83
|
+
'drag-leave',
|
84
|
+
'drag-drop'
|
85
|
+
]);
|
86
|
+
|
87
|
+
// 处理items映射到data
|
88
|
+
const data = computed(() => props.items);
|
89
|
+
|
90
|
+
// 展开事件
|
91
|
+
const expandedModel = computed({
|
92
|
+
get: () => props.expanded,
|
93
|
+
set: (val) => emit('update:expanded', val)
|
94
|
+
});
|
95
|
+
|
96
|
+
// 激活节点
|
97
|
+
const activedModel = computed({
|
98
|
+
get: () => props.actived,
|
99
|
+
set: (val) => emit('update:actived', val)
|
100
|
+
});
|
101
|
+
|
102
|
+
// 值改变事件
|
103
|
+
const handleChange = (val, context) => {
|
104
|
+
emit('update:modelValue', val);
|
105
|
+
emit('change', val, context);
|
106
|
+
};
|
107
|
+
|
108
|
+
// 节点展开事件
|
109
|
+
const handleExpand = (val, context) => {
|
110
|
+
emit('update:expanded', val);
|
111
|
+
emit('expand', val, context);
|
112
|
+
};
|
113
|
+
|
114
|
+
// 节点激活事件
|
115
|
+
const handleActive = (val, context) => {
|
116
|
+
emit('update:actived', val);
|
117
|
+
emit('active', val, context);
|
118
|
+
};
|
119
|
+
</script>
|
120
|
+
|
121
|
+
<style>
|
122
|
+
.t-tree {
|
123
|
+
width: 100%;
|
124
|
+
}
|
125
|
+
</style>
|
@@ -14,7 +14,7 @@
|
|
14
14
|
:month-change="monthChange"
|
15
15
|
:render-cell="renderCell"
|
16
16
|
:theme="theme"
|
17
|
-
:value="
|
17
|
+
:value="modelValue"
|
18
18
|
:year="year"
|
19
19
|
@cell-click="handleCellClick"
|
20
20
|
@cell-double-click="handleCellDoubleClick"
|
@@ -111,7 +111,7 @@ export default {
|
|
111
111
|
default: 'full',
|
112
112
|
validator: (val) => ['full', 'card'].includes(val)
|
113
113
|
},
|
114
|
-
|
114
|
+
modelValue: {
|
115
115
|
type: [String, Number, Array, Date],
|
116
116
|
default: null
|
117
117
|
},
|
@@ -120,10 +120,13 @@ export default {
|
|
120
120
|
default: undefined
|
121
121
|
}
|
122
122
|
},
|
123
|
-
emits: ['cell-click', 'cell-double-click', 'cell-right-click', 'month-change'],
|
123
|
+
emits: ['cell-click', 'cell-double-click', 'cell-right-click', 'month-change', 'update:modelValue'],
|
124
124
|
methods: {
|
125
125
|
handleCellClick(options) {
|
126
126
|
this.$emit('cell-click', options)
|
127
|
+
if (options && options.date) {
|
128
|
+
this.$emit('update:modelValue', options.date)
|
129
|
+
}
|
127
130
|
},
|
128
131
|
handleCellDoubleClick(options) {
|
129
132
|
this.$emit('cell-double-click', options)
|
@@ -0,0 +1,226 @@
|
|
1
|
+
<template>
|
2
|
+
<t-dialog v-model:visible="isVisible" :attach="attach" :body="body" :cancel-btn="cancelBtn" :close-btn="closeBtn"
|
3
|
+
:close-on-esc-keydown="closeOnEscKeydown" :close-on-overlay-click="closeOnOverlayClick"
|
4
|
+
:confirm-btn="confirmBtn" :default-visible="defaultVisible" :destroy-on-close="destroyOnClose"
|
5
|
+
:draggable="draggable" :footer="footer" :header="header" :mode="mode" :placement="placement"
|
6
|
+
:show-overlay="showOverlay" :width="width" :z-index="zIndex" @cancel="handleCancel" @close="handleClose"
|
7
|
+
@close-btn-click="handleCloseBtnClick" @confirm="handleConfirm" @esc-keydown="handleEscKeydown"
|
8
|
+
@overlay-click="handleOverlayClick" @opened="handleOpened" @closed="handleClosed"
|
9
|
+
@update:visible="handleUpdateVisible">
|
10
|
+
<!-- 头部插槽 -->
|
11
|
+
<template v-if="$slots.header" #header>
|
12
|
+
<slot name="header"></slot>
|
13
|
+
</template>
|
14
|
+
|
15
|
+
<!-- 内容插槽 -->
|
16
|
+
<template v-if="$slots.body" #body>
|
17
|
+
<slot name="body"></slot>
|
18
|
+
</template>
|
19
|
+
|
20
|
+
<!-- 默认插槽 -->
|
21
|
+
<slot></slot>
|
22
|
+
|
23
|
+
<!-- 页脚插槽 -->
|
24
|
+
<template v-if="$slots.footer" #footer>
|
25
|
+
<slot name="footer"></slot>
|
26
|
+
</template>
|
27
|
+
|
28
|
+
<!-- 取消按钮插槽 -->
|
29
|
+
<template v-if="$slots.cancelBtn" #cancel-btn>
|
30
|
+
<slot name="cancelBtn"></slot>
|
31
|
+
</template>
|
32
|
+
|
33
|
+
<!-- 确认按钮插槽 -->
|
34
|
+
<template v-if="$slots.confirmBtn" #confirm-btn>
|
35
|
+
<slot name="confirmBtn"></slot>
|
36
|
+
</template>
|
37
|
+
</t-dialog>
|
38
|
+
</template>
|
39
|
+
|
40
|
+
<script>
|
41
|
+
export default {
|
42
|
+
name: "EbizDialog"
|
43
|
+
}
|
44
|
+
</script>
|
45
|
+
|
46
|
+
<script setup>
|
47
|
+
import { ref, watch } from 'vue';
|
48
|
+
import { Dialog as TDialog } from 'tdesign-vue-next';
|
49
|
+
|
50
|
+
// 定义属性
|
51
|
+
const props = defineProps({
|
52
|
+
// 对话框挂载的节点
|
53
|
+
attach: {
|
54
|
+
type: [String, Function, Element],
|
55
|
+
default: 'body'
|
56
|
+
},
|
57
|
+
// 对话框内容
|
58
|
+
body: {
|
59
|
+
type: [String, Function],
|
60
|
+
default: ''
|
61
|
+
},
|
62
|
+
// 取消按钮,可自定义。值为 null 则不显示取消按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性
|
63
|
+
cancelBtn: {
|
64
|
+
type: [String, Object, null],
|
65
|
+
default: ''
|
66
|
+
},
|
67
|
+
// 关闭按钮,值为 true 显示默认关闭按钮;值为 false 则不显示关闭按钮;值类型为 string 则直接显示值;值类型为 TNode,则显示自定义按钮
|
68
|
+
closeBtn: {
|
69
|
+
type: [Boolean, String, Function],
|
70
|
+
default: true
|
71
|
+
},
|
72
|
+
// 按下 ESC 时是否触发对话框关闭
|
73
|
+
closeOnEscKeydown: {
|
74
|
+
type: Boolean,
|
75
|
+
default: undefined
|
76
|
+
},
|
77
|
+
// 点击蒙层时是否触发关闭
|
78
|
+
closeOnOverlayClick: {
|
79
|
+
type: Boolean,
|
80
|
+
default: undefined
|
81
|
+
},
|
82
|
+
// 确认按钮,可自定义。值为 null 则不显示确认按钮。值类型为字符串,则表示自定义按钮文本,值类型为 Object 则表示透传 Button 组件属性
|
83
|
+
confirmBtn: {
|
84
|
+
type: [String, Object, null],
|
85
|
+
default: ''
|
86
|
+
},
|
87
|
+
// 对话框默认是否显示
|
88
|
+
defaultVisible: {
|
89
|
+
type: Boolean,
|
90
|
+
default: false
|
91
|
+
},
|
92
|
+
// 是否在关闭弹框的时候销毁子元素
|
93
|
+
destroyOnClose: {
|
94
|
+
type: Boolean,
|
95
|
+
default: false
|
96
|
+
},
|
97
|
+
// 对话框是否可以拖拽
|
98
|
+
draggable: {
|
99
|
+
type: Boolean,
|
100
|
+
default: false
|
101
|
+
},
|
102
|
+
// 底部操作栏,默认会有"确认"和"取消"两个按钮
|
103
|
+
footer: {
|
104
|
+
type: [Boolean, Function],
|
105
|
+
default: true
|
106
|
+
},
|
107
|
+
// 头部内容
|
108
|
+
header: {
|
109
|
+
type: [String, Boolean, Function],
|
110
|
+
default: true
|
111
|
+
},
|
112
|
+
// 对话框类型
|
113
|
+
mode: {
|
114
|
+
type: String,
|
115
|
+
default: 'modal',
|
116
|
+
validator: (val) => ['modal', 'modeless', 'full-screen'].includes(val)
|
117
|
+
},
|
118
|
+
// 对话框位置,类似 CSS 中的 position
|
119
|
+
placement: {
|
120
|
+
type: String,
|
121
|
+
default: 'top',
|
122
|
+
validator: (val) => ['top', 'center'].includes(val)
|
123
|
+
},
|
124
|
+
// 是否显示遮罩层
|
125
|
+
showOverlay: {
|
126
|
+
type: Boolean,
|
127
|
+
default: true
|
128
|
+
},
|
129
|
+
// 控制对话框显示与隐藏
|
130
|
+
visible: {
|
131
|
+
type: Boolean,
|
132
|
+
default: undefined
|
133
|
+
},
|
134
|
+
// 对话框宽度
|
135
|
+
width: {
|
136
|
+
type: [String, Number],
|
137
|
+
default: undefined
|
138
|
+
},
|
139
|
+
// 对话框层级
|
140
|
+
zIndex: {
|
141
|
+
type: Number,
|
142
|
+
default: undefined
|
143
|
+
}
|
144
|
+
});
|
145
|
+
|
146
|
+
// 显示状态
|
147
|
+
const isVisible = ref(props.visible);
|
148
|
+
|
149
|
+
// 监听visible属性变化
|
150
|
+
watch(() => props.visible, (newValue) => {
|
151
|
+
isVisible.value = newValue;
|
152
|
+
});
|
153
|
+
|
154
|
+
// 定义事件
|
155
|
+
const emit = defineEmits([
|
156
|
+
'cancel',
|
157
|
+
'close',
|
158
|
+
'close-btn-click',
|
159
|
+
'confirm',
|
160
|
+
'esc-keydown',
|
161
|
+
'overlay-click',
|
162
|
+
'opened',
|
163
|
+
'closed',
|
164
|
+
'update:visible'
|
165
|
+
]);
|
166
|
+
|
167
|
+
// 取消按钮点击事件
|
168
|
+
const handleCancel = (e) => {
|
169
|
+
emit('cancel', { e });
|
170
|
+
emit('close', { trigger: 'cancel', e });
|
171
|
+
emit('update:visible', false);
|
172
|
+
};
|
173
|
+
|
174
|
+
// 关闭事件
|
175
|
+
const handleClose = (context) => {
|
176
|
+
emit('close', context);
|
177
|
+
emit('update:visible', false);
|
178
|
+
};
|
179
|
+
|
180
|
+
// 关闭按钮点击事件
|
181
|
+
const handleCloseBtnClick = (e) => {
|
182
|
+
emit('close-btn-click', { e });
|
183
|
+
emit('close', { trigger: 'close-btn', e });
|
184
|
+
emit('update:visible', false);
|
185
|
+
};
|
186
|
+
|
187
|
+
// 确认按钮点击事件
|
188
|
+
const handleConfirm = (e) => {
|
189
|
+
emit('confirm', { e });
|
190
|
+
emit('update:visible', false);
|
191
|
+
};
|
192
|
+
|
193
|
+
// ESC 按键按下事件
|
194
|
+
const handleEscKeydown = (e) => {
|
195
|
+
emit('esc-keydown', { e });
|
196
|
+
emit('close', { trigger: 'esc', e });
|
197
|
+
emit('update:visible', false);
|
198
|
+
};
|
199
|
+
|
200
|
+
// 遮罩层点击事件
|
201
|
+
const handleOverlayClick = (e) => {
|
202
|
+
emit('overlay-click', { e });
|
203
|
+
emit('close', { trigger: 'overlay', e });
|
204
|
+
emit('update:visible', false);
|
205
|
+
};
|
206
|
+
|
207
|
+
// 对话框打开完成事件
|
208
|
+
const handleOpened = () => {
|
209
|
+
emit('opened');
|
210
|
+
};
|
211
|
+
|
212
|
+
// 对话框关闭完成事件
|
213
|
+
const handleClosed = () => {
|
214
|
+
emit('closed');
|
215
|
+
};
|
216
|
+
|
217
|
+
// 更新可见状态
|
218
|
+
const handleUpdateVisible = (visible) => {
|
219
|
+
isVisible.value = visible;
|
220
|
+
emit('update:visible', visible);
|
221
|
+
};
|
222
|
+
</script>
|
223
|
+
|
224
|
+
<style lang="less" scoped>
|
225
|
+
/* 自定义样式 */
|
226
|
+
</style>
|