@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,143 @@
|
|
1
|
+
<template>
|
2
|
+
<div class="tdesign-collapse-wrapper">
|
3
|
+
<t-collapse
|
4
|
+
v-model="innerValue"
|
5
|
+
:default-value="defaultValue"
|
6
|
+
:borderless="borderless"
|
7
|
+
:default-expand-all="defaultExpandAll"
|
8
|
+
:disabled="disabled"
|
9
|
+
:expand-icon="expandIcon"
|
10
|
+
:expand-icon-placement="expandIconPlacement"
|
11
|
+
:expand-mutex="expandMutex"
|
12
|
+
:expand-on-row-click="expandOnRowClick"
|
13
|
+
@change="handleChange"
|
14
|
+
>
|
15
|
+
<slot></slot>
|
16
|
+
</t-collapse>
|
17
|
+
</div>
|
18
|
+
</template>
|
19
|
+
|
20
|
+
<script>
|
21
|
+
import { Collapse as TCollapse } from 'tdesign-vue-next';
|
22
|
+
import { defineComponent, toRefs, computed, watch } from 'vue';
|
23
|
+
|
24
|
+
export default defineComponent({
|
25
|
+
name: 'TdesignCollapse',
|
26
|
+
components: {
|
27
|
+
't-collapse': TCollapse,
|
28
|
+
},
|
29
|
+
props: {
|
30
|
+
/**
|
31
|
+
* 是否为无边框模式
|
32
|
+
*/
|
33
|
+
borderless: {
|
34
|
+
type: Boolean,
|
35
|
+
default: false,
|
36
|
+
},
|
37
|
+
/**
|
38
|
+
* 默认是否展开全部
|
39
|
+
*/
|
40
|
+
defaultExpandAll: {
|
41
|
+
type: Boolean,
|
42
|
+
default: false,
|
43
|
+
},
|
44
|
+
/**
|
45
|
+
* 是否禁用面板展开/收起操作
|
46
|
+
*/
|
47
|
+
disabled: {
|
48
|
+
type: Boolean,
|
49
|
+
default: false,
|
50
|
+
},
|
51
|
+
/**
|
52
|
+
* 展开图标。值为 undefined 或 false 则不显示展开图标;值为 true 显示默认图标
|
53
|
+
*/
|
54
|
+
expandIcon: {
|
55
|
+
type: [Boolean, Function],
|
56
|
+
default: true,
|
57
|
+
},
|
58
|
+
/**
|
59
|
+
* 展开图标的位置,左侧或右侧
|
60
|
+
*/
|
61
|
+
expandIconPlacement: {
|
62
|
+
type: String,
|
63
|
+
default: 'left',
|
64
|
+
validator(val) {
|
65
|
+
return ['left', 'right'].includes(val);
|
66
|
+
},
|
67
|
+
},
|
68
|
+
/**
|
69
|
+
* 每个面板互斥展开,每次只展开一个面板
|
70
|
+
*/
|
71
|
+
expandMutex: {
|
72
|
+
type: Boolean,
|
73
|
+
default: false,
|
74
|
+
},
|
75
|
+
/**
|
76
|
+
* 是否允许点击整行标题展开面板
|
77
|
+
*/
|
78
|
+
expandOnRowClick: {
|
79
|
+
type: Boolean,
|
80
|
+
default: true,
|
81
|
+
},
|
82
|
+
/**
|
83
|
+
* 展开的面板集合
|
84
|
+
*/
|
85
|
+
value: {
|
86
|
+
type: Array,
|
87
|
+
default: () => [],
|
88
|
+
},
|
89
|
+
/**
|
90
|
+
* 展开的面板集合,用于v-model双向绑定
|
91
|
+
*/
|
92
|
+
modelValue: {
|
93
|
+
type: Array,
|
94
|
+
default: () => [],
|
95
|
+
},
|
96
|
+
/**
|
97
|
+
* 展开的面板集合,非受控属性
|
98
|
+
*/
|
99
|
+
defaultValue: {
|
100
|
+
type: Array,
|
101
|
+
default: () => [],
|
102
|
+
},
|
103
|
+
},
|
104
|
+
emits: ['change', 'update:value', 'update:modelValue'],
|
105
|
+
setup(props, { emit }) {
|
106
|
+
const { value, modelValue } = toRefs(props);
|
107
|
+
|
108
|
+
// 处理v-model和传统value的计算属性
|
109
|
+
const innerValue = computed({
|
110
|
+
get() {
|
111
|
+
// 优先使用v-model绑定的值
|
112
|
+
return modelValue.value.length > 0 ? modelValue.value : value.value;
|
113
|
+
},
|
114
|
+
set(val) {
|
115
|
+
emit('update:value', val);
|
116
|
+
emit('update:modelValue', val);
|
117
|
+
},
|
118
|
+
});
|
119
|
+
|
120
|
+
// 监听外部值变化,同步到内部状态
|
121
|
+
watch([value, modelValue], () => {
|
122
|
+
// 这里不需要额外处理,因为计算属性会自动更新
|
123
|
+
});
|
124
|
+
|
125
|
+
// 切换面板时触发,返回变化的值
|
126
|
+
const handleChange = (val) => {
|
127
|
+
innerValue.value = val;
|
128
|
+
emit('change', val);
|
129
|
+
};
|
130
|
+
|
131
|
+
return {
|
132
|
+
innerValue,
|
133
|
+
handleChange,
|
134
|
+
};
|
135
|
+
},
|
136
|
+
});
|
137
|
+
</script>
|
138
|
+
|
139
|
+
<style scoped>
|
140
|
+
.tdesign-collapse-wrapper {
|
141
|
+
width: 100%;
|
142
|
+
}
|
143
|
+
</style>
|
@@ -0,0 +1,80 @@
|
|
1
|
+
<template>
|
2
|
+
<t-collapse-panel
|
3
|
+
:value="value"
|
4
|
+
:header="header"
|
5
|
+
:content="content"
|
6
|
+
:disabled="disabled"
|
7
|
+
:destroy-on-collapse="destroyOnCollapse"
|
8
|
+
:expand-icon="expandIcon"
|
9
|
+
>
|
10
|
+
<template v-if="$slots.header" #header>
|
11
|
+
<slot name="header"></slot>
|
12
|
+
</template>
|
13
|
+
<template v-if="$slots.default">
|
14
|
+
<slot></slot>
|
15
|
+
</template>
|
16
|
+
<template v-if="$slots.rightContent" #right-content>
|
17
|
+
<slot name="rightContent"></slot>
|
18
|
+
</template>
|
19
|
+
</t-collapse-panel>
|
20
|
+
</template>
|
21
|
+
|
22
|
+
<script>
|
23
|
+
import { CollapsePanel as TCollapsePanel } from 'tdesign-vue-next';
|
24
|
+
import { defineComponent } from 'vue';
|
25
|
+
|
26
|
+
export default defineComponent({
|
27
|
+
name: 'TdesignCollapsePanel',
|
28
|
+
components: {
|
29
|
+
't-collapse-panel': TCollapsePanel,
|
30
|
+
},
|
31
|
+
props: {
|
32
|
+
/**
|
33
|
+
* 面板唯一标识
|
34
|
+
*/
|
35
|
+
value: {
|
36
|
+
type: [String, Number],
|
37
|
+
required: true,
|
38
|
+
},
|
39
|
+
/**
|
40
|
+
* 面板头内容
|
41
|
+
*/
|
42
|
+
header: {
|
43
|
+
type: [String, Function],
|
44
|
+
default: '',
|
45
|
+
},
|
46
|
+
/**
|
47
|
+
* 面板内容
|
48
|
+
*/
|
49
|
+
content: {
|
50
|
+
type: [String, Function],
|
51
|
+
default: '',
|
52
|
+
},
|
53
|
+
/**
|
54
|
+
* 是否禁用面板展开/收起操作
|
55
|
+
*/
|
56
|
+
disabled: {
|
57
|
+
type: Boolean,
|
58
|
+
default: false,
|
59
|
+
},
|
60
|
+
/**
|
61
|
+
* 折叠时是否销毁面板内容
|
62
|
+
*/
|
63
|
+
destroyOnCollapse: {
|
64
|
+
type: Boolean,
|
65
|
+
default: false,
|
66
|
+
},
|
67
|
+
/**
|
68
|
+
* 展开图标。值为 undefined 或 false 则不显示展开图标;值为 true 显示默认图标
|
69
|
+
*/
|
70
|
+
expandIcon: {
|
71
|
+
type: [Boolean, Function],
|
72
|
+
default: undefined,
|
73
|
+
},
|
74
|
+
},
|
75
|
+
});
|
76
|
+
</script>
|
77
|
+
|
78
|
+
<style scoped>
|
79
|
+
/* 可根据需要添加自定义样式,使panel更美观 */
|
80
|
+
</style>
|
@@ -0,0 +1,125 @@
|
|
1
|
+
<template>
|
2
|
+
<t-date-picker
|
3
|
+
:allowInput="allowInput"
|
4
|
+
:clearable="clearable"
|
5
|
+
:disabled="disabled"
|
6
|
+
:enableTimePicker="enableTimePicker"
|
7
|
+
:format="format"
|
8
|
+
:mode="mode"
|
9
|
+
:placeholder="placeholder"
|
10
|
+
:presetsPlacement="presetsPlacement"
|
11
|
+
:presets="presets"
|
12
|
+
:size="size"
|
13
|
+
:status="status"
|
14
|
+
:valueType="valueType"
|
15
|
+
:value="modelValue"
|
16
|
+
@change="handleChange"
|
17
|
+
>
|
18
|
+
<template v-if="$slots.prefixIcon" #prefixIcon>
|
19
|
+
<slot name="prefixIcon"></slot>
|
20
|
+
</template>
|
21
|
+
|
22
|
+
<template v-if="$slots.suffixIcon" #suffixIcon>
|
23
|
+
<slot name="suffixIcon"></slot>
|
24
|
+
</template>
|
25
|
+
|
26
|
+
<template v-if="$slots.panel" #panel>
|
27
|
+
<slot name="panel"></slot>
|
28
|
+
</template>
|
29
|
+
</t-date-picker>
|
30
|
+
</template>
|
31
|
+
|
32
|
+
<script>
|
33
|
+
export default {
|
34
|
+
name: "EbizTdesignDatePicker"
|
35
|
+
}
|
36
|
+
</script>
|
37
|
+
|
38
|
+
<script setup>
|
39
|
+
import { defineProps, defineEmits } from 'vue';
|
40
|
+
import { DatePicker as TDatePicker } from 'tdesign-vue-next';
|
41
|
+
|
42
|
+
defineProps({
|
43
|
+
// 是否允许直接输入日期
|
44
|
+
allowInput: {
|
45
|
+
type: Boolean,
|
46
|
+
default: false
|
47
|
+
},
|
48
|
+
// 是否显示清除按钮
|
49
|
+
clearable: {
|
50
|
+
type: Boolean,
|
51
|
+
default: true
|
52
|
+
},
|
53
|
+
// 是否禁用组件
|
54
|
+
disabled: {
|
55
|
+
type: Boolean,
|
56
|
+
default: false
|
57
|
+
},
|
58
|
+
// 是否启用时间选择
|
59
|
+
enableTimePicker: {
|
60
|
+
type: Boolean,
|
61
|
+
default: false
|
62
|
+
},
|
63
|
+
// 日期格式
|
64
|
+
format: {
|
65
|
+
type: String,
|
66
|
+
default: 'YYYY-MM-DD'
|
67
|
+
},
|
68
|
+
// 选择器模式
|
69
|
+
mode: {
|
70
|
+
type: String,
|
71
|
+
default: 'date',
|
72
|
+
validator: (val) => ['date', 'month', 'year', 'week', 'quarter'].includes(val)
|
73
|
+
},
|
74
|
+
// 输入框占位符
|
75
|
+
placeholder: {
|
76
|
+
type: String,
|
77
|
+
default: '请选择日期'
|
78
|
+
},
|
79
|
+
// 预设快捷日期显示位置
|
80
|
+
presetsPlacement: {
|
81
|
+
type: String,
|
82
|
+
default: 'bottom',
|
83
|
+
validator: (val) => ['left', 'top', 'right', 'bottom'].includes(val)
|
84
|
+
},
|
85
|
+
// 预设快捷日期选择
|
86
|
+
presets: {
|
87
|
+
type: Object,
|
88
|
+
default: () => ({})
|
89
|
+
},
|
90
|
+
// 组件尺寸
|
91
|
+
size: {
|
92
|
+
type: String,
|
93
|
+
default: 'medium',
|
94
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val)
|
95
|
+
},
|
96
|
+
// 输入框状态
|
97
|
+
status: {
|
98
|
+
type: String,
|
99
|
+
default: 'default',
|
100
|
+
validator: (val) => ['default', 'success', 'warning', 'error'].includes(val)
|
101
|
+
},
|
102
|
+
// 用于格式化日期的值
|
103
|
+
valueType: {
|
104
|
+
type: String,
|
105
|
+
default: '',
|
106
|
+
validator: (val) => ['', 'time-stamp', 'Date', 'YYYY', 'YYYY-MM', 'YYYY-MM-DD'].includes(val)
|
107
|
+
},
|
108
|
+
// 日期选择器的值
|
109
|
+
modelValue: {
|
110
|
+
type: [String, Number, Date, Array],
|
111
|
+
default: ''
|
112
|
+
}
|
113
|
+
});
|
114
|
+
|
115
|
+
const emit = defineEmits(['change', 'update:modelValue']);
|
116
|
+
|
117
|
+
const handleChange = (value, context) => {
|
118
|
+
emit('change', value, context);
|
119
|
+
emit('update:modelValue', value);
|
120
|
+
};
|
121
|
+
</script>
|
122
|
+
|
123
|
+
<style lang="less" scoped>
|
124
|
+
/* 自定义样式 */
|
125
|
+
</style>
|
@@ -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>
|
@@ -0,0 +1,134 @@
|
|
1
|
+
<template>
|
2
|
+
<t-form
|
3
|
+
:class="customClass"
|
4
|
+
:data="data"
|
5
|
+
:colon="colon"
|
6
|
+
:disabled="disabled"
|
7
|
+
:form-controlled="formControlled"
|
8
|
+
:label-align="labelAlign"
|
9
|
+
:label-width="labelWidth"
|
10
|
+
:layout="layout"
|
11
|
+
:prevent-submit-default="preventSubmitDefault"
|
12
|
+
:reset-type="resetType"
|
13
|
+
:required-mark="requiredMark"
|
14
|
+
:rules="rules"
|
15
|
+
:show-error-message="showErrorMessage"
|
16
|
+
:status-icon="statusIcon"
|
17
|
+
:submit-with-warning-message="submitWithWarningMessage"
|
18
|
+
@reset="handleReset"
|
19
|
+
@submit="handleSubmit"
|
20
|
+
@validate="handleValidate"
|
21
|
+
>
|
22
|
+
<slot></slot>
|
23
|
+
</t-form>
|
24
|
+
</template>
|
25
|
+
|
26
|
+
<script>
|
27
|
+
export default {
|
28
|
+
name: "EbizTdesignForm"
|
29
|
+
}
|
30
|
+
</script>
|
31
|
+
|
32
|
+
<script setup>
|
33
|
+
import { defineProps, defineEmits } from 'vue';
|
34
|
+
import { Form as TForm } from 'tdesign-vue-next';
|
35
|
+
|
36
|
+
defineProps({
|
37
|
+
// 自定义类名
|
38
|
+
customClass: {
|
39
|
+
type: String,
|
40
|
+
default: ''
|
41
|
+
},
|
42
|
+
// 数据对象
|
43
|
+
data: {
|
44
|
+
type: Object,
|
45
|
+
default: () => ({})
|
46
|
+
},
|
47
|
+
// 是否在表单标签后面添加冒号
|
48
|
+
colon: {
|
49
|
+
type: Boolean,
|
50
|
+
default: false
|
51
|
+
},
|
52
|
+
// 是否禁用所有表单项
|
53
|
+
disabled: {
|
54
|
+
type: Boolean,
|
55
|
+
default: false
|
56
|
+
},
|
57
|
+
// 表单控件是否为受控模式
|
58
|
+
formControlled: {
|
59
|
+
type: Boolean,
|
60
|
+
default: false
|
61
|
+
},
|
62
|
+
// 标签对齐方式
|
63
|
+
labelAlign: {
|
64
|
+
type: String,
|
65
|
+
default: 'right',
|
66
|
+
validator: (val) => ['left', 'right', 'top'].includes(val)
|
67
|
+
},
|
68
|
+
// 标签宽度
|
69
|
+
labelWidth: {
|
70
|
+
type: [String, Number],
|
71
|
+
default: '100px'
|
72
|
+
},
|
73
|
+
// 表单布局
|
74
|
+
layout: {
|
75
|
+
type: String,
|
76
|
+
default: 'vertical',
|
77
|
+
validator: (val) => ['vertical', 'inline'].includes(val)
|
78
|
+
},
|
79
|
+
// 是否阻止表单提交默认行为
|
80
|
+
preventSubmitDefault: {
|
81
|
+
type: Boolean,
|
82
|
+
default: true
|
83
|
+
},
|
84
|
+
// 重置表单的方式
|
85
|
+
resetType: {
|
86
|
+
type: String,
|
87
|
+
default: 'empty',
|
88
|
+
validator: (val) => ['empty', 'initial'].includes(val)
|
89
|
+
},
|
90
|
+
// 是否显示必填标记
|
91
|
+
requiredMark: {
|
92
|
+
type: Boolean,
|
93
|
+
default: true
|
94
|
+
},
|
95
|
+
// 表单字段验证规则
|
96
|
+
rules: {
|
97
|
+
type: Object,
|
98
|
+
default: () => ({})
|
99
|
+
},
|
100
|
+
// 是否显示校验错误信息
|
101
|
+
showErrorMessage: {
|
102
|
+
type: Boolean,
|
103
|
+
default: true
|
104
|
+
},
|
105
|
+
// 是否显示校验状态图标
|
106
|
+
statusIcon: {
|
107
|
+
type: [Boolean, Function],
|
108
|
+
default: false
|
109
|
+
},
|
110
|
+
// 是否在提交表单且校验不通过时,显示错误信息
|
111
|
+
submitWithWarningMessage: {
|
112
|
+
type: Boolean,
|
113
|
+
default: false
|
114
|
+
}
|
115
|
+
});
|
116
|
+
|
117
|
+
const emit = defineEmits(['reset', 'submit', 'validate']);
|
118
|
+
|
119
|
+
const handleReset = (e) => {
|
120
|
+
emit('reset', e);
|
121
|
+
};
|
122
|
+
|
123
|
+
const handleSubmit = (e) => {
|
124
|
+
emit('submit', e);
|
125
|
+
};
|
126
|
+
|
127
|
+
const handleValidate = (params) => {
|
128
|
+
emit('validate', params);
|
129
|
+
};
|
130
|
+
</script>
|
131
|
+
|
132
|
+
<style lang="less" scoped>
|
133
|
+
/* 自定义样式 */
|
134
|
+
</style>
|