@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,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>
|
@@ -1,14 +1,15 @@
|
|
1
1
|
<template>
|
2
|
-
<
|
3
|
-
|
4
|
-
:disabled="disabled"
|
5
|
-
|
2
|
+
<t-select ref="selectRef" v-model="selectedValue" :options="options" :loading="loading" :filterable="true"
|
3
|
+
@search="handleRemoteSearch" :multiple="multiple" :placeholder="placeholder" :clearable="clearable"
|
4
|
+
:disabled="disabled" :size="size" :empty="emptyText" :popupProps="popupProps" @change="handleChange"
|
5
|
+
@focus="handleFocus" @blur="handleBlur">
|
6
|
+
<template #prefixIcon v-if="$slots.prefix">
|
6
7
|
<slot name="prefix"></slot>
|
7
8
|
</template>
|
8
|
-
<template #suffix>
|
9
|
+
<template #suffixIcon v-if="$slots.suffix">
|
9
10
|
<slot name="suffix"></slot>
|
10
11
|
</template>
|
11
|
-
</
|
12
|
+
</t-select>
|
12
13
|
</template>
|
13
14
|
|
14
15
|
<script>
|
@@ -19,8 +20,8 @@ export default {
|
|
19
20
|
|
20
21
|
<script setup>
|
21
22
|
import { ref, onMounted, toRefs, computed } from 'vue';
|
22
|
-
import { Select as
|
23
|
-
import dataService from
|
23
|
+
import { Select as TSelect } from 'tdesign-vue-next';
|
24
|
+
import dataService from '../apiService/simpleDataService';
|
24
25
|
|
25
26
|
const props = defineProps({
|
26
27
|
/**
|
@@ -30,6 +31,7 @@ const props = defineProps({
|
|
30
31
|
type: Object,
|
31
32
|
required: true,
|
32
33
|
default: () => ({
|
34
|
+
key: null,
|
33
35
|
apiId: null,
|
34
36
|
apiType: ''
|
35
37
|
})
|
@@ -39,7 +41,9 @@ const props = defineProps({
|
|
39
41
|
*/
|
40
42
|
queryParams: {
|
41
43
|
type: Object,
|
42
|
-
default: {
|
44
|
+
default: () => ({
|
45
|
+
name: ''
|
46
|
+
})
|
43
47
|
},
|
44
48
|
/**
|
45
49
|
* 是否多选
|
@@ -73,21 +77,54 @@ const props = defineProps({
|
|
73
77
|
* 默认值
|
74
78
|
*/
|
75
79
|
modelValue: {
|
76
|
-
type: [String, Number],
|
80
|
+
type: [String, Number, Array],
|
77
81
|
default: ''
|
78
82
|
},
|
83
|
+
/**
|
84
|
+
* 选项配置
|
85
|
+
*/
|
79
86
|
optionsConfig: {
|
80
|
-
|
81
|
-
|
87
|
+
type: Object,
|
88
|
+
default: () => ({
|
89
|
+
labelField: '',
|
90
|
+
valueField: ''
|
91
|
+
})
|
92
|
+
},
|
93
|
+
/**
|
94
|
+
* 组件尺寸
|
95
|
+
*/
|
96
|
+
size: {
|
97
|
+
type: String,
|
98
|
+
default: 'medium',
|
99
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val)
|
100
|
+
},
|
101
|
+
/**
|
102
|
+
* 空数据文本
|
103
|
+
*/
|
104
|
+
emptyText: {
|
105
|
+
type: String,
|
106
|
+
default: '暂无数据'
|
107
|
+
},
|
108
|
+
/**
|
109
|
+
* 弹出层配置
|
110
|
+
*/
|
111
|
+
popupProps: {
|
112
|
+
type: Object,
|
113
|
+
default: () => ({})
|
82
114
|
}
|
83
115
|
});
|
84
116
|
|
85
117
|
const { modelValue, apiConfig, queryParams } = toRefs(props)
|
86
118
|
|
87
|
-
const emit = defineEmits(['update:modelValue', 'change']);
|
119
|
+
const emit = defineEmits(['update:modelValue', 'change', 'focus', 'blur']);
|
88
120
|
|
89
121
|
// 选中的值
|
90
|
-
const selectedValue = computed(
|
122
|
+
const selectedValue = computed({
|
123
|
+
get: () => modelValue.value,
|
124
|
+
set: (val) => {
|
125
|
+
emit('update:modelValue', val);
|
126
|
+
}
|
127
|
+
});
|
91
128
|
|
92
129
|
// 选项列表
|
93
130
|
const options = ref([]);
|
@@ -104,37 +141,60 @@ const focus = () => {
|
|
104
141
|
};
|
105
142
|
|
106
143
|
defineExpose({
|
107
|
-
focus
|
144
|
+
focus,
|
145
|
+
selectRef,
|
146
|
+
options
|
108
147
|
});
|
109
148
|
|
110
149
|
// 远程搜索处理函数
|
111
|
-
const handleRemoteSearch = async () => {
|
112
|
-
//if (options.value?.length > 0) return
|
113
|
-
|
150
|
+
const handleRemoteSearch = async (keyword) => {
|
114
151
|
loading.value = true;
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
queryParams
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
152
|
+
try {
|
153
|
+
const params = {
|
154
|
+
queryParams: {
|
155
|
+
...queryParams.value,
|
156
|
+
name: keyword
|
157
|
+
}
|
158
|
+
};
|
159
|
+
const res = await dataService.fetch(params, {
|
160
|
+
key: props.apiConfig.key,
|
161
|
+
apiId: props.apiConfig.apiId,
|
162
|
+
apiType: 'MULTIPLE_DATA_SEARCH'
|
163
|
+
});
|
164
|
+
const { labelField, valueField } = props.optionsConfig;
|
165
|
+
|
166
|
+
options.value = res.data.map(item => ({
|
167
|
+
...item,
|
168
|
+
label: labelField ? item[labelField] : (item.label || item.name),
|
169
|
+
value: valueField ? item[valueField] : (item.value || item.id)
|
170
|
+
}));
|
171
|
+
} catch (error) {
|
172
|
+
console.error('远程搜索失败:', error);
|
173
|
+
options.value = [];
|
174
|
+
} finally {
|
175
|
+
loading.value = false;
|
176
|
+
}
|
177
|
+
|
178
|
+
};
|
179
|
+
|
180
|
+
// 处理获取焦点事件
|
181
|
+
const handleFocus = (value, context) => {
|
182
|
+
emit('focus', value, context);
|
183
|
+
// 当选项为空时,初始加载数据
|
184
|
+
if (options.value.length === 0) {
|
185
|
+
handleRemoteSearch('');
|
131
186
|
}
|
132
187
|
};
|
133
188
|
|
189
|
+
// 处理失去焦点事件
|
190
|
+
const handleBlur = (value, context) => {
|
191
|
+
emit('blur', value, context);
|
192
|
+
};
|
193
|
+
|
134
194
|
// 值变化处理函数
|
135
|
-
const handleChange = (value) => {
|
195
|
+
const handleChange = (value, context) => {
|
136
196
|
emit('update:modelValue', value);
|
137
|
-
emit('change', value);
|
197
|
+
emit('change', value, context);
|
138
198
|
};
|
139
199
|
|
140
200
|
// 组件挂载时,如果有默认值则加载对应的选项
|
@@ -145,10 +205,17 @@ onMounted(async () => {
|
|
145
205
|
const params = {
|
146
206
|
queryParams: queryParams.value
|
147
207
|
};
|
148
|
-
const res = await dataService.fetch(params, {
|
208
|
+
const res = await dataService.fetch(params, {
|
209
|
+
key: props.apiConfig.key,
|
210
|
+
apiId: props.apiConfig.apiId,
|
211
|
+
apiType: 'MULTIPLE_DATA_SEARCH'
|
212
|
+
});
|
213
|
+
const { labelField, valueField } = props.optionsConfig;
|
214
|
+
|
149
215
|
options.value = res.data.map(item => ({
|
150
|
-
|
151
|
-
|
216
|
+
...item,
|
217
|
+
label: labelField ? item[labelField] : (item.label || item.name),
|
218
|
+
value: valueField ? item[valueField] : (item.value || item.id)
|
152
219
|
}));
|
153
220
|
} catch (error) {
|
154
221
|
console.error('加载默认选项失败:', error);
|
@@ -156,12 +223,11 @@ onMounted(async () => {
|
|
156
223
|
loading.value = false;
|
157
224
|
}
|
158
225
|
}
|
159
|
-
|
160
226
|
});
|
161
227
|
</script>
|
162
228
|
|
163
229
|
<style scoped>
|
164
|
-
.
|
230
|
+
.t-select {
|
165
231
|
width: 100%;
|
166
232
|
}
|
167
233
|
</style>
|
@@ -1,12 +1,7 @@
|
|
1
1
|
<template>
|
2
2
|
<tiny-tabs v-model="showTab" :tab-style="props.tabStyle" activeColor="#5e7ce0" @click="tabChange">
|
3
|
-
<tiny-tab-item
|
4
|
-
|
5
|
-
v-for="i in showTabs"
|
6
|
-
:key="i.value"
|
7
|
-
:title="i.label"
|
8
|
-
:name="i.value.toString()"
|
9
|
-
/>
|
3
|
+
<tiny-tab-item activeColor="#5e7ce0" v-for="i in showTabs" :key="i.value" :title="i.label"
|
4
|
+
:name="i.value.toString()" />
|
10
5
|
</tiny-tabs>
|
11
6
|
</template>
|
12
7
|
|
@@ -22,6 +17,7 @@ const props = defineProps({
|
|
22
17
|
apiConfig: {
|
23
18
|
type: Object,
|
24
19
|
default: () => ({
|
20
|
+
key: null,
|
25
21
|
apiId: null,
|
26
22
|
apiType: 'MULTIPLE_DATA_SEARCH',
|
27
23
|
}),
|
@@ -63,7 +59,7 @@ const remoteTabs = ref([])
|
|
63
59
|
|
64
60
|
// 展示的tabs
|
65
61
|
const showTabs = computed(() => {
|
66
|
-
|
62
|
+
console.log(props.tabs, 66, 110)
|
67
63
|
if (remoteTabs.value.length) return [{ label: '全部', value: '0' }, ...remoteTabs.value];
|
68
64
|
if (props.tabs.length) return props.tabs
|
69
65
|
return [{ label: '全部', value: '0' }]
|
@@ -87,7 +83,7 @@ watch(() => showTabs.value, () => {
|
|
87
83
|
|
88
84
|
watch(() => props.apiConfig, (nVal) => {
|
89
85
|
if (!nVal?.apiId) return
|
90
|
-
dataService.fetch({
|
86
|
+
dataService.fetch({}, { key: nVal.key, apiId: nVal.apiId, apiType: 'MULTIPLE_DATA_SEARCH' }).then(res => {
|
91
87
|
remoteTabs.value = (res.data ?? []).map(i => ({
|
92
88
|
label: i[props.labelKey],
|
93
89
|
value: i[props.valueKey],
|
@@ -146,4 +142,4 @@ watch(() => props.apiConfig, (nVal) => {
|
|
146
142
|
overflow: hidden;
|
147
143
|
white-space: nowrap;
|
148
144
|
}
|
149
|
-
</style>
|
145
|
+
</style>
|