ylwl-cpscoms 1.0.0 → 1.2.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.
Files changed (48) hide show
  1. package/es/DtTable/index.vue.js +379 -0
  2. package/es/DtTable/index.vue2.js +719 -0
  3. package/es/DtTable/index.vue3.js +6 -0
  4. package/es/SlAlert/index.vue.js +1 -1
  5. package/es/SlAlert/index.vue3.js +1 -1
  6. package/es/SlForm/index.vue.js +1 -1
  7. package/es/SlForm/index.vue3.js +1 -1
  8. package/es/SlPage/index.vue.js +2 -2
  9. package/es/SlPage/index.vue3.js +1 -1
  10. package/es/index.js +3 -1
  11. package/package.json +2 -3
  12. package/src/SlAlert/SlAlert.stories.js +0 -108
  13. package/src/SlAlert/index.vue +0 -54
  14. package/src/SlAlert/remark.md +0 -16
  15. package/src/SlDescriptions/SlDescriptions.stories.js +0 -119
  16. package/src/SlDescriptions/index.vue +0 -60
  17. package/src/SlDescriptions/renderOptions.vue +0 -27
  18. package/src/SlDialog/README-PLUS.md +0 -74
  19. package/src/SlDialog/README.md +0 -114
  20. package/src/SlDialog/dialogPlus.js +0 -160
  21. package/src/SlDialog/index.js +0 -170
  22. package/src/SlDrawer/SlDrawer.stories.js +0 -154
  23. package/src/SlDrawer/index.js +0 -62
  24. package/src/SlForm/SlForm.stories.js +0 -120
  25. package/src/SlForm/index.css +0 -141
  26. package/src/SlForm/index.vue +0 -365
  27. package/src/SlForm/mixinRender.js +0 -228
  28. package/src/SlForm/otherItem/titleItem.vue +0 -31
  29. package/src/SlForm/remark.md +0 -607
  30. package/src/SlGuide/SlGuide.stories.js +0 -100
  31. package/src/SlGuide/index.vue +0 -166
  32. package/src/SlGuide/remark.md +0 -90
  33. package/src/SlMessageBox/index.js +0 -35
  34. package/src/SlPage/README.md +0 -515
  35. package/src/SlPage/SlPage.stories.js +0 -125
  36. package/src/SlPage/index.css +0 -38
  37. package/src/SlPage/index.vue +0 -266
  38. package/src/SlPage/remark.md +0 -283
  39. package/src/SlTable/SlTable.stories.js +0 -118
  40. package/src/SlTable/components/colSetting.vue +0 -86
  41. package/src/SlTable/index.vue +0 -541
  42. package/src/SlTitle/SlTitle.stories.js +0 -98
  43. package/src/SlTitle/index.vue +0 -49
  44. package/src/global.css +0 -5
  45. package/src/index.js +0 -47
  46. package/src/store/index.js +0 -20
  47. package/src/utils/index.js +0 -47
  48. package/src/utils/tableConfig.js +0 -33
@@ -0,0 +1,719 @@
1
+ import { objectSpread2 as _objectSpread2, typeof as _typeof, asyncToGenerator as _asyncToGenerator, regenerator as _regenerator, toConsumableArray as _toConsumableArray } from '../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { Loading, Message } from 'element-ui';
3
+
4
+ // VNode 渲染组件
5
+ var VnodeComponent = {
6
+ functional: true,
7
+ props: {
8
+ vnode: {
9
+ type: Object,
10
+ default: null
11
+ }
12
+ },
13
+ render: function render(h, context) {
14
+ return context.props.vnode || h('span');
15
+ }
16
+ };
17
+ var script = {
18
+ name: 'DtTable',
19
+ components: {
20
+ VnodeComponent: VnodeComponent
21
+ },
22
+ props: {
23
+ gridOptions: {
24
+ type: Object,
25
+ required: true
26
+ },
27
+ isDisabled: {
28
+ type: Boolean,
29
+ default: false
30
+ },
31
+ pagination: {
32
+ type: Object,
33
+ default: function _default() {
34
+ return {
35
+ currentPage: 1,
36
+ pageSize: 10,
37
+ total: 0,
38
+ pageSizes: [10, 20, 50, 100],
39
+ layout: 'total, sizes, prev, pager, next, jumper',
40
+ background: true,
41
+ small: false,
42
+ disabled: false,
43
+ hideOnSinglePage: false
44
+ };
45
+ }
46
+ },
47
+ apiFunction: {
48
+ type: Function
49
+ },
50
+ apiParams: {
51
+ type: Object
52
+ },
53
+ immediate: {
54
+ type: Boolean,
55
+ default: false
56
+ }
57
+ },
58
+ emits: ['page-change', 'size-change', 'update:pagination', 'action-click', 'validate-error', 'remote-search', 'search', 'linkage-change', 'async-load', 'selection-change'],
59
+ data: function data() {
60
+ return {
61
+ formRef: null,
62
+ tableRef: null,
63
+ loading: false,
64
+ localPagination: _objectSpread2({}, this.pagination),
65
+ tableData: this.gridOptions.data || [],
66
+ searchParams: {},
67
+ loadingInstance: null,
68
+ loadingFields: new Set(),
69
+ formModel: {
70
+ tableData: this.gridOptions.data || []
71
+ }
72
+ };
73
+ },
74
+ computed: {
75
+ hasSelectionColumn: function hasSelectionColumn() {
76
+ return this.gridOptions.columns.some(function (col) {
77
+ return col.field === 'selection';
78
+ });
79
+ },
80
+ formRules: function formRules() {
81
+ var rules = {};
82
+ this.gridOptions.columns.forEach(function (column) {
83
+ if (column.field && column.rules) {
84
+ rules[column.field] = column.rules;
85
+ }
86
+ });
87
+ return rules;
88
+ }
89
+ },
90
+ watch: {
91
+ 'gridOptions.data': {
92
+ handler: function handler(newVal) {
93
+ this.tableData = newVal || [];
94
+ this.formModel.tableData = newVal || [];
95
+ },
96
+ immediate: true,
97
+ deep: true
98
+ },
99
+ pagination: {
100
+ handler: function handler(newVal) {
101
+ this.localPagination = _objectSpread2({}, newVal);
102
+ },
103
+ deep: true
104
+ },
105
+ localPagination: {
106
+ handler: function handler(newVal) {
107
+ this.$emit('update:pagination', newVal);
108
+ },
109
+ deep: true
110
+ },
111
+ tableData: {
112
+ handler: function handler(newData, oldData) {
113
+ var _this = this;
114
+ if (newData.length > 0 && newData !== oldData) {
115
+ this.$nextTick(function () {
116
+ _this.initAsyncData();
117
+ });
118
+ }
119
+ },
120
+ deep: true
121
+ }
122
+ },
123
+ mounted: function mounted() {
124
+ this.initRefs();
125
+ if (this.immediate) {
126
+ this.getTableDatas();
127
+ }
128
+ this.initAsyncData();
129
+ },
130
+ methods: {
131
+ // 判断是否为 VNode
132
+ isVNode: function isVNode(vnode) {
133
+ return vnode && _typeof(vnode) === 'object' && vnode.tag && vnode.children !== undefined;
134
+ },
135
+ // 调用 render 函数并传入 h
136
+ callRender: function callRender(column, scope) {
137
+ return column.render(_objectSpread2(_objectSpread2({}, scope), {}, {
138
+ h: this.$createElement
139
+ }));
140
+ },
141
+ // 初始化引用
142
+ initRefs: function initRefs() {
143
+ this.formRef = this.$refs.formRef;
144
+ this.tableRef = this.$refs.tableRef;
145
+ },
146
+ // 滚动到底部
147
+ scrollToBottom: function scrollToBottom() {
148
+ var _this2 = this;
149
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
150
+ var tableWrapper;
151
+ return _regenerator().w(function (_context) {
152
+ while (1) switch (_context.n) {
153
+ case 0:
154
+ _context.n = 1;
155
+ return _this2.$nextTick();
156
+ case 1:
157
+ if (_this2.tableRef) {
158
+ _context.n = 2;
159
+ break;
160
+ }
161
+ return _context.a(2);
162
+ case 2:
163
+ try {
164
+ tableWrapper = _this2.tableRef.$el.querySelector('.el-table__body-wrapper');
165
+ if (tableWrapper) {
166
+ tableWrapper.scrollTo({
167
+ top: tableWrapper.scrollHeight,
168
+ behavior: 'smooth'
169
+ });
170
+ }
171
+ } catch (error) {
172
+ console.warn('滚动到底部失败:', error);
173
+ }
174
+ case 3:
175
+ return _context.a(2);
176
+ }
177
+ }, _callee);
178
+ }))();
179
+ },
180
+ // 异步加载选项数据
181
+ loadAsyncOptions: function loadAsyncOptions(column, row, index) {
182
+ var _this3 = this;
183
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
184
+ var fieldKey, options, _t;
185
+ return _regenerator().w(function (_context2) {
186
+ while (1) switch (_context2.p = _context2.n) {
187
+ case 0:
188
+ if (!(column.asyncOptions && !column.asyncOptions.loadData)) {
189
+ _context2.n = 1;
190
+ break;
191
+ }
192
+ return _context2.a(2);
193
+ case 1:
194
+ fieldKey = row ? "".concat(column.field, "_").concat(row.id || index) : column.field;
195
+ _context2.p = 2;
196
+ _this3.loadingFields.add(fieldKey);
197
+ if (row) {
198
+ _this3.$set(row, "".concat(column.field, "Loading"), true);
199
+ } else {
200
+ _this3.$set(_this3.searchParams, "".concat(column.field, "Loading"), true);
201
+ }
202
+ _context2.n = 3;
203
+ return column.asyncOptions.loadData(row);
204
+ case 3:
205
+ options = _context2.v;
206
+ if (row) {
207
+ if (!row._asyncOptions) {
208
+ _this3.$set(row, '_asyncOptions', {});
209
+ }
210
+ _this3.$set(row._asyncOptions, column.field, options);
211
+ } else {
212
+ if (!_this3.searchParams._asyncOptions) {
213
+ _this3.$set(_this3.searchParams, '_asyncOptions', {});
214
+ }
215
+ _this3.$set(_this3.searchParams._asyncOptions, column.field, options);
216
+ }
217
+ _this3.$emit('async-load', {
218
+ field: column.field,
219
+ row: row,
220
+ index: index,
221
+ options: options
222
+ });
223
+ _context2.n = 5;
224
+ break;
225
+ case 4:
226
+ _context2.p = 4;
227
+ _t = _context2.v;
228
+ console.error("\u5F02\u6B65\u52A0\u8F7D\u9009\u9879\u5931\u8D25 [".concat(column.field, "]:"), _t);
229
+ case 5:
230
+ _context2.p = 5;
231
+ if (row) {
232
+ _this3.$set(row, "".concat(column.field, "Loading"), false);
233
+ }
234
+ return _context2.f(5);
235
+ case 6:
236
+ return _context2.a(2);
237
+ }
238
+ }, _callee2, null, [[2, 4, 5, 6]]);
239
+ }))();
240
+ },
241
+ // 初始化异步数据
242
+ initAsyncData: function initAsyncData() {
243
+ var _this4 = this;
244
+ // 初始化表格中的异步 Select
245
+ this.gridOptions.columns.forEach(function (column) {
246
+ if (column.asyncOptions && column.asyncOptions.immediate) {
247
+ _this4.tableData.forEach(function (row, index) {
248
+ if (row._asyncOptions && !row._asyncOptions[column.field]) {
249
+ _this4.loadAsyncOptions(column, row, index);
250
+ }
251
+ });
252
+ }
253
+ });
254
+ },
255
+ // 获取表格数据
256
+ getTableDatas: function getTableDatas(params) {
257
+ var _this5 = this;
258
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
259
+ var requestParams, _yield$_this5$apiFunc, data, _t2;
260
+ return _regenerator().w(function (_context3) {
261
+ while (1) switch (_context3.p = _context3.n) {
262
+ case 0:
263
+ if (_this5.apiFunction) {
264
+ _context3.n = 1;
265
+ break;
266
+ }
267
+ console.warn('apiFunction is not provided');
268
+ return _context3.a(2);
269
+ case 1:
270
+ _this5.startLoading();
271
+ _this5.loading = true;
272
+ _context3.p = 2;
273
+ requestParams = _objectSpread2(_objectSpread2(_objectSpread2(_objectSpread2({}, _this5.apiParams), _this5.searchParams), params), {}, {
274
+ currentPage: _this5.localPagination.currentPage,
275
+ pageSize: _this5.localPagination.pageSize
276
+ });
277
+ _context3.n = 3;
278
+ return _this5.apiFunction(requestParams);
279
+ case 3:
280
+ _yield$_this5$apiFunc = _context3.v;
281
+ data = _yield$_this5$apiFunc.data;
282
+ _this5.tableData = data.list || [];
283
+ _this5.localPagination.total = data.count;
284
+ _context3.n = 5;
285
+ break;
286
+ case 4:
287
+ _context3.p = 4;
288
+ _t2 = _context3.v;
289
+ console.error('Error fetching table data:', _t2);
290
+ case 5:
291
+ _context3.p = 5;
292
+ _this5.loading = false;
293
+ _this5.endLoading();
294
+ return _context3.f(5);
295
+ case 6:
296
+ return _context3.a(2);
297
+ }
298
+ }, _callee3, null, [[2, 4, 5, 6]]);
299
+ }))();
300
+ },
301
+ // 开始加载
302
+ startLoading: function startLoading() {
303
+ this.loading = true;
304
+ if (this.loadingInstance) {
305
+ this.loadingInstance.close();
306
+ }
307
+ this.loadingInstance = Loading.service({
308
+ target: '.dt_table',
309
+ lock: true,
310
+ text: '加载中...',
311
+ background: 'rgba(255, 255, 255, 0.5)'
312
+ });
313
+ },
314
+ // 结束加载
315
+ endLoading: function endLoading() {
316
+ this.loading = false;
317
+ if (this.loadingInstance) {
318
+ this.loadingInstance.close();
319
+ this.loadingInstance = null;
320
+ }
321
+ },
322
+ // 处理分页变化
323
+ handleCurrentChange: function handleCurrentChange(page) {
324
+ this.localPagination.currentPage = page;
325
+ this.$emit('page-change', page);
326
+ this.getTableDatas();
327
+ },
328
+ // 处理每页条数变化
329
+ handleSizeChange: function handleSizeChange(size) {
330
+ this.localPagination.pageSize = size;
331
+ this.localPagination.currentPage = 1;
332
+ this.$emit('size-change', size);
333
+ this.getTableDatas();
334
+ },
335
+ // 处理选择变化
336
+ handleSelectionChange: function handleSelectionChange(selection) {
337
+ this.$emit('selection-change', selection);
338
+ },
339
+ // 获取选中数据
340
+ getSelection: function getSelection() {
341
+ return this.$refs.tableRef ? this.$refs.tableRef.selection : [];
342
+ },
343
+ // 清空选择
344
+ clearSelection: function clearSelection() {
345
+ this.$refs.tableRef && this.$refs.tableRef.clearSelection();
346
+ },
347
+ // 切换行选中状态
348
+ toggleRowSelection: function toggleRowSelection(row, selected) {
349
+ this.$refs.tableRef && this.$refs.tableRef.toggleRowSelection(row, selected);
350
+ },
351
+ // 处理操作按钮点击
352
+ handleActionClick: function handleActionClick(button, row, index, event) {
353
+ event.stopPropagation();
354
+ if (button.click) {
355
+ button.click(row, index);
356
+ }
357
+ this.$emit('action-click', button, row, index);
358
+ },
359
+ // 确保表单就绪
360
+ ensureFormReady: function ensureFormReady() {
361
+ var _this6 = this;
362
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
363
+ return _regenerator().w(function (_context4) {
364
+ while (1) switch (_context4.n) {
365
+ case 0:
366
+ if (!_this6.formRef) {
367
+ _context4.n = 1;
368
+ break;
369
+ }
370
+ return _context4.a(2, true);
371
+ case 1:
372
+ _context4.n = 2;
373
+ return _this6.$nextTick();
374
+ case 2:
375
+ _this6.initRefs();
376
+ if (_this6.formRef) {
377
+ _context4.n = 4;
378
+ break;
379
+ }
380
+ console.warn('表单引用初始化失败,尝试重新渲染');
381
+ _context4.n = 3;
382
+ return _this6.$nextTick();
383
+ case 3:
384
+ _this6.initRefs();
385
+ case 4:
386
+ return _context4.a(2, !!_this6.formRef);
387
+ }
388
+ }, _callee4);
389
+ }))();
390
+ },
391
+ // 验证表单
392
+ validate: function validate() {
393
+ var _this7 = this;
394
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee5() {
395
+ var rowErrors, promises, results, isValid, errorParts, errorMessage, _t3;
396
+ return _regenerator().w(function (_context5) {
397
+ while (1) switch (_context5.p = _context5.n) {
398
+ case 0:
399
+ _context5.n = 1;
400
+ return _this7.ensureFormReady();
401
+ case 1:
402
+ if (_this7.formRef) {
403
+ _context5.n = 2;
404
+ break;
405
+ }
406
+ return _context5.a(2, Promise.reject(new Error('表单未初始化,请检查组件状态')));
407
+ case 2:
408
+ rowErrors = new Map();
409
+ _context5.p = 3;
410
+ promises = []; // 修复:使用正确的 prop 路径 tableData.${rowIndex}.${column.field}
411
+ _this7.formModel.tableData.forEach(function (_, rowIndex) {
412
+ _this7.gridOptions.columns.forEach(function (column) {
413
+ if (column.field && column.rules) {
414
+ promises.push(new Promise(function (resolve, reject) {
415
+ // 修复:添加 tableData 前缀
416
+ var propPath = "tableData.".concat(rowIndex, ".").concat(column.field);
417
+ _this7.formRef.validateField(propPath, function (error) {
418
+ if (error) {
419
+ if (!rowErrors.has(rowIndex)) {
420
+ rowErrors.set(rowIndex, []);
421
+ }
422
+ var fieldName = column.title || column.field;
423
+ rowErrors.get(rowIndex).push(fieldName);
424
+ reject(error);
425
+ } else {
426
+ resolve(true);
427
+ }
428
+ });
429
+ }).catch(function () {
430
+ return false;
431
+ }));
432
+ }
433
+ });
434
+ });
435
+ _context5.n = 4;
436
+ return Promise.all(promises);
437
+ case 4:
438
+ results = _context5.v;
439
+ isValid = results.every(function (result) {
440
+ return result !== false;
441
+ });
442
+ if (isValid) {
443
+ _context5.n = 5;
444
+ break;
445
+ }
446
+ errorParts = [];
447
+ rowErrors.forEach(function (fields, rowIndex) {
448
+ if (fields.length > 0) {
449
+ var uniqueFields = Array.from(new Set(fields));
450
+ errorParts.push("\u7B2C".concat(rowIndex + 1, "\u884C\uFF1A").concat(uniqueFields.join(',')));
451
+ }
452
+ });
453
+ if (errorParts.length > 0) {
454
+ errorMessage = errorParts.join(';');
455
+ Message({
456
+ message: "\u8BF7\u5B8C\u5584\u4EE5\u4E0B\u4FE1\u606F\uFF1A\n".concat(errorMessage),
457
+ type: 'error',
458
+ duration: 10000,
459
+ showClose: true,
460
+ dangerouslyUseHTMLString: true
461
+ });
462
+ }
463
+ _this7.$emit('validate-error', '表单验证失败');
464
+ return _context5.a(2, Promise.reject(new Error('表单验证失败')));
465
+ case 5:
466
+ return _context5.a(2, Promise.resolve(true));
467
+ case 6:
468
+ _context5.p = 6;
469
+ _t3 = _context5.v;
470
+ console.error('表单验证异常:', _t3);
471
+ Message.error('表单验证过程中发生异常');
472
+ _this7.$emit('validate-error', _t3);
473
+ return _context5.a(2, Promise.reject(_t3));
474
+ }
475
+ }, _callee5, null, [[3, 6]]);
476
+ }))();
477
+ },
478
+ // 重置表单
479
+ resetFields: function resetFields() {
480
+ var _this8 = this;
481
+ if (!this.formRef) return;
482
+ this.formModel.tableData.forEach(function (_, index) {
483
+ _this8.gridOptions.columns.forEach(function (column) {
484
+ if (column.field) {
485
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
486
+ _this8.formRef.resetFields(propPath);
487
+ }
488
+ });
489
+ });
490
+ },
491
+ // 清除验证
492
+ clearValidate: function clearValidate() {
493
+ var _this9 = this;
494
+ if (!this.formRef) return;
495
+ this.formModel.tableData.forEach(function (_, index) {
496
+ _this9.gridOptions.columns.forEach(function (column) {
497
+ if (column.field) {
498
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
499
+ _this9.formRef.clearValidate(propPath);
500
+ }
501
+ });
502
+ });
503
+ },
504
+ // 处理联动变化
505
+ handleLinkageChange: function handleLinkageChange(column, value, row, index, type) {
506
+ var _this0 = this;
507
+ return _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee6() {
508
+ var _column$linkage, targetField, method, options, _t4;
509
+ return _regenerator().w(function (_context6) {
510
+ while (1) switch (_context6.p = _context6.n) {
511
+ case 0:
512
+ if (column.linkage) {
513
+ _context6.n = 1;
514
+ break;
515
+ }
516
+ return _context6.a(2);
517
+ case 1:
518
+ _column$linkage = column.linkage, targetField = _column$linkage.targetField, method = _column$linkage.method, _column$linkage.clearTarget;
519
+ if (!row._linkageOptions) {
520
+ _this0.$set(row, '_linkageOptions', {});
521
+ }
522
+ _this0.$set(row._linkageOptions, targetField, []);
523
+ if (!(!value && value !== 0)) {
524
+ _context6.n = 2;
525
+ break;
526
+ }
527
+ _this0.tableData = _toConsumableArray(_this0.tableData);
528
+ return _context6.a(2);
529
+ case 2:
530
+ _context6.p = 2;
531
+ _this0.$set(row, "".concat(targetField, "Loading"), true);
532
+ _context6.n = 3;
533
+ return method(value, row, type);
534
+ case 3:
535
+ options = _context6.v;
536
+ _this0.$set(row._linkageOptions, targetField, options);
537
+ _this0.tableData = _toConsumableArray(_this0.tableData);
538
+ _this0.$emit('linkage-change', {
539
+ sourceField: column.field,
540
+ targetField: targetField,
541
+ value: value,
542
+ row: row,
543
+ index: index,
544
+ options: options
545
+ });
546
+ _context6.n = 5;
547
+ break;
548
+ case 4:
549
+ _context6.p = 4;
550
+ _t4 = _context6.v;
551
+ console.error('联动数据获取失败:', _t4);
552
+ case 5:
553
+ _context6.p = 5;
554
+ _this0.$set(row, "".concat(targetField, "Loading"), false);
555
+ return _context6.f(5);
556
+ case 6:
557
+ return _context6.a(2);
558
+ }
559
+ }, _callee6, null, [[2, 4, 5, 6]]);
560
+ }))();
561
+ },
562
+ // 获取选项数据
563
+ getOptions: function getOptions(column, row) {
564
+ if (row._asyncOptions && row._asyncOptions[column.field]) {
565
+ return row._asyncOptions[column.field];
566
+ }
567
+ if (row._linkageOptions && row._linkageOptions[column.field]) {
568
+ return row._linkageOptions[column.field];
569
+ }
570
+ return column.options || [];
571
+ },
572
+ // 计算字段是否禁用
573
+ getFieldDisabled: function getFieldDisabled(column, row, index) {
574
+ if (this.isDisabled) return true;
575
+ if (typeof column.disabled === 'function') {
576
+ return column.disabled(row, index);
577
+ }
578
+ return column.disabled || false;
579
+ },
580
+ // 计算按钮是否显示
581
+ getButtonShow: function getButtonShow(button, row, index) {
582
+ if (typeof button.show === 'function') {
583
+ return button.show(row, index);
584
+ }
585
+ return button.show !== undefined ? button.show : true;
586
+ },
587
+ // 计算按钮是否禁用
588
+ getButtonDisabled: function getButtonDisabled(button, row) {
589
+ if (typeof button.disabled === 'function') {
590
+ return button.disabled(row);
591
+ }
592
+ return button.disabled || false;
593
+ },
594
+ // 计算最小值
595
+ getMinValue: function getMinValue(column, row, index) {
596
+ if (typeof column.min === 'function') {
597
+ return column.min(row, index);
598
+ }
599
+ return column.min;
600
+ },
601
+ // 计算最大值
602
+ getMaxValue: function getMaxValue(column, row, index) {
603
+ if (typeof column.max === 'function') {
604
+ return column.max(row, index);
605
+ }
606
+ return column.max;
607
+ },
608
+ // 手动触发联动
609
+ triggerLinkage: function triggerLinkage(field, type) {
610
+ var _this1 = this;
611
+ var column = this.gridOptions.columns.find(function (col) {
612
+ return col.field === field;
613
+ });
614
+ if (!column || !column.linkage) {
615
+ console.warn("\u5B57\u6BB5 ".concat(field, " \u6CA1\u6709\u914D\u7F6E\u8054\u52A8\u6216\u4E0D\u5B58\u5728"));
616
+ return;
617
+ }
618
+ this.tableData.forEach(function (row, index) {
619
+ var sourceValue = row[field];
620
+ if (sourceValue !== undefined && sourceValue !== null && sourceValue !== '') {
621
+ _this1.handleLinkageChange(column, sourceValue, row, index, type);
622
+ }
623
+ });
624
+ },
625
+ // 各种事件处理函数
626
+ handleSelectChange: function handleSelectChange(column, value, row, index) {
627
+ column.events && column.events.change && column.events.change(value, row, index);
628
+ if (column.linkage) {
629
+ this.handleLinkageChange(column, value, row, index);
630
+ }
631
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
632
+ this.formRef && this.formRef.validateField(propPath);
633
+ },
634
+ handleInputChange: function handleInputChange(column, value, row, index) {
635
+ column.events && column.events.change && column.events.change(value, row, index);
636
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
637
+ this.formRef && this.formRef.validateField(propPath);
638
+ },
639
+ handleInputNumberChange: function handleInputNumberChange(column, value, row, index) {
640
+ column.events && column.events.change && column.events.change(value, row, index);
641
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
642
+ this.formRef && this.formRef.validateField(propPath);
643
+ },
644
+ handleSwitchChange: function handleSwitchChange(column, value, row, index) {
645
+ column.events && column.events.change && column.events.change(value, row, index);
646
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
647
+ this.formRef && this.formRef.validateField(propPath);
648
+ },
649
+ handleTimeChange: function handleTimeChange(column, value, row, index) {
650
+ column.events && column.events.change && column.events.change(value, row, index);
651
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
652
+ this.formRef && this.formRef.validateField(propPath);
653
+ },
654
+ handleDateChange: function handleDateChange(column, value, row, index) {
655
+ column.events && column.events.change && column.events.change(value, row, index);
656
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
657
+ this.formRef && this.formRef.validateField(propPath);
658
+ },
659
+ handleDateTimeChange: function handleDateTimeChange(column, value, row, index) {
660
+ column.events && column.events.change && column.events.change(value, row, index);
661
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
662
+ this.formRef && this.formRef.validateField(propPath);
663
+ },
664
+ handleDateRangeChange: function handleDateRangeChange(column, value, row, index) {
665
+ column.events && column.events.change && column.events.change(value, row, index);
666
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
667
+ this.formRef && this.formRef.validateField(propPath);
668
+ },
669
+ handleFocus: function handleFocus(column, event, row) {
670
+ column.events && column.events.focus && column.events.focus(event, row);
671
+ if (column.asyncOptions && !(row._asyncOptions && row._asyncOptions[column.field])) {
672
+ this.loadAsyncOptions(column, row);
673
+ }
674
+ },
675
+ handleBlur: function handleBlur(column, event, row, index) {
676
+ column.events && column.events.blur && column.events.blur(event, row);
677
+ var propPath = "tableData.".concat(index, ".").concat(column.field);
678
+ this.formRef && this.formRef.validateField(propPath);
679
+ },
680
+ handleClear: function handleClear(column, row, index) {
681
+ column.events && column.events.clear && column.events.clear();
682
+ if (column.linkage) {
683
+ var targetField = column.linkage.targetField;
684
+ if (targetField) {
685
+ this.$set(row, targetField, undefined);
686
+ if (row._linkageOptions) {
687
+ this.$set(row._linkageOptions, targetField, []);
688
+ }
689
+ }
690
+ }
691
+ },
692
+ // 刷新方法
693
+ refresh: function refresh(params) {
694
+ return this.getTableDatas(params);
695
+ },
696
+ getAppendComponent: function getAppendComponent(column, scope) {
697
+ if (typeof column.unit === 'function') {
698
+ return {
699
+ functional: true,
700
+ render: function render(h) {
701
+ return column.unit(h, scope);
702
+ }
703
+ };
704
+ } else {
705
+ return {
706
+ render: function render(h) {
707
+ return h('span', {
708
+ style: {
709
+ paddingLeft: '5px'
710
+ }
711
+ }, column.unit);
712
+ }
713
+ };
714
+ }
715
+ }
716
+ }
717
+ };
718
+
719
+ export { script as default };