@ebiz/designer-components 0.0.18-beta.3 → 0.0.18-beta.4

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-beta.3",
3
+ "version": "0.0.18-beta.4",
4
4
  "private": false,
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -4,11 +4,11 @@
4
4
  * 所有接口均使用POST方法提交
5
5
  */
6
6
 
7
- import axios from "axios";
8
- import { TinyNotify } from "@opentiny/vue";
7
+ import axios from 'axios'
8
+ import { TinyNotify } from '@opentiny/vue'
9
9
 
10
10
  // 从环境变量获取API基础URL
11
- const API_BASE_URL = "http://localhost:8090/api";
11
+ const API_BASE_URL = 'http://localhost:8090/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
- "Content-Type": "application/json",
21
- Accept: "application/json",
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("token");
31
+ const token = localStorage.getItem('token')
32
32
  if (token) {
33
- config.headers["Authorization"] = `Bearer ${token}`;
33
+ config.headers['Authorization'] = `Bearer ${token}`
34
34
  }
35
-
35
+
36
36
  // 如果是FormData格式,不设置Content-Type,让浏览器自动设置
37
37
  if (config.data instanceof FormData) {
38
- config.headers["Content-Type"] = undefined;
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: "warning",
72
- title: "未授权",
73
- message: "您无权限访问,请授权后重试",
74
- position: "top-right",
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: "warning",
81
- title: "权限不足",
82
- message: "禁止访问,权限不足",
83
- position: "top-right",
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: "warning",
90
- title: "404",
91
- message: "请求的资源不存在",
92
- position: "top-right",
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: "warning",
99
- title: "错误",
100
- message: "服务器内部错误",
101
- position: "top-right",
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: "warning",
108
- title: "请求失败",
107
+ type: 'warning',
108
+ title: '请求失败',
109
109
  message: error.message,
110
- position: "top-right",
111
- duration: 2000,
112
- });
110
+ position: 'top-right',
111
+ duration: 2000
112
+ })
113
113
  }
114
114
  } else {
115
115
  TinyNotify({
116
- type: "error",
117
- title: "网络错误",
116
+ type: 'error',
117
+ title: '网络错误',
118
118
  message: error.message,
119
- position: "top-right",
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: "/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
- };
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 = "", ...restConfig } = apiConfig;
162
+ const { apiId = '', ...restConfig } = apiConfig
163
163
 
164
164
  const defaultConfig = {
165
165
  // 默认列表查询配置
166
166
  headers: {
167
- "X-List-Query": "true",
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 = "", formData, onProgress = () => {}) => {
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
- const fixedFormData = new FormData();
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
- .then(response => {
256
- console.log('Upload server response:', response);
257
-
258
- // 处理文件路径
259
- // 如果返回的是相对路径,转换为完整URL
260
- if (typeof response === 'string' && !response.startsWith('http')) {
261
- // 判断路径是否以斜杠开头
262
- const baseUrl = API_BASE_URL.endsWith('/') ? API_BASE_URL.slice(0, -1) : API_BASE_URL;
263
- const filePath = response.startsWith('/') ? response : `/${response}`;
264
-
265
- // 构建完整URL
266
- const fullUrl = `${baseUrl}/files${filePath}`;
267
- console.log('Converted file path to full URL:', fullUrl);
268
- return fullUrl;
269
- }
270
-
271
- return response;
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
@@ -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
  })
@@ -30,6 +30,7 @@ const props = defineProps({
30
30
  type: Object,
31
31
  required: true,
32
32
  default: () => ({
33
+ key: null,
33
34
  apiId: null,
34
35
  apiType: ''
35
36
  })
@@ -117,7 +118,7 @@ const handleRemoteSearch = async () => {
117
118
  const params = {
118
119
  queryParams: queryParams.value
119
120
  };
120
- const res = await dataService.fetch(params, { apiId: props.apiConfig.apiId, apiType: 'MULTIPLE_DATA_SEARCH' });
121
+ const res = await dataService.fetch(params, { key: props.apiConfig.key, apiId: props.apiConfig.apiId, apiType: 'MULTIPLE_DATA_SEARCH' });
121
122
  options.value = res.data.map(item => ({
122
123
  label: item.label || item.name,
123
124
  value: item.value || item.id
@@ -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
- activeColor="#5e7ce0"
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
- console.log(props.tabs,66, 110)
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({ }, { apiId: nVal.apiId, apiType: 'MULTIPLE_DATA_SEARCH' }).then(res => {
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>
@@ -1,52 +1,51 @@
1
1
  <template>
2
2
  <div class="ebiz-title">
3
- <!-- <div class="color-block" :style="{ backgroundColor: color, width: `${blockWidth}px` }"></div> -->
4
- <!-- <div class="title-text">
3
+ <div class="color-block" :style="{ backgroundColor: color, width: `${blockWidth}px` }"></div>
4
+ <div class="title-text">
5
5
  <slot name="title">
6
6
  {{ displayTitle }}
7
7
  </slot>
8
- </div> -->
8
+ </div>
9
9
  </div>
10
10
  </template>
11
11
 
12
12
  <script setup>
13
+ import { defineProps, computed } from 'vue';
13
14
 
14
- // import { defineProps, computed } from 'vue';
15
+ /**
16
+ * EbizTitle 组件 - 带有色块的标题组件
17
+ * 支持自定义标题文本、色块颜色和色块宽度
18
+ * 包含一个按钮,点击时在标题后添加点号并触发事件
19
+ * 支持通过插槽自定义标题内容
20
+ */
21
+ const props = defineProps({
22
+ /**
23
+ * 标题文本 (当不使用插槽时显示)
24
+ */
25
+ title: {
26
+ type: String,
27
+ default: '标题'
28
+ },
29
+ /**
30
+ * 色块颜色,支持任何有效的CSS颜色值
31
+ */
32
+ color: {
33
+ type: String,
34
+ default: '#1890ff'
35
+ },
36
+ /**
37
+ * 色块宽度,单位为像素
38
+ */
39
+ blockWidth: {
40
+ type: Number,
41
+ default: 10
42
+ }
43
+ });
15
44
 
16
- // /**
17
- // * EbizTitle 组件 - 带有色块的标题组件
18
- // * 支持自定义标题文本、色块颜色和色块宽度
19
- // * 包含一个按钮,点击时在标题后添加点号并触发事件
20
- // * 支持通过插槽自定义标题内容
21
- // */
22
- // const props = defineProps({
23
- // /**
24
- // * 标题文本 (当不使用插槽时显示)
25
- // */
26
- // title: {
27
- // type: String,
28
- // default: '标题'
29
- // },
30
- // /**
31
- // * 色块颜色,支持任何有效的CSS颜色值
32
- // */
33
- // color: {
34
- // type: String,
35
- // default: '#1890ff'
36
- // },
37
- // /**
38
- // * 色块宽度,单位为像素
39
- // */
40
- // blockWidth: {
41
- // type: Number,
42
- // default: 10
43
- // }
44
- // });
45
45
 
46
- // // // 计算属性:根据点号数量生成显示的标题
47
- // const displayTitle = computed(() => {
48
- // return props.title;
49
- // });
46
+ const displayTitle = computed(() => {
47
+ return props.title;
48
+ });
50
49
  </script>
51
50
 
52
51
  <style scoped>