@vue-start/element-pro 0.1.1 → 0.2.1

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,8 +1,8 @@
1
- import { inject, provide, defineComponent, createVNode, mergeProps, ref, reactive, computed, toRaw, Fragment, createTextVNode, withDirectives, isVNode, 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 { keys, omit, forEach, size, map, debounce, some, get, clone, isBoolean, set, isArray, merge, sortBy, filter, isFunction, isNumber, pick } from 'lodash';
4
- import { useEffect, useWatch } from '@vue-start/hooks';
5
- import { getValidValues, getFormItemEl, convertPathToList, getItemEl, useProCurd, CurdAddAction, CurdCurrentMode, useProModule, CurdAction } from '@vue-start/pro';
1
+ import { defineComponent, createVNode, mergeProps, reactive, ref, toRaw, isVNode } from 'vue';
2
+ import { ElRow, ElCol, ElLoading, ElFormItem, ElForm, ElSelect, ElOption, ElInput, ElInputNumber, ElDatePicker, ElTimePicker, ElTreeSelect, ElCheckboxGroup, ElRadioGroup, ElSwitch, ElCascader, ElButton, ElTable, ElTableColumn, ElPagination, ElDescriptions, ElDescriptionsItem, ElDialog } from 'element-plus';
3
+ import { isString, keys, omit, map, get } from 'lodash';
4
+ import { createGrid, generateId, createExpose, createForm, createSearchForm, createFormItemCompFn, useProForm, createFormList, createTable, createCurdForm, CurdCurrentMode, useProCurd, createCurdList, createCurdDesc, CurdAction } from '@vue-start/pro';
5
+ import { useEffect, setReactiveValue } from '@vue-start/hooks';
6
6
 
7
7
  function ownKeys(object, enumerableOnly) {
8
8
  var keys = Object.keys(object);
@@ -78,428 +78,176 @@ function _nonIterableSpread() {
78
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.");
79
79
  }
80
80
 
81
- /**
82
- * ProForm ctx
83
- */
84
- var ProFormKey = Symbol("pro-form");
85
- var useProForm = function useProForm() {
86
- return inject(ProFormKey);
87
- };
88
- var provideProForm = function provideProForm(ctx) {
89
- provide(ProFormKey, ctx);
90
- };
91
- /**
92
- * ProFormList ctx
93
- */
81
+ var ProGrid = createGrid(ElRow, ElCol);
94
82
 
95
- var ProFormListKey = Symbol("pro-form-list");
96
- var useProFormList = function useProFormList() {
97
- return inject(ProFormListKey);
98
- };
99
- var provideProFormList = function provideProFormList(ctx) {
100
- provide(ProFormListKey, ctx);
83
+ var createLoadingId = function createLoadingId() {
84
+ var prefix = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "comp";
85
+ return prefix + "-" + generateId();
101
86
  };
102
87
 
103
- var proFormItemProps$1 = function proFormItemProps() {
88
+ var proLoadingProps = function proLoadingProps() {
104
89
  return {
105
- name: {
106
- type: [String, Array]
107
- }
108
- };
109
- };
110
-
111
- var ProFormItem = defineComponent({
112
- props: _objectSpread2(_objectSpread2({}, ElFormItem.props), proFormItemProps$1()),
113
- setup: function setup(props, _ref) {
114
- var slots = _ref.slots;
115
- var invalidKeys = keys(proFormItemProps$1());
116
- return function () {
117
- return createVNode(ElFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name", "prop"])), {
118
- "prop": props.prop || props.name
119
- }), slots);
120
- };
121
- }
122
- });
123
-
124
- var proFormProps = function proFormProps() {
125
- return {
126
- /**
127
- * 子组件是否只读样式
128
- */
129
- readonly: {
130
- type: Boolean,
131
- "default": undefined
90
+ loading: {
91
+ type: Boolean
132
92
  },
133
-
134
- /**
135
- * FormComponent 根据此项来确定组件是否显示
136
- * rules 根据rules中方法生成showState对象
137
- */
138
- showState: {
139
- type: Object
93
+ target: {
94
+ type: [String, Object]
140
95
  },
141
- showStateRules: {
142
- type: Object
96
+ body: {
97
+ type: Boolean
143
98
  },
144
-
145
- /**
146
- * 是否只读
147
- */
148
- readonlyState: {
149
- type: Object
99
+ fullscreen: {
100
+ type: Boolean
150
101
  },
151
- readonlyStateRules: {
152
- type: Object
102
+ lock: {
103
+ type: Boolean
153
104
  },
154
-
155
- /**
156
- * 是否disabled
157
- */
158
- disableState: {
159
- type: Object
105
+ text: {
106
+ type: String
160
107
  },
161
- disableStateRules: {
162
- type: Object
108
+ spinner: {
109
+ type: String
163
110
  },
164
-
165
- /**
166
- * 展示控件集合,readonly模式下使用这些组件渲染
167
- */
168
- elementMap: {
169
- type: Object
111
+ background: {
112
+ type: String
170
113
  },
171
-
172
- /**
173
- * provide传递
174
- */
175
- provideExtra: {
176
- type: Object
114
+ customClass: {
115
+ type: String
177
116
  }
178
117
  };
179
118
  };
180
119
 
181
- //emit;
182
- var ProForm = defineComponent({
183
- props: _objectSpread2(_objectSpread2({}, ElForm.props), proFormProps()),
184
- setup: function setup(props, _ref2) {
185
- var slots = _ref2.slots,
186
- expose = _ref2.expose,
187
- emit = _ref2.emit;
188
- var form = ref();
189
- var formState = props.model || reactive({}); //组件状态相关
190
-
191
- var showState = props.showState || reactive({});
192
- var readonlyState = props.readonlyState || reactive({});
193
- var disableState = props.disableState || reactive({}); //formState改变情况下,更新 showState,readonlyState,disableState状态
194
-
120
+ var ProLoading = defineComponent({
121
+ props: _objectSpread2({}, proLoadingProps()),
122
+ setup: function setup(props, _ref) {
123
+ var slots = _ref.slots;
124
+ var id = createLoadingId();
195
125
  useEffect(function () {
196
- if (props.showStateRules) {
197
- forEach(props.showStateRules, function (fn, key) {
198
- showState[key] = fn(formState);
199
- });
126
+ if (!props.loading) {
127
+ return;
200
128
  }
201
129
 
202
- if (props.readonlyStateRules) {
203
- forEach(props.readonlyStateRules, function (fn, key) {
204
- readonlyState[key] = fn(formState);
205
- });
206
- }
130
+ var element = props.target;
207
131
 
208
- if (props.disableStateRules) {
209
- forEach(props.disableStateRules, function (fn, key) {
210
- disableState[key] = fn(formState);
211
- });
132
+ if (!slots["default"]) {
133
+ //监听
134
+ if (props.target && isString(props.target)) {
135
+ element = document.querySelector("#" + props.target);
136
+ }
137
+ } else {
138
+ //包裹
139
+ element = document.getElementById(id);
212
140
  }
213
- }, formState); //转换为ref对象
214
-
215
- var readonly = computed(function () {
216
- return props.readonly;
217
- });
218
- provideProForm(_objectSpread2({
219
- formRef: form,
220
- formState: formState,
221
- showState: showState,
222
- readonlyState: readonlyState,
223
- disableState: disableState,
224
- //
225
- elementMap: props.elementMap,
226
- //
227
- readonly: readonly
228
- }, props.provideExtra));
229
141
 
230
- var formRef = function formRef(el) {
231
- var nexEl = _objectSpread2(_objectSpread2({}, el), {}, {
232
- submit: function submit() {
233
- var _el$validate;
234
-
235
- (_el$validate = el.validate) === null || _el$validate === void 0 ? void 0 : _el$validate.call(el, function (isValid, invalidFields) {
236
- if (isValid) {
237
- //验证成功
238
- //删除不显示的值再触发事件
239
- var _showValues = getValidValues(formState, showState, props.showStateRules);
142
+ if (!element) {
143
+ return;
144
+ }
240
145
 
241
- emit("finish", _showValues, toRaw(formState));
242
- } else {
243
- emit("finishFailed", invalidFields);
244
- }
245
- });
246
- }
146
+ var instance = ElLoading.service({
147
+ target: element,
148
+ body: props.body,
149
+ fullscreen: props.fullscreen,
150
+ lock: props.lock,
151
+ text: props.text,
152
+ spinner: props.spinner,
153
+ background: props.background,
154
+ customClass: props.customClass
247
155
  });
248
-
249
- expose(nexEl);
250
- form.value = nexEl;
251
- };
252
-
253
- var invalidKeys = keys(proFormProps());
156
+ return function () {
157
+ instance && instance.close();
158
+ };
159
+ }, function () {
160
+ return props.loading;
161
+ });
254
162
  return function () {
255
- return createVNode(ElForm, mergeProps({
256
- "ref": formRef
257
- }, omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["model"])), {
258
- "model": formState
259
- }), slots);
163
+ if (!slots["default"]) {
164
+ return null;
165
+ }
166
+
167
+ return createVNode("div", {
168
+ "id": id
169
+ }, [slots["default"]()]);
260
170
  };
261
171
  }
262
172
  });
263
173
 
264
- var proSchemaFormProps = function proSchemaFormProps() {
174
+ var proFormItemProps = function proFormItemProps() {
265
175
  return {
266
- columns: {
267
- type: Array
268
- },
269
-
270
- /**
271
- * 录入控件集合,通过column->valueType 查找对应的录入组件
272
- */
273
- formElementMap: {
274
- type: Object
275
- },
276
-
277
- /**
278
- * 是否启用rules验证
279
- */
280
- needRules: {
281
- type: Boolean,
282
- "default": true
176
+ name: {
177
+ type: [String, Array]
283
178
  }
284
179
  };
285
180
  };
286
181
 
287
- var ProSchemaForm = defineComponent({
288
- name: "PSchemaForm",
289
- props: _objectSpread2(_objectSpread2({}, ProForm.props), proSchemaFormProps()),
182
+ var ProFormItem = defineComponent({
183
+ props: _objectSpread2(_objectSpread2({}, ElFormItem.props), proFormItemProps()),
290
184
  setup: function setup(props, _ref) {
291
- var slots = _ref.slots,
292
- expose = _ref.expose;
293
- var formItemList = computed(function () {
294
- if (!props.formElementMap || size(props.formElementMap) <= 0) {
295
- return null;
296
- }
297
-
298
- return map(props.columns, function (item) {
299
- return getFormItemEl(props.formElementMap, item, props.needRules);
300
- });
301
- });
302
- var invalidKeys = keys(proSchemaFormProps());
185
+ var slots = _ref.slots;
186
+ var invalidKeys = keys(proFormItemProps());
303
187
  return function () {
304
- var _slots$default;
305
-
306
- return createVNode(ProForm, mergeProps({
307
- "ref": function ref(el) {
308
- return expose(el);
309
- }
310
- }, omit(props, invalidKeys)), _objectSpread2({
311
- "default": function _default() {
312
- return [formItemList.value, (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
313
- }
314
- }, omit(slots, "default")));
188
+ return createVNode(ElFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name", "prop"])), {
189
+ "prop": props.prop || props.name
190
+ }), slots);
315
191
  };
316
192
  }
317
193
  });
318
-
319
- var SearchMode;
320
-
321
- (function (SearchMode) {
322
- SearchMode["AUTO"] = "AUTO";
323
- SearchMode["MANUAL"] = "MANUAL";
324
- })(SearchMode || (SearchMode = {}));
325
-
326
- var proSearchFormProps = function proSearchFormProps() {
327
- return {
328
- /**
329
- * 初始化触发 onFinish
330
- */
331
- initEmit: {
332
- type: Boolean,
333
- "default": true
334
- },
335
-
336
- /**
337
- * 模式 自动触发或者手动触发 onFinish
338
- */
339
- searchMode: {
340
- type: String,
341
- "default": SearchMode.AUTO
342
- },
343
-
344
- /**
345
- * 需要debounce处理的字段
346
- */
347
- debounceKeys: {
348
- type: Array
349
- },
350
- debounceTime: {
351
- type: Number,
352
- "default": 800
353
- },
354
- //
355
- inline: {
356
- type: Boolean,
357
- "default": true
358
- }
359
- };
360
- };
361
-
362
- var ProSearchForm = defineComponent({
363
- name: "PSearchForm",
364
- props: _objectSpread2(_objectSpread2({}, omit(ProSchemaForm.props, "inline")), proSearchFormProps()),
365
- setup: function setup(props, _ref) {
366
- var slots = _ref.slots,
367
- emit = _ref.emit,
368
- expose = _ref.expose;
194
+ var Form = defineComponent({
195
+ props: _objectSpread2({}, ElForm.props),
196
+ setup: function setup(props, _ref2) {
197
+ var slots = _ref2.slots,
198
+ emit = _ref2.emit,
199
+ expose = _ref2.expose;
369
200
  var formState = props.model || reactive({});
370
-
371
- var handleFinish = function handleFinish() {
372
- var values = toRaw(formState);
373
- var showValues = getValidValues(values, props.showState, props.showStateRules);
374
- emit("finish", showValues, values);
375
- };
376
-
377
- var debounceFinish = debounce(function () {
378
- handleFinish();
379
- }, props.debounceTime); //初始化
380
-
201
+ var formRef = ref();
202
+ var formMethods = ["clearValidate", "resetFields", "scrollToField", "validate", "validateField", "submit"];
381
203
  useEffect(function () {
382
- if (props.initEmit) {
383
- handleFinish();
384
- }
385
- }, []);
386
-
387
- var isDebounceDataChange = function isDebounceDataChange(state, prevState, debounceKeys) {
388
- return some(debounceKeys, function (key) {
389
- return get(state, key) !== get(prevState, key);
390
- });
391
- }; //监听
392
-
393
-
394
- useEffect(function (state, prevState) {
395
- if (props.searchMode !== SearchMode.AUTO) {
396
- return;
397
- } //如果改变的值中包括debounceKeys中注册的 延时触发
398
-
399
-
400
- if (props.debounceKeys && size(props.debounceKeys) > 0 && isDebounceDataChange(state, prevState, props.debounceKeys)) {
401
- debounceFinish();
204
+ if (!formRef.value) {
402
205
  return;
403
206
  }
404
207
 
405
- handleFinish();
406
- }, function () {
407
- return clone(formState);
408
- });
409
- var invalidKeys = keys(proSearchFormProps());
208
+ formRef.value.submit = function () {
209
+ var _formRef$value;
210
+
211
+ (_formRef$value = formRef.value) === null || _formRef$value === void 0 ? void 0 : _formRef$value.validate(function (isValid, invalidFields) {
212
+ if (isValid) {
213
+ emit("finish", toRaw(formState));
214
+ } else {
215
+ emit("finishFailed", invalidFields);
216
+ }
217
+ });
218
+ };
219
+ }, []);
220
+ expose(createExpose(formMethods, formRef));
410
221
  return function () {
411
- return createVNode(ProSchemaForm, mergeProps({
412
- "ref": function ref(el) {
413
- return expose(el);
414
- },
415
- "inline": props.inline
416
- }, omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["model"])), {
417
- "needRules": false,
222
+ return createVNode(ElForm, mergeProps({
223
+ "ref": formRef
224
+ }, omit(props, "model"), {
418
225
  "model": formState
419
226
  }), slots);
420
227
  };
421
228
  }
422
229
  });
230
+ //emit;
231
+ var ProForm = createForm(Form, ProGrid);
232
+ var ProSearchForm = createSearchForm(ProForm, {
233
+ needRules: {
234
+ type: Boolean,
235
+ "default": false
236
+ },
237
+ inline: {
238
+ type: Boolean,
239
+ "default": true
240
+ }
241
+ });
423
242
 
424
- var proFormItemProps = function proFormItemProps() {
243
+ var createFormItemComponent = createFormItemCompFn(ProFormItem, function (value, setValue, disabled) {
425
244
  return {
426
- readonly: {
427
- type: Boolean,
428
- "default": undefined
429
- },
430
- fieldProps: {
431
- type: Object
432
- },
433
- showProps: {
434
- type: Object
435
- }
245
+ modelValue: value,
246
+ "onUpdate:modelValue": setValue,
247
+ clearable: true,
248
+ disabled: disabled
436
249
  };
437
- };
438
-
439
- var createFormItemComponent = function createFormItemComponent(_ref) {
440
- var InputComp = _ref.InputComp,
441
- valueType = _ref.valueType,
442
- name = _ref.name;
443
- return defineComponent({
444
- name: name,
445
- props: _objectSpread2(_objectSpread2({}, ProFormItem.props), proFormItemProps()),
446
- setup: function setup(props, _ref2) {
447
- var slots = _ref2.slots;
448
-
449
- var _useProForm = useProForm(),
450
- formState = _useProForm.formState,
451
- showState = _useProForm.showState,
452
- readonlyState = _useProForm.readonlyState,
453
- disableState = _useProForm.disableState,
454
- formReadonly = _useProForm.readonly,
455
- elementMap = _useProForm.elementMap;
456
-
457
- var formListCtx = useProFormList(); //优先级 props.readonly > readonlyState > formContext.readonly
458
-
459
- var readonly = computed(function () {
460
- if (isBoolean(props.readonly)) {
461
- return props.readonly;
462
- } else if (isBoolean(readonlyState[props.name])) {
463
- return readonlyState[props.name];
464
- }
465
-
466
- return formReadonly.value;
467
- });
468
- var nameList = convertPathToList(props.name);
469
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
470
- var invalidKeys = keys(proFormItemProps());
471
- return function () {
472
- var show = get(showState, props.name);
473
-
474
- if (isBoolean(show) && !show) {
475
- return null;
476
- }
477
-
478
- var value = get(formState, path); //valueType对应的展示组件
479
-
480
- var ShowComp = get(elementMap, valueType);
481
- return createVNode(ProFormItem, mergeProps(omit.apply(void 0, [props].concat(_toConsumableArray(invalidKeys), ["name"])), {
482
- "name": path
483
- }), {
484
- "default": function _default() {
485
- return [readonly.value ? createVNode(Fragment, null, [ShowComp ? createVNode(ShowComp, mergeProps({
486
- "value": value
487
- }, props.fieldProps, {
488
- "showProps": props.showProps
489
- }), slots) : createVNode("span", null, [value])]) : createVNode(InputComp, mergeProps({
490
- "modelValue": value,
491
- "onUpdate:modelValue": function onUpdateModelValue(v) {
492
- set(formState, path, v);
493
- },
494
- "clearable": true,
495
- "disabled": get(disableState, props.name)
496
- }, props.fieldProps), slots)];
497
- }
498
- });
499
- };
500
- }
501
- });
502
- };
250
+ });
503
251
 
504
252
  var proSelectProps = function proSelectProps() {
505
253
  return {
@@ -519,7 +267,7 @@ var ProSelect = defineComponent({
519
267
 
520
268
  return createVNode(ElSelect, mergeProps(omit(props, invalidKeys), {
521
269
  "onUpdate:modelValue": function onUpdateModelValue(v) {
522
- emit("update:modelValue", v);
270
+ emit("update:modelValue", v ? v : undefined);
523
271
  }
524
272
  }), _objectSpread2({
525
273
  "default": function _default() {
@@ -608,24 +356,7 @@ var ProSubmitButton = defineComponent({
608
356
  }
609
357
  });
610
358
 
611
- var FormListProvider = defineComponent({
612
- props: {
613
- pathList: {
614
- type: Array
615
- }
616
- },
617
- setup: function setup(props, _ref) {
618
- var slots = _ref.slots;
619
- provideProFormList({
620
- pathList: props.pathList
621
- });
622
- return function () {
623
- var _slots$default;
624
-
625
- return (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots);
626
- };
627
- }
628
- });
359
+ var FormList = createFormList(ProFormItem);
629
360
 
630
361
  var proFormListProps = function proFormListProps() {
631
362
  return {
@@ -636,671 +367,230 @@ var proFormListProps = function proFormListProps() {
636
367
  addButtonProps: {
637
368
  type: Object
638
369
  },
639
- //每行默认id
640
- rowKey: {
370
+ minusButtonText: {
641
371
  type: String,
642
- "default": "id"
372
+ "default": "删除"
373
+ },
374
+ minusButtonProps: {
375
+ type: Object
643
376
  }
644
377
  };
645
378
  };
646
379
 
647
380
  var ProFormList = defineComponent({
648
381
  name: "PFormList",
649
- props: _objectSpread2(_objectSpread2({}, ProFormItem.props), proFormListProps()),
650
- setup: function setup(props, _ref2) {
651
- var slots = _ref2.slots;
652
-
653
- var _useProForm = useProForm(),
654
- formState = _useProForm.formState,
655
- readonly = _useProForm.readonly;
656
-
657
- var formListCtx = useProFormList();
658
- var nameList = convertPathToList(props.prop);
659
- var path = formListCtx !== null && formListCtx !== void 0 && formListCtx.pathList ? [].concat(_toConsumableArray(formListCtx.pathList), _toConsumableArray(nameList)) : nameList;
660
-
661
- var handleAdd = function handleAdd() {
662
- var targetList = get(formState, path);
663
-
664
- if (!isArray(targetList)) {
665
- targetList = [];
666
- }
667
-
668
- targetList.push(_defineProperty({}, props.rowKey, new Date().valueOf()));
669
- set(formState, path, targetList);
670
- };
671
-
672
- var handleRemove = function handleRemove(index) {
673
- var targetList = get(formState, path);
674
-
675
- if (size(targetList) <= 0) {
676
- return;
677
- }
678
-
679
- targetList.splice(index, 1);
680
- };
681
-
382
+ props: _objectSpread2(_objectSpread2({}, FormList.props), proFormListProps()),
383
+ setup: function setup(props, _ref) {
384
+ var slots = _ref.slots;
682
385
  var invalidKeys = keys(proFormListProps());
683
386
  return function () {
684
- return createVNode(ProFormItem, omit(props, invalidKeys), {
685
- "default": function _default() {
686
- return [map(get(formState, path), function (item, index) {
687
- var _slots$default2;
688
-
689
- return createVNode(FormListProvider, {
690
- "key": index,
691
- "pathList": [].concat(_toConsumableArray(path), [index])
692
- }, {
693
- "default": function _default() {
694
- return [createVNode("div", {
695
- "class": "pro-form-list-item"
696
- }, [(_slots$default2 = slots["default"]) === null || _slots$default2 === void 0 ? void 0 : _slots$default2.call(slots), !readonly.value && createVNode("div", {
697
- "class": "pro-form-list-item-minus",
698
- "onClick": function onClick() {
699
- return handleRemove(index);
700
- }
701
- }, [slots.minus ? slots.minus() : createVNode(ElButton, {
702
- "link": true
703
- }, {
704
- "default": function _default() {
705
- return [createTextVNode("\u5220\u9664")];
706
- }
707
- })])])];
708
- }
709
- });
710
- }), !readonly.value && createVNode("div", {
711
- "class": "pro-form-list-item-add",
712
- "onClick": handleAdd
713
- }, [slots.add ? slots.add() : createVNode(ElButton, mergeProps({
714
- "type": "primary"
715
- }, props.addButtonProps), {
387
+ return createVNode(FormList, omit(props, invalidKeys), _objectSpread2({
388
+ itemMinus: function itemMinus() {
389
+ return createVNode(ElButton, props.minusButtonProps, {
390
+ "default": function _default() {
391
+ return [props.minusButtonText];
392
+ }
393
+ });
394
+ },
395
+ add: function add() {
396
+ return createVNode(ElButton, props.addButtonProps, {
716
397
  "default": function _default() {
717
398
  return [props.addButtonText];
718
399
  }
719
- })])];
400
+ });
720
401
  }
721
- });
402
+ }, slots));
722
403
  };
723
404
  }
724
405
  });
725
406
 
726
- var proTableProps = function proTableProps() {
727
- return {
728
- //操作栏
729
- operate: {
730
- type: Object
731
- },
732
- //默认空字符串
733
- columnEmptyText: {
734
- type: String
735
- },
736
-
737
- /**
738
- * 公共column,会merge到columns item中
739
- */
740
- column: {
741
- type: Object
742
- },
743
- //
407
+ var Table = defineComponent({
408
+ props: _objectSpread2(_objectSpread2({}, ElTable.props), {}, {
744
409
  columns: {
745
410
  type: Array
746
411
  },
747
-
748
- /**
749
- * 展示控件集合,readonly模式下使用这些组件渲染
750
- */
751
- elementMap: {
752
- type: Object
412
+ dataSource: {
413
+ type: Array
753
414
  },
754
-
755
- /**
756
- * loading
757
- */
758
415
  loading: {
759
- type: Boolean,
760
- "default": false
416
+ type: Boolean
761
417
  }
762
- };
763
- };
764
-
765
- var ProTable = defineComponent({
766
- props: _objectSpread2(_objectSpread2({}, ElTable.props), proTableProps()),
418
+ }),
767
419
  setup: function setup(props, _ref) {
768
- var slots = _ref.slots,
769
- expose = _ref.expose;
770
- var columns = computed(function () {
771
- //根据valueType选择对应的展示组件
772
- var columns = map(props.columns, function (item) {
773
- //merge从共item
774
- var nextItem = merge(props.column, item);
775
-
776
- if (!item.customRender || !item.formatter) {
777
- nextItem.customRender = function (_ref2) {
778
- var text = _ref2.text;
779
- return getItemEl(props.elementMap, _objectSpread2(_objectSpread2({}, item), {}, {
780
- showProps: _objectSpread2(_objectSpread2({}, item.showProps), {}, {
781
- content: props.columnEmptyText
782
- })
783
- }), text) || text || props.columnEmptyText;
784
- };
785
- }
786
-
787
- return nextItem;
788
- });
789
- var operate = props.operate; //处理operate
790
-
791
- if (operate && size(operate.items) > 0) {
792
- //将itemState补充的信息拼到item中
793
- var completeItems = map(operate.items, function (i) {
794
- return _objectSpread2(_objectSpread2({}, i), get(operate.itemState, i.value));
795
- }); //排序
796
-
797
- var operateList = sortBy(completeItems, function (item) {
798
- return item.sort;
799
- });
800
- columns.push(_objectSpread2(_objectSpread2({
801
- title: "操作",
802
- valueType: "option",
803
- fixed: "right"
804
- }, props.column), {}, {
805
- customRender: function customRender(_ref3) {
806
- var record = _ref3.record;
807
- var validList = filter(operateList, function (item) {
808
- if (isFunction(item.show)) {
809
- return item.show(record);
810
- }
811
-
812
- if (item.show === false) {
813
- return false;
814
- }
815
-
816
- return true;
817
- });
818
- return createVNode("div", {
819
- "class": "pro-table-operate"
820
- }, [map(validList, function (item) {
821
- // 自定义
822
- if (isFunction(item.element)) {
823
- return item.element(record, item);
824
- }
825
-
826
- return createVNode(ElButton, {
827
- "key": item.value,
828
- "type": "primary",
829
- "link": true,
830
- "disabled": isFunction(item.disabled) ? item.disabled(record) : item.disabled,
831
- "onClick": function onClick() {
832
- var _item$onClick;
833
-
834
- (_item$onClick = item.onClick) === null || _item$onClick === void 0 ? void 0 : _item$onClick.call(item, record);
835
- }
836
- }, {
837
- "default": function _default() {
838
- return [item.label];
839
- }
840
- });
841
- })]);
842
- }
843
- }, operate.column));
844
- }
845
-
846
- return columns;
847
- });
848
- var invalidKeys = keys(proTableProps());
420
+ var slots = _ref.slots;
421
+ var id = createLoadingId("table");
849
422
  return function () {
850
- var _slots$default;
423
+ var _slots$start, _slots$default;
851
424
 
852
- return withDirectives(createVNode(ElTable, mergeProps({
853
- "ref": function ref(el) {
854
- expose(el);
855
- }
856
- }, omit(props, invalidKeys)), _objectSpread2({
425
+ return createVNode(ElTable, mergeProps({
426
+ "id": id
427
+ }, omit(props, "columns", "dataSource", "loading"), {
428
+ "data": props.dataSource || props.data
429
+ }), _objectSpread2({
857
430
  "default": function _default() {
858
- return [map(columns.value, function (item) {
859
- var formatter = function formatter(record, column, value, index) {
860
- if (item.formatter) {
861
- return item.formatter(record, column, value, index);
862
- }
863
-
864
- if (item.customRender) {
865
- return item.customRender({
866
- value: value,
867
- text: value,
868
- record: record,
869
- column: column
870
- });
871
- }
872
-
873
- return null;
874
- };
875
-
431
+ return [(_slots$start = slots.start) === null || _slots$start === void 0 ? void 0 : _slots$start.call(slots), map(props.columns, function (item) {
876
432
  return createVNode(ElTableColumn, mergeProps({
877
- "key": item.dataIndex || item.prop
433
+ "key": item.dataIndex
878
434
  }, omit(item, "title", "label", "renderHeader", "prop", "dataIndex", "formatter", "customRender"), {
879
- "label": isVNode(item.title) ? undefined : item.title || item.label,
435
+ "label": isVNode(item.title) ? undefined : item.title || get(item, "label"),
880
436
  "renderHeader": isVNode(item.title) ? function () {
881
437
  return item.title;
882
438
  } : undefined,
883
- "prop": item.dataIndex || item.prop,
884
- "formatter": item.formatter || item.customRender ? formatter : undefined
439
+ "prop": item.dataIndex,
440
+ "formatter": function formatter(record, column, value, index) {
441
+ if (item.customRender) {
442
+ return item.customRender({
443
+ value: value,
444
+ text: value,
445
+ record: record,
446
+ column: column,
447
+ index: index
448
+ });
449
+ }
450
+
451
+ return value;
452
+ }
885
453
  }), null);
886
- }), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots)];
454
+ }), (_slots$default = slots["default"]) === null || _slots$default === void 0 ? void 0 : _slots$default.call(slots), props.loading && createVNode(ProLoading, {
455
+ "target": id,
456
+ "loading": true
457
+ }, null)];
887
458
  }
888
- }, omit(slots, "default"))), [[resolveDirective("loading"), props.loading]]);
459
+ }, omit(slots, "default", "start")));
889
460
  };
890
461
  }
891
462
  });
463
+ var ProTable = createTable(Table);
892
464
 
893
- var defaultPage = {
894
- page: 1,
895
- pageSize: 10
896
- };
897
-
898
- var proListProps = function proListProps() {
465
+ var ProCurdForm = createCurdForm(ProForm, ElButton, function (curdState) {
899
466
  return {
900
- /**
901
- * extra 是否放到SearchForm中
902
- */
903
- extraInSearch: {
904
- type: Boolean,
905
- "default": undefined
906
- },
907
- //search
908
- searchProps: {
909
- type: Object
910
- },
911
- //table
912
- tableProps: {
913
- type: Object
914
- },
915
- //pagination
916
- paginationProps: {
917
- type: Object
918
- },
919
- //pageState
920
- pageState: {
921
- type: Object
922
- }
467
+ hideRequiredAsterisk: curdState.mode === CurdCurrentMode.DETAIL
923
468
  };
924
- };
925
-
926
- var ProList = defineComponent({
927
- props: _objectSpread2({}, proListProps()),
928
- setup: function setup(props, _ref) {
929
- var _props$searchProps;
930
-
931
- var slots = _ref.slots,
932
- emit = _ref.emit;
933
-
934
- /******************* search pagination ********************/
935
- var searchState = ((_props$searchProps = props.searchProps) === null || _props$searchProps === void 0 ? void 0 : _props$searchProps.model) || reactive({});
936
- var pageState = props.pageState || reactive(_objectSpread2({}, defaultPage));
937
-
938
- var handleSearch = function handleSearch() {
939
- emit("list", _objectSpread2(_objectSpread2({}, searchState), pageState));
940
- }; //页数重置1 且搜索
941
-
942
-
943
- var executeSearchWithResetPage = function executeSearchWithResetPage() {
944
- pageState.page = 1;
945
- handleSearch();
946
- }; //无SearchForm组件 初始化 触发
947
-
948
-
949
- useEffect(function () {
950
- var _props$searchProps2, _props$searchProps3;
951
-
952
- if (size((_props$searchProps2 = props.searchProps) === null || _props$searchProps2 === void 0 ? void 0 : _props$searchProps2.columns) <= 0 && ((_props$searchProps3 = props.searchProps) === null || _props$searchProps3 === void 0 ? void 0 : _props$searchProps3.initEmit) !== false) {
953
- handleSearch();
954
- }
955
- }, []); //无SearchForm组件 订阅searchState
956
-
957
- useWatch(function () {
958
- var _props$searchProps4;
959
-
960
- if (size((_props$searchProps4 = props.searchProps) === null || _props$searchProps4 === void 0 ? void 0 : _props$searchProps4.columns) <= 0) {
961
- executeSearchWithResetPage();
962
- }
963
- }, searchState);
964
- return function () {
965
- var _slots$divide, _slots$divide2;
966
-
967
- var searchProps = props.searchProps;
968
- var tableProps = props.tableProps;
969
- var paginationProps = props.paginationProps; //操作按钮
970
-
971
- var extra = slots.extra ? createVNode("div", {
972
- "class": "pro-list-search"
973
- }, [slots.extra()]) : null; //分页参数
974
-
975
- var pagination = _objectSpread2(_objectSpread2({}, paginationProps), {}, {
976
- currentPage: pageState.page,
977
- pageSize: pageState.pageSize,
978
- onSizeChange: function onSizeChange(pageSize) {
979
- pageState.pageSize = pageSize;
980
- handleSearch();
981
- },
982
- onCurrentChange: function onCurrentChange(current) {
983
- pageState.page = current;
984
- handleSearch();
985
- }
986
- });
987
-
988
- return createVNode(Fragment, null, [size(searchProps === null || searchProps === void 0 ? void 0 : searchProps.columns) > 0 && createVNode(ProSearchForm, mergeProps(searchProps, {
989
- "model": searchState,
990
- "onFinish": executeSearchWithResetPage
991
- }), {
992
- "default": function _default() {
993
- return [props.extraInSearch && extra];
994
- }
995
- }), (_slots$divide = slots.divide) === null || _slots$divide === void 0 ? void 0 : _slots$divide.call(slots), (size(searchProps === null || searchProps === void 0 ? void 0 : searchProps.columns) <= 0 || !props.extraInSearch) && extra, slots["default"] ? slots["default"]() : createVNode(ProTable, 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), 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)])]);
996
- };
997
- }
998
469
  });
999
-
1000
- /**
1001
- * 添加 和 修改 时候的确定按钮
1002
- */
1003
-
1004
- var OkButton = defineComponent({
1005
- props: _objectSpread2({}, ElButton.props),
1006
- setup: function setup(props, _ref) {
1007
- var slots = _ref.slots;
1008
-
470
+ var ProCurdFormConnect = defineComponent({
471
+ setup: function setup() {
1009
472
  var _useProCurd = useProCurd(),
1010
- curdState = _useProCurd.curdState;
473
+ formProps = _useProCurd.formProps;
1011
474
 
1012
475
  return function () {
1013
- return createVNode(ProSubmitButton, mergeProps({
1014
- "onClick": function onClick() {
1015
- curdState.addAction = CurdAddAction.NORMAL;
1016
- }
1017
- }, props, {
1018
- "loading": curdState.operateLoading
1019
- }), {
1020
- "default": function _default() {
1021
- return [slots["default"] ? slots["default"]() : "确定"];
1022
- }
1023
- });
476
+ 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"));
1024
477
  };
1025
478
  }
1026
479
  });
1027
- /**
1028
- * 添加 时候的 确定并继续添加按钮
1029
- */
1030
-
1031
- var ContinueAddButton = defineComponent({
1032
- props: _objectSpread2({}, ElButton.props),
1033
- setup: function setup(props, _ref2) {
1034
- var slots = _ref2.slots;
1035
480
 
1036
- var _useProCurd2 = useProCurd(),
1037
- curdState = _useProCurd2.curdState;
481
+ var CurdList = createCurdList(ProSearchForm, ProTable);
1038
482
 
1039
- return function () {
1040
- return createVNode(ProSubmitButton, mergeProps({
1041
- "onClick": function onClick() {
1042
- curdState.addAction = CurdAddAction.CONTINUE;
1043
- }
1044
- }, props, {
1045
- "loading": curdState.operateLoading
1046
- }), {
1047
- "default": function _default() {
1048
- return [slots["default"] ? slots["default"]() : "确定并继续"];
1049
- }
1050
- });
1051
- };
1052
- }
1053
- });
1054
-
1055
- var proOperateButtonProps = function proOperateButtonProps() {
1056
- return {
1057
- //显示 确定并继续 按钮
1058
- showContinueAdd: {
1059
- type: Boolean,
1060
- "default": false
1061
- },
1062
- //
1063
- okText: {
1064
- type: String,
1065
- "default": "确定"
1066
- },
1067
- okButtonProps: {
1068
- type: Object
1069
- },
1070
- //
1071
- continueText: {
1072
- type: String,
1073
- "default": "确定并继续"
1074
- },
1075
- continueButtonProps: {
483
+ /**
484
+ * 组合列表
485
+ * SearchForm + Table + Pagination
486
+ */
487
+ var ProCurdList = defineComponent({
488
+ props: _objectSpread2(_objectSpread2({}, CurdList.props), {}, {
489
+ paginationProps: {
1076
490
  type: Object
1077
491
  }
1078
- };
1079
- };
1080
-
1081
- var ProOperateButton = defineComponent({
1082
- props: _objectSpread2({}, proOperateButtonProps()),
1083
- setup: function setup(props, _ref3) {
1084
- var slots = _ref3.slots;
1085
-
1086
- var _useProCurd3 = useProCurd(),
1087
- curdState = _useProCurd3.curdState;
1088
-
492
+ }),
493
+ setup: function setup(props, _ref) {
494
+ var slots = _ref.slots;
1089
495
  return function () {
1090
- var _slots$left, _slots$center, _slots$right;
1091
-
1092
- return createVNode("div", {
1093
- "class": "pro-curd-form-operate"
1094
- }, [(_slots$left = slots.left) === null || _slots$left === void 0 ? void 0 : _slots$left.call(slots), createVNode(OkButton, props.okButtonProps, {
1095
- "default": function _default() {
1096
- return [props.okText];
1097
- }
1098
- }), (_slots$center = slots.center) === null || _slots$center === void 0 ? void 0 : _slots$center.call(slots), curdState.mode === CurdCurrentMode.ADD && props.showContinueAdd && createVNode(ContinueAddButton, props.continueButtonProps, {
1099
- "default": function _default() {
1100
- return [props.continueText];
496
+ return createVNode(CurdList, omit(props, "paginationProps"), _objectSpread2({
497
+ pagination: function pagination(pageState, total, handleSearch) {
498
+ return createVNode(ElPagination, mergeProps(props.paginationProps, {
499
+ "total": total,
500
+ "currentPage": pageState.page,
501
+ "pageSize": pageState.pageSize,
502
+ "onSizeChange": function onSizeChange(pageSize) {
503
+ pageState.pageSize = pageSize;
504
+ handleSearch();
505
+ },
506
+ "onCurrentChange": function onCurrentChange(current) {
507
+ pageState.page = current;
508
+ handleSearch();
509
+ }
510
+ }), null);
1101
511
  }
1102
- }), (_slots$right = slots.right) === null || _slots$right === void 0 ? void 0 : _slots$right.call(slots)]);
512
+ }, slots));
1103
513
  };
1104
514
  }
1105
515
  });
1106
-
1107
- var proCurdFormProps = function proCurdFormProps() {
1108
- return {
1109
- //
1110
- operateButtonProps: {
1111
- type: Object
1112
- }
1113
- };
1114
- };
1115
-
1116
- var ProCurdForm = defineComponent({
1117
- props: _objectSpread2(_objectSpread2({}, ProSchemaForm.props), proCurdFormProps()),
1118
- setup: function setup(props, _ref4) {
1119
- var slots = _ref4.slots;
1120
-
1121
- var _useProModule = useProModule(),
1122
- elementMap = _useProModule.elementMap,
1123
- formElementMap = _useProModule.formElementMap;
1124
-
1125
- var _useProCurd4 = useProCurd(),
1126
- curdState = _useProCurd4.curdState,
1127
- formColumns = _useProCurd4.formColumns,
1128
- sendCurdEvent = _useProCurd4.sendCurdEvent;
1129
-
1130
- var handleFinish = function handleFinish(values) {
1131
- if (curdState.mode === CurdCurrentMode.EDIT) {
1132
- //edit
1133
- sendCurdEvent({
1134
- action: CurdAction.EDIT,
1135
- type: "execute",
1136
- values: values
1137
- });
1138
- } else {
1139
- //add
1140
- sendCurdEvent({
1141
- action: CurdAction.ADD,
1142
- type: "execute",
1143
- values: values
1144
- });
1145
- }
1146
- };
516
+ var ProCurdListConnect = defineComponent({
517
+ setup: function setup() {
518
+ var _useProCurd = useProCurd(),
519
+ listProps = _useProCurd.listProps;
1147
520
 
1148
521
  return function () {
1149
- var _slots$default;
1150
-
1151
- return createVNode(ProSchemaForm, mergeProps({
1152
- "elementMap": elementMap,
1153
- "formElementMap": formElementMap
1154
- }, props, {
1155
- "columns": formColumns,
1156
- "model": curdState.detailData,
1157
- "readonly": curdState.mode === CurdCurrentMode.DETAIL,
1158
- "hideRequiredAsterisk": curdState.mode === CurdCurrentMode.DETAIL,
1159
- "onFinish": handleFinish
1160
- }), _objectSpread2({
1161
- "default": function _default() {
1162
- 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)];
1163
- }
1164
- }, omit(slots, "default")));
522
+ 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"));
1165
523
  };
1166
524
  }
1167
525
  });
1168
- var ProCurdFormConnect = defineComponent({
526
+
527
+ var ProCurdDesc = createCurdDesc(ElDescriptions, ElDescriptionsItem);
528
+ var ProCurdDescConnect = defineComponent({
1169
529
  setup: function setup() {
1170
- var _useProCurd5 = useProCurd(),
1171
- formProps = _useProCurd5.formProps;
530
+ var _useProCurd = useProCurd(),
531
+ descProps = _useProCurd.descProps;
1172
532
 
1173
533
  return function () {
1174
- return createVNode(ProCurdForm, omit(formProps, "slots"), get(formProps, "slots"));
534
+ return createVNode(ProCurdDesc, omit(descProps === null || descProps === void 0 ? void 0 : descProps.value, "slots"), get(descProps === null || descProps === void 0 ? void 0 : descProps.value, "slots"));
1175
535
  };
1176
536
  }
1177
537
  });
1178
538
 
1179
- /**
1180
- * 组合列表
1181
- * SearchForm + Table + Pagination
1182
- */
1183
- var ProCurdList = defineComponent({
1184
- props: _objectSpread2({}, ProList.props),
539
+ var ProCurdModal = defineComponent({
540
+ props: _objectSpread2({}, ElDialog.props),
1185
541
  setup: function setup(props, _ref) {
1186
542
  var slots = _ref.slots;
1187
543
 
1188
- var _useProModule = useProModule(),
1189
- elementMap = _useProModule.elementMap,
1190
- formElementMap = _useProModule.formElementMap;
1191
-
1192
544
  var _useProCurd = useProCurd(),
1193
545
  curdState = _useProCurd.curdState,
1194
- searchColumns = _useProCurd.searchColumns,
1195
- tableColumns = _useProCurd.tableColumns,
1196
- getOperate = _useProCurd.getOperate,
1197
- sendCurdEvent = _useProCurd.sendCurdEvent;
1198
- /******************* table ********************/
546
+ getOperate = _useProCurd.getOperate; //根据当前模式展示不同的Title
1199
547
 
1200
548
 
1201
- var prepareTableItem = function prepareTableItem(action) {
1202
- return _objectSpread2(_objectSpread2({}, pick(getOperate(action), "label", "element", "show", "disabled", "onClick", "sort")), {}, {
1203
- value: action
1204
- });
1205
- }; //table操作栏 items
549
+ var getTitle = function getTitle() {
550
+ var _getOperate, _getOperate2, _getOperate3;
1206
551
 
552
+ switch (curdState.mode) {
553
+ case CurdAction.ADD:
554
+ return (_getOperate = getOperate(CurdAction.ADD)) === null || _getOperate === void 0 ? void 0 : _getOperate.label;
1207
555
 
1208
- var tableOperateItems = [prepareTableItem(CurdAction.DETAIL), prepareTableItem(CurdAction.EDIT), prepareTableItem(CurdAction.DELETE)];
1209
- return function () {
1210
- var _tableProps$operate, _tableProps$operate2, _curdState$listData, _curdState$listData2;
556
+ case CurdAction.EDIT:
557
+ return (_getOperate2 = getOperate(CurdAction.EDIT)) === null || _getOperate2 === void 0 ? void 0 : _getOperate2.label;
1211
558
 
1212
- var tableProps = props.tableProps;
1213
- return createVNode(ProList, mergeProps({
1214
- "onList": function onList(values) {
1215
- sendCurdEvent({
1216
- action: CurdAction.LIST,
1217
- type: "emit",
1218
- values: values
1219
- });
1220
- }
1221
- }, props, {
1222
- "searchProps": _objectSpread2(_objectSpread2({
1223
- formElementMap: formElementMap
1224
- }, props.searchProps), {}, {
1225
- columns: searchColumns.value
1226
- }),
1227
- "tableProps": _objectSpread2(_objectSpread2({
1228
- elementMap: elementMap
1229
- }, tableProps), {}, {
1230
- operate: _objectSpread2(_objectSpread2({}, tableProps === null || tableProps === void 0 ? void 0 : tableProps.operate), {}, {
1231
- items: tableProps !== null && tableProps !== void 0 && (_tableProps$operate = tableProps.operate) !== null && _tableProps$operate !== void 0 && _tableProps$operate.items ? [].concat(tableOperateItems, _toConsumableArray(tableProps === null || tableProps === void 0 ? void 0 : (_tableProps$operate2 = tableProps.operate) === null || _tableProps$operate2 === void 0 ? void 0 : _tableProps$operate2.items)) : tableOperateItems
1232
- }),
1233
- columns: tableColumns.value,
1234
- loading: curdState.listLoading,
1235
- data: (_curdState$listData = curdState.listData) === null || _curdState$listData === void 0 ? void 0 : _curdState$listData.dataSource
1236
- }),
1237
- "paginationProps": _objectSpread2(_objectSpread2({}, props.paginationProps), {}, {
1238
- total: (_curdState$listData2 = curdState.listData) === null || _curdState$listData2 === void 0 ? void 0 : _curdState$listData2.total
1239
- })
1240
- }), slots);
559
+ case CurdAction.DETAIL:
560
+ return (_getOperate3 = getOperate(CurdAction.DETAIL)) === null || _getOperate3 === void 0 ? void 0 : _getOperate3.label;
561
+ }
1241
562
  };
1242
- }
1243
- });
1244
- var ProCurdListConnect = defineComponent({
1245
- setup: function setup() {
1246
- var _useProCurd2 = useProCurd(),
1247
- listProps = _useProCurd2.listProps;
1248
563
 
1249
- return function () {
1250
- return createVNode(ProCurdList, omit(listProps, "slots"), get(listProps, "slots"));
564
+ var handleCancel = function handleCancel() {
565
+ curdState.mode = undefined;
566
+ setReactiveValue(curdState.detailData, {});
567
+ curdState.detailLoading = false;
568
+ curdState.addAction = undefined;
1251
569
  };
1252
- }
1253
- });
1254
-
1255
- function _isSlot(s) {
1256
- return typeof s === 'function' || Object.prototype.toString.call(s) === '[object Object]' && !isVNode(s);
1257
- }
1258
-
1259
- var ProCurdDesc = defineComponent({
1260
- props: _objectSpread2({}, ElDescriptions.props),
1261
- setup: function setup(props, _ref) {
1262
- var slots = _ref.slots;
1263
-
1264
- var _useProModule = useProModule(),
1265
- getItemVNode = _useProModule.getItemVNode;
1266
-
1267
- var _useProCurd = useProCurd(),
1268
- curdState = _useProCurd.curdState,
1269
- descColumns = _useProCurd.descColumns;
1270
570
 
1271
- var descVNodes = computed(function () {
1272
- return map(descColumns.value, function (item) {
1273
- var _slot;
1274
-
1275
- var value = get(curdState.detailData, item.dataIndex);
1276
- return createVNode(ElDescriptionsItem, mergeProps({
1277
- "key": item.dataIndex,
1278
- "label": item.title
1279
- }, get(item.extra, "desc")), _isSlot(_slot = getItemVNode(item, value)) ? _slot : {
1280
- "default": function _default() {
1281
- return [_slot];
1282
- }
1283
- });
1284
- });
1285
- });
1286
571
  return function () {
1287
- return createVNode(ElDescriptions, props, _objectSpread2({
1288
- "default": function _default() {
1289
- return descVNodes.value;
1290
- }
1291
- }, omit(slots, "default")));
572
+ return createVNode(ElDialog, mergeProps({
573
+ "destroyOnClose": true,
574
+ "title": getTitle(),
575
+ "modelValue": !!curdState.mode,
576
+ "onClose": handleCancel
577
+ }, props), slots);
1292
578
  };
1293
579
  }
1294
580
  });
1295
- var ProCurdDescConnect = defineComponent({
581
+ var ProCurdModalConnect = defineComponent({
1296
582
  setup: function setup() {
1297
583
  var _useProCurd2 = useProCurd(),
1298
- descProps = _useProCurd2.descProps;
584
+ modalProps = _useProCurd2.modalProps;
1299
585
 
1300
586
  return function () {
1301
- return createVNode(ProCurdList, omit(descProps, "slots"), get(descProps, "slots"));
587
+ return createVNode(ProCurdModal, omit(modalProps === null || modalProps === void 0 ? void 0 : modalProps.value, "slots"), _objectSpread2({
588
+ "default": function _default() {
589
+ return [createVNode(ProCurdFormConnect, null, null)];
590
+ }
591
+ }, get(modalProps === null || modalProps === void 0 ? void 0 : modalProps.value, "slots")));
1302
592
  };
1303
593
  }
1304
594
  });
1305
595
 
1306
- export { ContinueAddButton, OkButton, ProCurdDesc, ProCurdDescConnect, ProCurdForm, ProCurdFormConnect, ProCurdList, ProCurdListConnect, ProForm, ProFormCascader, ProFormCheckbox, ProFormDatePicker, ProFormItem, ProFormList, ProFormRadio, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextNumber, ProFormTimePicker, ProFormTreeSelect, ProList, ProOperateButton, ProSchemaForm, ProSearchForm, ProSelect, ProSubmitButton, ProTable, SearchMode, createFormItemComponent, defaultPage, provideProForm, provideProFormList, useProForm, useProFormList };
596
+ export { ProCurdDesc, ProCurdDescConnect, ProCurdForm, ProCurdFormConnect, ProCurdList, ProCurdListConnect, ProCurdModal, ProCurdModalConnect, ProForm, ProFormCascader, ProFormCheckbox, ProFormDatePicker, ProFormItem, ProFormList, ProFormRadio, ProFormSelect, ProFormSwitch, ProFormText, ProFormTextNumber, ProFormTimePicker, ProFormTreeSelect, ProGrid, ProLoading, ProSearchForm, ProSelect, ProSubmitButton, ProTable, createFormItemComponent, createLoadingId };