form-custom-test 3.0.159 → 3.0.161

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/render.es.js CHANGED
@@ -29,7 +29,7 @@ var __objRest = (source2, exclude) => {
29
29
  }
30
30
  return target;
31
31
  };
32
- import { openBlock, createElementBlock, normalizeClass, renderSlot, reactive, createElementVNode, toDisplayString, createCommentVNode, resolveComponent, normalizeStyle, withModifiers, Fragment, createVNode, createBlock, withCtx, createTextVNode, renderList, defineComponent, createSlots, watch, ref, onBeforeUnmount, onMounted, onUnmounted, withDirectives, mergeProps, resolveDynamicComponent, vShow, isVNode } from "vue";
32
+ import { openBlock, createElementBlock, normalizeClass, renderSlot, reactive, createElementVNode, toDisplayString, createCommentVNode, resolveComponent, normalizeStyle, withModifiers, Fragment, createVNode, createBlock, withCtx, createTextVNode, withDirectives, vShow, renderList, defineComponent, createSlots, watch, ref, onBeforeUnmount, onMounted, onUnmounted, mergeProps, resolveDynamicComponent, isVNode } from "vue";
33
33
  import { ElMessage } from "element-plus";
34
34
  var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
35
35
  function getDefaultExportFromCjs(x) {
@@ -3100,7 +3100,7 @@ const getRegExp = function(validatorName2) {
3100
3100
  maxLen10Decimals2: "/^\\d{1,10}(\\.\\d{1,2})?$/",
3101
3101
  maxLen12Decimals2: "/^\\d{1,12}(\\.\\d{1,2})?$/",
3102
3102
  latitude: "/^-?(?:90(?:\\.0{1,6})?|[1-8]?\\d(?:\\.\\d{1,6})?|0(?:\\.\\d{1,6})?)$/",
3103
- sixFigures: "/^\\d{1,6}(\\.\\d{1,6})?$/",
3103
+ sixFigures: "/^(0|[1-9]\\d{0,5})(\\.\\d{1,6})?$/",
3104
3104
  percentage: "/^(?:100(?:\\.0{0,4})?|[1-9]?\\d(?:\\.\\d{0,4})?|0(?:\\.\\d{0,4})?)$/",
3105
3105
  longitude: "/^-?(?:180(?:\\.0{1,6})?|1[0-7]\\d(?:\\.\\d{1,6})?|[1-9]?\\d(?:\\.\\d{1,6})?|0(?:\\.\\d{1,6})?)$/"
3106
3106
  };
@@ -8797,10 +8797,13 @@ var fieldMixin = {
8797
8797
  this.rules.splice(0, this.rules.length);
8798
8798
  },
8799
8799
  buildFieldRules() {
8800
- if (!this.field.formItemFlag && this.field.options.hidden) {
8800
+ if (!this.field.formItemFlag) {
8801
8801
  return;
8802
8802
  }
8803
8803
  this.rules.splice(0, this.rules.length);
8804
+ if (!!this.field.options.hidden && !this.designState) {
8805
+ return;
8806
+ }
8804
8807
  if (!!this.field.options.required) {
8805
8808
  this.rules.push({
8806
8809
  required: true,
@@ -8972,6 +8975,10 @@ var fieldMixin = {
8972
8975
  return formRef && typeof formRef.findColByName === "function" ? formRef.findColByName(null, colName) : null;
8973
8976
  },
8974
8977
  setColHidden(colName, hidden) {
8978
+ const formRef = this.getFormRef();
8979
+ if (formRef && typeof formRef.setColHidden === "function") {
8980
+ return formRef.setColHidden(colName, hidden);
8981
+ }
8975
8982
  const hiddenVal = !!hidden;
8976
8983
  if (Array.isArray(colName)) {
8977
8984
  let anySet = false;
@@ -9450,7 +9457,7 @@ function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
9450
9457
  return openBlock(), createElementBlock("div", {
9451
9458
  class: normalizeClass(["field-wrapper", { "design-time-bottom-margin": !!this.designer }])
9452
9459
  }, [
9453
- !!$props.field.formItemFlag && (!$props.field.options.hidden || $props.designState === true) ? (openBlock(), createBlock(_component_el_form_item, {
9460
+ !!$props.field.formItemFlag ? withDirectives((openBlock(), createBlock(_component_el_form_item, {
9454
9461
  key: 0,
9455
9462
  label: $options.label,
9456
9463
  "label-width": $options.labelWidth + "px",
@@ -9514,7 +9521,9 @@ function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
9514
9521
  renderSlot(_ctx.$slots, "default", {}, void 0, true)
9515
9522
  ]),
9516
9523
  _: 3
9517
- }, 8, ["label", "label-width", "title", "rules", "prop", "class"])) : createCommentVNode("", true),
9524
+ }, 8, ["label", "label-width", "title", "rules", "prop", "class"])), [
9525
+ [vShow, $props.designState === true || !$props.field.options.hidden]
9526
+ ]) : createCommentVNode("", true),
9518
9527
  !!this.designer ? (openBlock(), createElementBlock(Fragment, { key: 1 }, [
9519
9528
  $props.designer.selectedId === $props.field.id ? (openBlock(), createElementBlock("div", _hoisted_2$w, [
9520
9529
  createElementVNode("i", {
@@ -9558,7 +9567,7 @@ function _sfc_render$19(_ctx, _cache, $props, $setup, $data, $options) {
9558
9567
  ], 64)) : createCommentVNode("", true)
9559
9568
  ], 2);
9560
9569
  }
9561
- var FormItemWrapper = /* @__PURE__ */ _export_sfc$1(_sfc_main$19, [["render", _sfc_render$19], ["__scopeId", "data-v-eed9a7f0"]]);
9570
+ var FormItemWrapper = /* @__PURE__ */ _export_sfc$1(_sfc_main$19, [["render", _sfc_render$19], ["__scopeId", "data-v-a42827ee"]]);
9562
9571
  var __glob_0_8 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
9563
9572
  __proto__: null,
9564
9573
  "default": FormItemWrapper
@@ -24458,6 +24467,12 @@ const _sfc_main$B = {
24458
24467
  this.initLayoutProps();
24459
24468
  this.initRefList();
24460
24469
  },
24470
+ mounted() {
24471
+ var _a, _b;
24472
+ if (!this.designState && ((_b = (_a = this.widget) == null ? void 0 : _a.options) == null ? void 0 : _b.hidden)) {
24473
+ this.$nextTick(() => this.syncColFieldValidation(true));
24474
+ }
24475
+ },
24461
24476
  beforeUnmount() {
24462
24477
  var _a, _b;
24463
24478
  if (this.refList != null && ((_b = (_a = this.widget) == null ? void 0 : _a.options) == null ? void 0 : _b.name)) {
@@ -24470,12 +24485,40 @@ const _sfc_main$B = {
24470
24485
  this.layoutProps.span = val;
24471
24486
  },
24472
24487
  immediate: true
24488
+ },
24489
+ "widget.options.hidden": {
24490
+ handler(val) {
24491
+ if (this.designState)
24492
+ return;
24493
+ this.syncColFieldValidation(!!val);
24494
+ }
24473
24495
  }
24474
24496
  },
24475
24497
  methods: {
24498
+ syncColFieldValidation(hidden) {
24499
+ if (!this.widget)
24500
+ return;
24501
+ const hiddenFlag = !!hidden;
24502
+ traverseFieldWidgetsOfContainer(this.widget, (fieldWidget) => {
24503
+ if (!fieldWidget.formItemFlag || !fieldWidget.options || !fieldWidget.options.name) {
24504
+ return;
24505
+ }
24506
+ const fieldRef = this.getWidgetRef(fieldWidget.options.name);
24507
+ if (!fieldRef)
24508
+ return;
24509
+ if (hiddenFlag) {
24510
+ if (typeof fieldRef.clearFieldRules === "function") {
24511
+ fieldRef.clearFieldRules();
24512
+ }
24513
+ } else if (typeof fieldRef.buildFieldRules === "function") {
24514
+ fieldRef.buildFieldRules();
24515
+ }
24516
+ });
24517
+ },
24476
24518
  setHidden(flag) {
24477
24519
  if (this.widget && this.widget.options) {
24478
24520
  this.widget.options.hidden = !!flag;
24521
+ this.syncColFieldValidation(flag);
24479
24522
  this.$nextTick(() => this.$forceUpdate());
24480
24523
  }
24481
24524
  },
@@ -24577,7 +24620,7 @@ function _sfc_render$B(_ctx, _cache, $props, $setup, $data, $options) {
24577
24620
  [vShow, $options.colVisible]
24578
24621
  ]) : createCommentVNode("", true);
24579
24622
  }
24580
- var GridColItem = /* @__PURE__ */ _export_sfc$1(_sfc_main$B, [["render", _sfc_render$B], ["__scopeId", "data-v-746165e2"]]);
24623
+ var GridColItem = /* @__PURE__ */ _export_sfc$1(_sfc_main$B, [["render", _sfc_render$B], ["__scopeId", "data-v-20705201"]]);
24581
24624
  var __glob_0_1$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
24582
24625
  __proto__: null,
24583
24626
  "default": GridColItem
@@ -24827,9 +24870,9 @@ function _sfc_render$A(_ctx, _cache, $props, $setup, $data, $options) {
24827
24870
  ref: $props.widget.id
24828
24871
  }, {
24829
24872
  default: withCtx(() => [
24830
- (openBlock(true), createElementBlock(Fragment, null, renderList($props.widget.cols.filter((item) => !item.options.hidden) || [], (colWidget, colIdx) => {
24873
+ (openBlock(true), createElementBlock(Fragment, null, renderList($props.widget.cols || [], (colWidget, colIdx) => {
24831
24874
  return openBlock(), createBlock(_component_grid_col_item, {
24832
- key: colIdx,
24875
+ key: colWidget.id,
24833
24876
  widget: colWidget,
24834
24877
  "parent-list": $props.widget.cols,
24835
24878
  "index-of-parent-list": colIdx,
@@ -25810,13 +25853,81 @@ const _sfc_main$v = {
25810
25853
  }
25811
25854
  });
25812
25855
  },
25856
+ findFieldByName(fieldName) {
25857
+ if (!fieldName || !this.widgetList)
25858
+ return null;
25859
+ let found = null;
25860
+ const walk = (list) => {
25861
+ if (!Array.isArray(list) || found)
25862
+ return;
25863
+ list.forEach((w) => {
25864
+ if (found || !w)
25865
+ return;
25866
+ if (w.formItemFlag && w.options && w.options.name === fieldName) {
25867
+ found = w;
25868
+ return;
25869
+ }
25870
+ if (Array.isArray(w.widgetList))
25871
+ walk(w.widgetList);
25872
+ if (Array.isArray(w.cols)) {
25873
+ w.cols.forEach((c) => walk(c && c.widgetList));
25874
+ }
25875
+ if (Array.isArray(w.rows)) {
25876
+ w.rows.forEach((r) => Array.isArray(r && r.cols) && r.cols.forEach((c) => walk(c && c.widgetList)));
25877
+ }
25878
+ if (Array.isArray(w.tabs)) {
25879
+ w.tabs.forEach((t) => walk(t && t.widgetList));
25880
+ }
25881
+ });
25882
+ };
25883
+ walk(this.widgetList);
25884
+ return found;
25885
+ },
25813
25886
  findWidgetAndSetHidden(widgetName, hiddenFlag) {
25814
25887
  let foundW = this.getWidgetRef(widgetName);
25815
25888
  if (!!foundW) {
25816
25889
  foundW.setHidden(hiddenFlag);
25817
- } else {
25818
- this.findWidgetOfSubFormAndSetHidden(widgetName, hiddenFlag);
25890
+ return;
25819
25891
  }
25892
+ const fieldSchema = this.findFieldByName(widgetName);
25893
+ if (fieldSchema && fieldSchema.options) {
25894
+ fieldSchema.options.hidden = !!hiddenFlag;
25895
+ this.$nextTick(() => {
25896
+ const ref2 = this.getWidgetRef(widgetName);
25897
+ if (ref2) {
25898
+ if (hiddenFlag) {
25899
+ if (typeof ref2.clearFieldRules === "function")
25900
+ ref2.clearFieldRules();
25901
+ } else if (typeof ref2.buildFieldRules === "function") {
25902
+ ref2.buildFieldRules();
25903
+ }
25904
+ }
25905
+ this.$forceUpdate();
25906
+ });
25907
+ return;
25908
+ }
25909
+ this.findWidgetOfSubFormAndSetHidden(widgetName, hiddenFlag);
25910
+ },
25911
+ setFieldRequired(fieldName, required) {
25912
+ const flag = !!required;
25913
+ const fieldRef = this.getWidgetRef(fieldName);
25914
+ if (fieldRef && typeof fieldRef.setRequired === "function") {
25915
+ fieldRef.setRequired(flag);
25916
+ if (typeof fieldRef.buildFieldRules === "function") {
25917
+ fieldRef.buildFieldRules();
25918
+ }
25919
+ return true;
25920
+ }
25921
+ const fieldSchema = this.findFieldByName(fieldName);
25922
+ if (fieldSchema && fieldSchema.options) {
25923
+ fieldSchema.options.required = flag;
25924
+ const refAfter = this.getWidgetRef(fieldName);
25925
+ if (refAfter && typeof refAfter.buildFieldRules === "function") {
25926
+ refAfter.buildFieldRules();
25927
+ }
25928
+ return true;
25929
+ }
25930
+ return false;
25820
25931
  },
25821
25932
  findWidgetOfSubFormAndSetHidden(widgetName, hiddenFlag) {
25822
25933
  this.findWidgetNameInSubForm(widgetName).forEach((wn) => {
@@ -26220,11 +26331,41 @@ const _sfc_main$v = {
26220
26331
  }
26221
26332
  return null;
26222
26333
  },
26334
+ syncFieldRulesByCol(col, hidden) {
26335
+ if (!col)
26336
+ return;
26337
+ const hiddenFlag = !!hidden;
26338
+ traverseFieldWidgetsOfContainer(col, (fieldWidget) => {
26339
+ if (!fieldWidget.formItemFlag || !fieldWidget.options || !fieldWidget.options.name) {
26340
+ return;
26341
+ }
26342
+ const fieldRef = this.getWidgetRef(fieldWidget.options.name);
26343
+ if (!fieldRef)
26344
+ return;
26345
+ if (hiddenFlag) {
26346
+ if (typeof fieldRef.clearFieldRules === "function") {
26347
+ fieldRef.clearFieldRules();
26348
+ }
26349
+ } else if (typeof fieldRef.buildFieldRules === "function") {
26350
+ fieldRef.buildFieldRules();
26351
+ }
26352
+ });
26353
+ },
26223
26354
  setColHidden(colName, hidden) {
26355
+ if (Array.isArray(colName)) {
26356
+ let anySet = false;
26357
+ colName.forEach((name) => {
26358
+ if (this.setColHidden(name, hidden)) {
26359
+ anySet = true;
26360
+ }
26361
+ });
26362
+ return anySet;
26363
+ }
26224
26364
  const col = this.findColByName(null, colName);
26225
26365
  if (!col || !col.options)
26226
26366
  return false;
26227
26367
  col.options.hidden = !!hidden;
26368
+ this.syncFieldRulesByCol(col, hidden);
26228
26369
  this.$nextTick(() => this.$forceUpdate());
26229
26370
  return true;
26230
26371
  }
@@ -26285,7 +26426,7 @@ function _sfc_render$v(_ctx, _cache, $props, $setup, $data, $options) {
26285
26426
  _: 3
26286
26427
  }, 8, ["label-position", "size", "class", "label-width", "model"]);
26287
26428
  }
26288
- var VFormRender = /* @__PURE__ */ _export_sfc$1(_sfc_main$v, [["render", _sfc_render$v], ["__scopeId", "data-v-6e3bb628"]]);
26429
+ var VFormRender = /* @__PURE__ */ _export_sfc$1(_sfc_main$v, [["render", _sfc_render$v], ["__scopeId", "data-v-3d429201"]]);
26289
26430
  function registerIcon(app) {
26290
26431
  app.component("el-icon-edit", edit);
26291
26432
  app.component("el-icon-minus", minus);
@@ -26300,13 +26441,13 @@ function registerIcon(app) {
26300
26441
  if (typeof window !== "undefined") {
26301
26442
  let loadSvg = function() {
26302
26443
  var body = document.body;
26303
- var svgDom = document.getElementById("__svg__icons__dom__1779190384706__");
26444
+ var svgDom = document.getElementById("__svg__icons__dom__1779273154047__");
26304
26445
  if (!svgDom) {
26305
26446
  svgDom = document.createElementNS("http://www.w3.org/2000/svg", "svg");
26306
26447
  svgDom.style.position = "absolute";
26307
26448
  svgDom.style.width = "0";
26308
26449
  svgDom.style.height = "0";
26309
- svgDom.id = "__svg__icons__dom__1779190384706__";
26450
+ svgDom.id = "__svg__icons__dom__1779273154047__";
26310
26451
  svgDom.setAttribute("xmlns", "http://www.w3.org/2000/svg");
26311
26452
  svgDom.setAttribute("xmlns:link", "http://www.w3.org/1999/xlink");
26312
26453
  }