@vue-start/pro 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/index.d.ts +113 -6
- package/dist/index.es.js +586 -131
- package/dist/index.js +588 -128
- package/package.json +10 -2
package/dist/index.es.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { defineComponent, computed, reactive, inject, h, provide,
|
|
2
|
-
import { map, isString, forEach,
|
|
1
|
+
import { defineComponent, computed, reactive, inject, h, provide, ref, createVNode, mergeProps, Fragment } from 'vue';
|
|
2
|
+
import { map, isString, forEach, filter as filter$1, keys, omit, isArray, split, isFunction, get, isEmpty, isObject, mergeWith, reduce, sortBy, pick, debounce, size, some, clone, set, isBoolean, merge as merge$1 } from 'lodash';
|
|
3
3
|
import { filter, tap, merge, Subject } from 'rxjs';
|
|
4
4
|
import { useEffect, setReactiveValue, useWatch } from '@vue-start/hooks';
|
|
5
5
|
import { useRequestProvide, isFailedRequestActor, isPreRequestActor, isDoneRequestActor } from '@vue-start/request';
|
|
6
|
+
import { useRouter, useRoute } from 'vue-router';
|
|
6
7
|
|
|
7
8
|
function ownKeys(object, enumerableOnly) {
|
|
8
9
|
var keys = Object.keys(object);
|
|
@@ -150,17 +151,100 @@ var useComposeRequestActor = function useComposeRequestActor(actors, options, ca
|
|
|
150
151
|
}, []);
|
|
151
152
|
};
|
|
152
153
|
|
|
153
|
-
/**
|
|
154
|
-
*
|
|
155
|
-
* @param
|
|
154
|
+
/**
|
|
155
|
+
* 剔除showState或showStateRules规则为!true的值
|
|
156
|
+
* @param values
|
|
157
|
+
* @param showState
|
|
158
|
+
* @param showStateRules
|
|
159
|
+
*/
|
|
160
|
+
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
161
|
+
if (showState) {
|
|
162
|
+
var invalidKeys = filter$1(keys(showState), function (key) {
|
|
163
|
+
return !showState[key];
|
|
164
|
+
});
|
|
165
|
+
return omit(values, invalidKeys);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
if (showStateRules) {
|
|
169
|
+
var _invalidKeys = filter$1(keys(showStateRules), function (key) {
|
|
170
|
+
return !showStateRules[key](values);
|
|
171
|
+
});
|
|
172
|
+
|
|
173
|
+
return omit(values, _invalidKeys);
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
return values;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* string类型的path转为arr
|
|
180
|
+
* @param path
|
|
181
|
+
*/
|
|
182
|
+
|
|
183
|
+
var convertPathToList = function convertPathToList(path) {
|
|
184
|
+
if (!path) {
|
|
185
|
+
return undefined;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
if (isArray(path)) {
|
|
189
|
+
return path;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
if (path && isString(path) && path.indexOf(".") > 0) {
|
|
193
|
+
return split(path, ".");
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
return [path];
|
|
197
|
+
};
|
|
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
|
+
/**
|
|
206
|
+
* 将listState 中的数据通过id merge到 list item中
|
|
207
|
+
* ps:数组会替换
|
|
208
|
+
* @param list
|
|
209
|
+
* @param listState
|
|
210
|
+
* @param id
|
|
211
|
+
*/
|
|
212
|
+
|
|
213
|
+
var mergeStateToList = function mergeStateToList(list, listState, id) {
|
|
214
|
+
if (!listState || !id) {
|
|
215
|
+
return list;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return map(list, function (item) {
|
|
219
|
+
var idName = isFunction(id) ? id(item) : id; //如果listState中有值,merge处理
|
|
220
|
+
|
|
221
|
+
var stateData = get(listState, idName);
|
|
222
|
+
|
|
223
|
+
if (!stateData || isEmpty(stateData) || isFunction(stateData) || !isObject(stateData)) {
|
|
224
|
+
return item;
|
|
225
|
+
} //只有是对象(键值对)才合并
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
return mergeWith(item, stateData, function (objValue, srcValue) {
|
|
229
|
+
//如果是数组,替换
|
|
230
|
+
if (isArray(objValue) || isArray(srcValue)) {
|
|
231
|
+
return srcValue;
|
|
232
|
+
}
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
};
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* 获取Column的valueType,默认"text"
|
|
239
|
+
* @param column
|
|
156
240
|
*/
|
|
157
241
|
|
|
158
242
|
var getColumnValueType = function getColumnValueType(column) {
|
|
159
243
|
return column.formValueType || column.valueType || "text";
|
|
160
244
|
};
|
|
161
|
-
/**
|
|
162
|
-
*获取Column的FormItem name
|
|
163
|
-
* @param column
|
|
245
|
+
/**
|
|
246
|
+
*获取Column的FormItem name
|
|
247
|
+
* @param column
|
|
164
248
|
*/
|
|
165
249
|
|
|
166
250
|
var getColumnFormItemName = function getColumnFormItemName(column) {
|
|
@@ -168,12 +252,12 @@ var getColumnFormItemName = function getColumnFormItemName(column) {
|
|
|
168
252
|
|
|
169
253
|
return ((_column$formItemProps = column.formItemProps) === null || _column$formItemProps === void 0 ? void 0 : _column$formItemProps.name) || column.dataIndex;
|
|
170
254
|
};
|
|
171
|
-
/**
|
|
172
|
-
* 根据Column生成FormItem VNode
|
|
173
|
-
* formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
|
|
174
|
-
* @param formElementMap
|
|
175
|
-
* @param column
|
|
176
|
-
* @param needRules
|
|
255
|
+
/**
|
|
256
|
+
* 根据Column生成FormItem VNode
|
|
257
|
+
* formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
|
|
258
|
+
* @param formElementMap
|
|
259
|
+
* @param column
|
|
260
|
+
* @param needRules
|
|
177
261
|
*/
|
|
178
262
|
|
|
179
263
|
var getFormItemEl = function getFormItemEl(formElementMap, column) {
|
|
@@ -198,11 +282,11 @@ var getFormItemEl = function getFormItemEl(formElementMap, column) {
|
|
|
198
282
|
showProps: column.showProps
|
|
199
283
|
}), (_column$formFieldProp = column.formFieldProps) === null || _column$formFieldProp === void 0 ? void 0 : _column$formFieldProp.slots);
|
|
200
284
|
};
|
|
201
|
-
/**
|
|
202
|
-
* 根据Column生成Item VNode
|
|
203
|
-
* @param elementMap
|
|
204
|
-
* @param column
|
|
205
|
-
* @param value
|
|
285
|
+
/**
|
|
286
|
+
* 根据Column生成Item VNode
|
|
287
|
+
* @param elementMap
|
|
288
|
+
* @param column
|
|
289
|
+
* @param value
|
|
206
290
|
*/
|
|
207
291
|
|
|
208
292
|
var getItemEl = function getItemEl(elementMap, column, value) {
|
|
@@ -234,44 +318,44 @@ var RequestAction = {
|
|
|
234
318
|
|
|
235
319
|
var proModuleProps = function proModuleProps() {
|
|
236
320
|
return {
|
|
237
|
-
/**
|
|
238
|
-
* module状态
|
|
321
|
+
/**
|
|
322
|
+
* module状态
|
|
239
323
|
*/
|
|
240
324
|
state: {
|
|
241
325
|
type: Object
|
|
242
326
|
},
|
|
243
327
|
|
|
244
|
-
/**
|
|
245
|
-
* 配置(静态)
|
|
328
|
+
/**
|
|
329
|
+
* 配置(静态)
|
|
246
330
|
*/
|
|
247
331
|
columns: {
|
|
248
332
|
type: Array
|
|
249
333
|
},
|
|
250
334
|
|
|
251
|
-
/**
|
|
252
|
-
* 配置(动态)
|
|
253
|
-
* columns动态属性兼容
|
|
335
|
+
/**
|
|
336
|
+
* 配置(动态)
|
|
337
|
+
* columns动态属性兼容
|
|
254
338
|
*/
|
|
255
339
|
columnState: {
|
|
256
340
|
type: Object
|
|
257
341
|
},
|
|
258
342
|
|
|
259
|
-
/**
|
|
260
|
-
* 展示组件集
|
|
343
|
+
/**
|
|
344
|
+
* 展示组件集
|
|
261
345
|
*/
|
|
262
346
|
elementMap: {
|
|
263
347
|
type: Object
|
|
264
348
|
},
|
|
265
349
|
|
|
266
|
-
/**
|
|
267
|
-
* 录入组件集
|
|
350
|
+
/**
|
|
351
|
+
* 录入组件集
|
|
268
352
|
*/
|
|
269
353
|
formElementMap: {
|
|
270
354
|
type: Object
|
|
271
355
|
},
|
|
272
356
|
|
|
273
|
-
/**
|
|
274
|
-
* requests
|
|
357
|
+
/**
|
|
358
|
+
* requests
|
|
275
359
|
*/
|
|
276
360
|
requests: {
|
|
277
361
|
type: Array
|
|
@@ -282,27 +366,15 @@ var proModuleProps = function proModuleProps() {
|
|
|
282
366
|
var ProModule = defineComponent({
|
|
283
367
|
props: _objectSpread2({}, proModuleProps()),
|
|
284
368
|
setup: function setup(props, _ref) {
|
|
285
|
-
var slots = _ref.slots
|
|
369
|
+
var slots = _ref.slots,
|
|
370
|
+
expose = _ref.expose;
|
|
286
371
|
|
|
287
|
-
/**
|
|
288
|
-
* columns columnState 合并
|
|
372
|
+
/**
|
|
373
|
+
* columns columnState 合并
|
|
289
374
|
*/
|
|
290
375
|
var columns = computed(function () {
|
|
291
|
-
return
|
|
292
|
-
|
|
293
|
-
var mapData = get(props.columnState, getColumnFormItemName(item));
|
|
294
|
-
|
|
295
|
-
if (isObject(mapData) && !isEmpty(mapData) && !isArray(mapData) && !isFunction(mapData)) {
|
|
296
|
-
//合并
|
|
297
|
-
return mergeWith(item, mapData, function (objValue, srcValue) {
|
|
298
|
-
//如果是数组,替换
|
|
299
|
-
if (isArray(objValue) || isArray(srcValue)) {
|
|
300
|
-
return srcValue;
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
return item;
|
|
376
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
377
|
+
return getColumnFormItemName(item);
|
|
306
378
|
});
|
|
307
379
|
});
|
|
308
380
|
/*********************************** 渲染组件 ***************************************/
|
|
@@ -456,6 +528,10 @@ var ProModule = defineComponent({
|
|
|
456
528
|
requests: props.requests,
|
|
457
529
|
sendRequest: sendRequest
|
|
458
530
|
});
|
|
531
|
+
expose({
|
|
532
|
+
sendEvent: sendEvent,
|
|
533
|
+
sendRequest: sendRequest
|
|
534
|
+
});
|
|
459
535
|
return function () {
|
|
460
536
|
var _slots$default;
|
|
461
537
|
|
|
@@ -538,6 +614,11 @@ var CurdAddAction;
|
|
|
538
614
|
CurdAddAction["CONTINUE"] = "CONTINUE";
|
|
539
615
|
})(CurdAddAction || (CurdAddAction = {}));
|
|
540
616
|
|
|
617
|
+
var defaultPage = {
|
|
618
|
+
page: 1,
|
|
619
|
+
pageSize: 10
|
|
620
|
+
};
|
|
621
|
+
|
|
541
622
|
var proCurdProps = function proCurdProps() {
|
|
542
623
|
return {
|
|
543
624
|
/**
|
|
@@ -574,7 +655,8 @@ var proCurdProps = function proCurdProps() {
|
|
|
574
655
|
var Curd = defineComponent({
|
|
575
656
|
props: _objectSpread2({}, proCurdProps()),
|
|
576
657
|
setup: function setup(props, _ref) {
|
|
577
|
-
var slots = _ref.slots
|
|
658
|
+
var slots = _ref.slots,
|
|
659
|
+
expose = _ref.expose;
|
|
578
660
|
|
|
579
661
|
var _ref2 = useProModule(),
|
|
580
662
|
columns = _ref2.columns,
|
|
@@ -643,12 +725,18 @@ var Curd = defineComponent({
|
|
|
643
725
|
var sendCurdEvent = function sendCurdEvent(event) {
|
|
644
726
|
sendEvent({
|
|
645
727
|
type: event.action,
|
|
646
|
-
payload: omit(event, "action")
|
|
728
|
+
payload: omit(event, "action", "source"),
|
|
729
|
+
source: event.source
|
|
647
730
|
});
|
|
648
731
|
}; //事件订阅
|
|
649
732
|
|
|
650
733
|
|
|
651
734
|
useModuleEvent(function (event) {
|
|
735
|
+
//如果当前event存在source 不处理
|
|
736
|
+
if (event.source) {
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
739
|
+
|
|
652
740
|
var action = event.type;
|
|
653
741
|
var _ref3 = event.payload,
|
|
654
742
|
type = _ref3.type,
|
|
@@ -725,6 +813,11 @@ var Curd = defineComponent({
|
|
|
725
813
|
descProps: descProps,
|
|
726
814
|
modalProps: modalProps
|
|
727
815
|
});
|
|
816
|
+
expose({
|
|
817
|
+
sendCurdEvent: sendCurdEvent,
|
|
818
|
+
getOperate: getOperate,
|
|
819
|
+
refreshList: handleSearch
|
|
820
|
+
});
|
|
728
821
|
return function () {
|
|
729
822
|
var _slots$default;
|
|
730
823
|
|
|
@@ -741,7 +834,10 @@ var ProCurd = defineComponent({
|
|
|
741
834
|
setup: function setup(props, _ref4) {
|
|
742
835
|
var _curdOperateOpts;
|
|
743
836
|
|
|
744
|
-
var slots = _ref4.slots
|
|
837
|
+
var slots = _ref4.slots,
|
|
838
|
+
expose = _ref4.expose;
|
|
839
|
+
var moduleRef = ref();
|
|
840
|
+
var curdRef = ref();
|
|
745
841
|
var curdState = props.curdState || reactive({
|
|
746
842
|
detailData: {}
|
|
747
843
|
});
|
|
@@ -793,18 +889,383 @@ var ProCurd = defineComponent({
|
|
|
793
889
|
},
|
|
794
890
|
label: "删除"
|
|
795
891
|
}), _curdOperateOpts);
|
|
892
|
+
/****************************** columns分类 *************************************/
|
|
893
|
+
|
|
796
894
|
var requests = map(props.operates, function (item) {
|
|
797
895
|
var curdOpts = get(curdOperateOpts, item.action);
|
|
798
896
|
return _objectSpread2(_objectSpread2({}, curdOpts), item);
|
|
799
897
|
});
|
|
800
898
|
var moduleKeys = keys(omit(ProModule.props, "state", "requests"));
|
|
899
|
+
expose({
|
|
900
|
+
moduleRef: moduleRef,
|
|
901
|
+
curdRef: curdRef
|
|
902
|
+
});
|
|
903
|
+
return function () {
|
|
904
|
+
return createVNode(ProModule, mergeProps({
|
|
905
|
+
"ref": moduleRef
|
|
906
|
+
}, pick(props, moduleKeys), {
|
|
907
|
+
"state": curdState,
|
|
908
|
+
"requests": requests
|
|
909
|
+
}), {
|
|
910
|
+
"default": function _default() {
|
|
911
|
+
return [createVNode(Curd, mergeProps({
|
|
912
|
+
"ref": curdRef
|
|
913
|
+
}, omit.apply(void 0, [props].concat(_toConsumableArray(moduleKeys), ["curdState", "operates"])), {
|
|
914
|
+
"operates": requests
|
|
915
|
+
}), slots)];
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
};
|
|
919
|
+
}
|
|
920
|
+
});
|
|
921
|
+
|
|
922
|
+
var modalCurdProps = function modalCurdProps() {
|
|
923
|
+
return {
|
|
924
|
+
defaultAddRecord: {
|
|
925
|
+
type: Object
|
|
926
|
+
}
|
|
927
|
+
};
|
|
928
|
+
};
|
|
929
|
+
|
|
930
|
+
/**
|
|
931
|
+
* 事件处理
|
|
932
|
+
*/
|
|
933
|
+
var ModalCurd = defineComponent({
|
|
934
|
+
props: _objectSpread2({}, modalCurdProps()),
|
|
935
|
+
setup: function setup(props) {
|
|
936
|
+
var _listProps$value;
|
|
937
|
+
|
|
938
|
+
var _useProModule = useProModule(),
|
|
939
|
+
dispatch = _useProModule.dispatch,
|
|
940
|
+
sendRequest = _useProModule.sendRequest;
|
|
941
|
+
|
|
942
|
+
var _useProCurd = useProCurd(),
|
|
943
|
+
rowKey = _useProCurd.rowKey,
|
|
944
|
+
curdState = _useProCurd.curdState,
|
|
945
|
+
listProps = _useProCurd.listProps,
|
|
946
|
+
getOperate = _useProCurd.getOperate,
|
|
947
|
+
refreshList = _useProCurd.refreshList;
|
|
948
|
+
|
|
949
|
+
var pageState = (listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState) || reactive(_objectSpread2({}, defaultPage)); //发送详情接口
|
|
950
|
+
|
|
951
|
+
var sendDetailRequest = function sendDetailRequest(record) {
|
|
952
|
+
var operateOpts = getOperate(CurdAction.DETAIL);
|
|
953
|
+
|
|
954
|
+
if (operateOpts !== null && operateOpts !== void 0 && operateOpts.actor) {
|
|
955
|
+
//如果注册了详情接口 发起请求
|
|
956
|
+
sendRequest(CurdAction.DETAIL, record, rowKey);
|
|
957
|
+
} else {
|
|
958
|
+
//直接使用当前record作为详情数据
|
|
959
|
+
dispatch({
|
|
960
|
+
type: "detailData",
|
|
961
|
+
payload: record
|
|
962
|
+
});
|
|
963
|
+
}
|
|
964
|
+
};
|
|
965
|
+
|
|
966
|
+
var dealDetail = function dealDetail(subAction, _ref) {
|
|
967
|
+
var record = _ref.record;
|
|
968
|
+
|
|
969
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
970
|
+
dispatch({
|
|
971
|
+
type: "mode",
|
|
972
|
+
payload: CurdCurrentMode.DETAIL
|
|
973
|
+
});
|
|
974
|
+
sendDetailRequest(record);
|
|
975
|
+
}
|
|
976
|
+
};
|
|
977
|
+
|
|
978
|
+
var dealAdd = function dealAdd(subAction) {
|
|
979
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
980
|
+
dispatch({
|
|
981
|
+
type: "mode",
|
|
982
|
+
payload: CurdCurrentMode.ADD
|
|
983
|
+
});
|
|
984
|
+
dispatch({
|
|
985
|
+
type: "detailData",
|
|
986
|
+
payload: props.defaultAddRecord || {}
|
|
987
|
+
});
|
|
988
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
989
|
+
//添加成功
|
|
990
|
+
pageState.page = 1; //重置当前页数
|
|
991
|
+
//刷新List
|
|
992
|
+
|
|
993
|
+
refreshList({
|
|
994
|
+
page: 1
|
|
995
|
+
});
|
|
996
|
+
|
|
997
|
+
if (curdState.addAction === CurdAddAction.CONTINUE) {
|
|
998
|
+
dispatch({
|
|
999
|
+
type: "detailData",
|
|
1000
|
+
payload: props.defaultAddRecord || {}
|
|
1001
|
+
});
|
|
1002
|
+
} else {
|
|
1003
|
+
dispatch({
|
|
1004
|
+
type: "mode",
|
|
1005
|
+
payload: undefined
|
|
1006
|
+
});
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
};
|
|
1010
|
+
|
|
1011
|
+
var dealEdit = function dealEdit(subAction, _ref2) {
|
|
1012
|
+
var record = _ref2.record;
|
|
1013
|
+
|
|
1014
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1015
|
+
dispatch({
|
|
1016
|
+
type: "mode",
|
|
1017
|
+
payload: CurdCurrentMode.EDIT
|
|
1018
|
+
});
|
|
1019
|
+
sendDetailRequest(record);
|
|
1020
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1021
|
+
// 编辑成功
|
|
1022
|
+
dispatch({
|
|
1023
|
+
type: "mode",
|
|
1024
|
+
payload: undefined
|
|
1025
|
+
}); //刷新列表
|
|
1026
|
+
|
|
1027
|
+
refreshList();
|
|
1028
|
+
}
|
|
1029
|
+
};
|
|
1030
|
+
|
|
1031
|
+
var dealDelete = function dealDelete(subAction) {
|
|
1032
|
+
if (subAction === CurdSubAction.SUCCESS) {
|
|
1033
|
+
//刷新列表
|
|
1034
|
+
refreshList();
|
|
1035
|
+
}
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
useModuleEvent(function (_ref3) {
|
|
1039
|
+
var type = _ref3.type,
|
|
1040
|
+
payload = _ref3.payload,
|
|
1041
|
+
source = _ref3.source;
|
|
1042
|
+
|
|
1043
|
+
if (source) {
|
|
1044
|
+
return;
|
|
1045
|
+
}
|
|
1046
|
+
|
|
1047
|
+
var action = type;
|
|
1048
|
+
var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
|
|
1049
|
+
var record = payload === null || payload === void 0 ? void 0 : payload.record;
|
|
1050
|
+
|
|
1051
|
+
if (action === RequestAction.Success) {
|
|
1052
|
+
//覆盖
|
|
1053
|
+
action = get(payload, ["requestOpts", "action"]);
|
|
1054
|
+
subAction = CurdSubAction.SUCCESS;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
switch (action) {
|
|
1058
|
+
case CurdAction.DETAIL:
|
|
1059
|
+
dealDetail(subAction, {
|
|
1060
|
+
record: record
|
|
1061
|
+
});
|
|
1062
|
+
break;
|
|
1063
|
+
|
|
1064
|
+
case CurdAction.ADD:
|
|
1065
|
+
dealAdd(subAction);
|
|
1066
|
+
break;
|
|
1067
|
+
|
|
1068
|
+
case CurdAction.EDIT:
|
|
1069
|
+
dealEdit(subAction, {
|
|
1070
|
+
record: record
|
|
1071
|
+
});
|
|
1072
|
+
break;
|
|
1073
|
+
|
|
1074
|
+
case CurdAction.DELETE:
|
|
1075
|
+
dealDelete(subAction);
|
|
1076
|
+
break;
|
|
1077
|
+
}
|
|
1078
|
+
});
|
|
1079
|
+
return function () {
|
|
1080
|
+
return null;
|
|
1081
|
+
};
|
|
1082
|
+
}
|
|
1083
|
+
});
|
|
1084
|
+
var ProModalCurd = defineComponent({
|
|
1085
|
+
props: _objectSpread2(_objectSpread2({}, ProCurd.props), ModalCurd.props),
|
|
1086
|
+
setup: function setup(props, _ref4) {
|
|
1087
|
+
var slots = _ref4.slots;
|
|
1088
|
+
var invalidKeys = keys(ModalCurd.props);
|
|
801
1089
|
return function () {
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
1090
|
+
var _slots$default;
|
|
1091
|
+
|
|
1092
|
+
return createVNode(ProCurd, omit(props, invalidKeys), {
|
|
1093
|
+
"default": function _default() {
|
|
1094
|
+
return [createVNode(ModalCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1095
|
+
}
|
|
1096
|
+
});
|
|
1097
|
+
};
|
|
1098
|
+
}
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
var pageCurdProps = function pageCurdProps() {
|
|
1102
|
+
return {
|
|
1103
|
+
defaultAddRecord: {
|
|
1104
|
+
type: Object
|
|
1105
|
+
},
|
|
1106
|
+
routeBack: {
|
|
1107
|
+
type: Function
|
|
1108
|
+
}
|
|
1109
|
+
};
|
|
1110
|
+
};
|
|
1111
|
+
|
|
1112
|
+
var PageCurd = defineComponent({
|
|
1113
|
+
props: _objectSpread2({}, pageCurdProps()),
|
|
1114
|
+
setup: function setup(props) {
|
|
1115
|
+
var router = useRouter();
|
|
1116
|
+
var route = useRoute();
|
|
1117
|
+
|
|
1118
|
+
var _useProModule = useProModule(),
|
|
1119
|
+
dispatch = _useProModule.dispatch,
|
|
1120
|
+
sendRequest = _useProModule.sendRequest;
|
|
1121
|
+
|
|
1122
|
+
var _useProCurd = useProCurd(),
|
|
1123
|
+
rowKey = _useProCurd.rowKey,
|
|
1124
|
+
curdState = _useProCurd.curdState;
|
|
1125
|
+
|
|
1126
|
+
var dealList = function dealList(subAction) {
|
|
1127
|
+
if (subAction === CurdSubAction.PAGE) {
|
|
1128
|
+
//其实就是个重置过程
|
|
1129
|
+
dispatch({
|
|
1130
|
+
type: "mode",
|
|
1131
|
+
payload: undefined
|
|
1132
|
+
});
|
|
1133
|
+
dispatch({
|
|
1134
|
+
type: "detailData",
|
|
1135
|
+
payload: {}
|
|
1136
|
+
});
|
|
1137
|
+
dispatch({
|
|
1138
|
+
type: "detailLoading",
|
|
1139
|
+
payload: false
|
|
1140
|
+
});
|
|
1141
|
+
dispatch({
|
|
1142
|
+
type: "addAction",
|
|
1143
|
+
payload: undefined
|
|
1144
|
+
});
|
|
1145
|
+
}
|
|
1146
|
+
};
|
|
1147
|
+
|
|
1148
|
+
var dealDetail = function dealDetail(subAction, _ref) {
|
|
1149
|
+
var record = _ref.record;
|
|
1150
|
+
|
|
1151
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1152
|
+
router.push({
|
|
1153
|
+
path: "".concat(route.path, "/detail"),
|
|
1154
|
+
query: pick(record, rowKey)
|
|
1155
|
+
});
|
|
1156
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1157
|
+
dispatch({
|
|
1158
|
+
type: "mode",
|
|
1159
|
+
payload: CurdCurrentMode.DETAIL
|
|
1160
|
+
});
|
|
1161
|
+
sendRequest(CurdAction.DETAIL, route.query, rowKey);
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
|
|
1165
|
+
var dealAdd = function dealAdd(subAction) {
|
|
1166
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1167
|
+
router.push({
|
|
1168
|
+
path: "".concat(route.path, "/add")
|
|
1169
|
+
});
|
|
1170
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1171
|
+
dispatch({
|
|
1172
|
+
type: "mode",
|
|
1173
|
+
payload: CurdCurrentMode.ADD
|
|
1174
|
+
});
|
|
1175
|
+
dispatch({
|
|
1176
|
+
type: "detailData",
|
|
1177
|
+
payload: props.defaultAddRecord || {}
|
|
1178
|
+
});
|
|
1179
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1180
|
+
if (curdState.addAction === CurdAddAction.CONTINUE) {
|
|
1181
|
+
dispatch({
|
|
1182
|
+
type: "detailData",
|
|
1183
|
+
payload: props.defaultAddRecord || {}
|
|
1184
|
+
});
|
|
1185
|
+
} else {
|
|
1186
|
+
props.routeBack ? props.routeBack(CurdAction.ADD) : router.go(-1);
|
|
1187
|
+
}
|
|
1188
|
+
}
|
|
1189
|
+
};
|
|
1190
|
+
|
|
1191
|
+
var dealEdit = function dealEdit(subAction, _ref2) {
|
|
1192
|
+
var record = _ref2.record;
|
|
1193
|
+
|
|
1194
|
+
if (subAction === CurdSubAction.EMIT) {
|
|
1195
|
+
router.push({
|
|
1196
|
+
path: "".concat(route.path, "/edit"),
|
|
1197
|
+
query: pick(record, rowKey)
|
|
1198
|
+
});
|
|
1199
|
+
} else if (subAction === CurdSubAction.PAGE) {
|
|
1200
|
+
dispatch({
|
|
1201
|
+
type: "mode",
|
|
1202
|
+
payload: CurdCurrentMode.EDIT
|
|
1203
|
+
});
|
|
1204
|
+
sendRequest(CurdAction.DETAIL, route.query, rowKey);
|
|
1205
|
+
} else if (subAction === CurdSubAction.SUCCESS) {
|
|
1206
|
+
props.routeBack ? props.routeBack(CurdAction.EDIT) : router.go(-1);
|
|
1207
|
+
}
|
|
1208
|
+
};
|
|
1209
|
+
|
|
1210
|
+
useModuleEvent(function (_ref3) {
|
|
1211
|
+
var type = _ref3.type,
|
|
1212
|
+
payload = _ref3.payload,
|
|
1213
|
+
source = _ref3.source;
|
|
1214
|
+
|
|
1215
|
+
if (source) {
|
|
1216
|
+
return;
|
|
1217
|
+
}
|
|
1218
|
+
|
|
1219
|
+
var action = type;
|
|
1220
|
+
var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
|
|
1221
|
+
var record = payload === null || payload === void 0 ? void 0 : payload.record;
|
|
1222
|
+
|
|
1223
|
+
if (action === RequestAction.Success) {
|
|
1224
|
+
//覆盖
|
|
1225
|
+
action = get(payload, ["requestOpts", "action"]);
|
|
1226
|
+
subAction = CurdSubAction.SUCCESS;
|
|
1227
|
+
}
|
|
1228
|
+
|
|
1229
|
+
switch (action) {
|
|
1230
|
+
case CurdAction.LIST:
|
|
1231
|
+
dealList(subAction);
|
|
1232
|
+
break;
|
|
1233
|
+
|
|
1234
|
+
case CurdAction.DETAIL:
|
|
1235
|
+
dealDetail(subAction, {
|
|
1236
|
+
record: record
|
|
1237
|
+
});
|
|
1238
|
+
break;
|
|
1239
|
+
|
|
1240
|
+
case CurdAction.ADD:
|
|
1241
|
+
dealAdd(subAction);
|
|
1242
|
+
break;
|
|
1243
|
+
|
|
1244
|
+
case CurdAction.EDIT:
|
|
1245
|
+
dealEdit(subAction, {
|
|
1246
|
+
record: record
|
|
1247
|
+
});
|
|
1248
|
+
break;
|
|
1249
|
+
}
|
|
1250
|
+
});
|
|
1251
|
+
return function () {
|
|
1252
|
+
return null;
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
});
|
|
1256
|
+
var ProPageCurd = defineComponent({
|
|
1257
|
+
props: _objectSpread2(_objectSpread2({}, ProCurd.props), PageCurd.props),
|
|
1258
|
+
setup: function setup(props, _ref4) {
|
|
1259
|
+
var slots = _ref4.slots;
|
|
1260
|
+
var invalidKeys = keys(PageCurd.props);
|
|
1261
|
+
return function () {
|
|
1262
|
+
var _slots$default;
|
|
1263
|
+
|
|
1264
|
+
return createVNode(ProCurd, omit(props, invalidKeys), {
|
|
1265
|
+
"default": function _default() {
|
|
1266
|
+
return [createVNode(PageCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
|
|
1267
|
+
}
|
|
1268
|
+
});
|
|
808
1269
|
};
|
|
809
1270
|
}
|
|
810
1271
|
});
|
|
@@ -872,6 +1333,9 @@ var proFormProps = function proFormProps() {
|
|
|
872
1333
|
columns: {
|
|
873
1334
|
type: Array
|
|
874
1335
|
},
|
|
1336
|
+
columnState: {
|
|
1337
|
+
type: Object
|
|
1338
|
+
},
|
|
875
1339
|
|
|
876
1340
|
/**
|
|
877
1341
|
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
@@ -937,17 +1401,9 @@ var ProForm = defineComponent({
|
|
|
937
1401
|
var readonly = computed(function () {
|
|
938
1402
|
return props.readonly;
|
|
939
1403
|
});
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
var formItemVNodes = computed(function () {
|
|
945
|
-
if (size(props.formElementMap) <= 0) {
|
|
946
|
-
return [];
|
|
947
|
-
}
|
|
948
|
-
|
|
949
|
-
return map(props.columns, function (item) {
|
|
950
|
-
return getFormItemEl(props.formElementMap, item, props.needRules);
|
|
1404
|
+
var columns = computed(function () {
|
|
1405
|
+
return mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1406
|
+
return getColumnFormItemName(item);
|
|
951
1407
|
});
|
|
952
1408
|
});
|
|
953
1409
|
provideProForm(_objectSpread2({
|
|
@@ -957,14 +1413,16 @@ var ProForm = defineComponent({
|
|
|
957
1413
|
disableState: disableState,
|
|
958
1414
|
//
|
|
959
1415
|
elementMap: props.elementMap,
|
|
1416
|
+
formElementMap: props.formElementMap,
|
|
960
1417
|
//
|
|
961
1418
|
readonly: readonly,
|
|
962
1419
|
//
|
|
963
|
-
|
|
1420
|
+
columns: columns
|
|
964
1421
|
}, props.provideExtra));
|
|
965
1422
|
return function () {
|
|
966
1423
|
var _slots$default;
|
|
967
1424
|
|
|
1425
|
+
// console.log("########", columns.value, props.columns, props.columnState);
|
|
968
1426
|
return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
|
|
969
1427
|
};
|
|
970
1428
|
}
|
|
@@ -1085,51 +1543,6 @@ var ProSearchForm = defineComponent({
|
|
|
1085
1543
|
}
|
|
1086
1544
|
});
|
|
1087
1545
|
|
|
1088
|
-
/**
|
|
1089
|
-
* 剔除showState或showStateRules规则为!true的值
|
|
1090
|
-
* @param values
|
|
1091
|
-
* @param showState
|
|
1092
|
-
* @param showStateRules
|
|
1093
|
-
*/
|
|
1094
|
-
var getValidValues = function getValidValues(values, showState, showStateRules) {
|
|
1095
|
-
if (showState) {
|
|
1096
|
-
var invalidKeys = filter$1(keys(showState), function (key) {
|
|
1097
|
-
return !showState[key];
|
|
1098
|
-
});
|
|
1099
|
-
return omit(values, invalidKeys);
|
|
1100
|
-
}
|
|
1101
|
-
|
|
1102
|
-
if (showStateRules) {
|
|
1103
|
-
var _invalidKeys = filter$1(keys(showStateRules), function (key) {
|
|
1104
|
-
return !showStateRules[key](values);
|
|
1105
|
-
});
|
|
1106
|
-
|
|
1107
|
-
return omit(values, _invalidKeys);
|
|
1108
|
-
}
|
|
1109
|
-
|
|
1110
|
-
return values;
|
|
1111
|
-
};
|
|
1112
|
-
/**
|
|
1113
|
-
* string类型的path转为arr
|
|
1114
|
-
* @param path
|
|
1115
|
-
*/
|
|
1116
|
-
|
|
1117
|
-
var convertPathToList = function convertPathToList(path) {
|
|
1118
|
-
if (!path) {
|
|
1119
|
-
return undefined;
|
|
1120
|
-
}
|
|
1121
|
-
|
|
1122
|
-
if (isArray(path)) {
|
|
1123
|
-
return path;
|
|
1124
|
-
}
|
|
1125
|
-
|
|
1126
|
-
if (path && isString(path) && path.indexOf(".") > 0) {
|
|
1127
|
-
return split(path, ".");
|
|
1128
|
-
}
|
|
1129
|
-
|
|
1130
|
-
return [path];
|
|
1131
|
-
};
|
|
1132
|
-
|
|
1133
1546
|
/**
|
|
1134
1547
|
* ProFormList ctx
|
|
1135
1548
|
*/
|
|
@@ -1346,8 +1759,8 @@ var proTableProps = function proTableProps() {
|
|
|
1346
1759
|
type: String
|
|
1347
1760
|
},
|
|
1348
1761
|
|
|
1349
|
-
/**
|
|
1350
|
-
* 公共column,会merge到columns item中
|
|
1762
|
+
/**
|
|
1763
|
+
* 公共column,会merge到columns item中
|
|
1351
1764
|
*/
|
|
1352
1765
|
column: {
|
|
1353
1766
|
type: Object
|
|
@@ -1356,23 +1769,40 @@ var proTableProps = function proTableProps() {
|
|
|
1356
1769
|
columns: {
|
|
1357
1770
|
type: Array
|
|
1358
1771
|
},
|
|
1772
|
+
columnState: {
|
|
1773
|
+
type: Object
|
|
1774
|
+
},
|
|
1359
1775
|
|
|
1360
|
-
/**
|
|
1361
|
-
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1776
|
+
/**
|
|
1777
|
+
* 展示控件集合,readonly模式下使用这些组件渲染
|
|
1362
1778
|
*/
|
|
1363
1779
|
elementMap: {
|
|
1364
1780
|
type: Object
|
|
1365
1781
|
},
|
|
1366
1782
|
|
|
1367
|
-
/**
|
|
1368
|
-
* loading
|
|
1783
|
+
/**
|
|
1784
|
+
* loading
|
|
1369
1785
|
*/
|
|
1370
1786
|
loading: {
|
|
1371
1787
|
type: Boolean
|
|
1372
1788
|
},
|
|
1373
1789
|
|
|
1374
|
-
/**
|
|
1375
|
-
*
|
|
1790
|
+
/**
|
|
1791
|
+
* 序号
|
|
1792
|
+
*/
|
|
1793
|
+
serialNumber: {
|
|
1794
|
+
type: Boolean
|
|
1795
|
+
},
|
|
1796
|
+
|
|
1797
|
+
/**
|
|
1798
|
+
* 分页
|
|
1799
|
+
*/
|
|
1800
|
+
pagination: {
|
|
1801
|
+
type: Object
|
|
1802
|
+
},
|
|
1803
|
+
|
|
1804
|
+
/**
|
|
1805
|
+
* provide传递
|
|
1376
1806
|
*/
|
|
1377
1807
|
provideExtra: {
|
|
1378
1808
|
type: Object
|
|
@@ -1385,8 +1815,11 @@ var ProTable = defineComponent({
|
|
|
1385
1815
|
setup: function setup(props, _ref) {
|
|
1386
1816
|
var slots = _ref.slots;
|
|
1387
1817
|
var columns = computed(function () {
|
|
1388
|
-
|
|
1389
|
-
|
|
1818
|
+
var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
|
|
1819
|
+
return item.dataIndex;
|
|
1820
|
+
}); //根据valueType选择对应的展示组件
|
|
1821
|
+
|
|
1822
|
+
var columns = map(mergeColumns, function (item) {
|
|
1390
1823
|
//merge公共item
|
|
1391
1824
|
var nextItem = merge$1(props.column, item);
|
|
1392
1825
|
|
|
@@ -1404,7 +1837,29 @@ var ProTable = defineComponent({
|
|
|
1404
1837
|
}
|
|
1405
1838
|
|
|
1406
1839
|
return nextItem;
|
|
1407
|
-
});
|
|
1840
|
+
}); //处理序号
|
|
1841
|
+
|
|
1842
|
+
if (props.serialNumber) {
|
|
1843
|
+
columns.unshift(_objectSpread2(_objectSpread2({
|
|
1844
|
+
title: "序号",
|
|
1845
|
+
dataIndex: "serialNumber",
|
|
1846
|
+
width: 80
|
|
1847
|
+
}, props.column), {}, {
|
|
1848
|
+
// @ts-ignore
|
|
1849
|
+
customRender: function customRender(_ref3) {
|
|
1850
|
+
var _props$pagination, _props$pagination2;
|
|
1851
|
+
|
|
1852
|
+
var index = _ref3.index;
|
|
1853
|
+
|
|
1854
|
+
if ((_props$pagination = props.pagination) !== null && _props$pagination !== void 0 && _props$pagination.page && (_props$pagination2 = props.pagination) !== null && _props$pagination2 !== void 0 && _props$pagination2.pageSize) {
|
|
1855
|
+
return props.pagination.pageSize * (props.pagination.page - 1) + index + 1;
|
|
1856
|
+
}
|
|
1857
|
+
|
|
1858
|
+
return index + 1;
|
|
1859
|
+
}
|
|
1860
|
+
}));
|
|
1861
|
+
}
|
|
1862
|
+
|
|
1408
1863
|
var operate = props.operate; //处理operate
|
|
1409
1864
|
|
|
1410
1865
|
if (operate && operate.items && some(operate.items, function (item) {
|
|
@@ -1423,8 +1878,8 @@ var ProTable = defineComponent({
|
|
|
1423
1878
|
dataIndex: "operate",
|
|
1424
1879
|
fixed: "right"
|
|
1425
1880
|
}, props.column), {}, {
|
|
1426
|
-
customRender: function customRender(
|
|
1427
|
-
var record =
|
|
1881
|
+
customRender: function customRender(_ref4) {
|
|
1882
|
+
var record = _ref4.record;
|
|
1428
1883
|
var validItems = filter$1(sortedItems, function (item) {
|
|
1429
1884
|
if (item.show && isFunction(item.show)) {
|
|
1430
1885
|
return item.show(record);
|
|
@@ -1466,9 +1921,9 @@ var ProTable = defineComponent({
|
|
|
1466
1921
|
return function () {
|
|
1467
1922
|
var _slots$default;
|
|
1468
1923
|
|
|
1469
|
-
return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots
|
|
1924
|
+
return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
|
|
1470
1925
|
};
|
|
1471
1926
|
}
|
|
1472
1927
|
});
|
|
1473
1928
|
|
|
1474
|
-
export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd, ProForm, ProFormList, ProModule, ProSearchForm, ProTable, RequestAction, SearchMode, convertPathToList, createFormItemCompFn, getColumnFormItemName, getColumnValueType, getFormItemEl, getItemEl, getValidValues, provideProCurd, provideProModule, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
|
|
1929
|
+
export { CurdAction, CurdAddAction, CurdCurrentMode, CurdSubAction, ProCurd, ProForm, ProFormList, ProModalCurd, ProModule, ProPageCurd, ProSearchForm, ProTable, RequestAction, SearchMode, convertPathToList, createFormItemCompFn, defaultPage, generateId, getColumnFormItemName, getColumnValueType, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProModule, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };
|