"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                                */
;/* empty css                                                                        */
;/* empty css                                                                        */
;/* empty css                                                                     */
;/* empty css                                                                  */
;/* empty css                                                                     */
;/* empty css                                                                           */
;/* empty css                                                                     */
const Vue = require("vue");
const FieldSetMapping = require("../../../../components/FieldSetMapping.vue2.js");
const common = require("../../../utils/common.js");
const index = require("../../../../api/index.js");
;/* empty css                         */
const _pluginVue_exportHelper = require("../../../../../../_virtual/_plugin-vue_export-helper.js");
const index$1 = require("../../../../../../node_modules/element-plus/es/components/form/index.js");
const index$2 = require("../../../../../../node_modules/element-plus/es/components/select/index.js");
const _sfc_main = {
  __name: "TableChildSelection",
  props: {
    formData: Object
  },
  setup(__props) {
    const currentInstance = Vue.getCurrentInstance();
    const ctx = currentInstance.proxy;
    const props = __props;
    const fieldList = Vue.computed(() => {
      return common.getEditConfigDataFields().filter(
        (item) => item.fieldType == "subTable"
      );
    });
    const subTableOptions = Vue.ref({});
    Vue.watch(
      () => props.formData.selectSubTableFieldId,
      (id) => {
        const fieldItem = common.getEditConfigDataFields().find((item) => item.id == id);
        if (fieldItem) {
          const subTableId = fieldItem.subTableId;
          index.default.getById(ctx.$http, subTableId).then((data) => {
            subTableOptions.value = JSON.parse(data.context);
          });
        }
      },
      {
        immediate: true
      }
    );
    const tableFields = Vue.computed(() => {
      var _a, _b;
      return [
        ...((_a = subTableOptions.value) == null ? void 0 : _a.fieldsData) || [],
        ...((_b = subTableOptions.value) == null ? void 0 : _b.hiddenFields) || []
      ];
    });
    return (_ctx, _cache) => {
      const _component_el_option = index$2.ElOption;
      const _component_el_select = index$2.ElSelect;
      const _component_el_form_item = index$1.ElFormItem;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createVNode(_component_el_form_item, { label: "选择子列表" }, {
          default: Vue.withCtx(() => [
            Vue.createVNode(_component_el_select, {
              modelValue: __props.formData.selectSubTableFieldId,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => __props.formData.selectSubTableFieldId = $event),
              filterable: "",
              size: "small",
              clearable: ""
            }, {
              default: Vue.withCtx(() => [
                (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(fieldList), (item) => {
                  return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                    key: item.id,
                    label: item.label,
                    value: item.id
                  }, null, 8, ["label", "value"]);
                }), 128))
              ]),
              _: 1
            }, 8, ["modelValue"])
          ]),
          _: 1
        }),
        Vue.createVNode(_component_el_form_item, { label: "选取后表单赋值映射" }, {
          default: Vue.withCtx(() => [
            Vue.createVNode(FieldSetMapping.default, {
              modelValue: __props.formData.subTableSelectionFieldMapping,
              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => __props.formData.subTableSelectionFieldMapping = $event),
              fieldLabel: "赋值表单字段",
              valueLabel: "列表字段",
              valueOptions: Vue.unref(tableFields),
              valueSelectMode: ""
            }, null, 8, ["modelValue", "valueOptions"])
          ]),
          _: 1
        })
      ], 64);
    };
  }
};
const TableChildSelection = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-170db076"]]);
exports.default = TableChildSelection;
