@vue-start/pro 0.3.1 → 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 +6 -0
- package/dist/index.d.ts +148 -363
- package/dist/index.es.js +795 -269
- package/dist/index.js +803 -270
- package/package.json +2 -2
package/dist/index.es.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { defineComponent, computed, reactive, inject, h, provide, ref,
|
|
2
|
-
import { map, isString, forEach, filter as filter$1, keys, omit, isArray, split,
|
|
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';
|
|
@@ -79,6 +79,50 @@ function _nonIterableSpread() {
|
|
|
79
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.");
|
|
80
80
|
}
|
|
81
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
|
+
|
|
82
126
|
var createUseRequestActor = function createUseRequestActor(filterFun) {
|
|
83
127
|
return function (actors, callback) {
|
|
84
128
|
var _useRequestProvide = useRequestProvide(),
|
|
@@ -151,12 +195,85 @@ var useComposeRequestActor = function useComposeRequestActor(actors, options, ca
|
|
|
151
195
|
}, []);
|
|
152
196
|
};
|
|
153
197
|
|
|
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
|
+
|
|
154
270
|
/**
|
|
155
271
|
* 剔除showState或showStateRules规则为!true的值
|
|
156
272
|
* @param values
|
|
157
273
|
* @param showState
|
|
158
274
|
* @param showStateRules
|
|
159
275
|
*/
|
|
276
|
+
|
|
160
277
|
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
161
278
|
if (showState) {
|
|
162
279
|
var invalidKeys = filter$1(keys(showState), function (key) {
|
|
@@ -195,16 +312,10 @@ var convertPathToList = function convertPathToList(path) {
|
|
|
195
312
|
|
|
196
313
|
return [path];
|
|
197
314
|
};
|
|
198
|
-
/**
|
|
199
|
-
* 唯一id
|
|
200
|
-
*/
|
|
201
|
-
|
|
202
|
-
var generateId = function generateId() {
|
|
203
|
-
return Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36);
|
|
204
|
-
};
|
|
205
315
|
/**
|
|
206
316
|
* 将listState 中的数据通过id merge到 list item中
|
|
207
317
|
* ps:数组会替换
|
|
318
|
+
* 注意:mergeWith 会改变原始对象
|
|
208
319
|
* @param list
|
|
209
320
|
* @param listState
|
|
210
321
|
* @param id
|
|
@@ -234,6 +345,31 @@ var mergeStateToList = function mergeStateToList(list, listState, id) {
|
|
|
234
345
|
});
|
|
235
346
|
};
|
|
236
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
|
+
|
|
237
373
|
/**
|
|
238
374
|
* 获取Column的valueType,默认"text"
|
|
239
375
|
* @param column
|
|
@@ -621,16 +757,16 @@ var defaultPage = {
|
|
|
621
757
|
|
|
622
758
|
var proCurdProps = function proCurdProps() {
|
|
623
759
|
return {
|
|
624
|
-
/**
|
|
625
|
-
* 列表 或 详情 的唯一标识
|
|
760
|
+
/**
|
|
761
|
+
* 列表 或 详情 的唯一标识
|
|
626
762
|
*/
|
|
627
763
|
rowKey: {
|
|
628
764
|
type: String,
|
|
629
765
|
"default": "id"
|
|
630
766
|
},
|
|
631
767
|
|
|
632
|
-
/**
|
|
633
|
-
* operates
|
|
768
|
+
/**
|
|
769
|
+
* operates
|
|
634
770
|
*/
|
|
635
771
|
operates: {
|
|
636
772
|
type: Array
|
|
@@ -663,10 +799,10 @@ var Curd = defineComponent({
|
|
|
663
799
|
state = _ref2.state,
|
|
664
800
|
sendEvent = _ref2.sendEvent,
|
|
665
801
|
sendRequest = _ref2.sendRequest;
|
|
666
|
-
/**
|
|
667
|
-
* 排序
|
|
668
|
-
* @param list
|
|
669
|
-
* @param propName
|
|
802
|
+
/**
|
|
803
|
+
* 排序
|
|
804
|
+
* @param list
|
|
805
|
+
* @param propName
|
|
670
806
|
*/
|
|
671
807
|
|
|
672
808
|
|
|
@@ -675,8 +811,8 @@ var Curd = defineComponent({
|
|
|
675
811
|
return get(item, propName);
|
|
676
812
|
});
|
|
677
813
|
};
|
|
678
|
-
/**
|
|
679
|
-
* 非 hideInForm columns
|
|
814
|
+
/**
|
|
815
|
+
* 非 hideInForm columns
|
|
680
816
|
*/
|
|
681
817
|
|
|
682
818
|
|
|
@@ -685,8 +821,8 @@ var Curd = defineComponent({
|
|
|
685
821
|
return !item.hideInForm;
|
|
686
822
|
}), "formSort");
|
|
687
823
|
});
|
|
688
|
-
/**
|
|
689
|
-
* 非 hideInDetail columns
|
|
824
|
+
/**
|
|
825
|
+
* 非 hideInDetail columns
|
|
690
826
|
*/
|
|
691
827
|
|
|
692
828
|
var descColumns = computed(function () {
|
|
@@ -694,8 +830,8 @@ var Curd = defineComponent({
|
|
|
694
830
|
return !item.hideInDetail;
|
|
695
831
|
}), "descSort");
|
|
696
832
|
});
|
|
697
|
-
/**
|
|
698
|
-
* 非 hideInTable columns
|
|
833
|
+
/**
|
|
834
|
+
* 非 hideInTable columns
|
|
699
835
|
*/
|
|
700
836
|
|
|
701
837
|
var tableColumns = computed(function () {
|
|
@@ -703,8 +839,8 @@ var Curd = defineComponent({
|
|
|
703
839
|
return !item.hideInTable;
|
|
704
840
|
}), "tableSort");
|
|
705
841
|
});
|
|
706
|
-
/**
|
|
707
|
-
* search columns
|
|
842
|
+
/**
|
|
843
|
+
* search columns
|
|
708
844
|
*/
|
|
709
845
|
|
|
710
846
|
var searchColumns = computed(function () {
|
|
@@ -1270,6 +1406,319 @@ var ProPageCurd = defineComponent({
|
|
|
1270
1406
|
}
|
|
1271
1407
|
});
|
|
1272
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
|
+
|
|
1273
1722
|
var ProFormKey = Symbol("pro-form");
|
|
1274
1723
|
var useProForm = function useProForm() {
|
|
1275
1724
|
return inject(ProFormKey);
|
|
@@ -1368,65 +1817,120 @@ var proFormProps = function proFormProps() {
|
|
|
1368
1817
|
};
|
|
1369
1818
|
};
|
|
1370
1819
|
|
|
1371
|
-
var
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
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
|
+
}
|
|
1376
1841
|
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1842
|
+
if (props.readonlyStateRules) {
|
|
1843
|
+
forEach(props.readonlyStateRules, function (fn, key) {
|
|
1844
|
+
readonlyState[key] = fn(formState);
|
|
1845
|
+
});
|
|
1846
|
+
}
|
|
1380
1847
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
}
|
|
1386
|
-
}
|
|
1848
|
+
if (props.disableStateRules) {
|
|
1849
|
+
forEach(props.disableStateRules, function (fn, key) {
|
|
1850
|
+
disableState[key] = fn(formState);
|
|
1851
|
+
});
|
|
1852
|
+
}
|
|
1853
|
+
}, formState); //readonly
|
|
1387
1854
|
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
});
|
|
1392
|
-
}
|
|
1855
|
+
var readonly = computed(function () {
|
|
1856
|
+
return props.readonly;
|
|
1857
|
+
}); //columns合并
|
|
1393
1858
|
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1859
|
+
var columns = computed(function () {
|
|
1860
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1861
|
+
return getColumnFormItemName(item);
|
|
1397
1862
|
});
|
|
1398
|
-
}
|
|
1399
|
-
}, formState); //转换为ref对象
|
|
1400
|
-
|
|
1401
|
-
var readonly = computed(function () {
|
|
1402
|
-
return props.readonly;
|
|
1403
|
-
});
|
|
1404
|
-
var columns = computed(function () {
|
|
1405
|
-
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1406
|
-
return getColumnFormItemName(item);
|
|
1407
1863
|
});
|
|
1408
|
-
});
|
|
1409
|
-
provideProForm(_objectSpread2({
|
|
1410
|
-
formState: formState,
|
|
1411
|
-
showState: showState,
|
|
1412
|
-
readonlyState: readonlyState,
|
|
1413
|
-
disableState: disableState,
|
|
1414
|
-
//
|
|
1415
|
-
elementMap: props.elementMap,
|
|
1416
|
-
formElementMap: props.formElementMap,
|
|
1417
|
-
//
|
|
1418
|
-
readonly: readonly,
|
|
1419
|
-
//
|
|
1420
|
-
columns: columns
|
|
1421
|
-
}, props.provideExtra));
|
|
1422
|
-
return function () {
|
|
1423
|
-
var _slots$default;
|
|
1424
1864
|
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
}
|
|
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
|
+
};
|
|
1430
1934
|
|
|
1431
1935
|
var SearchMode;
|
|
1432
1936
|
|
|
@@ -1475,6 +1979,11 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1475
1979
|
debounceKeys: {
|
|
1476
1980
|
type: Array
|
|
1477
1981
|
},
|
|
1982
|
+
//默认 valueType 为 text 的控件会debounce处理
|
|
1983
|
+
debounceTypes: {
|
|
1984
|
+
type: Array,
|
|
1985
|
+
"default": ["text"]
|
|
1986
|
+
},
|
|
1478
1987
|
debounceTime: {
|
|
1479
1988
|
type: Number,
|
|
1480
1989
|
"default": 800
|
|
@@ -1486,62 +1995,74 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1486
1995
|
* 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
|
|
1487
1996
|
* 针对传入的model(监听对象)做相应的finish(回调)处理
|
|
1488
1997
|
*/
|
|
1489
|
-
var
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
var
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
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);
|
|
2012
|
+
});
|
|
2013
|
+
var formRef = ref();
|
|
1501
2014
|
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
};
|
|
2015
|
+
var handleFinish = function handleFinish() {
|
|
2016
|
+
var _formRef$value;
|
|
1505
2017
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
}, props.debounceTime); //初始化
|
|
2018
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
2019
|
+
};
|
|
1509
2020
|
|
|
1510
|
-
|
|
1511
|
-
if (props.initEmit) {
|
|
2021
|
+
var debounceFinish = debounce(function () {
|
|
1512
2022
|
handleFinish();
|
|
1513
|
-
}
|
|
1514
|
-
}, []);
|
|
2023
|
+
}, props.debounceTime); //初始化
|
|
1515
2024
|
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
2025
|
+
useEffect(function () {
|
|
2026
|
+
if (props.initEmit) {
|
|
2027
|
+
handleFinish();
|
|
2028
|
+
}
|
|
2029
|
+
}, []);
|
|
1521
2030
|
|
|
2031
|
+
var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
|
|
2032
|
+
return some(debounceKeys, function (key) {
|
|
2033
|
+
return get(state, key) !== get(prevState, key);
|
|
2034
|
+
});
|
|
2035
|
+
}; //监听
|
|
1522
2036
|
|
|
1523
|
-
useWatch(function (state, prevState) {
|
|
1524
|
-
if (props.searchMode !== SearchMode.AUTO) {
|
|
1525
|
-
return;
|
|
1526
|
-
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1527
2037
|
|
|
2038
|
+
useWatch(function (state, prevState) {
|
|
2039
|
+
if (props.searchMode !== SearchMode.AUTO) {
|
|
2040
|
+
return;
|
|
2041
|
+
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1528
2042
|
|
|
1529
|
-
var debounceKeys = size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
|
|
1530
2043
|
|
|
1531
|
-
|
|
1532
|
-
debounceFinish();
|
|
1533
|
-
return;
|
|
1534
|
-
}
|
|
2044
|
+
var debounceKeys = size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
|
|
1535
2045
|
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
});
|
|
2046
|
+
if (size(debounceKeys) > 0 && isDebounceDataChange(state, prevState, debounceKeys)) {
|
|
2047
|
+
debounceFinish();
|
|
2048
|
+
return;
|
|
2049
|
+
}
|
|
2050
|
+
|
|
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
|
+
});
|
|
2065
|
+
};
|
|
1545
2066
|
|
|
1546
2067
|
/**
|
|
1547
2068
|
* ProFormList ctx
|
|
@@ -1575,86 +2096,83 @@ var FormListProvider = defineComponent({
|
|
|
1575
2096
|
}
|
|
1576
2097
|
});
|
|
1577
2098
|
|
|
1578
|
-
var
|
|
1579
|
-
return {
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
}
|
|
1590
|
-
};
|
|
1591
|
-
};
|
|
1592
|
-
|
|
1593
|
-
var ProFormList = defineComponent({
|
|
1594
|
-
props: _objectSpread2({}, proFormListProps()),
|
|
1595
|
-
setup: function setup(props, _ref2) {
|
|
1596
|
-
var slots = _ref2.slots;
|
|
1597
|
-
|
|
1598
|
-
var _useProForm = useProForm(),
|
|
1599
|
-
formState = _useProForm.formState,
|
|
1600
|
-
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;
|
|
1601
2110
|
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
2111
|
+
var _useProForm = useProForm(),
|
|
2112
|
+
formState = _useProForm.formState,
|
|
2113
|
+
readonly = _useProForm.readonly;
|
|
1605
2114
|
|
|
1606
|
-
|
|
1607
|
-
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;
|
|
1608
2118
|
|
|
1609
|
-
|
|
1610
|
-
targetList =
|
|
1611
|
-
}
|
|
2119
|
+
var handleAdd = function handleAdd() {
|
|
2120
|
+
var targetList = get(formState, path);
|
|
1612
2121
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
2122
|
+
if (!isArray(targetList)) {
|
|
2123
|
+
targetList = [];
|
|
2124
|
+
}
|
|
1616
2125
|
|
|
1617
|
-
|
|
1618
|
-
|
|
2126
|
+
targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
|
|
2127
|
+
set(formState, path, targetList);
|
|
2128
|
+
};
|
|
1619
2129
|
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
}
|
|
2130
|
+
var handleRemove = function handleRemove(index) {
|
|
2131
|
+
var targetList = get(formState, path);
|
|
1623
2132
|
|
|
1624
|
-
|
|
1625
|
-
|
|
2133
|
+
if (size(targetList) <= 0) {
|
|
2134
|
+
return;
|
|
2135
|
+
}
|
|
1626
2136
|
|
|
1627
|
-
|
|
1628
|
-
|
|
2137
|
+
targetList.splice(index, 1);
|
|
2138
|
+
};
|
|
1629
2139
|
|
|
1630
|
-
return
|
|
1631
|
-
var _slots$
|
|
2140
|
+
return function () {
|
|
2141
|
+
var _slots$add;
|
|
1632
2142
|
|
|
1633
|
-
return createVNode(
|
|
1634
|
-
"key": index,
|
|
1635
|
-
"pathList": [].concat(_toConsumableArray(path), [index])
|
|
1636
|
-
}, {
|
|
2143
|
+
return createVNode(FormItem, omit(props, "rowKey"), {
|
|
1637
2144
|
"default": function _default() {
|
|
1638
|
-
return [
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
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",
|
|
1642
2168
|
"onClick": handleAdd
|
|
1643
|
-
}, [(_slots$
|
|
1644
|
-
"class": "pro-form-list-item-minus",
|
|
1645
|
-
"onClick": function onClick() {
|
|
1646
|
-
return handleRemove(index);
|
|
1647
|
-
}
|
|
1648
|
-
}, [(_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)])];
|
|
1649
2170
|
}
|
|
1650
2171
|
});
|
|
1651
|
-
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
};
|
|
1656
|
-
}
|
|
1657
|
-
});
|
|
2172
|
+
};
|
|
2173
|
+
}
|
|
2174
|
+
});
|
|
2175
|
+
};
|
|
1658
2176
|
|
|
1659
2177
|
var proFormItemProps = function proFormItemProps() {
|
|
1660
2178
|
return {
|
|
@@ -1759,8 +2277,8 @@ var proTableProps = function proTableProps() {
|
|
|
1759
2277
|
type: String
|
|
1760
2278
|
},
|
|
1761
2279
|
|
|
1762
|
-
/**
|
|
1763
|
-
* 公共column,会merge到columns item中
|
|
2280
|
+
/**
|
|
2281
|
+
* 公共column,会merge到columns item中
|
|
1764
2282
|
*/
|
|
1765
2283
|
column: {
|
|
1766
2284
|
type: Object
|
|
@@ -1773,36 +2291,29 @@ var proTableProps = function proTableProps() {
|
|
|
1773
2291
|
type: Object
|
|
1774
2292
|
},
|
|
1775
2293
|
|
|
1776
|
-
/**
|
|
1777
|
-
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
2294
|
+
/**
|
|
2295
|
+
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1778
2296
|
*/
|
|
1779
2297
|
elementMap: {
|
|
1780
2298
|
type: Object
|
|
1781
2299
|
},
|
|
1782
2300
|
|
|
1783
|
-
/**
|
|
1784
|
-
*
|
|
1785
|
-
*/
|
|
1786
|
-
loading: {
|
|
1787
|
-
type: Boolean
|
|
1788
|
-
},
|
|
1789
|
-
|
|
1790
|
-
/**
|
|
1791
|
-
* 序号
|
|
2301
|
+
/**
|
|
2302
|
+
* 序号
|
|
1792
2303
|
*/
|
|
1793
2304
|
serialNumber: {
|
|
1794
2305
|
type: Boolean
|
|
1795
2306
|
},
|
|
1796
2307
|
|
|
1797
|
-
/**
|
|
1798
|
-
* 分页
|
|
2308
|
+
/**
|
|
2309
|
+
* 分页
|
|
1799
2310
|
*/
|
|
1800
|
-
|
|
2311
|
+
paginationState: {
|
|
1801
2312
|
type: Object
|
|
1802
2313
|
},
|
|
1803
2314
|
|
|
1804
|
-
/**
|
|
1805
|
-
* provide传递
|
|
2315
|
+
/**
|
|
2316
|
+
* provide传递
|
|
1806
2317
|
*/
|
|
1807
2318
|
provideExtra: {
|
|
1808
2319
|
type: Object
|
|
@@ -1810,62 +2321,35 @@ var proTableProps = function proTableProps() {
|
|
|
1810
2321
|
};
|
|
1811
2322
|
};
|
|
1812
2323
|
|
|
1813
|
-
var
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1819
|
-
return item.dataIndex;
|
|
1820
|
-
}); //根据valueType选择对应的展示组件
|
|
1821
|
-
|
|
1822
|
-
var columns = map(mergeColumns, function (item) {
|
|
1823
|
-
//merge公共item
|
|
1824
|
-
var nextItem = _objectSpread2(_objectSpread2({}, props.column), item);
|
|
1825
|
-
|
|
1826
|
-
if (!item.customRender) {
|
|
1827
|
-
nextItem.customRender = function (_ref2) {
|
|
1828
|
-
var text = _ref2.text;
|
|
1829
|
-
var vn = getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1830
|
-
showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
|
|
1831
|
-
content: props.columnEmptyText
|
|
1832
|
-
})
|
|
1833
|
-
}), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
|
|
1834
|
-
|
|
1835
|
-
return vn || text || props.columnEmptyText;
|
|
1836
|
-
};
|
|
1837
|
-
}
|
|
1838
|
-
|
|
1839
|
-
return nextItem;
|
|
1840
|
-
}); //处理序号
|
|
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;
|
|
1841
2329
|
|
|
1842
|
-
|
|
1843
|
-
|
|
2330
|
+
var createNumberColumn = function createNumberColumn() {
|
|
2331
|
+
return _objectSpread2(_objectSpread2({
|
|
1844
2332
|
title: "序号",
|
|
1845
2333
|
dataIndex: "serialNumber",
|
|
1846
2334
|
width: 80
|
|
1847
2335
|
}, props.column), {}, {
|
|
1848
|
-
|
|
1849
|
-
|
|
1850
|
-
var _props$pagination, _props$pagination2;
|
|
2336
|
+
customRender: function customRender(_ref2) {
|
|
2337
|
+
var _props$paginationStat, _props$paginationStat2;
|
|
1851
2338
|
|
|
1852
|
-
var index =
|
|
2339
|
+
var index = _ref2.index;
|
|
1853
2340
|
|
|
1854
|
-
if ((_props$
|
|
1855
|
-
return props.
|
|
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;
|
|
1856
2343
|
}
|
|
1857
2344
|
|
|
1858
2345
|
return index + 1;
|
|
1859
2346
|
}
|
|
1860
|
-
})
|
|
1861
|
-
}
|
|
2347
|
+
});
|
|
2348
|
+
};
|
|
1862
2349
|
|
|
1863
|
-
var
|
|
2350
|
+
var createOperateColumn = function createOperateColumn() {
|
|
2351
|
+
var operate = props.operate; //将itemState补充的信息拼到item中
|
|
1864
2352
|
|
|
1865
|
-
if (operate && operate.items && some(operate.items, function (item) {
|
|
1866
|
-
return item.show;
|
|
1867
|
-
})) {
|
|
1868
|
-
//将itemState补充的信息拼到item中
|
|
1869
2353
|
var items = map(operate.items, function (i) {
|
|
1870
2354
|
return _objectSpread2(_objectSpread2({}, i), get(operate.itemState, i.value));
|
|
1871
2355
|
}); //排序
|
|
@@ -1873,14 +2357,14 @@ var ProTable = defineComponent({
|
|
|
1873
2357
|
var sortedItems = sortBy(items, function (item) {
|
|
1874
2358
|
return item.sort;
|
|
1875
2359
|
});
|
|
1876
|
-
|
|
2360
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, props.column), {}, {
|
|
1877
2361
|
title: "操作",
|
|
1878
2362
|
dataIndex: "operate",
|
|
1879
2363
|
fixed: "right"
|
|
1880
|
-
},
|
|
1881
|
-
customRender: function customRender(
|
|
1882
|
-
var record =
|
|
1883
|
-
var
|
|
2364
|
+
}, operate.column), {}, {
|
|
2365
|
+
customRender: function customRender(_ref3) {
|
|
2366
|
+
var record = _ref3.record;
|
|
2367
|
+
var showItems = filter$1(sortedItems, function (item) {
|
|
1884
2368
|
if (item.show && isFunction(item.show)) {
|
|
1885
2369
|
return item.show(record);
|
|
1886
2370
|
}
|
|
@@ -1893,7 +2377,7 @@ var ProTable = defineComponent({
|
|
|
1893
2377
|
});
|
|
1894
2378
|
return createVNode("div", {
|
|
1895
2379
|
"class": "pro-table-operate"
|
|
1896
|
-
}, [map(
|
|
2380
|
+
}, [map(showItems, function (item) {
|
|
1897
2381
|
//自定义
|
|
1898
2382
|
if (isFunction(item.element)) {
|
|
1899
2383
|
return item.element(record, item);
|
|
@@ -1910,20 +2394,62 @@ var ProTable = defineComponent({
|
|
|
1910
2394
|
}, [item.label]);
|
|
1911
2395
|
})]);
|
|
1912
2396
|
}
|
|
1913
|
-
}
|
|
1914
|
-
}
|
|
2397
|
+
});
|
|
2398
|
+
};
|
|
1915
2399
|
|
|
1916
|
-
|
|
1917
|
-
|
|
1918
|
-
|
|
1919
|
-
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
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
|
+
}
|
|
1923
2421
|
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
1927
|
-
|
|
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
|
+
};
|
|
1928
2454
|
|
|
1929
|
-
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 };
|