sohelp-eleplus 1.1.22 → 1.1.25

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.
@@ -4,6 +4,7 @@ import { moduleCache } from '../../cache/ModuleCache';
4
4
  import { usePermission } from '@/utils/use-permission';
5
5
  import { useMobile } from '@/utils/use-mobile';
6
6
  import { useI18n } from 'vue-i18n';
7
+ import { EleMessage } from '@/components/ele-admin-plus/components';
7
8
 
8
9
  /**
9
10
  * 深拷贝
@@ -89,13 +90,13 @@ const switchVxeProperty = (property, sortList, f, formulaMap) => {
89
90
  * 自定义格式化渲然
90
91
  */
91
92
 
92
- if (property.renderType && property.renderType === 'customFormatter') {
93
+ if (property.render && property.render === 'customFormatter') {
93
94
  delete editor.slots.default;
94
95
  editor.type = 'html';
95
96
  editor.formatter = function ({ row, column, cellValue }) {
96
- if (property.render) {
97
+ if (property.renderParam) {
97
98
  try {
98
- const func = new Function('row', 'column', 'cellValue', `return ( () => { ${property.render} })()`);
99
+ const func = new Function('$row', '$column', '$value', `return ( () => { ${property.renderParam} })()`);
99
100
  return func(row, column, cellValue);
100
101
  } catch (e) {
101
102
  console.error('customFormatter 执行错误:', e);
@@ -184,7 +185,7 @@ const filterFieldsByProperties = (_data) => {
184
185
  };
185
186
 
186
187
  let validProperties = Object.fromEntries(
187
- data.properties.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
188
+ data.properties?.filter((item) => item.name && !item.hidden)?.map((item) => [item.name, item.label])
188
189
  );
189
190
 
190
191
  data.list = filterArray(data.list).filter((item) => {
@@ -195,7 +196,7 @@ const filterFieldsByProperties = (_data) => {
195
196
 
196
197
  //过滤掉不在列表中的sort属性
197
198
  data.filter.sort = filterArray(data.filter.sort.filter((item) => data.list.some((f) => f === item)));
198
- data.properties = data.properties.filter((item) => item.name && !item.hidden);
199
+ data.properties = data.properties?.filter((item) => item.name && !item.hidden);
199
200
 
200
201
  data.filter.field = data.filter.field.filter((item) => {
201
202
  return item.name in validProperties;
@@ -345,7 +346,7 @@ export function useSohelpGridConfig() {
345
346
  var batchButtonsIndex = -1;
346
347
  const DefaultGridOptions = reactive(deepClone(_DefaultGridOptions));
347
348
  /**获取列表配置*/
348
- const config = isGridConfig ? await moduleCache.getGrid(_refid) : await moduleCache.getEntityGrid(_refid);
349
+ const config = await moduleCache.getGrid(_refid);
349
350
 
350
351
  if (!config) {
351
352
  throw new Error(_refid + ' : 没有发现网格列表配置!');
@@ -30,7 +30,10 @@
30
30
  'operationButtonClick',
31
31
  'changeFilterScheme',
32
32
  'editClosed',
33
- 'currentColumnChange'
33
+ 'currentColumnChange',
34
+ 'checkboxChange',
35
+ 'pageChange',
36
+ 'radioChange'
34
37
  ]);
35
38
 
36
39
  // grid实例
@@ -75,6 +78,18 @@
75
78
  })
76
79
  });
77
80
 
81
+ const checkboxChange = (row, checked, type) => {
82
+ emit('checkboxChange', row, checked, type);
83
+ };
84
+
85
+ const radioChange = (config) => {
86
+ emit('radioChange', config);
87
+ };
88
+
89
+ const pageChange = (config) => {
90
+ emit('pageChange', config);
91
+ };
92
+
78
93
  /**
79
94
  * 分割器配置
80
95
  */
@@ -200,6 +215,41 @@
200
215
  return sohelpGridRef.value?.selections;
201
216
  };
202
217
 
218
+ /**
219
+ * 设置复选框行键
220
+
221
+ * @param row 行数据
222
+
223
+ * @param checked 是否选中
224
+ */
225
+ const setCheckboxRowKey = (row, checked) => {
226
+ sohelpGridRef.value?.setCheckboxRowKey(row, checked);
227
+ };
228
+
229
+ const setRadioRowKey = (row, checked) => {
230
+ sohelpGridRef.value?.setRadioRowKey(row, checked);
231
+ };
232
+
233
+ /**
234
+ * 获取选中的记录
235
+ */
236
+ const getCheckboxRecords = () => {
237
+ return sohelpGridRef.value?.getCheckboxRecords();
238
+ };
239
+ /**
240
+ * 获取保留的记录
241
+ */
242
+ const getCheckboxReserveRecords = (isFull = false) => {
243
+ return sohelpGridRef.value?.getCheckboxReserveRecords(isFull);
244
+ };
245
+
246
+ /**
247
+ * 获取数据
248
+ */
249
+ const getData = () => {
250
+ return sohelpGridRef.value?.getData();
251
+ };
252
+
203
253
  watch(
204
254
  _filterValue,
205
255
  (val) => {
@@ -217,7 +267,12 @@
217
267
  reload,
218
268
  load,
219
269
  refresh,
220
- validate
270
+ validate,
271
+ setCheckboxRowKey,
272
+ getCheckboxRecords,
273
+ getCheckboxReserveRecords,
274
+ getData,
275
+ setRadioRowKey
221
276
  });
222
277
  </script>
223
278
  <script>
@@ -258,6 +313,11 @@
258
313
  @operationButtonClick="operationButtonClick"
259
314
  @editClosed="editClosed"
260
315
  @currentColumnChange="currentColumnChange"
316
+ @checkboxChange="checkboxChange"
317
+ @checkboxAll="checkboxChange"
318
+ @radioChange="radioChange"
319
+ @pageChange="pageChange"
320
+ v-bind="$attrs"
261
321
  >
262
322
  <template v-for="(_, name) in $slots" #[name]="slotProps">
263
323
  <slot :name="name" v-bind="slotProps" />
@@ -105,7 +105,10 @@
105
105
  layout: 'horizontal'
106
106
  };
107
107
  }
108
- }
108
+ },
109
+ refid: String,
110
+ ref_id: String,
111
+ ref_type: [String, Number]
109
112
  });
110
113
 
111
114
  const emit = defineEmits(['update:modelValue', 'update:data']);
@@ -160,7 +163,7 @@
160
163
  return false;
161
164
  }
162
165
 
163
- const res = await SohelpHttp.post('/engine/web/file/delete', { id: id });
166
+ const res = await SohelpHttp.post('/engine/web/file/delete', { id: id, refid: props.refid });
164
167
 
165
168
  if (res.meta.success) {
166
169
  ElMessage.success(res.meta.message);
@@ -182,6 +185,9 @@
182
185
  const uploadMethod = async ({ file }) => {
183
186
  const formData = new FormData();
184
187
  formData.append('files', file);
188
+ formData.append('refid', props.refid);
189
+ formData.append('ref_id', props.ref_id);
190
+ formData.append('ref_type', props.ref_type);
185
191
 
186
192
  const res = await SohelpHttp.post('/engine/web/file/upload', formData);
187
193
  if (res.meta.success && res.data.length > 0) {