import "../../../../node_modules/element-plus/es/index.mjs";
/* empty css                                                          */
/* empty css                                                                     */
/* empty css                                                                  */
/* empty css                                                               */
/* empty css                                                            */
/* empty css                                                               */
/* empty css                                                               */
/* empty css                                                              */
/* empty css                                                                  */
/* empty css                                                               */
/* empty css                                                               */
/* empty css                                                             */
/* empty css                                                             */
import "../../../../node_modules/element-plus/theme-chalk/el-tab-pane.css.mjs";
/* empty css                                                              */
/* empty css                                                             */
/* empty css                                                               */
import { getCurrentInstance, computed, ref, watch, createElementBlock, openBlock, Fragment, createVNode, withCtx, unref, isRef, renderList, createBlock, createElementVNode, createCommentVNode, createTextVNode, toDisplayString } from "vue";
import { Plus as plus_default } from "../../../../node_modules/@element-plus/icons-vue/dist/index.mjs";
import { useAdvancedFilterDialog } from "../advancedFilter/useAdvancedFilterDialog.mjs";
import { getEditConfigDataFields, getEditConfigData, cloneDeep } from "../utils/common.mjs";
import FilterConfigDisplay from "../../components/FilterConfigDisplay.vue.mjs";
import "../../../../node_modules/element-plus/theme-chalk/el-tooltip.css.mjs";
/* empty css                                                                  */
/* empty css                                                              */
/* empty css                                                                          */
import "../../../../node_modules/element-plus/theme-chalk/el-date-picker.css.mjs";
/* empty css                                                                */
/* empty css                                                              */
/* empty css                                         */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
/* empty css                                   */
import api from "../../api/index.mjs";
/* empty css                                                              */
/* empty css                                                                */
/* empty css                                */
import _sfc_main$1 from "../../components/FormulaEditorInput.vue.mjs";
/* empty css            */
import { ElContainer, ElMain } from "../../../../node_modules/element-plus/es/components/container/index.mjs";
import { ElTabs, ElTabPane } from "../../../../node_modules/element-plus/es/components/tabs/index.mjs";
import { ElButton } from "../../../../node_modules/element-plus/es/components/button/index.mjs";
import { ElScrollbar } from "../../../../node_modules/element-plus/es/components/scrollbar/index.mjs";
import { ElCard } from "../../../../node_modules/element-plus/es/components/card/index.mjs";
import { ElEmpty } from "../../../../node_modules/element-plus/es/components/empty/index.mjs";
import { ElSelect, ElOption, ElOptionGroup } from "../../../../node_modules/element-plus/es/components/select/index.mjs";
const _hoisted_1 = { class: "tab-content" };
const _hoisted_2 = {
  key: 0,
  class: "tab-link-content"
};
const _hoisted_3 = { class: "add-rule-btn" };
const _hoisted_4 = { class: "tab-desc" };
const _hoisted_5 = { class: "rule-content" };
const _hoisted_6 = { class: "rule-actions" };
const _hoisted_7 = {
  key: 0,
  class: "rule-section"
};
const _hoisted_8 = { class: "rule-conditions" };
const _hoisted_9 = { class: "condition-item" };
const _hoisted_10 = { class: "rule-section" };
const _hoisted_11 = { class: "rule-section-title" };
const _hoisted_12 = { class: "rule-field-values" };
const _hoisted_13 = {
  key: 0,
  class: "field-assignments-display"
};
const _hoisted_14 = { class: "field-name" };
const _hoisted_15 = { class: "field-value-display" };
const _hoisted_16 = {
  key: 1,
  class: "field-assignments-display"
};
const _hoisted_17 = { class: "field-name" };
const _hoisted_18 = { class: "field-value-display" };
const _hoisted_19 = {
  key: 2,
  class: "field-value-item"
};
const _hoisted_20 = {
  key: 1,
  class: "tab-empty-state"
};
const _hoisted_21 = { class: "advanced-title" };
const _hoisted_22 = { key: 0 };
const _hoisted_23 = {
  key: 1,
  class: "field-assignment-area"
};
const _hoisted_24 = { class: "field-assignment-list" };
const _hoisted_25 = {
  key: 0,
  class: "field-value-input"
};
const _hoisted_26 = {
  key: 2,
  class: "field-assignment-area"
};
const _hoisted_27 = { class: "field-assignment-list" };
const _hoisted_28 = {
  key: 0,
  class: "field-value-input"
};
const _sfc_main = {
  __name: "index",
  props: {
    linkedConfig: {
      type: Object,
      default: () => ({})
    }
  },
  emits: ["update:linkedConfig"],
  setup(__props, { emit: __emit }) {
    const props = __props;
    const currentInstance = getCurrentInstance();
    const ctx = currentInstance.proxy;
    const emit = __emit;
    const fieldsData = computed(() => {
      return getEditConfigDataFields();
    });
    const optionsFieldsData = computed(() => {
      const list = ["select", "multipleSelection", "radio", "checkbox"];
      const fieldList = getEditConfigDataFields().filter(
        (item) => list.includes(item.fieldType)
      );
      return fieldList.filter(
        (item) => {
          var _a;
          return ((_a = item.optionConfig) == null ? void 0 : _a.optionSource) != "dataSource";
        }
      );
    });
    const hiddenFields = computed(() => {
      const editConfigData = getEditConfigData();
      const fields = (editConfigData == null ? void 0 : editConfigData.hiddenFields) || [];
      return fields.map((item) => ({
        id: item == null ? void 0 : item.id,
        fieldId: item == null ? void 0 : item.id,
        label: item == null ? void 0 : item.label
      }));
    });
    const tabList = ref([
      {
        label: "数据",
        name: "dataLink",
        desc: "根据触发方式和触发条件让字段的值根据其他字段的值自动变化,"
      },
      {
        label: "显隐",
        name: "visibility",
        desc: "让字段在特定条件成立时显示，反之隐藏"
      },
      { label: "必填", name: "required", desc: "让字段在特定条件成立时变为必填" },
      {
        label: "只读",
        name: "disabled",
        desc: "让字段在特定条件成立时变为不可编辑"
      },
      // { label: "禁用", name: "disabled", desc: "让字段在特定条件成立时变为禁用" },
      { label: "可选项", name: "options", desc: "让字段的选择项根据条件动态变化" }
    ]);
    const activeTab = ref("dataLink");
    const currentTab = computed(() => {
      return tabList.value.find((tab) => tab.name == activeTab.value);
    });
    const dataLinkFieldList = ref([]);
    const filterConfig = ref();
    const editingRuleIndex = ref(-1);
    const fieldAssignments = ref([]);
    const optionsFieldsOptionsCache = ref({});
    async function loadOptionsFieldsOptions(fieldId) {
      if (!fieldId) return [];
      if (optionsFieldsOptionsCache.value[fieldId]) {
        return optionsFieldsOptionsCache.value[fieldId];
      }
      const options = await getOptionsFieldsOptions(
        optionsFieldsData.value,
        fieldId
      );
      optionsFieldsOptionsCache.value[fieldId] = options;
      return options;
    }
    watch(
      () => fieldAssignments.value.map((a) => a.fieldId).filter(Boolean).join(","),
      async () => {
        if (currentTab.value.name == "options") {
          for (const assignment of fieldAssignments.value) {
            if (assignment.fieldId && !optionsFieldsOptionsCache.value[assignment.fieldId]) {
              await loadOptionsFieldsOptions(assignment.fieldId);
            }
          }
        }
      },
      { immediate: true }
    );
    function getOptionsFieldsOptionsByCache(fieldId) {
      return optionsFieldsOptionsCache.value[fieldId] || [];
    }
    function onFieldIdChange(index) {
      fieldAssignments.value[index].optionsOpt = null;
    }
    const filterTitle = ref("");
    const filterSuccessDesc = ref("条件满足时或不设置条件，数据联动赋值以下字段");
    function handleAddRule(tab) {
      const name = tab.name;
      filterTitle.value = `${tab.label}联动规则`;
      editingRuleIndex.value = -1;
      switch (name) {
        case "dataLink":
          filterSuccessDesc.value = `条件满足时或不设置条件，数据联动赋值以下字段`;
          break;
        case "visibility":
          filterSuccessDesc.value = `条件满足时，显示以下字段`;
          break;
        case "required":
        case "readonly":
        case "disabled":
          filterSuccessDesc.value = `条件满足时，${tab.label}以下字段`;
          break;
        case "property":
          filterSuccessDesc.value = `条件满足时，${tab.label}以下字段的属性`;
          break;
        case "options":
          filterSuccessDesc.value = `条件满足时，可显示以下字段的可选项`;
          break;
      }
      filterConfig.value = {
        operator: "and",
        conditions: [],
        groups: []
      };
      dataLinkFieldList.value = [];
      fieldAssignments.value = [];
      openAdvancedFilterDialog();
    }
    const {
      advancedFilterDialogVisible,
      openAdvancedFilterDialog,
      AdvancedFilterDialog
    } = useAdvancedFilterDialog();
    watch(advancedFilterDialogVisible, (visible) => {
      if (!visible) {
        editingRuleIndex.value = -1;
      }
    });
    function advancedConfirm(data) {
      var _a;
      const linedConfigArr = [
        ...((_a = props.linkedConfig) == null ? void 0 : _a[currentTab.value.name]) || []
      ];
      const newRule = {
        dataLinkFieldList: dataLinkFieldList.value,
        filterConfig: data
      };
      if (currentTab.value.name == "dataLink" || currentTab.value.name == "options") {
        newRule.fieldAssignments = cloneDeep(fieldAssignments.value);
      }
      if (editingRuleIndex.value == -1) {
        linedConfigArr.push(newRule);
      } else {
        linedConfigArr[editingRuleIndex.value] = newRule;
      }
      const newLinkedConfig = {
        ...props.linkedConfig,
        [currentTab.value.name]: linedConfigArr
      };
      emit("update:linkedConfig", newLinkedConfig);
      editingRuleIndex.value = -1;
    }
    const getFieldLabel = (fieldId) => {
      const field = fieldsData.value.find((f) => f.id == fieldId);
      return (field == null ? void 0 : field.label) || fieldId;
    };
    const getFieldTitle = (tabName) => {
      const titleMap = {
        dataLink: "数据字段",
        visibility: "显示字段",
        required: "必填字段",
        readonly: "只读字段",
        disabled: "禁用字段",
        options: "字段显示可选项"
      };
      return titleMap[tabName] || "联动字段";
    };
    const formatFormulaText = (assignment) => {
      const { formula } = assignment;
      if (formula == null || (formula == null ? void 0 : formula.value) == void 0 || (formula == null ? void 0 : formula.text) == null || (formula == null ? void 0 : formula.text) == void 0 || (formula == null ? void 0 : formula.value.text) == "") {
        return "空";
      }
      return String(formula.text);
    };
    const addFieldAssignment = () => {
      fieldAssignments.value.push({
        fieldId: null,
        value: null,
        optionsOpt: null,
        optionsLabel: "",
        isField: false,
        operator: "eq",
        formula: {
          value: {
            text: "",
            marks: []
          },
          text: ""
        }
      });
    };
    function onOptionsOptChange(index) {
      const assignment = fieldAssignments.value[index];
      if (!assignment.optionsOpt || !assignment.optionsOpt.length) {
        assignment.optionsLabel = "";
        return;
      }
      const options = optionsFieldsOptionsCache.value[assignment.fieldId] || [];
      const labels = assignment.optionsOpt.map((val) => {
        const opt = options.find((o) => o.value === val);
        return opt ? opt.label : val;
      });
      assignment.optionsLabel = labels.join(", ");
    }
    const removeFieldAssignment = (index) => {
      fieldAssignments.value.splice(index, 1);
    };
    const handleEditRule = (tab, item, index) => {
      filterTitle.value = `${tab.label}联动规则`;
      filterConfig.value = cloneDeep(item.filterConfig);
      dataLinkFieldList.value = [...item.dataLinkFieldList.map(String)];
      if ((tab.name == "dataLink" || tab.name == "options") && item.fieldAssignments) {
        fieldAssignments.value = cloneDeep(item.fieldAssignments);
      } else if (tab.name == "dataLink" || tab.name == "options") {
        fieldAssignments.value = [];
      }
      editingRuleIndex.value = index;
      openAdvancedFilterDialog();
    };
    const handleDeleteRule = (tab, index) => {
      var _a;
      const configArr = [...((_a = props.linkedConfig) == null ? void 0 : _a[tab.name]) || []];
      configArr.splice(index, 1);
      const newLinkedConfig = {
        ...props.linkedConfig,
        [tab.name]: configArr
      };
      emit("update:linkedConfig", newLinkedConfig);
    };
    async function getOptionsFieldsOptions(optionsFieldsData2, fieldId) {
      var _a;
      const optionConfig = (_a = optionsFieldsData2.find(
        (item) => item.id == fieldId
      )) == null ? void 0 : _a.optionConfig;
      if (!(optionConfig == null ? void 0 : optionConfig.optionSource)) return [];
      if (optionConfig.optionSource == "custom") {
        return optionConfig.options.map((item) => ({
          label: item.label,
          value: item.value
        }));
      } else if (optionConfig.optionSource == "dictionary") {
        const data = await api.getDicDataByKey(
          ctx.$http,
          optionConfig.dictionaryValue
        );
        return Object.entries(data).map(([value, label]) => ({ label, value }));
      }
      return [];
    }
    return (_ctx, _cache) => {
      const _component_el_button = ElButton;
      const _component_el_card = ElCard;
      const _component_el_scrollbar = ElScrollbar;
      const _component_el_empty = ElEmpty;
      const _component_el_tab_pane = ElTabPane;
      const _component_el_tabs = ElTabs;
      const _component_el_main = ElMain;
      const _component_el_container = ElContainer;
      const _component_el_option = ElOption;
      const _component_el_select = ElSelect;
      const _component_el_option_group = ElOptionGroup;
      return openBlock(), createElementBlock(Fragment, null, [
        createVNode(_component_el_container, { style: { "border": "1px solid #ebeef5", "border-radius": "4px" } }, {
          default: withCtx(() => [
            createVNode(_component_el_main, { style: { "padding": "0" } }, {
              default: withCtx(() => [
                createVNode(_component_el_tabs, {
                  modelValue: unref(activeTab),
                  "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => isRef(activeTab) ? activeTab.value = $event : null),
                  class: "data-link-tabs"
                }, {
                  default: withCtx(() => [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(tabList), (tab) => {
                      return openBlock(), createBlock(_component_el_tab_pane, {
                        key: tab.name,
                        label: tab.label,
                        name: tab.name
                      }, {
                        default: withCtx(() => {
                          var _a, _b, _c, _d;
                          return [
                            createElementVNode("div", _hoisted_1, [
                              ((_b = (_a = props.linkedConfig) == null ? void 0 : _a[tab.name]) == null ? void 0 : _b.length) ? (openBlock(), createElementBlock("div", _hoisted_2, [
                                createElementVNode("div", _hoisted_3, [
                                  createVNode(_component_el_button, {
                                    type: "primary",
                                    icon: unref(plus_default),
                                    onClick: ($event) => handleAddRule(tab)
                                  }, {
                                    default: withCtx(() => [
                                      createTextVNode(" 添加" + toDisplayString(tab.label) + "联动规则 ", 1)
                                    ]),
                                    _: 2
                                  }, 1032, ["icon", "onClick"]),
                                  createElementVNode("span", _hoisted_4, toDisplayString(tab.desc), 1)
                                ]),
                                createVNode(_component_el_scrollbar, { class: "rule-content-scrollbar" }, {
                                  default: withCtx(() => {
                                    var _a2;
                                    return [
                                      (openBlock(true), createElementBlock(Fragment, null, renderList((_a2 = props.linkedConfig) == null ? void 0 : _a2[tab.name], (item, idx) => {
                                        return openBlock(), createBlock(_component_el_card, {
                                          key: idx,
                                          class: "rule-card",
                                          shadow: "hover"
                                        }, {
                                          default: withCtx(() => {
                                            var _a3;
                                            return [
                                              createElementVNode("div", _hoisted_5, [
                                                createElementVNode("div", _hoisted_6, [
                                                  createVNode(_component_el_button, {
                                                    type: "primary",
                                                    link: "",
                                                    size: "small",
                                                    onClick: ($event) => handleEditRule(tab, item, idx)
                                                  }, {
                                                    default: withCtx(() => _cache[3] || (_cache[3] = [
                                                      createTextVNode(" 编辑 ")
                                                    ])),
                                                    _: 2
                                                  }, 1032, ["onClick"]),
                                                  createVNode(_component_el_button, {
                                                    type: "danger",
                                                    link: "",
                                                    size: "small",
                                                    onClick: ($event) => handleDeleteRule(tab, idx)
                                                  }, {
                                                    default: withCtx(() => _cache[4] || (_cache[4] = [
                                                      createTextVNode(" 删除 ")
                                                    ])),
                                                    _: 2
                                                  }, 1032, ["onClick"])
                                                ]),
                                                item.filterConfig && ((_a3 = item.filterConfig.conditions) == null ? void 0 : _a3.length) ? (openBlock(), createElementBlock("div", _hoisted_7, [
                                                  _cache[5] || (_cache[5] = createElementVNode("div", { class: "rule-section-title" }, "触发条件", -1)),
                                                  createElementVNode("div", _hoisted_8, [
                                                    createElementVNode("div", _hoisted_9, [
                                                      createVNode(FilterConfigDisplay, {
                                                        config: item.filterConfig,
                                                        "field-label-getter": getFieldLabel
                                                      }, null, 8, ["config"])
                                                    ])
                                                  ])
                                                ])) : createCommentVNode("", true),
                                                createElementVNode("div", _hoisted_10, [
                                                  createElementVNode("div", _hoisted_11, toDisplayString(getFieldTitle(tab.name)), 1),
                                                  createElementVNode("div", _hoisted_12, [
                                                    tab.name == "dataLink" && item.fieldAssignments && item.fieldAssignments.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_13, [
                                                      (openBlock(true), createElementBlock(Fragment, null, renderList(item.fieldAssignments, (assignment, index) => {
                                                        return openBlock(), createElementBlock("div", {
                                                          key: index,
                                                          class: "field-assignment-display-item"
                                                        }, [
                                                          createElementVNode("span", _hoisted_14, "「" + toDisplayString(getFieldLabel(assignment.fieldId)) + "」", 1),
                                                          _cache[6] || (_cache[6] = createElementVNode("span", { class: "field-operator" }, "=", -1)),
                                                          createElementVNode("span", _hoisted_15, [
                                                            assignment.isField ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
                                                              createTextVNode(" 「" + toDisplayString(getFieldLabel(assignment.value)) + "」 ", 1)
                                                            ], 64)) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
                                                              createTextVNode(toDisplayString(formatFormulaText(assignment)), 1)
                                                            ], 64))
                                                          ])
                                                        ]);
                                                      }), 128))
                                                    ])) : tab.name == "options" && item.fieldAssignments && item.fieldAssignments.length > 0 ? (openBlock(), createElementBlock("div", _hoisted_16, [
                                                      (openBlock(true), createElementBlock(Fragment, null, renderList(item.fieldAssignments, (assignment, index) => {
                                                        return openBlock(), createElementBlock("div", {
                                                          key: index,
                                                          class: "field-assignment-display-item"
                                                        }, [
                                                          createElementVNode("span", _hoisted_17, "「" + toDisplayString(getFieldLabel(assignment.fieldId)) + "」", 1),
                                                          _cache[7] || (_cache[7] = createElementVNode("span", { class: "field-operator" }, "→", -1)),
                                                          createElementVNode("span", _hoisted_18, toDisplayString(assignment.optionsLabel), 1)
                                                        ]);
                                                      }), 128))
                                                    ])) : (openBlock(), createElementBlock("span", _hoisted_19, toDisplayString(item.dataLinkFieldList.map((fieldId) => `${getFieldLabel(fieldId)}`).join(", ")), 1))
                                                  ])
                                                ])
                                              ])
                                            ];
                                          }),
                                          _: 2
                                        }, 1024);
                                      }), 128))
                                    ];
                                  }),
                                  _: 2
                                }, 1024)
                              ])) : createCommentVNode("", true),
                              !((_d = (_c = props.linkedConfig) == null ? void 0 : _c[tab.name]) == null ? void 0 : _d.length) ? (openBlock(), createElementBlock("div", _hoisted_20, [
                                createVNode(_component_el_empty, {
                                  description: tab.desc
                                }, {
                                  default: withCtx(() => [
                                    createVNode(_component_el_button, {
                                      type: "primary",
                                      icon: unref(plus_default),
                                      onClick: ($event) => handleAddRule(tab)
                                    }, {
                                      default: withCtx(() => [
                                        createTextVNode(" 添加" + toDisplayString(tab.label) + "联动规则 ", 1)
                                      ]),
                                      _: 2
                                    }, 1032, ["icon", "onClick"])
                                  ]),
                                  _: 2
                                }, 1032, ["description"])
                              ])) : createCommentVNode("", true)
                            ])
                          ];
                        }),
                        _: 2
                      }, 1032, ["label", "name"]);
                    }), 128))
                  ]),
                  _: 1
                }, 8, ["modelValue"])
              ]),
              _: 1
            })
          ]),
          _: 1
        }),
        createVNode(unref(AdvancedFilterDialog), {
          modelValue: unref(advancedFilterDialogVisible),
          "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => isRef(advancedFilterDialogVisible) ? advancedFilterDialogVisible.value = $event : null),
          filterConfig: unref(filterConfig),
          onConfirm: advancedConfirm,
          title: unref(filterTitle)
        }, {
          default: withCtx(({ filterConfigData }) => {
            var _a, _b;
            return [
              createElementVNode("span", _hoisted_21, toDisplayString(unref(filterSuccessDesc)), 1),
              unref(currentTab).name !== "dataLink" && unref(currentTab).name !== "options" ? (openBlock(), createElementBlock("div", _hoisted_22, [
                createVNode(_component_el_select, {
                  modelValue: unref(dataLinkFieldList),
                  "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => isRef(dataLinkFieldList) ? dataLinkFieldList.value = $event : null),
                  multiple: "",
                  filterable: "",
                  placeholder: !filterConfigData || ((_a = filterConfigData.conditions) == null ? void 0 : _a.length) == 0 ? "请选择字段" : "",
                  disabled: !filterConfigData || ((_b = filterConfigData.conditions) == null ? void 0 : _b.length) == 0
                }, {
                  default: withCtx(() => [
                    (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fieldsData), (item) => {
                      return openBlock(), createBlock(_component_el_option, {
                        key: item.id + "",
                        label: item.label,
                        value: item.id + ""
                      }, null, 8, ["label", "value"]);
                    }), 128))
                  ]),
                  _: 2
                }, 1032, ["modelValue", "placeholder", "disabled"])
              ])) : unref(currentTab).name == "options" ? (openBlock(), createElementBlock("div", _hoisted_23, [
                createElementVNode("div", _hoisted_24, [
                  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fieldAssignments), (assignment, index) => {
                    return openBlock(), createElementBlock("div", {
                      key: index,
                      class: "field-assignment-item"
                    }, [
                      createVNode(_component_el_select, {
                        modelValue: assignment.fieldId,
                        "onUpdate:modelValue": ($event) => assignment.fieldId = $event,
                        filterable: "",
                        placeholder: "请选择字段",
                        style: { "width": "200px", "margin-right": "12px" },
                        onChange: ($event) => onFieldIdChange(index)
                      }, {
                        default: withCtx(() => [
                          (openBlock(true), createElementBlock(Fragment, null, renderList(unref(optionsFieldsData), (item) => {
                            return openBlock(), createBlock(_component_el_option, {
                              key: item.id,
                              label: item.label,
                              value: item.id
                            }, null, 8, ["label", "value"]);
                          }), 128))
                        ]),
                        _: 2
                      }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"]),
                      assignment.fieldId ? (openBlock(), createElementBlock("div", _hoisted_25, [
                        createVNode(_component_el_select, {
                          modelValue: assignment.optionsOpt,
                          "onUpdate:modelValue": ($event) => assignment.optionsOpt = $event,
                          multiple: "",
                          placeholder: "请选择可选项",
                          style: { "width": "100%", "margin-right": "12px" },
                          loading: !unref(optionsFieldsOptionsCache)[assignment.fieldId],
                          onChange: ($event) => onOptionsOptChange(index)
                        }, {
                          default: withCtx(() => [
                            (openBlock(true), createElementBlock(Fragment, null, renderList(getOptionsFieldsOptionsByCache(
                              assignment.fieldId
                            ), (item) => {
                              return openBlock(), createBlock(_component_el_option, {
                                key: item.value,
                                label: item.label,
                                value: item.value
                              }, null, 8, ["label", "value"]);
                            }), 128))
                          ]),
                          _: 2
                        }, 1032, ["modelValue", "onUpdate:modelValue", "loading", "onChange"])
                      ])) : createCommentVNode("", true),
                      createVNode(_component_el_button, {
                        type: "danger",
                        link: "",
                        icon: "Delete",
                        onClick: ($event) => removeFieldAssignment(index),
                        style: { "margin-left": "8px" }
                      }, null, 8, ["onClick"])
                    ]);
                  }), 128))
                ]),
                createVNode(_component_el_button, {
                  type: "primary",
                  link: "",
                  icon: "CirclePlus",
                  onClick: addFieldAssignment,
                  class: "add-assignment-btn"
                }, {
                  default: withCtx(() => _cache[8] || (_cache[8] = [
                    createTextVNode(" 添加可选项字段 ")
                  ])),
                  _: 1
                })
              ])) : (openBlock(), createElementBlock("div", _hoisted_26, [
                createElementVNode("div", _hoisted_27, [
                  (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fieldAssignments), (assignment, index) => {
                    return openBlock(), createElementBlock("div", {
                      key: index,
                      class: "field-assignment-item"
                    }, [
                      createVNode(_component_el_select, {
                        modelValue: assignment.fieldId,
                        "onUpdate:modelValue": ($event) => assignment.fieldId = $event,
                        filterable: "",
                        placeholder: "请选择字段",
                        style: { "width": "200px", "margin-right": "12px" }
                      }, {
                        default: withCtx(() => [
                          unref(fieldsData).length > 0 ? (openBlock(), createBlock(_component_el_option_group, {
                            key: 0,
                            label: "表单字段"
                          }, {
                            default: withCtx(() => [
                              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(fieldsData), (item) => {
                                return openBlock(), createBlock(_component_el_option, {
                                  key: item.id,
                                  label: item.label,
                                  value: item.id
                                }, null, 8, ["label", "value"]);
                              }), 128))
                            ]),
                            _: 1
                          })) : createCommentVNode("", true),
                          unref(hiddenFields).length > 0 ? (openBlock(), createBlock(_component_el_option_group, {
                            key: 1,
                            label: "隐藏域"
                          }, {
                            default: withCtx(() => [
                              (openBlock(true), createElementBlock(Fragment, null, renderList(unref(hiddenFields), (field) => {
                                return openBlock(), createBlock(_component_el_option, {
                                  key: field.id,
                                  label: field.label,
                                  value: field.id
                                }, null, 8, ["label", "value"]);
                              }), 128))
                            ]),
                            _: 1
                          })) : createCommentVNode("", true)
                        ]),
                        _: 2
                      }, 1032, ["modelValue", "onUpdate:modelValue"]),
                      assignment.fieldId ? (openBlock(), createElementBlock("div", _hoisted_28, [
                        createVNode(unref(_sfc_main$1), {
                          title: "公式配置",
                          formulaConf: assignment.formula.value,
                          "onUpdate:formulaConf": ($event) => assignment.formula.value = $event,
                          modelValue: assignment.formula.text,
                          "onUpdate:modelValue": ($event) => assignment.formula.text = $event
                        }, null, 8, ["formulaConf", "onUpdate:formulaConf", "modelValue", "onUpdate:modelValue"])
                      ])) : createCommentVNode("", true),
                      createVNode(_component_el_button, {
                        type: "danger",
                        link: "",
                        icon: "Delete",
                        onClick: ($event) => removeFieldAssignment(index),
                        style: { "margin-left": "8px" }
                      }, null, 8, ["onClick"])
                    ]);
                  }), 128))
                ]),
                createVNode(_component_el_button, {
                  type: "primary",
                  link: "",
                  icon: "CirclePlus",
                  onClick: addFieldAssignment,
                  class: "add-assignment-btn"
                }, {
                  default: withCtx(() => _cache[9] || (_cache[9] = [
                    createTextVNode(" 添加字段赋值 ")
                  ])),
                  _: 1
                })
              ]))
            ];
          }),
          _: 1
        }, 8, ["modelValue", "filterConfig", "title"])
      ], 64);
    };
  }
};
const DataLinkage = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-35097e4f"]]);
export {
  DataLinkage as default
};
