yxuse 3.0.50 → 3.0.52

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.
Files changed (42) hide show
  1. package/README.md +27 -13
  2. package/lib/components.cjs.js +1 -1
  3. package/lib/components.es.js +5 -6
  4. package/lib/index.cjs2.js +1 -1
  5. package/lib/index.cjs5.js +1 -1
  6. package/lib/index.cjs5.js.gz +0 -0
  7. package/lib/index.cjs5.js.map +1 -1
  8. package/lib/index.cjs6.js +3 -3
  9. package/lib/index.cjs6.js.gz +0 -0
  10. package/lib/index.cjs6.js.map +1 -1
  11. package/lib/index.es2.js +2 -2
  12. package/lib/index.es5.js +2 -2
  13. package/lib/index.es5.js.gz +0 -0
  14. package/lib/index.es6.js +201 -201
  15. package/lib/index.es6.js.gz +0 -0
  16. package/lib/index.es6.js.map +1 -1
  17. package/lib/mqtt.min.cjs.js +1 -1
  18. package/lib/mqtt.min.cjs.js.gz +0 -0
  19. package/lib/mqtt.min.cjs.js.map +1 -1
  20. package/lib/mqtt.min.es.js +14 -7
  21. package/lib/mqtt.min.es.js.gz +0 -0
  22. package/lib/mqtt.min.es.js.map +1 -1
  23. package/lib/style.css +1 -1
  24. package/lib/style.css.gz +0 -0
  25. package/lib/theme.cjs.js +1 -1
  26. package/lib/theme.es.js +1 -1
  27. package/lib/translate.cjs.js +1 -1
  28. package/lib/translate.es.js +1 -1
  29. package/lib/utils.cjs.js +1 -1
  30. package/lib/utils.es.js +3 -3
  31. package/package.json +3 -3
  32. package/types/components/YxDialog/index.vue.d.ts +1 -1
  33. package/types/components/YxDrawer/index.vue.d.ts +1 -1
  34. package/types/components/YxForm/index.vue.d.ts +5 -3
  35. package/types/components/YxForm/type.d.ts +5 -5
  36. package/types/components/YxTable/index.vue.d.ts +3 -2
  37. package/types/components/YxTable/type.d.ts +2 -1
  38. package/types/components/YxUpload/index.vue.d.ts +4 -1
  39. package/types/components/index.d.ts +0 -1
  40. package/types/components/type.d.ts +0 -1
  41. package/types/utils/common/index.d.ts +6 -3
  42. package/lib/index.es2.js.gz +0 -0
package/lib/index.es6.js CHANGED
@@ -49,13 +49,13 @@ var __async = (__this, __arguments, generator) => {
49
49
  step((generator = generator.apply(__this, __arguments)).next());
50
50
  });
51
51
  };
52
- import { defineComponent, reactive, resolveComponent, createBlock, openBlock, createSlots, withCtx, renderSlot, createElementVNode, createVNode, createTextVNode, watch, resolveDynamicComponent, mergeProps, createElementBlock, createCommentVNode, Fragment, renderList, useSlots, useAttrs, ref, onMounted, nextTick, withModifiers, isVNode, toDisplayString, unref, normalizeStyle, normalizeClass, version, createApp } from "vue";
52
+ import { defineComponent, reactive, resolveComponent, createBlock, openBlock, createSlots, withCtx, renderSlot, createElementVNode, createVNode, createTextVNode, watch, resolveDynamicComponent, mergeProps, createElementBlock, createCommentVNode, Fragment, renderList, useSlots, useAttrs, ref, onMounted, nextTick, onBeforeMount, withModifiers, isVNode, toDisplayString, unref, normalizeStyle, normalizeClass, version, createApp } from "vue";
53
53
  import { S as Sortable, _ as _export_sfc, T as Toolbar } from "./index.es5.js";
54
+ import { genFileId } from "element-plus";
54
55
  import { j as jumpToHome, b as getUserConfig } from "./index.es12.js";
55
- import "element-plus";
56
56
  import { u as uploadResourceApi } from "./index.es13.js";
57
- const _hoisted_1$3 = { class: "dialog-footer flex justify-end" };
58
- const _sfc_main$9 = /* @__PURE__ */ defineComponent({
57
+ const _hoisted_1$4 = { class: "dialog-footer flex justify-end" };
58
+ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
59
59
  __name: "index",
60
60
  setup(__props, { expose: __expose }) {
61
61
  const dialogOptions = reactive({
@@ -67,6 +67,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
67
67
  autoClose: true
68
68
  });
69
69
  const close = () => {
70
+ dialogMap["cancel"] && dialogMap["cancel"]();
70
71
  dialogOptions.show = false;
71
72
  };
72
73
  const dialogMap = {};
@@ -81,7 +82,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
81
82
  dialogOptions.loading = false;
82
83
  }
83
84
  });
84
- const show = ({ width, title, submit: submit2, cancel, showFooter, autoClose, beforeOpen, beforeSubmit }) => {
85
+ const show = (_0) => __async(this, [_0], function* ({ width, title, submit: submit2, cancel, showFooter, autoClose, beforeOpen, beforeSubmit }) {
85
86
  if (width) dialogOptions.width = width;
86
87
  if (title) dialogOptions.title = title;
87
88
  if (showFooter !== void 0) dialogOptions.showFooter = showFooter;
@@ -89,9 +90,11 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
89
90
  if (submit2) dialogMap["submit"] = submit2;
90
91
  if (cancel) dialogMap["cancel"] = cancel;
91
92
  if (beforeSubmit) dialogMap["beforeSubmit"] = beforeSubmit;
92
- if (beforeOpen) beforeOpen();
93
+ if (beforeOpen) {
94
+ yield beforeOpen();
95
+ }
93
96
  dialogOptions.show = true;
94
- };
97
+ });
95
98
  __expose({
96
99
  show,
97
100
  close
@@ -104,9 +107,10 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
104
107
  attrs: "",
105
108
  width: dialogOptions.width,
106
109
  modelValue: dialogOptions.show,
107
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => dialogOptions.show = $event),
110
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => dialogOptions.show = $event),
108
111
  title: dialogOptions.title,
109
- "destroy-on-close": ""
112
+ "destroy-on-close": "",
113
+ "before-close": close
110
114
  }, createSlots({
111
115
  default: withCtx(() => [
112
116
  renderSlot(_ctx.$slots, "default")
@@ -116,12 +120,12 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
116
120
  dialogOptions.showFooter ? {
117
121
  name: "footer",
118
122
  fn: withCtx(() => [
119
- createElementVNode("span", _hoisted_1$3, [
123
+ createElementVNode("span", _hoisted_1$4, [
120
124
  createVNode(_component_el_button, {
121
125
  plain: "",
122
- onClick: close
126
+ onClick: _cache[0] || (_cache[0] = ($event) => dialogOptions.show = false)
123
127
  }, {
124
- default: withCtx(() => _cache[1] || (_cache[1] = [
128
+ default: withCtx(() => _cache[2] || (_cache[2] = [
125
129
  createTextVNode("取消")
126
130
  ])),
127
131
  _: 1
@@ -130,7 +134,7 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
130
134
  loading: dialogOptions.loading,
131
135
  onClick: submit
132
136
  }, {
133
- default: withCtx(() => _cache[2] || (_cache[2] = [
137
+ default: withCtx(() => _cache[3] || (_cache[3] = [
134
138
  createTextVNode("确认")
135
139
  ])),
136
140
  _: 1
@@ -143,8 +147,8 @@ const _sfc_main$9 = /* @__PURE__ */ defineComponent({
143
147
  };
144
148
  }
145
149
  });
146
- const _hoisted_1$2 = { class: "dialog-footer flex justify-end" };
147
- const _sfc_main$8 = /* @__PURE__ */ defineComponent({
150
+ const _hoisted_1$3 = { class: "dialog-footer flex justify-end" };
151
+ const _sfc_main$7 = /* @__PURE__ */ defineComponent({
148
152
  __name: "index",
149
153
  setup(__props, { expose: __expose }) {
150
154
  const drawerOptions = reactive({
@@ -156,6 +160,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
156
160
  autoClose: true
157
161
  });
158
162
  const close = () => {
163
+ drawerMap["cancel"] && drawerMap["cancel"]();
159
164
  drawerOptions.show = false;
160
165
  };
161
166
  const drawerMap = {};
@@ -170,7 +175,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
170
175
  drawerOptions.loading = false;
171
176
  }
172
177
  });
173
- const show = ({ width, title, submit: submit2, cancel, showFooter, autoClose, beforeOpen, beforeSubmit }) => {
178
+ const show = (_0) => __async(this, [_0], function* ({ width, title, submit: submit2, cancel, showFooter, autoClose, beforeOpen, beforeSubmit }) {
174
179
  if (width) drawerOptions.width = width;
175
180
  if (title) drawerOptions.title = title;
176
181
  if (showFooter !== void 0) drawerOptions.showFooter = showFooter;
@@ -178,9 +183,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
178
183
  if (submit2) drawerMap["submit"] = submit2;
179
184
  if (cancel) drawerMap["cancel"] = cancel;
180
185
  if (beforeSubmit) drawerMap["beforeSubmit"] = beforeSubmit;
181
- if (beforeOpen) beforeOpen();
186
+ if (beforeOpen) {
187
+ yield beforeOpen();
188
+ }
182
189
  drawerOptions.show = true;
183
- };
190
+ });
184
191
  __expose({
185
192
  show,
186
193
  close
@@ -191,10 +198,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
191
198
  return openBlock(), createBlock(_component_el_drawer, {
192
199
  "close-on-click-modal": false,
193
200
  attrs: "",
194
- width: drawerOptions.width,
201
+ size: drawerOptions.width,
195
202
  modelValue: drawerOptions.show,
196
- "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => drawerOptions.show = $event),
197
- title: drawerOptions.title
203
+ "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => drawerOptions.show = $event),
204
+ title: drawerOptions.title,
205
+ "destroy-on-close": "",
206
+ onClose: close
198
207
  }, createSlots({
199
208
  default: withCtx(() => [
200
209
  renderSlot(_ctx.$slots, "default")
@@ -204,12 +213,12 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
204
213
  drawerOptions.showFooter ? {
205
214
  name: "footer",
206
215
  fn: withCtx(() => [
207
- createElementVNode("span", _hoisted_1$2, [
216
+ createElementVNode("span", _hoisted_1$3, [
208
217
  createVNode(_component_el_button, {
209
218
  plain: "",
210
- onClick: close
219
+ onClick: _cache[0] || (_cache[0] = ($event) => drawerOptions.show = false)
211
220
  }, {
212
- default: withCtx(() => _cache[1] || (_cache[1] = [
221
+ default: withCtx(() => _cache[2] || (_cache[2] = [
213
222
  createTextVNode("取消")
214
223
  ])),
215
224
  _: 1
@@ -218,7 +227,7 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
218
227
  loading: drawerOptions.loading,
219
228
  onClick: submit
220
229
  }, {
221
- default: withCtx(() => _cache[2] || (_cache[2] = [
230
+ default: withCtx(() => _cache[3] || (_cache[3] = [
222
231
  createTextVNode("确认")
223
232
  ])),
224
233
  _: 1
@@ -227,11 +236,11 @@ const _sfc_main$8 = /* @__PURE__ */ defineComponent({
227
236
  ]),
228
237
  key: "0"
229
238
  } : void 0
230
- ]), 1032, ["width", "modelValue", "title"]);
239
+ ]), 1032, ["size", "modelValue", "title"]);
231
240
  };
232
241
  }
233
242
  });
234
- const _sfc_main$7 = /* @__PURE__ */ defineComponent({
243
+ const _sfc_main$6 = /* @__PURE__ */ defineComponent({
235
244
  __name: "index",
236
245
  props: {
237
246
  conf: {},
@@ -20450,14 +20459,16 @@ const exportToExcel = ({ header, tableData, fileName }) => {
20450
20459
  function _isSlot$1(s) {
20451
20460
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
20452
20461
  }
20453
- const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
20462
+ const _sfc_main$5 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues({}, {
20454
20463
  name: "YxTable"
20455
20464
  }), {
20456
20465
  __name: "index",
20457
20466
  props: {
20458
20467
  tableData: {},
20459
20468
  rowKey: {},
20460
- columns: {},
20469
+ columns: {
20470
+ type: [Array, Function]
20471
+ },
20461
20472
  pageInfo: {},
20462
20473
  sort: {
20463
20474
  type: Boolean
@@ -20473,12 +20484,28 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20473
20484
  const slots = useSlots();
20474
20485
  const attrs = useAttrs();
20475
20486
  const tableRef = ref();
20487
+ const columns = ref([]);
20476
20488
  const emit = __emit;
20477
20489
  onMounted(() => {
20478
20490
  nextTick(() => {
20479
20491
  startSort();
20480
20492
  });
20481
20493
  });
20494
+ onBeforeMount(() => __async(this, null, function* () {
20495
+ columns.value = typeof props.columns === "function" ? yield props.columns() : props.columns;
20496
+ columns.value.forEach((col) => {
20497
+ var _a;
20498
+ if (!col.renderType) return;
20499
+ if (["select", "cascader"].includes(col.renderType) && ((_a = col == null ? void 0 : col.config) == null ? void 0 : _a.loadOptions)) {
20500
+ loadOptions(col.config);
20501
+ }
20502
+ });
20503
+ }));
20504
+ const loadOptions = (config) => __async(this, null, function* () {
20505
+ if ((config == null ? void 0 : config.options) && (config == null ? void 0 : config.options.length) === 0 && (config == null ? void 0 : config.loadOptions) && typeof (config == null ? void 0 : config.loadOptions) === "function") {
20506
+ config.options = yield config == null ? void 0 : config.loadOptions();
20507
+ }
20508
+ });
20482
20509
  const startSort = () => {
20483
20510
  var _a, _b;
20484
20511
  if (!props.sort) return;
@@ -20496,10 +20523,9 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20496
20523
  }
20497
20524
  });
20498
20525
  };
20499
- const render = (props2) => {
20526
+ const render2 = (props2) => {
20500
20527
  let _slot;
20501
20528
  const {
20502
- columns,
20503
20529
  rowKey,
20504
20530
  tableData,
20505
20531
  pageInfo
@@ -20524,7 +20550,7 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20524
20550
  prop: cell.prop,
20525
20551
  config: cell.config
20526
20552
  };
20527
- return createVNode(_sfc_main$7, {
20553
+ return createVNode(_sfc_main$6, {
20528
20554
  "conf": conf,
20529
20555
  "model": scope.row,
20530
20556
  "onChange": cell == null ? void 0 : cell.change
@@ -20583,114 +20609,52 @@ const _sfc_main$6 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20583
20609
  "onCurrentChange": handleCurrentChange
20584
20610
  }, null)]);
20585
20611
  };
20612
+ if (!columns.value) return;
20586
20613
  return createVNode(Fragment, null, [createVNode(resolveComponent("el-table"), mergeProps({
20587
20614
  "ref": tableRef
20588
20615
  }, attrs, {
20589
20616
  "row-key": rowKey,
20590
20617
  "data": tableData
20591
- }), _isSlot$1(_slot = renderColumn(columns)) ? _slot : {
20618
+ }), _isSlot$1(_slot = renderColumn(columns.value)) ? _slot : {
20592
20619
  default: () => [_slot]
20593
20620
  }), pagination()]);
20594
20621
  };
20595
- const exportDataToExcel = ({
20596
- header,
20597
- tableData,
20598
- fileName
20599
- }) => {
20622
+ const exportDataToExcel = (fileName) => {
20623
+ const header = columns.value.filter((cell) => cell.prop);
20624
+ const tableData = props.tableData;
20600
20625
  exportToExcel({
20601
20626
  header,
20602
20627
  tableData,
20603
- fileName
20628
+ fileName: fileName || Date.now()
20604
20629
  });
20605
20630
  };
20631
+ const updateColumns = (newColumns) => __async(this, null, function* () {
20632
+ if (!columns.value) return;
20633
+ columns.value = typeof newColumns === "function" ? yield newColumns() : newColumns;
20634
+ });
20606
20635
  __expose({
20607
20636
  tableRef,
20608
- exportDataToExcel
20637
+ exportDataToExcel,
20638
+ updateColumns
20609
20639
  });
20610
20640
  return (_ctx, _cache) => {
20611
- return openBlock(), createBlock(resolveDynamicComponent(render(props)));
20641
+ return openBlock(), createBlock(resolveDynamicComponent(render2(props)));
20612
20642
  };
20613
20643
  }
20614
20644
  }));
20615
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
20616
- __name: "index",
20617
- props: {
20618
- searchColumns: {},
20619
- searchParams: {},
20620
- showSearchBtn: {
20621
- type: Boolean,
20622
- default: true
20623
- },
20624
- showAddBtn: {
20625
- type: Boolean,
20626
- default: true
20627
- },
20628
- style: {},
20629
- labelStyle: {},
20630
- className: {},
20631
- classLabelName: {}
20632
- },
20633
- emits: ["search", "add"],
20634
- setup(__props, {
20635
- emit: __emit
20636
- }) {
20637
- const slots = useSlots();
20638
- const props = __props;
20639
- const emit = __emit;
20640
- const render = (props2) => {
20641
- const {
20642
- searchColumns,
20643
- searchParams,
20644
- showSearchBtn,
20645
- showAddBtn,
20646
- style,
20647
- labelStyle,
20648
- className,
20649
- classLabelName
20650
- } = props2;
20651
- const renderColumn = (searchColumns2) => {
20652
- return searchColumns2.filter((cell) => !cell.show || cell.show()).map((cell) => {
20653
- var _a, _b;
20654
- const conf = {
20655
- renderType: cell.renderType,
20656
- prop: cell.key,
20657
- config: cell.config
20658
- };
20659
- return createVNode("div", {
20660
- "class": `flex items-center search-item ${className != null ? className : ""} ${(_a = cell.className) != null ? _a : ""}`,
20661
- "style": __spreadValues(__spreadValues({}, style), cell.style)
20662
- }, [createVNode("span", {
20663
- "class": `whitespace-nowrap label ${classLabelName != null ? classLabelName : ""} ${(_b = cell.classLabelName) != null ? _b : ""}`,
20664
- "style": __spreadValues(__spreadValues({}, labelStyle), cell.labelStyle)
20665
- }, [createTextVNode(" "), cell.label, createTextVNode(" ")]), createVNode(_sfc_main$7, {
20666
- "class": cell.componentClassName,
20667
- "style": cell.componentStyle,
20668
- "conf": conf,
20669
- "model": searchParams,
20670
- "onChange": cell == null ? void 0 : cell.change
20671
- }, null)]);
20672
- });
20673
- };
20674
- return createVNode(Fragment, null, [createVNode("div", {
20675
- "class": "table-search flex gap-10"
20676
- }, [renderColumn(searchColumns), showSearchBtn && createVNode(resolveComponent("el-button"), {
20677
- "onClick": () => emit("search"),
20678
- "class": "search-item"
20679
- }, {
20680
- default: () => [createTextVNode("搜索"), " "]
20681
- }), showAddBtn && createVNode(resolveComponent("el-button"), {
20682
- "class": "search-item",
20683
- "onClick": () => emit("add")
20684
- }, {
20685
- default: () => [createTextVNode("添加")]
20686
- }), slots.default && slots.default()])]);
20687
- };
20688
- return (_ctx, _cache) => {
20689
- return openBlock(), createBlock(resolveDynamicComponent(render(props)));
20690
- };
20691
- }
20692
- });
20693
- const index$2 = /* @__PURE__ */ _export_sfc(_sfc_main$5, [["__scopeId", "data-v-c70da20e"]]);
20645
+ const _hoisted_1$2 = {
20646
+ xmlns: "http://www.w3.org/2000/svg",
20647
+ viewBox: "0 0 1024 1024"
20648
+ };
20649
+ function render(_ctx, _cache) {
20650
+ return openBlock(), createElementBlock("svg", _hoisted_1$2, _cache[0] || (_cache[0] = [
20651
+ createElementVNode("path", {
20652
+ fill: "currentColor",
20653
+ d: "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m23.744 191.488c-52.096 0-92.928 14.784-123.2 44.352-30.976 29.568-45.76 70.4-45.76 122.496h80.256c0-29.568 5.632-52.8 17.6-68.992 13.376-19.712 35.2-28.864 66.176-28.864 23.936 0 42.944 6.336 56.32 19.712 12.672 13.376 19.712 31.68 19.712 54.912 0 17.6-6.336 34.496-19.008 49.984l-8.448 9.856c-45.76 40.832-73.216 70.4-82.368 89.408-9.856 19.008-14.08 42.24-14.08 68.992v9.856h80.96v-9.856c0-16.896 3.52-31.68 10.56-45.76 6.336-12.672 15.488-24.64 28.16-35.2 33.792-29.568 54.208-48.576 60.544-55.616 16.896-22.528 26.048-51.392 26.048-86.592q0-64.416-42.24-101.376c-28.16-25.344-65.472-37.312-111.232-37.312m-12.672 406.208a54.27 54.27 0 0 0-38.72 14.784 49.4 49.4 0 0 0-15.488 38.016c0 15.488 4.928 28.16 15.488 38.016A54.85 54.85 0 0 0 523.072 768c15.488 0 28.16-4.928 38.72-14.784a51.52 51.52 0 0 0 16.192-38.72 51.97 51.97 0 0 0-15.488-38.016 55.94 55.94 0 0 0-39.424-14.784"
20654
+ }, null, -1)
20655
+ ]));
20656
+ }
20657
+ const Question = { render };
20694
20658
  function _isSlot(s) {
20695
20659
  return typeof s === "function" || Object.prototype.toString.call(s) === "[object Object]" && !isVNode(s);
20696
20660
  }
@@ -20719,27 +20683,54 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20719
20683
  }) {
20720
20684
  const formData = ref({});
20721
20685
  const formRules = ref({});
20722
- const initForm = () => {
20686
+ const formColumn = ref([]);
20687
+ const isOptionsComponent = (type) => type && ["select", "cascader"].includes(type);
20688
+ const initForm = () => __async(this, null, function* () {
20689
+ var _a;
20723
20690
  const {
20724
20691
  formList,
20725
20692
  formParams
20726
20693
  } = props;
20727
- if (!(formList == null ? void 0 : formList.length)) return;
20728
- if (!formParams || Object.keys(formParams).length === 0) {
20729
- formList.forEach((item) => {
20730
- var _a;
20731
- if ((_a = item.children) == null ? void 0 : _a.length) {
20732
- item.children.forEach((child) => {
20733
- if (child.prop) formData.value[child == null ? void 0 : child.prop] = "";
20734
- });
20735
- } else if (item.prop) {
20736
- formData.value[item == null ? void 0 : item.prop] = "";
20694
+ formColumn.value = typeof formList === "function" ? yield formList() : formList;
20695
+ if (!Array.isArray(formColumn.value) || formColumn.value.length === 0) {
20696
+ return;
20697
+ }
20698
+ const initialData = {};
20699
+ const fillFormData = (item) => {
20700
+ if (item.prop && !(item.prop in initialData)) {
20701
+ initialData[item.prop] = "";
20702
+ }
20703
+ if (isOptionsComponent(item == null ? void 0 : item.renderType)) {
20704
+ loadOptions(item);
20705
+ }
20706
+ if (Array.isArray(item.children)) {
20707
+ item.children.forEach(fillFormData);
20708
+ }
20709
+ };
20710
+ formColumn.value.forEach((item) => fillFormData(item));
20711
+ if (formParams && Object.keys(formParams).length > 0) {
20712
+ for (const item of formColumn.value) {
20713
+ if (!item.prop) continue;
20714
+ const isAsyncOption = ((_a = item.config) == null ? void 0 : _a.loadOptions) && typeof item.config.loadOptions === "function";
20715
+ if (!(isAsyncOption && formParams[item.prop] !== void 0)) {
20716
+ initialData[item.prop] = formParams[item.prop];
20737
20717
  }
20738
- });
20739
- } else {
20740
- formData.value = formParams;
20718
+ }
20741
20719
  }
20742
- };
20720
+ formData.value = initialData;
20721
+ });
20722
+ const loadOptions = (_0) => __async(this, [_0], function* ({
20723
+ config,
20724
+ prop
20725
+ }) {
20726
+ var _a;
20727
+ if ((config == null ? void 0 : config.options) && (config == null ? void 0 : config.options.length) === 0 && (config == null ? void 0 : config.loadOptions) && typeof (config == null ? void 0 : config.loadOptions) === "function") {
20728
+ config.options = yield config == null ? void 0 : config.loadOptions();
20729
+ if (prop && ((_a = props == null ? void 0 : props.formParams) == null ? void 0 : _a[prop])) {
20730
+ formData.value[prop] = props == null ? void 0 : props.formParams[prop];
20731
+ }
20732
+ }
20733
+ });
20743
20734
  const slots = useSlots();
20744
20735
  const attrs = useAttrs();
20745
20736
  const props = __props;
@@ -20755,34 +20746,38 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20755
20746
  }
20756
20747
  });
20757
20748
  const getRules = () => {
20758
- let rules = {};
20759
- const {
20760
- formList
20761
- } = props;
20762
- if (!(formList == null ? void 0 : formList.length)) return;
20749
+ var _a;
20750
+ const rules = {};
20751
+ if (!((_a = formColumn.value) == null ? void 0 : _a.length)) return;
20763
20752
  const handleRule = (item) => {
20764
- if (!item.required) return;
20753
+ var _a2;
20765
20754
  if (!item.prop) return;
20766
20755
  const isSelect = (item == null ? void 0 : item.renderType) && ["select", "cascader"].includes(item == null ? void 0 : item.renderType);
20767
20756
  const defaultRule = {
20768
20757
  required: true,
20769
- message: `${item.label}不能为空`,
20758
+ message: `${(_a2 = item.label) != null ? _a2 : "该字段"}不能为空`,
20770
20759
  trigger: isSelect ? "change" : "blur"
20771
20760
  };
20772
- rules[item.prop] = rules[item.prop] ? [...rules[item.prop], defaultRule] : [defaultRule];
20773
- if (item.rules) {
20774
- rules[item.prop] = [...rules[item.prop], ...item.rules];
20761
+ if (item.required) {
20762
+ rules[item.prop] = [defaultRule];
20763
+ }
20764
+ if (item.rules && item.rules.length > 0) {
20765
+ rules[item.prop] = [...rules[item == null ? void 0 : item.prop] || [], ...item.rules];
20775
20766
  }
20776
20767
  };
20777
- formList.forEach((form) => {
20778
- var _a;
20779
- (_a = form.children) == null ? void 0 : _a.forEach(handleRule);
20768
+ formColumn.value.forEach((form) => {
20769
+ var _a2;
20770
+ (_a2 = form.children) == null ? void 0 : _a2.forEach(handleRule);
20780
20771
  handleRule(form);
20781
20772
  });
20782
20773
  formRules.value = rules;
20783
20774
  };
20784
- initForm();
20785
- getRules();
20775
+ onBeforeMount(() => __async(this, null, function* () {
20776
+ if (props.formList) {
20777
+ yield initForm();
20778
+ getRules();
20779
+ }
20780
+ }));
20786
20781
  const formRef = ref();
20787
20782
  const getFormStyle = () => {
20788
20783
  const {
@@ -20814,13 +20809,14 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20814
20809
  "grid-gap": gap
20815
20810
  }, style);
20816
20811
  };
20817
- const render = (props2) => {
20812
+ const render2 = (props2) => {
20813
+ var _a;
20818
20814
  let _slot;
20819
20815
  const {
20820
- formList,
20821
20816
  formStyle,
20822
20817
  formLayout
20823
20818
  } = props2;
20819
+ if (!((_a = formColumn.value) == null ? void 0 : _a.length)) return;
20824
20820
  const dynamicComponent = ({
20825
20821
  renderType,
20826
20822
  event,
@@ -20828,6 +20824,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20828
20824
  label,
20829
20825
  config
20830
20826
  }) => {
20827
+ if (!prop) return;
20831
20828
  const Component = resolveComponent("el-" + renderType);
20832
20829
  const renderChildComponent = () => {
20833
20830
  if (renderType === "select") return config == null ? void 0 : config.options.map((item) => createVNode(resolveComponent("el-option"), {
@@ -20840,9 +20837,9 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20840
20837
  }, null));
20841
20838
  return null;
20842
20839
  };
20843
- const _a = config || {}, {
20840
+ const _a2 = config || {}, {
20844
20841
  options
20845
- } = _a, conf = __objRest(_a, [
20842
+ } = _a2, conf = __objRest(_a2, [
20846
20843
  "options"
20847
20844
  ]);
20848
20845
  if (renderType === "cascader") return createVNode(resolveComponent("el-cascader"), mergeProps(event, conf, {
@@ -20851,7 +20848,7 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20851
20848
  "onUpdate:modelValue": ($event) => formData.value[prop] = $event,
20852
20849
  "placeholder": `请选择${label}`
20853
20850
  }), null);
20854
- let isSelect = ["select", "cascader"].includes(renderType);
20851
+ let isSelect = renderType && ["select", "cascader"].includes(renderType);
20855
20852
  return createVNode(Component, mergeProps(event, {
20856
20853
  "placeholder": `请${isSelect ? "选择" : "输入"}${label}`
20857
20854
  }, conf, {
@@ -20862,21 +20859,15 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20862
20859
  });
20863
20860
  };
20864
20861
  const formItemSlots = (form, scope) => {
20865
- var _a;
20866
- return form.slotName && ((_a = slots[form.slotName]) == null ? void 0 : _a.call(slots, scope));
20862
+ var _a2;
20863
+ return form.slotName && ((_a2 = slots[form.slotName]) == null ? void 0 : _a2.call(slots, scope));
20867
20864
  };
20868
- const renderFormItem = (formList2) => {
20865
+ const renderFormItem = (formList) => {
20869
20866
  const renderForm = (form) => {
20870
20867
  var _b;
20871
- const _a = form, {
20872
- render: render2,
20873
- config,
20874
- renderType,
20868
+ const _a2 = form, {
20875
20869
  className
20876
- } = _a, formProps = __objRest(_a, [
20877
- "render",
20878
- "config",
20879
- "renderType",
20870
+ } = _a2, formProps = __objRest(_a2, [
20880
20871
  "className"
20881
20872
  ]);
20882
20873
  return createVNode(resolveComponent("el-form-item"), mergeProps({
@@ -20892,34 +20883,28 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20892
20883
  return (form == null ? void 0 : form.slotName) && formItemSlots(form, scope);
20893
20884
  },
20894
20885
  label: () => {
20895
- var _a2, _b2;
20886
+ var _a3, _b2;
20896
20887
  return form.label ? createVNode("div", {
20897
- "class": `flex items-center gap-5 ${(_a2 = form.labelClassName) != null ? _a2 : ""}`
20888
+ "class": `flex items-center gap-5 ${(_a3 = form.labelClassName) != null ? _a3 : ""}`
20898
20889
  }, [form.label, form.promptConf ? createVNode(resolveComponent("el-tooltip"), (_b2 = form.promptConf) == null ? void 0 : _b2.tooltipConf, {
20899
20890
  default: () => {
20900
- var _a3, _b3, _c;
20891
+ var _a4, _b3, _c;
20901
20892
  return [createVNode(resolveComponent("el-icon"), {
20902
- "size": (_b3 = (_a3 = form.promptConf) == null ? void 0 : _a3.size) != null ? _b3 : 15,
20893
+ "size": (_b3 = (_a4 = form.promptConf) == null ? void 0 : _a4.size) != null ? _b3 : 15,
20903
20894
  "color": (_c = form.promptConf) == null ? void 0 : _c.color
20904
20895
  }, {
20905
- default: () => [createVNode("svg", {
20906
- "xmlns": "http://www.w3.org/2000/svg",
20907
- "viewBox": "0 0 1024 1024"
20908
- }, [createVNode("path", {
20909
- "fill": "currentColor",
20910
- "d": "M512 64a448 448 0 1 1 0 896 448 448 0 0 1 0-896m23.744 191.488c-52.096 0-92.928 14.784-123.2 44.352-30.976 29.568-45.76 70.4-45.76 122.496h80.256c0-29.568 5.632-52.8 17.6-68.992 13.376-19.712 35.2-28.864 66.176-28.864 23.936 0 42.944 6.336 56.32 19.712 12.672 13.376 19.712 31.68 19.712 54.912 0 17.6-6.336 34.496-19.008 49.984l-8.448 9.856c-45.76 40.832-73.216 70.4-82.368 89.408-9.856 19.008-14.08 42.24-14.08 68.992v9.856h80.96v-9.856c0-16.896 3.52-31.68 10.56-45.76 6.336-12.672 15.488-24.64 28.16-35.2 33.792-29.568 54.208-48.576 60.544-55.616 16.896-22.528 26.048-51.392 26.048-86.592 0-42.944-14.08-76.736-42.24-101.376-28.16-25.344-65.472-37.312-111.232-37.312zm-12.672 406.208a54.272 54.272 0 0 0-38.72 14.784 49.408 49.408 0 0 0-15.488 38.016c0 15.488 4.928 28.16 15.488 38.016A54.848 54.848 0 0 0 523.072 768c15.488 0 28.16-4.928 38.72-14.784a51.52 51.52 0 0 0 16.192-38.72 51.968 51.968 0 0 0-15.488-38.016 55.936 55.936 0 0 0-39.424-14.784z"
20911
- }, null)])]
20896
+ default: () => [createVNode(Question, null, null)]
20912
20897
  })];
20913
20898
  }
20914
20899
  }) : ""]) : null;
20915
20900
  }
20916
20901
  });
20917
20902
  };
20918
- return formList2.filter((form) => !form.show || form.show(formData.value)).map((form) => {
20919
- var _a, _b, _c, _d;
20903
+ return formList.filter((form) => !form.show || form.show(formData.value)).map((form) => {
20904
+ var _a2, _b, _c, _d;
20920
20905
  if (form.children && form.children.length > 0) {
20921
20906
  return createVNode("div", {
20922
- "class": `flex flex-col ${(_a = form.groupWrapClassName) != null ? _a : ""}`,
20907
+ "class": `flex flex-col ${(_a2 = form.groupWrapClassName) != null ? _a2 : ""}`,
20923
20908
  "style": __spreadValues({}, form == null ? void 0 : form.groupWrapStyle)
20924
20909
  }, [createVNode("div", {
20925
20910
  "class": (_b = form.groupTitleClassName) != null ? _b : "",
@@ -20938,26 +20923,29 @@ const _sfc_main$4 = /* @__PURE__ */ defineComponent(__spreadProps(__spreadValues
20938
20923
  "model": formData.value,
20939
20924
  "rules": formRules.value,
20940
20925
  "class": "grid",
20941
- "ref": formRef
20926
+ "ref": formRef,
20927
+ "validate-on-rule-change": false
20942
20928
  }, attrs, {
20943
20929
  "style": __spreadValues({}, getFormStyle())
20944
- }), _isSlot(_slot = renderFormItem(formList)) ? _slot : {
20930
+ }), _isSlot(_slot = renderFormItem(formColumn.value)) ? _slot : {
20945
20931
  default: () => [_slot]
20946
20932
  })]);
20947
20933
  };
20948
20934
  const formValidate = () => __async(this, null, function* () {
20949
- return yield formRef.value.validate((valid) => valid ? true : false);
20935
+ if (!formRef.value) return Promise.resolve(false);
20936
+ return yield formRef.value.validate(() => Promise.resolve());
20950
20937
  });
20951
20938
  __expose({
20952
20939
  formData,
20953
- formValidate
20940
+ formValidate,
20941
+ formRef
20954
20942
  });
20955
20943
  return (_ctx, _cache) => {
20956
- return openBlock(), createBlock(resolveDynamicComponent(render(props)));
20944
+ return openBlock(), createBlock(resolveDynamicComponent(render2(props)));
20957
20945
  };
20958
20946
  }
20959
20947
  }));
20960
- const index$1 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-91a038d9"]]);
20948
+ const index$1 = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["__scopeId", "data-v-4196aa66"]]);
20961
20949
  let versionKey, curVersion, updateApp;
20962
20950
  const updateSysVersion = () => {
20963
20951
  localStorage.setItem(versionKey, curVersion);
@@ -21064,6 +21052,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
21064
21052
  },
21065
21053
  emits: ["update:fileObsUrl", "getFile"],
21066
21054
  setup(__props, {
21055
+ expose: __expose,
21067
21056
  emit: __emit
21068
21057
  }) {
21069
21058
  const attrs = useAttrs();
@@ -21071,6 +21060,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
21071
21060
  const fileList = ref([]);
21072
21061
  const props = __props;
21073
21062
  const fileObsUrl = ref("");
21063
+ const upload = ref();
21074
21064
  const emit = __emit;
21075
21065
  const uploadFile = (_0) => __async(this, [_0], function* ({
21076
21066
  file
@@ -21086,7 +21076,16 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
21086
21076
  fileObsUrl.value = data.fileUrl;
21087
21077
  emit("update:fileObsUrl", fileObsUrl.value);
21088
21078
  });
21089
- const render = (props2) => {
21079
+ const onExceed = (files) => {
21080
+ upload.value.clearFiles();
21081
+ const file = files[0];
21082
+ file.uid = genFileId();
21083
+ upload.value.handleStart(file);
21084
+ };
21085
+ __expose({
21086
+ upload
21087
+ });
21088
+ const render2 = (props2) => {
21090
21089
  const defaultTrigger = () => {
21091
21090
  return createVNode(resolveComponent("el-button"), null, {
21092
21091
  default: () => {
@@ -21096,10 +21095,13 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
21096
21095
  });
21097
21096
  };
21098
21097
  return createVNode(Fragment, null, [createVNode(resolveComponent("el-upload"), mergeProps({
21098
+ "ref": "upload",
21099
21099
  "class": "w-full h-full",
21100
21100
  "http-request": uploadFile,
21101
21101
  "file-list": fileList.value
21102
- }, attrs), {
21102
+ }, attrs, {
21103
+ "on-exceed": onExceed
21104
+ }), {
21103
21105
  trigger: () => {
21104
21106
  return (props2 == null ? void 0 : props2.triggerRender) ? props2 == null ? void 0 : props2.triggerRender(fileObsUrl.value) : slots["trigger"] ? slots["trigger"]() : defaultTrigger();
21105
21107
  },
@@ -21111,7 +21113,7 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
21111
21113
  })]);
21112
21114
  };
21113
21115
  return (_ctx, _cache) => {
21114
- return openBlock(), createBlock(resolveDynamicComponent(render(props)), {
21116
+ return openBlock(), createBlock(resolveDynamicComponent(render2(props)), {
21115
21117
  "model-value": fileObsUrl.value
21116
21118
  }, null, 8, ["model-value"]);
21117
21119
  };
@@ -21203,25 +21205,23 @@ const components2 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
21203
21205
  LogoTitleRender,
21204
21206
  Toolbar,
21205
21207
  Update,
21206
- YxDialog: _sfc_main$9,
21207
- YxDrawer: _sfc_main$8,
21208
+ YxDialog: _sfc_main$8,
21209
+ YxDrawer: _sfc_main$7,
21208
21210
  YxForm: index$1,
21209
21211
  YxIcon: index,
21210
- YxSearchForm: index$2,
21211
- YxTable: _sfc_main$6,
21212
+ YxTable: _sfc_main$5,
21212
21213
  YxUpload: _sfc_main$1
21213
21214
  }, Symbol.toStringTag, { value: "Module" }));
21214
21215
  export {
21215
21216
  LogoTitleRender as L,
21216
21217
  Update as U,
21217
- _sfc_main$9 as _,
21218
- _sfc_main$8 as a,
21219
- _sfc_main$6 as b,
21218
+ _sfc_main$8 as _,
21219
+ _sfc_main$7 as a,
21220
+ _sfc_main$5 as b,
21220
21221
  components2 as c,
21221
- index$1 as d,
21222
- index as e,
21223
- _sfc_main$1 as f,
21224
- LogoTitle as g,
21225
- index$2 as i
21222
+ index as d,
21223
+ _sfc_main$1 as e,
21224
+ LogoTitle as f,
21225
+ index$1 as i
21226
21226
  };
21227
21227
  //# sourceMappingURL=index.es6.js.map