@ebiz/designer-components 0.0.18-beta.1 → 0.0.18-beta.10
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 +133 -131
- package/src/components/Button.vue +3 -2
- package/src/components/EbizAvatar.vue +116 -0
- package/src/components/EbizEmployeeInfo.vue +139 -0
- package/src/components/EbizRemoteSelect.vue +99 -41
- package/src/components/EbizStatistic.vue +150 -0
- package/src/components/EbizTabHeader.vue +6 -10
- package/src/components/EbizTabPanel.vue +23 -0
- package/src/components/EbizTabs.vue +143 -0
- package/src/components/TdesignAlert.vue +116 -0
- package/src/components/TdesignCalendar/index.vue +6 -3
- package/src/components/TdesignDialog.vue +221 -0
- package/src/components/TdesignInput.vue +23 -23
- package/src/components/TdesignTimeline.vue +58 -0
- package/src/components/TdesignTimelineItem.vue +72 -0
- package/src/components/TdesignUpload.vue +67 -98
- package/src/components/TdesignWatermark.vue +108 -0
- package/src/index.js +79 -45
- package/src/main.js +2 -2
- package/src/router/index.js +48 -0
- package/src/views/DialogDemo.vue +126 -0
- package/src/views/EbizAvatar.vue +224 -0
- package/src/views/EbizEmployeeInfo.vue +250 -0
- package/src/views/Home.vue +9 -1
- package/src/views/RemoteSelect.vue +336 -5
- package/src/views/StatisticDemo.vue +191 -0
- package/src/views/TabsDemo.vue +283 -0
- package/src/views/TdesignAlert.vue +99 -0
- package/src/views/TimelineDemo.vue +161 -0
- package/src/views/WatermarkDemo.vue +86 -0
package/package.json
CHANGED
@@ -0,0 +1,116 @@
|
|
1
|
+
/**
|
2
|
+
* 模拟数据服务
|
3
|
+
* 用于组件演示,提供模拟的远程数据查询
|
4
|
+
*/
|
5
|
+
|
6
|
+
// 模拟用户数据
|
7
|
+
const mockUsers = [
|
8
|
+
{ id: '1', name: '张三', email: 'zhangsan@example.com', department: '研发部' },
|
9
|
+
{ id: '2', name: '李四', email: 'lisi@example.com', department: '市场部' },
|
10
|
+
{ id: '3', name: '王五', email: 'wangwu@example.com', department: '设计部' },
|
11
|
+
{ id: '4', name: '赵六', email: 'zhaoliu@example.com', department: '人力资源部' },
|
12
|
+
{ id: '5', name: '钱七', email: 'qianqi@example.com', department: '财务部' },
|
13
|
+
{ id: '6', name: '孙八', email: 'sunba@example.com', department: '行政部' },
|
14
|
+
{ id: '7', name: '周九', email: 'zhoujiu@example.com', department: '销售部' },
|
15
|
+
{ id: '8', name: '吴十', email: 'wushi@example.com', department: '客服部' },
|
16
|
+
{ id: '9', name: '郑十一', email: 'zhengshiyi@example.com', department: '研发部' },
|
17
|
+
{ id: '10', name: '王十二', email: 'wangshier@example.com', department: '市场部' },
|
18
|
+
{ id: '11', name: '刘十三', email: 'liushisan@example.com', department: '设计部' },
|
19
|
+
{ id: '12', name: '陈十四', email: 'chenshisi@example.com', department: '人力资源部' },
|
20
|
+
{ id: '13', name: '杨十五', email: 'yangshiwu@example.com', department: '财务部' },
|
21
|
+
{ id: '14', name: '黄十六', email: 'huangshiliu@example.com', department: '行政部' },
|
22
|
+
{ id: '15', name: '赵十七', email: 'zhaoshiqi@example.com', department: '销售部' }
|
23
|
+
];
|
24
|
+
|
25
|
+
// 模拟产品数据
|
26
|
+
const mockProducts = [
|
27
|
+
{ id: 'p1', name: '笔记本电脑', price: 5999, category: '电子产品' },
|
28
|
+
{ id: 'p2', name: '智能手机', price: 3999, category: '电子产品' },
|
29
|
+
{ id: 'p3', name: '平板电脑', price: 2999, category: '电子产品' },
|
30
|
+
{ id: 'p4', name: '智能手表', price: 1999, category: '电子产品' },
|
31
|
+
{ id: 'p5', name: '耳机', price: 799, category: '电子产品' },
|
32
|
+
{ id: 'p6', name: '办公桌', price: 1299, category: '办公家具' },
|
33
|
+
{ id: 'p7', name: '办公椅', price: 899, category: '办公家具' },
|
34
|
+
{ id: 'p8', name: '文件柜', price: 1099, category: '办公家具' },
|
35
|
+
{ id: 'p9', name: '书架', price: 799, category: '办公家具' },
|
36
|
+
{ id: 'p10', name: '打印机', price: 1599, category: '办公设备' }
|
37
|
+
];
|
38
|
+
|
39
|
+
// 模拟城市数据
|
40
|
+
const mockCities = [
|
41
|
+
{ id: 'c1', name: '北京', code: 'BJ', population: 21893095 },
|
42
|
+
{ id: 'c2', name: '上海', code: 'SH', population: 24870895 },
|
43
|
+
{ id: 'c3', name: '广州', code: 'GZ', population: 18676605 },
|
44
|
+
{ id: 'c4', name: '深圳', code: 'SZ', population: 17494398 },
|
45
|
+
{ id: 'c5', name: '成都', code: 'CD', population: 16580376 },
|
46
|
+
{ id: 'c6', name: '杭州', code: 'HZ', population: 10360391 },
|
47
|
+
{ id: 'c7', name: '武汉', code: 'WH', population: 12326500 },
|
48
|
+
{ id: 'c8', name: '西安', code: 'XA', population: 12952907 },
|
49
|
+
{ id: 'c9', name: '重庆', code: 'CQ', population: 31243200 },
|
50
|
+
{ id: 'c10', name: '南京', code: 'NJ', population: 8335000 }
|
51
|
+
];
|
52
|
+
|
53
|
+
// 数据映射
|
54
|
+
const dataMap = {
|
55
|
+
mockUserList: mockUsers.map(user => ({
|
56
|
+
id: user.id,
|
57
|
+
name: user.name,
|
58
|
+
label: `${user.name} (${user.department})`,
|
59
|
+
value: user.id
|
60
|
+
})),
|
61
|
+
mockProductList: mockProducts.map(product => ({
|
62
|
+
id: product.id,
|
63
|
+
name: product.name,
|
64
|
+
label: `${product.name} - ¥${product.price}`,
|
65
|
+
value: product.id
|
66
|
+
})),
|
67
|
+
mockCityList: mockCities.map(city => ({
|
68
|
+
id: city.id,
|
69
|
+
name: city.name,
|
70
|
+
label: city.name,
|
71
|
+
value: city.id
|
72
|
+
}))
|
73
|
+
};
|
74
|
+
|
75
|
+
/**
|
76
|
+
* 模拟数据获取函数
|
77
|
+
* @param {Object} params - 请求参数
|
78
|
+
* @param {Object} apiConfig - API配置
|
79
|
+
* @returns {Promise<Object>} 响应数据
|
80
|
+
*/
|
81
|
+
const mockFetch = (params, apiConfig) => {
|
82
|
+
return new Promise((resolve) => {
|
83
|
+
console.log('Mock fetch params:', params);
|
84
|
+
console.log('Mock fetch apiConfig:', apiConfig);
|
85
|
+
|
86
|
+
// 模拟网络延迟
|
87
|
+
setTimeout(() => {
|
88
|
+
let result = [];
|
89
|
+
const { apiId } = apiConfig;
|
90
|
+
const keyword = params?.queryParams?.keyword || '';
|
91
|
+
|
92
|
+
// 根据API ID获取对应的数据
|
93
|
+
if (dataMap[apiId]) {
|
94
|
+
result = dataMap[apiId];
|
95
|
+
|
96
|
+
// 如果有关键字,进行筛选
|
97
|
+
if (keyword) {
|
98
|
+
result = result.filter(item =>
|
99
|
+
item.label.toLowerCase().includes(keyword.toLowerCase()) ||
|
100
|
+
item.name.toLowerCase().includes(keyword.toLowerCase())
|
101
|
+
);
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
resolve({
|
106
|
+
code: 0,
|
107
|
+
data: result,
|
108
|
+
message: 'success'
|
109
|
+
});
|
110
|
+
}, 500); // 模拟 500ms 延迟
|
111
|
+
});
|
112
|
+
};
|
113
|
+
|
114
|
+
export default {
|
115
|
+
fetch: mockFetch
|
116
|
+
};
|
@@ -4,11 +4,11 @@
|
|
4
4
|
* 所有接口均使用POST方法提交
|
5
5
|
*/
|
6
6
|
|
7
|
-
import axios from
|
8
|
-
import { TinyNotify } from
|
7
|
+
import axios from 'axios'
|
8
|
+
import { TinyNotify } from '@opentiny/vue'
|
9
9
|
|
10
10
|
// 从环境变量获取API基础URL
|
11
|
-
const API_BASE_URL =
|
11
|
+
const API_BASE_URL = 'http://' + window.location.host + '/api'
|
12
12
|
|
13
13
|
/**
|
14
14
|
* 创建axios实例
|
@@ -17,10 +17,10 @@ const axiosInstance = axios.create({
|
|
17
17
|
baseURL: API_BASE_URL,
|
18
18
|
timeout: 30000,
|
19
19
|
headers: {
|
20
|
-
|
21
|
-
Accept:
|
22
|
-
}
|
23
|
-
})
|
20
|
+
'Content-Type': 'application/json',
|
21
|
+
Accept: 'application/json'
|
22
|
+
}
|
23
|
+
})
|
24
24
|
|
25
25
|
/**
|
26
26
|
* 请求拦截器
|
@@ -28,117 +28,117 @@ const axiosInstance = axios.create({
|
|
28
28
|
axiosInstance.interceptors.request.use(
|
29
29
|
(config) => {
|
30
30
|
// 添加认证信息
|
31
|
-
const token = localStorage.getItem(
|
31
|
+
const token = localStorage.getItem('token')
|
32
32
|
if (token) {
|
33
|
-
config.headers[
|
33
|
+
config.headers['AppDataAuthorization'] = `Bearer ${token}`
|
34
34
|
}
|
35
|
-
|
35
|
+
|
36
36
|
// 如果是FormData格式,不设置Content-Type,让浏览器自动设置
|
37
37
|
if (config.data instanceof FormData) {
|
38
|
-
config.headers[
|
38
|
+
config.headers['Content-Type'] = undefined
|
39
39
|
}
|
40
|
-
|
41
|
-
return config
|
40
|
+
|
41
|
+
return config
|
42
42
|
},
|
43
43
|
(error) => {
|
44
|
-
return Promise.reject(error)
|
44
|
+
return Promise.reject(error)
|
45
45
|
}
|
46
|
-
)
|
46
|
+
)
|
47
47
|
|
48
48
|
/**
|
49
49
|
* 响应拦截器
|
50
50
|
*/
|
51
51
|
axiosInstance.interceptors.response.use(
|
52
52
|
(response) => {
|
53
|
-
const { data } = response
|
53
|
+
const { data } = response
|
54
54
|
|
55
55
|
// 根据后端API的响应格式进行调整
|
56
56
|
if (data.code === 0) {
|
57
|
-
return data.data
|
57
|
+
return data.data
|
58
58
|
} else {
|
59
59
|
// message.error(data.message || '请求失败');
|
60
|
-
return Promise.reject(new Error(data.message || data.msg ||
|
60
|
+
return Promise.reject(new Error(data.message || data.msg || '请求失败'))
|
61
61
|
}
|
62
62
|
},
|
63
63
|
(error) => {
|
64
64
|
// 错误处理
|
65
65
|
if (error.response) {
|
66
|
-
const { status } = error.response
|
66
|
+
const { status } = error.response
|
67
67
|
|
68
68
|
switch (status) {
|
69
69
|
case 401:
|
70
70
|
TinyNotify({
|
71
|
-
type:
|
72
|
-
title:
|
73
|
-
message:
|
74
|
-
position:
|
75
|
-
duration: 2000
|
76
|
-
})
|
77
|
-
break
|
71
|
+
type: 'warning',
|
72
|
+
title: '未授权',
|
73
|
+
message: '您无权限访问,请授权后重试',
|
74
|
+
position: 'top-right',
|
75
|
+
duration: 2000
|
76
|
+
})
|
77
|
+
break
|
78
78
|
case 403:
|
79
79
|
TinyNotify({
|
80
|
-
type:
|
81
|
-
title:
|
82
|
-
message:
|
83
|
-
position:
|
84
|
-
duration: 2000
|
85
|
-
})
|
86
|
-
break
|
80
|
+
type: 'warning',
|
81
|
+
title: '权限不足',
|
82
|
+
message: '禁止访问,权限不足',
|
83
|
+
position: 'top-right',
|
84
|
+
duration: 2000
|
85
|
+
})
|
86
|
+
break
|
87
87
|
case 404:
|
88
88
|
TinyNotify({
|
89
|
-
type:
|
90
|
-
title:
|
91
|
-
message:
|
92
|
-
position:
|
93
|
-
duration: 2000
|
94
|
-
})
|
95
|
-
break
|
89
|
+
type: 'warning',
|
90
|
+
title: '404',
|
91
|
+
message: '请求的资源不存在',
|
92
|
+
position: 'top-right',
|
93
|
+
duration: 2000
|
94
|
+
})
|
95
|
+
break
|
96
96
|
case 500:
|
97
97
|
TinyNotify({
|
98
|
-
type:
|
99
|
-
title:
|
100
|
-
message:
|
101
|
-
position:
|
102
|
-
duration: 2000
|
103
|
-
})
|
104
|
-
break
|
98
|
+
type: 'warning',
|
99
|
+
title: '错误',
|
100
|
+
message: '服务器内部错误',
|
101
|
+
position: 'top-right',
|
102
|
+
duration: 2000
|
103
|
+
})
|
104
|
+
break
|
105
105
|
default:
|
106
106
|
TinyNotify({
|
107
|
-
type:
|
108
|
-
title:
|
107
|
+
type: 'warning',
|
108
|
+
title: '请求失败',
|
109
109
|
message: error.message,
|
110
|
-
position:
|
111
|
-
duration: 2000
|
112
|
-
})
|
110
|
+
position: 'top-right',
|
111
|
+
duration: 2000
|
112
|
+
})
|
113
113
|
}
|
114
114
|
} else {
|
115
115
|
TinyNotify({
|
116
|
-
type:
|
117
|
-
title:
|
116
|
+
type: 'error',
|
117
|
+
title: '网络错误',
|
118
118
|
message: error.message,
|
119
|
-
position:
|
120
|
-
duration: 2000
|
121
|
-
})
|
119
|
+
position: 'top-right',
|
120
|
+
duration: 2000
|
121
|
+
})
|
122
122
|
// message.error('网络错误,请检查您的网络连接');
|
123
123
|
}
|
124
124
|
|
125
|
-
return Promise.reject(error)
|
125
|
+
return Promise.reject(error)
|
126
126
|
}
|
127
|
-
)
|
127
|
+
)
|
128
128
|
|
129
129
|
let apiMap = {
|
130
|
-
MULTIPLE_DATA_SEARCH:
|
131
|
-
DETAILS_DATA:
|
132
|
-
INTERFACE_PLUGIN:
|
133
|
-
DATA_INSERT:
|
134
|
-
BATCH_DATA_INSERT:
|
135
|
-
DATA_MODIFY:
|
136
|
-
BATCH_DATA_MODIFY:
|
137
|
-
DEL_DATA:
|
138
|
-
BATCH_DEL_DATA:
|
139
|
-
MULTIPLE_DATA_LINK_SEARCH:
|
140
|
-
FILE_UPLOAD:
|
141
|
-
}
|
130
|
+
MULTIPLE_DATA_SEARCH: '/appdata/select',
|
131
|
+
DETAILS_DATA: '/appdata/detailData',
|
132
|
+
INTERFACE_PLUGIN: '/appdata/plugin',
|
133
|
+
DATA_INSERT: '/appdata/addData',
|
134
|
+
BATCH_DATA_INSERT: '/appdata/addDatas',
|
135
|
+
DATA_MODIFY: '/appdata/updateData',
|
136
|
+
BATCH_DATA_MODIFY: '/appdata/updateDatas',
|
137
|
+
DEL_DATA: '/appdata/delData',
|
138
|
+
BATCH_DEL_DATA: '/appdata/delDatas',
|
139
|
+
MULTIPLE_DATA_LINK_SEARCH: '/api/appdata/link/select',
|
140
|
+
FILE_UPLOAD: '/api/file/upload' // 文件上传API
|
141
|
+
}
|
142
142
|
|
143
143
|
/**
|
144
144
|
* 数据服务
|
@@ -154,29 +154,32 @@ const dataService = {
|
|
154
154
|
* @returns {Promise<any>} 响应数据
|
155
155
|
* @example
|
156
156
|
*/
|
157
|
-
fetch: (params = {}, apiConfig = {}, url =
|
157
|
+
fetch: (params = {}, apiConfig = {}, url = '') => {
|
158
158
|
if (!url) {
|
159
|
-
url = apiMap[apiConfig.apiType]
|
159
|
+
url = apiMap[apiConfig.apiType]
|
160
160
|
}
|
161
161
|
|
162
|
-
const { apiId =
|
162
|
+
const { apiId = '', ...restConfig } = apiConfig
|
163
163
|
|
164
164
|
const defaultConfig = {
|
165
165
|
// 默认列表查询配置
|
166
166
|
headers: {
|
167
|
-
|
167
|
+
'X-List-Query': 'true'
|
168
168
|
},
|
169
|
-
timeout: 20000
|
170
|
-
}
|
169
|
+
timeout: 20000
|
170
|
+
}
|
171
171
|
if (!params) {
|
172
|
-
params = {}
|
172
|
+
params = {}
|
173
|
+
}
|
174
|
+
params.apiId = apiConfig.apiId
|
175
|
+
if (apiConfig.key) {
|
176
|
+
params.key = apiConfig.key
|
173
177
|
}
|
174
|
-
params.apiId = apiConfig.apiId;
|
175
178
|
|
176
|
-
const config = { ...defaultConfig, ...restConfig }
|
177
|
-
return axiosInstance.post(url, params, config)
|
179
|
+
const config = { ...defaultConfig, ...restConfig }
|
180
|
+
return axiosInstance.post(url, params, config)
|
178
181
|
},
|
179
|
-
|
182
|
+
|
180
183
|
/**
|
181
184
|
* 文件上传
|
182
185
|
* @param {string} url - 上传URL,默认使用apiMap中的FILE_UPLOAD
|
@@ -184,16 +187,16 @@ const dataService = {
|
|
184
187
|
* @param {Function} onProgress - 上传进度回调函数,参数为0-100的进度百分比
|
185
188
|
* @returns {Promise<any>} 上传响应数据
|
186
189
|
*/
|
187
|
-
upload: (url =
|
190
|
+
upload: (url = '', formData, onProgress = () => {}) => {
|
188
191
|
// 如果没有指定URL,使用默认的文件上传URL
|
189
192
|
if (!url) {
|
190
|
-
url = apiMap.FILE_UPLOAD
|
193
|
+
url = apiMap.FILE_UPLOAD
|
191
194
|
}
|
192
|
-
|
195
|
+
|
193
196
|
// 确保FormData中的文件字段名是'file'
|
194
|
-
|
195
|
-
let fileFound = false
|
196
|
-
|
197
|
+
let fixedFormData = new FormData()
|
198
|
+
let fileFound = false
|
199
|
+
|
197
200
|
// 检查并修复FormData
|
198
201
|
if (formData instanceof FormData) {
|
199
202
|
// 由于FormData不能直接检查内容,我们使用迭代器
|
@@ -201,40 +204,40 @@ const dataService = {
|
|
201
204
|
// 在某些旧浏览器中可能不支持entries()
|
202
205
|
if (typeof formData.entries === 'function') {
|
203
206
|
for (let pair of formData.entries()) {
|
204
|
-
const [key, value] = pair
|
205
|
-
|
207
|
+
const [key, value] = pair
|
208
|
+
|
206
209
|
if (value instanceof File || value instanceof Blob) {
|
207
210
|
// 找到文件,使用正确的字段名
|
208
|
-
console.log(`Found file in field ${key}, adding as 'file'`)
|
209
|
-
fixedFormData.append('file', value)
|
210
|
-
fileFound = true
|
211
|
+
console.log(`Found file in field ${key}, adding as 'file'`)
|
212
|
+
fixedFormData.append('file', value)
|
213
|
+
fileFound = true
|
211
214
|
} else {
|
212
215
|
// 保留其他字段
|
213
|
-
fixedFormData.append(key, value)
|
216
|
+
fixedFormData.append(key, value)
|
214
217
|
}
|
215
218
|
}
|
216
219
|
} else {
|
217
220
|
// 如果不支持entries(),假设formData已经是正确的,直接使用
|
218
|
-
console.log('FormData.entries() not supported, using original FormData')
|
219
|
-
fixedFormData = formData
|
220
|
-
fileFound = true
|
221
|
+
console.log('FormData.entries() not supported, using original FormData')
|
222
|
+
fixedFormData = formData
|
223
|
+
fileFound = true
|
221
224
|
}
|
222
225
|
} catch (e) {
|
223
|
-
console.error('Error processing FormData:', e)
|
226
|
+
console.error('Error processing FormData:', e)
|
224
227
|
// 出错时使用原始FormData
|
225
|
-
fixedFormData = formData
|
228
|
+
fixedFormData = formData
|
226
229
|
}
|
227
230
|
} else {
|
228
|
-
console.error('Invalid FormData:', formData)
|
229
|
-
return Promise.reject(new Error('FormData is required for file upload'))
|
231
|
+
console.error('Invalid FormData:', formData)
|
232
|
+
return Promise.reject(new Error('FormData is required for file upload'))
|
230
233
|
}
|
231
|
-
|
234
|
+
|
232
235
|
// 如果没有找到文件,返回错误
|
233
236
|
if (!fileFound && typeof formData.entries === 'function') {
|
234
|
-
console.error('No file found in FormData')
|
235
|
-
return Promise.reject(new Error('No file found in FormData'))
|
237
|
+
console.error('No file found in FormData')
|
238
|
+
return Promise.reject(new Error('No file found in FormData'))
|
236
239
|
}
|
237
|
-
|
240
|
+
|
238
241
|
// 上传配置
|
239
242
|
const config = {
|
240
243
|
timeout: 60000, // 上传超时时间加长
|
@@ -244,33 +247,32 @@ const dataService = {
|
|
244
247
|
},
|
245
248
|
onUploadProgress: (progressEvent) => {
|
246
249
|
// 计算上传进度百分比
|
247
|
-
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
248
|
-
onProgress(percentCompleted)
|
250
|
+
const percentCompleted = Math.round((progressEvent.loaded * 100) / progressEvent.total)
|
251
|
+
onProgress(percentCompleted)
|
249
252
|
}
|
250
|
-
}
|
251
|
-
|
253
|
+
}
|
254
|
+
|
252
255
|
// 发起上传请求
|
253
|
-
console.log('Sending file upload request to:', url)
|
254
|
-
return axiosInstance.post(url, fixedFormData, config)
|
255
|
-
.
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
});
|
256
|
+
console.log('Sending file upload request to:', url)
|
257
|
+
return axiosInstance.post(url, fixedFormData, config).then((response) => {
|
258
|
+
console.log('Upload server response:', response)
|
259
|
+
|
260
|
+
// 处理文件路径
|
261
|
+
// 如果返回的是相对路径,转换为完整URL
|
262
|
+
if (typeof response === 'string' && !response.startsWith('http')) {
|
263
|
+
// 判断路径是否以斜杠开头
|
264
|
+
const baseUrl = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL
|
265
|
+
const filePath = response.startsWith('/') ? response : `/${response}`
|
266
|
+
|
267
|
+
// 构建完整URL
|
268
|
+
const fullUrl = `${baseUrl}/files${filePath}`
|
269
|
+
console.log('Converted file path to full URL:', fullUrl)
|
270
|
+
return fullUrl
|
271
|
+
}
|
272
|
+
|
273
|
+
return response
|
274
|
+
})
|
273
275
|
}
|
274
|
-
}
|
276
|
+
}
|
275
277
|
|
276
|
-
export default dataService
|
278
|
+
export default dataService
|
@@ -19,7 +19,7 @@ export default {
|
|
19
19
|
|
20
20
|
import { ref, reactive, computed, toRef, toRefs } from 'vue';
|
21
21
|
import { TinyButton, TinyTooltip, TinyNotify } from '@opentiny/vue';
|
22
|
-
import dataService from '../apiService/
|
22
|
+
import dataService from '../apiService/simpleDataServiceAppData';
|
23
23
|
|
24
24
|
|
25
25
|
const props = defineProps({
|
@@ -46,6 +46,7 @@ const props = defineProps({
|
|
46
46
|
apiConfig: {//接口配置
|
47
47
|
type: Object,
|
48
48
|
default: {
|
49
|
+
key: null,
|
49
50
|
apiId: null,
|
50
51
|
apiType: ''
|
51
52
|
}
|
@@ -91,7 +92,7 @@ const click = () => {
|
|
91
92
|
props.onClick()
|
92
93
|
if (!isNormal.value && apiConfig.value.apiId) {
|
93
94
|
props.onPrepare()
|
94
|
-
dataService.fetch(data.value, { apiId: apiConfig.value.apiId, apiType: apiMap[apiConfig.value.apiType] }).then((res) => {
|
95
|
+
dataService.fetch(data.value, { key: apiConfig.value.key, apiId: apiConfig.value.apiId, apiType: apiMap[apiConfig.value.apiType] }).then((res) => {
|
95
96
|
emit('click', res)
|
96
97
|
props.onFinish()
|
97
98
|
})
|
@@ -0,0 +1,116 @@
|
|
1
|
+
<template>
|
2
|
+
<t-avatar
|
3
|
+
:alt="alt"
|
4
|
+
:badge-props="badgeProps"
|
5
|
+
:content="content"
|
6
|
+
:hide-on-load-error="hideOnLoadError"
|
7
|
+
:image="image"
|
8
|
+
:image-props="imageProps"
|
9
|
+
:shape="shape"
|
10
|
+
:size="size"
|
11
|
+
:style="customStyle"
|
12
|
+
@error="handleError"
|
13
|
+
>
|
14
|
+
<!-- 图标插槽 -->
|
15
|
+
<template v-if="$slots.icon" #icon>
|
16
|
+
<slot name="icon"></slot>
|
17
|
+
</template>
|
18
|
+
|
19
|
+
<!-- 内容插槽 -->
|
20
|
+
<template v-if="$slots.content" #content>
|
21
|
+
<slot name="content"></slot>
|
22
|
+
</template>
|
23
|
+
|
24
|
+
<!-- 默认插槽 -->
|
25
|
+
<slot>{{ content }}</slot>
|
26
|
+
</t-avatar>
|
27
|
+
</template>
|
28
|
+
|
29
|
+
<script>
|
30
|
+
export default {
|
31
|
+
name: "EbizAvatar"
|
32
|
+
}
|
33
|
+
</script>
|
34
|
+
|
35
|
+
<script setup>
|
36
|
+
import { defineProps, defineEmits, computed } from 'vue';
|
37
|
+
import { Avatar as TAvatar } from 'tdesign-vue-next';
|
38
|
+
|
39
|
+
const props = defineProps({
|
40
|
+
// 头像替代文本
|
41
|
+
alt: {
|
42
|
+
type: String,
|
43
|
+
default: ''
|
44
|
+
},
|
45
|
+
// 徽标属性
|
46
|
+
badgeProps: {
|
47
|
+
type: Object,
|
48
|
+
default: () => ({})
|
49
|
+
},
|
50
|
+
// 头像内容
|
51
|
+
content: {
|
52
|
+
type: [String, Function],
|
53
|
+
default: ''
|
54
|
+
},
|
55
|
+
// 图片加载失败时是否隐藏
|
56
|
+
hideOnLoadError: {
|
57
|
+
type: Boolean,
|
58
|
+
default: false
|
59
|
+
},
|
60
|
+
// 头像图片地址
|
61
|
+
image: {
|
62
|
+
type: String,
|
63
|
+
default: ''
|
64
|
+
},
|
65
|
+
// 图片属性
|
66
|
+
imageProps: {
|
67
|
+
type: Object,
|
68
|
+
default: () => ({})
|
69
|
+
},
|
70
|
+
// 头像形状
|
71
|
+
shape: {
|
72
|
+
type: String,
|
73
|
+
default: 'circle',
|
74
|
+
validator: (val) => ['circle', 'round'].includes(val)
|
75
|
+
},
|
76
|
+
// 头像尺寸
|
77
|
+
size: {
|
78
|
+
type: String,
|
79
|
+
default: 'medium',
|
80
|
+
validator: (val) => ['small', 'medium', 'large'].includes(val) || /^(\d+px|\d+em|\d+rem|\d+%)$/.test(val)
|
81
|
+
},
|
82
|
+
// 自定义宽度
|
83
|
+
width: {
|
84
|
+
type: [String, Number],
|
85
|
+
default: ''
|
86
|
+
},
|
87
|
+
// 自定义高度
|
88
|
+
height: {
|
89
|
+
type: [String, Number],
|
90
|
+
default: ''
|
91
|
+
}
|
92
|
+
});
|
93
|
+
|
94
|
+
const emit = defineEmits(['error']);
|
95
|
+
|
96
|
+
// 处理图片加载错误事件
|
97
|
+
const handleError = (context) => {
|
98
|
+
emit('error', context);
|
99
|
+
};
|
100
|
+
|
101
|
+
// 计算样式
|
102
|
+
const customStyle = computed(() => {
|
103
|
+
const style = {};
|
104
|
+
if (props.width) {
|
105
|
+
style.width = typeof props.width === 'number' ? `${props.width}px` : props.width;
|
106
|
+
}
|
107
|
+
if (props.height) {
|
108
|
+
style.height = typeof props.height === 'number' ? `${props.height}px` : props.height;
|
109
|
+
}
|
110
|
+
return style;
|
111
|
+
});
|
112
|
+
</script>
|
113
|
+
|
114
|
+
<style lang="less" scoped>
|
115
|
+
/* 自定义样式 */
|
116
|
+
</style>
|