@vue-start/pro 0.2.0 → 0.3.2
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/CHANGELOG.md +28 -0
- package/dist/index.d.ts +203 -311
- package/dist/index.es.js +1388 -407
- package/dist/index.js +1401 -408
- package/package.json +10 -2
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineComponent, computed, reactive, inject, h, provide,
|
|
2
|
-
import { map, isString, forEach,
|
|
1
|
+
import { defineComponent, createVNode, mergeProps, isVNode, computed, reactive, inject, h, provide, ref, Fragment } from 'vue';
|
|
2
|
+
import { map, isString, forEach, findIndex, get, isFunction, size, find, filter as filter$1, keys, omit, isArray, split, isEmpty, isObject, mergeWith, reduce, sortBy, pick, concat, isUndefined, debounce, some, clone, set, isBoolean } from 'lodash';
|
|
3
3
|
import { filter, tap, merge, Subject } from 'rxjs';
|
|
4
4
|
import { useEffect, setReactiveValue, useWatch } from '@vue-start/hooks';
|
|
5
5
|
import { useRequestProvide, isFailedRequestActor, isPreRequestActor, isDoneRequestActor } from '@vue-start/request';
|
|
6
|
+
import { useRouter, useRoute } from 'vue-router';
|
|
6
7
|
|
|
7
8
|
function ownKeys(object, enumerableOnly) {
|
|
8
9
|
var keys = Object.keys(object);
|
|
@@ -78,6 +79,50 @@ function _nonIterableSpread() {
|
|
|
78
79
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
function _isSlot$1(s) {
|
|
83
|
+
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
var proGridProps = function proGridProps() {
|
|
87
|
+
return {
|
|
88
|
+
row: {
|
|
89
|
+
type: Object,
|
|
90
|
+
"default": undefined
|
|
91
|
+
},
|
|
92
|
+
col: {
|
|
93
|
+
type: Object
|
|
94
|
+
},
|
|
95
|
+
items: {
|
|
96
|
+
type: Array
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
var createGrid = function createGrid(Row, Col) {
|
|
102
|
+
return defineComponent({
|
|
103
|
+
props: _objectSpread2({}, proGridProps()),
|
|
104
|
+
setup: function setup(props) {
|
|
105
|
+
return function () {
|
|
106
|
+
var _slot;
|
|
107
|
+
|
|
108
|
+
return createVNode(Row, props.row, _isSlot$1(_slot = map(props.items, function (item) {
|
|
109
|
+
return createVNode(Col, mergeProps({
|
|
110
|
+
"key": item.rowKey
|
|
111
|
+
}, props.col, item.col), {
|
|
112
|
+
"default": function _default() {
|
|
113
|
+
return [item.vNode];
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
})) ? _slot : {
|
|
117
|
+
"default": function _default() {
|
|
118
|
+
return [_slot];
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
|
|
81
126
|
var createUseRequestActor = function createUseRequestActor(filterFun) {
|
|
82
127
|
return function (actors, callback) {
|
|
83
128
|
var _useRequestProvide = useRequestProvide(),
|
|
@@ -150,17 +195,192 @@ var useComposeRequestActor = function useComposeRequestActor(actors, options, ca
|
|
|
150
195
|
}, []);
|
|
151
196
|
};
|
|
152
197
|
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
198
|
+
var treeDefaultNames = {
|
|
199
|
+
children: "children",
|
|
200
|
+
label: "label",
|
|
201
|
+
value: "value"
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* 根据value从treeData中找到对象
|
|
205
|
+
* @param data
|
|
206
|
+
* @param value
|
|
207
|
+
* @param fieldNames
|
|
208
|
+
* @param cb 对象:同步 方法:回调,可以理解为异步
|
|
209
|
+
*/
|
|
210
|
+
|
|
211
|
+
var findTargetInTree = function findTargetInTree(data, value, fieldNames, cb) {
|
|
212
|
+
var index = findIndex(data, function (item) {
|
|
213
|
+
return get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || treeDefaultNames.value) === value;
|
|
214
|
+
});
|
|
215
|
+
|
|
216
|
+
if (index > -1) {
|
|
217
|
+
if (isFunction(cb)) {
|
|
218
|
+
cb(index, data[index], data);
|
|
219
|
+
} else {
|
|
220
|
+
cb.index = index;
|
|
221
|
+
cb.target = data[index];
|
|
222
|
+
cb.list = data;
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
forEach(data, function (item) {
|
|
229
|
+
var children = get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || treeDefaultNames.children);
|
|
230
|
+
|
|
231
|
+
if (size(children) > 0) {
|
|
232
|
+
findTargetInTree(children, value, fieldNames, cb);
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
/**
|
|
237
|
+
* 根据value从treeData中找出对象及父列表
|
|
238
|
+
* @param data
|
|
239
|
+
* @param value
|
|
240
|
+
* @param fieldNames
|
|
241
|
+
* @param cb
|
|
242
|
+
* @param parent
|
|
243
|
+
*/
|
|
244
|
+
|
|
245
|
+
var findTargetListInTree = function findTargetListInTree(data, value, fieldNames, cb) {
|
|
246
|
+
var parent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
247
|
+
var target = find(data, function (item) {
|
|
248
|
+
return get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || treeDefaultNames.value) === value;
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
if (target) {
|
|
252
|
+
if (isFunction(cb)) {
|
|
253
|
+
cb([].concat(_toConsumableArray(parent), [target]));
|
|
254
|
+
} else {
|
|
255
|
+
cb.list = [].concat(_toConsumableArray(parent), [target]);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
forEach(data, function (item) {
|
|
262
|
+
var children = get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || treeDefaultNames.children);
|
|
263
|
+
|
|
264
|
+
if (size(children) > 0) {
|
|
265
|
+
findTargetListInTree(children, value, fieldNames, cb, [].concat(_toConsumableArray(parent), [item]));
|
|
266
|
+
}
|
|
267
|
+
});
|
|
268
|
+
};
|
|
269
|
+
|
|
270
|
+
/**
|
|
271
|
+
* 剔除showState或showStateRules规则为!true的值
|
|
272
|
+
* @param values
|
|
273
|
+
* @param showState
|
|
274
|
+
* @param showStateRules
|
|
275
|
+
*/
|
|
276
|
+
|
|
277
|
+
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
278
|
+
if (showState) {
|
|
279
|
+
var invalidKeys = filter$1(keys(showState), function (key) {
|
|
280
|
+
return !showState[key];
|
|
281
|
+
});
|
|
282
|
+
return omit(values, invalidKeys);
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
if (showStateRules) {
|
|
286
|
+
var _invalidKeys = filter$1(keys(showStateRules), function (key) {
|
|
287
|
+
return !showStateRules[key](values);
|
|
288
|
+
});
|
|
289
|
+
|
|
290
|
+
return omit(values, _invalidKeys);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
return values;
|
|
294
|
+
};
|
|
295
|
+
/**
|
|
296
|
+
* string类型的path转为arr
|
|
297
|
+
* @param path
|
|
298
|
+
*/
|
|
299
|
+
|
|
300
|
+
var convertPathToList = function convertPathToList(path) {
|
|
301
|
+
if (!path) {
|
|
302
|
+
return undefined;
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
if (isArray(path)) {
|
|
306
|
+
return path;
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
if (path && isString(path) && path.indexOf(".") > 0) {
|
|
310
|
+
return split(path, ".");
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
return [path];
|
|
314
|
+
};
|
|
315
|
+
/**
|
|
316
|
+
* 将listState 中的数据通过id merge到 list item中
|
|
317
|
+
* ps:数组会替换
|
|
318
|
+
* 注意:mergeWith 会改变原始对象
|
|
319
|
+
* @param list
|
|
320
|
+
* @param listState
|
|
321
|
+
* @param id
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
var mergeStateToList = function mergeStateToList(list, listState, id) {
|
|
325
|
+
if (!listState || !id) {
|
|
326
|
+
return list;
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
return map(list, function (item) {
|
|
330
|
+
var idName = isFunction(id) ? id(item) : id; //如果listState中有值,merge处理
|
|
331
|
+
|
|
332
|
+
var stateData = get(listState, idName);
|
|
333
|
+
|
|
334
|
+
if (!stateData || isEmpty(stateData) || isFunction(stateData) || !isObject(stateData)) {
|
|
335
|
+
return item;
|
|
336
|
+
} //只有是对象(键值对)才合并
|
|
337
|
+
|
|
338
|
+
|
|
339
|
+
return mergeWith(item, stateData, function (objValue, srcValue) {
|
|
340
|
+
//如果是数组,替换
|
|
341
|
+
if (isArray(objValue) || isArray(srcValue)) {
|
|
342
|
+
return srcValue;
|
|
343
|
+
}
|
|
344
|
+
});
|
|
345
|
+
});
|
|
346
|
+
};
|
|
347
|
+
|
|
348
|
+
/**
|
|
349
|
+
* 唯一id
|
|
350
|
+
*/
|
|
351
|
+
|
|
352
|
+
var generateId = function generateId() {
|
|
353
|
+
return Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36);
|
|
354
|
+
};
|
|
355
|
+
/**
|
|
356
|
+
* ref 传递
|
|
357
|
+
*/
|
|
358
|
+
|
|
359
|
+
var createExpose = function createExpose(methods, targetRef) {
|
|
360
|
+
return reduce(methods, function (pair, method) {
|
|
361
|
+
return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, method, function () {
|
|
362
|
+
var _targetRef$value, _targetRef$value$meth;
|
|
363
|
+
|
|
364
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
365
|
+
params[_key] = arguments[_key];
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
return (_targetRef$value = targetRef.value) === null || _targetRef$value === void 0 ? void 0 : (_targetRef$value$meth = _targetRef$value[method]) === null || _targetRef$value$meth === void 0 ? void 0 : _targetRef$value$meth.call.apply(_targetRef$value$meth, [_targetRef$value].concat(params));
|
|
369
|
+
}));
|
|
370
|
+
}, {});
|
|
371
|
+
};
|
|
372
|
+
|
|
373
|
+
/**
|
|
374
|
+
* 获取Column的valueType,默认"text"
|
|
375
|
+
* @param column
|
|
156
376
|
*/
|
|
157
377
|
|
|
158
378
|
var getColumnValueType = function getColumnValueType(column) {
|
|
159
379
|
return column.formValueType || column.valueType || "text";
|
|
160
380
|
};
|
|
161
|
-
/**
|
|
162
|
-
*获取Column的FormItem name
|
|
163
|
-
* @param column
|
|
381
|
+
/**
|
|
382
|
+
*获取Column的FormItem name
|
|
383
|
+
* @param column
|
|
164
384
|
*/
|
|
165
385
|
|
|
166
386
|
var getColumnFormItemName = function getColumnFormItemName(column) {
|
|
@@ -168,12 +388,12 @@ var getColumnFormItemName = function getColumnFormItemName(column) {
|
|
|
168
388
|
|
|
169
389
|
return ((_column$formItemProps = column.formItemProps) === null || _column$formItemProps === void 0 ? void 0 : _column$formItemProps.name) || column.dataIndex;
|
|
170
390
|
};
|
|
171
|
-
/**
|
|
172
|
-
* 根据Column生成FormItem VNode
|
|
173
|
-
* formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
|
|
174
|
-
* @param formElementMap
|
|
175
|
-
* @param column
|
|
176
|
-
* @param needRules
|
|
391
|
+
/**
|
|
392
|
+
* 根据Column生成FormItem VNode
|
|
393
|
+
* formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
|
|
394
|
+
* @param formElementMap
|
|
395
|
+
* @param column
|
|
396
|
+
* @param needRules
|
|
177
397
|
*/
|
|
178
398
|
|
|
179
399
|
var getFormItemEl = function getFormItemEl(formElementMap, column) {
|
|
@@ -198,11 +418,11 @@ var getFormItemEl = function getFormItemEl(formElementMap, column) {
|
|
|
198
418
|
showProps: column.showProps
|
|
199
419
|
}), (_column$formFieldProp = column.formFieldProps) === null || _column$formFieldProp === void 0 ? void 0 : _column$formFieldProp.slots);
|
|
200
420
|
};
|
|
201
|
-
/**
|
|
202
|
-
* 根据Column生成Item VNode
|
|
203
|
-
* @param elementMap
|
|
204
|
-
* @param column
|
|
205
|
-
* @param value
|
|
421
|
+
/**
|
|
422
|
+
* 根据Column生成Item VNode
|
|
423
|
+
* @param elementMap
|
|
424
|
+
* @param column
|
|
425
|
+
* @param value
|
|
206
426
|
*/
|
|
207
427
|
|
|
208
428
|
var getItemEl = function getItemEl(elementMap, column, value) {
|
|
@@ -234,44 +454,44 @@ var RequestAction = {
|
|
|
234
454
|
|
|
235
455
|
var proModuleProps = function proModuleProps() {
|
|
236
456
|
return {
|
|
237
|
-
/**
|
|
238
|
-
* module状态
|
|
457
|
+
/**
|
|
458
|
+
* module状态
|
|
239
459
|
*/
|
|
240
460
|
state: {
|
|
241
461
|
type: Object
|
|
242
462
|
},
|
|
243
463
|
|
|
244
|
-
/**
|
|
245
|
-
* 配置(静态)
|
|
464
|
+
/**
|
|
465
|
+
* 配置(静态)
|
|
246
466
|
*/
|
|
247
467
|
columns: {
|
|
248
468
|
type: Array
|
|
249
469
|
},
|
|
250
470
|
|
|
251
|
-
/**
|
|
252
|
-
* 配置(动态)
|
|
253
|
-
* columns动态属性兼容
|
|
471
|
+
/**
|
|
472
|
+
* 配置(动态)
|
|
473
|
+
* columns动态属性兼容
|
|
254
474
|
*/
|
|
255
475
|
columnState: {
|
|
256
476
|
type: Object
|
|
257
477
|
},
|
|
258
478
|
|
|
259
|
-
/**
|
|
260
|
-
* 展示组件集
|
|
479
|
+
/**
|
|
480
|
+
* 展示组件集
|
|
261
481
|
*/
|
|
262
482
|
elementMap: {
|
|
263
483
|
type: Object
|
|
264
484
|
},
|
|
265
485
|
|
|
266
|
-
/**
|
|
267
|
-
* 录入组件集
|
|
486
|
+
/**
|
|
487
|
+
* 录入组件集
|
|
268
488
|
*/
|
|
269
489
|
formElementMap: {
|
|
270
490
|
type: Object
|
|
271
491
|
},
|
|
272
492
|
|
|
273
|
-
/**
|
|
274
|
-
* requests
|
|
493
|
+
/**
|
|
494
|
+
* requests
|
|
275
495
|
*/
|
|
276
496
|
requests: {
|
|
277
497
|
type: Array
|
|
@@ -282,27 +502,15 @@ var proModuleProps = function proModuleProps() {
|
|
|
282
502
|
var ProModule = defineComponent({
|
|
283
503
|
props: _objectSpread2({}, proModuleProps()),
|
|
284
504
|
setup: function setup(props, _ref) {
|
|
285
|
-
var slots = _ref.slots
|
|
505
|
+
var slots = _ref.slots,
|
|
506
|
+
expose = _ref.expose;
|
|
286
507
|
|
|
287
|
-
/**
|
|
288
|
-
* columns columnState 合并
|
|
508
|
+
/**
|
|
509
|
+
* columns columnState 合并
|
|
289
510
|
*/
|
|
290
511
|
var columns = computed(function () {
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
var mapData = get(props.columnState, getColumnFormItemName(item));
|
|
294
|
-
|
|
295
|
-
if (isObject(mapData) && !isEmpty(mapData) && !isArray(mapData) && !isFunction(mapData)) {
|
|
296
|
-
//合并
|
|
297
|
-
return mergeWith(item, mapData, function (objValue, srcValue) {
|
|
298
|
-
//如果是数组,替换
|
|
299
|
-
if (isArray(objValue) || isArray(srcValue)) {
|
|
300
|
-
return srcValue;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return item;
|
|
512
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
513
|
+
return getColumnFormItemName(item);
|
|
306
514
|
});
|
|
307
515
|
});
|
|
308
516
|
/*********************************** 渲染组件 ***************************************/
|
|
@@ -456,6 +664,10 @@ var ProModule = defineComponent({
|
|
|
456
664
|
requests: props.requests,
|
|
457
665
|
sendRequest: sendRequest
|
|
458
666
|
});
|
|
667
|
+
expose({
|
|
668
|
+
sendEvent: sendEvent,
|
|
669
|
+
sendRequest: sendRequest
|
|
670
|
+
});
|
|
459
671
|
return function () {
|
|
460
672
|
var _slots$default;
|
|
461
673
|
|
|
@@ -538,18 +750,23 @@ var CurdAddAction;
|
|
|
538
750
|
CurdAddAction["CONTINUE"] = "CONTINUE";
|
|
539
751
|
})(CurdAddAction || (CurdAddAction = {}));
|
|
540
752
|
|
|
753
|
+
var defaultPage = {
|
|
754
|
+
page: 1,
|
|
755
|
+
pageSize: 10
|
|
756
|
+
};
|
|
757
|
+
|
|
541
758
|
var proCurdProps = function proCurdProps() {
|
|
542
759
|
return {
|
|
543
|
-
/**
|
|
544
|
-
* 列表 或 详情 的唯一标识
|
|
760
|
+
/**
|
|
761
|
+
* 列表 或 详情 的唯一标识
|
|
545
762
|
*/
|
|
546
763
|
rowKey: {
|
|
547
764
|
type: String,
|
|
548
765
|
"default": "id"
|
|
549
766
|
},
|
|
550
767
|
|
|
551
|
-
/**
|
|
552
|
-
* operates
|
|
768
|
+
/**
|
|
769
|
+
* operates
|
|
553
770
|
*/
|
|
554
771
|
operates: {
|
|
555
772
|
type: Array
|
|
@@ -574,17 +791,18 @@ var proCurdProps = function proCurdProps() {
|
|
|
574
791
|
var Curd = defineComponent({
|
|
575
792
|
props: _objectSpread2({}, proCurdProps()),
|
|
576
793
|
setup: function setup(props, _ref) {
|
|
577
|
-
var slots = _ref.slots
|
|
794
|
+
var slots = _ref.slots,
|
|
795
|
+
expose = _ref.expose;
|
|
578
796
|
|
|
579
797
|
var _ref2 = useProModule(),
|
|
580
798
|
columns = _ref2.columns,
|
|
581
799
|
state = _ref2.state,
|
|
582
800
|
sendEvent = _ref2.sendEvent,
|
|
583
801
|
sendRequest = _ref2.sendRequest;
|
|
584
|
-
/**
|
|
585
|
-
* 排序
|
|
586
|
-
* @param list
|
|
587
|
-
* @param propName
|
|
802
|
+
/**
|
|
803
|
+
* 排序
|
|
804
|
+
* @param list
|
|
805
|
+
* @param propName
|
|
588
806
|
*/
|
|
589
807
|
|
|
590
808
|
|
|
@@ -593,8 +811,8 @@ var Curd = defineComponent({
|
|
|
593
811
|
return get(item, propName);
|
|
594
812
|
});
|
|
595
813
|
};
|
|
596
|
-
/**
|
|
597
|
-
* 非 hideInForm columns
|
|
814
|
+
/**
|
|
815
|
+
* 非 hideInForm columns
|
|
598
816
|
*/
|
|
599
817
|
|
|
600
818
|
|
|
@@ -603,8 +821,8 @@ var Curd = defineComponent({
|
|
|
603
821
|
return !item.hideInForm;
|
|
604
822
|
}), "formSort");
|
|
605
823
|
});
|
|
606
|
-
/**
|
|
607
|
-
* 非 hideInDetail columns
|
|
824
|
+
/**
|
|
825
|
+
* 非 hideInDetail columns
|
|
608
826
|
*/
|
|
609
827
|
|
|
610
828
|
var descColumns = computed(function () {
|
|
@@ -612,8 +830,8 @@ var Curd = defineComponent({
|
|
|
612
830
|
return !item.hideInDetail;
|
|
613
831
|
}), "descSort");
|
|
614
832
|
});
|
|
615
|
-
/**
|
|
616
|
-
* 非 hideInTable columns
|
|
833
|
+
/**
|
|
834
|
+
* 非 hideInTable columns
|
|
617
835
|
*/
|
|
618
836
|
|
|
619
837
|
var tableColumns = computed(function () {
|
|
@@ -621,8 +839,8 @@ var Curd = defineComponent({
|
|
|
621
839
|
return !item.hideInTable;
|
|
622
840
|
}), "tableSort");
|
|
623
841
|
});
|
|
624
|
-
/**
|
|
625
|
-
* search columns
|
|
842
|
+
/**
|
|
843
|
+
* search columns
|
|
626
844
|
*/
|
|
627
845
|
|
|
628
846
|
var searchColumns = computed(function () {
|
|
@@ -643,12 +861,18 @@ var Curd = defineComponent({
|
|
|
643
861
|
var sendCurdEvent = function sendCurdEvent(event) {
|
|
644
862
|
sendEvent({
|
|
645
863
|
type: event.action,
|
|
646
|
-
payload: omit(event, "action")
|
|
864
|
+
payload: omit(event, "action", "source"),
|
|
865
|
+
source: event.source
|
|
647
866
|
});
|
|
648
867
|
}; //事件订阅
|
|
649
868
|
|
|
650
869
|
|
|
651
870
|
useModuleEvent(function (event) {
|
|
871
|
+
//如果当前event存在source 不处理
|
|
872
|
+
if (event.source) {
|
|
873
|
+
return;
|
|
874
|
+
}
|
|
875
|
+
|
|
652
876
|
var action = event.type;
|
|
653
877
|
var _ref3 = event.payload,
|
|
654
878
|
type = _ref3.type,
|
|
@@ -725,6 +949,11 @@ var Curd = defineComponent({
|
|
|
725
949
|
descProps: descProps,
|
|
726
950
|
modalProps: modalProps
|
|
727
951
|
});
|
|
952
|
+
expose({
|
|
953
|
+
sendCurdEvent: sendCurdEvent,
|
|
954
|
+
getOperate: getOperate,
|
|
955
|
+
refreshList: handleSearch
|
|
956
|
+
});
|
|
728
957
|
return function () {
|
|
729
958
|
var _slots$default;
|
|
730
959
|
|
|
@@ -741,7 +970,10 @@ var ProCurd = defineComponent({
|
|
|
741
970
|
setup: function setup(props, _ref4) {
|
|
742
971
|
var _curdOperateOpts;
|
|
743
972
|
|
|
744
|
-
var slots = _ref4.slots
|
|
973
|
+
var slots = _ref4.slots,
|
|
974
|
+
expose = _ref4.expose;
|
|
975
|
+
var moduleRef = ref();
|
|
976
|
+
var curdRef = ref();
|
|
745
977
|
var curdState = props.curdState || reactive({
|
|
746
978
|
detailData: {}
|
|
747
979
|
});
|
|
@@ -793,183 +1025,913 @@ var ProCurd = defineComponent({
|
|
|
793
1025
|
},
|
|
794
1026
|
label: "删除"
|
|
795
1027
|
}), _curdOperateOpts);
|
|
1028
|
+
/****************************** columns分类 *************************************/
|
|
1029
|
+
|
|
796
1030
|
var requests = map(props.operates, function (item) {
|
|
797
1031
|
var curdOpts = get(curdOperateOpts, item.action);
|
|
798
1032
|
return _objectSpread2(_objectSpread2({}, curdOpts), item);
|
|
799
1033
|
});
|
|
800
1034
|
var moduleKeys = keys(omit(ProModule.props, "state", "requests"));
|
|
1035
|
+
expose({
|
|
1036
|
+
moduleRef: moduleRef,
|
|
1037
|
+
curdRef: curdRef
|
|
1038
|
+
});
|
|
801
1039
|
return function () {
|
|
802
|
-
return
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
}),
|
|
1040
|
+
return createVNode(ProModule, mergeProps({
|
|
1041
|
+
"ref": moduleRef
|
|
1042
|
+
}, pick(props, moduleKeys), {
|
|
1043
|
+
"state": curdState,
|
|
1044
|
+
"requests": requests
|
|
1045
|
+
}), {
|
|
1046
|
+
"default": function _default() {
|
|
1047
|
+
return [createVNode(Curd, mergeProps({
|
|
1048
|
+
"ref": curdRef
|
|
1049
|
+
}, omit.apply(void 0, [props].concat(_toConsumableArray(moduleKeys), ["curdState", "operates"])), {
|
|
1050
|
+
"operates": requests
|
|
1051
|
+
}), slots)];
|
|
1052
|
+
}
|
|
1053
|
+
});
|
|
808
1054
|
};
|
|
809
1055
|
}
|
|
810
1056
|
});
|
|
811
1057
|
|
|
812
|
-
var
|
|
813
|
-
var useProForm = function useProForm() {
|
|
814
|
-
return inject(ProFormKey);
|
|
815
|
-
};
|
|
816
|
-
|
|
817
|
-
var provideProForm = function provideProForm(ctx) {
|
|
818
|
-
provide(ProFormKey, ctx);
|
|
819
|
-
};
|
|
820
|
-
|
|
821
|
-
var proFormProps = function proFormProps() {
|
|
1058
|
+
var modalCurdProps = function modalCurdProps() {
|
|
822
1059
|
return {
|
|
823
|
-
|
|
824
|
-
* 同 antd 或 element form中的model
|
|
825
|
-
*/
|
|
826
|
-
model: {
|
|
1060
|
+
defaultAddRecord: {
|
|
827
1061
|
type: Object
|
|
828
|
-
}
|
|
1062
|
+
}
|
|
1063
|
+
};
|
|
1064
|
+
};
|
|
829
1065
|
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
1066
|
+
/**
|
|
1067
|
+
* 事件处理
|
|
1068
|
+
*/
|
|
1069
|
+
var ModalCurd = defineComponent({
|
|
1070
|
+
props: _objectSpread2({}, modalCurdProps()),
|
|
1071
|
+
setup: function setup(props) {
|
|
1072
|
+
var _listProps$value;
|
|
1073
|
+
|
|
1074
|
+
var _useProModule = useProModule(),
|
|
1075
|
+
dispatch = _useProModule.dispatch,
|
|
1076
|
+
sendRequest = _useProModule.sendRequest;
|
|
1077
|
+
|
|
1078
|
+
var _useProCurd = useProCurd(),
|
|
1079
|
+
rowKey = _useProCurd.rowKey,
|
|
1080
|
+
curdState = _useProCurd.curdState,
|
|
1081
|
+
listProps = _useProCurd.listProps,
|
|
1082
|
+
getOperate = _useProCurd.getOperate,
|
|
1083
|
+
refreshList = _useProCurd.refreshList;
|
|
1084
|
+
|
|
1085
|
+
var pageState = (listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState) || reactive(_objectSpread2({}, defaultPage)); //发送详情接口
|
|
1086
|
+
|
|
1087
|
+
var sendDetailRequest = function sendDetailRequest(record) {
|
|
1088
|
+
var operateOpts = getOperate(CurdAction.DETAIL);
|
|
1089
|
+
|
|
1090
|
+
if (operateOpts !== null && operateOpts !== void 0 && operateOpts.actor) {
|
|
1091
|
+
//如果注册了详情接口 发起请求
|
|
1092
|
+
sendRequest(CurdAction.DETAIL, record, rowKey);
|
|
1093
|
+
} else {
|
|
1094
|
+
//直接使用当前record作为详情数据
|
|
1095
|
+
dispatch({
|
|
1096
|
+
type: "detailData",
|
|
1097
|
+
payload: record
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
};
|
|
837
1101
|
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
* rules 根据rules中方法生成showState对象
|
|
841
|
-
*/
|
|
842
|
-
showState: {
|
|
843
|
-
type: Object
|
|
844
|
-
},
|
|
845
|
-
showStateRules: {
|
|
846
|
-
type: Object
|
|
847
|
-
},
|
|
1102
|
+
var dealDetail = function dealDetail(subAction, _ref) {
|
|
1103
|
+
var record = _ref.record;
|
|
848
1104
|
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
},
|
|
1105
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1106
|
+
dispatch({
|
|
1107
|
+
type: "mode",
|
|
1108
|
+
payload: CurdCurrentMode.DETAIL
|
|
1109
|
+
});
|
|
1110
|
+
sendDetailRequest(record);
|
|
1111
|
+
}
|
|
1112
|
+
};
|
|
858
1113
|
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
1114
|
+
var dealAdd = function dealAdd(subAction) {
|
|
1115
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1116
|
+
dispatch({
|
|
1117
|
+
type: "mode",
|
|
1118
|
+
payload: CurdCurrentMode.ADD
|
|
1119
|
+
});
|
|
1120
|
+
dispatch({
|
|
1121
|
+
type: "detailData",
|
|
1122
|
+
payload: props.defaultAddRecord || {}
|
|
1123
|
+
});
|
|
1124
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1125
|
+
//添加成功
|
|
1126
|
+
pageState.page = 1; //重置当前页数
|
|
1127
|
+
//刷新List
|
|
868
1128
|
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
columns: {
|
|
873
|
-
type: Array
|
|
874
|
-
},
|
|
1129
|
+
refreshList({
|
|
1130
|
+
page: 1
|
|
1131
|
+
});
|
|
875
1132
|
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
1133
|
+
if (curdState.addAction === CurdAddAction.CONTINUE) {
|
|
1134
|
+
dispatch({
|
|
1135
|
+
type: "detailData",
|
|
1136
|
+
payload: props.defaultAddRecord || {}
|
|
1137
|
+
});
|
|
1138
|
+
} else {
|
|
1139
|
+
dispatch({
|
|
1140
|
+
type: "mode",
|
|
1141
|
+
payload: undefined
|
|
1142
|
+
});
|
|
1143
|
+
}
|
|
1144
|
+
}
|
|
1145
|
+
};
|
|
882
1146
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
*/
|
|
886
|
-
formElementMap: {
|
|
887
|
-
type: Object
|
|
888
|
-
},
|
|
1147
|
+
var dealEdit = function dealEdit(subAction, _ref2) {
|
|
1148
|
+
var record = _ref2.record;
|
|
889
1149
|
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
1150
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1151
|
+
dispatch({
|
|
1152
|
+
type: "mode",
|
|
1153
|
+
payload: CurdCurrentMode.EDIT
|
|
1154
|
+
});
|
|
1155
|
+
sendDetailRequest(record);
|
|
1156
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1157
|
+
// 编辑成功
|
|
1158
|
+
dispatch({
|
|
1159
|
+
type: "mode",
|
|
1160
|
+
payload: undefined
|
|
1161
|
+
}); //刷新列表
|
|
1162
|
+
|
|
1163
|
+
refreshList();
|
|
1164
|
+
}
|
|
1165
|
+
};
|
|
897
1166
|
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
1167
|
+
var dealDelete = function dealDelete(subAction) {
|
|
1168
|
+
if (subAction === CurdSubAction.SUCCESS) {
|
|
1169
|
+
//刷新列表
|
|
1170
|
+
refreshList();
|
|
1171
|
+
}
|
|
1172
|
+
};
|
|
1173
|
+
|
|
1174
|
+
useModuleEvent(function (_ref3) {
|
|
1175
|
+
var type = _ref3.type,
|
|
1176
|
+
payload = _ref3.payload,
|
|
1177
|
+
source = _ref3.source;
|
|
1178
|
+
|
|
1179
|
+
if (source) {
|
|
1180
|
+
return;
|
|
1181
|
+
}
|
|
1182
|
+
|
|
1183
|
+
var action = type;
|
|
1184
|
+
var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
|
|
1185
|
+
var record = payload === null || payload === void 0 ? void 0 : payload.record;
|
|
1186
|
+
|
|
1187
|
+
if (action === RequestAction.Success) {
|
|
1188
|
+
//覆盖
|
|
1189
|
+
action = get(payload, ["requestOpts", "action"]);
|
|
1190
|
+
subAction = CurdSubAction.SUCCESS;
|
|
1191
|
+
}
|
|
1192
|
+
|
|
1193
|
+
switch (action) {
|
|
1194
|
+
case CurdAction.DETAIL:
|
|
1195
|
+
dealDetail(subAction, {
|
|
1196
|
+
record: record
|
|
1197
|
+
});
|
|
1198
|
+
break;
|
|
1199
|
+
|
|
1200
|
+
case CurdAction.ADD:
|
|
1201
|
+
dealAdd(subAction);
|
|
1202
|
+
break;
|
|
1203
|
+
|
|
1204
|
+
case CurdAction.EDIT:
|
|
1205
|
+
dealEdit(subAction, {
|
|
1206
|
+
record: record
|
|
1207
|
+
});
|
|
1208
|
+
break;
|
|
1209
|
+
|
|
1210
|
+
case CurdAction.DELETE:
|
|
1211
|
+
dealDelete(subAction);
|
|
1212
|
+
break;
|
|
1213
|
+
}
|
|
1214
|
+
});
|
|
1215
|
+
return function () {
|
|
1216
|
+
return null;
|
|
1217
|
+
};
|
|
1218
|
+
}
|
|
1219
|
+
});
|
|
1220
|
+
var ProModalCurd = defineComponent({
|
|
1221
|
+
props: _objectSpread2(_objectSpread2({}, ProCurd.props), ModalCurd.props),
|
|
1222
|
+
setup: function setup(props, _ref4) {
|
|
1223
|
+
var slots = _ref4.slots;
|
|
1224
|
+
var invalidKeys = keys(ModalCurd.props);
|
|
1225
|
+
return function () {
|
|
1226
|
+
var _slots$default;
|
|
1227
|
+
|
|
1228
|
+
return createVNode(ProCurd, omit(props, invalidKeys), {
|
|
1229
|
+
"default": function _default() {
|
|
1230
|
+
return [createVNode(ModalCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1231
|
+
}
|
|
1232
|
+
});
|
|
1233
|
+
};
|
|
1234
|
+
}
|
|
1235
|
+
});
|
|
1236
|
+
|
|
1237
|
+
var pageCurdProps = function pageCurdProps() {
|
|
1238
|
+
return {
|
|
1239
|
+
defaultAddRecord: {
|
|
902
1240
|
type: Object
|
|
1241
|
+
},
|
|
1242
|
+
routeBack: {
|
|
1243
|
+
type: Function
|
|
903
1244
|
}
|
|
904
1245
|
};
|
|
905
1246
|
};
|
|
906
1247
|
|
|
907
|
-
var
|
|
908
|
-
props: _objectSpread2({},
|
|
909
|
-
setup: function setup(props
|
|
910
|
-
var
|
|
911
|
-
var
|
|
1248
|
+
var PageCurd = defineComponent({
|
|
1249
|
+
props: _objectSpread2({}, pageCurdProps()),
|
|
1250
|
+
setup: function setup(props) {
|
|
1251
|
+
var router = useRouter();
|
|
1252
|
+
var route = useRoute();
|
|
1253
|
+
|
|
1254
|
+
var _useProModule = useProModule(),
|
|
1255
|
+
dispatch = _useProModule.dispatch,
|
|
1256
|
+
sendRequest = _useProModule.sendRequest;
|
|
1257
|
+
|
|
1258
|
+
var _useProCurd = useProCurd(),
|
|
1259
|
+
rowKey = _useProCurd.rowKey,
|
|
1260
|
+
curdState = _useProCurd.curdState;
|
|
1261
|
+
|
|
1262
|
+
var dealList = function dealList(subAction) {
|
|
1263
|
+
if (subAction === CurdSubAction.PAGE) {
|
|
1264
|
+
//其实就是个重置过程
|
|
1265
|
+
dispatch({
|
|
1266
|
+
type: "mode",
|
|
1267
|
+
payload: undefined
|
|
1268
|
+
});
|
|
1269
|
+
dispatch({
|
|
1270
|
+
type: "detailData",
|
|
1271
|
+
payload: {}
|
|
1272
|
+
});
|
|
1273
|
+
dispatch({
|
|
1274
|
+
type: "detailLoading",
|
|
1275
|
+
payload: false
|
|
1276
|
+
});
|
|
1277
|
+
dispatch({
|
|
1278
|
+
type: "addAction",
|
|
1279
|
+
payload: undefined
|
|
1280
|
+
});
|
|
1281
|
+
}
|
|
1282
|
+
};
|
|
912
1283
|
|
|
913
|
-
var
|
|
914
|
-
|
|
915
|
-
var disableState = props.disableState || reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
|
|
1284
|
+
var dealDetail = function dealDetail(subAction, _ref) {
|
|
1285
|
+
var record = _ref.record;
|
|
916
1286
|
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
1287
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1288
|
+
router.push({
|
|
1289
|
+
path: "".concat(route.path, "/detail"),
|
|
1290
|
+
query: pick(record, rowKey)
|
|
1291
|
+
});
|
|
1292
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1293
|
+
dispatch({
|
|
1294
|
+
type: "mode",
|
|
1295
|
+
payload: CurdCurrentMode.DETAIL
|
|
921
1296
|
});
|
|
1297
|
+
sendRequest(CurdAction.DETAIL, route.query, rowKey);
|
|
922
1298
|
}
|
|
1299
|
+
};
|
|
923
1300
|
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
1301
|
+
var dealAdd = function dealAdd(subAction) {
|
|
1302
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1303
|
+
router.push({
|
|
1304
|
+
path: "".concat(route.path, "/add")
|
|
927
1305
|
});
|
|
1306
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1307
|
+
dispatch({
|
|
1308
|
+
type: "mode",
|
|
1309
|
+
payload: CurdCurrentMode.ADD
|
|
1310
|
+
});
|
|
1311
|
+
dispatch({
|
|
1312
|
+
type: "detailData",
|
|
1313
|
+
payload: props.defaultAddRecord || {}
|
|
1314
|
+
});
|
|
1315
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1316
|
+
if (curdState.addAction === CurdAddAction.CONTINUE) {
|
|
1317
|
+
dispatch({
|
|
1318
|
+
type: "detailData",
|
|
1319
|
+
payload: props.defaultAddRecord || {}
|
|
1320
|
+
});
|
|
1321
|
+
} else {
|
|
1322
|
+
props.routeBack ? props.routeBack(CurdAction.ADD) : router.go(-1);
|
|
1323
|
+
}
|
|
928
1324
|
}
|
|
1325
|
+
};
|
|
929
1326
|
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
1327
|
+
var dealEdit = function dealEdit(subAction, _ref2) {
|
|
1328
|
+
var record = _ref2.record;
|
|
1329
|
+
|
|
1330
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1331
|
+
router.push({
|
|
1332
|
+
path: "".concat(route.path, "/edit"),
|
|
1333
|
+
query: pick(record, rowKey)
|
|
1334
|
+
});
|
|
1335
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1336
|
+
dispatch({
|
|
1337
|
+
type: "mode",
|
|
1338
|
+
payload: CurdCurrentMode.EDIT
|
|
933
1339
|
});
|
|
1340
|
+
sendRequest(CurdAction.DETAIL, route.query, rowKey);
|
|
1341
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1342
|
+
props.routeBack ? props.routeBack(CurdAction.EDIT) : router.go(-1);
|
|
934
1343
|
}
|
|
935
|
-
}
|
|
1344
|
+
};
|
|
936
1345
|
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
* 将columns 转化为FormItem VNode对象
|
|
942
|
-
*/
|
|
1346
|
+
useModuleEvent(function (_ref3) {
|
|
1347
|
+
var type = _ref3.type,
|
|
1348
|
+
payload = _ref3.payload,
|
|
1349
|
+
source = _ref3.source;
|
|
943
1350
|
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
return [];
|
|
1351
|
+
if (source) {
|
|
1352
|
+
return;
|
|
947
1353
|
}
|
|
948
1354
|
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1355
|
+
var action = type;
|
|
1356
|
+
var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
|
|
1357
|
+
var record = payload === null || payload === void 0 ? void 0 : payload.record;
|
|
1358
|
+
|
|
1359
|
+
if (action === RequestAction.Success) {
|
|
1360
|
+
//覆盖
|
|
1361
|
+
action = get(payload, ["requestOpts", "action"]);
|
|
1362
|
+
subAction = CurdSubAction.SUCCESS;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
switch (action) {
|
|
1366
|
+
case CurdAction.LIST:
|
|
1367
|
+
dealList(subAction);
|
|
1368
|
+
break;
|
|
1369
|
+
|
|
1370
|
+
case CurdAction.DETAIL:
|
|
1371
|
+
dealDetail(subAction, {
|
|
1372
|
+
record: record
|
|
1373
|
+
});
|
|
1374
|
+
break;
|
|
1375
|
+
|
|
1376
|
+
case CurdAction.ADD:
|
|
1377
|
+
dealAdd(subAction);
|
|
1378
|
+
break;
|
|
1379
|
+
|
|
1380
|
+
case CurdAction.EDIT:
|
|
1381
|
+
dealEdit(subAction, {
|
|
1382
|
+
record: record
|
|
1383
|
+
});
|
|
1384
|
+
break;
|
|
1385
|
+
}
|
|
952
1386
|
});
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
formItemVNodes: formItemVNodes
|
|
964
|
-
}, props.provideExtra));
|
|
1387
|
+
return function () {
|
|
1388
|
+
return null;
|
|
1389
|
+
};
|
|
1390
|
+
}
|
|
1391
|
+
});
|
|
1392
|
+
var ProPageCurd = defineComponent({
|
|
1393
|
+
props: _objectSpread2(_objectSpread2({}, ProCurd.props), PageCurd.props),
|
|
1394
|
+
setup: function setup(props, _ref4) {
|
|
1395
|
+
var slots = _ref4.slots;
|
|
1396
|
+
var invalidKeys = keys(PageCurd.props);
|
|
965
1397
|
return function () {
|
|
966
1398
|
var _slots$default;
|
|
967
1399
|
|
|
968
|
-
return (
|
|
1400
|
+
return createVNode(ProCurd, omit(props, invalidKeys), {
|
|
1401
|
+
"default": function _default() {
|
|
1402
|
+
return [createVNode(PageCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1403
|
+
}
|
|
1404
|
+
});
|
|
969
1405
|
};
|
|
970
1406
|
}
|
|
971
1407
|
});
|
|
972
1408
|
|
|
1409
|
+
function _isSlot(s) {
|
|
1410
|
+
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
|
|
1411
|
+
}
|
|
1412
|
+
|
|
1413
|
+
var createCurdDesc = function createCurdDesc(Descriptions, DescriptionsItem) {
|
|
1414
|
+
return defineComponent({
|
|
1415
|
+
props: _objectSpread2({}, Descriptions.props),
|
|
1416
|
+
setup: function setup(props, _ref) {
|
|
1417
|
+
var slots = _ref.slots;
|
|
1418
|
+
|
|
1419
|
+
var _useProModule = useProModule(),
|
|
1420
|
+
getItemVNode = _useProModule.getItemVNode;
|
|
1421
|
+
|
|
1422
|
+
var _useProCurd = useProCurd(),
|
|
1423
|
+
curdState = _useProCurd.curdState,
|
|
1424
|
+
descColumns = _useProCurd.descColumns;
|
|
1425
|
+
|
|
1426
|
+
var descVNodes = computed(function () {
|
|
1427
|
+
return map(descColumns.value, function (item) {
|
|
1428
|
+
var _slot;
|
|
1429
|
+
|
|
1430
|
+
var value = get(curdState.detailData, item.dataIndex);
|
|
1431
|
+
return createVNode(DescriptionsItem, mergeProps({
|
|
1432
|
+
"key": item.dataIndex,
|
|
1433
|
+
"label": item.title
|
|
1434
|
+
}, get(item.extra, "desc")), _isSlot(_slot = getItemVNode(item, value)) ? _slot : {
|
|
1435
|
+
"default": function _default() {
|
|
1436
|
+
return [_slot];
|
|
1437
|
+
}
|
|
1438
|
+
});
|
|
1439
|
+
});
|
|
1440
|
+
});
|
|
1441
|
+
return function () {
|
|
1442
|
+
var _slots$start, _slots$default;
|
|
1443
|
+
|
|
1444
|
+
return createVNode(Descriptions, props, _objectSpread2({
|
|
1445
|
+
"default": function _default() {
|
|
1446
|
+
return [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), descVNodes, (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1447
|
+
}
|
|
1448
|
+
}, omit(slots, "default", "start")));
|
|
1449
|
+
};
|
|
1450
|
+
}
|
|
1451
|
+
});
|
|
1452
|
+
};
|
|
1453
|
+
|
|
1454
|
+
var proCurdAddOrEditProps = function proCurdAddOrEditProps() {
|
|
1455
|
+
return {
|
|
1456
|
+
//是否使用operate bar
|
|
1457
|
+
operateBar: {
|
|
1458
|
+
type: Boolean,
|
|
1459
|
+
"default": true
|
|
1460
|
+
},
|
|
1461
|
+
//显示 确定并继续 按钮
|
|
1462
|
+
showContinueAdd: {
|
|
1463
|
+
type: Boolean,
|
|
1464
|
+
"default": false
|
|
1465
|
+
},
|
|
1466
|
+
//
|
|
1467
|
+
okText: {
|
|
1468
|
+
type: String,
|
|
1469
|
+
"default": "确定"
|
|
1470
|
+
},
|
|
1471
|
+
okButtonProps: {
|
|
1472
|
+
type: Object
|
|
1473
|
+
},
|
|
1474
|
+
//
|
|
1475
|
+
continueText: {
|
|
1476
|
+
type: String,
|
|
1477
|
+
"default": "确定并继续"
|
|
1478
|
+
},
|
|
1479
|
+
continueButtonProps: {
|
|
1480
|
+
type: Object
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
};
|
|
1484
|
+
|
|
1485
|
+
var createCurdForm = function createCurdForm(Form, Button, convertFormProps) {
|
|
1486
|
+
return defineComponent({
|
|
1487
|
+
props: _objectSpread2(_objectSpread2({}, Form.props), proCurdAddOrEditProps()),
|
|
1488
|
+
setup: function setup(props, _ref) {
|
|
1489
|
+
var slots = _ref.slots;
|
|
1490
|
+
|
|
1491
|
+
var _useProModule = useProModule(),
|
|
1492
|
+
elementMap = _useProModule.elementMap,
|
|
1493
|
+
formElementMap = _useProModule.formElementMap;
|
|
1494
|
+
|
|
1495
|
+
var _useProCurd = useProCurd(),
|
|
1496
|
+
curdState = _useProCurd.curdState,
|
|
1497
|
+
formColumns = _useProCurd.formColumns,
|
|
1498
|
+
sendCurdEvent = _useProCurd.sendCurdEvent;
|
|
1499
|
+
|
|
1500
|
+
var formRef = ref();
|
|
1501
|
+
|
|
1502
|
+
var handleFinish = function handleFinish(values) {
|
|
1503
|
+
if (curdState.mode === CurdCurrentMode.EDIT) {
|
|
1504
|
+
//edit
|
|
1505
|
+
sendCurdEvent({
|
|
1506
|
+
action: CurdAction.EDIT,
|
|
1507
|
+
type: CurdSubAction.EXECUTE,
|
|
1508
|
+
values: values
|
|
1509
|
+
});
|
|
1510
|
+
} else {
|
|
1511
|
+
//add
|
|
1512
|
+
sendCurdEvent({
|
|
1513
|
+
action: CurdAction.ADD,
|
|
1514
|
+
type: CurdSubAction.EXECUTE,
|
|
1515
|
+
values: values
|
|
1516
|
+
});
|
|
1517
|
+
}
|
|
1518
|
+
};
|
|
1519
|
+
|
|
1520
|
+
var handleAdd = function handleAdd() {
|
|
1521
|
+
var _formRef$value;
|
|
1522
|
+
|
|
1523
|
+
curdState.addAction = CurdAddAction.NORMAL;
|
|
1524
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
1525
|
+
};
|
|
1526
|
+
|
|
1527
|
+
var handleContinueAdd = function handleContinueAdd() {
|
|
1528
|
+
var _formRef$value2;
|
|
1529
|
+
|
|
1530
|
+
curdState.addAction = CurdAddAction.CONTINUE;
|
|
1531
|
+
(_formRef$value2 = formRef.value) === null || _formRef$value2 === void 0 ? void 0 : _formRef$value2.submit();
|
|
1532
|
+
};
|
|
1533
|
+
|
|
1534
|
+
return function () {
|
|
1535
|
+
var _slots$divide, _slots$operateStart, _slots$operateCenter, _slots$operateEnd, _slots$default;
|
|
1536
|
+
|
|
1537
|
+
return createVNode(Form, mergeProps({
|
|
1538
|
+
"ref": formRef
|
|
1539
|
+
}, props, {
|
|
1540
|
+
"elementMap": props.elementMap || elementMap,
|
|
1541
|
+
"formElementMap": props.formElementMap || formElementMap,
|
|
1542
|
+
"columns": formColumns.value,
|
|
1543
|
+
"model": curdState.detailData,
|
|
1544
|
+
"readonly": curdState.mode === CurdCurrentMode.DETAIL,
|
|
1545
|
+
"onFinish": handleFinish
|
|
1546
|
+
}, convertFormProps === null || convertFormProps === void 0 ? void 0 : convertFormProps(curdState)), _objectSpread2({
|
|
1547
|
+
"default": function _default() {
|
|
1548
|
+
return [(_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), props.operateBar && createVNode("div", {
|
|
1549
|
+
"class": "pro-curd-form-operate"
|
|
1550
|
+
}, [(_slots$operateStart = slots.operateStart) === null || _slots$operateStart === void 0 ? void 0 : _slots$operateStart.call(slots), curdState.mode !== CurdCurrentMode.DETAIL && createVNode(Button, mergeProps({
|
|
1551
|
+
"onClick": handleAdd
|
|
1552
|
+
}, props.okButtonProps, {
|
|
1553
|
+
"loading": curdState.operateLoading
|
|
1554
|
+
}), {
|
|
1555
|
+
"default": function _default() {
|
|
1556
|
+
return [props.okText];
|
|
1557
|
+
}
|
|
1558
|
+
}), (_slots$operateCenter = slots.operateCenter) === null || _slots$operateCenter === void 0 ? void 0 : _slots$operateCenter.call(slots), props.showContinueAdd && curdState.mode === CurdCurrentMode.ADD && createVNode(Button, mergeProps({
|
|
1559
|
+
"onClick": handleContinueAdd
|
|
1560
|
+
}, props.continueButtonProps, {
|
|
1561
|
+
"loading": curdState.operateLoading
|
|
1562
|
+
}), {
|
|
1563
|
+
"default": function _default() {
|
|
1564
|
+
return [props.continueText];
|
|
1565
|
+
}
|
|
1566
|
+
}), (_slots$operateEnd = slots.operateEnd) === null || _slots$operateEnd === void 0 ? void 0 : _slots$operateEnd.call(slots)]), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1567
|
+
}
|
|
1568
|
+
}, omit(slots, "default", "divide", "operateStart", "operateCenter", "operateEnd")));
|
|
1569
|
+
};
|
|
1570
|
+
}
|
|
1571
|
+
});
|
|
1572
|
+
};
|
|
1573
|
+
|
|
1574
|
+
var proCurdListProps = function proCurdListProps() {
|
|
1575
|
+
return {
|
|
1576
|
+
/**
|
|
1577
|
+
* extra 是否放到SearchForm中
|
|
1578
|
+
*/
|
|
1579
|
+
extraInSearch: {
|
|
1580
|
+
type: Boolean,
|
|
1581
|
+
"default": undefined
|
|
1582
|
+
},
|
|
1583
|
+
//search
|
|
1584
|
+
searchProps: {
|
|
1585
|
+
type: Object
|
|
1586
|
+
},
|
|
1587
|
+
//table
|
|
1588
|
+
tableProps: {
|
|
1589
|
+
type: Object
|
|
1590
|
+
},
|
|
1591
|
+
//pageState
|
|
1592
|
+
pageState: {
|
|
1593
|
+
type: Object
|
|
1594
|
+
}
|
|
1595
|
+
};
|
|
1596
|
+
};
|
|
1597
|
+
|
|
1598
|
+
var createCurdList = function createCurdList(SearchForm, Table) {
|
|
1599
|
+
return defineComponent({
|
|
1600
|
+
props: _objectSpread2({}, proCurdListProps()),
|
|
1601
|
+
setup: function setup(props, _ref) {
|
|
1602
|
+
var slots = _ref.slots;
|
|
1603
|
+
|
|
1604
|
+
var _useProModule = useProModule(),
|
|
1605
|
+
elementMap = _useProModule.elementMap,
|
|
1606
|
+
formElementMap = _useProModule.formElementMap;
|
|
1607
|
+
|
|
1608
|
+
var _useProCurd = useProCurd(),
|
|
1609
|
+
curdState = _useProCurd.curdState,
|
|
1610
|
+
searchColumns = _useProCurd.searchColumns,
|
|
1611
|
+
tableColumns = _useProCurd.tableColumns,
|
|
1612
|
+
getOperate = _useProCurd.getOperate,
|
|
1613
|
+
sendCurdEvent = _useProCurd.sendCurdEvent;
|
|
1614
|
+
/******************* search pagination ********************/
|
|
1615
|
+
|
|
1616
|
+
|
|
1617
|
+
var pageState = props.pageState || reactive(_objectSpread2({}, defaultPage));
|
|
1618
|
+
var prevValues;
|
|
1619
|
+
|
|
1620
|
+
var handleSearch = function handleSearch() {
|
|
1621
|
+
sendCurdEvent({
|
|
1622
|
+
action: CurdAction.LIST,
|
|
1623
|
+
type: CurdSubAction.EMIT,
|
|
1624
|
+
values: _objectSpread2(_objectSpread2({}, prevValues), pageState)
|
|
1625
|
+
});
|
|
1626
|
+
};
|
|
1627
|
+
|
|
1628
|
+
var executeSearchWithResetPage = function executeSearchWithResetPage(values) {
|
|
1629
|
+
prevValues = values;
|
|
1630
|
+
pageState.page = 1;
|
|
1631
|
+
handleSearch();
|
|
1632
|
+
};
|
|
1633
|
+
/******************* table ********************/
|
|
1634
|
+
|
|
1635
|
+
|
|
1636
|
+
var createTableItem = function createTableItem(action) {
|
|
1637
|
+
var operate = getOperate(action);
|
|
1638
|
+
|
|
1639
|
+
var item = _objectSpread2(_objectSpread2({}, pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
|
|
1640
|
+
show: !isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
|
|
1641
|
+
value: action
|
|
1642
|
+
});
|
|
1643
|
+
|
|
1644
|
+
if (!item.onClick) {
|
|
1645
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1646
|
+
onClick: function onClick(record) {
|
|
1647
|
+
//默认发送事件
|
|
1648
|
+
sendCurdEvent({
|
|
1649
|
+
action: action,
|
|
1650
|
+
type: CurdSubAction.EMIT,
|
|
1651
|
+
record: record
|
|
1652
|
+
});
|
|
1653
|
+
}
|
|
1654
|
+
});
|
|
1655
|
+
}
|
|
1656
|
+
|
|
1657
|
+
return item;
|
|
1658
|
+
}; //table操作栏 items
|
|
1659
|
+
|
|
1660
|
+
|
|
1661
|
+
var tableOperateItems = [createTableItem(CurdAction.DETAIL), createTableItem(CurdAction.EDIT), createTableItem(CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
|
|
1662
|
+
|
|
1663
|
+
var convertOperateItems = function convertOperateItems(list) {
|
|
1664
|
+
return map(list, function (item) {
|
|
1665
|
+
if (!item.onClick) {
|
|
1666
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1667
|
+
onClick: function onClick(record) {
|
|
1668
|
+
sendCurdEvent({
|
|
1669
|
+
action: "operate",
|
|
1670
|
+
type: item.value,
|
|
1671
|
+
record: record
|
|
1672
|
+
});
|
|
1673
|
+
}
|
|
1674
|
+
});
|
|
1675
|
+
}
|
|
1676
|
+
|
|
1677
|
+
return item;
|
|
1678
|
+
});
|
|
1679
|
+
};
|
|
1680
|
+
|
|
1681
|
+
return function () {
|
|
1682
|
+
var _props$searchProps, _slots$divide, _curdState$listData, _slots$divide2, _slots$footerStart, _slots$pagination, _curdState$listData2, _slots$footerEnd;
|
|
1683
|
+
|
|
1684
|
+
var tableProps = props.tableProps;
|
|
1685
|
+
var extra = slots.extra ? createVNode("div", {
|
|
1686
|
+
"class": "pro-curd-list-extra"
|
|
1687
|
+
}, [slots.extra()]) : null;
|
|
1688
|
+
return createVNode(Fragment, null, [createVNode(SearchForm, mergeProps({
|
|
1689
|
+
"formElementMap": formElementMap
|
|
1690
|
+
}, omit(props.searchProps, "slots"), {
|
|
1691
|
+
"columns": searchColumns.value,
|
|
1692
|
+
"onFinish": executeSearchWithResetPage
|
|
1693
|
+
}), _objectSpread2({
|
|
1694
|
+
"default": function _default() {
|
|
1695
|
+
return [props.extraInSearch && extra];
|
|
1696
|
+
}
|
|
1697
|
+
}, (_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.slots)), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots.table ? slots.table() : createVNode(Table, mergeProps({
|
|
1698
|
+
"elementMap": elementMap
|
|
1699
|
+
}, omit(tableProps, "slots", "operate"), {
|
|
1700
|
+
"operate": mergeWith({
|
|
1701
|
+
items: tableOperateItems
|
|
1702
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.operate, function (objValue, srcValue) {
|
|
1703
|
+
if (isArray(objValue) && isArray(srcValue)) {
|
|
1704
|
+
return concat(objValue, convertOperateItems(srcValue));
|
|
1705
|
+
}
|
|
1706
|
+
}),
|
|
1707
|
+
"paginationState": {
|
|
1708
|
+
page: pageState.page,
|
|
1709
|
+
pageSize: pageState.pageSize
|
|
1710
|
+
},
|
|
1711
|
+
"columns": tableColumns.value,
|
|
1712
|
+
"loading": curdState.listLoading,
|
|
1713
|
+
"dataSource": (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
|
|
1714
|
+
}), tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), createVNode("div", {
|
|
1715
|
+
"class": "pro-curd-list-footer"
|
|
1716
|
+
}, [(_slots$footerStart = slots.footerStart) === null || _slots$footerStart === void 0 ? void 0 : _slots$footerStart.call(slots), (_slots$pagination = slots.pagination) === null || _slots$pagination === void 0 ? void 0 : _slots$pagination.call(slots, pageState, (_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total, handleSearch), (_slots$footerEnd = slots.footerEnd) === null || _slots$footerEnd === void 0 ? void 0 : _slots$footerEnd.call(slots)])]);
|
|
1717
|
+
};
|
|
1718
|
+
}
|
|
1719
|
+
});
|
|
1720
|
+
};
|
|
1721
|
+
|
|
1722
|
+
var ProFormKey = Symbol("pro-form");
|
|
1723
|
+
var useProForm = function useProForm() {
|
|
1724
|
+
return inject(ProFormKey);
|
|
1725
|
+
};
|
|
1726
|
+
|
|
1727
|
+
var provideProForm = function provideProForm(ctx) {
|
|
1728
|
+
provide(ProFormKey, ctx);
|
|
1729
|
+
};
|
|
1730
|
+
|
|
1731
|
+
var proFormProps = function proFormProps() {
|
|
1732
|
+
return {
|
|
1733
|
+
/**
|
|
1734
|
+
* 同 antd 或 element form中的model
|
|
1735
|
+
*/
|
|
1736
|
+
model: {
|
|
1737
|
+
type: Object
|
|
1738
|
+
},
|
|
1739
|
+
|
|
1740
|
+
/**
|
|
1741
|
+
* 子组件是否只读样式
|
|
1742
|
+
*/
|
|
1743
|
+
readonly: {
|
|
1744
|
+
type: Boolean,
|
|
1745
|
+
"default": undefined
|
|
1746
|
+
},
|
|
1747
|
+
|
|
1748
|
+
/**
|
|
1749
|
+
* FormComponent 根据此项来确定组件是否显示
|
|
1750
|
+
* rules 根据rules中方法生成showState对象
|
|
1751
|
+
*/
|
|
1752
|
+
showState: {
|
|
1753
|
+
type: Object
|
|
1754
|
+
},
|
|
1755
|
+
showStateRules: {
|
|
1756
|
+
type: Object
|
|
1757
|
+
},
|
|
1758
|
+
|
|
1759
|
+
/**
|
|
1760
|
+
* 是否只读
|
|
1761
|
+
*/
|
|
1762
|
+
readonlyState: {
|
|
1763
|
+
type: Object
|
|
1764
|
+
},
|
|
1765
|
+
readonlyStateRules: {
|
|
1766
|
+
type: Object
|
|
1767
|
+
},
|
|
1768
|
+
|
|
1769
|
+
/**
|
|
1770
|
+
* 是否disabled
|
|
1771
|
+
*/
|
|
1772
|
+
disableState: {
|
|
1773
|
+
type: Object
|
|
1774
|
+
},
|
|
1775
|
+
disableStateRules: {
|
|
1776
|
+
type: Object
|
|
1777
|
+
},
|
|
1778
|
+
|
|
1779
|
+
/**
|
|
1780
|
+
*
|
|
1781
|
+
*/
|
|
1782
|
+
columns: {
|
|
1783
|
+
type: Array
|
|
1784
|
+
},
|
|
1785
|
+
columnState: {
|
|
1786
|
+
type: Object
|
|
1787
|
+
},
|
|
1788
|
+
|
|
1789
|
+
/**
|
|
1790
|
+
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1791
|
+
*/
|
|
1792
|
+
elementMap: {
|
|
1793
|
+
type: Object
|
|
1794
|
+
},
|
|
1795
|
+
|
|
1796
|
+
/**
|
|
1797
|
+
* 录入控件集合
|
|
1798
|
+
*/
|
|
1799
|
+
formElementMap: {
|
|
1800
|
+
type: Object
|
|
1801
|
+
},
|
|
1802
|
+
|
|
1803
|
+
/**
|
|
1804
|
+
* 是否启用rules验证
|
|
1805
|
+
*/
|
|
1806
|
+
needRules: {
|
|
1807
|
+
type: Boolean,
|
|
1808
|
+
"default": true
|
|
1809
|
+
},
|
|
1810
|
+
|
|
1811
|
+
/**
|
|
1812
|
+
* provide传递
|
|
1813
|
+
*/
|
|
1814
|
+
provideExtra: {
|
|
1815
|
+
type: Object
|
|
1816
|
+
}
|
|
1817
|
+
};
|
|
1818
|
+
};
|
|
1819
|
+
|
|
1820
|
+
var createForm = function createForm(Form, Grid) {
|
|
1821
|
+
return defineComponent({
|
|
1822
|
+
inheritAttrs: false,
|
|
1823
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), proFormProps()), omit(Grid.props, "items")),
|
|
1824
|
+
setup: function setup(props, _ref) {
|
|
1825
|
+
var slots = _ref.slots,
|
|
1826
|
+
emit = _ref.emit,
|
|
1827
|
+
expose = _ref.expose,
|
|
1828
|
+
attrs = _ref.attrs;
|
|
1829
|
+
var formState = props.model || reactive({}); //组件状态相关
|
|
1830
|
+
|
|
1831
|
+
var showState = props.showState || reactive({});
|
|
1832
|
+
var readonlyState = props.readonlyState || reactive({});
|
|
1833
|
+
var disableState = props.disableState || reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
|
|
1834
|
+
|
|
1835
|
+
useEffect(function () {
|
|
1836
|
+
if (props.showStateRules) {
|
|
1837
|
+
forEach(props.showStateRules, function (fn, key) {
|
|
1838
|
+
showState[key] = fn(formState);
|
|
1839
|
+
});
|
|
1840
|
+
}
|
|
1841
|
+
|
|
1842
|
+
if (props.readonlyStateRules) {
|
|
1843
|
+
forEach(props.readonlyStateRules, function (fn, key) {
|
|
1844
|
+
readonlyState[key] = fn(formState);
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1847
|
+
|
|
1848
|
+
if (props.disableStateRules) {
|
|
1849
|
+
forEach(props.disableStateRules, function (fn, key) {
|
|
1850
|
+
disableState[key] = fn(formState);
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
}, formState); //readonly
|
|
1854
|
+
|
|
1855
|
+
var readonly = computed(function () {
|
|
1856
|
+
return props.readonly;
|
|
1857
|
+
}); //columns合并
|
|
1858
|
+
|
|
1859
|
+
var columns = computed(function () {
|
|
1860
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1861
|
+
return getColumnFormItemName(item);
|
|
1862
|
+
});
|
|
1863
|
+
});
|
|
1864
|
+
|
|
1865
|
+
var handleFinish = function handleFinish(values) {
|
|
1866
|
+
//删除不显示的值再触发事件
|
|
1867
|
+
var showValues = getValidValues(values, showState, props.showStateRules);
|
|
1868
|
+
emit("finish", showValues, values);
|
|
1869
|
+
};
|
|
1870
|
+
|
|
1871
|
+
var formRef = ref();
|
|
1872
|
+
expose({
|
|
1873
|
+
submit: function submit() {
|
|
1874
|
+
var _formRef$value;
|
|
1875
|
+
|
|
1876
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
1877
|
+
},
|
|
1878
|
+
resetFields: function resetFields() {
|
|
1879
|
+
var _formRef$value2;
|
|
1880
|
+
|
|
1881
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1882
|
+
params[_key] = arguments[_key];
|
|
1883
|
+
}
|
|
1884
|
+
|
|
1885
|
+
(_formRef$value2 = formRef.value) === null || _formRef$value2 === void 0 ? void 0 : _formRef$value2.resetFields.apply(_formRef$value2, params);
|
|
1886
|
+
}
|
|
1887
|
+
});
|
|
1888
|
+
provideProForm(_objectSpread2({
|
|
1889
|
+
formState: formState,
|
|
1890
|
+
showState: showState,
|
|
1891
|
+
readonlyState: readonlyState,
|
|
1892
|
+
disableState: disableState,
|
|
1893
|
+
//
|
|
1894
|
+
elementMap: props.elementMap,
|
|
1895
|
+
formElementMap: props.formElementMap,
|
|
1896
|
+
//
|
|
1897
|
+
readonly: readonly,
|
|
1898
|
+
//
|
|
1899
|
+
columns: columns,
|
|
1900
|
+
//
|
|
1901
|
+
formRef: formRef
|
|
1902
|
+
}, props.provideExtra));
|
|
1903
|
+
var invalidKeys = keys(proFormProps());
|
|
1904
|
+
var gridKeys = keys(omit(Grid.props, "items"));
|
|
1905
|
+
return function () {
|
|
1906
|
+
var _slots$start, _slots$default;
|
|
1907
|
+
|
|
1908
|
+
return createVNode(Form, mergeProps({
|
|
1909
|
+
"ref": formRef
|
|
1910
|
+
}, omit(attrs, "onFinish"), omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), _toConsumableArray(gridKeys), ["onFinish"])), {
|
|
1911
|
+
"model": formState,
|
|
1912
|
+
"onFinish": handleFinish
|
|
1913
|
+
}), _objectSpread2({
|
|
1914
|
+
"default": function _default() {
|
|
1915
|
+
return [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), props.formElementMap && size(columns.value) > 0 && createVNode(Fragment, null, [props.row ? createVNode(Grid, {
|
|
1916
|
+
"row": props.row,
|
|
1917
|
+
"col": props.col,
|
|
1918
|
+
"items": map(columns.value, function (item) {
|
|
1919
|
+
return {
|
|
1920
|
+
rowKey: getColumnFormItemName(item),
|
|
1921
|
+
vNode: getFormItemEl(props.formElementMap, item, props.needRules),
|
|
1922
|
+
col: get(item, ["extra", "col"])
|
|
1923
|
+
};
|
|
1924
|
+
})
|
|
1925
|
+
}, null) : map(columns.value, function (item) {
|
|
1926
|
+
return getFormItemEl(props.formElementMap, item, props.needRules);
|
|
1927
|
+
})]), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1928
|
+
}
|
|
1929
|
+
}, omit(slots, "default")));
|
|
1930
|
+
};
|
|
1931
|
+
}
|
|
1932
|
+
});
|
|
1933
|
+
};
|
|
1934
|
+
|
|
973
1935
|
var SearchMode;
|
|
974
1936
|
|
|
975
1937
|
(function (SearchMode) {
|
|
@@ -1017,6 +1979,11 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1017
1979
|
debounceKeys: {
|
|
1018
1980
|
type: Array
|
|
1019
1981
|
},
|
|
1982
|
+
//默认 valueType 为 text 的控件会debounce处理
|
|
1983
|
+
debounceTypes: {
|
|
1984
|
+
type: Array,
|
|
1985
|
+
"default": ["text"]
|
|
1986
|
+
},
|
|
1020
1987
|
debounceTime: {
|
|
1021
1988
|
type: Number,
|
|
1022
1989
|
"default": 800
|
|
@@ -1028,106 +1995,73 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1028
1995
|
* 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
|
|
1029
1996
|
* 针对传入的model(监听对象)做相应的finish(回调)处理
|
|
1030
1997
|
*/
|
|
1031
|
-
var
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
var
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
emit("finish");
|
|
1046
|
-
};
|
|
1047
|
-
|
|
1048
|
-
var debounceFinish = debounce(function () {
|
|
1049
|
-
handleFinish();
|
|
1050
|
-
}, props.debounceTime); //初始化
|
|
1051
|
-
|
|
1052
|
-
useEffect(function () {
|
|
1053
|
-
if (props.initEmit) {
|
|
1054
|
-
handleFinish();
|
|
1055
|
-
}
|
|
1056
|
-
}, []);
|
|
1057
|
-
|
|
1058
|
-
var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
|
|
1059
|
-
return some(debounceKeys, function (key) {
|
|
1060
|
-
return get(state, key) !== get(prevState, key);
|
|
1998
|
+
var createSearchForm = function createSearchForm(Form, Props) {
|
|
1999
|
+
return defineComponent({
|
|
2000
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), Props), proSearchFormProps()),
|
|
2001
|
+
setup: function setup(props, _ref) {
|
|
2002
|
+
var slots = _ref.slots;
|
|
2003
|
+
var formState = props.model || reactive({});
|
|
2004
|
+
var valueTypeSet = new Set(props.debounceTypes); //根据column valueType 算出默认需要debounce处理的属性集合
|
|
2005
|
+
|
|
2006
|
+
var defaultDebounceKeys = map(filter$1(props.columns, function (column) {
|
|
2007
|
+
var valueType = getColumnValueType(column); //默认input组件的触发事件需要debounce处理
|
|
2008
|
+
|
|
2009
|
+
return valueTypeSet.has(valueType);
|
|
2010
|
+
}), function (column) {
|
|
2011
|
+
return getColumnFormItemName(column);
|
|
1061
2012
|
});
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
useWatch(function (state, prevState) {
|
|
1066
|
-
if (props.searchMode !== SearchMode.AUTO) {
|
|
1067
|
-
return;
|
|
1068
|
-
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1069
|
-
|
|
2013
|
+
var formRef = ref();
|
|
1070
2014
|
|
|
1071
|
-
var
|
|
2015
|
+
var handleFinish = function handleFinish() {
|
|
2016
|
+
var _formRef$value;
|
|
1072
2017
|
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
return;
|
|
1076
|
-
}
|
|
2018
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
2019
|
+
};
|
|
1077
2020
|
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
});
|
|
1082
|
-
return function () {
|
|
1083
|
-
return null;
|
|
1084
|
-
};
|
|
1085
|
-
}
|
|
1086
|
-
});
|
|
2021
|
+
var debounceFinish = debounce(function () {
|
|
2022
|
+
handleFinish();
|
|
2023
|
+
}, props.debounceTime); //初始化
|
|
1087
2024
|
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
*/
|
|
1094
|
-
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
1095
|
-
if (showState) {
|
|
1096
|
-
var invalidKeys = filter$1(keys(showState), function (key) {
|
|
1097
|
-
return !showState[key];
|
|
1098
|
-
});
|
|
1099
|
-
return omit(values, invalidKeys);
|
|
1100
|
-
}
|
|
2025
|
+
useEffect(function () {
|
|
2026
|
+
if (props.initEmit) {
|
|
2027
|
+
handleFinish();
|
|
2028
|
+
}
|
|
2029
|
+
}, []);
|
|
1101
2030
|
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
2031
|
+
var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
|
|
2032
|
+
return some(debounceKeys, function (key) {
|
|
2033
|
+
return get(state, key) !== get(prevState, key);
|
|
2034
|
+
});
|
|
2035
|
+
}; //监听
|
|
1106
2036
|
|
|
1107
|
-
return omit(values, _invalidKeys);
|
|
1108
|
-
}
|
|
1109
2037
|
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
* @param path
|
|
1115
|
-
*/
|
|
2038
|
+
useWatch(function (state, prevState) {
|
|
2039
|
+
if (props.searchMode !== SearchMode.AUTO) {
|
|
2040
|
+
return;
|
|
2041
|
+
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1116
2042
|
|
|
1117
|
-
var convertPathToList = function convertPathToList(path) {
|
|
1118
|
-
if (!path) {
|
|
1119
|
-
return undefined;
|
|
1120
|
-
}
|
|
1121
2043
|
|
|
1122
|
-
|
|
1123
|
-
return path;
|
|
1124
|
-
}
|
|
2044
|
+
var debounceKeys = size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
|
|
1125
2045
|
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
2046
|
+
if (size(debounceKeys) > 0 && isDebounceDataChange(state, prevState, debounceKeys)) {
|
|
2047
|
+
debounceFinish();
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
1129
2050
|
|
|
1130
|
-
|
|
2051
|
+
handleFinish();
|
|
2052
|
+
}, function () {
|
|
2053
|
+
return clone(formState);
|
|
2054
|
+
});
|
|
2055
|
+
var invalidKeys = keys(omit(proSearchFormProps(), "columns"));
|
|
2056
|
+
return function () {
|
|
2057
|
+
return createVNode(Form, mergeProps({
|
|
2058
|
+
"ref": formRef
|
|
2059
|
+
}, omit(props, invalidKeys), {
|
|
2060
|
+
"model": formState
|
|
2061
|
+
}), slots);
|
|
2062
|
+
};
|
|
2063
|
+
}
|
|
2064
|
+
});
|
|
1131
2065
|
};
|
|
1132
2066
|
|
|
1133
2067
|
/**
|
|
@@ -1162,86 +2096,83 @@ var FormListProvider = defineComponent({
|
|
|
1162
2096
|
}
|
|
1163
2097
|
});
|
|
1164
2098
|
|
|
1165
|
-
var
|
|
1166
|
-
return {
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
}
|
|
1177
|
-
};
|
|
1178
|
-
};
|
|
1179
|
-
|
|
1180
|
-
var ProFormList = defineComponent({
|
|
1181
|
-
props: _objectSpread2({}, proFormListProps()),
|
|
1182
|
-
setup: function setup(props, _ref2) {
|
|
1183
|
-
var slots = _ref2.slots;
|
|
1184
|
-
|
|
1185
|
-
var _useProForm = useProForm(),
|
|
1186
|
-
formState = _useProForm.formState,
|
|
1187
|
-
readonly = _useProForm.readonly;
|
|
2099
|
+
var createFormList = function createFormList(FormItem) {
|
|
2100
|
+
return defineComponent({
|
|
2101
|
+
props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
|
|
2102
|
+
//每行默认id
|
|
2103
|
+
rowKey: {
|
|
2104
|
+
type: String,
|
|
2105
|
+
"default": "id"
|
|
2106
|
+
}
|
|
2107
|
+
}),
|
|
2108
|
+
setup: function setup(props, _ref2) {
|
|
2109
|
+
var slots = _ref2.slots;
|
|
1188
2110
|
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
2111
|
+
var _useProForm = useProForm(),
|
|
2112
|
+
formState = _useProForm.formState,
|
|
2113
|
+
readonly = _useProForm.readonly;
|
|
1192
2114
|
|
|
1193
|
-
|
|
1194
|
-
var
|
|
2115
|
+
var formListCtx = useProFormList();
|
|
2116
|
+
var nameList = convertPathToList(props.name);
|
|
2117
|
+
var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
|
|
1195
2118
|
|
|
1196
|
-
|
|
1197
|
-
targetList =
|
|
1198
|
-
}
|
|
2119
|
+
var handleAdd = function handleAdd() {
|
|
2120
|
+
var targetList = get(formState, path);
|
|
1199
2121
|
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
2122
|
+
if (!isArray(targetList)) {
|
|
2123
|
+
targetList = [];
|
|
2124
|
+
}
|
|
1203
2125
|
|
|
1204
|
-
|
|
1205
|
-
|
|
2126
|
+
targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
|
|
2127
|
+
set(formState, path, targetList);
|
|
2128
|
+
};
|
|
1206
2129
|
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
}
|
|
2130
|
+
var handleRemove = function handleRemove(index) {
|
|
2131
|
+
var targetList = get(formState, path);
|
|
1210
2132
|
|
|
1211
|
-
|
|
1212
|
-
|
|
2133
|
+
if (size(targetList) <= 0) {
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
1213
2136
|
|
|
1214
|
-
|
|
1215
|
-
|
|
2137
|
+
targetList.splice(index, 1);
|
|
2138
|
+
};
|
|
1216
2139
|
|
|
1217
|
-
return
|
|
1218
|
-
var _slots$
|
|
2140
|
+
return function () {
|
|
2141
|
+
var _slots$add;
|
|
1219
2142
|
|
|
1220
|
-
return createVNode(
|
|
1221
|
-
"key": index,
|
|
1222
|
-
"pathList": [].concat(_toConsumableArray(path), [index])
|
|
1223
|
-
}, {
|
|
2143
|
+
return createVNode(FormItem, omit(props, "rowKey"), {
|
|
1224
2144
|
"default": function _default() {
|
|
1225
|
-
return [
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
2145
|
+
return [map(get(formState, path), function (item, index) {
|
|
2146
|
+
var _slots$default2, _slots$itemAdd, _slots$itemMinus;
|
|
2147
|
+
|
|
2148
|
+
return createVNode(FormListProvider, {
|
|
2149
|
+
"key": item[props.rowKey] || index,
|
|
2150
|
+
"pathList": [].concat(_toConsumableArray(path), [index])
|
|
2151
|
+
}, {
|
|
2152
|
+
"default": function _default() {
|
|
2153
|
+
return [createVNode("div", {
|
|
2154
|
+
"class": "pro-form-list-item"
|
|
2155
|
+
}, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode(Fragment, null, [createVNode("div", {
|
|
2156
|
+
"class": "pro-form-list-item-add",
|
|
2157
|
+
"onClick": handleAdd
|
|
2158
|
+
}, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), createVNode("div", {
|
|
2159
|
+
"class": "pro-form-list-item-minus",
|
|
2160
|
+
"onClick": function onClick() {
|
|
2161
|
+
return handleRemove(index);
|
|
2162
|
+
}
|
|
2163
|
+
}, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
|
|
2164
|
+
}
|
|
2165
|
+
});
|
|
2166
|
+
}), !readonly.value && createVNode("div", {
|
|
2167
|
+
"class": "pro-form-list-add",
|
|
1229
2168
|
"onClick": handleAdd
|
|
1230
|
-
}, [(_slots$
|
|
1231
|
-
"class": "pro-form-list-item-minus",
|
|
1232
|
-
"onClick": function onClick() {
|
|
1233
|
-
return handleRemove(index);
|
|
1234
|
-
}
|
|
1235
|
-
}, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
|
|
2169
|
+
}, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
|
|
1236
2170
|
}
|
|
1237
2171
|
});
|
|
1238
|
-
}
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
};
|
|
1243
|
-
}
|
|
1244
|
-
});
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
};
|
|
1245
2176
|
|
|
1246
2177
|
var proFormItemProps = function proFormItemProps() {
|
|
1247
2178
|
return {
|
|
@@ -1346,8 +2277,8 @@ var proTableProps = function proTableProps() {
|
|
|
1346
2277
|
type: String
|
|
1347
2278
|
},
|
|
1348
2279
|
|
|
1349
|
-
/**
|
|
1350
|
-
* 公共column,会merge到columns item中
|
|
2280
|
+
/**
|
|
2281
|
+
* 公共column,会merge到columns item中
|
|
1351
2282
|
*/
|
|
1352
2283
|
column: {
|
|
1353
2284
|
type: Object
|
|
@@ -1356,23 +2287,33 @@ var proTableProps = function proTableProps() {
|
|
|
1356
2287
|
columns: {
|
|
1357
2288
|
type: Array
|
|
1358
2289
|
},
|
|
2290
|
+
columnState: {
|
|
2291
|
+
type: Object
|
|
2292
|
+
},
|
|
1359
2293
|
|
|
1360
|
-
/**
|
|
1361
|
-
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
2294
|
+
/**
|
|
2295
|
+
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1362
2296
|
*/
|
|
1363
2297
|
elementMap: {
|
|
1364
2298
|
type: Object
|
|
1365
2299
|
},
|
|
1366
2300
|
|
|
1367
|
-
/**
|
|
1368
|
-
*
|
|
2301
|
+
/**
|
|
2302
|
+
* 序号
|
|
1369
2303
|
*/
|
|
1370
|
-
|
|
2304
|
+
serialNumber: {
|
|
1371
2305
|
type: Boolean
|
|
1372
2306
|
},
|
|
1373
2307
|
|
|
1374
|
-
/**
|
|
1375
|
-
*
|
|
2308
|
+
/**
|
|
2309
|
+
* 分页
|
|
2310
|
+
*/
|
|
2311
|
+
paginationState: {
|
|
2312
|
+
type: Object
|
|
2313
|
+
},
|
|
2314
|
+
|
|
2315
|
+
/**
|
|
2316
|
+
* provide传递
|
|
1376
2317
|
*/
|
|
1377
2318
|
provideExtra: {
|
|
1378
2319
|
type: Object
|
|
@@ -1380,37 +2321,35 @@ var proTableProps = function proTableProps() {
|
|
|
1380
2321
|
};
|
|
1381
2322
|
};
|
|
1382
2323
|
|
|
1383
|
-
var
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
var
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
var
|
|
1397
|
-
showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
|
|
1398
|
-
content: props.columnEmptyText
|
|
1399
|
-
})
|
|
1400
|
-
}), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
|
|
2324
|
+
var createTable = function createTable(Table, Props) {
|
|
2325
|
+
return defineComponent({
|
|
2326
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Table.props), Props), proTableProps()),
|
|
2327
|
+
setup: function setup(props, _ref) {
|
|
2328
|
+
var slots = _ref.slots;
|
|
2329
|
+
|
|
2330
|
+
var createNumberColumn = function createNumberColumn() {
|
|
2331
|
+
return _objectSpread2(_objectSpread2({
|
|
2332
|
+
title: "序号",
|
|
2333
|
+
dataIndex: "serialNumber",
|
|
2334
|
+
width: 80
|
|
2335
|
+
}, props.column), {}, {
|
|
2336
|
+
customRender: function customRender(_ref2) {
|
|
2337
|
+
var _props$paginationStat, _props$paginationStat2;
|
|
1401
2338
|
|
|
1402
|
-
|
|
1403
|
-
};
|
|
1404
|
-
}
|
|
2339
|
+
var index = _ref2.index;
|
|
1405
2340
|
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
2341
|
+
if ((_props$paginationStat = props.paginationState) !== null && _props$paginationStat !== void 0 && _props$paginationStat.page && (_props$paginationStat2 = props.paginationState) !== null && _props$paginationStat2 !== void 0 && _props$paginationStat2.pageSize) {
|
|
2342
|
+
return props.paginationState.pageSize * (props.paginationState.page - 1) + index + 1;
|
|
2343
|
+
}
|
|
2344
|
+
|
|
2345
|
+
return index + 1;
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
};
|
|
2349
|
+
|
|
2350
|
+
var createOperateColumn = function createOperateColumn() {
|
|
2351
|
+
var operate = props.operate; //将itemState补充的信息拼到item中
|
|
1409
2352
|
|
|
1410
|
-
if (operate && operate.items && some(operate.items, function (item) {
|
|
1411
|
-
return item.show;
|
|
1412
|
-
})) {
|
|
1413
|
-
//将itemState补充的信息拼到item中
|
|
1414
2353
|
var items = map(operate.items, function (i) {
|
|
1415
2354
|
return _objectSpread2(_objectSpread2({}, i), get(operate.itemState, i.value));
|
|
1416
2355
|
}); //排序
|
|
@@ -1418,14 +2357,14 @@ var ProTable = defineComponent({
|
|
|
1418
2357
|
var sortedItems = sortBy(items, function (item) {
|
|
1419
2358
|
return item.sort;
|
|
1420
2359
|
});
|
|
1421
|
-
|
|
2360
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, props.column), {}, {
|
|
1422
2361
|
title: "操作",
|
|
1423
2362
|
dataIndex: "operate",
|
|
1424
2363
|
fixed: "right"
|
|
1425
|
-
},
|
|
2364
|
+
}, operate.column), {}, {
|
|
1426
2365
|
customRender: function customRender(_ref3) {
|
|
1427
2366
|
var record = _ref3.record;
|
|
1428
|
-
var
|
|
2367
|
+
var showItems = filter$1(sortedItems, function (item) {
|
|
1429
2368
|
if (item.show && isFunction(item.show)) {
|
|
1430
2369
|
return item.show(record);
|
|
1431
2370
|
}
|
|
@@ -1438,7 +2377,7 @@ var ProTable = defineComponent({
|
|
|
1438
2377
|
});
|
|
1439
2378
|
return createVNode("div", {
|
|
1440
2379
|
"class": "pro-table-operate"
|
|
1441
|
-
}, [map(
|
|
2380
|
+
}, [map(showItems, function (item) {
|
|
1442
2381
|
//自定义
|
|
1443
2382
|
if (isFunction(item.element)) {
|
|
1444
2383
|
return item.element(record, item);
|
|
@@ -1455,20 +2394,62 @@ var ProTable = defineComponent({
|
|
|
1455
2394
|
}, [item.label]);
|
|
1456
2395
|
})]);
|
|
1457
2396
|
}
|
|
1458
|
-
}
|
|
1459
|
-
}
|
|
2397
|
+
});
|
|
2398
|
+
};
|
|
1460
2399
|
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
2400
|
+
var columns = computed(function () {
|
|
2401
|
+
var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
|
|
2402
|
+
return item.dataIndex;
|
|
2403
|
+
}); //根据valueType选择对应的展示组件
|
|
2404
|
+
|
|
2405
|
+
var columns = map(mergeColumns, function (item) {
|
|
2406
|
+
//merge公共item
|
|
2407
|
+
var nextItem = _objectSpread2(_objectSpread2({}, props.column), item);
|
|
2408
|
+
|
|
2409
|
+
if (!item.customRender) {
|
|
2410
|
+
nextItem.customRender = function (_ref4) {
|
|
2411
|
+
var text = _ref4.text;
|
|
2412
|
+
var vn = getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
|
|
2413
|
+
showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
|
|
2414
|
+
content: props.columnEmptyText
|
|
2415
|
+
})
|
|
2416
|
+
}), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
|
|
2417
|
+
|
|
2418
|
+
return vn || text || props.columnEmptyText;
|
|
2419
|
+
};
|
|
2420
|
+
}
|
|
1468
2421
|
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
2422
|
+
return nextItem;
|
|
2423
|
+
}); //处理序号
|
|
2424
|
+
|
|
2425
|
+
if (props.serialNumber) {
|
|
2426
|
+
columns.unshift(createNumberColumn());
|
|
2427
|
+
} //处理operate
|
|
2428
|
+
|
|
2429
|
+
|
|
2430
|
+
if (props.operate && props.operate.items && some(props.operate.items, function (item) {
|
|
2431
|
+
return item.show;
|
|
2432
|
+
})) {
|
|
2433
|
+
columns.push(createOperateColumn());
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
return columns;
|
|
2437
|
+
});
|
|
2438
|
+
var tableRef = ref();
|
|
2439
|
+
provideProTable(_objectSpread2({
|
|
2440
|
+
columns: columns,
|
|
2441
|
+
tableRef: tableRef
|
|
2442
|
+
}, props.provideExtra));
|
|
2443
|
+
var invalidKeys = keys(proTableProps());
|
|
2444
|
+
return function () {
|
|
2445
|
+
return createVNode(Table, mergeProps({
|
|
2446
|
+
"ref": tableRef
|
|
2447
|
+
}, omit(props, invalidKeys), {
|
|
2448
|
+
"columns": columns.value
|
|
2449
|
+
}), slots);
|
|
2450
|
+
};
|
|
2451
|
+
}
|
|
2452
|
+
});
|
|
2453
|
+
};
|
|
1473
2454
|
|
|
1474
|
-
export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd,
|
|
2455
|
+
export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd, ProModalCurd, ProModule, ProPageCurd, RequestAction, SearchMode, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, findTargetInTree, findTargetListInTree, generateId, getColumnFormItemName, getColumnValueType, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProModule, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
|