@ebiz/designer-components 0.0.18-kzy.3 → 0.0.18-kzy.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ebiz/designer-components",
3
- "version": "0.0.18-kzy.3",
3
+ "version": "0.0.18-kzy.5",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -8,9 +8,9 @@ import axios from 'axios'
8
8
  import { TinyNotify } from '@opentiny/vue'
9
9
 
10
10
  // 本地开发使用
11
- // const API_BASE_URL = "http://localhost:8090/api";
11
+ const API_BASE_URL = "http://localhost:8090/api";
12
12
  // 组件发布使用
13
- const API_BASE_URL = 'http://' + window.location.host + '/api'
13
+ // const API_BASE_URL = 'http://' + window.location.host + '/api'
14
14
 
15
15
  /**
16
16
  * 创建axios实例
@@ -59,7 +59,10 @@ axiosInstance.interceptors.response.use(
59
59
  return data.data
60
60
  } else {
61
61
  // message.error(data.message || '请求失败');
62
- return Promise.reject(new Error(data.message || data.msg || '请求失败'))
62
+ return Promise.reject({
63
+ code: data.code,
64
+ message: data.message || data.msg || '请求失败'
65
+ })
63
66
  }
64
67
  },
65
68
  (error) => {
@@ -175,7 +178,7 @@ const dataService = {
175
178
  }
176
179
  params.apiId = apiConfig.apiId
177
180
  if (apiConfig.key) {
178
- params.key = apiConfig.key
181
+ params.apiKey = apiConfig.key
179
182
  }
180
183
 
181
184
  const config = { ...defaultConfig, ...restConfig }
@@ -41,7 +41,7 @@ const props = defineProps({
41
41
  },
42
42
  size: {//'large' | 'medium' | 'small' | 'mini'
43
43
  type: String,
44
- default: 'medium'
44
+ default: ''
45
45
  },
46
46
  apiConfig: {//接口配置
47
47
  type: Object,
@@ -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>
@@ -0,0 +1,238 @@
1
+ <template>
2
+ <t-select ref="selectRef" v-model="selectedValue" :loading="loading" :filterable="true" @search="handleRemoteSearch"
3
+ :multiple="multiple" :placeholder="placeholder" :clearable="clearable" :disabled="disabled" :size="size"
4
+ :empty="emptyText" :popupProps="popupProps" @change="handleChange" @focus="handleFocus" @blur="handleBlur">
5
+ <t-option v-for="item in options" :key="item.value" :value="item.value" :label="item.label"
6
+ @click="handleClick(item.value)"></t-option>
7
+ <template #prefixIcon v-if="$slots.prefix">
8
+ <slot name="prefix"></slot>
9
+ </template>
10
+ <template #suffixIcon v-if="$slots.suffix">
11
+ <slot name="suffix"></slot>
12
+ </template>
13
+ </t-select>
14
+ </template>
15
+
16
+ <script>
17
+ export default {
18
+ name: "EbizRemoteSelect"
19
+ }
20
+ </script>
21
+
22
+ <script setup>
23
+ import { ref, onMounted, toRefs, computed } from 'vue';
24
+ import { Select as TSelect, Option as TOption } from '@opentiny/vue';
25
+ import dataService from '../apiService/simpleDataService';
26
+
27
+ const props = defineProps({
28
+ /**
29
+ * API配置
30
+ */
31
+ apiConfig: {
32
+ type: Object,
33
+ required: true,
34
+ default: () => ({
35
+ key: null,
36
+ apiId: null,
37
+ apiType: ''
38
+ })
39
+ },
40
+ /**
41
+ * 查询参数
42
+ */
43
+ queryParams: {
44
+ type: Object,
45
+ default: () => ({
46
+ name: ''
47
+ })
48
+ },
49
+ /**
50
+ * 是否多选
51
+ */
52
+ multiple: {
53
+ type: Boolean,
54
+ default: false
55
+ },
56
+ /**
57
+ * 占位符文本
58
+ */
59
+ placeholder: {
60
+ type: String,
61
+ default: '请选择'
62
+ },
63
+ /**
64
+ * 是否可清空
65
+ */
66
+ clearable: {
67
+ type: Boolean,
68
+ default: true
69
+ },
70
+ /**
71
+ * 是否禁用
72
+ */
73
+ disabled: {
74
+ type: Boolean,
75
+ default: false
76
+ },
77
+ /**
78
+ * 默认值
79
+ */
80
+ modelValue: {
81
+ type: [String, Number, Array],
82
+ default: ''
83
+ },
84
+ /**
85
+ * 选项配置
86
+ */
87
+ labelField: {
88
+ type: String,
89
+ default: ''
90
+ },
91
+ valueField: {
92
+ type: String,
93
+ default: ''
94
+ },
95
+ /**
96
+ * 组件尺寸
97
+ */
98
+ size: {
99
+ type: String,
100
+ default: '',
101
+ validator: (val) => ['small', 'medium', 'large'].includes(val)
102
+ },
103
+ /**
104
+ * 空数据文本
105
+ */
106
+ emptyText: {
107
+ type: String,
108
+ default: '暂无数据'
109
+ },
110
+ /**
111
+ * 弹出层配置
112
+ */
113
+ popupProps: {
114
+ type: Object,
115
+ default: () => ({})
116
+ }
117
+ });
118
+
119
+ const { modelValue, apiConfig, labelField, valueField, queryParams } = toRefs(props)
120
+
121
+ const emit = defineEmits(['update:modelValue', 'change', 'selectOption', 'focus', 'blur']);
122
+
123
+ // 选中的值
124
+ const selectedValue = computed({
125
+ get: () => modelValue.value,
126
+ set: (val) => {
127
+ emit('update:modelValue', val);
128
+ }
129
+ });
130
+
131
+ // 选项列表
132
+ const options = ref([]);
133
+
134
+ // 加载状态
135
+ const loading = ref(false);
136
+
137
+ // 获取select组件实例
138
+ const selectRef = ref(null);
139
+
140
+ // 暴露focus方法
141
+ const focus = () => {
142
+ selectRef.value?.focus();
143
+ };
144
+
145
+ defineExpose({
146
+ focus,
147
+ selectRef,
148
+ options
149
+ });
150
+
151
+ // 远程搜索处理函数
152
+ const handleRemoteSearch = async (keyword) => {
153
+ loading.value = true;
154
+ try {
155
+ const params = {
156
+ queryParams: {
157
+ ...queryParams.value,
158
+ name: keyword
159
+ }
160
+ };
161
+ const res = await dataService.fetch(params, {
162
+ key: props.apiConfig.key,
163
+ apiId: props.apiConfig.apiId,
164
+ apiType: 'MULTIPLE_DATA_SEARCH'
165
+ });
166
+
167
+ options.value = res.data.map(item => ({
168
+ ...item,
169
+ label: labelField.value ? item[labelField.value] : (item.label || item.name),
170
+ value: valueField.value ? item[valueField.value] : (item.value || item.id)
171
+ }));
172
+ } catch (error) {
173
+ console.error('远程搜索失败:', error);
174
+ options.value = [];
175
+ } finally {
176
+ loading.value = false;
177
+ }
178
+
179
+ };
180
+
181
+ // 处理获取焦点事件
182
+ const handleFocus = (value, context) => {
183
+ emit('focus', value, context);
184
+ // 当选项为空时,初始加载数据
185
+ if (options.value.length === 0) {
186
+ handleRemoteSearch('');
187
+ }
188
+ };
189
+
190
+ // 处理失去焦点事件
191
+ const handleBlur = (value, context) => {
192
+ emit('blur', value, context);
193
+ };
194
+
195
+ // 值变化处理函数
196
+ const handleChange = (value, context) => {
197
+ emit('update:modelValue', value);
198
+ emit('change', value, context);
199
+ if (value instanceof Array) {
200
+ emit('selectOption', options.value.filter(item => value.includes(item.value)));
201
+ } else {
202
+ emit('selectOption', options.value.find(item => item.value === value));
203
+ }
204
+ };
205
+
206
+ // 组件挂载时,如果有默认值则加载对应的选项
207
+ onMounted(async () => {
208
+ if (apiConfig.value.apiId && apiConfig.value.apiType >= 0) {
209
+ loading.value = true;
210
+ try {
211
+ const params = {
212
+ queryParams: queryParams.value
213
+ };
214
+ const res = await dataService.fetch(params, {
215
+ key: props.apiConfig.key,
216
+ apiId: props.apiConfig.apiId,
217
+ apiType: 'MULTIPLE_DATA_SEARCH'
218
+ });
219
+
220
+ options.value = res.data.map(item => ({
221
+ ...item,
222
+ label: labelField.value ? item[labelField.value] : (item.label || item.name),
223
+ value: valueField.value ? item[valueField.value] : (item.value || item.id)
224
+ }));
225
+ } catch (error) {
226
+ console.error('加载默认选项失败:', error);
227
+ } finally {
228
+ loading.value = false;
229
+ }
230
+ }
231
+ });
232
+ </script>
233
+
234
+ <style scoped>
235
+ .t-select {
236
+ width: 100%;
237
+ }
238
+ </style>
@@ -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>