@vue-start/pro 0.4.10 → 0.4.11

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/dist/index.es.js CHANGED
@@ -1,410 +1,158 @@
1
- import { defineComponent, createVNode, mergeProps, isVNode, computed, h, inject, reactive, Fragment, provide, ref } from 'vue';
2
- import { map, isString, forEach, reduce, size, get, set, pick, omit, isArray, some, keys, isFunction, head, isObject, filter as filter$1, split, isEmpty, mergeWith, sortBy, isUndefined, concat, debounce, clone, isBoolean } from 'lodash';
3
- import { filter, tap, merge, Subject } from 'rxjs';
4
- import { useEffect, setReactiveValue, useWatch } from '@vue-start/hooks';
5
- import { useRequestProvide, isFailedRequestActor, isPreRequestActor, isDoneRequestActor } from '@vue-start/request';
6
- import { useRouter, useRoute } from 'vue-router';
7
-
8
- function ownKeys(object, enumerableOnly) {
9
- var keys = Object.keys(object);
10
-
11
- if (Object.getOwnPropertySymbols) {
12
- var symbols = Object.getOwnPropertySymbols(object);
13
- enumerableOnly && (symbols = symbols.filter(function (sym) {
14
- return Object.getOwnPropertyDescriptor(object, sym).enumerable;
15
- })), keys.push.apply(keys, symbols);
16
- }
17
-
18
- return keys;
1
+ import { defineComponent as A, createVNode as v, mergeProps as M, isVNode as ie, computed as w, h as Q, inject as re, reactive as K, Fragment as ae, provide as oe, ref as U } from "vue";
2
+ import { map as O, isString as fe, forEach as W, reduce as Y, size as X, get as P, set as _, pick as k, omit as I, isArray as q, some as Pe, keys as N, isFunction as H, head as Ye, isObject as Re, filter as z, split as Ze, isEmpty as et, mergeWith as je, sortBy as Ne, cloneDeep as tt, isUndefined as nt, concat as rt, debounce as at, clone as ot, isBoolean as ye } from "lodash";
3
+ import { merge as ct, filter as he, tap as be, Subject as ut } from "rxjs";
4
+ import { useEffect as ce, setReactiveValue as st, useWatch as dt } from "@vue-start/hooks";
5
+ import { useRequestProvide as ge, isDoneRequestActor as Fe, isFailedRequestActor as xe } from "@vue-start/request";
6
+ import { useRouter as it, useRoute as lt } from "vue-router";
7
+ function mt(e) {
8
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !ie(e);
19
9
  }
20
-
21
- function _objectSpread2(target) {
22
- for (var i = 1; i < arguments.length; i++) {
23
- var source = null != arguments[i] ? arguments[i] : {};
24
- i % 2 ? ownKeys(Object(source), !0).forEach(function (key) {
25
- _defineProperty(target, key, source[key]);
26
- }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) {
27
- Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
28
- });
10
+ const ft = () => ({
11
+ row: {
12
+ type: Object,
13
+ default: void 0
14
+ },
15
+ col: {
16
+ type: Object
17
+ },
18
+ items: {
19
+ type: Array
29
20
  }
30
-
31
- return target;
32
- }
33
-
34
- function _defineProperty(obj, key, value) {
35
- if (key in obj) {
36
- Object.defineProperty(obj, key, {
37
- value: value,
38
- enumerable: true,
39
- configurable: true,
40
- writable: true
21
+ }), kt = (e, n) => A({
22
+ props: {
23
+ ...ft()
24
+ },
25
+ setup: (a) => () => {
26
+ let t;
27
+ return v(e, a.row, mt(t = O(a.items, (o) => v(n, M({
28
+ key: o.rowKey
29
+ }, a.col, o.col), {
30
+ default: () => [o.vNode]
31
+ }))) ? t : {
32
+ default: () => [t]
41
33
  });
42
- } else {
43
- obj[key] = value;
44
34
  }
45
-
46
- return obj;
47
- }
48
-
49
- function _toConsumableArray(arr) {
50
- return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
51
- }
52
-
53
- function _arrayWithoutHoles(arr) {
54
- if (Array.isArray(arr)) return _arrayLikeToArray(arr);
55
- }
56
-
57
- function _iterableToArray(iter) {
58
- if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter);
59
- }
60
-
61
- function _unsupportedIterableToArray(o, minLen) {
62
- if (!o) return;
63
- if (typeof o === "string") return _arrayLikeToArray(o, minLen);
64
- var n = Object.prototype.toString.call(o).slice(8, -1);
65
- if (n === "Object" && o.constructor) n = o.constructor.name;
66
- if (n === "Map" || n === "Set") return Array.from(o);
67
- if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
68
- }
69
-
70
- function _arrayLikeToArray(arr, len) {
71
- if (len == null || len > arr.length) len = arr.length;
72
-
73
- for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
74
-
75
- return arr2;
76
- }
77
-
78
- function _nonIterableSpread() {
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
- }
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
-
126
- var createUseRequestActor = function createUseRequestActor(filterFun) {
127
- return function (actors, callback) {
128
- var _useRequestProvide = useRequestProvide(),
129
- requestSubject$ = _useRequestProvide.requestSubject$;
130
-
131
- var nameSet = new Set(map(actors, function (actor) {
132
- return isString(actor) ? actor : actor.name;
133
- }));
134
- useEffect(function () {
135
- var sub = requestSubject$.pipe(filter(filterFun), tap(function (actor) {
136
- if (nameSet.has(actor.name)) {
137
- callback(actor);
138
- }
139
- })).subscribe();
140
- return function () {
141
- sub.unsubscribe();
142
- };
143
- }, []);
144
- };
145
- };
146
-
147
- var useDoneRequestActor = createUseRequestActor(isDoneRequestActor);
148
- var useFailedRequestActor = createUseRequestActor(isFailedRequestActor);
149
- var useComposeRequestActor = function useComposeRequestActor(actors, options, cancelWhileUnmount) {
150
- var _useRequestProvide2 = useRequestProvide(),
151
- requestSubject$ = _useRequestProvide2.requestSubject$,
152
- dispatchRequest = _useRequestProvide2.dispatchRequest;
153
-
154
- var nameSet = new Set(map(actors, function (actor) {
155
- return isString(actor) ? actor : actor.name;
156
- }));
157
- var lastRequestActors = {};
158
- useEffect(function () {
159
- var sub = merge(requestSubject$.pipe(filter(isPreRequestActor), tap(function (actor) {
160
- if (nameSet.has(actor.name)) {
161
- var _options$onStart;
162
-
163
- (_options$onStart = options.onStart) === null || _options$onStart === void 0 ? void 0 : _options$onStart.call(options, actor);
164
- lastRequestActors[actor.name] = actor;
165
- }
166
- })), requestSubject$.pipe(filter(isDoneRequestActor), tap(function (actor) {
167
- if (nameSet.has(actor.name)) {
168
- var _options$onSuccess, _options$onFinish;
169
-
170
- (_options$onSuccess = options.onSuccess) === null || _options$onSuccess === void 0 ? void 0 : _options$onSuccess.call(options, actor);
171
- (_options$onFinish = options.onFinish) === null || _options$onFinish === void 0 ? void 0 : _options$onFinish.call(options, actor);
172
- lastRequestActors[actor.name] = undefined;
173
- }
174
- })), requestSubject$.pipe(filter(isFailedRequestActor), tap(function (actor) {
175
- if (nameSet.has(actor.name)) {
176
- var _options$onFailed, _options$onFinish2;
177
-
178
- (_options$onFailed = options.onFailed) === null || _options$onFailed === void 0 ? void 0 : _options$onFailed.call(options, actor);
179
- (_options$onFinish2 = options.onFinish) === null || _options$onFinish2 === void 0 ? void 0 : _options$onFinish2.call(options, actor);
180
- lastRequestActors[actor.name] = undefined;
181
- }
182
- }))).subscribe();
183
- return function () {
184
- sub.unsubscribe();
185
-
186
- if (cancelWhileUnmount) {
187
- //组件销毁的时候cancel请求
188
- forEach(lastRequestActors, function (actor) {
189
- actor && dispatchRequest(_objectSpread2(_objectSpread2({}, actor), {}, {
190
- stage: "CANCEL"
191
- }));
192
- });
193
- }
35
+ }), ke = (e) => (n, a) => {
36
+ const { requestSubject$: t } = ge(), o = new Set(O(n, (r) => fe(r) ? r : r.name));
37
+ ce(() => {
38
+ const r = t.pipe(
39
+ he(e),
40
+ be((l) => {
41
+ o.has(l.name) && a(l);
42
+ })
43
+ ).subscribe();
44
+ return () => {
45
+ r.unsubscribe();
194
46
  };
195
47
  }, []);
196
- };
197
-
198
- /***************************************** curd模式 *****************************************/
199
-
200
- /**
201
- * 获取Column的valueType,默认"text"
202
- * @param column
203
- */
204
- var getColumnValueType = function getColumnValueType(column) {
205
- return column.formValueType || column.valueType || "text";
206
- };
207
- /**
208
- *获取Column的FormItem name
209
- * @param column
210
- */
211
-
212
- var getColumnFormItemName = function getColumnFormItemName(column) {
213
- var _column$formItemProps;
214
-
215
- return ((_column$formItemProps = column.formItemProps) === null || _column$formItemProps === void 0 ? void 0 : _column$formItemProps.name) || column.dataIndex;
216
- };
217
- /**
218
- * 根据Column生成FormItem VNode
219
- * formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
220
- * @param formElementMap
221
- * @param column
222
- * @param needRules
223
- */
224
-
225
- var getFormItemEl = function getFormItemEl(formElementMap, column) {
226
- var _column$formFieldProp;
227
-
228
- var needRules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
229
- var valueType = getColumnValueType(column);
230
- var Comp = get(formElementMap, valueType);
231
-
232
- if (!Comp) {
233
- return null;
234
- }
235
-
236
- var name = getColumnFormItemName(column);
237
- var itemProps = needRules ? column.formItemProps : omit(column.formItemProps, "rules");
238
- return h(Comp, _objectSpread2(_objectSpread2({
239
- key: name,
240
- name: name,
241
- label: column.title
242
- }, itemProps), {}, {
243
- fieldProps: omit(column.formFieldProps, "slots"),
244
- showProps: column.showProps
245
- }), (_column$formFieldProp = column.formFieldProps) === null || _column$formFieldProp === void 0 ? void 0 : _column$formFieldProp.slots);
246
- };
247
- /**
248
- * 根据Column生成Item VNode
249
- * @param elementMap
250
- * @param column
251
- * @param value
252
- */
253
-
254
- var getItemEl = function getItemEl(elementMap, column, value) {
255
- var _column$formFieldProp2;
256
-
257
- var valueType = column.valueType || "text";
258
- var Comp = get(elementMap, valueType);
259
-
260
- if (!Comp) {
48
+ }, qt = ke(Fe), Kt = ke(xe), yt = (e, n, a) => {
49
+ const { requestSubject$: t, dispatchRequest: o } = ge(), r = new Set(O(e, (f) => fe(f) ? f : f.name)), l = {};
50
+ ce(() => {
51
+ const f = ct(
52
+ t.pipe(
53
+ he(Fe),
54
+ be((y) => {
55
+ var p, c;
56
+ r.has(y.name) && ((p = n.onSuccess) == null || p.call(n, y), (c = n.onFinish) == null || c.call(n, y), l[y.name] = void 0);
57
+ })
58
+ ),
59
+ t.pipe(
60
+ he(xe),
61
+ be((y) => {
62
+ var p, c;
63
+ r.has(y.name) && ((p = n.onFailed) == null || p.call(n, y), (c = n.onFinish) == null || c.call(n, y), l[y.name] = void 0);
64
+ })
65
+ )
66
+ ).subscribe();
67
+ return () => {
68
+ f.unsubscribe(), a && W(l, (y) => {
69
+ y && o({ ...y, stage: "CANCEL" });
70
+ });
71
+ };
72
+ }, []);
73
+ }, qe = (e) => e.formValueType || e.valueType || "text", Z = (e) => {
74
+ var n;
75
+ return ((n = e.formItemProps) == null ? void 0 : n.name) || e.dataIndex;
76
+ }, ve = (e, n, a = !0) => {
77
+ var f;
78
+ const t = qe(n), o = P(e, t);
79
+ if (!o)
261
80
  return null;
262
- }
263
-
264
- return h(Comp, _objectSpread2(_objectSpread2({}, omit(column.formFieldProps, "slots")), {}, {
265
- showProps: column.showProps,
266
- value: value
267
- }), (_column$formFieldProp2 = column.formFieldProps) === null || _column$formFieldProp2 === void 0 ? void 0 : _column$formFieldProp2.slots);
268
- };
269
- /***************************************** 通用模式 *****************************************/
270
-
271
- var renderElements = function renderElements(elementMap, elementConfigs) {
272
- return map(elementConfigs, function (elementConfig) {
273
- return renderElement(elementMap, elementConfig);
274
- });
275
- };
276
- /**
277
- * props转换
278
- */
279
-
280
- var convertPropsEl = function convertPropsEl(elementMap, elementConfig) {
281
- var _elementConfig$highCo;
282
-
283
- var elementProps = elementConfig.elementProps;
284
-
285
- var nextProps = _objectSpread2({}, elementConfig.elementProps);
286
-
287
- forEach((_elementConfig$highCo = elementConfig.highConfig$) === null || _elementConfig$highCo === void 0 ? void 0 : _elementConfig$highCo.registerPropsTrans, function (item) {
288
- var target = get(elementProps, item.name);
289
-
290
- if (!target || isVNode(target)) {
291
- return;
292
- }
293
-
294
- if (isArray(target)) {
295
- //如果list中存在VNode,不转换
296
- if (some(target, function (sub) {
297
- return isVNode(sub);
298
- })) {
81
+ const r = Z(n), l = a ? n.formItemProps : I(n.formItemProps, "rules");
82
+ return Q(o, {
83
+ key: r,
84
+ name: r,
85
+ label: n.title,
86
+ ...l,
87
+ fieldProps: I(n.formFieldProps, "slots"),
88
+ showProps: n.showProps
89
+ }, (f = n.formFieldProps) == null ? void 0 : f.slots);
90
+ }, Ke = (e, n, a) => {
91
+ var r;
92
+ const t = n.valueType || "text", o = P(e, t);
93
+ return o ? Q(o, {
94
+ ...I(n.formFieldProps, "slots"),
95
+ showProps: n.showProps,
96
+ value: a
97
+ }, (r = n.formFieldProps) == null ? void 0 : r.slots) : null;
98
+ }, Te = (e, n) => O(n, (a) => ee(e, a)), Ue = (e, n) => {
99
+ var o;
100
+ const a = n.elementProps, t = {
101
+ ...n.elementProps
102
+ };
103
+ return W((o = n.highConfig$) == null ? void 0 : o.registerPropsTrans, (r) => {
104
+ const l = P(a, r.name);
105
+ if (!(!l || ie(l))) {
106
+ if (q(l)) {
107
+ if (Pe(l, (f) => ie(f)))
108
+ return;
109
+ _(t, r.name, Te(e, l));
299
110
  return;
300
- } //如果碰到特殊场景,可以替换成单个渲染模式
301
-
302
-
303
- set(nextProps, item.name, renderElements(elementMap, target));
304
- return;
305
- }
306
-
307
- if (!target.elementType) {
308
- return;
111
+ }
112
+ !l.elementType || (r.isFun ? _(t, r.name, (...f) => {
113
+ const y = r.needParams ? {
114
+ ...l.elementProps,
115
+ params$: f
116
+ } : l.elementProps;
117
+ return ee(e, {
118
+ ...l,
119
+ elementProps: y
120
+ });
121
+ }) : _(t, r.name, ee(e, l)));
309
122
  }
310
-
311
- if (item.isFun) {
312
- set(nextProps, item.name, function () {
313
- for (var _len = arguments.length, params$ = new Array(_len), _key = 0; _key < _len; _key++) {
314
- params$[_key] = arguments[_key];
315
- }
316
-
317
- var ep = item.needParams ? _objectSpread2(_objectSpread2({}, target.elementProps), {}, {
318
- params$: params$
319
- }) : target.elementProps;
320
- return renderElement(elementMap, _objectSpread2(_objectSpread2({}, target), {}, {
321
- elementProps: ep
322
- }));
123
+ }), t;
124
+ }, Be = (e, n) => {
125
+ const a = X(n.children) > 0 ? Te(e, n.children) : void 0, t = n.childrenSlotName || "default", o = I(n.slots, a ? t : "");
126
+ return W(N(o), (r) => {
127
+ const l = o[r];
128
+ l && !H(l) && l.elementType && (o[r] = (...f) => {
129
+ const y = l.needParams ? {
130
+ ...l.elementProps,
131
+ params$: f
132
+ } : l.elementProps;
133
+ return ee(e, {
134
+ ...l,
135
+ elementProps: y
323
136
  });
324
- } else {
325
- set(nextProps, item.name, renderElement(elementMap, target));
326
- }
327
- });
328
- return nextProps;
329
- };
330
- /**
331
- * slots转换
332
- */
333
-
334
-
335
- var convertSlots = function convertSlots(elementMap, elementConfig) {
336
- var children = size(elementConfig.children) > 0 ? renderElements(elementMap, elementConfig.children) : undefined; //children插槽名称
337
-
338
- var childrenSlotName = elementConfig.childrenSlotName || "default";
339
- var validSlots = omit(elementConfig.slots, children ? childrenSlotName : ""); //如果slots注册的是 IElementConfig ,进行转换
340
-
341
- forEach(keys(validSlots), function (k) {
342
- var v = validSlots[k]; //IElementConfig
343
-
344
- if (v && !isFunction(v) && v.elementType) {
345
- validSlots[k] = function () {
346
- for (var _len2 = arguments.length, params$ = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
347
- params$[_key2] = arguments[_key2];
348
- }
349
-
350
- //如果需要params,在props中注入 params$
351
- var elementProps = v.needParams ? _objectSpread2(_objectSpread2({}, v.elementProps), {}, {
352
- params$: params$
353
- }) : v.elementProps;
354
- return renderElement(elementMap, _objectSpread2(_objectSpread2({}, v), {}, {
355
- elementProps: elementProps
356
- }));
357
- };
358
- }
359
- });
360
- return _objectSpread2(_defineProperty({}, childrenSlotName, children ? function () {
361
- return children;
362
- } : undefined), validSlots);
363
- };
364
- /**
365
- *
366
- * @param elementMap
367
- * @param elementConfig
368
- */
369
-
370
-
371
- var renderElement = function renderElement(elementMap, elementConfig) {
372
- var El = get(elementMap, elementConfig.elementType) || elementConfig.elementType; //如果有highConfig$,包裹一层Wrapper
373
-
374
- if (elementConfig.highConfig$) {
375
- return h(Wrapper, {
376
- key: elementConfig.elementId,
377
- elementMap: elementMap,
378
- elementConfig: elementConfig
379
137
  });
380
- }
381
-
382
- var slots = convertSlots(elementMap, elementConfig);
383
- var elementProps = convertPropsEl(elementMap, elementConfig);
384
- return h(El, _objectSpread2({
385
- key: elementConfig.elementId
386
- }, elementProps), slots);
387
- };
388
- /**
389
- * 获取第一层级属性名
390
- * 如:['aaa','bbb',...] 中的 'aaa'
391
- * 如:"aaa.bbb.ccc..." 中的 'aaa'
392
- */
393
-
394
- var getFirstPropName = function getFirstPropName(name) {
395
- if (isArray(name)) {
396
- return head(name);
397
- } else if (isString(name) && name.indexOf(".") > 0) {
398
- return name.substring(0, name.indexOf("."));
399
- }
400
-
401
- return name;
402
- };
403
- /**
404
- * 处理highConfig$
405
- */
406
-
407
- var Wrapper = defineComponent({
138
+ }), {
139
+ [t]: a ? () => a : void 0,
140
+ ...o
141
+ };
142
+ }, ee = (e, n) => {
143
+ const a = P(e, n.elementType) || n.elementType;
144
+ if (n.highConfig$)
145
+ return Q(Et, {
146
+ key: n.elementId,
147
+ elementMap: e,
148
+ elementConfig: n
149
+ });
150
+ const t = Be(e, n), o = Ue(e, n);
151
+ return Q(a, {
152
+ key: n.elementId,
153
+ ...o
154
+ }, t);
155
+ }, pt = (e) => q(e) ? Ye(e) : fe(e) && e.indexOf(".") > 0 ? e.substring(0, e.indexOf(".")) : e, Et = A({
408
156
  props: {
409
157
  elementMap: {
410
158
  type: Object
@@ -413,2260 +161,1341 @@ var Wrapper = defineComponent({
413
161
  type: Object
414
162
  }
415
163
  },
416
- setup: function setup(props) {
417
- var _useProModule = useProModule(),
418
- state = _useProModule.state,
419
- sendEvent = _useProModule.sendEvent;
420
-
421
- var elementMap = props.elementMap,
422
- elementConfig = props.elementConfig;
423
- var highConfig$ = elementConfig.highConfig$; //转换props
424
-
425
- var elementProps = convertPropsEl(elementMap, elementConfig); //事件订阅
426
-
427
- var events = reduce(highConfig$.registerEventList, function (pair, item) {
428
- return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, item.name, function () {
429
- for (var _len3 = arguments.length, params = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
430
- params[_key3] = arguments[_key3];
431
- }
432
-
433
- sendEvent({
434
- type: item.sendEventName || elementConfig.elementId,
435
- payload: params
164
+ setup: (e) => {
165
+ const {
166
+ state: n,
167
+ sendEvent: a
168
+ } = ue(), {
169
+ elementMap: t,
170
+ elementConfig: o
171
+ } = e, r = o.highConfig$, l = Ue(t, o), f = Y(r.registerEventList, (u, s) => ({
172
+ ...u,
173
+ [s.name]: (...i) => {
174
+ a({
175
+ type: s.sendEventName || o.elementId,
176
+ payload: i
436
177
  });
437
- }));
438
- }, {}); //receiveStateList 订阅
439
-
440
- var receiveStates = computed(function () {
441
- if (!highConfig$.registerStateList || size(highConfig$.registerStateList) <= 0) {
442
- return undefined;
443
178
  }
444
-
445
- var changeProps = _objectSpread2({}, elementProps); //赋值 && 返回一级属性名称
446
-
447
-
448
- var firstPropNameList = map(highConfig$.registerStateList, function (item) {
449
- var targetName = item.mapName || item.name; //从state中取值
450
-
451
- var value = get(state, item.name); //赋值
452
-
453
- set(changeProps, targetName, value); //返回一级属性名称
454
-
455
- return getFirstPropName(targetName);
179
+ }), {}), y = w(() => {
180
+ if (!r.registerStateList || X(r.registerStateList) <= 0)
181
+ return;
182
+ const u = {
183
+ ...l
184
+ }, s = O(r.registerStateList, (i) => {
185
+ const d = i.mapName || i.name, m = P(n, i.name);
186
+ return _(u, d, m), pt(d);
456
187
  });
457
- return pick(changeProps, firstPropNameList);
458
- });
459
- var El = get(elementMap, elementConfig.elementType) || elementConfig.elementType;
460
- var slots = convertSlots(elementMap, elementConfig);
461
- return function () {
462
- //如果标记show$值为false,不渲染组件
463
- var show$ = get(receiveStates.value, "show$");
464
-
465
- if (show$ === false) {
466
- return null;
467
- }
468
-
469
- return h(El, _objectSpread2(_objectSpread2(_objectSpread2({
470
- key: elementConfig.elementId
471
- }, elementProps), omit(receiveStates.value, "show$")), events), slots);
472
- };
188
+ return k(u, s);
189
+ }), p = P(t, o.elementType) || o.elementType, c = Be(t, o);
190
+ return () => P(y.value, "show$") === !1 ? null : Q(p, {
191
+ key: o.elementId,
192
+ ...l,
193
+ ...I(y.value, "show$"),
194
+ ...f
195
+ }, c);
473
196
  }
474
- });
475
-
476
- var ProModuleKey = Symbol("pro-module");
477
- var useProModule = function useProModule() {
478
- return inject(ProModuleKey);
479
- };
480
- var provideProModule = function provideProModule(ctx) {
481
- provide(ProModuleKey, ctx);
482
- };
483
- var RequestAction = {
197
+ }), $e = Symbol("pro-module"), ue = () => re($e), St = (e) => {
198
+ oe($e, e);
199
+ }, te = {
484
200
  Success: "request-success$",
485
201
  Fail: "request-fail$"
486
- };
487
-
488
- var proModuleProps = function proModuleProps() {
489
- return {
490
- /**
491
- * module状态
492
- */
493
- state: {
494
- type: Object
495
- },
496
-
497
- /**
498
- * 组件集
499
- */
500
- elementMap: {
501
- type: Object
502
- },
503
-
504
- /**
505
- * 组件描述(树)
506
- */
507
- elementConfigs: {
508
- type: Array
509
- },
510
-
511
- /**
512
- * requests
513
- */
514
- requests: {
515
- type: Array
516
- }
517
- };
518
- };
519
-
520
- var ProModule = defineComponent({
521
- props: _objectSpread2({}, proModuleProps()),
522
- setup: function setup(props, _ref) {
523
- var slots = _ref.slots,
524
- expose = _ref.expose;
525
-
526
- /*********************************** render ***************************************/
527
- var render = function render(elementConfig) {
528
- if (isArray(elementConfig)) {
529
- return renderElements(props.elementMap, elementConfig);
530
- }
531
-
532
- return renderElement(props.elementMap, elementConfig);
533
- };
534
- /*********************************** 事件处理 ***************************************/
535
-
536
-
537
- var subject$ = new Subject(); //发送Module事件
538
-
539
- var sendEvent = function sendEvent(action) {
540
- subject$.next(action);
541
- };
542
- /*********************************** 页面状态 ***************************************/
543
-
544
-
545
- var state = props.state || reactive({});
546
-
547
- var dispatch = function dispatch(action) {
548
- var prev = state[action.type];
549
- var data = isFunction(action.payload) ? action.payload(prev) : action.payload; //如果要更新的属性值是 object ,执行覆盖操作
550
-
551
- if (isObject(prev)) {
552
- setReactiveValue(state[action.type], data);
202
+ }, ht = () => ({
203
+ state: {
204
+ type: Object
205
+ },
206
+ elementMap: {
207
+ type: Object
208
+ },
209
+ elementConfigs: {
210
+ type: Array
211
+ },
212
+ requests: {
213
+ type: Array
214
+ }
215
+ }), pe = A({
216
+ props: {
217
+ ...ht()
218
+ },
219
+ setup: (e, {
220
+ slots: n,
221
+ expose: a
222
+ }) => {
223
+ const t = (s) => q(s) ? Te(e.elementMap, s) : ee(e.elementMap, s), o = new ut(), r = (s) => {
224
+ o.next(s);
225
+ }, l = e.state || K({}), f = (s) => {
226
+ const i = l[s.type], d = H(s.payload) ? s.payload(i) : s.payload;
227
+ if (Re(i)) {
228
+ st(l[s.type], d);
553
229
  return;
554
230
  }
555
-
556
- state[action.type] = data;
557
- };
558
- /*********************************** request ***************************************/
559
-
560
-
561
- var _useRequestProvide = useRequestProvide(),
562
- dispatchRequest = _useRequestProvide.dispatchRequest;
563
-
564
- var requestMap = reduce(props.requests, function (pair, item) {
565
- var _item$actor;
566
-
567
- return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, (_item$actor = item.actor) === null || _item$actor === void 0 ? void 0 : _item$actor.name, item));
568
- }, {});
569
- var actionMap = reduce(props.requests, function (pair, item) {
570
- return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, item.action, item));
571
- }, {}); //发送请求
572
-
573
- var sendRequest = function sendRequest(requestNameOrAction) {
574
- var requestOpts = get(requestMap, requestNameOrAction) || get(actionMap, requestNameOrAction);
575
-
576
- if (!requestOpts) {
231
+ l[s.type] = d;
232
+ }, {
233
+ dispatchRequest: y
234
+ } = ge(), p = Y(e.requests, (s, i) => {
235
+ var d;
236
+ return {
237
+ ...s,
238
+ [(d = i.actor) == null ? void 0 : d.name]: i
239
+ };
240
+ }, {}), c = Y(e.requests, (s, i) => ({
241
+ ...s,
242
+ [i.action]: i
243
+ }), {}), u = (s, ...i) => {
244
+ const d = P(p, s) || P(c, s);
245
+ if (!d)
577
246
  return;
578
- }
579
-
580
- var nextParams;
581
-
582
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
583
- params[_key - 1] = arguments[_key];
584
- }
585
-
586
- if (requestOpts.convertParams) {
587
- nextParams = requestOpts.convertParams.apply(requestOpts, params);
588
- } else {
589
- nextParams = get(params, 0);
590
- }
591
-
592
- dispatchRequest(requestOpts.actor, nextParams);
247
+ let m;
248
+ d.convertParams ? m = d.convertParams(...i) : m = P(i, 0), d.loadingName && f({
249
+ type: d.loadingName,
250
+ payload: !0
251
+ }), y(d.actor, m);
593
252
  };
594
-
595
- useComposeRequestActor(keys(requestMap), {
596
- onStart: function onStart(actor) {
597
- //如果设置了loading,将请求状态维护到state中
598
- var loadingName = get(requestMap, [actor.name, "loadingName"]);
599
-
600
- if (loadingName) {
601
- dispatch({
602
- type: loadingName,
603
- payload: true
253
+ return yt(N(p), {
254
+ onSuccess: (s) => {
255
+ var d, m;
256
+ const i = P(p, s.name);
257
+ if (i != null && i.stateName) {
258
+ const E = i.convertData ? i.convertData(s) : (d = s.res) == null ? void 0 : d.data;
259
+ f({
260
+ type: i.stateName,
261
+ payload: E
604
262
  });
605
263
  }
606
- },
607
- onSuccess: function onSuccess(actor) {
608
- var _requestOpts$onSucces;
609
-
610
- var requestOpts = get(requestMap, actor.name); //如果设置了stateName,将结果维护到state中
611
-
612
- if (requestOpts !== null && requestOpts !== void 0 && requestOpts.stateName) {
613
- var _actor$res;
614
-
615
- var data = requestOpts.convertData ? requestOpts.convertData(actor) : (_actor$res = actor.res) === null || _actor$res === void 0 ? void 0 : _actor$res.data;
616
- dispatch({
617
- type: requestOpts.stateName,
618
- payload: data
619
- });
620
- } //发送成功事件
621
-
622
-
623
- sendEvent({
624
- type: RequestAction.Success,
264
+ r({
265
+ type: te.Success,
625
266
  payload: {
626
- actor: actor,
627
- requestOpts: requestOpts
267
+ actor: s,
268
+ requestOpts: i
628
269
  }
629
- }); //回调事件
630
-
631
- (_requestOpts$onSucces = requestOpts.onSuccess) === null || _requestOpts$onSucces === void 0 ? void 0 : _requestOpts$onSucces.call(requestOpts, actor);
270
+ }), (m = i.onSuccess) == null || m.call(i, s);
632
271
  },
633
- onFailed: function onFailed(actor) {
634
- var _requestOpts$onFailed;
635
-
636
- var requestOpts = get(requestMap, actor.name); //发送失败事件
637
-
638
- sendEvent({
639
- type: RequestAction.Fail,
272
+ onFailed: (s) => {
273
+ var d;
274
+ const i = P(p, s.name);
275
+ r({
276
+ type: te.Fail,
640
277
  payload: {
641
- actor: actor,
642
- requestOpts: requestOpts
278
+ actor: s,
279
+ requestOpts: i
643
280
  }
644
- }); //回调事件
645
-
646
- (_requestOpts$onFailed = requestOpts.onFailed) === null || _requestOpts$onFailed === void 0 ? void 0 : _requestOpts$onFailed.call(requestOpts, actor);
281
+ }), (d = i.onFailed) == null || d.call(i, s);
647
282
  },
648
- onFinish: function onFinish(actor) {
649
- var loadingName = get(requestMap, [actor.name, "loadingName"]);
650
-
651
- if (loadingName) {
652
- dispatch({
653
- type: loadingName,
654
- payload: false
655
- });
656
- }
283
+ onFinish: (s) => {
284
+ const i = P(p, [s.name, "loadingName"]);
285
+ i && f({
286
+ type: i,
287
+ payload: !1
288
+ });
657
289
  }
658
- }, true);
659
- provideProModule({
660
- elementMap: props.elementMap,
661
- //
662
- subject$: subject$,
663
- sendEvent: sendEvent,
664
- //
665
- state: state,
666
- dispatch: dispatch,
667
- //
668
- requests: props.requests,
669
- sendRequest: sendRequest
670
- });
671
- expose({
672
- sendEvent: sendEvent,
673
- sendRequest: sendRequest
674
- });
675
- return function () {
676
- var _slots$default;
677
-
678
- return createVNode(Fragment, null, [size(props.elementConfigs) > 0 && render(props.elementConfigs), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)]);
290
+ }, !0), St({
291
+ elementMap: e.elementMap,
292
+ subject$: o,
293
+ sendEvent: r,
294
+ state: l,
295
+ dispatch: f,
296
+ requests: e.requests,
297
+ sendRequest: u
298
+ }), a({
299
+ sendEvent: r,
300
+ sendRequest: u
301
+ }), () => {
302
+ var s;
303
+ return v(ae, null, [X(e.elementConfigs) > 0 && t(e.elementConfigs), (s = n.default) == null ? void 0 : s.call(n)]);
679
304
  };
680
305
  }
681
- });
682
-
683
- //订阅module事件
684
- var useModuleEvent = function useModuleEvent(cb) {
685
- var _useProModule = useProModule(),
686
- subject$ = _useProModule.subject$;
687
-
688
- useEffect(function () {
689
- var sub = subject$.subscribe({
690
- next: function next(action) {
691
- cb(action);
306
+ }), De = (e) => {
307
+ const { subject$: n } = ue();
308
+ ce(() => {
309
+ const a = n.subscribe({
310
+ next: (t) => {
311
+ e(t);
692
312
  }
693
313
  });
694
- return function () {
695
- return sub.unsubscribe();
696
- };
314
+ return () => a.unsubscribe();
697
315
  }, []);
698
- };
699
-
700
- var ProCurdKey = Symbol("pro-curd");
701
- var useProCurd = function useProCurd() {
702
- return inject(ProCurdKey);
703
- };
704
- var provideProCurd = function provideProCurd(ctx) {
705
- return provide(ProCurdKey, ctx);
706
- };
707
- /************************************ 常量 *************************************/
708
-
709
- /**
710
- * curd 5种基础Action
711
- */
712
-
713
- var CurdAction;
714
-
715
- (function (CurdAction) {
716
- CurdAction["LIST"] = "LIST";
717
- CurdAction["DETAIL"] = "DETAIL";
718
- CurdAction["ADD"] = "ADD";
719
- CurdAction["EDIT"] = "EDIT";
720
- CurdAction["DELETE"] = "DELETE";
721
- })(CurdAction || (CurdAction = {}));
722
-
723
- /**
724
- * CurdAction 的子事件
725
- */
726
- var CurdSubAction;
727
-
728
- (function (CurdSubAction) {
729
- CurdSubAction["EMIT"] = "EMIT";
730
- CurdSubAction["EXECUTE"] = "EXECUTE";
731
- CurdSubAction["PAGE"] = "PAGE";
732
- CurdSubAction["SUCCESS"] = "SUCCESS";
733
- CurdSubAction["FAIL"] = "FAIL";
734
- })(CurdSubAction || (CurdSubAction = {}));
735
-
736
- /**
737
- * curd 操作模式
738
- */
739
- var CurdCurrentMode;
740
-
741
- (function (CurdCurrentMode) {
742
- CurdCurrentMode["ADD"] = "ADD";
743
- CurdCurrentMode["EDIT"] = "EDIT";
744
- CurdCurrentMode["DETAIL"] = "DETAIL";
745
- })(CurdCurrentMode || (CurdCurrentMode = {}));
746
-
747
- /**
748
- * curd add 模式下 标记 "确定" "确定并继续" 触发
749
- */
750
- var CurdAddAction;
751
-
752
- (function (CurdAddAction) {
753
- CurdAddAction["NORMAL"] = "NORMAL";
754
- CurdAddAction["CONTINUE"] = "CONTINUE";
755
- })(CurdAddAction || (CurdAddAction = {}));
756
-
757
- /**
758
- * 剔除showState或showStateRules规则为!true的值
759
- * @param values
760
- * @param showState
761
- * @param showStateRules
762
- */
763
-
764
- var getValidValues = function getValidValues(values, showState, showStateRules) {
765
- if (showState) {
766
- var invalidKeys = filter$1(keys(showState), function (key) {
767
- return !showState[key];
768
- });
769
- return omit(values, invalidKeys);
770
- }
771
-
772
- if (showStateRules) {
773
- var _invalidKeys = filter$1(keys(showStateRules), function (key) {
774
- return !showStateRules[key](values);
775
- });
776
-
777
- return omit(values, _invalidKeys);
778
- }
779
-
780
- return values;
781
- };
782
- /**
783
- * string类型的path转为arr
784
- * @param path
785
- */
786
-
787
- var convertPathToList = function convertPathToList(path) {
788
- if (!path) {
789
- return undefined;
790
- }
791
-
792
- if (isArray(path)) {
793
- return path;
316
+ }, Ve = Symbol("pro-curd"), se = () => re(Ve), bt = (e) => oe(Ve, e);
317
+ var g = /* @__PURE__ */ ((e) => (e.LIST = "LIST", e.DETAIL = "DETAIL", e.ADD = "ADD", e.EDIT = "EDIT", e.DELETE = "DELETE", e))(g || {}), D = /* @__PURE__ */ ((e) => (e.EMIT = "EMIT", e.EXECUTE = "EXECUTE", e.PAGE = "PAGE", e.SUCCESS = "SUCCESS", e.FAIL = "FAIL", e))(D || {}), F = /* @__PURE__ */ ((e) => (e.ADD = "ADD", e.EDIT = "EDIT", e.DETAIL = "DETAIL", e))(F || {}), ne = /* @__PURE__ */ ((e) => (e.NORMAL = "NORMAL", e.CONTINUE = "CONTINUE", e))(ne || {});
318
+ const vt = (e, n, a) => {
319
+ if (n) {
320
+ const t = z(N(n), (o) => !n[o]);
321
+ return I(e, t);
794
322
  }
795
-
796
- if (path && isString(path) && path.indexOf(".") > 0) {
797
- return split(path, ".");
323
+ if (a) {
324
+ const t = z(N(a), (o) => !a[o](e));
325
+ return I(e, t);
798
326
  }
799
-
800
- return [path];
801
- };
802
- /**
803
- * 将listState 中的数据通过id merge到 list item中
804
- * ps:数组会替换
805
- * 注意:mergeWith 会改变原始对象
806
- * @param list
807
- * @param listState
808
- * @param id
809
- */
810
-
811
- var mergeStateToList = function mergeStateToList(list, listState, id) {
812
- if (!listState || !id) {
813
- return list;
814
- }
815
-
816
- return map(list, function (item) {
817
- var idName = isFunction(id) ? id(item) : id; //如果listState中有值,merge处理
818
-
819
- var stateData = get(listState, idName);
820
-
821
- if (!stateData || isEmpty(stateData) || isFunction(stateData) || !isObject(stateData)) {
822
- return item;
823
- } //只有是对象(键值对)才合并
824
-
825
-
826
- return mergeWith(item, stateData, function (objValue, srcValue) {
827
- //如果是数组,替换
828
- if (isArray(objValue) || isArray(srcValue)) {
829
- return srcValue;
830
- }
831
- });
327
+ return e;
328
+ }, Xe = (e) => {
329
+ if (!!e)
330
+ return q(e) ? e : e && fe(e) && e.indexOf(".") > 0 ? Ze(e, ".") : [e];
331
+ }, Ie = (e, n, a) => !n || !a ? e : O(e, (t) => {
332
+ const o = H(a) ? a(t) : a, r = P(n, o);
333
+ return !r || et(r) || H(r) || !Re(r) ? t : je(t, r, (l, f) => {
334
+ if (q(l) || q(f))
335
+ return f;
832
336
  });
833
- };
834
-
835
- /**
836
- * ref 传递
837
- */
838
-
839
- var createExpose = function createExpose(methods, targetRef) {
840
- return reduce(methods, function (pair, method) {
841
- return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, method, function () {
842
- var _targetRef$value, _targetRef$value$meth;
843
-
844
- for (var _len = arguments.length, params = new Array(_len), _key = 0; _key < _len; _key++) {
845
- params[_key] = arguments[_key];
846
- }
847
-
848
- 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));
849
- }));
850
- }, {});
851
- };
852
-
853
- var defaultPage = {
337
+ }), J = (e, n) => Y(
338
+ e,
339
+ (a, t) => ({
340
+ ...a,
341
+ [t]: (...o) => {
342
+ var r, l;
343
+ return (l = (r = n.value) == null ? void 0 : r[t]) == null ? void 0 : l.call(r, ...o);
344
+ }
345
+ }),
346
+ {}
347
+ ), Pt = {
854
348
  page: 1,
855
349
  pageSize: 10
856
- };
857
-
858
- var proCurdProps = function proCurdProps() {
859
- return {
860
- /**
861
- * 配置(静态)
862
- */
863
- columns: {
864
- type: Array
865
- },
866
-
867
- /**
868
- * 配置(动态)
869
- * columns动态属性兼容
870
- */
871
- columnState: {
872
- type: Object
873
- },
874
-
875
- /**
876
- * 录入组件集
877
- */
878
- formElementMap: {
879
- type: Object
880
- },
881
-
882
- /**
883
- * 列表 或 详情 的唯一标识
884
- */
885
- rowKey: {
886
- type: String,
887
- "default": "id"
888
- },
889
-
890
- /**
891
- * operates
892
- */
893
- operates: {
894
- type: Array
895
- },
896
-
897
- /************************* 子组件props *******************************/
898
- listProps: {
899
- type: Object
900
- },
901
- formProps: {
902
- type: Object
903
- },
904
- descProps: {
905
- type: Object
906
- },
907
- modalProps: {
908
- type: Object
909
- }
910
- };
911
- };
912
-
913
- var CurdMethods = ["sendCurdEvent", "refreshList", "sendEvent", "sendRequest"];
914
- var Curd = defineComponent({
915
- props: _objectSpread2({}, proCurdProps()),
916
- setup: function setup(props, _ref) {
917
- var slots = _ref.slots,
918
- expose = _ref.expose;
919
-
920
- var _ref2 = useProModule(),
921
- elementMap = _ref2.elementMap,
922
- state = _ref2.state,
923
- sendEvent = _ref2.sendEvent,
924
- sendRequest = _ref2.sendRequest;
925
- /**
926
- * columns columnState 合并
927
- */
928
-
929
-
930
- var columns = computed(function () {
931
- return mergeStateToList(props.columns, props.columnState, function (item) {
932
- return getColumnFormItemName(item);
350
+ }, gt = () => ({
351
+ columns: {
352
+ type: Array
353
+ },
354
+ columnState: {
355
+ type: Object
356
+ },
357
+ formElementMap: {
358
+ type: Object
359
+ },
360
+ rowKey: {
361
+ type: String,
362
+ default: "id"
363
+ },
364
+ operates: {
365
+ type: Array
366
+ },
367
+ listProps: {
368
+ type: Object
369
+ },
370
+ formProps: {
371
+ type: Object
372
+ },
373
+ descProps: {
374
+ type: Object
375
+ },
376
+ modalProps: {
377
+ type: Object
378
+ }
379
+ }), ze = ["sendCurdEvent", "refreshList", "sendEvent", "sendRequest"], Ae = A({
380
+ props: {
381
+ ...gt()
382
+ },
383
+ setup: (e, {
384
+ slots: n,
385
+ expose: a
386
+ }) => {
387
+ const {
388
+ elementMap: t,
389
+ state: o,
390
+ sendEvent: r,
391
+ sendRequest: l
392
+ } = ue(), f = w(() => Ie(e.columns, e.columnState, (T) => Z(T))), y = (T, L = !0) => ve(e.formElementMap, T, L), p = (T, L) => Ke(t, T, L), c = (T, L) => {
393
+ const G = z(f.value, (R) => {
394
+ const j = P(R, ["extra", T]) || P(R, T);
395
+ return L ? j !== !1 : j;
933
396
  });
934
- });
935
- /*********************************** 渲染组件 ***************************************/
936
- // 获取FormItem VNode
937
-
938
- var getFormItemVNode = function getFormItemVNode(column) {
939
- var needRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
940
- return getFormItemEl(props.formElementMap, column, needRules);
941
- }; // 获取Item VNode
942
-
943
-
944
- var getItemVNode = function getItemVNode(column, value) {
945
- return getItemEl(elementMap, column, value);
946
- };
947
- /**
948
- * ${signName} 配置为true 会被选择
949
- * @param signName
950
- * @param opposite 如果为true,未配置(undefined)会被选择
951
- */
952
-
953
-
954
- var getSignColumns = function getSignColumns(signName, opposite) {
955
- var signColumns = filter$1(columns.value, function (item) {
956
- var sign = get(item, ["extra", signName]) || get(item, signName);
957
-
958
- if (opposite) {
959
- //不为false 即为选中
960
- return sign !== false;
961
- } //只有true 才为选中
962
-
963
-
964
- return sign;
397
+ return Ne(G, (R) => P(R, ["extra", `${T}Sort`]) || P(R, `${T}Sort`));
398
+ }, u = w(() => c("form", !0)), s = w(() => c("detail", !0)), i = w(() => c("table", !0)), d = w(() => c("search"));
399
+ let m;
400
+ const E = (T) => {
401
+ l(g.LIST, {
402
+ ...m,
403
+ ...T
965
404
  });
966
- return sortBy(signColumns, function (item) {
967
- return get(item, ["extra", "".concat(signName, "Sort")]) || get(item, "".concat(signName, "Sort"));
405
+ }, S = (T) => {
406
+ r({
407
+ type: T.action,
408
+ payload: I(T, "action", "source"),
409
+ source: T.source
968
410
  });
969
411
  };
970
-
971
- var formColumns = computed(function () {
972
- return getSignColumns("form", true);
973
- });
974
- var descColumns = computed(function () {
975
- return getSignColumns("detail", true);
976
- });
977
- var tableColumns = computed(function () {
978
- return getSignColumns("table", true);
979
- });
980
- var searchColumns = computed(function () {
981
- return getSignColumns("search");
982
- });
983
- /******************************** 逻辑 *************************************/
984
- //上一次发起列表请求的参数
985
-
986
- var prevListParams; //刷新列表
987
-
988
- var handleSearch = function handleSearch(extra) {
989
- sendRequest(CurdAction.LIST, _objectSpread2(_objectSpread2({}, prevListParams), extra));
990
- }; //发送事件
991
-
992
-
993
- var sendCurdEvent = function sendCurdEvent(event) {
994
- sendEvent({
995
- type: event.action,
996
- payload: omit(event, "action", "source"),
997
- source: event.source
998
- });
999
- }; //事件订阅
1000
-
1001
-
1002
- useModuleEvent(function (_ref3) {
1003
- var type = _ref3.type,
1004
- payload = _ref3.payload,
1005
- source = _ref3.source;
1006
-
1007
- //如果当前event存在source 不处理
1008
- if (source) {
412
+ De(({
413
+ type: T,
414
+ payload: L,
415
+ source: G
416
+ }) => {
417
+ if (G)
1009
418
  return;
1010
- }
1011
-
1012
- var action = type;
1013
- var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
1014
-
1015
- if (action === RequestAction.Success) {
1016
- //覆盖
1017
- action = get(payload, ["requestOpts", "action"]);
1018
- subAction = CurdSubAction.SUCCESS;
1019
- }
1020
-
1021
- var _ref4 = payload,
1022
- values = _ref4.values,
1023
- record = _ref4.record;
1024
-
1025
- switch (action) {
1026
- case CurdAction.LIST:
1027
- if (subAction === CurdSubAction.EMIT) {
1028
- prevListParams = values;
1029
- handleSearch();
1030
- }
1031
-
419
+ let R = T, j = L == null ? void 0 : L.type;
420
+ R === te.Success && (R = P(L, ["requestOpts", "action"]), j = D.SUCCESS);
421
+ const {
422
+ values: V,
423
+ record: de
424
+ } = L;
425
+ switch (R) {
426
+ case g.LIST:
427
+ j === D.EMIT && (m = V, E());
1032
428
  return;
1033
-
1034
- case CurdAction.ADD:
1035
- if (subAction === CurdSubAction.EXECUTE) {
1036
- sendRequest(CurdAction.ADD, values, state.detailData);
1037
- }
1038
-
429
+ case g.ADD:
430
+ j === D.EXECUTE && l(g.ADD, V, o.detailData);
1039
431
  return;
1040
-
1041
- case CurdAction.EDIT:
1042
- if (subAction === CurdSubAction.EXECUTE) {
1043
- sendRequest(CurdAction.EDIT, values, state.detailData);
1044
- }
1045
-
432
+ case g.EDIT:
433
+ j === D.EXECUTE && l(g.EDIT, V, o.detailData);
1046
434
  return;
1047
-
1048
- case CurdAction.DELETE:
1049
- if (subAction === CurdSubAction.EMIT) {
1050
- sendRequest(CurdAction.DELETE, record, props.rowKey);
1051
- } else if (subAction === CurdSubAction.SUCCESS) {
1052
- handleSearch();
1053
- }
1054
-
435
+ case g.DELETE:
436
+ j === D.EMIT ? l(g.DELETE, de, e.rowKey) : j === D.SUCCESS && E();
1055
437
  return;
1056
- } //非 CurdAction 五种操作的其他请求
1057
-
1058
-
1059
- if (action && type === CurdSubAction.EXECUTE) {
1060
- sendRequest(action, values);
1061
438
  }
439
+ R && T === D.EXECUTE && l(R, V);
1062
440
  });
1063
- var operateMap = reduce(props.operates, function (pair, item) {
1064
- return _objectSpread2(_objectSpread2({}, pair), {}, _defineProperty({}, item.action, item));
1065
- }, {}); //根据Action获取ICurdOperateOpts
1066
-
1067
- var getOperate = function getOperate(action) {
1068
- return get(operateMap, action);
1069
- };
1070
-
1071
- var listProps = computed(function () {
1072
- return props.listProps;
1073
- });
1074
- var formProps = computed(function () {
1075
- return props.formProps;
1076
- });
1077
- var descProps = computed(function () {
1078
- return props.descProps;
1079
- });
1080
- var modalProps = computed(function () {
1081
- return props.modalProps;
1082
- });
1083
- provideProCurd({
1084
- columns: columns,
1085
- getSignColumns: getSignColumns,
1086
- getFormItemVNode: getFormItemVNode,
1087
- getItemVNode: getItemVNode,
1088
- elementMap: elementMap,
1089
- formElementMap: props.formElementMap,
1090
- //
1091
- rowKey: props.rowKey,
1092
- curdState: state,
1093
- formColumns: formColumns,
1094
- descColumns: descColumns,
1095
- tableColumns: tableColumns,
1096
- searchColumns: searchColumns,
1097
- //
1098
- sendCurdEvent: sendCurdEvent,
1099
- //
1100
- operates: props.operates,
1101
- getOperate: getOperate,
1102
- //
1103
- refreshList: handleSearch,
1104
- //
1105
- listProps: listProps,
1106
- formProps: formProps,
1107
- descProps: descProps,
1108
- modalProps: modalProps
1109
- });
1110
- expose({
1111
- sendCurdEvent: sendCurdEvent,
1112
- refreshList: handleSearch
1113
- });
1114
- return function () {
1115
- var _slots$default;
1116
-
1117
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
441
+ const h = Y(e.operates, (T, L) => ({
442
+ ...T,
443
+ [L.action]: L
444
+ }), {}), b = (T) => P(h, T), C = w(() => e.listProps), x = w(() => e.formProps), B = w(() => e.descProps), $ = w(() => e.modalProps);
445
+ return bt({
446
+ columns: f,
447
+ getSignColumns: c,
448
+ getFormItemVNode: y,
449
+ getItemVNode: p,
450
+ elementMap: t,
451
+ formElementMap: e.formElementMap,
452
+ rowKey: e.rowKey,
453
+ curdState: o,
454
+ formColumns: u,
455
+ descColumns: s,
456
+ tableColumns: i,
457
+ searchColumns: d,
458
+ sendCurdEvent: S,
459
+ operates: e.operates,
460
+ getOperate: b,
461
+ refreshList: E,
462
+ listProps: C,
463
+ formProps: x,
464
+ descProps: B,
465
+ modalProps: $
466
+ }), a({
467
+ sendCurdEvent: S,
468
+ refreshList: E
469
+ }), () => {
470
+ var T;
471
+ return (T = n.default) == null ? void 0 : T.call(n);
1118
472
  };
1119
473
  }
1120
- });
1121
- var ProCurd = defineComponent({
1122
- props: _objectSpread2(_objectSpread2(_objectSpread2({}, omit(ProModule.props, "state", "requests")), Curd.props), {}, {
474
+ }), le = A({
475
+ props: {
476
+ ...I(pe.props, "state", "requests"),
477
+ ...Ae.props,
1123
478
  curdState: {
1124
479
  type: Object
1125
480
  }
1126
- }),
1127
- setup: function setup(props, _ref5) {
1128
- var _curdOperateOpts;
1129
-
1130
- var slots = _ref5.slots,
1131
- expose = _ref5.expose;
1132
- var moduleRef = ref();
1133
- var curdRef = ref();
1134
- var curdState = props.curdState || reactive({
481
+ },
482
+ setup: (e, {
483
+ slots: n,
484
+ expose: a
485
+ }) => {
486
+ const t = U(), o = U(), r = e.curdState || K({
1135
487
  detailData: {}
1136
- });
1137
- /****************** 请求处理 **********************/
1138
- //curd默认网络属性
1139
-
1140
- var curdOperateOpts = (_curdOperateOpts = {}, _defineProperty(_curdOperateOpts, CurdAction.LIST, {
1141
- convertParams: function convertParams(values) {
1142
- return values;
1143
- },
1144
- convertData: function convertData(actor) {
1145
- var _actor$res;
1146
-
1147
- return (_actor$res = actor.res) === null || _actor$res === void 0 ? void 0 : _actor$res.data;
488
+ }), l = {
489
+ [g.LIST]: {
490
+ convertParams: (c) => c,
491
+ convertData: (c) => {
492
+ var u;
493
+ return (u = c.res) == null ? void 0 : u.data;
494
+ },
495
+ loadingName: "listLoading",
496
+ stateName: "listData"
1148
497
  },
1149
- loadingName: "listLoading",
1150
- stateName: "listData"
1151
- }), _defineProperty(_curdOperateOpts, CurdAction.DETAIL, {
1152
- convertParams: function convertParams(record, rowKey) {
1153
- return pick(record, rowKey);
498
+ [g.DETAIL]: {
499
+ convertParams: (c, u) => k(c, u),
500
+ convertData: (c) => {
501
+ var u;
502
+ return (u = c.res) == null ? void 0 : u.data;
503
+ },
504
+ loadingName: "detailLoading",
505
+ stateName: "detailData",
506
+ label: "\u8BE6\u60C5"
1154
507
  },
1155
- convertData: function convertData(actor) {
1156
- var _actor$res2;
1157
-
1158
- return (_actor$res2 = actor.res) === null || _actor$res2 === void 0 ? void 0 : _actor$res2.data;
1159
- },
1160
- loadingName: "detailLoading",
1161
- stateName: "detailData",
1162
- label: "详情"
1163
- }), _defineProperty(_curdOperateOpts, CurdAction.ADD, {
1164
- convertParams: function convertParams(values, record) {
1165
- return {
1166
- body: _objectSpread2(_objectSpread2({}, record), values)
1167
- };
1168
- },
1169
- loadingName: "operateLoading",
1170
- label: "添加"
1171
- }), _defineProperty(_curdOperateOpts, CurdAction.EDIT, {
1172
- convertParams: function convertParams(values, record) {
1173
- return {
1174
- body: _objectSpread2(_objectSpread2({}, record), values)
1175
- };
508
+ [g.ADD]: {
509
+ convertParams: (c, u) => ({
510
+ body: {
511
+ ...u,
512
+ ...c
513
+ }
514
+ }),
515
+ loadingName: "operateLoading",
516
+ label: "\u6DFB\u52A0"
1176
517
  },
1177
- loadingName: "operateLoading",
1178
- label: "编辑"
1179
- }), _defineProperty(_curdOperateOpts, CurdAction.DELETE, {
1180
- convertParams: function convertParams(record, rowKey) {
1181
- return pick(record, rowKey);
518
+ [g.EDIT]: {
519
+ convertParams: (c, u) => ({
520
+ body: {
521
+ ...u,
522
+ ...c
523
+ }
524
+ }),
525
+ loadingName: "operateLoading",
526
+ label: "\u7F16\u8F91"
1182
527
  },
1183
- label: "删除"
1184
- }), _curdOperateOpts);
1185
- /****************************** columns分类 *************************************/
1186
-
1187
- var operates = map(props.operates, function (item) {
1188
- var curdOpts = get(curdOperateOpts, item.action);
1189
- return _objectSpread2(_objectSpread2({}, curdOpts), item);
1190
- }); //只取配置actor的项
1191
-
1192
- var requests = filter$1(operates, function (item) {
1193
- return item.actor;
1194
- });
1195
- var moduleKeys = keys(omit(ProModule.props, "state", "requests"));
1196
- expose({
1197
- sendCurdEvent: function sendCurdEvent(event) {
1198
- var _curdRef$value;
1199
-
1200
- (_curdRef$value = curdRef.value) === null || _curdRef$value === void 0 ? void 0 : _curdRef$value.sendCurdEvent(event);
528
+ [g.DELETE]: {
529
+ convertParams: (c, u) => k(c, u),
530
+ label: "\u5220\u9664"
531
+ }
532
+ }, f = O(e.operates, (c) => ({
533
+ ...P(l, c.action),
534
+ ...c
535
+ })), y = z(f, (c) => c.actor), p = N(I(pe.props, "state", "requests"));
536
+ return a({
537
+ sendCurdEvent: (c) => {
538
+ var u;
539
+ (u = o.value) == null || u.sendCurdEvent(c);
1201
540
  },
1202
- refreshList: function refreshList(extra) {
1203
- var _curdRef$value2;
1204
-
1205
- (_curdRef$value2 = curdRef.value) === null || _curdRef$value2 === void 0 ? void 0 : _curdRef$value2.refreshList(extra);
541
+ refreshList: (c) => {
542
+ var u;
543
+ (u = o.value) == null || u.refreshList(c);
1206
544
  },
1207
- sendEvent: function sendEvent(action) {
1208
- var _moduleRef$value;
1209
-
1210
- (_moduleRef$value = moduleRef.value) === null || _moduleRef$value === void 0 ? void 0 : _moduleRef$value.sendEvent(action);
545
+ sendEvent: (c) => {
546
+ var u;
547
+ (u = t.value) == null || u.sendEvent(c);
1211
548
  },
1212
- sendRequest: function sendRequest(requestNameOrAction) {
1213
- var _moduleRef$value2;
1214
-
1215
- for (var _len = arguments.length, params = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
1216
- params[_key - 1] = arguments[_key];
1217
- }
1218
-
1219
- (_moduleRef$value2 = moduleRef.value) === null || _moduleRef$value2 === void 0 ? void 0 : _moduleRef$value2.sendRequest.apply(_moduleRef$value2, [requestNameOrAction].concat(params));
549
+ sendRequest: (c, ...u) => {
550
+ var s;
551
+ (s = t.value) == null || s.sendRequest(c, ...u);
1220
552
  }
553
+ }), () => v(pe, M({
554
+ ref: t
555
+ }, k(e, p), {
556
+ state: r,
557
+ requests: y
558
+ }), {
559
+ default: () => [v(Ae, M({
560
+ ref: o
561
+ }, I(e, ...p, "curdState", "operates"), {
562
+ operates: f
563
+ }), n)]
1221
564
  });
1222
- return function () {
1223
- return createVNode(ProModule, mergeProps({
1224
- "ref": moduleRef
1225
- }, pick(props, moduleKeys), {
1226
- "state": curdState,
1227
- "requests": requests
1228
- }), {
1229
- "default": function _default() {
1230
- return [createVNode(Curd, mergeProps({
1231
- "ref": curdRef
1232
- }, omit.apply(void 0, [props].concat(_toConsumableArray(moduleKeys), ["curdState", "operates"])), {
1233
- "operates": operates
1234
- }), slots)];
1235
- }
1236
- });
1237
- };
1238
565
  }
1239
- });
1240
-
1241
- var modalCurdProps = function modalCurdProps() {
1242
- return {
1243
- defaultAddRecord: {
1244
- type: Object
1245
- }
1246
- };
1247
- };
1248
-
1249
- /**
1250
- * 事件处理
1251
- */
1252
- var ModalCurd = defineComponent({
1253
- props: _objectSpread2({}, modalCurdProps()),
1254
- setup: function setup(props) {
1255
- var _listProps$value;
1256
-
1257
- var _useProModule = useProModule(),
1258
- dispatch = _useProModule.dispatch,
1259
- sendRequest = _useProModule.sendRequest;
1260
-
1261
- var _useProCurd = useProCurd(),
1262
- rowKey = _useProCurd.rowKey,
1263
- curdState = _useProCurd.curdState,
1264
- listProps = _useProCurd.listProps,
1265
- getOperate = _useProCurd.getOperate,
1266
- refreshList = _useProCurd.refreshList;
1267
-
1268
- var pageState = listProps === null || listProps === void 0 ? void 0 : (_listProps$value = listProps.value) === null || _listProps$value === void 0 ? void 0 : _listProps$value.pageState; //发送详情接口
1269
-
1270
- var sendDetailRequest = function sendDetailRequest(record) {
1271
- var operateOpts = getOperate(CurdAction.DETAIL);
1272
-
1273
- if (operateOpts !== null && operateOpts !== void 0 && operateOpts.actor) {
1274
- //如果注册了详情接口 发起请求
1275
- sendRequest(CurdAction.DETAIL, record, rowKey);
1276
- } else {
1277
- //直接使用当前record作为详情数据
1278
- dispatch({
1279
- type: "detailData",
1280
- payload: record
1281
- });
1282
- }
1283
- };
1284
-
1285
- var dealDetail = function dealDetail(subAction, _ref) {
1286
- var record = _ref.record;
1287
-
1288
- if (subAction === CurdSubAction.EMIT) {
1289
- dispatch({
1290
- type: "mode",
1291
- payload: CurdCurrentMode.DETAIL
1292
- });
1293
- sendDetailRequest(record);
1294
- }
566
+ }), Tt = () => ({
567
+ defaultAddRecord: {
568
+ type: Object
569
+ }
570
+ }), Ee = A({
571
+ props: {
572
+ ...Tt()
573
+ },
574
+ setup: (e) => {
575
+ var i;
576
+ const {
577
+ dispatch: n,
578
+ sendRequest: a
579
+ } = ue(), {
580
+ rowKey: t,
581
+ curdState: o,
582
+ listProps: r,
583
+ getOperate: l,
584
+ refreshList: f
585
+ } = se(), y = (i = r == null ? void 0 : r.value) == null ? void 0 : i.pageState, p = (d) => {
586
+ const m = l(g.DETAIL);
587
+ m != null && m.actor ? a(g.DETAIL, d, t) : n({
588
+ type: "detailData",
589
+ payload: tt(d)
590
+ });
591
+ }, c = (d, {
592
+ record: m
593
+ }) => {
594
+ d === D.EMIT && (n({
595
+ type: "mode",
596
+ payload: F.DETAIL
597
+ }), p(m));
598
+ }, u = (d) => {
599
+ d === D.EMIT ? (n({
600
+ type: "mode",
601
+ payload: F.ADD
602
+ }), n({
603
+ type: "detailData",
604
+ payload: e.defaultAddRecord || {}
605
+ })) : d === D.SUCCESS && (y && (y.page = 1), f(), o.addAction === ne.CONTINUE ? n({
606
+ type: "detailData",
607
+ payload: e.defaultAddRecord || {}
608
+ }) : n({
609
+ type: "mode",
610
+ payload: void 0
611
+ }));
612
+ }, s = (d, {
613
+ record: m
614
+ }) => {
615
+ d === D.EMIT ? (n({
616
+ type: "mode",
617
+ payload: F.EDIT
618
+ }), p(m)) : d === D.SUCCESS && (n({
619
+ type: "mode",
620
+ payload: void 0
621
+ }), f());
1295
622
  };
1296
-
1297
- var dealAdd = function dealAdd(subAction) {
1298
- if (subAction === CurdSubAction.EMIT) {
1299
- dispatch({
1300
- type: "mode",
1301
- payload: CurdCurrentMode.ADD
1302
- });
1303
- dispatch({
1304
- type: "detailData",
1305
- payload: props.defaultAddRecord || {}
1306
- });
1307
- } else if (subAction === CurdSubAction.SUCCESS) {
1308
- //添加成功
1309
- if (pageState) {
1310
- pageState.page = 1; //重置当前页数
1311
- } //刷新List
1312
-
1313
-
1314
- refreshList();
1315
-
1316
- if (curdState.addAction === CurdAddAction.CONTINUE) {
1317
- dispatch({
1318
- type: "detailData",
1319
- payload: props.defaultAddRecord || {}
623
+ return De(({
624
+ type: d,
625
+ payload: m,
626
+ source: E
627
+ }) => {
628
+ if (E)
629
+ return;
630
+ let S = d, h = m == null ? void 0 : m.type;
631
+ const b = m == null ? void 0 : m.record;
632
+ switch (S === te.Success && (S = P(m, ["requestOpts", "action"]), h = D.SUCCESS), S) {
633
+ case g.DETAIL:
634
+ c(h, {
635
+ record: b
1320
636
  });
1321
- } else {
1322
- dispatch({
1323
- type: "mode",
1324
- payload: undefined
637
+ break;
638
+ case g.ADD:
639
+ u(h);
640
+ break;
641
+ case g.EDIT:
642
+ s(h, {
643
+ record: b
1325
644
  });
1326
- }
645
+ break;
1327
646
  }
1328
- };
1329
-
1330
- var dealEdit = function dealEdit(subAction, _ref2) {
1331
- var record = _ref2.record;
1332
-
1333
- if (subAction === CurdSubAction.EMIT) {
1334
- dispatch({
1335
- type: "mode",
1336
- payload: CurdCurrentMode.EDIT
1337
- });
1338
- sendDetailRequest(record);
1339
- } else if (subAction === CurdSubAction.SUCCESS) {
1340
- // 编辑成功
1341
- dispatch({
1342
- type: "mode",
1343
- payload: undefined
1344
- }); //刷新列表
1345
-
1346
- refreshList();
647
+ }), () => null;
648
+ }
649
+ }), Ut = A({
650
+ props: {
651
+ ...le.props,
652
+ ...Ee.props
653
+ },
654
+ setup: (e, {
655
+ slots: n,
656
+ expose: a
657
+ }) => {
658
+ const t = U();
659
+ a(J(ze, t));
660
+ const o = N(Ee.props);
661
+ return () => v(le, M({
662
+ ref: t
663
+ }, I(e, o)), {
664
+ default: () => {
665
+ var r;
666
+ return [v(Ee, k(e, o), null), (r = n.default) == null ? void 0 : r.call(n)];
1347
667
  }
668
+ });
669
+ }
670
+ }), Dt = () => ({
671
+ defaultAddRecord: {
672
+ type: Object
673
+ },
674
+ routeBack: {
675
+ type: Function
676
+ }
677
+ }), Se = A({
678
+ props: {
679
+ ...Dt()
680
+ },
681
+ setup: (e) => {
682
+ const n = it(), a = lt(), {
683
+ dispatch: t,
684
+ sendRequest: o
685
+ } = ue(), {
686
+ rowKey: r,
687
+ curdState: l
688
+ } = se(), f = (u) => {
689
+ u === D.PAGE && (t({
690
+ type: "mode",
691
+ payload: void 0
692
+ }), t({
693
+ type: "detailData",
694
+ payload: {}
695
+ }), t({
696
+ type: "detailLoading",
697
+ payload: !1
698
+ }), t({
699
+ type: "addAction",
700
+ payload: void 0
701
+ }));
702
+ }, y = (u, {
703
+ record: s
704
+ }) => {
705
+ u === D.EMIT ? n.push({
706
+ path: `${a.path}/detail`,
707
+ query: k(s, r)
708
+ }) : u === D.PAGE && (t({
709
+ type: "mode",
710
+ payload: F.DETAIL
711
+ }), o(g.DETAIL, a.query, r));
712
+ }, p = (u) => {
713
+ u === D.EMIT ? n.push({
714
+ path: `${a.path}/add`
715
+ }) : u === D.PAGE ? (t({
716
+ type: "mode",
717
+ payload: F.ADD
718
+ }), t({
719
+ type: "detailData",
720
+ payload: e.defaultAddRecord || {}
721
+ })) : u === D.SUCCESS && (l.addAction === ne.CONTINUE ? t({
722
+ type: "detailData",
723
+ payload: e.defaultAddRecord || {}
724
+ }) : e.routeBack ? e.routeBack(g.ADD) : n.go(-1));
725
+ }, c = (u, {
726
+ record: s
727
+ }) => {
728
+ u === D.EMIT ? n.push({
729
+ path: `${a.path}/edit`,
730
+ query: k(s, r)
731
+ }) : u === D.PAGE ? (t({
732
+ type: "mode",
733
+ payload: F.EDIT
734
+ }), o(g.DETAIL, a.query, r)) : u === D.SUCCESS && (e.routeBack ? e.routeBack(g.EDIT) : n.go(-1));
1348
735
  };
1349
-
1350
- useModuleEvent(function (_ref3) {
1351
- var type = _ref3.type,
1352
- payload = _ref3.payload,
1353
- source = _ref3.source;
1354
-
1355
- if (source) {
736
+ return De(({
737
+ type: u,
738
+ payload: s,
739
+ source: i
740
+ }) => {
741
+ if (i)
1356
742
  return;
1357
- }
1358
-
1359
- var action = type;
1360
- var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
1361
- var record = payload === null || payload === void 0 ? void 0 : payload.record;
1362
-
1363
- if (action === RequestAction.Success) {
1364
- //覆盖
1365
- action = get(payload, ["requestOpts", "action"]);
1366
- subAction = CurdSubAction.SUCCESS;
1367
- }
1368
-
1369
- switch (action) {
1370
- case CurdAction.DETAIL:
1371
- dealDetail(subAction, {
1372
- record: record
743
+ let d = u, m = s == null ? void 0 : s.type;
744
+ const E = s == null ? void 0 : s.record;
745
+ switch (d === te.Success && (d = P(s, ["requestOpts", "action"]), m = D.SUCCESS), d) {
746
+ case g.LIST:
747
+ f(m);
748
+ break;
749
+ case g.DETAIL:
750
+ y(m, {
751
+ record: E
1373
752
  });
1374
753
  break;
1375
-
1376
- case CurdAction.ADD:
1377
- dealAdd(subAction);
754
+ case g.ADD:
755
+ p(m);
1378
756
  break;
1379
-
1380
- case CurdAction.EDIT:
1381
- dealEdit(subAction, {
1382
- record: record
757
+ case g.EDIT:
758
+ c(m, {
759
+ record: E
1383
760
  });
1384
761
  break;
1385
762
  }
1386
- });
1387
- return function () {
1388
- return null;
1389
- };
763
+ }), () => null;
1390
764
  }
1391
- });
1392
- var ProModalCurd = defineComponent({
1393
- props: _objectSpread2(_objectSpread2({}, ProCurd.props), ModalCurd.props),
1394
- setup: function setup(props, _ref4) {
1395
- var slots = _ref4.slots,
1396
- expose = _ref4.expose;
1397
- var curdRef = ref();
1398
- expose(createExpose(CurdMethods, curdRef));
1399
- var invalidKeys = keys(ModalCurd.props);
1400
- return function () {
1401
- var _slots$default;
1402
-
1403
- return createVNode(ProCurd, mergeProps({
1404
- "ref": curdRef
1405
- }, omit(props, invalidKeys)), {
1406
- "default": function _default() {
1407
- return [createVNode(ModalCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
1408
- }
1409
- });
1410
- };
765
+ }), Bt = A({
766
+ props: {
767
+ ...le.props,
768
+ ...Se.props
769
+ },
770
+ setup: (e, {
771
+ slots: n,
772
+ expose: a
773
+ }) => {
774
+ const t = U();
775
+ a(J(ze, t));
776
+ const o = N(Se.props);
777
+ return () => v(le, M({
778
+ ref: t
779
+ }, I(e, o)), {
780
+ default: () => {
781
+ var r;
782
+ return [v(Se, k(e, o), null), (r = n.default) == null ? void 0 : r.call(n)];
783
+ }
784
+ });
1411
785
  }
1412
786
  });
1413
-
1414
- var pageCurdProps = function pageCurdProps() {
1415
- return {
1416
- defaultAddRecord: {
1417
- type: Object
1418
- },
1419
- routeBack: {
787
+ function It(e) {
788
+ return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !ie(e);
789
+ }
790
+ const $t = (e, n) => A({
791
+ props: {
792
+ ...e.props,
793
+ renderItem: {
1420
794
  type: Function
795
+ },
796
+ signName: {
797
+ type: String
1421
798
  }
1422
- };
1423
- };
1424
-
1425
- var PageCurd = defineComponent({
1426
- props: _objectSpread2({}, pageCurdProps()),
1427
- setup: function setup(props) {
1428
- var router = useRouter();
1429
- var route = useRoute();
1430
-
1431
- var _useProModule = useProModule(),
1432
- dispatch = _useProModule.dispatch,
1433
- sendRequest = _useProModule.sendRequest;
1434
-
1435
- var _useProCurd = useProCurd(),
1436
- rowKey = _useProCurd.rowKey,
1437
- curdState = _useProCurd.curdState;
1438
-
1439
- var dealList = function dealList(subAction) {
1440
- if (subAction === CurdSubAction.PAGE) {
1441
- //其实就是个重置过程
1442
- dispatch({
1443
- type: "mode",
1444
- payload: undefined
1445
- });
1446
- dispatch({
1447
- type: "detailData",
1448
- payload: {}
1449
- });
1450
- dispatch({
1451
- type: "detailLoading",
1452
- payload: false
1453
- });
1454
- dispatch({
1455
- type: "addAction",
1456
- payload: undefined
1457
- });
1458
- }
1459
- };
1460
-
1461
- var dealDetail = function dealDetail(subAction, _ref) {
1462
- var record = _ref.record;
1463
-
1464
- if (subAction === CurdSubAction.EMIT) {
1465
- router.push({
1466
- path: "".concat(route.path, "/detail"),
1467
- query: pick(record, rowKey)
1468
- });
1469
- } else if (subAction === CurdSubAction.PAGE) {
1470
- dispatch({
1471
- type: "mode",
1472
- payload: CurdCurrentMode.DETAIL
1473
- });
1474
- sendRequest(CurdAction.DETAIL, route.query, rowKey);
1475
- }
1476
- };
1477
-
1478
- var dealAdd = function dealAdd(subAction) {
1479
- if (subAction === CurdSubAction.EMIT) {
1480
- router.push({
1481
- path: "".concat(route.path, "/add")
1482
- });
1483
- } else if (subAction === CurdSubAction.PAGE) {
1484
- dispatch({
1485
- type: "mode",
1486
- payload: CurdCurrentMode.ADD
1487
- });
1488
- dispatch({
1489
- type: "detailData",
1490
- payload: props.defaultAddRecord || {}
1491
- });
1492
- } else if (subAction === CurdSubAction.SUCCESS) {
1493
- if (curdState.addAction === CurdAddAction.CONTINUE) {
1494
- dispatch({
1495
- type: "detailData",
1496
- payload: props.defaultAddRecord || {}
1497
- });
1498
- } else {
1499
- props.routeBack ? props.routeBack(CurdAction.ADD) : router.go(-1);
1500
- }
1501
- }
1502
- };
1503
-
1504
- var dealEdit = function dealEdit(subAction, _ref2) {
1505
- var record = _ref2.record;
1506
-
1507
- if (subAction === CurdSubAction.EMIT) {
1508
- router.push({
1509
- path: "".concat(route.path, "/edit"),
1510
- query: pick(record, rowKey)
1511
- });
1512
- } else if (subAction === CurdSubAction.PAGE) {
1513
- dispatch({
1514
- type: "mode",
1515
- payload: CurdCurrentMode.EDIT
799
+ },
800
+ setup: (a, {
801
+ slots: t
802
+ }) => {
803
+ const {
804
+ getItemVNode: o,
805
+ curdState: r,
806
+ descColumns: l,
807
+ getSignColumns: f
808
+ } = se(), y = w(() => {
809
+ const p = a.signName ? f(a.signName) : l.value;
810
+ return O(p, (c) => {
811
+ var d;
812
+ let u;
813
+ const s = (d = a.renderItem) == null ? void 0 : d.call(a, c);
814
+ if (s)
815
+ return s;
816
+ const i = P(r.detailData, c.dataIndex);
817
+ return v(n, M({
818
+ key: c.dataIndex,
819
+ label: c.title
820
+ }, P(c.extra, "desc")), It(u = o(c, i)) ? u : {
821
+ default: () => [u]
1516
822
  });
1517
- sendRequest(CurdAction.DETAIL, route.query, rowKey);
1518
- } else if (subAction === CurdSubAction.SUCCESS) {
1519
- props.routeBack ? props.routeBack(CurdAction.EDIT) : router.go(-1);
1520
- }
1521
- };
1522
-
1523
- useModuleEvent(function (_ref3) {
1524
- var type = _ref3.type,
1525
- payload = _ref3.payload,
1526
- source = _ref3.source;
1527
-
1528
- if (source) {
1529
- return;
1530
- }
1531
-
1532
- var action = type;
1533
- var subAction = payload === null || payload === void 0 ? void 0 : payload.type;
1534
- var record = payload === null || payload === void 0 ? void 0 : payload.record;
1535
-
1536
- if (action === RequestAction.Success) {
1537
- //覆盖
1538
- action = get(payload, ["requestOpts", "action"]);
1539
- subAction = CurdSubAction.SUCCESS;
1540
- }
1541
-
1542
- switch (action) {
1543
- case CurdAction.LIST:
1544
- dealList(subAction);
1545
- break;
1546
-
1547
- case CurdAction.DETAIL:
1548
- dealDetail(subAction, {
1549
- record: record
1550
- });
1551
- break;
1552
-
1553
- case CurdAction.ADD:
1554
- dealAdd(subAction);
1555
- break;
1556
-
1557
- case CurdAction.EDIT:
1558
- dealEdit(subAction, {
1559
- record: record
1560
- });
1561
- break;
1562
- }
823
+ });
824
+ });
825
+ return () => v(e, a, {
826
+ default: () => {
827
+ var p, c;
828
+ return [(p = t.start) == null ? void 0 : p.call(t), y.value, (c = t.default) == null ? void 0 : c.call(t)];
829
+ },
830
+ ...I(t, "default", "start")
1563
831
  });
1564
- return function () {
1565
- return null;
1566
- };
1567
832
  }
1568
- });
1569
- var ProPageCurd = defineComponent({
1570
- props: _objectSpread2(_objectSpread2({}, ProCurd.props), PageCurd.props),
1571
- setup: function setup(props, _ref4) {
1572
- var slots = _ref4.slots,
1573
- expose = _ref4.expose;
1574
- var curdRef = ref();
1575
- expose(createExpose(CurdMethods, curdRef));
1576
- var invalidKeys = keys(PageCurd.props);
1577
- return function () {
1578
- var _slots$default;
1579
-
1580
- return createVNode(ProCurd, mergeProps({
1581
- "ref": curdRef
1582
- }, omit(props, invalidKeys)), {
1583
- "default": function _default() {
1584
- return [createVNode(PageCurd, pick(props, invalidKeys), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
1585
- }
1586
- });
1587
- };
833
+ }), Ct = () => ({
834
+ signName: {
835
+ type: String
836
+ },
837
+ modelName: {
838
+ type: String,
839
+ default: "detailData"
840
+ },
841
+ operateBar: {
842
+ type: Boolean,
843
+ default: !0
844
+ },
845
+ showContinueAdd: {
846
+ type: Boolean,
847
+ default: !1
848
+ },
849
+ okText: {
850
+ type: String,
851
+ default: "\u786E\u5B9A"
852
+ },
853
+ okButtonProps: {
854
+ type: Object
855
+ },
856
+ continueText: {
857
+ type: String,
858
+ default: "\u786E\u5B9A\u5E76\u7EE7\u7EED"
859
+ },
860
+ continueButtonProps: {
861
+ type: Object
1588
862
  }
1589
- });
1590
-
1591
- function _isSlot(s) {
1592
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
1593
- }
1594
-
1595
- var createCurdDesc = function createCurdDesc(Descriptions, DescriptionsItem) {
1596
- return defineComponent({
1597
- props: _objectSpread2(_objectSpread2({}, Descriptions.props), {}, {
1598
- //重写Item content
1599
- renderItem: {
1600
- type: Function
1601
- },
1602
- //标记名称
1603
- signName: {
1604
- type: String
863
+ }), Vt = (e, n, a, t) => A({
864
+ inheritAttrs: !1,
865
+ props: {
866
+ ...e.props,
867
+ ...Ct()
868
+ },
869
+ setup: (o, {
870
+ slots: r,
871
+ attrs: l,
872
+ expose: f
873
+ }) => {
874
+ const {
875
+ elementMap: y,
876
+ formElementMap: p,
877
+ curdState: c,
878
+ formColumns: u,
879
+ getSignColumns: s,
880
+ sendCurdEvent: i
881
+ } = se(), d = U(), m = w(() => o.signName ? s(o.signName) : u.value), E = (b, C) => {
882
+ if (l.onFinish) {
883
+ l.onFinish(b, C);
884
+ return;
1605
885
  }
1606
- }),
1607
- setup: function setup(props, _ref) {
1608
- var slots = _ref.slots;
1609
-
1610
- var _useProCurd = useProCurd(),
1611
- getItemVNode = _useProCurd.getItemVNode,
1612
- curdState = _useProCurd.curdState,
1613
- descColumns = _useProCurd.descColumns,
1614
- getSignColumns = _useProCurd.getSignColumns;
1615
-
1616
- var descVNodes = computed(function () {
1617
- var columns = props.signName ? getSignColumns(props.signName) : descColumns.value;
1618
- return map(columns, function (item) {
1619
- var _slot;
1620
-
1621
- var _props$renderItem;
1622
-
1623
- var vn = (_props$renderItem = props.renderItem) === null || _props$renderItem === void 0 ? void 0 : _props$renderItem.call(props, item);
1624
-
1625
- if (vn) {
1626
- return vn;
1627
- }
1628
-
1629
- var value = get(curdState.detailData, item.dataIndex);
1630
- return createVNode(DescriptionsItem, mergeProps({
1631
- "key": item.dataIndex,
1632
- "label": item.title
1633
- }, get(item.extra, "desc")), _isSlot(_slot = getItemVNode(item, value)) ? _slot : {
1634
- "default": function _default() {
1635
- return [_slot];
1636
- }
1637
- });
1638
- });
886
+ c.mode === F.EDIT ? i({
887
+ action: g.EDIT,
888
+ type: D.EXECUTE,
889
+ values: b
890
+ }) : i({
891
+ action: g.ADD,
892
+ type: D.EXECUTE,
893
+ values: b
1639
894
  });
1640
- return function () {
1641
- var _slots$start, _slots$default;
1642
-
1643
- return createVNode(Descriptions, props, _objectSpread2({
1644
- "default": function _default() {
1645
- return [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), descVNodes.value, (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
1646
- }
1647
- }, omit(slots, "default", "start")));
1648
- };
1649
- }
1650
- });
1651
- };
1652
-
1653
- var proCurdAddOrEditProps = function proCurdAddOrEditProps() {
1654
- return {
1655
- //标记名称
1656
- signName: {
1657
- type: String
1658
- },
1659
- //form model 绑定的curdState中的对象
1660
- modelName: {
1661
- type: String,
1662
- "default": "detailData"
1663
- },
1664
- //是否使用operate bar
1665
- operateBar: {
1666
- type: Boolean,
1667
- "default": true
1668
- },
1669
- //显示 确定并继续 按钮
1670
- showContinueAdd: {
1671
- type: Boolean,
1672
- "default": false
1673
- },
1674
- //
1675
- okText: {
1676
- type: String,
1677
- "default": "确定"
1678
- },
1679
- okButtonProps: {
1680
- type: Object
1681
- },
1682
- //
1683
- continueText: {
1684
- type: String,
1685
- "default": "确定并继续"
1686
- },
1687
- continueButtonProps: {
1688
- type: Object
1689
- }
1690
- };
1691
- };
1692
-
1693
- var createCurdForm = function createCurdForm(Form, Button, convertFormProps, formMethods) {
1694
- return defineComponent({
1695
- inheritAttrs: false,
1696
- props: _objectSpread2(_objectSpread2({}, Form.props), proCurdAddOrEditProps()),
1697
- setup: function setup(props, _ref) {
1698
- var slots = _ref.slots,
1699
- attrs = _ref.attrs,
1700
- expose = _ref.expose;
1701
-
1702
- var _useProCurd = useProCurd(),
1703
- elementMap = _useProCurd.elementMap,
1704
- formElementMap = _useProCurd.formElementMap,
1705
- curdState = _useProCurd.curdState,
1706
- formColumns = _useProCurd.formColumns,
1707
- getSignColumns = _useProCurd.getSignColumns,
1708
- sendCurdEvent = _useProCurd.sendCurdEvent;
1709
-
1710
- var formRef = ref();
1711
- var columns = computed(function () {
1712
- if (props.signName) {
1713
- return getSignColumns(props.signName);
895
+ }, S = () => {
896
+ var b;
897
+ c.addAction = ne.NORMAL, (b = d.value) == null || b.submit();
898
+ }, h = () => {
899
+ var b;
900
+ c.addAction = ne.CONTINUE, (b = d.value) == null || b.submit();
901
+ };
902
+ return f(J(t, d)), () => v(e, M({
903
+ ref: d
904
+ }, I(l, "onFinish"), o, {
905
+ elementMap: o.elementMap || y,
906
+ formElementMap: o.formElementMap || p,
907
+ columns: o.columns || m.value,
908
+ model: o.model || c[o.modelName],
909
+ readonly: c.mode === F.DETAIL,
910
+ onFinish: E
911
+ }, a == null ? void 0 : a(c)), {
912
+ default: () => {
913
+ var b, C, x, B, $;
914
+ return [(b = r.divide) == null ? void 0 : b.call(r), o.operateBar && v("div", {
915
+ class: "pro-curd-form-operate"
916
+ }, [(C = r.operateStart) == null ? void 0 : C.call(r), c.mode !== F.DETAIL && v(n, M({
917
+ onClick: S
918
+ }, o.okButtonProps, {
919
+ loading: c.operateLoading
920
+ }), {
921
+ default: () => [o.okText]
922
+ }), (x = r.operateCenter) == null ? void 0 : x.call(r), o.showContinueAdd && c.mode === F.ADD && v(n, M({
923
+ onClick: h
924
+ }, o.continueButtonProps, {
925
+ loading: c.operateLoading
926
+ }), {
927
+ default: () => [o.continueText]
928
+ }), (B = r.operateEnd) == null ? void 0 : B.call(r)]), ($ = r.default) == null ? void 0 : $.call(r)];
929
+ },
930
+ ...I(r, "default", "divide", "operateStart", "operateCenter", "operateEnd")
931
+ });
932
+ }
933
+ }), At = () => ({
934
+ extraInSearch: {
935
+ type: Boolean,
936
+ default: void 0
937
+ },
938
+ searchProps: {
939
+ type: Object
940
+ },
941
+ tableProps: {
942
+ type: Object
943
+ },
944
+ paginationProps: {
945
+ type: Object
946
+ },
947
+ showPagination: {
948
+ type: Boolean,
949
+ default: !0
950
+ },
951
+ pageState: {
952
+ type: Object
953
+ }
954
+ }), Xt = (e, n) => A({
955
+ props: {
956
+ ...At()
957
+ },
958
+ setup: (a, {
959
+ slots: t
960
+ }) => {
961
+ const {
962
+ elementMap: o,
963
+ formElementMap: r,
964
+ curdState: l,
965
+ searchColumns: f,
966
+ tableColumns: y,
967
+ sendCurdEvent: p,
968
+ operates: c
969
+ } = se(), u = a.pageState || K({
970
+ ...Pt
971
+ });
972
+ let s;
973
+ const i = () => {
974
+ p({
975
+ action: g.LIST,
976
+ type: D.EMIT,
977
+ values: {
978
+ ...s,
979
+ ...u
1714
980
  }
1715
-
1716
- return formColumns.value;
1717
981
  });
1718
-
1719
- var handleFinish = function handleFinish(values, originValues) {
1720
- if (attrs.onFinish) {
1721
- attrs.onFinish(values, originValues);
1722
- return;
1723
- }
1724
-
1725
- if (curdState.mode === CurdCurrentMode.EDIT) {
1726
- //edit
1727
- sendCurdEvent({
1728
- action: CurdAction.EDIT,
1729
- type: CurdSubAction.EXECUTE,
1730
- values: values
1731
- });
1732
- } else {
1733
- //add
1734
- sendCurdEvent({
1735
- action: CurdAction.ADD,
1736
- type: CurdSubAction.EXECUTE,
1737
- values: values
1738
- });
1739
- }
1740
- };
1741
-
1742
- var handleAdd = function handleAdd() {
1743
- var _formRef$value;
1744
-
1745
- curdState.addAction = CurdAddAction.NORMAL;
1746
- (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
982
+ }, d = (S) => {
983
+ s = S, u.page = 1, i();
984
+ }, m = O(z(c, (S) => {
985
+ const h = S.action;
986
+ return h === g.DETAIL || h === g.EDIT || h === g.DELETE || S.tableOperate;
987
+ }), (S) => {
988
+ const h = {
989
+ ...k(S, "label", "element", "disabled", "sort", "onClick"),
990
+ show: nt(S == null ? void 0 : S.show) ? !1 : S == null ? void 0 : S.show,
991
+ value: S.action
1747
992
  };
1748
-
1749
- var handleContinueAdd = function handleContinueAdd() {
1750
- var _formRef$value2;
1751
-
1752
- curdState.addAction = CurdAddAction.CONTINUE;
1753
- (_formRef$value2 = formRef.value) === null || _formRef$value2 === void 0 ? void 0 : _formRef$value2.submit();
1754
- };
1755
-
1756
- expose(createExpose(formMethods, formRef));
1757
- return function () {
1758
- var _slots$divide, _slots$operateStart, _slots$operateCenter, _slots$operateEnd, _slots$default;
1759
-
1760
- return createVNode(Form, mergeProps({
1761
- "ref": formRef
1762
- }, omit(attrs, "onFinish"), props, {
1763
- "elementMap": props.elementMap || elementMap,
1764
- "formElementMap": props.formElementMap || formElementMap,
1765
- "columns": props.columns || columns.value,
1766
- "model": props.model || curdState[props.modelName],
1767
- "readonly": curdState.mode === CurdCurrentMode.DETAIL,
1768
- "onFinish": handleFinish
1769
- }, convertFormProps === null || convertFormProps === void 0 ? void 0 : convertFormProps(curdState)), _objectSpread2({
1770
- "default": function _default() {
1771
- return [(_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), props.operateBar && createVNode("div", {
1772
- "class": "pro-curd-form-operate"
1773
- }, [(_slots$operateStart = slots.operateStart) === null || _slots$operateStart === void 0 ? void 0 : _slots$operateStart.call(slots), curdState.mode !== CurdCurrentMode.DETAIL && createVNode(Button, mergeProps({
1774
- "onClick": handleAdd
1775
- }, props.okButtonProps, {
1776
- "loading": curdState.operateLoading
1777
- }), {
1778
- "default": function _default() {
1779
- return [props.okText];
1780
- }
1781
- }), (_slots$operateCenter = slots.operateCenter) === null || _slots$operateCenter === void 0 ? void 0 : _slots$operateCenter.call(slots), props.showContinueAdd && curdState.mode === CurdCurrentMode.ADD && createVNode(Button, mergeProps({
1782
- "onClick": handleContinueAdd
1783
- }, props.continueButtonProps, {
1784
- "loading": curdState.operateLoading
1785
- }), {
1786
- "default": function _default() {
1787
- return [props.continueText];
1788
- }
1789
- }), (_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)];
1790
- }
1791
- }, omit(slots, "default", "divide", "operateStart", "operateCenter", "operateEnd")));
1792
- };
1793
- }
1794
- });
1795
- };
1796
-
1797
- var proCurdListProps = function proCurdListProps() {
1798
- return {
1799
- /**
1800
- * extra 是否放到SearchForm中
1801
- */
1802
- extraInSearch: {
1803
- type: Boolean,
1804
- "default": undefined
1805
- },
1806
- //search
1807
- searchProps: {
1808
- type: Object
1809
- },
1810
- //table
1811
- tableProps: {
1812
- type: Object
1813
- },
1814
- //pagination是否展示
1815
- paginationProps: {
1816
- type: Object
1817
- },
1818
- showPagination: {
1819
- type: Boolean,
1820
- "default": true
1821
- },
1822
- //pageState
1823
- pageState: {
1824
- type: Object
1825
- }
1826
- };
1827
- };
1828
-
1829
- var createCurdList = function createCurdList(SearchForm, Table) {
1830
- return defineComponent({
1831
- props: _objectSpread2({}, proCurdListProps()),
1832
- setup: function setup(props, _ref) {
1833
- var slots = _ref.slots;
1834
-
1835
- var _useProCurd = useProCurd(),
1836
- elementMap = _useProCurd.elementMap,
1837
- formElementMap = _useProCurd.formElementMap,
1838
- curdState = _useProCurd.curdState,
1839
- searchColumns = _useProCurd.searchColumns,
1840
- tableColumns = _useProCurd.tableColumns,
1841
- sendCurdEvent = _useProCurd.sendCurdEvent,
1842
- operates = _useProCurd.operates;
1843
- /******************* search pagination ********************/
1844
-
1845
-
1846
- var pageState = props.pageState || reactive(_objectSpread2({}, defaultPage));
1847
- var prevValues;
1848
-
1849
- var handleSearch = function handleSearch() {
1850
- sendCurdEvent({
1851
- action: CurdAction.LIST,
1852
- type: CurdSubAction.EMIT,
1853
- values: _objectSpread2(_objectSpread2({}, prevValues), pageState)
993
+ return h.onClick || (h.onClick = (b) => {
994
+ p({
995
+ action: S.action,
996
+ type: D.EMIT,
997
+ record: b
1854
998
  });
1855
- };
1856
-
1857
- var executeSearchWithResetPage = function executeSearchWithResetPage(values) {
1858
- prevValues = values;
1859
- pageState.page = 1;
1860
- handleSearch();
1861
- };
1862
- /******************* table ********************/
1863
-
1864
-
1865
- var tableOperateItems = map(filter$1(operates, function (item) {
1866
- var action = item.action;
1867
- return action === CurdAction.DETAIL || action === CurdAction.EDIT || action === CurdAction.DELETE || item.tableOperate;
1868
- }), function (operate) {
1869
- var item = _objectSpread2(_objectSpread2({}, pick(operate, "label", "element", "disabled", "sort", "onClick")), {}, {
1870
- show: !isUndefined(operate === null || operate === void 0 ? void 0 : operate.show) ? operate === null || operate === void 0 ? void 0 : operate.show : false,
1871
- value: operate.action
1872
- });
1873
-
1874
- if (!item.onClick) {
1875
- item.onClick = function (record) {
1876
- sendCurdEvent({
1877
- action: operate.action,
1878
- type: CurdSubAction.EMIT,
1879
- record: record
1880
- });
1881
- };
1882
- }
1883
-
1884
- return item;
1885
- }); //新配置的operate item,添加默认发送事件方法
1886
-
1887
- var convertOperateItems = function convertOperateItems(list) {
1888
- return map(list, function (item) {
1889
- if (!item.onClick) {
1890
- return _objectSpread2(_objectSpread2({}, item), {}, {
1891
- onClick: function onClick(record) {
1892
- sendCurdEvent({
1893
- action: "operate",
1894
- type: item.value,
1895
- record: record
1896
- });
1897
- }
1898
- });
1899
- }
1900
-
1901
- return item;
999
+ }), h;
1000
+ }), E = (S) => O(S, (h) => h.onClick ? h : {
1001
+ ...h,
1002
+ onClick: (b) => {
1003
+ p({
1004
+ action: "operate",
1005
+ type: h.value,
1006
+ record: b
1902
1007
  });
1903
- };
1904
-
1905
- return function () {
1906
- var _curdState$listData, _slots$start, _props$searchProps, _slots$divide, _slots$divide2, _slots$footerStart, _slots$pagination, _curdState$listData2, _slots$footerEnd, _slots$end;
1907
-
1908
- var tableProps = props.tableProps;
1909
-
1910
- var rewriteTableProps = _objectSpread2(_objectSpread2({
1911
- elementMap: elementMap,
1912
- columns: tableColumns.value
1913
- }, omit(tableProps, "slots", "operate")), {}, {
1914
- operate: mergeWith({
1915
- items: tableOperateItems
1916
- }, tableProps === null || tableProps === void 0 ? void 0 : tableProps.operate, function (objValue, srcValue) {
1917
- if (isArray(objValue) && isArray(srcValue)) {
1918
- return concat(objValue, convertOperateItems(srcValue));
1919
- }
1920
- }),
1921
- paginationState: {
1922
- page: pageState.page,
1923
- pageSize: pageState.pageSize
1924
- },
1925
- loading: curdState.listLoading,
1926
- dataSource: (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
1927
- });
1928
-
1929
- var extra = slots.extra ? createVNode("div", {
1930
- "class": "pro-curd-list-extra"
1931
- }, [slots.extra()]) : null;
1932
- return createVNode(Fragment, null, [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), slots.search ? slots.search({
1933
- executeSearchWithResetPage: executeSearchWithResetPage
1934
- }) : createVNode(SearchForm, mergeProps({
1935
- "formElementMap": formElementMap,
1936
- "columns": searchColumns.value
1937
- }, omit(props.searchProps, "slots"), {
1938
- "onFinish": executeSearchWithResetPage
1939
- }), _objectSpread2({
1940
- "default": function _default() {
1941
- return [props.extraInSearch && extra];
1942
- }
1943
- }, (_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(rewriteTableProps) : createVNode(Table, rewriteTableProps, tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), props.showPagination && createVNode("div", {
1944
- "class": "pro-curd-list-footer"
1945
- }, [(_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)]), (_slots$end = slots.end) === null || _slots$end === void 0 ? void 0 : _slots$end.call(slots)]);
1946
- };
1947
- }
1948
- });
1949
- };
1950
-
1951
- /**
1952
- * ProFormList ctx
1953
- */
1954
-
1955
- var ProFormListKey = Symbol("pro-form-list");
1956
- var useProFormList = function useProFormList() {
1957
- return inject(ProFormListKey);
1958
- };
1959
- var provideProFormList = function provideProFormList(ctx) {
1960
- provide(ProFormListKey, ctx);
1961
- };
1962
- var FormListProvider = defineComponent({
1008
+ }
1009
+ });
1010
+ return () => {
1011
+ var C, x, B, $, T, L, G, R, j, V;
1012
+ const S = a.tableProps, h = {
1013
+ elementMap: o,
1014
+ columns: y.value,
1015
+ ...I(S, "slots", "operate"),
1016
+ operate: je({
1017
+ items: m
1018
+ }, S == null ? void 0 : S.operate, (de, Ce) => {
1019
+ if (q(de) && q(Ce))
1020
+ return rt(de, E(Ce));
1021
+ }),
1022
+ paginationState: {
1023
+ page: u.page,
1024
+ pageSize: u.pageSize
1025
+ },
1026
+ loading: l.listLoading,
1027
+ dataSource: (C = l.listData) == null ? void 0 : C.dataSource
1028
+ }, b = t.extra ? v("div", {
1029
+ class: "pro-curd-list-extra"
1030
+ }, [t.extra()]) : null;
1031
+ return v(ae, null, [(x = t.start) == null ? void 0 : x.call(t), t.search ? t.search({
1032
+ executeSearchWithResetPage: d
1033
+ }) : v(e, M({
1034
+ formElementMap: r,
1035
+ columns: f.value
1036
+ }, I(a.searchProps, "slots"), {
1037
+ onFinish: d
1038
+ }), {
1039
+ default: () => [a.extraInSearch && b],
1040
+ ...(B = a.searchProps) == null ? void 0 : B.slots
1041
+ }), ($ = t.divide) == null ? void 0 : $.call(t), !a.extraInSearch && b, t.table ? t.table(h) : v(n, h, S == null ? void 0 : S.slots), (T = t.divide2) == null ? void 0 : T.call(t), a.showPagination && v("div", {
1042
+ class: "pro-curd-list-footer"
1043
+ }, [(L = t.footerStart) == null ? void 0 : L.call(t), (R = t.pagination) == null ? void 0 : R.call(t, u, (G = l.listData) == null ? void 0 : G.total, i), (j = t.footerEnd) == null ? void 0 : j.call(t)]), (V = t.end) == null ? void 0 : V.call(t)]);
1044
+ };
1045
+ }
1046
+ }), Ge = Symbol("pro-form-list"), We = () => re(Ge), _e = (e) => {
1047
+ oe(Ge, e);
1048
+ }, Lt = A({
1963
1049
  props: {
1964
1050
  pathList: {
1965
1051
  type: Array
1966
1052
  }
1967
1053
  },
1968
- setup: function setup(props, _ref) {
1969
- var slots = _ref.slots;
1970
- provideProFormList({
1971
- pathList: props.pathList
1972
- });
1973
- return function () {
1974
- var _slots$default;
1975
-
1976
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
1054
+ setup: (e, {
1055
+ slots: n
1056
+ }) => (_e({
1057
+ pathList: e.pathList
1058
+ }), () => {
1059
+ var a;
1060
+ return (a = n.default) == null ? void 0 : a.call(n);
1061
+ })
1062
+ }), zt = (e) => A({
1063
+ props: {
1064
+ ...e.props,
1065
+ rowKey: {
1066
+ type: String,
1067
+ default: "id"
1068
+ }
1069
+ },
1070
+ setup: (n, {
1071
+ slots: a
1072
+ }) => {
1073
+ const {
1074
+ formState: t,
1075
+ readonly: o
1076
+ } = Je(), r = We(), l = Xe(n.name), f = r != null && r.pathList ? [...r.pathList, ...l] : l, y = () => {
1077
+ let c = P(t, f);
1078
+ q(c) || (c = []), c.push({
1079
+ [n.rowKey]: new Date().valueOf()
1080
+ }), _(t, f, c);
1081
+ }, p = (c) => {
1082
+ const u = P(t, f);
1083
+ X(u) <= 0 || u.splice(c, 1);
1977
1084
  };
1085
+ return () => v(e, I(n, "rowKey"), {
1086
+ default: () => {
1087
+ var c;
1088
+ return [O(P(t, f), (u, s) => v(Lt, {
1089
+ key: u[n.rowKey] || s,
1090
+ pathList: [...f, s]
1091
+ }, {
1092
+ default: () => {
1093
+ var i, d, m;
1094
+ return [v("div", {
1095
+ class: "pro-form-list-item"
1096
+ }, [(i = a.default) == null ? void 0 : i.call(a), !o.value && v(ae, null, [v("div", {
1097
+ class: "pro-form-list-item-add",
1098
+ onClick: y
1099
+ }, [(d = a.itemAdd) == null ? void 0 : d.call(a)]), v("div", {
1100
+ class: "pro-form-list-item-minus",
1101
+ onClick: () => p(s)
1102
+ }, [(m = a.itemMinus) == null ? void 0 : m.call(a)])])])];
1103
+ }
1104
+ })), !o.value && v("div", {
1105
+ class: "pro-form-list-add",
1106
+ onClick: y
1107
+ }, [(c = a.add) == null ? void 0 : c.call(a)])];
1108
+ }
1109
+ });
1110
+ }
1111
+ }), He = Symbol("pro-form"), Je = () => re(He), Ot = (e) => {
1112
+ oe(He, e);
1113
+ }, Le = () => ({
1114
+ model: {
1115
+ type: Object
1116
+ },
1117
+ readonly: {
1118
+ type: Boolean,
1119
+ default: void 0
1120
+ },
1121
+ showState: {
1122
+ type: Object
1123
+ },
1124
+ showStateRules: {
1125
+ type: Object
1126
+ },
1127
+ readonlyState: {
1128
+ type: Object
1129
+ },
1130
+ readonlyStateRules: {
1131
+ type: Object
1132
+ },
1133
+ disableState: {
1134
+ type: Object
1135
+ },
1136
+ disableStateRules: {
1137
+ type: Object
1138
+ },
1139
+ columns: {
1140
+ type: Array
1141
+ },
1142
+ columnState: {
1143
+ type: Object
1144
+ },
1145
+ elementMap: {
1146
+ type: Object
1147
+ },
1148
+ formElementMap: {
1149
+ type: Object
1150
+ },
1151
+ needRules: {
1152
+ type: Boolean,
1153
+ default: !0
1154
+ },
1155
+ provideExtra: {
1156
+ type: Object
1157
+ }
1158
+ }), Gt = (e, n, a) => A({
1159
+ inheritAttrs: !1,
1160
+ props: {
1161
+ ...e.props,
1162
+ ...Le(),
1163
+ ...I(n.props, "items")
1164
+ },
1165
+ setup: (t, {
1166
+ slots: o,
1167
+ emit: r,
1168
+ expose: l,
1169
+ attrs: f
1170
+ }) => {
1171
+ const y = t.model || K({}), p = t.showState || K({}), c = t.readonlyState || K({}), u = t.disableState || K({});
1172
+ ce(() => {
1173
+ t.showStateRules && W(t.showStateRules, (h, b) => {
1174
+ p[b] = h(y);
1175
+ }), t.readonlyStateRules && W(t.readonlyStateRules, (h, b) => {
1176
+ c[b] = h(y);
1177
+ }), t.disableStateRules && W(t.disableStateRules, (h, b) => {
1178
+ u[b] = h(y);
1179
+ });
1180
+ }, y);
1181
+ const s = w(() => t.readonly), i = w(() => Ie(t.columns, t.columnState, (h) => Z(h))), d = (h) => {
1182
+ const b = vt(h, p, t.showStateRules);
1183
+ r("finish", b, h);
1184
+ }, m = U();
1185
+ l(J(a, m)), Ot({
1186
+ formState: y,
1187
+ showState: p,
1188
+ readonlyState: c,
1189
+ disableState: u,
1190
+ elementMap: t.elementMap,
1191
+ formElementMap: t.formElementMap,
1192
+ readonly: s,
1193
+ columns: i,
1194
+ formRef: m,
1195
+ ...t.provideExtra
1196
+ }), _e({});
1197
+ const E = N(Le()), S = N(I(n.props, "items"));
1198
+ return () => v(e, M({
1199
+ ref: m
1200
+ }, I(f, "onFinish"), I(t, ...E, ...S, "onFinish"), {
1201
+ model: y,
1202
+ onFinish: d
1203
+ }), {
1204
+ default: () => {
1205
+ var h, b;
1206
+ return [(h = o.start) == null ? void 0 : h.call(o), t.formElementMap && X(i.value) > 0 && v(ae, null, [t.row ? v(n, {
1207
+ row: t.row,
1208
+ col: t.col,
1209
+ items: O(i.value, (C) => ({
1210
+ rowKey: Z(C),
1211
+ vNode: ve(t.formElementMap, C, t.needRules),
1212
+ col: P(C, ["extra", "col"])
1213
+ }))
1214
+ }, null) : O(i.value, (C) => ve(t.formElementMap, C, t.needRules))]), (b = o.default) == null ? void 0 : b.call(o)];
1215
+ },
1216
+ ...I(o, "default")
1217
+ });
1978
1218
  }
1979
1219
  });
1980
-
1981
- var createFormList = function createFormList(FormItem) {
1982
- return defineComponent({
1983
- props: _objectSpread2(_objectSpread2({}, FormItem.props), {}, {
1984
- //每行默认id
1985
- rowKey: {
1986
- type: String,
1987
- "default": "id"
1220
+ let me;
1221
+ (function(e) {
1222
+ e.AUTO = "AUTO", e.MANUAL = "MANUAL";
1223
+ })(me || (me = {}));
1224
+ const Oe = () => ({
1225
+ model: {
1226
+ type: Object
1227
+ },
1228
+ initEmit: {
1229
+ type: Boolean,
1230
+ default: !0
1231
+ },
1232
+ searchMode: {
1233
+ type: String,
1234
+ default: me.AUTO
1235
+ },
1236
+ columns: {
1237
+ type: Array
1238
+ },
1239
+ debounceKeys: {
1240
+ type: Array
1241
+ },
1242
+ debounceTypes: {
1243
+ type: Array,
1244
+ default: ["text"]
1245
+ },
1246
+ debounceTime: {
1247
+ type: Number,
1248
+ default: 800
1249
+ }
1250
+ }), Wt = (e, n, a) => A({
1251
+ props: {
1252
+ ...e.props,
1253
+ ...n,
1254
+ ...Oe()
1255
+ },
1256
+ setup: (t, {
1257
+ slots: o,
1258
+ expose: r
1259
+ }) => {
1260
+ const l = t.model || K({}), f = new Set(t.debounceTypes), y = O(z(t.columns, (d) => {
1261
+ const m = qe(d);
1262
+ return f.has(m);
1263
+ }), (d) => Z(d)), p = U();
1264
+ r(J(a, p));
1265
+ const c = () => {
1266
+ var d;
1267
+ (d = p.value) == null || d.submit();
1268
+ }, u = at(() => {
1269
+ c();
1270
+ }, t.debounceTime);
1271
+ ce(() => {
1272
+ t.initEmit && c();
1273
+ }, []);
1274
+ const s = (d, m, E) => Pe(E, (S) => P(d, S) !== P(m, S));
1275
+ dt((d, m) => {
1276
+ if (t.searchMode !== me.AUTO)
1277
+ return;
1278
+ const E = X(t.debounceKeys) > 0 ? t.debounceKeys : y;
1279
+ if (X(E) > 0 && s(d, m, E)) {
1280
+ u();
1281
+ return;
1988
1282
  }
1989
- }),
1990
- setup: function setup(props, _ref2) {
1991
- var slots = _ref2.slots;
1992
-
1993
- var _useProForm = useProForm(),
1994
- formState = _useProForm.formState,
1995
- readonly = _useProForm.readonly;
1996
-
1997
- var formListCtx = useProFormList();
1998
- var nameList = convertPathToList(props.name);
1999
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
2000
-
2001
- var handleAdd = function handleAdd() {
2002
- var targetList = get(formState, path);
2003
-
2004
- if (!isArray(targetList)) {
2005
- targetList = [];
2006
- }
2007
-
2008
- targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
2009
- set(formState, path, targetList);
2010
- };
2011
-
2012
- var handleRemove = function handleRemove(index) {
2013
- var targetList = get(formState, path);
2014
-
2015
- if (size(targetList) <= 0) {
2016
- return;
2017
- }
2018
-
2019
- targetList.splice(index, 1);
2020
- };
2021
-
2022
- return function () {
2023
- var _slots$add;
2024
-
2025
- return createVNode(FormItem, omit(props, "rowKey"), {
2026
- "default": function _default() {
2027
- return [map(get(formState, path), function (item, index) {
2028
- var _slots$default2, _slots$itemAdd, _slots$itemMinus;
2029
-
2030
- return createVNode(FormListProvider, {
2031
- "key": item[props.rowKey] || index,
2032
- "pathList": [].concat(_toConsumableArray(path), [index])
2033
- }, {
2034
- "default": function _default() {
2035
- return [createVNode("div", {
2036
- "class": "pro-form-list-item"
2037
- }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode(Fragment, null, [createVNode("div", {
2038
- "class": "pro-form-list-item-add",
2039
- "onClick": handleAdd
2040
- }, [(_slots$itemAdd = slots.itemAdd) === null || _slots$itemAdd === void 0 ? void 0 : _slots$itemAdd.call(slots)]), createVNode("div", {
2041
- "class": "pro-form-list-item-minus",
2042
- "onClick": function onClick() {
2043
- return handleRemove(index);
2044
- }
2045
- }, [(_slots$itemMinus = slots.itemMinus) === null || _slots$itemMinus === void 0 ? void 0 : _slots$itemMinus.call(slots)])])])];
2046
- }
2047
- });
2048
- }), !readonly.value && createVNode("div", {
2049
- "class": "pro-form-list-add",
2050
- "onClick": handleAdd
2051
- }, [(_slots$add = slots.add) === null || _slots$add === void 0 ? void 0 : _slots$add.call(slots)])];
2052
- }
2053
- });
2054
- };
2055
- }
2056
- });
2057
- };
2058
-
2059
- var ProFormKey = Symbol("pro-form");
2060
- var useProForm = function useProForm() {
2061
- return inject(ProFormKey);
2062
- };
2063
-
2064
- var provideProForm = function provideProForm(ctx) {
2065
- provide(ProFormKey, ctx);
2066
- };
2067
-
2068
- var proFormProps = function proFormProps() {
2069
- return {
2070
- /**
2071
- * 同 antd 或 element form中的model
2072
- */
2073
- model: {
2074
- type: Object
2075
- },
2076
-
2077
- /**
2078
- * 子组件是否只读样式
2079
- */
2080
- readonly: {
2081
- type: Boolean,
2082
- "default": undefined
2083
- },
2084
-
2085
- /**
2086
- * FormComponent 根据此项来确定组件是否显示
2087
- * rules 根据rules中方法生成showState对象
2088
- */
2089
- showState: {
2090
- type: Object
2091
- },
2092
- showStateRules: {
2093
- type: Object
2094
- },
2095
-
2096
- /**
2097
- * 是否只读
2098
- */
2099
- readonlyState: {
2100
- type: Object
2101
- },
2102
- readonlyStateRules: {
2103
- type: Object
2104
- },
2105
-
2106
- /**
2107
- * 是否disabled
2108
- */
2109
- disableState: {
2110
- type: Object
2111
- },
2112
- disableStateRules: {
2113
- type: Object
2114
- },
2115
-
2116
- /**
2117
- *
2118
- */
2119
- columns: {
2120
- type: Array
2121
- },
2122
- columnState: {
2123
- type: Object
2124
- },
2125
-
2126
- /**
2127
- * 展示控件集合,readonly模式下使用这些组件渲染
2128
- */
2129
- elementMap: {
2130
- type: Object
2131
- },
2132
-
2133
- /**
2134
- * 录入控件集合
2135
- */
2136
- formElementMap: {
2137
- type: Object
2138
- },
2139
-
2140
- /**
2141
- * 是否启用rules验证
2142
- */
2143
- needRules: {
2144
- type: Boolean,
2145
- "default": true
2146
- },
2147
-
2148
- /**
2149
- * provide传递
2150
- */
2151
- provideExtra: {
2152
- type: Object
2153
- }
2154
- };
2155
- };
2156
-
2157
- var createForm = function createForm(Form, Grid, formMethods) {
2158
- return defineComponent({
2159
- inheritAttrs: false,
2160
- props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), proFormProps()), omit(Grid.props, "items")),
2161
- setup: function setup(props, _ref) {
2162
- var slots = _ref.slots,
2163
- emit = _ref.emit,
2164
- expose = _ref.expose,
2165
- attrs = _ref.attrs;
2166
- var formState = props.model || reactive({}); //组件状态相关
2167
-
2168
- var showState = props.showState || reactive({});
2169
- var readonlyState = props.readonlyState || reactive({});
2170
- var disableState = props.disableState || reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
2171
-
2172
- useEffect(function () {
2173
- if (props.showStateRules) {
2174
- forEach(props.showStateRules, function (fn, key) {
2175
- showState[key] = fn(formState);
2176
- });
2177
- }
2178
-
2179
- if (props.readonlyStateRules) {
2180
- forEach(props.readonlyStateRules, function (fn, key) {
2181
- readonlyState[key] = fn(formState);
2182
- });
2183
- }
2184
-
2185
- if (props.disableStateRules) {
2186
- forEach(props.disableStateRules, function (fn, key) {
2187
- disableState[key] = fn(formState);
2188
- });
2189
- }
2190
- }, formState); //readonly
2191
-
2192
- var readonly = computed(function () {
2193
- return props.readonly;
2194
- }); //columns合并
2195
-
2196
- var columns = computed(function () {
2197
- return mergeStateToList(props.columns, props.columnState, function (item) {
2198
- return getColumnFormItemName(item);
2199
- });
2200
- });
2201
-
2202
- var handleFinish = function handleFinish(values) {
2203
- //删除不显示的值再触发事件
2204
- var showValues = getValidValues(values, showState, props.showStateRules);
2205
- emit("finish", showValues, values);
2206
- };
2207
-
2208
- var formRef = ref();
2209
- expose(createExpose(formMethods, formRef));
2210
- provideProForm(_objectSpread2({
2211
- formState: formState,
2212
- showState: showState,
2213
- readonlyState: readonlyState,
2214
- disableState: disableState,
2215
- //
2216
- elementMap: props.elementMap,
2217
- formElementMap: props.formElementMap,
2218
- //
2219
- readonly: readonly,
2220
- //
2221
- columns: columns,
2222
- //
2223
- formRef: formRef
2224
- }, props.provideExtra)); //为了不warning ...
2225
-
2226
- provideProFormList({});
2227
- var invalidKeys = keys(proFormProps());
2228
- var gridKeys = keys(omit(Grid.props, "items"));
2229
- return function () {
2230
- var _slots$start, _slots$default;
2231
-
2232
- return createVNode(Form, mergeProps({
2233
- "ref": formRef
2234
- }, omit(attrs, "onFinish"), omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), _toConsumableArray(gridKeys), ["onFinish"])), {
2235
- "model": formState,
2236
- "onFinish": handleFinish
2237
- }), _objectSpread2({
2238
- "default": function _default() {
2239
- 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, {
2240
- "row": props.row,
2241
- "col": props.col,
2242
- "items": map(columns.value, function (item) {
2243
- return {
2244
- rowKey: getColumnFormItemName(item),
2245
- vNode: getFormItemEl(props.formElementMap, item, props.needRules),
2246
- col: get(item, ["extra", "col"])
2247
- };
2248
- })
2249
- }, null) : map(columns.value, function (item) {
2250
- return getFormItemEl(props.formElementMap, item, props.needRules);
2251
- })]), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
2252
- }
2253
- }, omit(slots, "default")));
2254
- };
2255
- }
2256
- });
2257
- };
2258
-
2259
- var SearchMode;
2260
-
2261
- (function (SearchMode) {
2262
- SearchMode["AUTO"] = "AUTO";
2263
- SearchMode["MANUAL"] = "MANUAL";
2264
- })(SearchMode || (SearchMode = {}));
2265
-
2266
- var proSearchFormProps = function proSearchFormProps() {
2267
- return {
2268
- /**
2269
- * 需要监听的对象
2270
- */
2271
- model: {
2272
- type: Object
2273
- },
2274
-
2275
- /**
2276
- * 初始化触发 onFinish
2277
- */
2278
- initEmit: {
2279
- type: Boolean,
2280
- "default": true
2281
- },
2282
-
2283
- /**
2284
- * 模式 自动触发或者手动触发 onFinish
2285
- */
2286
- searchMode: {
2287
- type: String,
2288
- "default": SearchMode.AUTO
2289
- },
2290
-
2291
- /**
2292
- * 配置 同ProForm中的columns
2293
- * 可以根据column中valueType计算出默认的debounceKeys
2294
- */
2295
- columns: {
2296
- type: Array
2297
- },
2298
-
2299
- /**
2300
- * 需要debounce处理的字段
2301
- */
2302
- debounceKeys: {
2303
- type: Array
2304
- },
2305
- //默认 valueType 为 text 的控件会debounce处理
2306
- debounceTypes: {
2307
- type: Array,
2308
- "default": ["text"]
2309
- },
2310
- debounceTime: {
2311
- type: Number,
2312
- "default": 800
2313
- }
2314
- };
2315
- };
2316
-
2317
- /**
2318
- * 该组件只是个模式,最终返回null,不做任何渲染,应配合着ProForm的包装类一起使用
2319
- * 针对传入的model(监听对象)做相应的finish(回调)处理
2320
- */
2321
- var createSearchForm = function createSearchForm(Form, Props, formMethods) {
2322
- return defineComponent({
2323
- props: _objectSpread2(_objectSpread2(_objectSpread2({}, Form.props), Props), proSearchFormProps()),
2324
- setup: function setup(props, _ref) {
2325
- var slots = _ref.slots,
2326
- expose = _ref.expose;
2327
- var formState = props.model || reactive({});
2328
- var valueTypeSet = new Set(props.debounceTypes); //根据column valueType 算出默认需要debounce处理的属性集合
2329
-
2330
- var defaultDebounceKeys = map(filter$1(props.columns, function (column) {
2331
- var valueType = getColumnValueType(column); //默认input组件的触发事件需要debounce处理
2332
-
2333
- return valueTypeSet.has(valueType);
2334
- }), function (column) {
2335
- return getColumnFormItemName(column);
2336
- });
2337
- var formRef = ref();
2338
- expose(createExpose(formMethods, formRef));
2339
-
2340
- var handleFinish = function handleFinish() {
2341
- var _formRef$value;
2342
-
2343
- (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
2344
- };
2345
-
2346
- var debounceFinish = debounce(function () {
2347
- handleFinish();
2348
- }, props.debounceTime); //初始化
2349
-
2350
- useEffect(function () {
2351
- if (props.initEmit) {
2352
- handleFinish();
2353
- }
2354
- }, []);
2355
-
2356
- var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
2357
- return some(debounceKeys, function (key) {
2358
- return get(state, key) !== get(prevState, key);
2359
- });
2360
- }; //监听
2361
-
2362
-
2363
- useWatch(function (state, prevState) {
2364
- if (props.searchMode !== SearchMode.AUTO) {
2365
- return;
2366
- } //如果改变的值中包括debounceKeys中注册的 延时触发
2367
-
2368
-
2369
- var debounceKeys = size(props.debounceKeys) > 0 ? props.debounceKeys : defaultDebounceKeys;
2370
-
2371
- if (size(debounceKeys) > 0 && isDebounceDataChange(state, prevState, debounceKeys)) {
2372
- debounceFinish();
2373
- return;
2374
- }
2375
-
2376
- handleFinish();
2377
- }, function () {
2378
- return clone(formState);
1283
+ c();
1284
+ }, () => ot(l));
1285
+ const i = N(I(Oe(), "columns"));
1286
+ return () => v(e, M({
1287
+ ref: p
1288
+ }, I(t, i), {
1289
+ model: l
1290
+ }), o);
1291
+ }
1292
+ }), we = () => ({
1293
+ readonly: {
1294
+ type: Boolean,
1295
+ default: void 0
1296
+ },
1297
+ fieldProps: {
1298
+ type: Object
1299
+ },
1300
+ showProps: {
1301
+ type: Object
1302
+ },
1303
+ slots: {
1304
+ type: Object
1305
+ }
1306
+ }), _t = (e, n) => ({
1307
+ InputComp: a,
1308
+ valueType: t,
1309
+ name: o
1310
+ }) => A({
1311
+ name: o,
1312
+ props: {
1313
+ ...e.props,
1314
+ ...we()
1315
+ },
1316
+ setup: (r, {
1317
+ slots: l
1318
+ }) => {
1319
+ const {
1320
+ formState: f,
1321
+ showState: y,
1322
+ readonlyState: p,
1323
+ disableState: c,
1324
+ readonly: u,
1325
+ elementMap: s
1326
+ } = Je(), i = We(), d = w(() => ye(r.readonly) ? r.readonly : ye(p[r.name]) ? p[r.name] : u.value), m = Xe(r.name), E = i != null && i.pathList ? [...i.pathList, ...m] : m, S = (b) => {
1327
+ _(f, E, b);
1328
+ }, h = N(we());
1329
+ return () => {
1330
+ const b = P(y, E);
1331
+ if (ye(b) && !b)
1332
+ return null;
1333
+ const C = P(f, E), x = P(s, t);
1334
+ return v(e, M(I(r, ...h, "name", "slots"), {
1335
+ name: E
1336
+ }), {
1337
+ default: () => [d.value ? v(ae, null, [x ? v(x, M({
1338
+ value: C
1339
+ }, r.fieldProps, {
1340
+ showProps: r.showProps
1341
+ }), l) : v("span", null, [C])]) : v(a, M(n(C, S, P(c, E)), r.fieldProps), l)],
1342
+ ...r.slots
2379
1343
  });
2380
- var invalidKeys = keys(omit(proSearchFormProps(), "columns"));
2381
- return function () {
2382
- return createVNode(Form, mergeProps({
2383
- "ref": formRef
2384
- }, omit(props, invalidKeys), {
2385
- "model": formState
2386
- }), slots);
2387
- };
2388
- }
2389
- });
2390
- };
2391
-
2392
- var proFormItemProps = function proFormItemProps() {
2393
- return {
2394
- readonly: {
2395
- type: Boolean,
2396
- "default": undefined
2397
- },
2398
- fieldProps: {
2399
- type: Object
2400
- },
2401
- showProps: {
2402
- type: Object
2403
- },
2404
- slots: {
2405
- type: Object
2406
- }
2407
- };
2408
- };
2409
-
2410
- var createFormItemCompFn = function createFormItemCompFn(FormItem, convertInputCompProps) {
2411
- return function (_ref) {
2412
- var InputComp = _ref.InputComp,
2413
- valueType = _ref.valueType,
2414
- name = _ref.name;
2415
- return defineComponent({
2416
- name: name,
2417
- props: _objectSpread2(_objectSpread2({}, FormItem.props), proFormItemProps()),
2418
- setup: function setup(props, _ref2) {
2419
- var slots = _ref2.slots;
2420
-
2421
- var _useProForm = useProForm(),
2422
- formState = _useProForm.formState,
2423
- showState = _useProForm.showState,
2424
- readonlyState = _useProForm.readonlyState,
2425
- disableState = _useProForm.disableState,
2426
- formReadonly = _useProForm.readonly,
2427
- elementMap = _useProForm.elementMap;
2428
-
2429
- var formListCtx = useProFormList(); //优先级 props.readonly > readonlyState > formContext.readonly
2430
-
2431
- var readonly = computed(function () {
2432
- if (isBoolean(props.readonly)) {
2433
- return props.readonly;
2434
- } else if (isBoolean(readonlyState[props.name])) {
2435
- return readonlyState[props.name];
2436
- }
2437
-
2438
- return formReadonly.value;
2439
- });
2440
- var nameList = convertPathToList(props.name);
2441
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
2442
-
2443
- var setValue = function setValue(v) {
2444
- set(formState, path, v);
2445
- };
2446
-
2447
- var invalidKeys = keys(proFormItemProps());
2448
- return function () {
2449
- var show = get(showState, path);
2450
-
2451
- if (isBoolean(show) && !show) {
2452
- return null;
2453
- }
2454
-
2455
- var value = get(formState, path); //valueType对应的展示组件
2456
-
2457
- var ShowComp = get(elementMap, valueType);
2458
- return createVNode(FormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name", "slots"])), {
2459
- "name": path
2460
- }), _objectSpread2({
2461
- "default": function _default() {
2462
- return [readonly.value ? createVNode(Fragment, null, [ShowComp ? createVNode(ShowComp, mergeProps({
2463
- "value": value
2464
- }, props.fieldProps, {
2465
- "showProps": props.showProps
2466
- }), slots) : createVNode("span", null, [value])]) : createVNode(InputComp, mergeProps(convertInputCompProps(value, setValue, get(disableState, path)), props.fieldProps), slots)];
2467
- }
2468
- }, props.slots));
2469
- };
1344
+ };
1345
+ }
1346
+ }), Qe = Symbol("pro-table"), Ht = () => re(Qe), wt = (e) => {
1347
+ oe(Qe, e);
1348
+ }, Me = () => ({
1349
+ operate: {
1350
+ type: Object
1351
+ },
1352
+ columnEmptyText: {
1353
+ type: String
1354
+ },
1355
+ column: {
1356
+ type: Object
1357
+ },
1358
+ columns: {
1359
+ type: Array
1360
+ },
1361
+ columnState: {
1362
+ type: Object
1363
+ },
1364
+ elementMap: {
1365
+ type: Object
1366
+ },
1367
+ serialNumber: {
1368
+ type: Boolean
1369
+ },
1370
+ paginationState: {
1371
+ type: Object
1372
+ },
1373
+ provideExtra: {
1374
+ type: Object
1375
+ }
1376
+ }), Jt = (e, n, a) => A({
1377
+ props: {
1378
+ ...e.props,
1379
+ ...n,
1380
+ ...Me()
1381
+ },
1382
+ setup: (t, {
1383
+ slots: o,
1384
+ expose: r
1385
+ }) => {
1386
+ const l = () => ({
1387
+ title: "\u5E8F\u53F7",
1388
+ dataIndex: "serialNumber",
1389
+ width: 80,
1390
+ ...t.column,
1391
+ customRender: ({
1392
+ index: u
1393
+ }) => {
1394
+ var s, i;
1395
+ return ((s = t.paginationState) == null ? void 0 : s.page) && ((i = t.paginationState) == null ? void 0 : i.pageSize) ? t.paginationState.pageSize * (t.paginationState.page - 1) + u + 1 : u + 1;
2470
1396
  }
2471
- });
2472
- };
2473
- };
2474
-
2475
- var ProTableKey = Symbol("pro-table");
2476
- var useProTable = function useProTable() {
2477
- return inject(ProTableKey);
2478
- };
2479
-
2480
- var provideProTable = function provideProTable(ctx) {
2481
- provide(ProTableKey, ctx);
2482
- };
2483
-
2484
- var proTableProps = function proTableProps() {
2485
- return {
2486
- //操作栏
2487
- operate: {
2488
- type: Object
2489
- },
2490
- //默认空字符串
2491
- columnEmptyText: {
2492
- type: String
2493
- },
2494
-
2495
- /**
2496
- * 公共column,会merge到columns item中
2497
- */
2498
- column: {
2499
- type: Object
2500
- },
2501
- //
2502
- columns: {
2503
- type: Array
2504
- },
2505
- columnState: {
2506
- type: Object
2507
- },
2508
-
2509
- /**
2510
- * 展示控件集合,readonly模式下使用这些组件渲染
2511
- */
2512
- elementMap: {
2513
- type: Object
2514
- },
2515
-
2516
- /**
2517
- * 序号
2518
- */
2519
- serialNumber: {
2520
- type: Boolean
2521
- },
2522
-
2523
- /**
2524
- * 分页
2525
- */
2526
- paginationState: {
2527
- type: Object
2528
- },
2529
-
2530
- /**
2531
- * provide传递
2532
- */
2533
- provideExtra: {
2534
- type: Object
2535
- }
2536
- };
2537
- };
2538
-
2539
- var createTable = function createTable(Table, Props, tableMethods) {
2540
- return defineComponent({
2541
- props: _objectSpread2(_objectSpread2(_objectSpread2({}, Table.props), Props), proTableProps()),
2542
- setup: function setup(props, _ref) {
2543
- var slots = _ref.slots,
2544
- expose = _ref.expose;
2545
-
2546
- var createNumberColumn = function createNumberColumn() {
2547
- return _objectSpread2(_objectSpread2({
2548
- title: "序号",
2549
- dataIndex: "serialNumber",
2550
- width: 80
2551
- }, props.column), {}, {
2552
- customRender: function customRender(_ref2) {
2553
- var _props$paginationStat, _props$paginationStat2;
2554
-
2555
- var index = _ref2.index;
2556
-
2557
- 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) {
2558
- return props.paginationState.pageSize * (props.paginationState.page - 1) + index + 1;
1397
+ }), f = () => {
1398
+ const u = t.operate, s = O(u.items, (d) => ({
1399
+ ...d,
1400
+ ...P(u.itemState, d.value)
1401
+ })), i = Ne(s, (d) => d.sort);
1402
+ return {
1403
+ ...t.column,
1404
+ title: "\u64CD\u4F5C",
1405
+ dataIndex: "operate",
1406
+ fixed: "right",
1407
+ ...u.column,
1408
+ customRender: ({
1409
+ record: d
1410
+ }) => {
1411
+ const m = z(i, (E) => E.show && H(E.show) ? E.show(d) : E.show !== !1);
1412
+ return v("div", {
1413
+ class: "pro-table-operate"
1414
+ }, [O(m, (E) => H(E.element) ? E.element(d, E) : v("div", {
1415
+ class: "pro-table-operate-item",
1416
+ key: E.value,
1417
+ onClick: () => {
1418
+ var S;
1419
+ (S = E.onClick) == null || S.call(E, d);
2559
1420
  }
2560
-
2561
- return index + 1;
2562
- }
2563
- });
2564
- };
2565
-
2566
- var createOperateColumn = function createOperateColumn() {
2567
- var operate = props.operate; //将itemState补充的信息拼到item中
2568
-
2569
- var items = map(operate.items, function (i) {
2570
- return _objectSpread2(_objectSpread2({}, i), get(operate.itemState, i.value));
2571
- }); //排序
2572
-
2573
- var sortedItems = sortBy(items, function (item) {
2574
- return item.sort;
2575
- });
2576
- return _objectSpread2(_objectSpread2(_objectSpread2({}, props.column), {}, {
2577
- title: "操作",
2578
- dataIndex: "operate",
2579
- fixed: "right"
2580
- }, operate.column), {}, {
2581
- customRender: function customRender(_ref3) {
2582
- var record = _ref3.record;
2583
- var showItems = filter$1(sortedItems, function (item) {
2584
- if (item.show && isFunction(item.show)) {
2585
- return item.show(record);
2586
- }
2587
-
2588
- if (item.show === false) {
2589
- return false;
2590
- }
2591
-
2592
- return true;
2593
- });
2594
- return createVNode("div", {
2595
- "class": "pro-table-operate"
2596
- }, [map(showItems, function (item) {
2597
- //自定义
2598
- if (isFunction(item.element)) {
2599
- return item.element(record, item);
2600
- }
2601
-
2602
- return createVNode("div", {
2603
- "class": "pro-table-operate-item",
2604
- "key": item.value,
2605
- "onClick": function onClick() {
2606
- var _item$onClick;
2607
-
2608
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, record);
2609
- }
2610
- }, [item.label]);
2611
- })]);
2612
- }
2613
- });
1421
+ }, [E.label]))]);
1422
+ }
2614
1423
  };
2615
-
2616
- var columns = computed(function () {
2617
- var mergeColumns = mergeStateToList(props.columns, props.columnState, function (item) {
2618
- return item.dataIndex;
2619
- }); //根据valueType选择对应的展示组件
2620
-
2621
- var columns = map(mergeColumns, function (item) {
2622
- //merge公共item
2623
- var nextItem = _objectSpread2(_objectSpread2({}, props.column), item);
2624
-
2625
- if (!item.customRender) {
2626
- nextItem.customRender = function (_ref4) {
2627
- var text = _ref4.text;
2628
- var vn = getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
2629
- showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
2630
- content: props.columnEmptyText
2631
- })
2632
- }), text); //如果找不到注册的组件,使用当前值 及 columnEmptyText
2633
-
2634
- return vn || text || props.columnEmptyText;
2635
- };
1424
+ }, y = w(() => {
1425
+ const u = Ie(t.columns, t.columnState, (i) => i.dataIndex), s = O(u, (i) => {
1426
+ const d = {
1427
+ ...t.column,
1428
+ ...i
1429
+ };
1430
+ return i.customRender || (d.customRender = ({
1431
+ text: m
1432
+ }) => Ke(t.elementMap, {
1433
+ ...i,
1434
+ showProps: {
1435
+ ...i.showProps,
1436
+ content: t.columnEmptyText
2636
1437
  }
2637
-
2638
- return nextItem;
2639
- }); //处理序号
2640
-
2641
- if (props.serialNumber) {
2642
- columns.unshift(createNumberColumn());
2643
- } //处理operate
2644
-
2645
-
2646
- if (props.operate && props.operate.items && some(props.operate.items, function (item) {
2647
- return item.show;
2648
- })) {
2649
- columns.push(createOperateColumn());
2650
- }
2651
-
2652
- return columns;
1438
+ }, m) || m || t.columnEmptyText), d;
2653
1439
  });
2654
- var tableRef = ref();
2655
- provideProTable(_objectSpread2({
2656
- columns: columns,
2657
- tableRef: tableRef
2658
- }, props.provideExtra));
2659
- expose(createExpose(tableMethods || [], tableRef));
2660
- var invalidKeys = keys(proTableProps());
2661
- return function () {
2662
- return createVNode(Table, mergeProps({
2663
- "ref": tableRef
2664
- }, omit(props, invalidKeys), {
2665
- "columns": columns.value
2666
- }), slots);
2667
- };
2668
- }
2669
- });
1440
+ return t.serialNumber && s.unshift(l()), t.operate && t.operate.items && Pe(t.operate.items, (i) => i.show) && s.push(f()), s;
1441
+ }), p = U();
1442
+ wt({
1443
+ columns: y,
1444
+ tableRef: p,
1445
+ ...t.provideExtra
1446
+ }), r(J(a || [], p));
1447
+ const c = N(Me());
1448
+ return () => v(e, M({
1449
+ ref: p
1450
+ }, I(t, c), {
1451
+ columns: y.value
1452
+ }), o);
1453
+ }
1454
+ });
1455
+ export {
1456
+ g as CurdAction,
1457
+ ne as CurdAddAction,
1458
+ F as CurdCurrentMode,
1459
+ ze as CurdMethods,
1460
+ D as CurdSubAction,
1461
+ le as ProCurd,
1462
+ Ut as ProModalCurd,
1463
+ pe as ProModule,
1464
+ Bt as ProPageCurd,
1465
+ te as RequestAction,
1466
+ me as SearchMode,
1467
+ Et as Wrapper,
1468
+ Xe as convertPathToList,
1469
+ $t as createCurdDesc,
1470
+ Vt as createCurdForm,
1471
+ Xt as createCurdList,
1472
+ J as createExpose,
1473
+ Gt as createForm,
1474
+ _t as createFormItemCompFn,
1475
+ zt as createFormList,
1476
+ kt as createGrid,
1477
+ Wt as createSearchForm,
1478
+ Jt as createTable,
1479
+ Pt as defaultPage,
1480
+ Z as getColumnFormItemName,
1481
+ qe as getColumnValueType,
1482
+ pt as getFirstPropName,
1483
+ ve as getFormItemEl,
1484
+ Ke as getItemEl,
1485
+ vt as getValidValues,
1486
+ Ie as mergeStateToList,
1487
+ bt as provideProCurd,
1488
+ _e as provideProFormList,
1489
+ St as provideProModule,
1490
+ ee as renderElement,
1491
+ Te as renderElements,
1492
+ yt as useComposeRequestActor,
1493
+ qt as useDoneRequestActor,
1494
+ Kt as useFailedRequestActor,
1495
+ De as useModuleEvent,
1496
+ se as useProCurd,
1497
+ Je as useProForm,
1498
+ We as useProFormList,
1499
+ ue as useProModule,
1500
+ Ht as useProTable
2670
1501
  };
2671
-
2672
- export { CurdAction, CurdAddAction, CurdCurrentMode, CurdMethods, CurdSubAction, ProCurd, ProModalCurd, ProModule, ProPageCurd, RequestAction, SearchMode, Wrapper, convertPathToList, createCurdDesc, createCurdForm, createCurdList, createExpose, createForm, createFormItemCompFn, createFormList, createGrid, createSearchForm, createTable, defaultPage, getColumnFormItemName, getColumnValueType, getFirstPropName, getFormItemEl, getItemEl, getValidValues, mergeStateToList, provideProCurd, provideProFormList, provideProModule, renderElement, renderElements, useComposeRequestActor, useDoneRequestActor, useFailedRequestActor, useModuleEvent, useProCurd, useProForm, useProFormList, useProModule, useProTable };