"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
;/* empty css                                               */
;/* empty css                                                     */
const Vue = require("vue");
const optionUtil = require("../../../utils/optionUtil.js");
;/* empty css           */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../node_modules/vant/es/form/index.js");
const index$1 = require("../../../../node_modules/vant/es/cell-group/index.js");
const _sfc_main = {
  __name: "Form",
  props: {
    modelValue: {
      type: Object,
      default: {}
    },
    disabled: {
      type: Boolean,
      default: false
    },
    formType: {
      type: String,
      default: "edit"
    },
    isCard: {
      //卡片风格
      type: Boolean,
      default: false
    },
    isShadow: {
      //卡片阴影
      type: Boolean,
      default: true
    }
  },
  emits: ["update:modelValue", "submit"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const emit = __emit;
    const formData = Vue.computed({
      get: () => {
        return props.modelValue;
      },
      set: (val) => {
        emit("update:modelValue", val);
      }
    });
    Vue.provide("formData", formData);
    Vue.provide(
      "formDisabled",
      Vue.computed(() => props.disabled)
    );
    Vue.provide(
      "formReadonly",
      Vue.computed(() => props.formType == "detail")
    );
    const dicLoaded = Vue.ref(false);
    const slots = Vue.useSlots();
    const dicListMap = Vue.ref({});
    const processSlotComponents = async () => {
      var _a;
      const slotElements = (_a = slots.default) == null ? void 0 : _a.call(slots);
      const dicKeyList = [];
      if (slotElements) {
        slotElements.forEach((node) => {
          if (node.type.__name === "FormItem" && node.props.optionType == "dic") {
            dicKeyList.push(node.props.dicKey);
          }
        });
        if (dicKeyList.length > 0) {
          const uniqueDicKeys = [...new Set(dicKeyList)];
          dicListMap.value = await optionUtil.getParmDicMapByKeys(uniqueDicKeys.join(","));
        }
        dicLoaded.value = true;
      }
    };
    Vue.provide("dicListMap", dicListMap);
    processSlotComponents();
    function submitForm(oriFormData) {
      emit("submit", Vue.toRaw(formData.value));
    }
    return (_ctx, _cache) => {
      const _component_van_cell_group = index$1.CellGroup;
      const _component_van_form = index.Form;
      return Vue.openBlock(), Vue.createBlock(_component_van_form, Vue.mergeProps(_ctx.$attrs, {
        required: "auto",
        class: { fecMForm: true, isShadow: __props.isCard && __props.isShadow },
        onSubmit: submitForm
      }), {
        default: Vue.withCtx(() => [
          Vue.createVNode(_component_van_cell_group, { inset: __props.isCard }, {
            default: Vue.withCtx(() => [
              Vue.renderSlot(_ctx.$slots, "default", {}, void 0, true)
            ]),
            _: 3
          }, 8, ["inset"])
        ]),
        _: 3
      }, 16, ["class"]);
    };
  }
};
const _Form = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-d3a67979"]]);
exports.default = _Form;
