vue-super-crud 1.7.4 → 1.8.0

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": "vue-super-crud",
3
- "version": "1.7.4",
3
+ "version": "1.8.0",
4
4
  "main": "lib/super-crud.min.js",
5
5
  "files": [
6
6
  "lib",
@@ -11,6 +11,7 @@ export const renderItem = {
11
11
  strict: true,
12
12
  type: [String, Object, Function],
13
13
  properties: {
14
+ key: String,
14
15
  request: Function,
15
16
  label: String, // 数据字典中label字段的属性名
16
17
  value: String, // 数据字典中value字段的属性名
@@ -77,6 +77,30 @@ export default {
77
77
  type: String,
78
78
  default: "small",
79
79
  },
80
+ persistPageSize: Boolean, // 是否持久化拖动宽度
81
+ persistWidth: Boolean, // 是否持久化拖动宽度
82
+ delayRender: Boolean, // 是否启用延迟渲染
83
+ delayRenderConfig: {
84
+ // 延迟渲染配置
85
+ type: [Boolean, Object],
86
+ default: () => ({
87
+ batchSize: 16,
88
+ maxProcessTime: 16,
89
+ frameDelay: 2,
90
+ strategy: "cell",
91
+ }),
92
+ properties: {
93
+ batchSize: Number, // 每批处理的元素数量,数值越大渲染越快,但可能导致卡顿
94
+ maxProcessTime: Number, // 每帧最大处理时间(ms),防止单帧处理时间过长
95
+ frameDelay: Number, // 批次间的帧间隔,数值越大越平滑,但渲染完成时间越长
96
+ },
97
+ }, // 是否启用延迟渲染
98
+ virtualized: Boolean, // 是否启用虚拟列表
99
+ itemSize: {
100
+ // 延迟渲染、虚拟列表的固定行高
101
+ type: Number,
102
+ default: 40,
103
+ },
80
104
  summaryData: Array, // 外部传入的统计数据
81
105
  // 是否禁用
82
106
  disabled: Boolean,
@@ -279,7 +303,6 @@ export default {
279
303
  type: [Boolean, Object],
280
304
  default: () => ({
281
305
  show: true,
282
- width: 290,
283
306
  resetBtn: true,
284
307
  }),
285
308
  properties: {
@@ -335,6 +358,7 @@ export default {
335
358
  layout: "total, sizes, prev, pager, next, jumper",
336
359
  background: true,
337
360
  pagerCount: 5,
361
+ memorizeScroll: true, // 临时保存分页滚动位置
338
362
  }),
339
363
  },
340
364
  // 空状态配置
package/src/index.js CHANGED
@@ -14,6 +14,7 @@ import button from "pak/button";
14
14
  import position from "pak/core/components/position";
15
15
  import grid from "pak/grid/index.vue";
16
16
  import cell from "pak/grid/cell.vue";
17
+ import lazyRender from "pak/lazyRender/index.vue";
17
18
 
18
19
  import { mergeTemplate } from "./template";
19
20
  import directive from "pak/directive";
@@ -37,28 +38,28 @@ const components = [
37
38
  position,
38
39
  grid,
39
40
  cell,
41
+ lazyRender,
40
42
  ];
41
43
 
42
44
  const install = function (Vue, opts = {}) {
43
45
  // 判断是否安装
44
46
  if (install.installed) return;
45
47
  install.installed = true;
46
- if (opts.template) {
47
- mergeTemplate(opts.template);
48
- }
49
- window.Vue = Vue;
50
48
 
51
- Vue.prototype.$scOpt = opts;
52
- Vue.prototype.$scDialog = dialog;
53
- Vue.prototype.$scDict = globalDict(Vue, opts.dict || {});
49
+ // 合并外部代码模板
50
+ opts.template && mergeTemplate(opts.template);
54
51
 
52
+ // 初始化配置管理器
55
53
  configManager.create(config, opts);
56
- // Vue.use(Contextmenu);
54
+
57
55
  // 遍历注册全局组件
58
- components.forEach((component) => {
59
- Vue.component(component.name, component);
60
- });
56
+ components.forEach((component) => Vue.component(component.name, component));
57
+
58
+ Vue.prototype.$scOpt = opts;
59
+ Vue.prototype.$scDialog = dialog;
60
+ Vue.prototype.$scDict = globalDict(Vue, opts.dict || {});
61
61
  directive(Vue);
62
+ window.Vue = Vue;
62
63
  };
63
64
 
64
65
  // 判断是否是直接引入文件
@@ -315,6 +315,11 @@ export default {
315
315
 
316
316
  return {
317
317
  input: (value) => {
318
+ // 处理空值情况
319
+ if (value === undefined || value === null || value === "") {
320
+ return "";
321
+ }
322
+
318
323
  try {
319
324
  let rawStr = "";
320
325
  if (typeof value === "string") {
@@ -323,7 +328,11 @@ export default {
323
328
  rawStr = String(value);
324
329
  }
325
330
 
326
- const num = Number(rawStr) || 0;
331
+ const num = Number(rawStr);
332
+ // 如果转换后是 NaN,返回空字符串
333
+ if (isNaN(num)) {
334
+ return "";
335
+ }
327
336
 
328
337
  // 传入原始字符串,用于处理特殊情况
329
338
  let formatted = formatPrecision(num, rawStr);
@@ -336,7 +345,7 @@ export default {
336
345
  return `${config.prefix}${formatted}${config.suffix}`;
337
346
  } catch (error) {
338
347
  console.warn("数字格式化失败:", error);
339
- return value;
348
+ return "";
340
349
  }
341
350
  },
342
351
  // 输出时去除格式化(还原为原始数字字符串)