@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.js
CHANGED
|
@@ -83,6 +83,50 @@ function _nonIterableSpread() {
|
|
|
83
83
|
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
84
84
|
}
|
|
85
85
|
|
|
86
|
+
function _isSlot$1(s) {
|
|
87
|
+
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var proGridProps = function proGridProps() {
|
|
91
|
+
return {
|
|
92
|
+
row: {
|
|
93
|
+
type: Object,
|
|
94
|
+
"default": undefined
|
|
95
|
+
},
|
|
96
|
+
col: {
|
|
97
|
+
type: Object
|
|
98
|
+
},
|
|
99
|
+
items: {
|
|
100
|
+
type: Array
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
var createGrid = function createGrid(Row, Col) {
|
|
106
|
+
return vue.defineComponent({
|
|
107
|
+
props: _objectSpread2({}, proGridProps()),
|
|
108
|
+
setup: function setup(props) {
|
|
109
|
+
return function () {
|
|
110
|
+
var _slot;
|
|
111
|
+
|
|
112
|
+
return vue.createVNode(Row, props.row, _isSlot$1(_slot = lodash.map(props.items, function (item) {
|
|
113
|
+
return vue.createVNode(Col, vue.mergeProps({
|
|
114
|
+
"key": item.rowKey
|
|
115
|
+
}, props.col, item.col), {
|
|
116
|
+
"default": function _default() {
|
|
117
|
+
return [item.vNode];
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
})) ? _slot : {
|
|
121
|
+
"default": function _default() {
|
|
122
|
+
return [_slot];
|
|
123
|
+
}
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
|
|
86
130
|
var createUseRequestActor = function createUseRequestActor(filterFun) {
|
|
87
131
|
return function (actors, callback) {
|
|
88
132
|
var _useRequestProvide = request.useRequestProvide(),
|
|
@@ -155,12 +199,85 @@ var useComposeRequestActor = function useComposeRequestActor(actors, options, ca
|
|
|
155
199
|
}, []);
|
|
156
200
|
};
|
|
157
201
|
|
|
202
|
+
var treeDefaultNames = {
|
|
203
|
+
children: "children",
|
|
204
|
+
label: "label",
|
|
205
|
+
value: "value"
|
|
206
|
+
};
|
|
207
|
+
/**
|
|
208
|
+
* 根据value从treeData中找到对象
|
|
209
|
+
* @param data
|
|
210
|
+
* @param value
|
|
211
|
+
* @param fieldNames
|
|
212
|
+
* @param cb 对象:同步 方法:回调,可以理解为异步
|
|
213
|
+
*/
|
|
214
|
+
|
|
215
|
+
var findTargetInTree = function findTargetInTree(data, value, fieldNames, cb) {
|
|
216
|
+
var index = lodash.findIndex(data, function (item) {
|
|
217
|
+
return lodash.get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || treeDefaultNames.value) === value;
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
if (index > -1) {
|
|
221
|
+
if (lodash.isFunction(cb)) {
|
|
222
|
+
cb(index, data[index], data);
|
|
223
|
+
} else {
|
|
224
|
+
cb.index = index;
|
|
225
|
+
cb.target = data[index];
|
|
226
|
+
cb.list = data;
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
return;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
lodash.forEach(data, function (item) {
|
|
233
|
+
var children = lodash.get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || treeDefaultNames.children);
|
|
234
|
+
|
|
235
|
+
if (lodash.size(children) > 0) {
|
|
236
|
+
findTargetInTree(children, value, fieldNames, cb);
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
};
|
|
240
|
+
/**
|
|
241
|
+
* 根据value从treeData中找出对象及父列表
|
|
242
|
+
* @param data
|
|
243
|
+
* @param value
|
|
244
|
+
* @param fieldNames
|
|
245
|
+
* @param cb
|
|
246
|
+
* @param parent
|
|
247
|
+
*/
|
|
248
|
+
|
|
249
|
+
var findTargetListInTree = function findTargetListInTree(data, value, fieldNames, cb) {
|
|
250
|
+
var parent = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
251
|
+
var target = lodash.find(data, function (item) {
|
|
252
|
+
return lodash.get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.value) || treeDefaultNames.value) === value;
|
|
253
|
+
});
|
|
254
|
+
|
|
255
|
+
if (target) {
|
|
256
|
+
if (lodash.isFunction(cb)) {
|
|
257
|
+
cb([].concat(_toConsumableArray(parent), [target]));
|
|
258
|
+
} else {
|
|
259
|
+
cb.list = [].concat(_toConsumableArray(parent), [target]);
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
return;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
lodash.forEach(data, function (item) {
|
|
266
|
+
var children = lodash.get(item, (fieldNames === null || fieldNames === void 0 ? void 0 : fieldNames.children) || treeDefaultNames.children);
|
|
267
|
+
|
|
268
|
+
if (lodash.size(children) > 0) {
|
|
269
|
+
findTargetListInTree(children, value, fieldNames, cb, [].concat(_toConsumableArray(parent), [item]));
|
|
270
|
+
}
|
|
271
|
+
});
|
|
272
|
+
};
|
|
273
|
+
|
|
158
274
|
/**
|
|
159
275
|
* 剔除showState或showStateRules规则为!true的值
|
|
160
276
|
* @param values
|
|
161
277
|
* @param showState
|
|
162
278
|
* @param showStateRules
|
|
163
279
|
*/
|
|
280
|
+
|
|
164
281
|
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
165
282
|
if (showState) {
|
|
166
283
|
var invalidKeys = lodash.filter(lodash.keys(showState), function (key) {
|
|
@@ -199,16 +316,10 @@ var convertPathToList = function convertPathToList(path) {
|
|
|
199
316
|
|
|
200
317
|
return [path];
|
|
201
318
|
};
|
|
202
|
-
/**
|
|
203
|
-
* 唯一id
|
|
204
|
-
*/
|
|
205
|
-
|
|
206
|
-
var generateId = function generateId() {
|
|
207
|
-
return Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36);
|
|
208
|
-
};
|
|
209
319
|
/**
|
|
210
320
|
* 将listState 中的数据通过id merge到 list item中
|
|
211
321
|
* ps:数组会替换
|
|
322
|
+
* 注意:mergeWith 会改变原始对象
|
|
212
323
|
* @param list
|
|
213
324
|
* @param listState
|
|
214
325
|
* @param id
|
|
@@ -238,6 +349,31 @@ var mergeStateToList = function mergeStateToList(list, listState, id) {
|
|
|
238
349
|
});
|
|
239
350
|
};
|
|
240
351
|
|
|
352
|
+
/**
|
|
353
|
+
* 唯一id
|
|
354
|
+
*/
|
|
355
|
+
|
|
356
|
+
var generateId = function generateId() {
|
|
357
|
+
return Number(Math.random().toString().substr(3, 3) + Date.now()).toString(36);
|
|
358
|
+
};
|
|
359
|
+
/**
|
|
360
|
+
* ref 传递
|
|
361
|
+
*/
|
|
362
|
+
|
|
363
|
+
var createExpose = function createExpose(methods, targetRef) {
|
|
364
|
+
return lodash.reduce(methods, function (pair, method) {
|
|
365
|
+
return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, method, function () {
|
|
366
|
+
var _targetRef$value, _targetRef$value$meth;
|
|
367
|
+
|
|
368
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
369
|
+
params[_key] = arguments[_key];
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
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));
|
|
373
|
+
}));
|
|
374
|
+
}, {});
|
|
375
|
+
};
|
|
376
|
+
|
|
241
377
|
/**
|
|
242
378
|
* 获取Column的valueType,默认"text"
|
|
243
379
|
* @param column
|
|
@@ -625,16 +761,16 @@ var defaultPage = {
|
|
|
625
761
|
|
|
626
762
|
var proCurdProps = function proCurdProps() {
|
|
627
763
|
return {
|
|
628
|
-
/**
|
|
629
|
-
* 列表 或 详情 的唯一标识
|
|
764
|
+
/**
|
|
765
|
+
* 列表 或 详情 的唯一标识
|
|
630
766
|
*/
|
|
631
767
|
rowKey: {
|
|
632
768
|
type: String,
|
|
633
769
|
"default": "id"
|
|
634
770
|
},
|
|
635
771
|
|
|
636
|
-
/**
|
|
637
|
-
* operates
|
|
772
|
+
/**
|
|
773
|
+
* operates
|
|
638
774
|
*/
|
|
639
775
|
operates: {
|
|
640
776
|
type: Array
|
|
@@ -667,10 +803,10 @@ var Curd = vue.defineComponent({
|
|
|
667
803
|
state = _ref2.state,
|
|
668
804
|
sendEvent = _ref2.sendEvent,
|
|
669
805
|
sendRequest = _ref2.sendRequest;
|
|
670
|
-
/**
|
|
671
|
-
* 排序
|
|
672
|
-
* @param list
|
|
673
|
-
* @param propName
|
|
806
|
+
/**
|
|
807
|
+
* 排序
|
|
808
|
+
* @param list
|
|
809
|
+
* @param propName
|
|
674
810
|
*/
|
|
675
811
|
|
|
676
812
|
|
|
@@ -679,8 +815,8 @@ var Curd = vue.defineComponent({
|
|
|
679
815
|
return lodash.get(item, propName);
|
|
680
816
|
});
|
|
681
817
|
};
|
|
682
|
-
/**
|
|
683
|
-
* 非 hideInForm columns
|
|
818
|
+
/**
|
|
819
|
+
* 非 hideInForm columns
|
|
684
820
|
*/
|
|
685
821
|
|
|
686
822
|
|
|
@@ -689,8 +825,8 @@ var Curd = vue.defineComponent({
|
|
|
689
825
|
return !item.hideInForm;
|
|
690
826
|
}), "formSort");
|
|
691
827
|
});
|
|
692
|
-
/**
|
|
693
|
-
* 非 hideInDetail columns
|
|
828
|
+
/**
|
|
829
|
+
* 非 hideInDetail columns
|
|
694
830
|
*/
|
|
695
831
|
|
|
696
832
|
var descColumns = vue.computed(function () {
|
|
@@ -698,8 +834,8 @@ var Curd = vue.defineComponent({
|
|
|
698
834
|
return !item.hideInDetail;
|
|
699
835
|
}), "descSort");
|
|
700
836
|
});
|
|
701
|
-
/**
|
|
702
|
-
* 非 hideInTable columns
|
|
837
|
+
/**
|
|
838
|
+
* 非 hideInTable columns
|
|
703
839
|
*/
|
|
704
840
|
|
|
705
841
|
var tableColumns = vue.computed(function () {
|
|
@@ -707,8 +843,8 @@ var Curd = vue.defineComponent({
|
|
|
707
843
|
return !item.hideInTable;
|
|
708
844
|
}), "tableSort");
|
|
709
845
|
});
|
|
710
|
-
/**
|
|
711
|
-
* search columns
|
|
846
|
+
/**
|
|
847
|
+
* search columns
|
|
712
848
|
*/
|
|
713
849
|
|
|
714
850
|
var searchColumns = vue.computed(function () {
|
|
@@ -1274,6 +1410,319 @@ var ProPageCurd = vue.defineComponent({
|
|
|
1274
1410
|
}
|
|
1275
1411
|
});
|
|
1276
1412
|
|
|
1413
|
+
function _isSlot(s) {
|
|
1414
|
+
return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !vue.isVNode(s);
|
|
1415
|
+
}
|
|
1416
|
+
|
|
1417
|
+
var createCurdDesc = function createCurdDesc(Descriptions, DescriptionsItem) {
|
|
1418
|
+
return vue.defineComponent({
|
|
1419
|
+
props: _objectSpread2({}, Descriptions.props),
|
|
1420
|
+
setup: function setup(props, _ref) {
|
|
1421
|
+
var slots = _ref.slots;
|
|
1422
|
+
|
|
1423
|
+
var _useProModule = useProModule(),
|
|
1424
|
+
getItemVNode = _useProModule.getItemVNode;
|
|
1425
|
+
|
|
1426
|
+
var _useProCurd = useProCurd(),
|
|
1427
|
+
curdState = _useProCurd.curdState,
|
|
1428
|
+
descColumns = _useProCurd.descColumns;
|
|
1429
|
+
|
|
1430
|
+
var descVNodes = vue.computed(function () {
|
|
1431
|
+
return lodash.map(descColumns.value, function (item) {
|
|
1432
|
+
var _slot;
|
|
1433
|
+
|
|
1434
|
+
var value = lodash.get(curdState.detailData, item.dataIndex);
|
|
1435
|
+
return vue.createVNode(DescriptionsItem, vue.mergeProps({
|
|
1436
|
+
"key": item.dataIndex,
|
|
1437
|
+
"label": item.title
|
|
1438
|
+
}, lodash.get(item.extra, "desc")), _isSlot(_slot = getItemVNode(item, value)) ? _slot : {
|
|
1439
|
+
"default": function _default() {
|
|
1440
|
+
return [_slot];
|
|
1441
|
+
}
|
|
1442
|
+
});
|
|
1443
|
+
});
|
|
1444
|
+
});
|
|
1445
|
+
return function () {
|
|
1446
|
+
var _slots$start, _slots$default;
|
|
1447
|
+
|
|
1448
|
+
return vue.createVNode(Descriptions, props, _objectSpread2({
|
|
1449
|
+
"default": function _default() {
|
|
1450
|
+
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)];
|
|
1451
|
+
}
|
|
1452
|
+
}, lodash.omit(slots, "default", "start")));
|
|
1453
|
+
};
|
|
1454
|
+
}
|
|
1455
|
+
});
|
|
1456
|
+
};
|
|
1457
|
+
|
|
1458
|
+
var proCurdAddOrEditProps = function proCurdAddOrEditProps() {
|
|
1459
|
+
return {
|
|
1460
|
+
//是否使用operate bar
|
|
1461
|
+
operateBar: {
|
|
1462
|
+
type: Boolean,
|
|
1463
|
+
"default": true
|
|
1464
|
+
},
|
|
1465
|
+
//显示 确定并继续 按钮
|
|
1466
|
+
showContinueAdd: {
|
|
1467
|
+
type: Boolean,
|
|
1468
|
+
"default": false
|
|
1469
|
+
},
|
|
1470
|
+
//
|
|
1471
|
+
okText: {
|
|
1472
|
+
type: String,
|
|
1473
|
+
"default": "确定"
|
|
1474
|
+
},
|
|
1475
|
+
okButtonProps: {
|
|
1476
|
+
type: Object
|
|
1477
|
+
},
|
|
1478
|
+
//
|
|
1479
|
+
continueText: {
|
|
1480
|
+
type: String,
|
|
1481
|
+
"default": "确定并继续"
|
|
1482
|
+
},
|
|
1483
|
+
continueButtonProps: {
|
|
1484
|
+
type: Object
|
|
1485
|
+
}
|
|
1486
|
+
};
|
|
1487
|
+
};
|
|
1488
|
+
|
|
1489
|
+
var createCurdForm = function createCurdForm(Form, Button, convertFormProps) {
|
|
1490
|
+
return vue.defineComponent({
|
|
1491
|
+
props: _objectSpread2(_objectSpread2({}, Form.props), proCurdAddOrEditProps()),
|
|
1492
|
+
setup: function setup(props, _ref) {
|
|
1493
|
+
var slots = _ref.slots;
|
|
1494
|
+
|
|
1495
|
+
var _useProModule = useProModule(),
|
|
1496
|
+
elementMap = _useProModule.elementMap,
|
|
1497
|
+
formElementMap = _useProModule.formElementMap;
|
|
1498
|
+
|
|
1499
|
+
var _useProCurd = useProCurd(),
|
|
1500
|
+
curdState = _useProCurd.curdState,
|
|
1501
|
+
formColumns = _useProCurd.formColumns,
|
|
1502
|
+
sendCurdEvent = _useProCurd.sendCurdEvent;
|
|
1503
|
+
|
|
1504
|
+
var formRef = vue.ref();
|
|
1505
|
+
|
|
1506
|
+
var handleFinish = function handleFinish(values) {
|
|
1507
|
+
if (curdState.mode === exports.CurdCurrentMode.EDIT) {
|
|
1508
|
+
//edit
|
|
1509
|
+
sendCurdEvent({
|
|
1510
|
+
action: exports.CurdAction.EDIT,
|
|
1511
|
+
type: exports.CurdSubAction.EXECUTE,
|
|
1512
|
+
values: values
|
|
1513
|
+
});
|
|
1514
|
+
} else {
|
|
1515
|
+
//add
|
|
1516
|
+
sendCurdEvent({
|
|
1517
|
+
action: exports.CurdAction.ADD,
|
|
1518
|
+
type: exports.CurdSubAction.EXECUTE,
|
|
1519
|
+
values: values
|
|
1520
|
+
});
|
|
1521
|
+
}
|
|
1522
|
+
};
|
|
1523
|
+
|
|
1524
|
+
var handleAdd = function handleAdd() {
|
|
1525
|
+
var _formRef$value;
|
|
1526
|
+
|
|
1527
|
+
curdState.addAction = exports.CurdAddAction.NORMAL;
|
|
1528
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
var handleContinueAdd = function handleContinueAdd() {
|
|
1532
|
+
var _formRef$value2;
|
|
1533
|
+
|
|
1534
|
+
curdState.addAction = exports.CurdAddAction.CONTINUE;
|
|
1535
|
+
(_formRef$value2 = formRef.value) === null || _formRef$value2 === void 0 ? void 0 : _formRef$value2.submit();
|
|
1536
|
+
};
|
|
1537
|
+
|
|
1538
|
+
return function () {
|
|
1539
|
+
var _slots$divide, _slots$operateStart, _slots$operateCenter, _slots$operateEnd, _slots$default;
|
|
1540
|
+
|
|
1541
|
+
return vue.createVNode(Form, vue.mergeProps({
|
|
1542
|
+
"ref": formRef
|
|
1543
|
+
}, props, {
|
|
1544
|
+
"elementMap": props.elementMap || elementMap,
|
|
1545
|
+
"formElementMap": props.formElementMap || formElementMap,
|
|
1546
|
+
"columns": formColumns.value,
|
|
1547
|
+
"model": curdState.detailData,
|
|
1548
|
+
"readonly": curdState.mode === exports.CurdCurrentMode.DETAIL,
|
|
1549
|
+
"onFinish": handleFinish
|
|
1550
|
+
}, convertFormProps === null || convertFormProps === void 0 ? void 0 : convertFormProps(curdState)), _objectSpread2({
|
|
1551
|
+
"default": function _default() {
|
|
1552
|
+
return [(_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), props.operateBar && vue.createVNode("div", {
|
|
1553
|
+
"class": "pro-curd-form-operate"
|
|
1554
|
+
}, [(_slots$operateStart = slots.operateStart) === null || _slots$operateStart === void 0 ? void 0 : _slots$operateStart.call(slots), curdState.mode !== exports.CurdCurrentMode.DETAIL && vue.createVNode(Button, vue.mergeProps({
|
|
1555
|
+
"onClick": handleAdd
|
|
1556
|
+
}, props.okButtonProps, {
|
|
1557
|
+
"loading": curdState.operateLoading
|
|
1558
|
+
}), {
|
|
1559
|
+
"default": function _default() {
|
|
1560
|
+
return [props.okText];
|
|
1561
|
+
}
|
|
1562
|
+
}), (_slots$operateCenter = slots.operateCenter) === null || _slots$operateCenter === void 0 ? void 0 : _slots$operateCenter.call(slots), props.showContinueAdd && curdState.mode === exports.CurdCurrentMode.ADD && vue.createVNode(Button, vue.mergeProps({
|
|
1563
|
+
"onClick": handleContinueAdd
|
|
1564
|
+
}, props.continueButtonProps, {
|
|
1565
|
+
"loading": curdState.operateLoading
|
|
1566
|
+
}), {
|
|
1567
|
+
"default": function _default() {
|
|
1568
|
+
return [props.continueText];
|
|
1569
|
+
}
|
|
1570
|
+
}), (_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)];
|
|
1571
|
+
}
|
|
1572
|
+
}, lodash.omit(slots, "default", "divide", "operateStart", "operateCenter", "operateEnd")));
|
|
1573
|
+
};
|
|
1574
|
+
}
|
|
1575
|
+
});
|
|
1576
|
+
};
|
|
1577
|
+
|
|
1578
|
+
var proCurdListProps = function proCurdListProps() {
|
|
1579
|
+
return {
|
|
1580
|
+
/**
|
|
1581
|
+
* extra 是否放到SearchForm中
|
|
1582
|
+
*/
|
|
1583
|
+
extraInSearch: {
|
|
1584
|
+
type: Boolean,
|
|
1585
|
+
"default": undefined
|
|
1586
|
+
},
|
|
1587
|
+
//search
|
|
1588
|
+
searchProps: {
|
|
1589
|
+
type: Object
|
|
1590
|
+
},
|
|
1591
|
+
//table
|
|
1592
|
+
tableProps: {
|
|
1593
|
+
type: Object
|
|
1594
|
+
},
|
|
1595
|
+
//pageState
|
|
1596
|
+
pageState: {
|
|
1597
|
+
type: Object
|
|
1598
|
+
}
|
|
1599
|
+
};
|
|
1600
|
+
};
|
|
1601
|
+
|
|
1602
|
+
var createCurdList = function createCurdList(SearchForm, Table) {
|
|
1603
|
+
return vue.defineComponent({
|
|
1604
|
+
props: _objectSpread2({}, proCurdListProps()),
|
|
1605
|
+
setup: function setup(props, _ref) {
|
|
1606
|
+
var slots = _ref.slots;
|
|
1607
|
+
|
|
1608
|
+
var _useProModule = useProModule(),
|
|
1609
|
+
elementMap = _useProModule.elementMap,
|
|
1610
|
+
formElementMap = _useProModule.formElementMap;
|
|
1611
|
+
|
|
1612
|
+
var _useProCurd = useProCurd(),
|
|
1613
|
+
curdState = _useProCurd.curdState,
|
|
1614
|
+
searchColumns = _useProCurd.searchColumns,
|
|
1615
|
+
tableColumns = _useProCurd.tableColumns,
|
|
1616
|
+
getOperate = _useProCurd.getOperate,
|
|
1617
|
+
sendCurdEvent = _useProCurd.sendCurdEvent;
|
|
1618
|
+
/******************* search pagination ********************/
|
|
1619
|
+
|
|
1620
|
+
|
|
1621
|
+
var pageState = props.pageState || vue.reactive(_objectSpread2({}, defaultPage));
|
|
1622
|
+
var prevValues;
|
|
1623
|
+
|
|
1624
|
+
var handleSearch = function handleSearch() {
|
|
1625
|
+
sendCurdEvent({
|
|
1626
|
+
action: exports.CurdAction.LIST,
|
|
1627
|
+
type: exports.CurdSubAction.EMIT,
|
|
1628
|
+
values: _objectSpread2(_objectSpread2({}, prevValues), pageState)
|
|
1629
|
+
});
|
|
1630
|
+
};
|
|
1631
|
+
|
|
1632
|
+
var executeSearchWithResetPage = function executeSearchWithResetPage(values) {
|
|
1633
|
+
prevValues = values;
|
|
1634
|
+
pageState.page = 1;
|
|
1635
|
+
handleSearch();
|
|
1636
|
+
};
|
|
1637
|
+
/******************* table ********************/
|
|
1638
|
+
|
|
1639
|
+
|
|
1640
|
+
var createTableItem = function createTableItem(action) {
|
|
1641
|
+
var operate = getOperate(action);
|
|
1642
|
+
|
|
1643
|
+
var item = _objectSpread2(_objectSpread2({}, lodash.pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
|
|
1644
|
+
show: !lodash.isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
|
|
1645
|
+
value: action
|
|
1646
|
+
});
|
|
1647
|
+
|
|
1648
|
+
if (!item.onClick) {
|
|
1649
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1650
|
+
onClick: function onClick(record) {
|
|
1651
|
+
//默认发送事件
|
|
1652
|
+
sendCurdEvent({
|
|
1653
|
+
action: action,
|
|
1654
|
+
type: exports.CurdSubAction.EMIT,
|
|
1655
|
+
record: record
|
|
1656
|
+
});
|
|
1657
|
+
}
|
|
1658
|
+
});
|
|
1659
|
+
}
|
|
1660
|
+
|
|
1661
|
+
return item;
|
|
1662
|
+
}; //table操作栏 items
|
|
1663
|
+
|
|
1664
|
+
|
|
1665
|
+
var tableOperateItems = [createTableItem(exports.CurdAction.DETAIL), createTableItem(exports.CurdAction.EDIT), createTableItem(exports.CurdAction.DELETE)]; //新配置的operate item,添加默认发送事件方法
|
|
1666
|
+
|
|
1667
|
+
var convertOperateItems = function convertOperateItems(list) {
|
|
1668
|
+
return lodash.map(list, function (item) {
|
|
1669
|
+
if (!item.onClick) {
|
|
1670
|
+
return _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1671
|
+
onClick: function onClick(record) {
|
|
1672
|
+
sendCurdEvent({
|
|
1673
|
+
action: "operate",
|
|
1674
|
+
type: item.value,
|
|
1675
|
+
record: record
|
|
1676
|
+
});
|
|
1677
|
+
}
|
|
1678
|
+
});
|
|
1679
|
+
}
|
|
1680
|
+
|
|
1681
|
+
return item;
|
|
1682
|
+
});
|
|
1683
|
+
};
|
|
1684
|
+
|
|
1685
|
+
return function () {
|
|
1686
|
+
var _props$searchProps, _slots$divide, _curdState$listData, _slots$divide2, _slots$footerStart, _slots$pagination, _curdState$listData2, _slots$footerEnd;
|
|
1687
|
+
|
|
1688
|
+
var tableProps = props.tableProps;
|
|
1689
|
+
var extra = slots.extra ? vue.createVNode("div", {
|
|
1690
|
+
"class": "pro-curd-list-extra"
|
|
1691
|
+
}, [slots.extra()]) : null;
|
|
1692
|
+
return vue.createVNode(vue.Fragment, null, [vue.createVNode(SearchForm, vue.mergeProps({
|
|
1693
|
+
"formElementMap": formElementMap
|
|
1694
|
+
}, lodash.omit(props.searchProps, "slots"), {
|
|
1695
|
+
"columns": searchColumns.value,
|
|
1696
|
+
"onFinish": executeSearchWithResetPage
|
|
1697
|
+
}), _objectSpread2({
|
|
1698
|
+
"default": function _default() {
|
|
1699
|
+
return [props.extraInSearch && extra];
|
|
1700
|
+
}
|
|
1701
|
+
}, (_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() : vue.createVNode(Table, vue.mergeProps({
|
|
1702
|
+
"elementMap": elementMap
|
|
1703
|
+
}, lodash.omit(tableProps, "slots", "operate"), {
|
|
1704
|
+
"operate": lodash.mergeWith({
|
|
1705
|
+
items: tableOperateItems
|
|
1706
|
+
}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.operate, function (objValue, srcValue) {
|
|
1707
|
+
if (lodash.isArray(objValue) && lodash.isArray(srcValue)) {
|
|
1708
|
+
return lodash.concat(objValue, convertOperateItems(srcValue));
|
|
1709
|
+
}
|
|
1710
|
+
}),
|
|
1711
|
+
"paginationState": {
|
|
1712
|
+
page: pageState.page,
|
|
1713
|
+
pageSize: pageState.pageSize
|
|
1714
|
+
},
|
|
1715
|
+
"columns": tableColumns.value,
|
|
1716
|
+
"loading": curdState.listLoading,
|
|
1717
|
+
"dataSource": (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
|
|
1718
|
+
}), tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), vue.createVNode("div", {
|
|
1719
|
+
"class": "pro-curd-list-footer"
|
|
1720
|
+
}, [(_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)])]);
|
|
1721
|
+
};
|
|
1722
|
+
}
|
|
1723
|
+
});
|
|
1724
|
+
};
|
|
1725
|
+
|
|
1277
1726
|
var ProFormKey = Symbol("pro-form");
|
|
1278
1727
|
var useProForm = function useProForm() {
|
|
1279
1728
|
return vue.inject(ProFormKey);
|
|
@@ -1372,65 +1821,120 @@ var proFormProps = function proFormProps() {
|
|
|
1372
1821
|
};
|
|
1373
1822
|
};
|
|
1374
1823
|
|
|
1375
|
-
var
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1824
|
+
var createForm = function createForm(Form, Grid) {
|
|
1825
|
+
return vue.defineComponent({
|
|
1826
|
+
inheritAttrs: false,
|
|
1827
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), proFormProps()), lodash.omit(Grid.props, "items")),
|
|
1828
|
+
setup: function setup(props, _ref) {
|
|
1829
|
+
var slots = _ref.slots,
|
|
1830
|
+
emit = _ref.emit,
|
|
1831
|
+
expose = _ref.expose,
|
|
1832
|
+
attrs = _ref.attrs;
|
|
1833
|
+
var formState = props.model || vue.reactive({}); //组件状态相关
|
|
1834
|
+
|
|
1835
|
+
var showState = props.showState || vue.reactive({});
|
|
1836
|
+
var readonlyState = props.readonlyState || vue.reactive({});
|
|
1837
|
+
var disableState = props.disableState || vue.reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
|
|
1838
|
+
|
|
1839
|
+
hooks.useEffect(function () {
|
|
1840
|
+
if (props.showStateRules) {
|
|
1841
|
+
lodash.forEach(props.showStateRules, function (fn, key) {
|
|
1842
|
+
showState[key] = fn(formState);
|
|
1843
|
+
});
|
|
1844
|
+
}
|
|
1380
1845
|
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1846
|
+
if (props.readonlyStateRules) {
|
|
1847
|
+
lodash.forEach(props.readonlyStateRules, function (fn, key) {
|
|
1848
|
+
readonlyState[key] = fn(formState);
|
|
1849
|
+
});
|
|
1850
|
+
}
|
|
1384
1851
|
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1852
|
+
if (props.disableStateRules) {
|
|
1853
|
+
lodash.forEach(props.disableStateRules, function (fn, key) {
|
|
1854
|
+
disableState[key] = fn(formState);
|
|
1855
|
+
});
|
|
1856
|
+
}
|
|
1857
|
+
}, formState); //readonly
|
|
1391
1858
|
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
});
|
|
1396
|
-
}
|
|
1859
|
+
var readonly = vue.computed(function () {
|
|
1860
|
+
return props.readonly;
|
|
1861
|
+
}); //columns合并
|
|
1397
1862
|
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1863
|
+
var columns = vue.computed(function () {
|
|
1864
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1865
|
+
return getColumnFormItemName(item);
|
|
1401
1866
|
});
|
|
1402
|
-
}
|
|
1403
|
-
}, formState); //转换为ref对象
|
|
1404
|
-
|
|
1405
|
-
var readonly = vue.computed(function () {
|
|
1406
|
-
return props.readonly;
|
|
1407
|
-
});
|
|
1408
|
-
var columns = vue.computed(function () {
|
|
1409
|
-
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1410
|
-
return getColumnFormItemName(item);
|
|
1411
1867
|
});
|
|
1412
|
-
});
|
|
1413
|
-
provideProForm(_objectSpread2({
|
|
1414
|
-
formState: formState,
|
|
1415
|
-
showState: showState,
|
|
1416
|
-
readonlyState: readonlyState,
|
|
1417
|
-
disableState: disableState,
|
|
1418
|
-
//
|
|
1419
|
-
elementMap: props.elementMap,
|
|
1420
|
-
formElementMap: props.formElementMap,
|
|
1421
|
-
//
|
|
1422
|
-
readonly: readonly,
|
|
1423
|
-
//
|
|
1424
|
-
columns: columns
|
|
1425
|
-
}, props.provideExtra));
|
|
1426
|
-
return function () {
|
|
1427
|
-
var _slots$default;
|
|
1428
1868
|
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
}
|
|
1869
|
+
var handleFinish = function handleFinish(values) {
|
|
1870
|
+
//删除不显示的值再触发事件
|
|
1871
|
+
var showValues = getValidValues(values, showState, props.showStateRules);
|
|
1872
|
+
emit("finish", showValues, values);
|
|
1873
|
+
};
|
|
1874
|
+
|
|
1875
|
+
var formRef = vue.ref();
|
|
1876
|
+
expose({
|
|
1877
|
+
submit: function submit() {
|
|
1878
|
+
var _formRef$value;
|
|
1879
|
+
|
|
1880
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
1881
|
+
},
|
|
1882
|
+
resetFields: function resetFields() {
|
|
1883
|
+
var _formRef$value2;
|
|
1884
|
+
|
|
1885
|
+
for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
1886
|
+
params[_key] = arguments[_key];
|
|
1887
|
+
}
|
|
1888
|
+
|
|
1889
|
+
(_formRef$value2 = formRef.value) === null || _formRef$value2 === void 0 ? void 0 : _formRef$value2.resetFields.apply(_formRef$value2, params);
|
|
1890
|
+
}
|
|
1891
|
+
});
|
|
1892
|
+
provideProForm(_objectSpread2({
|
|
1893
|
+
formState: formState,
|
|
1894
|
+
showState: showState,
|
|
1895
|
+
readonlyState: readonlyState,
|
|
1896
|
+
disableState: disableState,
|
|
1897
|
+
//
|
|
1898
|
+
elementMap: props.elementMap,
|
|
1899
|
+
formElementMap: props.formElementMap,
|
|
1900
|
+
//
|
|
1901
|
+
readonly: readonly,
|
|
1902
|
+
//
|
|
1903
|
+
columns: columns,
|
|
1904
|
+
//
|
|
1905
|
+
formRef: formRef
|
|
1906
|
+
}, props.provideExtra));
|
|
1907
|
+
var invalidKeys = lodash.keys(proFormProps());
|
|
1908
|
+
var gridKeys = lodash.keys(lodash.omit(Grid.props, "items"));
|
|
1909
|
+
return function () {
|
|
1910
|
+
var _slots$start, _slots$default;
|
|
1911
|
+
|
|
1912
|
+
return vue.createVNode(Form, vue.mergeProps({
|
|
1913
|
+
"ref": formRef
|
|
1914
|
+
}, lodash.omit(attrs, "onFinish"), lodash.omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), _toConsumableArray(gridKeys), ["onFinish"])), {
|
|
1915
|
+
"model": formState,
|
|
1916
|
+
"onFinish": handleFinish
|
|
1917
|
+
}), _objectSpread2({
|
|
1918
|
+
"default": function _default() {
|
|
1919
|
+
return [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), props.formElementMap && lodash.size(columns.value) > 0 && vue.createVNode(vue.Fragment, null, [props.row ? vue.createVNode(Grid, {
|
|
1920
|
+
"row": props.row,
|
|
1921
|
+
"col": props.col,
|
|
1922
|
+
"items": lodash.map(columns.value, function (item) {
|
|
1923
|
+
return {
|
|
1924
|
+
rowKey: getColumnFormItemName(item),
|
|
1925
|
+
vNode: getFormItemEl(props.formElementMap, item, props.needRules),
|
|
1926
|
+
col: lodash.get(item, ["extra", "col"])
|
|
1927
|
+
};
|
|
1928
|
+
})
|
|
1929
|
+
}, null) : lodash.map(columns.value, function (item) {
|
|
1930
|
+
return getFormItemEl(props.formElementMap, item, props.needRules);
|
|
1931
|
+
})]), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1932
|
+
}
|
|
1933
|
+
}, lodash.omit(slots, "default")));
|
|
1934
|
+
};
|
|
1935
|
+
}
|
|
1936
|
+
});
|
|
1937
|
+
};
|
|
1434
1938
|
|
|
1435
1939
|
exports.SearchMode = void 0;
|
|
1436
1940
|
|
|
@@ -1479,6 +1983,11 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1479
1983
|
debounceKeys: {
|
|
1480
1984
|
type: Array
|
|
1481
1985
|
},
|
|
1986
|
+
//默认 valueType 为 text 的控件会debounce处理
|
|
1987
|
+
debounceTypes: {
|
|
1988
|
+
type: Array,
|
|
1989
|
+
"default": ["text"]
|
|
1990
|
+
},
|
|
1482
1991
|
debounceTime: {
|
|
1483
1992
|
type: Number,
|
|
1484
1993
|
"default": 800
|
|
@@ -1490,62 +1999,74 @@ var proSearchFormProps = function proSearchFormProps() {
|
|
|
1490
1999
|
* 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
|
|
1491
2000
|
* 针对传入的model(监听对象)做相应的finish(回调)处理
|
|
1492
2001
|
*/
|
|
1493
|
-
var
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
var
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
2002
|
+
var createSearchForm = function createSearchForm(Form, Props) {
|
|
2003
|
+
return vue.defineComponent({
|
|
2004
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), Props), proSearchFormProps()),
|
|
2005
|
+
setup: function setup(props, _ref) {
|
|
2006
|
+
var slots = _ref.slots;
|
|
2007
|
+
var formState = props.model || vue.reactive({});
|
|
2008
|
+
var valueTypeSet = new Set(props.debounceTypes); //根据column valueType 算出默认需要debounce处理的属性集合
|
|
2009
|
+
|
|
2010
|
+
var defaultDebounceKeys = lodash.map(lodash.filter(props.columns, function (column) {
|
|
2011
|
+
var valueType = getColumnValueType(column); //默认input组件的触发事件需要debounce处理
|
|
2012
|
+
|
|
2013
|
+
return valueTypeSet.has(valueType);
|
|
2014
|
+
}), function (column) {
|
|
2015
|
+
return getColumnFormItemName(column);
|
|
2016
|
+
});
|
|
2017
|
+
var formRef = vue.ref();
|
|
1505
2018
|
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
};
|
|
2019
|
+
var handleFinish = function handleFinish() {
|
|
2020
|
+
var _formRef$value;
|
|
1509
2021
|
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
}, props.debounceTime); //初始化
|
|
2022
|
+
(_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
|
|
2023
|
+
};
|
|
1513
2024
|
|
|
1514
|
-
|
|
1515
|
-
if (props.initEmit) {
|
|
2025
|
+
var debounceFinish = lodash.debounce(function () {
|
|
1516
2026
|
handleFinish();
|
|
1517
|
-
}
|
|
1518
|
-
}, []);
|
|
2027
|
+
}, props.debounceTime); //初始化
|
|
1519
2028
|
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
2029
|
+
hooks.useEffect(function () {
|
|
2030
|
+
if (props.initEmit) {
|
|
2031
|
+
handleFinish();
|
|
2032
|
+
}
|
|
2033
|
+
}, []);
|
|
1525
2034
|
|
|
2035
|
+
var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
|
|
2036
|
+
return lodash.some(debounceKeys, function (key) {
|
|
2037
|
+
return lodash.get(state, key) !== lodash.get(prevState, key);
|
|
2038
|
+
});
|
|
2039
|
+
}; //监听
|
|
1526
2040
|
|
|
1527
|
-
hooks.useWatch(function (state, prevState) {
|
|
1528
|
-
if (props.searchMode !== exports.SearchMode.AUTO) {
|
|
1529
|
-
return;
|
|
1530
|
-
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1531
2041
|
|
|
2042
|
+
hooks.useWatch(function (state, prevState) {
|
|
2043
|
+
if (props.searchMode !== exports.SearchMode.AUTO) {
|
|
2044
|
+
return;
|
|
2045
|
+
} //如果改变的值中包括debounceKeys中注册的 延时触发
|
|
1532
2046
|
|
|
1533
|
-
var debounceKeys = lodash.size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
|
|
1534
2047
|
|
|
1535
|
-
|
|
1536
|
-
debounceFinish();
|
|
1537
|
-
return;
|
|
1538
|
-
}
|
|
2048
|
+
var debounceKeys = lodash.size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
|
|
1539
2049
|
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
});
|
|
2050
|
+
if (lodash.size(debounceKeys) > 0 && isDebounceDataChange(state, prevState, debounceKeys)) {
|
|
2051
|
+
debounceFinish();
|
|
2052
|
+
return;
|
|
2053
|
+
}
|
|
2054
|
+
|
|
2055
|
+
handleFinish();
|
|
2056
|
+
}, function () {
|
|
2057
|
+
return lodash.clone(formState);
|
|
2058
|
+
});
|
|
2059
|
+
var invalidKeys = lodash.keys(lodash.omit(proSearchFormProps(), "columns"));
|
|
2060
|
+
return function () {
|
|
2061
|
+
return vue.createVNode(Form, vue.mergeProps({
|
|
2062
|
+
"ref": formRef
|
|
2063
|
+
}, lodash.omit(props, invalidKeys), {
|
|
2064
|
+
"model": formState
|
|
2065
|
+
}), slots);
|
|
2066
|
+
};
|
|
2067
|
+
}
|
|
2068
|
+
});
|
|
2069
|
+
};
|
|
1549
2070
|
|
|
1550
2071
|
/**
|
|
1551
2072
|
* ProFormList ctx
|
|
@@ -1579,86 +2100,83 @@ var FormListProvider = vue.defineComponent({
|
|
|
1579
2100
|
}
|
|
1580
2101
|
});
|
|
1581
2102
|
|
|
1582
|
-
var
|
|
1583
|
-
return {
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
}
|
|
1594
|
-
};
|
|
1595
|
-
};
|
|
1596
|
-
|
|
1597
|
-
var ProFormList = vue.defineComponent({
|
|
1598
|
-
props: _objectSpread2({}, proFormListProps()),
|
|
1599
|
-
setup: function setup(props, _ref2) {
|
|
1600
|
-
var slots = _ref2.slots;
|
|
1601
|
-
|
|
1602
|
-
var _useProForm = useProForm(),
|
|
1603
|
-
formState = _useProForm.formState,
|
|
1604
|
-
readonly = _useProForm.readonly;
|
|
2103
|
+
var createFormList = function createFormList(FormItem) {
|
|
2104
|
+
return vue.defineComponent({
|
|
2105
|
+
props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
|
|
2106
|
+
//每行默认id
|
|
2107
|
+
rowKey: {
|
|
2108
|
+
type: String,
|
|
2109
|
+
"default": "id"
|
|
2110
|
+
}
|
|
2111
|
+
}),
|
|
2112
|
+
setup: function setup(props, _ref2) {
|
|
2113
|
+
var slots = _ref2.slots;
|
|
1605
2114
|
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
2115
|
+
var _useProForm = useProForm(),
|
|
2116
|
+
formState = _useProForm.formState,
|
|
2117
|
+
readonly = _useProForm.readonly;
|
|
1609
2118
|
|
|
1610
|
-
|
|
1611
|
-
var
|
|
2119
|
+
var formListCtx = useProFormList();
|
|
2120
|
+
var nameList = convertPathToList(props.name);
|
|
2121
|
+
var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
|
|
1612
2122
|
|
|
1613
|
-
|
|
1614
|
-
targetList =
|
|
1615
|
-
}
|
|
2123
|
+
var handleAdd = function handleAdd() {
|
|
2124
|
+
var targetList = lodash.get(formState, path);
|
|
1616
2125
|
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
2126
|
+
if (!lodash.isArray(targetList)) {
|
|
2127
|
+
targetList = [];
|
|
2128
|
+
}
|
|
1620
2129
|
|
|
1621
|
-
|
|
1622
|
-
|
|
2130
|
+
targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
|
|
2131
|
+
lodash.set(formState, path, targetList);
|
|
2132
|
+
};
|
|
1623
2133
|
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
}
|
|
2134
|
+
var handleRemove = function handleRemove(index) {
|
|
2135
|
+
var targetList = lodash.get(formState, path);
|
|
1627
2136
|
|
|
1628
|
-
|
|
1629
|
-
|
|
2137
|
+
if (lodash.size(targetList) <= 0) {
|
|
2138
|
+
return;
|
|
2139
|
+
}
|
|
1630
2140
|
|
|
1631
|
-
|
|
1632
|
-
|
|
2141
|
+
targetList.splice(index, 1);
|
|
2142
|
+
};
|
|
1633
2143
|
|
|
1634
|
-
return
|
|
1635
|
-
var _slots$
|
|
2144
|
+
return function () {
|
|
2145
|
+
var _slots$add;
|
|
1636
2146
|
|
|
1637
|
-
return vue.createVNode(
|
|
1638
|
-
"key": index,
|
|
1639
|
-
"pathList": [].concat(_toConsumableArray(path), [index])
|
|
1640
|
-
}, {
|
|
2147
|
+
return vue.createVNode(FormItem, lodash.omit(props, "rowKey"), {
|
|
1641
2148
|
"default": function _default() {
|
|
1642
|
-
return [
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
2149
|
+
return [lodash.map(lodash.get(formState, path), function (item, index) {
|
|
2150
|
+
var _slots$default2, _slots$itemAdd, _slots$itemMinus;
|
|
2151
|
+
|
|
2152
|
+
return vue.createVNode(FormListProvider, {
|
|
2153
|
+
"key": item[props.rowKey] || index,
|
|
2154
|
+
"pathList": [].concat(_toConsumableArray(path), [index])
|
|
2155
|
+
}, {
|
|
2156
|
+
"default": function _default() {
|
|
2157
|
+
return [vue.createVNode("div", {
|
|
2158
|
+
"class": "pro-form-list-item"
|
|
2159
|
+
}, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && vue.createVNode(vue.Fragment, null, [vue.createVNode("div", {
|
|
2160
|
+
"class": "pro-form-list-item-add",
|
|
2161
|
+
"onClick": handleAdd
|
|
2162
|
+
}, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), vue.createVNode("div", {
|
|
2163
|
+
"class": "pro-form-list-item-minus",
|
|
2164
|
+
"onClick": function onClick() {
|
|
2165
|
+
return handleRemove(index);
|
|
2166
|
+
}
|
|
2167
|
+
}, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
|
|
2168
|
+
}
|
|
2169
|
+
});
|
|
2170
|
+
}), !readonly.value && vue.createVNode("div", {
|
|
2171
|
+
"class": "pro-form-list-add",
|
|
1646
2172
|
"onClick": handleAdd
|
|
1647
|
-
}, [(_slots$
|
|
1648
|
-
"class": "pro-form-list-item-minus",
|
|
1649
|
-
"onClick": function onClick() {
|
|
1650
|
-
return handleRemove(index);
|
|
1651
|
-
}
|
|
1652
|
-
}, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
|
|
2173
|
+
}, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
|
|
1653
2174
|
}
|
|
1654
2175
|
});
|
|
1655
|
-
}
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
};
|
|
1660
|
-
}
|
|
1661
|
-
});
|
|
2176
|
+
};
|
|
2177
|
+
}
|
|
2178
|
+
});
|
|
2179
|
+
};
|
|
1662
2180
|
|
|
1663
2181
|
var proFormItemProps = function proFormItemProps() {
|
|
1664
2182
|
return {
|
|
@@ -1763,8 +2281,8 @@ var proTableProps = function proTableProps() {
|
|
|
1763
2281
|
type: String
|
|
1764
2282
|
},
|
|
1765
2283
|
|
|
1766
|
-
/**
|
|
1767
|
-
* 公共column,会merge到columns item中
|
|
2284
|
+
/**
|
|
2285
|
+
* 公共column,会merge到columns item中
|
|
1768
2286
|
*/
|
|
1769
2287
|
column: {
|
|
1770
2288
|
type: Object
|
|
@@ -1777,36 +2295,29 @@ var proTableProps = function proTableProps() {
|
|
|
1777
2295
|
type: Object
|
|
1778
2296
|
},
|
|
1779
2297
|
|
|
1780
|
-
/**
|
|
1781
|
-
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
2298
|
+
/**
|
|
2299
|
+
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1782
2300
|
*/
|
|
1783
2301
|
elementMap: {
|
|
1784
2302
|
type: Object
|
|
1785
2303
|
},
|
|
1786
2304
|
|
|
1787
|
-
/**
|
|
1788
|
-
*
|
|
1789
|
-
*/
|
|
1790
|
-
loading: {
|
|
1791
|
-
type: Boolean
|
|
1792
|
-
},
|
|
1793
|
-
|
|
1794
|
-
/**
|
|
1795
|
-
* 序号
|
|
2305
|
+
/**
|
|
2306
|
+
* 序号
|
|
1796
2307
|
*/
|
|
1797
2308
|
serialNumber: {
|
|
1798
2309
|
type: Boolean
|
|
1799
2310
|
},
|
|
1800
2311
|
|
|
1801
|
-
/**
|
|
1802
|
-
* 分页
|
|
2312
|
+
/**
|
|
2313
|
+
* 分页
|
|
1803
2314
|
*/
|
|
1804
|
-
|
|
2315
|
+
paginationState: {
|
|
1805
2316
|
type: Object
|
|
1806
2317
|
},
|
|
1807
2318
|
|
|
1808
|
-
/**
|
|
1809
|
-
* provide传递
|
|
2319
|
+
/**
|
|
2320
|
+
* provide传递
|
|
1810
2321
|
*/
|
|
1811
2322
|
provideExtra: {
|
|
1812
2323
|
type: Object
|
|
@@ -1814,62 +2325,35 @@ var proTableProps = function proTableProps() {
|
|
|
1814
2325
|
};
|
|
1815
2326
|
};
|
|
1816
2327
|
|
|
1817
|
-
var
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1823
|
-
return item.dataIndex;
|
|
1824
|
-
}); //根据valueType选择对应的展示组件
|
|
1825
|
-
|
|
1826
|
-
var columns = lodash.map(mergeColumns, function (item) {
|
|
1827
|
-
//merge公共item
|
|
1828
|
-
var nextItem = _objectSpread2(_objectSpread2({}, props.column), item);
|
|
1829
|
-
|
|
1830
|
-
if (!item.customRender) {
|
|
1831
|
-
nextItem.customRender = function (_ref2) {
|
|
1832
|
-
var text = _ref2.text;
|
|
1833
|
-
var vn = getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
|
|
1834
|
-
showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
|
|
1835
|
-
content: props.columnEmptyText
|
|
1836
|
-
})
|
|
1837
|
-
}), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
|
|
1838
|
-
|
|
1839
|
-
return vn || text || props.columnEmptyText;
|
|
1840
|
-
};
|
|
1841
|
-
}
|
|
1842
|
-
|
|
1843
|
-
return nextItem;
|
|
1844
|
-
}); //处理序号
|
|
2328
|
+
var createTable = function createTable(Table, Props) {
|
|
2329
|
+
return vue.defineComponent({
|
|
2330
|
+
props: _objectSpread2(_objectSpread2(_objectSpread2({}, Table.props), Props), proTableProps()),
|
|
2331
|
+
setup: function setup(props, _ref) {
|
|
2332
|
+
var slots = _ref.slots;
|
|
1845
2333
|
|
|
1846
|
-
|
|
1847
|
-
|
|
2334
|
+
var createNumberColumn = function createNumberColumn() {
|
|
2335
|
+
return _objectSpread2(_objectSpread2({
|
|
1848
2336
|
title: "序号",
|
|
1849
2337
|
dataIndex: "serialNumber",
|
|
1850
2338
|
width: 80
|
|
1851
2339
|
}, props.column), {}, {
|
|
1852
|
-
|
|
1853
|
-
|
|
1854
|
-
var _props$pagination, _props$pagination2;
|
|
2340
|
+
customRender: function customRender(_ref2) {
|
|
2341
|
+
var _props$paginationStat, _props$paginationStat2;
|
|
1855
2342
|
|
|
1856
|
-
var index =
|
|
2343
|
+
var index = _ref2.index;
|
|
1857
2344
|
|
|
1858
|
-
if ((_props$
|
|
1859
|
-
return props.
|
|
2345
|
+
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) {
|
|
2346
|
+
return props.paginationState.pageSize * (props.paginationState.page - 1) + index + 1;
|
|
1860
2347
|
}
|
|
1861
2348
|
|
|
1862
2349
|
return index + 1;
|
|
1863
2350
|
}
|
|
1864
|
-
})
|
|
1865
|
-
}
|
|
2351
|
+
});
|
|
2352
|
+
};
|
|
1866
2353
|
|
|
1867
|
-
var
|
|
2354
|
+
var createOperateColumn = function createOperateColumn() {
|
|
2355
|
+
var operate = props.operate; //将itemState补充的信息拼到item中
|
|
1868
2356
|
|
|
1869
|
-
if (operate && operate.items && lodash.some(operate.items, function (item) {
|
|
1870
|
-
return item.show;
|
|
1871
|
-
})) {
|
|
1872
|
-
//将itemState补充的信息拼到item中
|
|
1873
2357
|
var items = lodash.map(operate.items, function (i) {
|
|
1874
2358
|
return _objectSpread2(_objectSpread2({}, i), lodash.get(operate.itemState, i.value));
|
|
1875
2359
|
}); //排序
|
|
@@ -1877,14 +2361,14 @@ var ProTable = vue.defineComponent({
|
|
|
1877
2361
|
var sortedItems = lodash.sortBy(items, function (item) {
|
|
1878
2362
|
return item.sort;
|
|
1879
2363
|
});
|
|
1880
|
-
|
|
2364
|
+
return _objectSpread2(_objectSpread2(_objectSpread2({}, props.column), {}, {
|
|
1881
2365
|
title: "操作",
|
|
1882
2366
|
dataIndex: "operate",
|
|
1883
2367
|
fixed: "right"
|
|
1884
|
-
},
|
|
1885
|
-
customRender: function customRender(
|
|
1886
|
-
var record =
|
|
1887
|
-
var
|
|
2368
|
+
}, operate.column), {}, {
|
|
2369
|
+
customRender: function customRender(_ref3) {
|
|
2370
|
+
var record = _ref3.record;
|
|
2371
|
+
var showItems = lodash.filter(sortedItems, function (item) {
|
|
1888
2372
|
if (item.show && lodash.isFunction(item.show)) {
|
|
1889
2373
|
return item.show(record);
|
|
1890
2374
|
}
|
|
@@ -1897,7 +2381,7 @@ var ProTable = vue.defineComponent({
|
|
|
1897
2381
|
});
|
|
1898
2382
|
return vue.createVNode("div", {
|
|
1899
2383
|
"class": "pro-table-operate"
|
|
1900
|
-
}, [lodash.map(
|
|
2384
|
+
}, [lodash.map(showItems, function (item) {
|
|
1901
2385
|
//自定义
|
|
1902
2386
|
if (lodash.isFunction(item.element)) {
|
|
1903
2387
|
return item.element(record, item);
|
|
@@ -1914,34 +2398,83 @@ var ProTable = vue.defineComponent({
|
|
|
1914
2398
|
}, [item.label]);
|
|
1915
2399
|
})]);
|
|
1916
2400
|
}
|
|
1917
|
-
}
|
|
1918
|
-
}
|
|
2401
|
+
});
|
|
2402
|
+
};
|
|
1919
2403
|
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
|
|
1925
|
-
|
|
1926
|
-
|
|
2404
|
+
var columns = vue.computed(function () {
|
|
2405
|
+
var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
|
|
2406
|
+
return item.dataIndex;
|
|
2407
|
+
}); //根据valueType选择对应的展示组件
|
|
2408
|
+
|
|
2409
|
+
var columns = lodash.map(mergeColumns, function (item) {
|
|
2410
|
+
//merge公共item
|
|
2411
|
+
var nextItem = _objectSpread2(_objectSpread2({}, props.column), item);
|
|
2412
|
+
|
|
2413
|
+
if (!item.customRender) {
|
|
2414
|
+
nextItem.customRender = function (_ref4) {
|
|
2415
|
+
var text = _ref4.text;
|
|
2416
|
+
var vn = getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
|
|
2417
|
+
showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
|
|
2418
|
+
content: props.columnEmptyText
|
|
2419
|
+
})
|
|
2420
|
+
}), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
|
|
2421
|
+
|
|
2422
|
+
return vn || text || props.columnEmptyText;
|
|
2423
|
+
};
|
|
2424
|
+
}
|
|
1927
2425
|
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
2426
|
+
return nextItem;
|
|
2427
|
+
}); //处理序号
|
|
2428
|
+
|
|
2429
|
+
if (props.serialNumber) {
|
|
2430
|
+
columns.unshift(createNumberColumn());
|
|
2431
|
+
} //处理operate
|
|
2432
|
+
|
|
2433
|
+
|
|
2434
|
+
if (props.operate && props.operate.items && lodash.some(props.operate.items, function (item) {
|
|
2435
|
+
return item.show;
|
|
2436
|
+
})) {
|
|
2437
|
+
columns.push(createOperateColumn());
|
|
2438
|
+
}
|
|
2439
|
+
|
|
2440
|
+
return columns;
|
|
2441
|
+
});
|
|
2442
|
+
var tableRef = vue.ref();
|
|
2443
|
+
provideProTable(_objectSpread2({
|
|
2444
|
+
columns: columns,
|
|
2445
|
+
tableRef: tableRef
|
|
2446
|
+
}, props.provideExtra));
|
|
2447
|
+
var invalidKeys = lodash.keys(proTableProps());
|
|
2448
|
+
return function () {
|
|
2449
|
+
return vue.createVNode(Table, vue.mergeProps({
|
|
2450
|
+
"ref": tableRef
|
|
2451
|
+
}, lodash.omit(props, invalidKeys), {
|
|
2452
|
+
"columns": columns.value
|
|
2453
|
+
}), slots);
|
|
2454
|
+
};
|
|
2455
|
+
}
|
|
2456
|
+
});
|
|
2457
|
+
};
|
|
1932
2458
|
|
|
1933
2459
|
exports.ProCurd = ProCurd;
|
|
1934
|
-
exports.ProForm = ProForm;
|
|
1935
|
-
exports.ProFormList = ProFormList;
|
|
1936
2460
|
exports.ProModalCurd = ProModalCurd;
|
|
1937
2461
|
exports.ProModule = ProModule;
|
|
1938
2462
|
exports.ProPageCurd = ProPageCurd;
|
|
1939
|
-
exports.ProSearchForm = ProSearchForm;
|
|
1940
|
-
exports.ProTable = ProTable;
|
|
1941
2463
|
exports.RequestAction = RequestAction;
|
|
1942
2464
|
exports.convertPathToList = convertPathToList;
|
|
2465
|
+
exports.createCurdDesc = createCurdDesc;
|
|
2466
|
+
exports.createCurdForm = createCurdForm;
|
|
2467
|
+
exports.createCurdList = createCurdList;
|
|
2468
|
+
exports.createExpose = createExpose;
|
|
2469
|
+
exports.createForm = createForm;
|
|
1943
2470
|
exports.createFormItemCompFn = createFormItemCompFn;
|
|
2471
|
+
exports.createFormList = createFormList;
|
|
2472
|
+
exports.createGrid = createGrid;
|
|
2473
|
+
exports.createSearchForm = createSearchForm;
|
|
2474
|
+
exports.createTable = createTable;
|
|
1944
2475
|
exports.defaultPage = defaultPage;
|
|
2476
|
+
exports.findTargetInTree = findTargetInTree;
|
|
2477
|
+
exports.findTargetListInTree = findTargetListInTree;
|
|
1945
2478
|
exports.generateId = generateId;
|
|
1946
2479
|
exports.getColumnFormItemName = getColumnFormItemName;
|
|
1947
2480
|
exports.getColumnValueType = getColumnValueType;
|