@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.
@@ -0,0 +1,96 @@
1
+ <template>
2
+ <div class="ebiz-page-header">
3
+ <div>
4
+ <div style="display: flex; align-items: center;">
5
+ <t-breadcrumb>
6
+ <t-breadcrumb-item :to="{ path: '/' }">
7
+ <template #icon><t-icon name="home" /></template>首页
8
+ </t-breadcrumb-item>
9
+ <t-breadcrumb-item v-for="(item, index) in breadcrumbList" :key="index">
10
+ <template #icon v-if="item.icon">
11
+ <t-icon :name="item.icon" />
12
+ </template>
13
+ {{ item.title }}
14
+ </t-breadcrumb-item>
15
+ </t-breadcrumb>
16
+ </div>
17
+ <slot></slot>
18
+ </div>
19
+ <div style="display: flex; align-items: center;">
20
+ <slot name="right"></slot>
21
+ <div class="help-doc" @click="goToHelp">
22
+ <t-icon name="chat-bubble-help-filled"></t-icon>
23
+ <span>帮助文档</span>
24
+ </div>
25
+ </div>
26
+
27
+ </div>
28
+ </template>
29
+
30
+ <script setup>
31
+ import { ref, onMounted, watch } from 'vue'
32
+ import { useRouter, useRoute } from 'vue-router'
33
+ import { Breadcrumb as TBreadcrumb, BreadcrumbItem as TBreadcrumbItem, Icon as TIcon } from "tdesign-vue-next"
34
+
35
+ const router = useRouter()
36
+ const route = useRoute()
37
+
38
+ const breadcrumbList = ref([])
39
+
40
+ // 计算面包屑导航列表
41
+ const generateBreadcrumb = () => {
42
+ const matched = route.matched
43
+ if (!matched.length) return
44
+
45
+ const result = []
46
+ matched.forEach(route => {
47
+ if (route.meta && route.meta.title) {
48
+ result.push({
49
+ title: route.meta.title,
50
+ icon: route.meta.icon || '',
51
+ path: route.path
52
+ })
53
+ }
54
+ })
55
+
56
+ breadcrumbList.value = result
57
+ }
58
+
59
+ // 跳转到帮助文档页面
60
+ const goToHelp = () => {
61
+ router.push(`/help?route=${route.path}`)
62
+ }
63
+
64
+ // 监听路由变化
65
+ watch(() => route.path, () => {
66
+ generateBreadcrumb()
67
+ }, { immediate: true })
68
+
69
+ onMounted(() => {
70
+ generateBreadcrumb()
71
+ })
72
+ </script>
73
+
74
+ <style scoped>
75
+ .ebiz-page-header {
76
+ display: flex;
77
+ align-items: center;
78
+ justify-content: space-between;
79
+ }
80
+
81
+ .help-doc {
82
+ display: flex;
83
+ align-items: center;
84
+ color: var(--td-brand-color);
85
+ cursor: pointer;
86
+ transition: opacity 0.2s;
87
+ }
88
+
89
+ .help-doc:hover {
90
+ opacity: 0.8;
91
+ }
92
+
93
+ .help-doc span {
94
+ margin-left: 4px;
95
+ }
96
+ </style>
@@ -1,14 +1,15 @@
1
1
  <template>
2
- <tiny-select ref="selectRef" v-model="selectedValue" :options="options" :loading="loading" :remote="true"
3
- :remote-method="handleRemoteSearch" :multiple="multiple" :placeholder="placeholder" :clearable="clearable"
4
- :disabled="disabled" @change="handleChange" @focus="handleRemoteSearch">
5
- <template #prefix>
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
- </tiny-select>
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 TinySelect } from '@opentiny/vue';
23
- import dataService from "../apiService/simpleDataService";
23
+ import { Select as TSelect } from 'tdesign-vue-next';
24
+ import dataService from '../apiService/simpleDataService';
24
25
 
25
26
  const props = defineProps({
26
27
  /**
@@ -40,7 +41,9 @@ const props = defineProps({
40
41
  */
41
42
  queryParams: {
42
43
  type: Object,
43
- default: {}
44
+ default: () => ({
45
+ name: ''
46
+ })
44
47
  },
45
48
  /**
46
49
  * 是否多选
@@ -74,21 +77,54 @@ const props = defineProps({
74
77
  * 默认值
75
78
  */
76
79
  modelValue: {
77
- type: [String, Number],
80
+ type: [String, Number, Array],
78
81
  default: ''
79
82
  },
83
+ /**
84
+ * 选项配置
85
+ */
80
86
  optionsConfig: {
81
- labelField: '',//作为label的字段
82
- valueField: ''//作为value的字段
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: () => ({})
83
114
  }
84
115
  });
85
116
 
86
117
  const { modelValue, apiConfig, queryParams } = toRefs(props)
87
118
 
88
- const emit = defineEmits(['update:modelValue', 'change']);
119
+ const emit = defineEmits(['update:modelValue', 'change', 'focus', 'blur']);
89
120
 
90
121
  // 选中的值
91
- const selectedValue = computed(() => modelValue.value)
122
+ const selectedValue = computed({
123
+ get: () => modelValue.value,
124
+ set: (val) => {
125
+ emit('update:modelValue', val);
126
+ }
127
+ });
92
128
 
93
129
  // 选项列表
94
130
  const options = ref([]);
@@ -105,37 +141,60 @@ const focus = () => {
105
141
  };
106
142
 
107
143
  defineExpose({
108
- focus
144
+ focus,
145
+ selectRef,
146
+ options
109
147
  });
110
148
 
111
149
  // 远程搜索处理函数
112
- const handleRemoteSearch = async () => {
113
- //if (options.value?.length > 0) return
114
-
150
+ const handleRemoteSearch = async (keyword) => {
115
151
  loading.value = true;
116
- if (apiConfig.value.apiId && apiConfig.value.apiType >= 0) {
117
- try {
118
- const params = {
119
- queryParams: queryParams.value
120
- };
121
- const res = await dataService.fetch(params, { key: props.apiConfig.key, apiId: props.apiConfig.apiId, apiType: 'MULTIPLE_DATA_SEARCH' });
122
- options.value = res.data.map(item => ({
123
- label: item.label || item.name,
124
- value: item.value || item.id
125
- }));
126
- } catch (error) {
127
- console.error('远程搜索失败:', error);
128
- options.value = [];
129
- } finally {
130
- loading.value = false;
131
- }
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('');
132
186
  }
133
187
  };
134
188
 
189
+ // 处理失去焦点事件
190
+ const handleBlur = (value, context) => {
191
+ emit('blur', value, context);
192
+ };
193
+
135
194
  // 值变化处理函数
136
- const handleChange = (value) => {
195
+ const handleChange = (value, context) => {
137
196
  emit('update:modelValue', value);
138
- emit('change', value);
197
+ emit('change', value, context);
139
198
  };
140
199
 
141
200
  // 组件挂载时,如果有默认值则加载对应的选项
@@ -146,10 +205,17 @@ onMounted(async () => {
146
205
  const params = {
147
206
  queryParams: queryParams.value
148
207
  };
149
- const res = await dataService.fetch(params, { apiId: props.apiConfig.apiId, apiType: 'MULTIPLE_DATA_SEARCH' });
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
+
150
215
  options.value = res.data.map(item => ({
151
- label: item.label || item.name,
152
- value: item.value || item.id
216
+ ...item,
217
+ label: labelField ? item[labelField] : (item.label || item.name),
218
+ value: valueField ? item[valueField] : (item.value || item.id)
153
219
  }));
154
220
  } catch (error) {
155
221
  console.error('加载默认选项失败:', error);
@@ -157,12 +223,11 @@ onMounted(async () => {
157
223
  loading.value = false;
158
224
  }
159
225
  }
160
-
161
226
  });
162
227
  </script>
163
228
 
164
229
  <style scoped>
165
- .tiny-select {
230
+ .t-select {
166
231
  width: 100%;
167
232
  }
168
233
  </style>