@vue-start/element-pro 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.es.js CHANGED
@@ -1,9 +1,8 @@
1
- import { inject, provide, defineComponent, createVNode, mergeProps, ref, reactive, computed, toRaw, Fragment, createTextVNode, isVNode, withDirectives, resolveDirective } from 'vue';
2
- import { ElFormItem, ElForm, ElSelect, ElOption, ElButton, ElInput, ElInputNumber, ElDatePicker, ElTimePicker, ElTreeSelect, ElCheckboxGroup, ElRadioGroup, ElSwitch, ElCascader, ElTable, ElTableColumn, ElPagination, ElDescriptions, ElDescriptionsItem } from 'element-plus';
3
- import { filter, keys, omit, isArray, isString, split, forEach, map, get, isObject, isEmpty, isFunction, mergeWith, size, debounce, some, clone, isBoolean, set, merge, sortBy, pick, camelCase, concat, isNumber } from 'lodash';
4
- import { useEffect, setReactiveValue, useWatch } from '@vue-start/hooks';
5
- import { useRequestProvide, isDoneRequestActor, isFailedRequestActor } from '@vue-start/request';
6
- import { filter as filter$1, tap } from 'rxjs';
1
+ import { defineComponent, createVNode, Fragment, mergeProps, isVNode, ref, reactive, toRaw, computed } from 'vue';
2
+ import { ElLoading, ElTableColumn, ElTable, ElPagination, ElRow, ElCol, ElFormItem, ElForm, ElSelect, ElOption, ElInput, ElInputNumber, ElDatePicker, ElTimePicker, ElTreeSelect, ElCheckboxGroup, ElRadioGroup, ElSwitch, ElCascader, ElButton, ElDescriptions, ElDescriptionsItem, ElDialog } from 'element-plus';
3
+ import { isString, map, omit, get, keys, pick, isNumber, size, isUndefined, mergeWith, isArray, concat } from 'lodash';
4
+ import { generateId, useProTable, ProTable as ProTable$1, useProForm, getFormItemEl, getColumnFormItemName, ProForm as ProForm$1, getValidValues, ProSearchForm as ProSearchForm$1, createFormItemCompFn, ProFormList as ProFormList$1, useProCurd, CurdAddAction, CurdCurrentMode, useProModule, CurdAction, CurdSubAction } from '@vue-start/pro';
5
+ import { useEffect, setReactiveValue } from '@vue-start/hooks';
7
6
 
8
7
  function ownKeys(object, enumerableOnly) {
9
8
  var keys = Object.keys(object);
@@ -79,201 +78,389 @@ function _nonIterableSpread() {
79
78
  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
79
  }
81
80
 
82
- /**
83
- * ProForm ctx
84
- */
85
- var ProFormKey = Symbol("pro-form");
86
- var useProForm = function useProForm() {
87
- return inject(ProFormKey);
81
+ var createLoadingId = function createLoadingId() {
82
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "comp";
83
+ return prefix + "-" + generateId();
88
84
  };
89
- var provideProForm = function provideProForm(ctx) {
90
- provide(ProFormKey, ctx);
91
- };
92
- /**
93
- * ProFormList ctx
94
- */
95
85
 
96
- var ProFormListKey = Symbol("pro-form-list");
97
- var useProFormList = function useProFormList() {
98
- return inject(ProFormListKey);
99
- };
100
- var provideProFormList = function provideProFormList(ctx) {
101
- provide(ProFormListKey, ctx);
86
+ var proLoadingProps = function proLoadingProps() {
87
+ return {
88
+ loading: {
89
+ type: Boolean
90
+ },
91
+ target: {
92
+ type: [String, Object]
93
+ },
94
+ body: {
95
+ type: Boolean
96
+ },
97
+ fullscreen: {
98
+ type: Boolean
99
+ },
100
+ lock: {
101
+ type: Boolean
102
+ },
103
+ text: {
104
+ type: String
105
+ },
106
+ spinner: {
107
+ type: String
108
+ },
109
+ background: {
110
+ type: String
111
+ },
112
+ customClass: {
113
+ type: String
114
+ }
115
+ };
102
116
  };
103
117
 
104
- /**
105
- * 剔除showState或showStateRules规则为!true的值
106
- * @param values
107
- * @param showState
108
- * @param showStateRules
109
- */
110
- var getValidValues = function getValidValues(values, showState, showStateRules) {
111
- if (showState) {
112
- var invalidKeys = filter(keys(showState), function (key) {
113
- return !showState[key];
114
- });
115
- return omit(values, invalidKeys);
116
- }
118
+ var ProLoading = defineComponent({
119
+ props: _objectSpread2({}, proLoadingProps()),
120
+ setup: function setup(props, _ref) {
121
+ var slots = _ref.slots;
122
+ var id = createLoadingId();
123
+ useEffect(function () {
124
+ if (!props.loading) {
125
+ return;
126
+ }
117
127
 
118
- if (showStateRules) {
119
- var _invalidKeys = filter(keys(showStateRules), function (key) {
120
- return !showStateRules[key](values);
121
- });
128
+ var element = props.target;
122
129
 
123
- return omit(values, _invalidKeys);
124
- }
130
+ if (!slots["default"]) {
131
+ //监听
132
+ if (props.target && isString(props.target)) {
133
+ element = document.querySelector("#" + props.target);
134
+ }
135
+ } else {
136
+ //包裹
137
+ element = document.getElementById(id);
138
+ }
125
139
 
126
- return values;
127
- };
128
- /**
129
- * string类型的path转为arr
130
- * @param path
131
- */
140
+ if (!element) {
141
+ return;
142
+ }
132
143
 
133
- var convertPathToList = function convertPathToList(path) {
134
- if (!path) {
135
- return undefined;
136
- }
144
+ var instance = ElLoading.service({
145
+ target: element,
146
+ body: props.body,
147
+ fullscreen: props.fullscreen,
148
+ lock: props.lock,
149
+ text: props.text,
150
+ spinner: props.spinner,
151
+ background: props.background,
152
+ customClass: props.customClass
153
+ });
154
+ return function () {
155
+ instance && instance.close();
156
+ };
157
+ }, function () {
158
+ return props.loading;
159
+ });
160
+ return function () {
161
+ if (!slots["default"]) {
162
+ return null;
163
+ }
137
164
 
138
- if (isArray(path)) {
139
- return path;
165
+ return createVNode("div", {
166
+ "id": id
167
+ }, [slots["default"]()]);
168
+ };
140
169
  }
170
+ });
141
171
 
142
- if (path && isString(path) && path.indexOf(".") > 0) {
143
- return split(path, ".");
144
- }
172
+ var Content$1 = defineComponent(function () {
173
+ var _useProTable = useProTable(),
174
+ columns = _useProTable.columns;
175
+
176
+ return function () {
177
+ return createVNode(Fragment, null, [map(columns.value, function (item) {
178
+ var formatter = function formatter(record, column, value, index) {
179
+ if (item.customRender) {
180
+ return item.customRender({
181
+ value: value,
182
+ text: value,
183
+ record: record,
184
+ column: column,
185
+ index: index
186
+ });
187
+ }
145
188
 
146
- return [path];
147
- };
189
+ return value;
190
+ };
148
191
 
149
- var proFormItemProps$1 = function proFormItemProps() {
150
- return {
151
- name: {
152
- type: [String, Array]
153
- }
192
+ return createVNode(ElTableColumn, mergeProps({
193
+ "key": item.dataIndex
194
+ }, omit(item, "title", "label", "renderHeader", "prop", "dataIndex", "formatter", "customRender"), {
195
+ "label": isVNode(item.title) ? undefined : item.title || get(item, "label"),
196
+ "renderHeader": isVNode(item.title) ? function () {
197
+ return item.title;
198
+ } : undefined,
199
+ "prop": item.dataIndex,
200
+ "formatter": formatter
201
+ }), null);
202
+ })]);
154
203
  };
155
- };
156
-
157
- var ProFormItem = defineComponent({
158
- props: _objectSpread2(_objectSpread2({}, ElFormItem.props), proFormItemProps$1()),
204
+ });
205
+ var ProTable = defineComponent({
206
+ inheritAttrs: false,
207
+ props: _objectSpread2(_objectSpread2({}, ElTable.props), ProTable$1.props),
159
208
  setup: function setup(props, _ref) {
160
- var slots = _ref.slots;
161
- var invalidKeys = keys(proFormItemProps$1());
209
+ var slots = _ref.slots,
210
+ expose = _ref.expose,
211
+ attrs = _ref.attrs;
212
+ var id = createLoadingId("table");
213
+ var tableRef = ref();
214
+ expose({
215
+ tableRef: tableRef
216
+ });
217
+ var originKeys = keys(ProTable$1.props);
162
218
  return function () {
163
- return createVNode(ElFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name", "prop"])), {
164
- "prop": props.prop || props.name
165
- }), slots);
219
+ var _slots$top, _slots$default;
220
+
221
+ return createVNode(ProTable$1, mergeProps(pick.apply(void 0, [props].concat(_toConsumableArray(originKeys), ["provideExtra"])), {
222
+ "provideExtra": _objectSpread2({
223
+ tableRef: tableRef
224
+ }, props.provideExtra)
225
+ }), {
226
+ "default": function _default() {
227
+ return [createVNode(ElTable, mergeProps({
228
+ "ref": tableRef,
229
+ "id": id
230
+ }, attrs, omit(props, originKeys)), _objectSpread2({
231
+ "default": function _default() {
232
+ return [(_slots$top = slots.top) === null || _slots$top === void 0 ? void 0 : _slots$top.call(slots), createVNode(Content$1, null, null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots), props.loading && createVNode(ProLoading, {
233
+ "target": id,
234
+ "loading": true
235
+ }, null)];
236
+ }
237
+ }, omit(slots, "default")))];
238
+ }
239
+ });
166
240
  };
167
241
  }
168
242
  });
169
243
 
170
- var proFormProps = function proFormProps() {
244
+ var defaultPage = {
245
+ page: 1,
246
+ pageSize: 10
247
+ };
248
+
249
+ var proListProps = function proListProps() {
171
250
  return {
172
251
  /**
173
- * 子组件是否只读样式
252
+ * extra 是否放到SearchForm中
174
253
  */
175
- readonly: {
254
+ extraInSearch: {
176
255
  type: Boolean,
177
256
  "default": undefined
178
257
  },
179
-
180
- /**
181
- * FormComponent 根据此项来确定组件是否显示
182
- * rules 根据rules中方法生成showState对象
183
- */
184
- showState: {
258
+ //search
259
+ searchProps: {
185
260
  type: Object
186
261
  },
187
- showStateRules: {
262
+ //table
263
+ tableProps: {
188
264
  type: Object
189
265
  },
190
-
191
- /**
192
- * 是否只读
193
- */
194
- readonlyState: {
266
+ //pagination
267
+ paginationProps: {
195
268
  type: Object
196
269
  },
197
- readonlyStateRules: {
270
+ //pageState
271
+ pageState: {
198
272
  type: Object
199
- },
273
+ }
274
+ };
275
+ };
276
+
277
+ var ProList = defineComponent({
278
+ props: _objectSpread2({}, proListProps()),
279
+ setup: function setup(props, _ref) {
280
+ var slots = _ref.slots,
281
+ emit = _ref.emit;
282
+
283
+ /******************* search pagination ********************/
284
+ var pageState = props.pageState || reactive(_objectSpread2({}, defaultPage));
285
+ var prevValues;
286
+
287
+ var handleSearch = function handleSearch() {
288
+ emit("list", _objectSpread2(_objectSpread2({}, prevValues), pageState));
289
+ }; //页数重置1 且搜索
290
+
291
+
292
+ var executeSearchWithResetPage = function executeSearchWithResetPage(values) {
293
+ prevValues = values;
294
+ pageState.page = 1;
295
+ handleSearch();
296
+ };
297
+
298
+ return function () {
299
+ var _slots$divide, _slots$divide2, _slots$footerLeft, _slots$footerRight;
300
+
301
+ var searchProps = props.searchProps;
302
+ var tableProps = props.tableProps;
303
+ var paginationProps = props.paginationProps; //操作按钮
304
+
305
+ var extra = slots.extra ? createVNode("div", {
306
+ "class": "pro-list-search"
307
+ }, [slots.extra()]) : null; //分页参数
308
+
309
+ var pagination = _objectSpread2(_objectSpread2({}, paginationProps), {}, {
310
+ currentPage: pageState.page,
311
+ pageSize: pageState.pageSize,
312
+ onSizeChange: function onSizeChange(pageSize) {
313
+ pageState.pageSize = pageSize;
314
+ handleSearch();
315
+ },
316
+ onCurrentChange: function onCurrentChange(current) {
317
+ pageState.page = current;
318
+ handleSearch();
319
+ }
320
+ });
321
+
322
+ return createVNode(Fragment, null, [createVNode(ProSearchForm, mergeProps(searchProps, {
323
+ "onFinish": executeSearchWithResetPage
324
+ }), {
325
+ "default": function _default() {
326
+ return [props.extraInSearch && extra];
327
+ }
328
+ }), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), !props.extraInSearch && extra, slots["default"] ? slots["default"]() : createVNode(ProTable, mergeProps({
329
+ "pagination": {
330
+ page: pageState.page,
331
+ pageSize: pageState.pageSize
332
+ }
333
+ }, omit(tableProps, "slots")), tableProps === null || tableProps === void 0 ? void 0 : tableProps.slots), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), createVNode("div", {
334
+ "class": "pro-list-footer"
335
+ }, [(_slots$footerLeft = slots.footerLeft) === null || _slots$footerLeft === void 0 ? void 0 : _slots$footerLeft.call(slots), isNumber(paginationProps === null || paginationProps === void 0 ? void 0 : paginationProps.total) && paginationProps.total > 0 && createVNode(Fragment, null, [slots.pagination ? slots.pagination(pagination) : createVNode(ElPagination, pagination, null)]), (_slots$footerRight = slots.footerRight) === null || _slots$footerRight === void 0 ? void 0 : _slots$footerRight.call(slots)])]);
336
+ };
337
+ }
338
+ });
339
+
340
+ function _isSlot$1(s) {
341
+ return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
342
+ }
200
343
 
344
+ var proGridProps = function proGridProps() {
345
+ return {
201
346
  /**
202
- * 是否disabled
347
+ * row属性
203
348
  */
204
- disableState: {
205
- type: Object
206
- },
207
- disableStateRules: {
208
- type: Object
349
+ row: {
350
+ type: Object,
351
+ "default": undefined
209
352
  },
210
353
 
211
354
  /**
212
- * 展示控件集合,readonly模式下使用这些组件渲染
355
+ * 公共col属性
213
356
  */
214
- elementMap: {
357
+ col: {
215
358
  type: Object
216
359
  },
217
360
 
218
361
  /**
219
- * provide传递
362
+ *
220
363
  */
221
- provideExtra: {
222
- type: Object
364
+ items: {
365
+ type: Array
223
366
  }
224
367
  };
225
368
  };
226
369
 
227
- //emit;
228
- var ProForm = defineComponent({
229
- props: _objectSpread2(_objectSpread2({}, ElForm.props), proFormProps()),
230
- setup: function setup(props, _ref2) {
231
- var slots = _ref2.slots,
232
- expose = _ref2.expose,
233
- emit = _ref2.emit;
234
- var form = ref();
235
- var formState = props.model || reactive({}); //组件状态相关
236
-
237
- var showState = props.showState || reactive({});
238
- var readonlyState = props.readonlyState || reactive({});
239
- var disableState = props.disableState || reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
370
+ var ProGrid = defineComponent({
371
+ props: _objectSpread2({}, proGridProps()),
372
+ setup: function setup(props) {
373
+ return function () {
374
+ var _slot;
240
375
 
241
- useEffect(function () {
242
- if (props.showStateRules) {
243
- forEach(props.showStateRules, function (fn, key) {
244
- showState[key] = fn(formState);
376
+ return createVNode(ElRow, props.row, _isSlot$1(_slot = map(props.items, function (item) {
377
+ return createVNode(ElCol, mergeProps({
378
+ "key": item.rowKey
379
+ }, props.col, item.col), {
380
+ "default": function _default() {
381
+ return [item.vNode];
382
+ }
245
383
  });
246
- }
384
+ })) ? _slot : {
385
+ "default": function _default() {
386
+ return [_slot];
387
+ }
388
+ });
389
+ };
390
+ }
391
+ });
247
392
 
248
- if (props.readonlyStateRules) {
249
- forEach(props.readonlyStateRules, function (fn, key) {
250
- readonlyState[key] = fn(formState);
251
- });
393
+ var proFormItemProps = function proFormItemProps() {
394
+ return {
395
+ name: {
396
+ type: [String, Array]
397
+ }
398
+ };
399
+ };
400
+
401
+ var ProFormItem = defineComponent({
402
+ props: _objectSpread2(_objectSpread2({}, ElFormItem.props), proFormItemProps()),
403
+ setup: function setup(props, _ref) {
404
+ var slots = _ref.slots;
405
+ var invalidKeys = keys(proFormItemProps());
406
+ return function () {
407
+ return createVNode(ElFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name", "prop"])), {
408
+ "prop": props.prop || props.name
409
+ }), slots);
410
+ };
411
+ }
412
+ });
413
+ //emit;
414
+ var Content = defineComponent({
415
+ props: _objectSpread2(_objectSpread2({}, ProGrid.props), {}, {
416
+ needRules: {
417
+ type: Boolean
418
+ }
419
+ }),
420
+ setup: function setup(props) {
421
+ var _useProForm = useProForm(),
422
+ formElementMap = _useProForm.formElementMap,
423
+ columns = _useProForm.columns;
424
+
425
+ return function () {
426
+ if (!formElementMap || size(columns.value) <= 0) {
427
+ return null;
252
428
  }
253
429
 
254
- if (props.disableStateRules) {
255
- forEach(props.disableStateRules, function (fn, key) {
256
- disableState[key] = fn(formState);
430
+ if (!props.row) {
431
+ return map(columns.value, function (item) {
432
+ return getFormItemEl(formElementMap, item, props.needRules);
257
433
  });
258
434
  }
259
- }, formState); //转换为ref对象
260
435
 
261
- var readonly = computed(function () {
262
- return props.readonly;
263
- });
264
- provideProForm(_objectSpread2({
265
- formRef: form,
266
- formState: formState,
267
- showState: showState,
268
- readonlyState: readonlyState,
269
- disableState: disableState,
270
- //
271
- elementMap: props.elementMap,
272
- //
273
- readonly: readonly
274
- }, props.provideExtra));
275
-
276
- var formRef = function formRef(el) {
436
+ return createVNode(ProGrid, {
437
+ "row": props.row,
438
+ "col": props.col,
439
+ "items": map(columns.value, function (item) {
440
+ var vNode = getFormItemEl(formElementMap, item, props.needRules);
441
+ return {
442
+ rowKey: getColumnFormItemName(item),
443
+ vNode: vNode,
444
+ col: get(item, ["extra", "col"])
445
+ };
446
+ })
447
+ }, null);
448
+ };
449
+ }
450
+ });
451
+ var ProForm = defineComponent({
452
+ inheritAttrs: false,
453
+ props: _objectSpread2(_objectSpread2(_objectSpread2({}, ElForm.props), omit(ProForm$1.props, "model")), omit(ProGrid.props, "items")),
454
+ setup: function setup(props, _ref2) {
455
+ var slots = _ref2.slots,
456
+ expose = _ref2.expose,
457
+ emit = _ref2.emit,
458
+ attrs = _ref2.attrs;
459
+ var formRef = ref();
460
+ var formState = props.model || reactive({});
461
+ var showState = props.showState || reactive({});
462
+
463
+ var handleRef = function handleRef(el) {
277
464
  var nexEl = _objectSpread2(_objectSpread2({}, el), {}, {
278
465
  submit: function submit() {
279
466
  var _el$validate;
@@ -293,440 +480,96 @@ var ProForm = defineComponent({
293
480
  });
294
481
 
295
482
  expose(nexEl);
296
- form.value = nexEl;
483
+ formRef.value = nexEl;
297
484
  };
298
485
 
299
- var invalidKeys = keys(proFormProps());
486
+ var originKeys = keys(omit(ProForm$1.props, "model"));
487
+ var gridKeys = keys(ProGrid.props);
300
488
  return function () {
301
- return createVNode(ElForm, mergeProps({
302
- "ref": formRef
303
- }, omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["model"])), {
304
- "model": formState
305
- }), slots);
489
+ var _slots$top, _slots$default;
490
+
491
+ return createVNode(ProForm$1, mergeProps(pick.apply(void 0, [props].concat(_toConsumableArray(originKeys), ["provideExtra"])), {
492
+ "model": formState,
493
+ "showState": showState,
494
+ "provideExtra": _objectSpread2({
495
+ formRef: formRef
496
+ }, props.provideExtra)
497
+ }), {
498
+ "default": function _default() {
499
+ return [createVNode(ElForm, mergeProps({
500
+ "ref": handleRef
501
+ }, attrs, omit.apply(void 0, [props].concat(_toConsumableArray(originKeys), ["model"], _toConsumableArray(gridKeys))), {
502
+ "model": formState
503
+ }), {
504
+ "default": function _default() {
505
+ return [(_slots$top = slots.top) === null || _slots$top === void 0 ? void 0 : _slots$top.call(slots), createVNode(Content, mergeProps(pick(props, gridKeys), {
506
+ "needRules": props.needRules
507
+ }), null), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
508
+ }
509
+ })];
510
+ }
511
+ });
306
512
  };
307
513
  }
308
514
  });
309
515
 
310
- var ProModuleKey = Symbol("pro-module");
311
- var useProModule = function useProModule() {
312
- return inject(ProModuleKey);
313
- };
314
- var provideProModule = function provideProModule(ctx) {
315
- provide(ProModuleKey, ctx);
316
- };
317
-
318
- /**
319
- * 获取Column的valueType,默认"text"
320
- * @param column
321
- */
322
-
323
- var getColumnValueType = function getColumnValueType(column) {
324
- return column.formValueType || column.valueType || "text";
325
- };
326
- /**
327
- *获取Column的FormItem name
328
- * @param column
329
- */
516
+ var ProSearchForm = defineComponent({
517
+ inheritAttrs: false,
518
+ props: _objectSpread2(_objectSpread2(_objectSpread2({}, omit(ProForm.props, "inline")), omit(ProSearchForm$1.props, "model", "columns")), {}, {
519
+ inline: {
520
+ type: Boolean,
521
+ "default": true
522
+ }
523
+ }),
524
+ setup: function setup(props, _ref) {
525
+ var slots = _ref.slots,
526
+ attrs = _ref.attrs;
527
+ var formRef = ref();
528
+ var formState = props.model || reactive({});
529
+ var originKeys = keys(omit(ProSearchForm$1.props, "model", "columns"));
530
+ return function () {
531
+ return createVNode(Fragment, null, [createVNode(ProForm, mergeProps({
532
+ "ref": formRef
533
+ }, attrs, omit.apply(void 0, [props].concat(_toConsumableArray(originKeys), ["needRules", "model"])), {
534
+ "model": formState,
535
+ "needRules": false
536
+ }), slots), createVNode(ProSearchForm$1, mergeProps(pick(props, originKeys), {
537
+ "model": formState,
538
+ "columns": props.columns,
539
+ "onFinish": function onFinish() {
540
+ var _formRef$value;
541
+
542
+ (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.submit();
543
+ }
544
+ }), null)]);
545
+ };
546
+ }
547
+ });
330
548
 
331
- var getColumnFormItemName = function getColumnFormItemName(column) {
332
- var _column$formItemProps;
549
+ var createFormItemComponent = createFormItemCompFn(ProFormItem, function (value, setValue, disabled) {
550
+ return {
551
+ modelValue: value,
552
+ "onUpdate:modelValue": setValue,
553
+ clearable: true,
554
+ disabled: disabled
555
+ };
556
+ });
333
557
 
334
- return ((_column$formItemProps = column.formItemProps) === null || _column$formItemProps === void 0 ? void 0 : _column$formItemProps.name) || column.dataIndex;
558
+ var proSelectProps = function proSelectProps() {
559
+ return {
560
+ options: Array
561
+ };
335
562
  };
336
- /**
337
- * 根据Column生成FormItem VNode
338
- * formFieldProps中的slots参数会以v-slots的形式传递到FormItem的录入组件(子组件)中
339
- * @param formElementMap
340
- * @param column
341
- * @param needRules
342
- */
343
563
 
344
- var getFormItemEl = function getFormItemEl(formElementMap, column) {
345
- var _column$formFieldProp;
346
-
347
- var needRules = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
348
- var valueType = getColumnValueType(column);
349
- var Comp = get(formElementMap, valueType);
350
-
351
- if (!Comp) {
352
- return null;
353
- }
354
-
355
- var name = getColumnFormItemName(column);
356
- var itemProps = needRules ? column.formItemProps : omit(column.formItemProps, "rules");
357
- return createVNode(Comp, mergeProps({
358
- "key": name,
359
- "name": name,
360
- "label": column.title
361
- }, itemProps, {
362
- "fieldProps": omit(column.formFieldProps, "slots"),
363
- "showProps": column.showProps
364
- }), (_column$formFieldProp = column.formFieldProps) === null || _column$formFieldProp === void 0 ? void 0 : _column$formFieldProp.slots);
365
- };
366
- /**
367
- * 根据Column生成Item VNode
368
- * @param elementMap
369
- * @param column
370
- * @param value
371
- */
372
-
373
- var getItemEl = function getItemEl(elementMap, column, value) {
374
- var _column$formFieldProp2;
375
-
376
- var valueType = column.valueType || "text";
377
- var Comp = get(elementMap, valueType);
378
-
379
- if (!Comp) {
380
- return null;
381
- }
382
-
383
- return createVNode(Comp, mergeProps(omit(column.formFieldProps, "slots"), {
384
- "showProps": column.showProps,
385
- "value": value
386
- }), (_column$formFieldProp2 = column.formFieldProps) === null || _column$formFieldProp2 === void 0 ? void 0 : _column$formFieldProp2.slots);
387
- };
388
-
389
- var proModuleProps = function proModuleProps() {
390
- return {
391
- /**
392
- * 配置(静态)
393
- */
394
- columns: {
395
- type: Array
396
- },
397
-
398
- /**
399
- * 配置(动态)
400
- * columns动态属性兼容
401
- */
402
- columnState: {
403
- type: Object
404
- },
405
-
406
- /**
407
- * 展示组件集
408
- */
409
- elementMap: {
410
- type: Object
411
- },
412
-
413
- /**
414
- * 录入组件集
415
- */
416
- formElementMap: {
417
- type: Object
418
- }
419
- };
420
- };
421
-
422
- var ProModule = defineComponent({
423
- name: "PModule",
424
- props: _objectSpread2({}, proModuleProps()),
425
- setup: function setup(props, _ref) {
426
- var slots = _ref.slots;
427
-
428
- /**
429
- * columns columnState 合并
430
- */
431
- var columns = computed(function () {
432
- return map(props.columns, function (item) {
433
- //如果columnState中有值,merge处理
434
- var mapData = get(props.columnState, getColumnFormItemName(item));
435
-
436
- if (isObject(mapData) && !isEmpty(mapData) && !isArray(mapData) && !isFunction(mapData)) {
437
- //合并
438
- return mergeWith(item, mapData, function (objValue, srcValue) {
439
- //如果是数组,替换
440
- if (isArray(objValue) || isArray(srcValue)) {
441
- return srcValue;
442
- }
443
- });
444
- }
445
-
446
- return item;
447
- });
448
- }); // 获取FormItem VNode
449
-
450
- var getFormItemVNode = function getFormItemVNode(column) {
451
- var needRules = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
452
- return getFormItemEl(props.formElementMap, column, needRules);
453
- }; // 获取Item VNode
454
-
455
-
456
- var getItemVNode = function getItemVNode(column, value) {
457
- return getItemEl(props.elementMap, column, value);
458
- };
459
-
460
- provideProModule({
461
- columns: columns,
462
- getFormItemVNode: getFormItemVNode,
463
- getItemVNode: getItemVNode,
464
- elementMap: props.elementMap,
465
- formElementMap: props.formElementMap
466
- });
467
- return function () {
468
- var _slots$default;
469
-
470
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
471
- };
472
- }
473
- });
474
-
475
- var proSchemaFormProps = function proSchemaFormProps() {
476
- return {
477
- columns: {
478
- type: Array
479
- },
480
-
481
- /**
482
- * 录入控件集合,通过column->valueType 查找对应的录入组件
483
- */
484
- formElementMap: {
485
- type: Object
486
- },
487
-
488
- /**
489
- * 是否启用rules验证
490
- */
491
- needRules: {
492
- type: Boolean,
493
- "default": true
494
- }
495
- };
496
- };
497
-
498
- var ProSchemaForm = defineComponent({
499
- name: "PSchemaForm",
500
- props: _objectSpread2(_objectSpread2({}, ProForm.props), proSchemaFormProps()),
501
- setup: function setup(props, _ref) {
502
- var slots = _ref.slots,
503
- expose = _ref.expose;
504
- var formItemList = computed(function () {
505
- if (!props.formElementMap || size(props.formElementMap) <= 0) {
506
- return null;
507
- }
508
-
509
- return map(props.columns, function (item) {
510
- return getFormItemEl(props.formElementMap, item, props.needRules);
511
- });
512
- });
513
- var invalidKeys = keys(proSchemaFormProps());
514
- return function () {
515
- var _slots$default;
516
-
517
- return createVNode(ProForm, mergeProps({
518
- "ref": function ref(el) {
519
- return expose(el);
520
- }
521
- }, omit(props, invalidKeys)), {
522
- "default": function _default() {
523
- return [formItemList.value, (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
524
- }
525
- });
526
- };
527
- }
528
- });
529
-
530
- var SearchMode;
531
-
532
- (function (SearchMode) {
533
- SearchMode["AUTO"] = "AUTO";
534
- SearchMode["MANUAL"] = "MANUAL";
535
- })(SearchMode || (SearchMode = {}));
536
-
537
- var proSearchFormProps = function proSearchFormProps() {
538
- return {
539
- /**
540
- * 初始化触发 onFinish
541
- */
542
- initEmit: {
543
- type: Boolean,
544
- "default": true
545
- },
546
-
547
- /**
548
- * 模式 自动触发或者手动触发 onFinish
549
- */
550
- searchMode: {
551
- type: String,
552
- "default": SearchMode.AUTO
553
- },
554
-
555
- /**
556
- * 需要debounce处理的字段
557
- */
558
- debounceKeys: {
559
- type: Array
560
- },
561
- debounceTime: {
562
- type: Number,
563
- "default": 800
564
- },
565
- //
566
- inline: {
567
- type: Boolean,
568
- "default": true
569
- }
570
- };
571
- };
572
-
573
- var ProSearchForm = defineComponent({
574
- name: "PSearchForm",
575
- props: _objectSpread2(_objectSpread2({}, omit(ProSchemaForm.props, "inline")), proSearchFormProps()),
576
- setup: function setup(props, _ref) {
577
- var slots = _ref.slots,
578
- emit = _ref.emit,
579
- expose = _ref.expose;
580
- var formState = props.model || reactive({});
581
-
582
- var handleFinish = function handleFinish() {
583
- var values = toRaw(formState);
584
- var showValues = getValidValues(values, props.showState, props.showStateRules);
585
- emit("finish", showValues, values);
586
- };
587
-
588
- var debounceFinish = debounce(function () {
589
- handleFinish();
590
- }, props.debounceTime); //初始化
591
-
592
- useEffect(function () {
593
- if (props.initEmit) {
594
- handleFinish();
595
- }
596
- }, []);
597
-
598
- var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
599
- return some(debounceKeys, function (key) {
600
- return get(state, key) !== get(prevState, key);
601
- });
602
- }; //监听
603
-
604
-
605
- useEffect(function (state, prevState) {
606
- if (props.searchMode !== SearchMode.AUTO) {
607
- return;
608
- } //如果改变的值中包括debounceKeys中注册的 延时触发
609
-
610
-
611
- if (props.debounceKeys && size(props.debounceKeys) > 0 && isDebounceDataChange(state, prevState, props.debounceKeys)) {
612
- debounceFinish();
613
- return;
614
- }
615
-
616
- handleFinish();
617
- }, function () {
618
- return clone(formState);
619
- });
620
- var invalidKeys = keys(proSearchFormProps());
621
- return function () {
622
- return createVNode(ProSchemaForm, mergeProps({
623
- "ref": function ref(el) {
624
- return expose(el);
625
- },
626
- "inline": props.inline
627
- }, omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["model"])), {
628
- "needRules": false,
629
- "model": formState
630
- }), slots);
631
- };
632
- }
633
- });
634
-
635
- var proFormItemProps = function proFormItemProps() {
636
- return {
637
- readonly: {
638
- type: Boolean,
639
- "default": undefined
640
- },
641
- fieldProps: {
642
- type: Object
643
- },
644
- showProps: {
645
- type: Object
646
- }
647
- };
648
- };
649
-
650
- var createFormItemComponent = function createFormItemComponent(_ref) {
651
- var InputComp = _ref.InputComp,
652
- valueType = _ref.valueType,
653
- name = _ref.name;
654
- return defineComponent({
655
- name: name,
656
- props: _objectSpread2(_objectSpread2({}, ProFormItem.props), proFormItemProps()),
657
- setup: function setup(props, _ref2) {
658
- var slots = _ref2.slots;
659
-
660
- var _useProForm = useProForm(),
661
- formState = _useProForm.formState,
662
- showState = _useProForm.showState,
663
- readonlyState = _useProForm.readonlyState,
664
- disableState = _useProForm.disableState,
665
- formReadonly = _useProForm.readonly,
666
- elementMap = _useProForm.elementMap;
667
-
668
- var formListCtx = useProFormList(); //优先级 props.readonly > readonlyState > formContext.readonly
669
-
670
- var readonly = computed(function () {
671
- if (isBoolean(props.readonly)) {
672
- return props.readonly;
673
- } else if (isBoolean(readonlyState[props.name])) {
674
- return readonlyState[props.name];
675
- }
676
-
677
- return formReadonly.value;
678
- });
679
- var nameList = convertPathToList(props.name);
680
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
681
- var invalidKeys = keys(proFormItemProps());
682
- return function () {
683
- var show = get(showState, props.name);
684
-
685
- if (isBoolean(show) && !show) {
686
- return null;
687
- }
688
-
689
- var value = get(formState, path); //valueType对应的展示组件
690
-
691
- var ShowComp = get(elementMap, valueType);
692
- return createVNode(ProFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name"])), {
693
- "name": path
694
- }), {
695
- "default": function _default() {
696
- return [readonly.value ? createVNode(Fragment, null, [ShowComp ? createVNode(ShowComp, mergeProps({
697
- "value": value
698
- }, props.fieldProps, {
699
- "showProps": props.showProps
700
- }), slots) : createVNode("span", null, [value])]) : createVNode(InputComp, mergeProps({
701
- "modelValue": value,
702
- "onUpdate:modelValue": function onUpdateModelValue(v) {
703
- set(formState, path, v);
704
- },
705
- "clearable": true,
706
- "disabled": get(disableState, props.name)
707
- }, props.fieldProps), slots)];
708
- }
709
- });
710
- };
711
- }
712
- });
713
- };
714
-
715
- var proSelectProps = function proSelectProps() {
716
- return {
717
- options: Array
718
- };
719
- };
720
-
721
- var ProSelect = defineComponent({
722
- name: "PSelect",
723
- props: _objectSpread2(_objectSpread2({}, ElSelect.props), proSelectProps()),
724
- setup: function setup(props, _ref) {
725
- var slots = _ref.slots,
726
- emit = _ref.emit;
727
- var invalidKeys = keys(proSelectProps());
728
- return function () {
729
- var _slots$default;
564
+ var ProSelect = defineComponent({
565
+ name: "PSelect",
566
+ props: _objectSpread2(_objectSpread2({}, ElSelect.props), proSelectProps()),
567
+ setup: function setup(props, _ref) {
568
+ var slots = _ref.slots,
569
+ emit = _ref.emit;
570
+ var invalidKeys = keys(proSelectProps());
571
+ return function () {
572
+ var _slots$default;
730
573
 
731
574
  return createVNode(ElSelect, mergeProps(omit(props, invalidKeys), {
732
575
  "onUpdate:modelValue": function onUpdateModelValue(v) {
@@ -763,718 +606,115 @@ var ProFormDatePicker = createFormItemComponent({
763
606
  var ProFormTimePicker = createFormItemComponent({
764
607
  InputComp: ElTimePicker,
765
608
  valueType: "time",
766
- name: "PFormTime"
767
- });
768
- var ProFormSelect = createFormItemComponent({
769
- InputComp: ProSelect,
770
- valueType: "select",
771
- name: "PFormSelect"
772
- });
773
- var ProFormTreeSelect = createFormItemComponent({
774
- InputComp: ElTreeSelect,
775
- valueType: "treeSelect",
776
- name: "PFormTreeSelect"
777
- });
778
- var ProFormCheckbox = createFormItemComponent({
779
- InputComp: ElCheckboxGroup,
780
- valueType: "checkbox",
781
- name: "PFromCheckbox"
782
- });
783
- var ProFormRadio = createFormItemComponent({
784
- InputComp: ElRadioGroup,
785
- valueType: "radio",
786
- name: "PFromRadio"
787
- });
788
- var ProFormSwitch = createFormItemComponent({
789
- InputComp: ElSwitch,
790
- valueType: "switch",
791
- name: "PFromSwitch"
792
- });
793
- var ProFormCascader = createFormItemComponent({
794
- InputComp: ElCascader,
795
- valueType: "cascader",
796
- name: "PFormCascader"
797
- });
798
- var ProSubmitButton = defineComponent({
799
- props: _objectSpread2({}, ElButton.props),
800
- setup: function setup(props, _ref) {
801
- var slots = _ref.slots,
802
- emit = _ref.emit;
803
-
804
- var _useProForm = useProForm(),
805
- formRef = _useProForm.formRef;
806
-
807
- var handleClick = function handleClick(e) {
808
- var _formRef$value, _formRef$value$submit;
809
-
810
- emit("click", e);
811
- (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : (_formRef$value$submit = _formRef$value.submit) === null || _formRef$value$submit === void 0 ? void 0 : _formRef$value$submit.call(_formRef$value);
812
- };
813
-
814
- return function () {
815
- return createVNode(ElButton, mergeProps({
816
- "onClick": handleClick
817
- }, props), slots);
818
- };
819
- }
820
- });
821
-
822
- var FormListProvider = defineComponent({
823
- props: {
824
- pathList: {
825
- type: Array
826
- }
827
- },
828
- setup: function setup(props, _ref) {
829
- var slots = _ref.slots;
830
- provideProFormList({
831
- pathList: props.pathList
832
- });
833
- return function () {
834
- var _slots$default;
835
-
836
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
837
- };
838
- }
839
- });
840
-
841
- var proFormListProps = function proFormListProps() {
842
- return {
843
- addButtonText: {
844
- type: String,
845
- "default": "添加一项"
846
- },
847
- addButtonProps: {
848
- type: Object
849
- },
850
- //每行默认id
851
- rowKey: {
852
- type: String,
853
- "default": "id"
854
- }
855
- };
856
- };
857
-
858
- var ProFormList = defineComponent({
859
- name: "PFormList",
860
- props: _objectSpread2(_objectSpread2({}, ProFormItem.props), proFormListProps()),
861
- setup: function setup(props, _ref2) {
862
- var slots = _ref2.slots;
863
-
864
- var _useProForm = useProForm(),
865
- formState = _useProForm.formState,
866
- readonly = _useProForm.readonly;
867
-
868
- var formListCtx = useProFormList();
869
- var nameList = convertPathToList(props.prop);
870
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
871
-
872
- var handleAdd = function handleAdd() {
873
- var targetList = get(formState, path);
874
-
875
- if (!isArray(targetList)) {
876
- targetList = [];
877
- }
878
-
879
- targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
880
- set(formState, path, targetList);
881
- };
882
-
883
- var handleRemove = function handleRemove(index) {
884
- var targetList = get(formState, path);
885
-
886
- if (size(targetList) <= 0) {
887
- return;
888
- }
889
-
890
- targetList.splice(index, 1);
891
- };
892
-
893
- var invalidKeys = keys(proFormListProps());
894
- return function () {
895
- return createVNode(ProFormItem, omit(props, invalidKeys), {
896
- "default": function _default() {
897
- return [map(get(formState, path), function (item, index) {
898
- var _slots$default2;
899
-
900
- return createVNode(FormListProvider, {
901
- "key": index,
902
- "pathList": [].concat(_toConsumableArray(path), [index])
903
- }, {
904
- "default": function _default() {
905
- return [createVNode("div", {
906
- "class": "pro-form-list-item"
907
- }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode("div", {
908
- "class": "pro-form-list-item-minus",
909
- "onClick": function onClick() {
910
- return handleRemove(index);
911
- }
912
- }, [slots.minus ? slots.minus() : createVNode(ElButton, {
913
- "link": true
914
- }, {
915
- "default": function _default() {
916
- return [createTextVNode("\u5220\u9664")];
917
- }
918
- })])])];
919
- }
920
- });
921
- }), !readonly.value && createVNode("div", {
922
- "class": "pro-form-list-item-add",
923
- "onClick": handleAdd
924
- }, [slots.add ? slots.add() : createVNode(ElButton, mergeProps({
925
- "type": "primary"
926
- }, props.addButtonProps), {
927
- "default": function _default() {
928
- return [props.addButtonText];
929
- }
930
- })])];
931
- }
932
- });
933
- };
934
- }
935
- });
936
-
937
- var proTableProps = function proTableProps() {
938
- return {
939
- //操作栏
940
- operate: {
941
- type: Object
942
- },
943
- //默认空字符串
944
- columnEmptyText: {
945
- type: String
946
- },
947
-
948
- /**
949
- * 公共column,会merge到columns item中
950
- */
951
- column: {
952
- type: Object
953
- },
954
- //
955
- columns: {
956
- type: Array
957
- },
958
-
959
- /**
960
- * 展示控件集合,readonly模式下使用这些组件渲染
961
- */
962
- elementMap: {
963
- type: Object
964
- }
965
- };
966
- };
967
-
968
- var ProTable = defineComponent({
969
- props: _objectSpread2(_objectSpread2({}, ElTable.props), proTableProps()),
970
- setup: function setup(props, _ref) {
971
- var slots = _ref.slots,
972
- expose = _ref.expose;
973
- var columns = computed(function () {
974
- //根据valueType选择对应的展示组件
975
- var columns = map(props.columns, function (item) {
976
- //merge从共item
977
- var nextItem = merge(props.column, item);
978
-
979
- if (!item.customRender || !item.formatter) {
980
- nextItem.customRender = function (_ref2) {
981
- var text = _ref2.text;
982
- return getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
983
- showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
984
- content: props.columnEmptyText
985
- })
986
- }), text) || text || props.columnEmptyText;
987
- };
988
- }
989
-
990
- return nextItem;
991
- });
992
- var operate = props.operate; //处理operate
993
-
994
- if (operate && size(operate.items) > 0) {
995
- //将itemState补充的信息拼到item中
996
- var completeItems = map(operate.items, function (i) {
997
- return _objectSpread2(_objectSpread2({}, i), get(operate.itemState, i.value));
998
- }); //排序
999
-
1000
- var operateList = sortBy(completeItems, function (item) {
1001
- return item.sort;
1002
- });
1003
- columns.push(_objectSpread2(_objectSpread2({
1004
- title: "操作",
1005
- valueType: "option",
1006
- fixed: "right"
1007
- }, props.column), {}, {
1008
- customRender: function customRender(_ref3) {
1009
- var record = _ref3.record;
1010
- var validList = filter(operateList, function (item) {
1011
- if (item.show && isFunction(item.show)) {
1012
- return item.show(record);
1013
- }
1014
-
1015
- return true;
1016
- });
1017
- return createVNode("div", {
1018
- "class": "pro-table-operate"
1019
- }, [map(validList, function (item) {
1020
- // 自定义
1021
- if (isFunction(item.element)) {
1022
- return item.element(record, item);
1023
- }
1024
-
1025
- return createVNode(ElButton, {
1026
- "key": item.value,
1027
- "link": true,
1028
- "disabled": isFunction(item.disabled) ? item.disabled(record) : item.disabled,
1029
- "onClick": function onClick() {
1030
- var _item$onClick;
1031
-
1032
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, record);
1033
- }
1034
- }, {
1035
- "default": function _default() {
1036
- return [item.label];
1037
- }
1038
- });
1039
- })]);
1040
- }
1041
- }, operate.column));
1042
- }
1043
-
1044
- return columns;
1045
- });
1046
- var invalidKeys = keys(proTableProps());
1047
- return function () {
1048
- var _slots$default;
1049
-
1050
- return createVNode(ElTable, mergeProps({
1051
- "ref": function ref(el) {
1052
- expose(el);
1053
- }
1054
- }, omit(props, invalidKeys)), _objectSpread2({
1055
- "default": function _default() {
1056
- return [map(columns.value, function (item) {
1057
- var formatter = function formatter(record, column, value, index) {
1058
- if (item.formatter) {
1059
- return item.formatter(record, column, value, index);
1060
- }
1061
-
1062
- if (item.customRender) {
1063
- return item.customRender({
1064
- value: value,
1065
- text: value,
1066
- record: record,
1067
- column: column
1068
- });
1069
- }
1070
-
1071
- return null;
1072
- };
1073
-
1074
- return createVNode(ElTableColumn, mergeProps({
1075
- "key": item.dataIndex || item.prop
1076
- }, omit(item, "title", "label", "renderHeader", "prop", "dataIndex", "formatter", "customRender"), {
1077
- "label": isVNode(item.title) ? undefined : item.title || item.label,
1078
- "renderHeader": isVNode(item.title) ? function () {
1079
- return item.title;
1080
- } : undefined,
1081
- "prop": item.dataIndex || item.prop,
1082
- "formatter": item.formatter || item.customRender ? formatter : undefined
1083
- }), null);
1084
- }), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
1085
- }
1086
- }, omit(slots, "default")));
1087
- };
1088
- }
1089
- });
1090
-
1091
- var ProCurdModuleKey = Symbol("pro-curd-module");
1092
- var useProCurdModule = function useProCurdModule() {
1093
- return inject(ProCurdModuleKey);
1094
- };
1095
- var provideProCurdModule = function provideProCurdModule(ctx) {
1096
- provide(ProCurdModuleKey, ctx);
1097
- };
1098
-
1099
- /**
1100
- * curd 操作模式
1101
- */
1102
- var CurdCurrentMode;
1103
-
1104
- (function (CurdCurrentMode) {
1105
- CurdCurrentMode["ADD"] = "ADD";
1106
- CurdCurrentMode["EDIT"] = "EDIT";
1107
- CurdCurrentMode["DETAIL"] = "DETAIL";
1108
- })(CurdCurrentMode || (CurdCurrentMode = {}));
1109
-
1110
- /**
1111
- * curd add 模式下 标记 "确定" "确定并继续" 触发
1112
- */
1113
- var CurdAddAction;
1114
-
1115
- (function (CurdAddAction) {
1116
- CurdAddAction["NORMAL"] = "NORMAL";
1117
- CurdAddAction["CONTINUE"] = "CONTINUE";
1118
- })(CurdAddAction || (CurdAddAction = {}));
1119
-
1120
- var proCurdModuleProps = function proCurdModuleProps() {
1121
- return {
1122
- /**
1123
- * 状态
1124
- */
1125
- curdState: {
1126
- type: Object
1127
- },
1128
-
1129
- /**
1130
- * 操作配置
1131
- */
1132
- operate: {
1133
- type: Object
1134
- },
1135
-
1136
- /**
1137
- * 列表 或 详情 的唯一标识
1138
- */
1139
- rowKey: {
1140
- type: String,
1141
- "default": "id"
1142
- },
1143
-
1144
- /************************* 子组件props *******************************/
1145
- listProps: {
1146
- type: Object
1147
- },
1148
- formProps: {
1149
- type: Object
1150
- },
1151
- descProps: {
1152
- type: Object
1153
- },
1154
- modalProps: {
1155
- type: Object
1156
- }
1157
- };
1158
- };
1159
-
1160
- var CurdModule = defineComponent({
1161
- props: _objectSpread2({}, proCurdModuleProps()),
609
+ name: "PFormTime"
610
+ });
611
+ var ProFormSelect = createFormItemComponent({
612
+ InputComp: ProSelect,
613
+ valueType: "select",
614
+ name: "PFormSelect"
615
+ });
616
+ var ProFormTreeSelect = createFormItemComponent({
617
+ InputComp: ElTreeSelect,
618
+ valueType: "treeSelect",
619
+ name: "PFormTreeSelect"
620
+ });
621
+ var ProFormCheckbox = createFormItemComponent({
622
+ InputComp: ElCheckboxGroup,
623
+ valueType: "checkbox",
624
+ name: "PFromCheckbox"
625
+ });
626
+ var ProFormRadio = createFormItemComponent({
627
+ InputComp: ElRadioGroup,
628
+ valueType: "radio",
629
+ name: "PFromRadio"
630
+ });
631
+ var ProFormSwitch = createFormItemComponent({
632
+ InputComp: ElSwitch,
633
+ valueType: "switch",
634
+ name: "PFromSwitch"
635
+ });
636
+ var ProFormCascader = createFormItemComponent({
637
+ InputComp: ElCascader,
638
+ valueType: "cascader",
639
+ name: "PFormCascader"
640
+ });
641
+ var ProSubmitButton = defineComponent({
642
+ props: _objectSpread2({}, ElButton.props),
1162
643
  setup: function setup(props, _ref) {
1163
- var slots = _ref.slots;
644
+ var slots = _ref.slots,
645
+ emit = _ref.emit;
1164
646
 
1165
- var _useProModule = useProModule(),
1166
- columns = _useProModule.columns;
647
+ var _useProForm = useProForm(),
648
+ formRef = _useProForm.formRef;
1167
649
 
1168
- var curdState = props.curdState || reactive({
1169
- detailData: {}
1170
- });
1171
- /**
1172
- * 排序
1173
- * @param list
1174
- * @param propName
1175
- */
650
+ var handleClick = function handleClick(e) {
651
+ var _formRef$value, _formRef$value$submit;
1176
652
 
1177
- var dealSort = function dealSort(list, propName) {
1178
- return sortBy(list, function (item) {
1179
- return get(item, propName);
1180
- });
653
+ emit("click", e);
654
+ (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : (_formRef$value$submit = _formRef$value.submit) === null || _formRef$value$submit === void 0 ? void 0 : _formRef$value$submit.call(_formRef$value);
1181
655
  };
1182
- /**
1183
- * 非 hideInForm columns
1184
- */
1185
-
1186
-
1187
- var formColumns = computed(function () {
1188
- return dealSort(filter(columns.value, function (item) {
1189
- return !item.hideInForm;
1190
- }), "formSort");
1191
- });
1192
- /**
1193
- * 非 hideInDetail columns
1194
- */
1195
-
1196
- var descColumns = computed(function () {
1197
- return dealSort(filter(columns.value, function (item) {
1198
- return !item.hideInDetail;
1199
- }), "descSort");
1200
- });
1201
- /**
1202
- * 非 hideInTable columns
1203
- */
1204
-
1205
- var tableColumns = computed(function () {
1206
- return dealSort(filter(columns.value, function (item) {
1207
- return !item.hideInTable;
1208
- }), "tableSort");
1209
- });
1210
- /**
1211
- * search columns
1212
- */
1213
-
1214
- var searchColumns = computed(function () {
1215
- return dealSort(filter(columns.value, function (item) {
1216
- return !!item.search;
1217
- }), "searchSort");
1218
- });
1219
-
1220
- var operate = _objectSpread2({
1221
- detailLabel: "详情",
1222
- editLabel: "编辑",
1223
- addLabel: "添加",
1224
- deleteLabel: "删除"
1225
- }, props.operate);
1226
-
1227
- provideProCurdModule({
1228
- rowKey: props.rowKey,
1229
- curdState: curdState,
1230
- formColumns: formColumns,
1231
- descColumns: descColumns,
1232
- tableColumns: tableColumns,
1233
- searchColumns: searchColumns,
1234
- operate: operate,
1235
- //
1236
- listProps: props.listProps,
1237
- formProps: props.formProps,
1238
- descProps: props.descProps,
1239
- modalProps: props.modalProps
1240
- });
1241
- return function () {
1242
- var _slots$default;
1243
656
 
1244
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
1245
- };
1246
- }
1247
- });
1248
- var ProCurd = defineComponent({
1249
- props: _objectSpread2(_objectSpread2({}, ProModule.props), proCurdModuleProps()),
1250
- setup: function setup(props, _ref2) {
1251
- var slots = _ref2.slots;
1252
- var moduleKeys = keys(ProModule.props);
1253
657
  return function () {
1254
- var _slots$default2;
1255
-
1256
- return createVNode(ProModule, pick(props, moduleKeys), {
1257
- "default": function _default() {
1258
- return [createVNode(CurdModule, omit(props, moduleKeys), {
1259
- "default": function _default() {
1260
- return [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots)];
1261
- }
1262
- })];
1263
- }
1264
- });
658
+ return createVNode(ElButton, mergeProps({
659
+ "onClick": handleClick
660
+ }, props), slots);
1265
661
  };
1266
662
  }
1267
663
  });
1268
664
 
1269
- var proCurdNetProps = function proCurdNetProps() {
665
+ var proFormListProps = function proFormListProps() {
1270
666
  return {
1271
- //发起接口参数/接口回来数据 转换
1272
- converts: {
667
+ addButtonText: {
668
+ type: String,
669
+ "default": "添加一项"
670
+ },
671
+ addButtonProps: {
1273
672
  type: Object
1274
673
  },
1275
- //
1276
- operate: {
674
+ minusButtonText: {
675
+ type: String,
676
+ "default": "删除"
677
+ },
678
+ minusButtonProps: {
1277
679
  type: Object
1278
680
  }
1279
681
  };
1280
682
  };
1281
683
 
1282
- var ProCurdNet = defineComponent({
1283
- props: _objectSpread2(_objectSpread2({}, ProCurd.props), proCurdNetProps()),
684
+ var ProFormList = defineComponent({
685
+ name: "PFormList",
686
+ props: _objectSpread2(_objectSpread2({}, ProFormItem.props), proFormListProps()),
1284
687
  setup: function setup(props, _ref) {
1285
- var _actionConvertParamsM;
1286
-
1287
688
  var slots = _ref.slots;
1288
-
1289
- var _useRequestProvide = useRequestProvide(),
1290
- dispatchRequest = _useRequestProvide.dispatchRequest,
1291
- requestSubject$ = _useRequestProvide.requestSubject$;
1292
-
1293
- var curdState = props.curdState || reactive({
1294
- detailData: {}
1295
- });
1296
- /********************************** 网络请求相关 ***************************************/
1297
- //默认converts
1298
-
1299
- var converts = _objectSpread2({
1300
- convertListParams: function convertListParams(values) {
1301
- return values;
1302
- },
1303
- convertListData: function convertListData(actor) {
1304
- var _actor$res;
1305
-
1306
- return (_actor$res = actor.res) === null || _actor$res === void 0 ? void 0 : _actor$res.data;
1307
- },
1308
- convertDetailParams: function convertDetailParams(record, rowKey) {
1309
- return pick(record, rowKey);
1310
- },
1311
- convertDetailData: function convertDetailData(actor) {
1312
- var _actor$res2;
1313
-
1314
- return (_actor$res2 = actor.res) === null || _actor$res2 === void 0 ? void 0 : _actor$res2.data;
1315
- },
1316
- convertAddParams: function convertAddParams(values, record) {
1317
- return {
1318
- body: _objectSpread2(_objectSpread2({}, record), values)
1319
- };
1320
- },
1321
- convertEditParams: function convertEditParams(values, record) {
1322
- return {
1323
- body: _objectSpread2(_objectSpread2({}, record), values)
1324
- };
1325
- }
1326
- }, props.converts);
1327
-
1328
- var Action = {
1329
- List: "list",
1330
- Detail: "detail",
1331
- Add: "add",
1332
- Edit: "edit",
1333
- Delete: "delete"
1334
- }; //接口map {`${actorName}`:action}
1335
-
1336
- var actorNameMap = {};
1337
- var lastRequestActors = {};
1338
- var actionConvertParamsMap = (_actionConvertParamsM = {}, _defineProperty(_actionConvertParamsM, Action.List, converts.convertListParams), _defineProperty(_actionConvertParamsM, Action.Detail, converts.convertDetailParams), _defineProperty(_actionConvertParamsM, Action.Add, converts.convertAddParams), _defineProperty(_actionConvertParamsM, Action.Edit, converts.convertEditParams), _defineProperty(_actionConvertParamsM, Action.Delete, converts.convertDeleteParams), _actionConvertParamsM);
1339
-
1340
- var createRequestFun = function createRequestFun(action) {
1341
- return function () {
1342
- var actor = get(props.operate, "".concat(action, "Actor"));
1343
-
1344
- if (!actor) {
1345
- return;
1346
- } // action he actorName 绑定
1347
-
1348
-
1349
- actorNameMap[actor.name] = action;
1350
- var convertParams = get(actionConvertParamsMap, action); // @ts-ignore
1351
-
1352
- var nextParams = convertParams ? convertParams.apply(void 0, arguments) : undefined;
1353
- lastRequestActors[action] = dispatchRequest(actor, nextParams);
1354
- };
1355
- };
1356
-
1357
- var actions = {
1358
- executeList: createRequestFun(Action.List),
1359
- executeDetail: createRequestFun(Action.Detail),
1360
- executeAdd: createRequestFun(Action.Add),
1361
- executeEdit: createRequestFun(Action.Edit),
1362
- executeDelete: createRequestFun(Action.Delete)
1363
- };
1364
- /********************************** operate ***************************************/
1365
-
1366
- var prevListParams;
1367
-
1368
- var handleSearch = function handleSearch() {
1369
- actions.executeList(prevListParams);
1370
- };
1371
-
1372
- var operate = _objectSpread2({
1373
- //list
1374
- onList: function onList(values) {
1375
- var _props$operate, _props$operate$onList;
1376
-
1377
- prevListParams = values;
1378
- handleSearch();
1379
- (_props$operate = props.operate) === null || _props$operate === void 0 ? void 0 : (_props$operate$onList = _props$operate.onListBubble) === null || _props$operate$onList === void 0 ? void 0 : _props$operate$onList.call(_props$operate, "emit", values);
1380
- },
1381
- onListDone: function onListDone(actor) {
1382
- var _converts$convertList, _props$operate2, _props$operate2$onLis;
1383
-
1384
- curdState.listLoading = false;
1385
- curdState.listData = (_converts$convertList = converts.convertListData) === null || _converts$convertList === void 0 ? void 0 : _converts$convertList.call(converts, actor);
1386
- (_props$operate2 = props.operate) === null || _props$operate2 === void 0 ? void 0 : (_props$operate2$onLis = _props$operate2.onListBubble) === null || _props$operate2$onLis === void 0 ? void 0 : _props$operate2$onLis.call(_props$operate2, "done", actor);
1387
- },
1388
- onListFail: function onListFail(actor) {
1389
- var _props$operate3, _props$operate3$onLis;
1390
-
1391
- curdState.listLoading = false;
1392
- (_props$operate3 = props.operate) === null || _props$operate3 === void 0 ? void 0 : (_props$operate3$onLis = _props$operate3.onListBubble) === null || _props$operate3$onLis === void 0 ? void 0 : _props$operate3$onLis.call(_props$operate3, "fail", actor);
1393
- },
1394
- //detail
1395
- onDetailDone: function onDetailDone(actor) {
1396
- var _converts$convertDeta, _props$operate4, _props$operate4$onDet;
1397
-
1398
- curdState.detailLoading = false;
1399
- setReactiveValue(curdState.detailData, (_converts$convertDeta = converts.convertDetailData) === null || _converts$convertDeta === void 0 ? void 0 : _converts$convertDeta.call(converts, actor));
1400
- (_props$operate4 = props.operate) === null || _props$operate4 === void 0 ? void 0 : (_props$operate4$onDet = _props$operate4.onDetailBubble) === null || _props$operate4$onDet === void 0 ? void 0 : _props$operate4$onDet.call(_props$operate4, "done", actor);
1401
- },
1402
- onDetailFail: function onDetailFail(actor) {
1403
- var _props$operate5, _props$operate5$onDet;
1404
-
1405
- curdState.detailLoading = false;
1406
- (_props$operate5 = props.operate) === null || _props$operate5 === void 0 ? void 0 : (_props$operate5$onDet = _props$operate5.onDetailBubble) === null || _props$operate5$onDet === void 0 ? void 0 : _props$operate5$onDet.call(_props$operate5, "fail", actor);
1407
- },
1408
- //add
1409
- onAddExecute: function onAddExecute(values) {
1410
- var _props$operate6, _props$operate6$onAdd;
1411
-
1412
- curdState.operateLoading = true;
1413
- actions.executeAdd(values, curdState.detailData);
1414
- (_props$operate6 = props.operate) === null || _props$operate6 === void 0 ? void 0 : (_props$operate6$onAdd = _props$operate6.onAddBubble) === null || _props$operate6$onAdd === void 0 ? void 0 : _props$operate6$onAdd.call(_props$operate6, "execute", values);
1415
- },
1416
- onAddFail: function onAddFail(actor) {
1417
- var _props$operate7, _props$operate7$onAdd;
1418
-
1419
- curdState.operateLoading = false;
1420
- (_props$operate7 = props.operate) === null || _props$operate7 === void 0 ? void 0 : (_props$operate7$onAdd = _props$operate7.onAddBubble) === null || _props$operate7$onAdd === void 0 ? void 0 : _props$operate7$onAdd.call(_props$operate7, "fail", actor);
1421
- },
1422
- //edit
1423
- onEditExecute: function onEditExecute(values) {
1424
- var _props$operate8, _props$operate8$onEdi;
1425
-
1426
- curdState.operateLoading = true;
1427
- actions.executeEdit(values, curdState.detailData);
1428
- (_props$operate8 = props.operate) === null || _props$operate8 === void 0 ? void 0 : (_props$operate8$onEdi = _props$operate8.onEditBubble) === null || _props$operate8$onEdi === void 0 ? void 0 : _props$operate8$onEdi.call(_props$operate8, "execute", values);
1429
- },
1430
- onEditFail: function onEditFail(actor) {
1431
- var _props$operate9, _props$operate9$onEdi;
1432
-
1433
- curdState.operateLoading = false;
1434
- (_props$operate9 = props.operate) === null || _props$operate9 === void 0 ? void 0 : (_props$operate9$onEdi = _props$operate9.onEditBubble) === null || _props$operate9$onEdi === void 0 ? void 0 : _props$operate9$onEdi.call(_props$operate9, "fail", actor);
1435
- },
1436
- //delete
1437
- onDelete: function onDelete(record) {
1438
- var _props$operate10, _props$operate10$onDe;
1439
-
1440
- actions.executeDelete(record, props.rowKey);
1441
- (_props$operate10 = props.operate) === null || _props$operate10 === void 0 ? void 0 : (_props$operate10$onDe = _props$operate10.onDeleteBubble) === null || _props$operate10$onDe === void 0 ? void 0 : _props$operate10$onDe.call(_props$operate10, "emit", record);
1442
- }
1443
- }, props.operate); //网络请求订阅
1444
-
1445
-
1446
- useEffect(function () {
1447
- //请求成功
1448
- var doneSub = requestSubject$.pipe(filter$1(isDoneRequestActor), tap(function (actor) {
1449
- var action = actorNameMap[actor.name];
1450
- var actionDone = get(operate, camelCase("on-".concat(action, "-done")));
1451
- actionDone === null || actionDone === void 0 ? void 0 : actionDone(actor);
1452
- lastRequestActors[action] = undefined;
1453
- })).subscribe(); //请求失败
1454
-
1455
- var failSub = requestSubject$.pipe(filter$1(isFailedRequestActor), tap(function (actor) {
1456
- var action = actorNameMap[actor.name];
1457
- var actionFail = get(operate, camelCase("on-".concat(action, "-fail")));
1458
- actionFail === null || actionFail === void 0 ? void 0 : actionFail(actor);
1459
- lastRequestActors[action] = undefined;
1460
- })).subscribe();
1461
- return function () {
1462
- doneSub.unsubscribe();
1463
- failSub.unsubscribe(); //组件销毁的时候cancel请求
1464
-
1465
- forEach(lastRequestActors, function (actor) {
1466
- actor && dispatchRequest(_objectSpread2(_objectSpread2({}, actor), {}, {
1467
- stage: "CANCEL"
1468
- }));
1469
- });
1470
- };
1471
- }, []);
689
+ var originKeys = keys(ProFormList$1.props);
690
+ var invalidKeys = keys(proFormListProps());
1472
691
  return function () {
1473
- var _slots$default;
1474
-
1475
- return createVNode(ProCurd, omit(props, "converts"), {
692
+ return createVNode(ProFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(originKeys), _toConsumableArray(invalidKeys))), {
693
+ "name": props.name
694
+ }), {
1476
695
  "default": function _default() {
1477
- return [(_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
696
+ return [createVNode(ProFormList$1, mergeProps(pick(props, originKeys), {
697
+ "name": props.name
698
+ }), _objectSpread2({
699
+ itemMinus: function itemMinus() {
700
+ return createVNode(ElButton, mergeProps({
701
+ "link": true
702
+ }, props.minusButtonProps), {
703
+ "default": function _default() {
704
+ return [props.minusButtonText];
705
+ }
706
+ });
707
+ },
708
+ add: function add() {
709
+ return createVNode(ElButton, mergeProps({
710
+ "type": "primary"
711
+ }, props.addButtonProps), {
712
+ "default": function _default() {
713
+ return [props.addButtonText];
714
+ }
715
+ });
716
+ }
717
+ }, slots))];
1478
718
  }
1479
719
  });
1480
720
  };
@@ -1490,8 +730,8 @@ var OkButton = defineComponent({
1490
730
  setup: function setup(props, _ref) {
1491
731
  var slots = _ref.slots;
1492
732
 
1493
- var _useProCurdModule = useProCurdModule(),
1494
- curdState = _useProCurdModule.curdState;
733
+ var _useProCurd = useProCurd(),
734
+ curdState = _useProCurd.curdState;
1495
735
 
1496
736
  return function () {
1497
737
  return createVNode(ProSubmitButton, mergeProps({
@@ -1517,8 +757,8 @@ var ContinueAddButton = defineComponent({
1517
757
  setup: function setup(props, _ref2) {
1518
758
  var slots = _ref2.slots;
1519
759
 
1520
- var _useProCurdModule2 = useProCurdModule(),
1521
- curdState = _useProCurdModule2.curdState;
760
+ var _useProCurd2 = useProCurd(),
761
+ curdState = _useProCurd2.curdState;
1522
762
 
1523
763
  return function () {
1524
764
  return createVNode(ProSubmitButton, mergeProps({
@@ -1567,8 +807,8 @@ var ProOperateButton = defineComponent({
1567
807
  setup: function setup(props, _ref3) {
1568
808
  var slots = _ref3.slots;
1569
809
 
1570
- var _useProCurdModule3 = useProCurdModule(),
1571
- curdState = _useProCurdModule3.curdState;
810
+ var _useProCurd3 = useProCurd(),
811
+ curdState = _useProCurd3.curdState;
1572
812
 
1573
813
  return function () {
1574
814
  var _slots$left, _slots$center, _slots$right;
@@ -1603,44 +843,46 @@ var ProCurdForm = defineComponent({
1603
843
  var slots = _ref4.slots;
1604
844
 
1605
845
  var _useProModule = useProModule(),
1606
- getFormItemVNode = _useProModule.getFormItemVNode;
1607
-
1608
- var _useProCurdModule4 = useProCurdModule(),
1609
- curdState = _useProCurdModule4.curdState,
1610
- formColumns = _useProCurdModule4.formColumns,
1611
- operate = _useProCurdModule4.operate;
846
+ elementMap = _useProModule.elementMap,
847
+ formElementMap = _useProModule.formElementMap;
1612
848
 
1613
- var formVNodes = computed(function () {
1614
- return map(formColumns.value, function (item) {
1615
- return getFormItemVNode(item, true);
1616
- });
1617
- });
849
+ var _useProCurd4 = useProCurd(),
850
+ curdState = _useProCurd4.curdState,
851
+ formColumns = _useProCurd4.formColumns,
852
+ sendCurdEvent = _useProCurd4.sendCurdEvent;
1618
853
 
1619
854
  var handleFinish = function handleFinish(values) {
1620
855
  if (curdState.mode === CurdCurrentMode.EDIT) {
1621
- var _operate$onEditExecut;
1622
-
1623
856
  //edit
1624
- (_operate$onEditExecut = operate.onEditExecute) === null || _operate$onEditExecut === void 0 ? void 0 : _operate$onEditExecut.call(operate, values);
857
+ sendCurdEvent({
858
+ action: CurdAction.EDIT,
859
+ type: CurdSubAction.EXECUTE,
860
+ values: values
861
+ });
1625
862
  } else {
1626
- var _operate$onAddExecute;
1627
-
1628
863
  //add
1629
- (_operate$onAddExecute = operate.onAddExecute) === null || _operate$onAddExecute === void 0 ? void 0 : _operate$onAddExecute.call(operate, values);
864
+ sendCurdEvent({
865
+ action: CurdAction.ADD,
866
+ type: CurdSubAction.EXECUTE,
867
+ values: values
868
+ });
1630
869
  }
1631
870
  };
1632
871
 
1633
872
  return function () {
1634
- return createVNode(ProForm, mergeProps(props, {
873
+ var _slots$default;
874
+
875
+ return createVNode(ProForm, mergeProps(omit(props, "elementMap", "formElementMap"), {
876
+ "elementMap": props.elementMap || elementMap,
877
+ "formElementMap": props.formElementMap || formElementMap,
878
+ "columns": formColumns.value,
1635
879
  "model": curdState.detailData,
1636
880
  "readonly": curdState.mode === CurdCurrentMode.DETAIL,
1637
881
  "hideRequiredAsterisk": curdState.mode === CurdCurrentMode.DETAIL,
1638
882
  "onFinish": handleFinish
1639
883
  }), _objectSpread2({
1640
884
  "default": function _default() {
1641
- var _slots$default;
1642
-
1643
- return createVNode(Fragment, null, [formVNodes.value, curdState.mode !== CurdCurrentMode.DETAIL && createVNode(ProOperateButton, omit(props.operateButtonProps, "slots"), get(props.operateButtonProps, "slots")), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)]);
885
+ return [curdState.mode !== CurdCurrentMode.DETAIL && createVNode(ProOperateButton, omit(props.operateButtonProps, "slots"), get(props.operateButtonProps, "slots")), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
1644
886
  }
1645
887
  }, omit(slots, "default")));
1646
888
  };
@@ -1648,184 +890,126 @@ var ProCurdForm = defineComponent({
1648
890
  });
1649
891
  var ProCurdFormConnect = defineComponent({
1650
892
  setup: function setup() {
1651
- var _useProCurdModule5 = useProCurdModule(),
1652
- formProps = _useProCurdModule5.formProps;
893
+ var _useProCurd5 = useProCurd(),
894
+ formProps = _useProCurd5.formProps;
1653
895
 
1654
896
  return function () {
1655
- return createVNode(ProCurdForm, omit(formProps, "slots"), get(formProps, "slots"));
897
+ return createVNode(ProCurdForm, omit(formProps === null || formProps === void 0 ? void 0 : formProps.value, "slots"), get(formProps === null || formProps === void 0 ? void 0 : formProps.value, "slots"));
1656
898
  };
1657
899
  }
1658
900
  });
1659
901
 
1660
- var defaultPage = {
1661
- page: 1,
1662
- pageSize: 10
1663
- };
1664
-
1665
- var curdListProps = function curdListProps() {
1666
- return {
1667
- /**
1668
- * extra 是否放到SearchForm中
1669
- */
1670
- extraInSearch: {
1671
- type: Boolean,
1672
- "default": undefined
1673
- },
1674
- //search
1675
- searchProps: {
1676
- type: Object
1677
- },
1678
- //table
1679
- tableProps: {
1680
- type: Object
1681
- },
1682
- //pagination
1683
- paginationProps: {
1684
- type: Object
1685
- },
1686
- //pageState
1687
- pageState: {
1688
- type: Object
1689
- }
1690
- };
1691
- };
1692
-
1693
902
  /**
1694
903
  * 组合列表
1695
904
  * SearchForm + Table + Pagination
1696
905
  */
1697
906
  var ProCurdList = defineComponent({
1698
- props: _objectSpread2({}, curdListProps()),
907
+ props: _objectSpread2({}, ProList.props),
1699
908
  setup: function setup(props, _ref) {
1700
- var _props$searchProps;
1701
-
1702
909
  var slots = _ref.slots;
1703
910
 
1704
911
  var _useProModule = useProModule(),
1705
912
  elementMap = _useProModule.elementMap,
1706
913
  formElementMap = _useProModule.formElementMap;
1707
914
 
1708
- var _useProCurdModule = useProCurdModule(),
1709
- curdState = _useProCurdModule.curdState,
1710
- searchColumns = _useProCurdModule.searchColumns,
1711
- tableColumns = _useProCurdModule.tableColumns,
1712
- operate = _useProCurdModule.operate;
915
+ var _useProCurd = useProCurd(),
916
+ curdState = _useProCurd.curdState,
917
+ searchColumns = _useProCurd.searchColumns,
918
+ tableColumns = _useProCurd.tableColumns,
919
+ getOperate = _useProCurd.getOperate,
920
+ sendCurdEvent = _useProCurd.sendCurdEvent;
1713
921
  /******************* table ********************/
1714
922
 
1715
923
 
1716
- var prepareTableItem = function prepareTableItem(propName) {
1717
- return {
1718
- value: propName,
1719
- label: get(operate, "".concat(propName, "Label")),
1720
- show: get(operate, propName, false),
924
+ var prepareTableItem = function prepareTableItem(action) {
925
+ var item = getOperate(action);
926
+ return _objectSpread2(_objectSpread2({}, pick(item, "label", "element", "disabled", "sort")), {}, {
927
+ show: !isUndefined(item === null || item === void 0 ? void 0 : item.show) ? item === null || item === void 0 ? void 0 : item.show : false,
1721
928
  onClick: function onClick(record) {
1722
- var fun = get(operate, camelCase("on-".concat(propName)));
1723
- fun === null || fun === void 0 ? void 0 : fun(record);
1724
- }
1725
- };
1726
- }; //table操作栏 items
1727
-
1728
-
1729
- var tableOperateItems = [prepareTableItem("detail"), prepareTableItem("edit"), prepareTableItem("delete")];
1730
- /******************* search pagination ********************/
1731
-
1732
- var searchState = ((_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.model) || reactive({});
1733
- var pageState = props.pageState || reactive(_objectSpread2({}, defaultPage));
1734
-
1735
- var handleSearch = function handleSearch() {
1736
- operate.onList && operate.onList(_objectSpread2(_objectSpread2({}, searchState), pageState));
1737
- };
1738
-
1739
- var executeSearchWithResetPage = function executeSearchWithResetPage() {
1740
- pageState.page = 1;
1741
- handleSearch();
1742
- }; //无SearchForm组件 初始化
1743
-
1744
-
1745
- useEffect(function () {
1746
- var _props$searchProps2;
929
+ if (item !== null && item !== void 0 && item.onClick) {
930
+ item.onClick(record);
931
+ return;
932
+ }
1747
933
 
1748
- // 处理触发onList 操作
1749
- if (size(searchColumns.value) <= 0 && ((_props$searchProps2 = props.searchProps) === null || _props$searchProps2 === void 0 ? void 0 : _props$searchProps2.initEmit) !== false) {
1750
- handleSearch();
1751
- }
1752
- }, []); //无SearchForm组件 订阅searchState
934
+ sendCurdEvent({
935
+ action: action,
936
+ type: CurdSubAction.EMIT,
937
+ record: record
938
+ });
939
+ },
940
+ value: action
941
+ });
942
+ }; //table操作栏 items
1753
943
 
1754
- useWatch(function () {
1755
- if (size(searchColumns.value) > 0) {
1756
- return;
1757
- }
1758
944
 
1759
- executeSearchWithResetPage();
1760
- }, searchState);
945
+ var tableOperateItems = [prepareTableItem(CurdAction.DETAIL), prepareTableItem(CurdAction.EDIT), prepareTableItem(CurdAction.DELETE)];
1761
946
  return function () {
1762
- var _slots$extra, _slots$divide, _curdState$listData, _props$tableProps, _slots$divide2, _curdState$listData2;
1763
-
1764
- var pagination = props.paginationProps; //
1765
-
1766
- var _extra = createVNode("div", {
1767
- "class": "pro-curd-list-search"
1768
- }, [operate.add && createVNode(ElButton, {
1769
- "type": "primary",
1770
- "onClick": function onClick() {
1771
- var _operate$onAdd;
1772
-
1773
- (_operate$onAdd = operate.onAdd) === null || _operate$onAdd === void 0 ? void 0 : _operate$onAdd.call(operate);
1774
- }
1775
- }, {
1776
- "default": function _default() {
1777
- return [operate.addLabel];
947
+ var _curdState$listData, _curdState$listData2;
948
+
949
+ var tableProps = props.tableProps;
950
+ var paginationProps = props.paginationProps;
951
+ return createVNode(ProList, mergeProps({
952
+ "onList": function onList(values) {
953
+ sendCurdEvent({
954
+ action: CurdAction.LIST,
955
+ type: CurdSubAction.EMIT,
956
+ values: values
957
+ });
1778
958
  }
1779
- }), (_slots$extra = slots.extra) === null || _slots$extra === void 0 ? void 0 : _slots$extra.call(slots)]);
959
+ }, props, {
960
+ "searchProps": _objectSpread2(_objectSpread2({
961
+ formElementMap: formElementMap
962
+ }, props.searchProps), {}, {
963
+ columns: searchColumns.value
964
+ }),
965
+ "tableProps": _objectSpread2(_objectSpread2({
966
+ elementMap: elementMap
967
+ }, tableProps), {}, {
968
+ operate: mergeWith({
969
+ items: tableOperateItems
970
+ }, tableProps === null || tableProps === void 0 ? void 0 : tableProps.operate, function (objValue, srcValue) {
971
+ if (isArray(objValue)) {
972
+ if (isArray(srcValue)) {
973
+ //合并
974
+ return concat(objValue, map(srcValue, function (item) {
975
+ var nextItem = _objectSpread2({}, item);
976
+
977
+ if (!item.onClick) {
978
+ nextItem.onClick = function (record) {
979
+ sendCurdEvent({
980
+ action: "operate",
981
+ type: item.value,
982
+ record: record
983
+ });
984
+ };
985
+ }
1780
986
 
1781
- return createVNode(Fragment, null, [size(searchColumns.value) > 0 && createVNode(ProSearchForm, mergeProps({
1782
- "formElementMap": formElementMap,
1783
- "columns": searchColumns.value
1784
- }, props.searchProps, {
1785
- "model": searchState,
1786
- "onFinish": executeSearchWithResetPage
1787
- }), {
1788
- //extraInSearch 模式下放入SearchForm
1789
- extra: function extra() {
1790
- return props.extraInSearch ? _extra : null;
1791
- }
1792
- }), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), (size(searchColumns.value) <= 0 || !props.extraInSearch) && (operate.add || slots.extra) && _extra, slots["default"] ? slots["default"]() : withDirectives(createVNode(ProTable, mergeProps({
1793
- "elementMap": elementMap,
1794
- "columns": tableColumns.value,
1795
- "operate": mergeWith({
1796
- items: tableOperateItems
1797
- }, operate.tableOperate, function (objValue, srcValue) {
1798
- if (isArray(objValue) && isArray(srcValue)) {
1799
- return concat(objValue, srcValue);
1800
- }
987
+ return nextItem;
988
+ }));
989
+ } else {
990
+ //使用curd默认
991
+ return objValue;
992
+ }
993
+ }
994
+ }),
995
+ columns: tableColumns.value,
996
+ loading: curdState.listLoading,
997
+ data: (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
998
+ }),
999
+ "paginationProps": _objectSpread2(_objectSpread2({}, paginationProps), {}, {
1000
+ total: (_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total
1801
1001
  })
1802
- }, omit(props.tableProps, "slots", "operate"), {
1803
- "data": (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
1804
- }), (_props$tableProps = props.tableProps) === null || _props$tableProps === void 0 ? void 0 : _props$tableProps.slots), [[resolveDirective("loading"), curdState.listLoading]]), (_slots$divide2 = slots.divide2) === null || _slots$divide2 === void 0 ? void 0 : _slots$divide2.call(slots), curdState.listData && isNumber((_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total) && curdState.listData.total > 0 && createVNode("div", {
1805
- "class": "pro-curd-list-bottom"
1806
- }, [createVNode(ElPagination, mergeProps(pagination, {
1807
- "total": curdState.listData.total,
1808
- "currentPage": pageState.page,
1809
- "pageSize": pageState.pageSize,
1810
- "onSizeChange": function onSizeChange(pageSize) {
1811
- pageState.pageSize = pageSize;
1812
- handleSearch();
1813
- },
1814
- "onCurrentChange": function onCurrentChange(current) {
1815
- pageState.page = current;
1816
- handleSearch();
1817
- }
1818
- }), null)])]);
1002
+ }), slots);
1819
1003
  };
1820
1004
  }
1821
1005
  });
1822
1006
  var ProCurdListConnect = defineComponent({
1823
1007
  setup: function setup() {
1824
- var _useProCurdModule2 = useProCurdModule(),
1825
- listProps = _useProCurdModule2.listProps;
1008
+ var _useProCurd2 = useProCurd(),
1009
+ listProps = _useProCurd2.listProps;
1826
1010
 
1827
1011
  return function () {
1828
- return createVNode(ProCurdList, omit(listProps, "slots"), get(listProps, "slots"));
1012
+ return createVNode(ProCurdList, omit(listProps === null || listProps === void 0 ? void 0 : listProps.value, "slots"), get(listProps === null || listProps === void 0 ? void 0 : listProps.value, "slots"));
1829
1013
  };
1830
1014
  }
1831
1015
  });
@@ -1842,9 +1026,9 @@ var ProCurdDesc = defineComponent({
1842
1026
  var _useProModule = useProModule(),
1843
1027
  getItemVNode = _useProModule.getItemVNode;
1844
1028
 
1845
- var _useProCurdModule = useProCurdModule(),
1846
- curdState = _useProCurdModule.curdState,
1847
- descColumns = _useProCurdModule.descColumns;
1029
+ var _useProCurd = useProCurd(),
1030
+ curdState = _useProCurd.curdState,
1031
+ descColumns = _useProCurd.descColumns;
1848
1032
 
1849
1033
  var descVNodes = computed(function () {
1850
1034
  return map(descColumns.value, function (item) {
@@ -1872,13 +1056,70 @@ var ProCurdDesc = defineComponent({
1872
1056
  });
1873
1057
  var ProCurdDescConnect = defineComponent({
1874
1058
  setup: function setup() {
1875
- var _useProCurdModule2 = useProCurdModule(),
1876
- descProps = _useProCurdModule2.descProps;
1059
+ var _useProCurd2 = useProCurd(),
1060
+ descProps = _useProCurd2.descProps;
1061
+
1062
+ return function () {
1063
+ return createVNode(ProCurdList, omit(descProps === null || descProps === void 0 ? void 0 : descProps.value, "slots"), get(descProps === null || descProps === void 0 ? void 0 : descProps.value, "slots"));
1064
+ };
1065
+ }
1066
+ });
1067
+
1068
+ var ProCurdModal = defineComponent({
1069
+ props: _objectSpread2({}, ElDialog.props),
1070
+ setup: function setup(props, _ref) {
1071
+ var slots = _ref.slots;
1072
+
1073
+ var _useProCurd = useProCurd(),
1074
+ curdState = _useProCurd.curdState,
1075
+ getOperate = _useProCurd.getOperate; //根据当前模式展示不同的Title
1076
+
1077
+
1078
+ var getTitle = function getTitle() {
1079
+ var _getOperate, _getOperate2, _getOperate3;
1080
+
1081
+ switch (curdState.mode) {
1082
+ case CurdAction.ADD:
1083
+ return (_getOperate = getOperate(CurdAction.ADD)) === null || _getOperate === void 0 ? void 0 : _getOperate.label;
1084
+
1085
+ case CurdAction.EDIT:
1086
+ return (_getOperate2 = getOperate(CurdAction.EDIT)) === null || _getOperate2 === void 0 ? void 0 : _getOperate2.label;
1087
+
1088
+ case CurdAction.DETAIL:
1089
+ return (_getOperate3 = getOperate(CurdAction.DETAIL)) === null || _getOperate3 === void 0 ? void 0 : _getOperate3.label;
1090
+ }
1091
+ };
1092
+
1093
+ var handleCancel = function handleCancel() {
1094
+ curdState.mode = undefined;
1095
+ setReactiveValue(curdState.detailData, {});
1096
+ curdState.detailLoading = false;
1097
+ curdState.addAction = undefined;
1098
+ };
1099
+
1100
+ return function () {
1101
+ return createVNode(ElDialog, mergeProps({
1102
+ "destroyOnClose": true,
1103
+ "title": getTitle(),
1104
+ "modelValue": !!curdState.mode,
1105
+ "onClose": handleCancel
1106
+ }, props), slots);
1107
+ };
1108
+ }
1109
+ });
1110
+ var ProCurdModalConnect = defineComponent({
1111
+ setup: function setup() {
1112
+ var _useProCurd2 = useProCurd(),
1113
+ modalProps = _useProCurd2.modalProps;
1877
1114
 
1878
1115
  return function () {
1879
- return createVNode(ProCurdList, omit(descProps, "slots"), get(descProps, "slots"));
1116
+ return createVNode(ProCurdModal, omit(modalProps === null || modalProps === void 0 ? void 0 : modalProps.value, "slots"), _objectSpread2({
1117
+ "default": function _default() {
1118
+ return [createVNode(ProCurdFormConnect, null, null)];
1119
+ }
1120
+ }, get(modalProps === null || modalProps === void 0 ? void 0 : modalProps.value, "slots")));
1880
1121
  };
1881
1122
  }
1882
1123
  });
1883
1124
 
1884
- export { ContinueAddButton, CurdAddAction, CurdCurrentMode, OkButton, ProCurd, ProCurdDesc, ProCurdDescConnect, ProCurdForm, ProCurdFormConnect, ProCurdList, ProCurdListConnect, ProCurdNet, ProForm, ProFormCascader, ProFormCheckbox, ProFormDatePicker, ProFormItem, ProFormList, ProFormRadio, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextNumber, ProFormTimePicker, ProFormTreeSelect, ProModule, ProOperateButton, ProSchemaForm, ProSearchForm, ProSelect, ProSubmitButton, ProTable, SearchMode, convertPathToList, createFormItemComponent, defaultPage, getColumnFormItemName, getColumnValueType, getFormItemEl, getItemEl, getValidValues, provideProCurdModule, provideProForm, provideProFormList, provideProModule, useProCurdModule, useProForm, useProFormList, useProModule };
1125
+ export { ContinueAddButton, OkButton, ProCurdDesc, ProCurdDescConnect, ProCurdForm, ProCurdFormConnect, ProCurdList, ProCurdListConnect, ProCurdModal, ProCurdModalConnect, ProForm, ProFormCascader, ProFormCheckbox, ProFormDatePicker, ProFormItem, ProFormList, ProFormRadio, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextNumber, ProFormTimePicker, ProFormTreeSelect, ProGrid, ProList, ProLoading, ProOperateButton, ProSearchForm, ProSelect, ProSubmitButton, ProTable, createFormItemComponent, createLoadingId, defaultPage };