sohelp-eleplus 1.1.21 → 1.1.22

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.
Files changed (101) hide show
  1. package/cache/DictCache.js +38 -7
  2. package/cache/ModuleCache.js +18 -1
  3. package/cache/README.md +53 -0
  4. package/http/CrudHttp.js +70 -36
  5. package/http/DictHttp.js +5 -1
  6. package/http/ModuleHttp.js +26 -11
  7. package/http/README.md +50 -0
  8. package/http/SohelpHttp.js +48 -49
  9. package/package.json +1 -1
  10. package/sohelp-ace-editor/README.md +53 -0
  11. package/sohelp-application-select/README.md +15 -0
  12. package/sohelp-autocode/README.md +38 -0
  13. package/sohelp-autocode/index.vue +7 -7
  14. package/sohelp-calendar-view/README.md +15 -0
  15. package/sohelp-card/README.md +27 -0
  16. package/sohelp-card-view/README.md +15 -0
  17. package/sohelp-condition/README.md +61 -0
  18. package/sohelp-cry-input/README.md +30 -0
  19. package/sohelp-date/README.md +27 -0
  20. package/sohelp-datetime/README.md +29 -0
  21. package/sohelp-datetime-picker/README.md +36 -0
  22. package/sohelp-datetime-range/README.md +35 -0
  23. package/sohelp-dict/README.md +43 -0
  24. package/sohelp-dict/index.vue +42 -25
  25. package/sohelp-drawer/README.md +42 -0
  26. package/sohelp-drawer/index.vue +4 -1
  27. package/sohelp-drop-card/README.md +41 -0
  28. package/sohelp-dyn-select/README.md +36 -0
  29. package/sohelp-dyn-tree/README.md +31 -0
  30. package/sohelp-dyn-tree-select/README.md +28 -0
  31. package/sohelp-entity-form/README.md +45 -0
  32. package/sohelp-entity-form/index.vue +9 -4
  33. package/sohelp-entity-grid/README.md +18 -0
  34. package/sohelp-file-upload/README.md +35 -0
  35. package/sohelp-file-upload/index.vue +21 -3
  36. package/sohelp-filter-scheme/README.md +41 -0
  37. package/sohelp-grid/README.md +47 -0
  38. package/sohelp-grid/index.vue +40 -18
  39. package/sohelp-grid/js/DefaultGridOptions.js +2 -1
  40. package/sohelp-grid/js/useSohelpGridConfig.js +32 -4
  41. package/sohelp-grid-select/README.md +38 -0
  42. package/sohelp-grid-view/README.md +34 -0
  43. package/sohelp-grid-view/filter/README.md +45 -0
  44. package/sohelp-grid-view/filter/config/README.md +37 -0
  45. package/sohelp-grid-view/filter/filter-form.vue +15 -12
  46. package/sohelp-grid-view-select/README.md +36 -0
  47. package/sohelp-group-view/README.md +7 -0
  48. package/sohelp-icon-select/README.md +21 -0
  49. package/sohelp-image-upload/README.md +35 -0
  50. package/sohelp-import/README.md +35 -0
  51. package/sohelp-input/README.md +21 -0
  52. package/sohelp-modal/README.md +30 -0
  53. package/sohelp-modal/index.vue +2 -1
  54. package/sohelp-module/README.md +24 -0
  55. package/sohelp-number-input/README.md +18 -0
  56. package/sohelp-number-range/README.md +24 -0
  57. package/sohelp-org-select/README.md +20 -0
  58. package/sohelp-org-tree/README.md +18 -0
  59. package/sohelp-org-tree-select/README.md +22 -0
  60. package/sohelp-org-user-tree/README.md +18 -0
  61. package/sohelp-org-user-tree-select/README.md +7 -0
  62. package/sohelp-page/README.md +21 -0
  63. package/sohelp-pagination/README.md +13 -0
  64. package/sohelp-power/README.md +27 -0
  65. package/sohelp-pro-form/README.md +35 -0
  66. package/sohelp-pro-form/components/pro-form-item.vue +3 -2
  67. package/sohelp-pro-form/util.js +6 -13
  68. package/sohelp-pro-layout/README.md +7 -0
  69. package/sohelp-pro-table/README.md +13 -0
  70. package/sohelp-process/README.md +24 -0
  71. package/sohelp-rate/README.md +23 -0
  72. package/sohelp-relation/README.md +7 -0
  73. package/sohelp-rich-text/README.md +23 -0
  74. package/sohelp-richtext/README.md +3 -0
  75. package/sohelp-role-select/README.md +20 -0
  76. package/sohelp-search/README.md +7 -0
  77. package/sohelp-search-pro-form/README.md +3 -0
  78. package/sohelp-select/README.md +51 -0
  79. package/sohelp-split-panel/README.md +31 -0
  80. package/sohelp-switch/README.md +33 -0
  81. package/sohelp-table/README.md +36 -0
  82. package/sohelp-tenant-select/README.md +31 -0
  83. package/sohelp-text/README.md +17 -0
  84. package/sohelp-textarea-input/README.md +24 -0
  85. package/sohelp-textarea-input/index.vue +16 -11
  86. package/sohelp-time/README.md +22 -0
  87. package/sohelp-tree/README.md +32 -0
  88. package/sohelp-tree-select/README.md +18 -0
  89. package/sohelp-user-select/README.md +22 -0
  90. package/sohelp-user-tag/README.md +15 -0
  91. package/sohelp-user-tree/README.md +15 -0
  92. package/sohelp-vform-drawer/README.md +25 -0
  93. package/sohelp-vform-eleplus/README.md +39 -0
  94. package/sohelp-vform-modal/README.md +25 -0
  95. package/sohelp-vform-select/README.md +15 -0
  96. package/sohelp-vxe-grid/README.md +50 -0
  97. package/sohelp-vxe-grid-select/README.md +36 -0
  98. package/sohelp-vxe-table/README.md +27 -0
  99. package/sohelp-workflow/README.md +28 -0
  100. package/sohelp-workflow-drawer/README.md +38 -0
  101. package/sohelp-grid/SohelpGridConfig.js~ +0 -408
@@ -5,11 +5,21 @@ import { ElMessage } from 'element-plus';
5
5
  * 字典缓存
6
6
  */
7
7
  export class DictCache {
8
+ /**
9
+ * 构造函数
10
+ * 初始化缓存Map和并发请求Promise
11
+ */
8
12
  constructor() {
9
13
  this.cache = new Map(); // 使用 Map 作为缓存存储结构
10
14
  this.initPromise = null; // 防止并发重复请求
11
15
  }
12
- //初始化字典数据
16
+ /**
17
+ * 初始化字典数据
18
+ *
19
+ * 首次调用时从后端获取字典数据并缓存,后续调用直接返回Promise。
20
+ * 防止并发重复请求。
21
+ * @returns {Promise<void>}
22
+ */
13
23
  async init() {
14
24
  if (this.initPromise) return this.initPromise;
15
25
  this.initPromise = getDictData()
@@ -22,34 +32,55 @@ export class DictCache {
22
32
  await this.initPromise;
23
33
  this.initPromise = null;
24
34
  }
25
- //设置字典数据
35
+ /**
36
+ * 批量设置字典数据
37
+ * @param {Object} data 字典数据对象,key为字典编码,value为字典项列表
38
+ */
26
39
  setData(data) {
27
40
  for (let key in data) {
28
41
  this.set(key, data[key]);
29
42
  }
30
43
  }
31
- // 设置缓存
44
+ /**
45
+ * 设置缓存
46
+ * @param {string} key 字典编码
47
+ * @param {Array} value 字典项列表
48
+ */
32
49
  set(key, value) {
33
50
  this.cache.set(key, value);
34
51
  }
35
- // 获取缓存
52
+ /**
53
+ * 获取缓存
54
+ * 如果缓存为空,会先触发初始化
55
+ * @param {string} key 字典编码
56
+ * @returns {Promise<Array|null>} 字典项列表或null
57
+ */
36
58
  async get(key) {
37
59
  if (this.cache.size === 0) {
38
60
  await this.init();
39
61
  }
40
62
  return this.cache.has(key) ? this.cache.get(key) : null;
41
63
  }
42
- // 检查缓存是否存在
64
+ /**
65
+ * 检查缓存是否存在
66
+ * @param {string} key 字典编码
67
+ * @returns {boolean}
68
+ */
43
69
  has(key) {
44
70
  return this.cache.has(key);
45
71
  }
46
72
 
47
- // 删除缓存
73
+ /**
74
+ * 删除缓存
75
+ * @param {string} key 字典编码
76
+ */
48
77
  delete(key) {
49
78
  this.cache.delete(key);
50
79
  }
51
80
 
52
- // 清空缓存
81
+ /**
82
+ * 清空所有字典缓存
83
+ */
53
84
  clear() {
54
85
  this.cache.clear();
55
86
  }
@@ -6,6 +6,17 @@ import { ElMessage } from "element-plus";
6
6
  * 模块缓存
7
7
  */
8
8
  class ModuleCache {
9
+ /**
10
+ * 构造函数
11
+ *
12
+ * 初始化各类缓存Map:
13
+ * - moduleCache: 模块缓存
14
+ * - layoutCache: 布局缓存
15
+ * - gridCache: 网格缓存
16
+ * - entityFormCache: 实体表单缓存
17
+ * - entityGridCache: 实体网格缓存
18
+ * - workflowCache: 工作流缓存
19
+ */
9
20
  constructor() {
10
21
  // 使用 Map 作为缓存模块存储结构
11
22
  this.moduleCache = new Map();
@@ -147,7 +158,13 @@ class ModuleCache {
147
158
  }
148
159
 
149
160
 
150
- //获取缓存
161
+ /**
162
+ * 获取模块配置缓存
163
+ *
164
+ * 如果缓存中不存在,会尝试从后端加载并缓存。
165
+ * @param {string} refid 模块引用ID
166
+ * @returns {Promise<Object|null>} 模块配置对象或null
167
+ */
151
168
  async getModule(refid) {
152
169
  const moduleRef = refid.split("!")[0];
153
170
  if (!this.hasModule(refid)) {
@@ -0,0 +1,53 @@
1
+ # 缓存管理 (Cache)
2
+
3
+ 本文档列出了 `src/components/sohelp-eleplus/cache` 目录下的缓存管理类。这些类主要用于在前端缓存频繁访问的数据(如字典、模块配置),以减少网络请求并提升应用性能。
4
+
5
+ ## 1. DictCache (字典缓存)
6
+
7
+ 用于缓存系统字典数据。通常在应用启动或首次访问字典时加载所有字典数据,后续访问直接从内存中获取。
8
+
9
+ | 方法名 | 说明 | 参数 |
10
+ | :--- | :--- | :--- |
11
+ | `init()` | 初始化字典数据 | - |
12
+ | `get(key)` | 获取指定编码的字典项列表 | `key`: 字典编码<br>返回: `Promise<Array>` |
13
+ | `set(key, value)` | 手动设置字典缓存 | `key`: 字典编码<br>`value`: 字典项列表 |
14
+ | `has(key)` | 检查是否存在指定字典 | `key`: 字典编码 |
15
+ | `delete(key)` | 删除指定字典缓存 | `key`: 字典编码 |
16
+ | `clear()` | 清空所有字典缓存 | - |
17
+
18
+ **使用示例:**
19
+ ```javascript
20
+ import { dictCache } from './DictCache';
21
+
22
+ // 获取性别字典
23
+ const genderList = await dictCache.get('gender');
24
+ ```
25
+
26
+ ## 2. ModuleCache (模块配置缓存)
27
+
28
+ 用于缓存低代码模块的元数据配置,包括模块信息、布局、列表配置、表单配置和工作流配置。
29
+
30
+ | 方法名 | 说明 | 参数 |
31
+ | :--- | :--- | :--- |
32
+ | `init(refid)` | 初始化指定模块的配置 | `refid`: 模块引用ID |
33
+ | `getModule(refid)` | 获取模块基础信息 | `refid`: 模块引用ID |
34
+ | `getLayout(refid)` | 获取模块布局配置 | `refid`: 模块引用ID |
35
+ | `getGrid(refid)` | 获取模块列表(Grid)配置 | `refid`: 模块引用ID |
36
+ | `getEntityForm(refid)` | 获取实体表单配置 | `refid`: 模块引用ID |
37
+ | `getWorkflow(refid)` | 获取工作流配置 | `refid`: 模块引用ID |
38
+ | `clear()` | 清空所有模块相关缓存 | - |
39
+
40
+ **缓存结构:**
41
+ - `moduleCache`: 模块基础信息
42
+ - `layoutCache`: 界面布局配置
43
+ - `gridCache`: 列表视图配置
44
+ - `entityFormCache`: 实体表单配置
45
+ - `workflowCache`: 工作流配置
46
+
47
+ **使用示例:**
48
+ ```javascript
49
+ import { moduleCache } from './ModuleCache';
50
+
51
+ // 获取模块配置
52
+ const moduleConfig = await moduleCache.getModule('user_module');
53
+ ```
package/http/CrudHttp.js CHANGED
@@ -6,9 +6,13 @@ import SohelpHttp from "./SohelpHttp";
6
6
  export const CrudHttp = {
7
7
  /**
8
8
  * 表单初始化数据
9
- * @param refid
10
- * @param params
11
- * @param callback
9
+ *
10
+ * 获取表单初始化所需的数据,如默认值、选项等。
11
+ *
12
+ * @param {string} refid 模块引用ID
13
+ * @param {Object} [params={}] 请求参数
14
+ * @param {Function} [callback] 请求完成后的回调函数
15
+ * @returns {Promise<any>} 返回Promise对象
12
16
  */
13
17
  initial: function(refid, params = {}, callback) {
14
18
  params["refid"] = refid;
@@ -16,9 +20,13 @@ export const CrudHttp = {
16
20
  },
17
21
  /**
18
22
  * 根据ID获取某一行数据
19
- * @param refid
20
- * @param params
21
- * @param callback
23
+ *
24
+ * 用于获取单行数据的详细信息。
25
+ *
26
+ * @param {string} refid 模块引用ID
27
+ * @param {Object} [params={}] 请求参数,通常包含 id
28
+ * @param {Function} [callback] 请求完成后的回调函数
29
+ * @returns {Promise<any>} 返回Promise对象
22
30
  */
23
31
  getById: function(refid, params = {}, callback) {
24
32
  params["refid"] = refid;
@@ -26,9 +34,13 @@ export const CrudHttp = {
26
34
  },
27
35
  /**
28
36
  * 根据ID,获取主体数据和外键数据
29
- * @param refid
30
- * @param params
31
- * @param callback
37
+ *
38
+ * 获取详细数据,包括关联的外键数据。
39
+ *
40
+ * @param {string} refid 模块引用ID
41
+ * @param {Object} [params={}] 请求参数,通常包含 id
42
+ * @param {Function} [callback] 请求完成后的回调函数
43
+ * @returns {Promise<any>} 返回Promise对象
32
44
  */
33
45
  detail: function(refid, params = {}, callback) {
34
46
  params["refid"] = refid;
@@ -36,9 +48,13 @@ export const CrudHttp = {
36
48
  },
37
49
  /**
38
50
  * 根据外键分页读取数据列表
39
- * @param refid 网格列表
40
- * @param data
41
- * @param callback
51
+ *
52
+ * 用于加载子表或关联表的分页数据。
53
+ *
54
+ * @param {string} refid 模块引用ID
55
+ * @param {Object} [params={}] 请求参数,包含分页信息和外键条件
56
+ * @param {Function} [callback] 请求完成后的回调函数
57
+ * @returns {Promise<any>} 返回Promise对象
42
58
  */
43
59
  pageByFk: function(refid, params = {}, callback) {
44
60
  params["refid"] = refid;
@@ -46,10 +62,13 @@ export const CrudHttp = {
46
62
  },
47
63
  /**
48
64
  * 保存单据
49
- * @param refid 模块地址
50
- * @param data 数据对象
51
- * @param callback 回调函数
52
- * @returns {Promise<axios.AxiosResponse<any>>}
65
+ *
66
+ * 保存表单数据(通用保存接口)。
67
+ *
68
+ * @param {string} refid 模块引用ID
69
+ * @param {Object} [data={}] 表单数据对象
70
+ * @param {Function} [callback] 请求完成后的回调函数
71
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
53
72
  */
54
73
  save: function(refid, data = {}, callback) {
55
74
  data["refid"] = refid;
@@ -57,10 +76,13 @@ export const CrudHttp = {
57
76
  },
58
77
  /**
59
78
  * 创建单据
60
- * @param refid 模块地址
61
- * @param data 数据对象
62
- * @param callback 回调函数
63
- * @returns {Promise<axios.AxiosResponse<any>>}
79
+ *
80
+ * 创建新的单据记录。
81
+ *
82
+ * @param {string} refid 模块引用ID
83
+ * @param {Object} [data={}] 表单数据对象
84
+ * @param {Function} [callback] 请求完成后的回调函数
85
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
64
86
  */
65
87
  create: function(refid, data = {}, callback) {
66
88
  data["refid"] = refid;
@@ -68,10 +90,13 @@ export const CrudHttp = {
68
90
  },
69
91
  /**
70
92
  * 更新单据
71
- * @param refid 模块地址
72
- * @param data 数据对象
73
- * @param callback 回调函数
74
- * @returns {Promise<axios.AxiosResponse<any>>}
93
+ *
94
+ * 更新已存在的单据记录。
95
+ *
96
+ * @param {string} refid 模块引用ID
97
+ * @param {Object} [data={}] 表单数据对象,通常包含 id
98
+ * @param {Function} [callback] 请求完成后的回调函数
99
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
75
100
  */
76
101
  update: function(refid, data = {}, callback) {
77
102
  data["refid"] = refid;
@@ -79,10 +104,13 @@ export const CrudHttp = {
79
104
  },
80
105
  /**
81
106
  * 删除单据
82
- * @param refid 模块地址
83
- * @param data 数据对象
84
- * @param callback 回调函数
85
- * @returns {Promise<axios.AxiosResponse<any>>}
107
+ *
108
+ * 删除指定的单据记录。
109
+ *
110
+ * @param {string} refid 模块引用ID
111
+ * @param {Object} [data={}] 数据对象,通常包含 id 或 ids
112
+ * @param {Function} [callback] 请求完成后的回调函数
113
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
86
114
  */
87
115
  delete: function(refid, data = {}, callback) {
88
116
  data["refid"] = refid;
@@ -90,10 +118,13 @@ export const CrudHttp = {
90
118
  },
91
119
  /**
92
120
  * 单据分页
93
- * @param refid 模块地址
94
- * @param params 数据对象
95
- * @param callback 回调函数
96
- * @returns {Promise<axios.AxiosResponse<any>>}
121
+ *
122
+ * 获取主表的分页数据列表。
123
+ *
124
+ * @param {string} refid 模块引用ID
125
+ * @param {Object} [params={}] 查询参数,包含分页、排序和筛选条件
126
+ * @param {Function} [callback] 请求完成后的回调函数
127
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
97
128
  */
98
129
  page: async function(refid, params = {}, callback) {
99
130
  params["refid"] = refid;
@@ -101,10 +132,13 @@ export const CrudHttp = {
101
132
  },
102
133
  /**
103
134
  * 单据详情
104
- * @param refid 模块地址
105
- * @param params 数据对象
106
- * @param callback 回调函数
107
- * @returns {Promise<axios.AxiosResponse<any>>}
135
+ *
136
+ * 获取单据的详细信息,通常用于查看或编辑页面。
137
+ *
138
+ * @param {string} refid 模块引用ID
139
+ * @param {Object} [params={}] 查询参数,通常包含 id
140
+ * @param {Function} [callback] 请求完成后的回调函数
141
+ * @returns {Promise<axios.AxiosResponse<any>>} 返回Promise对象
108
142
  */
109
143
  detail: async function(refid, params = {}, callback) {
110
144
  params["refid"] = refid;
package/http/DictHttp.js CHANGED
@@ -1,7 +1,11 @@
1
1
 
2
2
 
3
3
  /**
4
- * 字典数据
4
+ * 获取所有字典数据
5
+ *
6
+ * 从后端加载完整的字典数据列表。
7
+ *
8
+ * @returns {Promise<*>} 返回包含字典数据的Promise对象
5
9
  */
6
10
  export async function getDictData() {
7
11
  const res = await SohelpHttp.get('/engine/web/dict/list', {});
@@ -2,8 +2,11 @@
2
2
 
3
3
  /**
4
4
  * 获取界面配置
5
- * @param refid
6
- * @returns {Promise<*>}
5
+ *
6
+ * 获取指定模块的界面布局配置信息。
7
+ *
8
+ * @param {string} refid 模块引用ID
9
+ * @returns {Promise<*>} 返回布局配置数据
7
10
  */
8
11
  export async function getLayout(refid) {
9
12
  const res = await SohelpHttp.get("/engine/web/layout/read", {refid});
@@ -14,9 +17,12 @@ export async function getLayout(refid) {
14
17
  }
15
18
 
16
19
  /**
17
- * 获取界面配置
18
- * @param refid
19
- * @returns {Promise<*>}
20
+ * 获取模块配置
21
+ *
22
+ * 获取模块的元数据定义,包括字段、属性等信息。
23
+ *
24
+ * @param {string} refid 模块引用ID
25
+ * @returns {Promise<*>} 返回模块配置数据
20
26
  */
21
27
  export async function getModule(refid) {
22
28
  const res = await SohelpHttp.get("/engine/web/module/read", {refid});
@@ -29,8 +35,11 @@ export async function getModule(refid) {
29
35
 
30
36
  /**
31
37
  * 保存属性配置
32
- * @param {*} data
33
- * @returns
38
+ *
39
+ * 保存用户对表格列的筛选、排序等个性化配置。
40
+ *
41
+ * @param {*} data 配置数据对象
42
+ * @returns {Promise<*>} 返回保存结果
34
43
  */
35
44
  export async function saveGridFilter(data) {
36
45
  const res = await SohelpHttp.post('/engine/web/module/grid/save', data);
@@ -43,8 +52,11 @@ export async function saveGridFilter(data) {
43
52
 
44
53
  /**
45
54
  * 重置列设置
46
- * @param {*} refid
47
- * @returns
55
+ *
56
+ * 恢复表格列的默认配置。
57
+ *
58
+ * @param {*} refid 模块引用ID
59
+ * @returns {Promise<string>} 返回操作消息
48
60
  */
49
61
  export async function resetCommonConfig(refid) {
50
62
  const res = await SohelpHttp.post('/engine/web/module/grid/resetCommonConfig', refid);
@@ -56,8 +68,11 @@ export async function resetCommonConfig(refid) {
56
68
 
57
69
  /**
58
70
  * 更新列设置
59
- * @param {*} refid
60
- * @returns
71
+ *
72
+ * 更新表格列的通用配置。
73
+ *
74
+ * @param {*} data 配置数据对象
75
+ * @returns {Promise<string>} 返回操作消息
61
76
  */
62
77
  export async function updateCommonConfig(data) {
63
78
  const res = await SohelpHttp.post('/engine/web/module/grid/updateCommonConfig', data);
package/http/README.md ADDED
@@ -0,0 +1,50 @@
1
+ # HTTP 接口文档
2
+
3
+ 本文档列出了 `src/components/sohelp-eleplus/http` 目录下的所有 HTTP 接口封装。
4
+
5
+ ## 1. SohelpHttp (核心请求工具)
6
+
7
+ 封装了基础的 Axios 请求方法,提供统一的错误处理和参数序列化。
8
+
9
+ | 方法名 | 说明 | 参数 |
10
+ | :--- | :--- | :--- |
11
+ | `getBaseUrl()` | 获取后端上下文地址 | - |
12
+ | `download(_url, param, fileName, onProgress, config)` | 下载文件 | `_url`: 请求地址<br>`param`: 请求参数<br>`fileName`: 文件名<br>`onProgress`: 进度回调<br>`config`: Axios配置 |
13
+ | `get(url, param, callback)` | 发送 GET 请求 | `url`: 请求地址<br>`param`: 请求参数<br>`callback`: 回调函数 |
14
+ | `post(url, param, callback, error)` | 发送 POST 请求 | `url`: 请求地址<br>`param`: 请求参数<br>`callback`: 回调函数<br>`error`: 错误回调 |
15
+
16
+ ## 2. CrudHttp (增删改查操作)
17
+
18
+ 封装了通用的 CRUD 接口,用于与后端引擎进行数据交互。
19
+
20
+ | 方法名 | 说明 | 参数 |
21
+ | :--- | :--- | :--- |
22
+ | `initial(refid, params, callback)` | 表单初始化数据 | `refid`: 模块引用ID<br>`params`: 其他参数<br>`callback`: 回调函数 |
23
+ | `getById(refid, params, callback)` | 根据ID获取某一行数据 | `refid`: 模块引用ID<br>`params`: 包含id等参数<br>`callback`: 回调函数 |
24
+ | `detail(refid, params, callback)` | 根据ID获取主体数据和外键数据 | `refid`: 模块引用ID<br>`params`: 参数<br>`callback`: 回调函数 |
25
+ | `pageByFk(refid, params, callback)` | 根据外键分页读取数据列表 | `refid`: 模块引用ID<br>`params`: 参数<br>`callback`: 回调函数 |
26
+ | `save(refid, data, callback)` | 保存单据 | `refid`: 模块引用ID<br>`data`: 数据对象<br>`callback`: 回调函数 |
27
+ | `create(refid, data, callback)` | 创建单据 | `refid`: 模块引用ID<br>`data`: 数据对象<br>`callback`: 回调函数 |
28
+ | `update(refid, data, callback)` | 更新单据 | `refid`: 模块引用ID<br>`data`: 数据对象<br>`callback`: 回调函数 |
29
+ | `delete(refid, data, callback)` | 删除单据 | `refid`: 模块引用ID<br>`data`: 数据对象<br>`callback`: 回调函数 |
30
+ | `page(refid, params, callback)` | 单据分页查询 | `refid`: 模块引用ID<br>`params`: 查询参数<br>`callback`: 回调函数 |
31
+
32
+ ## 3. ModuleHttp (模块配置)
33
+
34
+ 用于获取和保存模块的界面配置、列设置等。
35
+
36
+ | 方法名 | 说明 | 参数 |
37
+ | :--- | :--- | :--- |
38
+ | `getLayout(refid)` | 获取界面布局配置 | `refid`: 模块引用ID |
39
+ | `getModule(refid)` | 获取模块配置 | `refid`: 模块引用ID |
40
+ | `saveGridFilter(data)` | 保存列表属性配置 | `data`: 配置数据 |
41
+ | `resetCommonConfig(refid)` | 重置列设置 | `refid`: 模块引用ID |
42
+ | `updateCommonConfig(data)` | 更新列设置 | `data`: 配置数据 |
43
+
44
+ ## 4. DictHttp (字典数据)
45
+
46
+ 用于获取系统字典数据。
47
+
48
+ | 方法名 | 说明 | 参数 |
49
+ | :--- | :--- | :--- |
50
+ | `getDictData()` | 获取所有字典数据 | - |
@@ -1,16 +1,14 @@
1
1
  /**
2
2
  * axios实例
3
3
  */
4
- import { ElMessageBox } from "element-plus/es";
5
-
4
+ import { ElMessageBox } from 'element-plus/es';
6
5
 
7
6
  export const SohelpHttp = {
8
-
9
7
  /**
10
8
  * 获取后端上下文地址
11
9
  */
12
- getBaseUrl(){
13
- return window.$axios.defaults.baseURL
10
+ getBaseUrl() {
11
+ return window.$axios.defaults.baseURL;
14
12
  },
15
13
 
16
14
  /**
@@ -22,30 +20,34 @@ export const SohelpHttp = {
22
20
  * @param config
23
21
  * @returns {Promise<never>}
24
22
  */
25
- download: async function(_url, param, fileName, onProgress, config = {}) {
23
+ download: async function (_url, param, fileName, onProgress, config = {}) {
26
24
  if (window.$axios == null) {
27
- console.error("请在配置main.js中配置window.$axios实例!!");
25
+ console.error('请在配置main.js中配置window.$axios实例!!');
28
26
  return;
29
27
  }
30
28
  try {
31
29
  if (!fileName) {
32
- fileName = (new Date()).getTime();
30
+ fileName = new Date().getTime();
33
31
  }
34
- // 发起POST请求,设置responseType为blob
35
- const response = await window.$axios.post(_url, param || {}, {
36
- responseType: 'blob',
37
- ...config,
38
- onDownloadProgress: (evt) => {
39
- if (typeof onProgress === "function") {
40
- const total = evt?.total || 0;
41
- const loaded = evt?.loaded || 0;
42
- onProgress(loaded, total);
32
+ // 发起GET请求,设置responseType为blob
33
+ const response = await window.$axios
34
+ .get(_url, {
35
+ params: param || {},
36
+ responseType: 'blob',
37
+ ...config,
38
+ onDownloadProgress: (evt) => {
39
+ if (typeof onProgress === 'function') {
40
+ const total = evt?.total || 0;
41
+ const loaded = evt?.loaded || 0;
42
+ onProgress(loaded, total);
43
+ }
43
44
  }
44
- }
45
- }).catch(e => {
46
- return Promise.reject(e.message);
47
- });
48
- if (response.type === "application/json") {
45
+ })
46
+ .catch((e) => {
47
+ return Promise.reject(e.message);
48
+ });
49
+
50
+ if (response.type === 'application/json') {
49
51
  try {
50
52
  const text = await response.text();
51
53
  const res = JSON.parse(text);
@@ -53,7 +55,7 @@ export const SohelpHttp = {
53
55
  return res.data;
54
56
  } else {
55
57
  if (res?.meta?.error) {
56
- console.log("SohelpHttp.download:", res.meta.error);
58
+ console.log('SohelpHttp.download:', res.meta.error);
57
59
  }
58
60
  return Promise.reject(new Error(res.meta.message));
59
61
  }
@@ -63,10 +65,12 @@ export const SohelpHttp = {
63
65
  return;
64
66
  }
65
67
  // 创建一个链接元素用于下载
66
- const url = window.URL.createObjectURL(response);
67
- const link = document.createElement("a");
68
+ const url = _url + '?' + new URLSearchParams(param).toString();
69
+ // const url = window.URL.createObjectURL(response.data);
70
+ const link = document.createElement('a');
68
71
  link.href = url;
69
- link.setAttribute("download", fileName); // 设置下载的文件名
72
+ link.target = '_blank';
73
+ link.setAttribute('download', fileName); // 设置下载的文件名
70
74
  document.body.appendChild(link);
71
75
 
72
76
  // 触发下载
@@ -78,52 +82,47 @@ export const SohelpHttp = {
78
82
  return Promise.reject(error);
79
83
  }
80
84
  },
81
- get: function(url, param, callback) {
85
+ get: function (url, param, callback) {
82
86
  if (window.$axios == null) {
83
- console.error("请在配置main.js中配置window.$axios实例!!");
87
+ console.error('请在配置main.js中配置window.$axios实例!!');
84
88
  return;
85
89
  }
86
90
  for (const key in param) {
87
- if (typeof param[key] === "object" && param[key] !== null) {
91
+ if (typeof param[key] === 'object' && param[key] !== null) {
88
92
  param[key] = JSON.stringify(param[key]); // 转换为 JSON 字符串
89
93
  }
90
94
  }
91
95
  let promise = window.$axios.get(url, { params: param });
92
96
  return promise.then((r) => {
93
97
  if (!r.meta.success && r.meta.error) {
94
- console.error(
95
- "(GET请求URL):",
96
- url,
97
- "(请求参数):",
98
- param,
99
- "(返回结果):",
100
- r.meta.error
101
- );
98
+ console.error('(GET请求URL):', url, '(请求参数):', param, '(返回结果):', r.meta.error);
102
99
  }
103
- if (typeof callback === "function") {
100
+ if (typeof callback === 'function') {
104
101
  callback.call(this, r);
105
102
  }
106
103
  return Promise.resolve(r);
107
104
  });
108
105
  },
109
- post: function(url, param, callback, error) {
106
+ /**
107
+ * 发送POST请求
108
+ *
109
+ * @param {string} url 请求地址
110
+ * @param {Object} param 请求参数
111
+ * @param {Function} [callback] 请求成功后的回调函数
112
+ * @param {Function} [error] 错误回调函数(目前未使用)
113
+ * @returns {Promise<any>} 返回Promise对象
114
+ */
115
+ post: function (url, param, callback, error) {
110
116
  if (window.$axios == null) {
111
- console.error("请在配置main.js中配置window.$axios实例!!");
117
+ console.error('请在配置main.js中配置window.$axios实例!');
112
118
  return;
113
119
  }
114
120
  let promise = window.$axios.post(url, param);
115
121
  return promise.then((r) => {
116
122
  if (!r.meta.success && r.meta.error) {
117
- console.error(
118
- "(GET请求URL):",
119
- url,
120
- "(请求参数):",
121
- param,
122
- "(返回结果):",
123
- r.meta.error
124
- );
123
+ console.error('(GET请求URL):', url, '(请求参数):', param, '(返回结果):', r.meta.error);
125
124
  }
126
- if (typeof callback === "function") {
125
+ if (typeof callback === 'function') {
127
126
  callback.call(this, r);
128
127
  }
129
128
  return Promise.resolve(r);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sohelp-eleplus",
3
- "version": "1.1.21",
3
+ "version": "1.1.22",
4
4
  "description": "SohelpEleplus Extension Components",
5
5
  "public": true,
6
6
  "main": "index.js",