"use strict";
Object.defineProperties(exports, { __esModule: { value: true }, [Symbol.toStringTag]: { value: "Module" } });
require("../../../../../node_modules/element-plus/es/index.js");
;/* empty css                                                             */
require("../../../../../node_modules/element-plus/theme-chalk/el-dropdown-menu.css.js");
require("../../../../../node_modules/element-plus/theme-chalk/el-dropdown-item.css.js");
;/* 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                                                                  */
;/* empty css                                                                   */
;/* empty css                                                                  */
const Vue = require("vue");
const index$6 = require("../../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const vueDraggablePlus = require("../../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.js");
const common = require("../../utils/common.js");
const FixedModeConfig = require("./FixedModeConfig.vue.js");
const DynamicModeConfig = require("./DynamicModeConfig.vue.js");
const tableBtn = require("../tableBtn.vue.js");
;/* empty css            */
const _pluginVue_exportHelper = require("../../../../../_virtual/_plugin-vue_export-helper.js");
const index = require("../../../../../node_modules/element-plus/es/components/switch/index.js");
const index$1 = require("../../../../../node_modules/element-plus/es/components/divider/index.js");
const index$2 = require("../../../../../node_modules/element-plus/es/components/select/index.js");
const index$3 = require("../../../../../node_modules/element-plus/es/components/input-number/index.js");
const index$4 = require("../../../../../node_modules/element-plus/es/components/dropdown/index.js");
const index$5 = require("../../../../../node_modules/element-plus/es/components/button/index.js");
const index$7 = require("../../../../../node_modules/element-plus/es/components/tag/index.js");
const index$8 = require("../../../../../node_modules/element-plus/es/components/icon/index.js");
const index$9 = require("../../../../../node_modules/element-plus/es/components/input/index.js");
const index$a = require("../../../../../node_modules/element-plus/es/components/empty/index.js");
const index$b = require("../../../../../node_modules/element-plus/es/components/checkbox/index.js");
const _hoisted_1 = { class: "table-query-config" };
const _hoisted_2 = { class: "config-row" };
const _hoisted_3 = {
  key: 0,
  class: "tab-panel"
};
const _hoisted_4 = { class: "tab-header" };
const _hoisted_5 = { class: "tab-config-list" };
const _hoisted_6 = { class: "drag-handle" };
const _hoisted_7 = { class: "add-field-label" };
const _hoisted_8 = { class: "add-field-label" };
const _sfc_main = {
  __name: "index",
  setup(__props) {
    const editConfigData = Vue.computed(() => common.getEditConfigData());
    const editConfigDataValue = Vue.computed(() => common.getEditConfigData());
    const queryConfig = Vue.computed(() => common.getEditConfigData().queryConfig);
    const tabConfigDropdownVisible = Vue.ref(false);
    const tabConfigs = Vue.computed({
      get: () => {
        var _a, _b;
        return ((_b = (_a = queryConfig.value) == null ? void 0 : _a.dynamicConfig) == null ? void 0 : _b.tabConfigs) || [];
      },
      set: (val) => {
        if (!queryConfig.value.dynamicConfig) {
          queryConfig.value.dynamicConfig = {};
        }
        queryConfig.value.dynamicConfig.tabConfigs = val;
      }
    });
    const searchFields = Vue.computed({
      get: () => {
        var _a, _b;
        return ((_b = (_a = queryConfig.value) == null ? void 0 : _a.dynamicConfig) == null ? void 0 : _b.searchFields) || [];
      },
      set: (val) => {
        if (!queryConfig.value.dynamicConfig) {
          queryConfig.value.dynamicConfig = {};
        }
        queryConfig.value.dynamicConfig.searchFields = val;
      }
    });
    Vue.watch(
      () => {
        var _a;
        return (_a = queryConfig.value) == null ? void 0 : _a.mode;
      },
      (newMode) => {
        if (!queryConfig.value) return;
        if (newMode === "dynamic" && !queryConfig.value.dynamicConfig) {
          queryConfig.value.dynamicConfig = {
            tabConfigs: [],
            searchFields: []
          };
        }
      },
      { immediate: true }
    );
    const availableFields = Vue.computed(() => {
      var _a, _b;
      const allFields = [
        ...((_a = editConfigData.value) == null ? void 0 : _a.fieldsData) || [],
        ...((_b = editConfigData.value) == null ? void 0 : _b.hiddenFields) || []
      ];
      return allFields;
    });
    const availableSearchFields = Vue.computed(() => {
      const selectedFieldIds = searchFields.value.map((f) => f.id);
      return availableFields.value.map((field) => ({
        ...field,
        isSearchField: selectedFieldIds.includes(field.id)
      }));
    });
    function addTabConfig() {
      const newTab = {
        id: Date.now(),
        label: `标签名${tabConfigs.value.length + 1}`,
        fieldName: "",
        fixedValue: ""
      };
      tabConfigs.value = [...tabConfigs.value, newTab];
    }
    function removeTabConfig(index2) {
      const newTabs = [...tabConfigs.value];
      newTabs.splice(index2, 1);
      tabConfigs.value = newTabs;
    }
    function handleSearchFieldChange(field, value) {
      if (value) {
        searchFields.value = [
          ...searchFields.value,
          {
            id: field.id,
            fieldName: field.fieldName,
            label: field.label,
            fieldType: field.fieldType
          }
        ];
      } else {
        const newFields = searchFields.value.filter((f) => f.id !== field.id);
        searchFields.value = newFields;
      }
    }
    function handleAddField(field, value) {
      if (!editConfigData.value.queryConfig) {
        editConfigData.value.queryConfig = {};
      }
      if (!editConfigData.value.queryConfig.filterFields) {
        editConfigData.value.queryConfig.filterFields = [];
      }
      if (value) {
        editConfigData.value.queryConfig.filterFields.push({
          id: Date.now(),
          fieldId: field.id,
          type: "filterWidgets",
          queryType: "fuzzy"
        });
      } else {
        const index2 = editConfigData.value.queryConfig.filterFields.findIndex(
          (f) => f.fieldId == field.id
        );
        if (index2 !== -1) {
          editConfigData.value.queryConfig.filterFields.splice(index2, 1);
        }
      }
    }
    return (_ctx, _cache) => {
      const _component_el_switch = index.ElSwitch;
      const _component_el_divider = index$1.ElDivider;
      const _component_el_option = index$2.ElOption;
      const _component_el_select = index$2.ElSelect;
      const _component_el_input_number = index$3.ElInputNumber;
      const _component_el_tag = index$7.ElTag;
      const _component_el_button = index$5.ElButton;
      const _component_el_icon = index$8.ElIcon;
      const _component_el_input = index$9.ElInput;
      const _component_el_empty = index$a.ElEmpty;
      const _component_el_dropdown = index$4.ElDropdown;
      const _component_el_checkbox = index$b.ElCheckbox;
      const _component_el_dropdown_item = index$4.ElDropdownItem;
      const _component_el_dropdown_menu = index$4.ElDropdownMenu;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.createElementVNode("div", _hoisted_2, [
            _cache[20] || (_cache[20] = Vue.createElementVNode("span", { class: "config-label" }, "开启筛选", -1)),
            Vue.createVNode(_component_el_switch, {
              modelValue: queryConfig.value.enabled,
              "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => queryConfig.value.enabled = $event),
              size: "small"
            }, null, 8, ["modelValue"]),
            Vue.createVNode(_component_el_divider, { direction: "vertical" }),
            _cache[21] || (_cache[21] = Vue.createElementVNode("span", { class: "config-label" }, "显示返回", -1)),
            Vue.createVNode(_component_el_switch, {
              modelValue: editConfigDataValue.value.showReturn,
              "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => editConfigDataValue.value.showReturn = $event),
              size: "small"
            }, null, 8, ["modelValue"]),
            Vue.createVNode(_component_el_divider, { direction: "vertical" }),
            _cache[22] || (_cache[22] = Vue.createElementVNode("span", { class: "config-label" }, "显示标题", -1)),
            Vue.createVNode(_component_el_switch, {
              modelValue: editConfigDataValue.value.showTitle,
              "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => editConfigDataValue.value.showTitle = $event),
              size: "small"
            }, null, 8, ["modelValue"]),
            Vue.createVNode(_component_el_divider, { direction: "vertical" }),
            _cache[23] || (_cache[23] = Vue.createElementVNode("span", { class: "config-label" }, "筛选模式", -1)),
            Vue.createVNode(_component_el_select, {
              modelValue: queryConfig.value.mode,
              "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => queryConfig.value.mode = $event),
              size: "small",
              style: { "width": "120px" }
            }, {
              default: Vue.withCtx(() => [
                Vue.createVNode(_component_el_option, {
                  label: "固定列",
                  value: "fixed"
                }),
                Vue.createVNode(_component_el_option, {
                  label: "动态列",
                  value: "dynamic"
                })
              ]),
              _: 1
            }, 8, ["modelValue"]),
            queryConfig.value.mode === "fixed" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 0 }, [
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              _cache[11] || (_cache[11] = Vue.createElementVNode("span", { class: "config-label" }, "筛选列数", -1)),
              Vue.createVNode(_component_el_select, {
                modelValue: queryConfig.value.columnCount,
                "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => queryConfig.value.columnCount = $event),
                size: "small",
                style: { "width": "100px" }
              }, {
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_option, {
                    label: "一列",
                    value: 1
                  }),
                  Vue.createVNode(_component_el_option, {
                    label: "二列",
                    value: 2
                  }),
                  Vue.createVNode(_component_el_option, {
                    label: "三列",
                    value: 3
                  }),
                  Vue.createVNode(_component_el_option, {
                    label: "四列",
                    value: 4
                  })
                ]),
                _: 1
              }, 8, ["modelValue"]),
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              _cache[12] || (_cache[12] = Vue.createElementVNode("span", { class: "config-label" }, "收起行数", -1)),
              Vue.createVNode(_component_el_input_number, {
                modelValue: queryConfig.value.collapseRows,
                "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => queryConfig.value.collapseRows = $event),
                min: 1,
                size: "small",
                "controls-position": "right",
                style: { "width": "80px" }
              }, null, 8, ["modelValue"])
            ], 64)) : Vue.createCommentVNode("", true),
            queryConfig.value.mode === "dynamic" ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 1 }, [
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              Vue.createVNode(_component_el_dropdown, {
                "max-height": 500,
                trigger: "click",
                "popper-class": "tab-config-dropdown",
                onVisibleChange: _cache[7] || (_cache[7] = (visible) => tabConfigDropdownVisible.value = visible)
              }, {
                dropdown: Vue.withCtx(() => [
                  tabConfigDropdownVisible.value ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_3, [
                    Vue.createElementVNode("div", _hoisted_4, [
                      _cache[15] || (_cache[15] = Vue.createElementVNode("span", { class: "tab-tip" }, "配置Tab页签筛选条件", -1)),
                      Vue.createVNode(_component_el_button, {
                        type: "primary",
                        size: "small",
                        onClick: addTabConfig,
                        icon: "Plus"
                      }, {
                        default: Vue.withCtx(() => _cache[14] || (_cache[14] = [
                          Vue.createTextVNode(" 添加Tab页签 ")
                        ])),
                        _: 1
                      })
                    ]),
                    Vue.createElementVNode("div", _hoisted_5, [
                      Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
                        modelValue: tabConfigs.value,
                        "onUpdate:modelValue": _cache[6] || (_cache[6] = ($event) => tabConfigs.value = $event),
                        animation: 150,
                        handle: ".drag-handle"
                      }, {
                        default: Vue.withCtx(() => [
                          (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(tabConfigs.value, (tab, index2) => {
                            return Vue.openBlock(), Vue.createElementBlock("div", {
                              key: tab.id,
                              class: "tab-config-item"
                            }, [
                              Vue.createElementVNode("div", _hoisted_6, [
                                Vue.createVNode(_component_el_icon, null, {
                                  default: Vue.withCtx(() => [
                                    Vue.createVNode(Vue.unref(index$6.Rank))
                                  ]),
                                  _: 1
                                })
                              ]),
                              Vue.createVNode(_component_el_input, {
                                modelValue: tab.label,
                                "onUpdate:modelValue": ($event) => tab.label = $event,
                                size: "small",
                                placeholder: "标签名",
                                style: { "width": "120px" }
                              }, null, 8, ["modelValue", "onUpdate:modelValue"]),
                              Vue.createVNode(_component_el_select, {
                                modelValue: tab.fieldName,
                                "onUpdate:modelValue": ($event) => tab.fieldName = $event,
                                size: "small",
                                placeholder: "选择字段",
                                style: { "width": "150px" },
                                "append-to": ".tab-config-dropdown"
                              }, {
                                default: Vue.withCtx(() => [
                                  (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(availableFields.value, (field) => {
                                    return Vue.openBlock(), Vue.createBlock(_component_el_option, {
                                      key: field.id,
                                      label: field.label,
                                      value: field.fieldName
                                    }, null, 8, ["label", "value"]);
                                  }), 128))
                                ]),
                                _: 2
                              }, 1032, ["modelValue", "onUpdate:modelValue"]),
                              Vue.createVNode(_component_el_input, {
                                modelValue: tab.fixedValue,
                                "onUpdate:modelValue": ($event) => tab.fixedValue = $event,
                                size: "small",
                                placeholder: "筛选值",
                                style: { "width": "120px" },
                                disabled: !tab.fieldName
                              }, null, 8, ["modelValue", "onUpdate:modelValue", "disabled"]),
                              Vue.createVNode(_component_el_button, {
                                icon: Vue.unref(index$6.Delete),
                                link: "",
                                type: "danger",
                                class: "delete-btn",
                                onClick: ($event) => removeTabConfig(index2)
                              }, null, 8, ["icon", "onClick"])
                            ]);
                          }), 128))
                        ]),
                        _: 1
                      }, 8, ["modelValue"]),
                      tabConfigs.value.length === 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_empty, {
                        key: 0,
                        description: "暂无Tab页签配置",
                        "image-size": 60
                      })) : Vue.createCommentVNode("", true)
                    ])
                  ])) : Vue.createCommentVNode("", true)
                ]),
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_button, {
                    icon: Vue.unref(index$6.Filter),
                    size: "small"
                  }, {
                    default: Vue.withCtx(() => [
                      _cache[13] || (_cache[13] = Vue.createTextVNode(" 配置Tab页签 ")),
                      tabConfigs.value.length > 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_tag, {
                        key: 0,
                        size: "small",
                        type: "primary",
                        class: "tab-count-tag"
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createTextVNode(Vue.toDisplayString(tabConfigs.value.length), 1)
                        ]),
                        _: 1
                      })) : Vue.createCommentVNode("", true)
                    ]),
                    _: 1
                  }, 8, ["icon"])
                ]),
                _: 1
              }),
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              Vue.createVNode(_component_el_dropdown, {
                "max-height": 500,
                trigger: "click",
                placement: "bottom",
                "hide-on-click": false
              }, {
                dropdown: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_dropdown_menu, null, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(availableSearchFields.value, (field) => {
                        return Vue.openBlock(), Vue.createBlock(_component_el_dropdown_item, {
                          key: field.id,
                          command: field
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_el_checkbox, {
                              modelValue: field.isSearchField,
                              "onUpdate:modelValue": ($event) => field.isSearchField = $event,
                              onChange: (value) => {
                                handleSearchFieldChange(field, value);
                              }
                            }, {
                              default: Vue.withCtx(() => [
                                Vue.createElementVNode("span", _hoisted_7, Vue.toDisplayString(field.label), 1)
                              ]),
                              _: 2
                            }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"])
                          ]),
                          _: 2
                        }, 1032, ["command"]);
                      }), 128)),
                      availableSearchFields.value.length === 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_dropdown_item, {
                        key: 0,
                        disabled: ""
                      }, {
                        default: Vue.withCtx(() => _cache[17] || (_cache[17] = [
                          Vue.createElementVNode("span", {
                            class: "add-field-label",
                            style: { "text-align": "center" }
                          }, "暂无可用字段", -1)
                        ])),
                        _: 1
                      })) : Vue.createCommentVNode("", true)
                    ]),
                    _: 1
                  })
                ]),
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_button, {
                    size: "small",
                    icon: Vue.unref(index$6.Plus)
                  }, {
                    default: Vue.withCtx(() => [
                      _cache[16] || (_cache[16] = Vue.createTextVNode(" 配置搜索字段 ")),
                      searchFields.value.length > 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_tag, {
                        key: 0,
                        size: "small",
                        type: "primary",
                        style: { "margin-left": "6px", "height": "16px", "padding": "0 5px" }
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createTextVNode(Vue.toDisplayString(searchFields.value.length), 1)
                        ]),
                        _: 1
                      })) : Vue.createCommentVNode("", true)
                    ]),
                    _: 1
                  }, 8, ["icon"])
                ]),
                _: 1
              }),
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              _cache[18] || (_cache[18] = Vue.createElementVNode("span", { class: "config-label" }, "高级搜索", -1)),
              Vue.createVNode(_component_el_switch, {
                modelValue: queryConfig.value.dynamicConfig.advancedSearch,
                "onUpdate:modelValue": _cache[8] || (_cache[8] = ($event) => queryConfig.value.dynamicConfig.advancedSearch = $event),
                size: "small"
              }, null, 8, ["modelValue"])
            ], 64)) : Vue.createCommentVNode("", true),
            queryConfig.value.mode === "fixed" || queryConfig.value.mode === "dynamic" && queryConfig.value.dynamicConfig.advancedSearch ? (Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, { key: 2 }, [
              Vue.createVNode(_component_el_divider, { direction: "vertical" }),
              Vue.createVNode(_component_el_dropdown, {
                trigger: "click",
                placement: "bottom",
                "hide-on-click": false
              }, {
                dropdown: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_dropdown_menu, null, {
                    default: Vue.withCtx(() => [
                      (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(availableFields.value, (field) => {
                        return Vue.openBlock(), Vue.createBlock(_component_el_dropdown_item, {
                          key: field.id,
                          command: field
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_el_checkbox, {
                              modelValue: field.isFilter,
                              "onUpdate:modelValue": ($event) => field.isFilter = $event,
                              onChange: (value) => {
                                handleAddField(field, value);
                              }
                            }, {
                              default: Vue.withCtx(() => [
                                Vue.createElementVNode("span", _hoisted_8, Vue.toDisplayString(field.label), 1)
                              ]),
                              _: 2
                            }, 1032, ["modelValue", "onUpdate:modelValue", "onChange"])
                          ]),
                          _: 2
                        }, 1032, ["command"]);
                      }), 128)),
                      availableFields.value.length === 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_dropdown_item, {
                        key: 0,
                        disabled: ""
                      }, {
                        default: Vue.withCtx(() => _cache[19] || (_cache[19] = [
                          Vue.createElementVNode("span", {
                            class: "add-field-label",
                            style: { "text-align": "center" }
                          }, "暂无可用字段", -1)
                        ])),
                        _: 1
                      })) : Vue.createCommentVNode("", true)
                    ]),
                    _: 1
                  })
                ]),
                default: Vue.withCtx(() => [
                  Vue.createVNode(_component_el_button, {
                    size: "small",
                    icon: Vue.unref(index$6.Plus)
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createTextVNode(Vue.toDisplayString(queryConfig.value.mode === "fixed" ? "新增筛选" : "高级搜索字段") + " ", 1),
                      queryConfig.value.filterFields.length > 0 ? (Vue.openBlock(), Vue.createBlock(_component_el_tag, {
                        key: 0,
                        size: "small",
                        type: "primary",
                        style: { "margin-left": "6px", "height": "16px", "padding": "0 5px" }
                      }, {
                        default: Vue.withCtx(() => [
                          Vue.createTextVNode(Vue.toDisplayString(queryConfig.value.filterFields.length), 1)
                        ]),
                        _: 1
                      })) : Vue.createCommentVNode("", true)
                    ]),
                    _: 1
                  }, 8, ["icon"])
                ]),
                _: 1
              })
            ], 64)) : Vue.createCommentVNode("", true)
          ]),
          queryConfig.value.mode === "fixed" && queryConfig.value.enabled ? (Vue.openBlock(), Vue.createBlock(FixedModeConfig.default, {
            key: 0,
            modelValue: queryConfig.value.filterFields,
            "onUpdate:modelValue": _cache[9] || (_cache[9] = ($event) => queryConfig.value.filterFields = $event)
          }, null, 8, ["modelValue"])) : queryConfig.value.mode === "dynamic" ? (Vue.openBlock(), Vue.createBlock(DynamicModeConfig.default, {
            key: 1,
            modelValue: queryConfig.value.dynamicConfig,
            "onUpdate:modelValue": _cache[10] || (_cache[10] = ($event) => queryConfig.value.dynamicConfig = $event),
            enabled: queryConfig.value.enabled
          }, null, 8, ["modelValue", "enabled"])) : Vue.createCommentVNode("", true)
        ]),
        queryConfig.value.mode === "fixed" ? (Vue.openBlock(), Vue.createBlock(tableBtn.default, { key: 0 })) : Vue.createCommentVNode("", true)
      ], 64);
    };
  }
};
const QueryModule = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-e569e134"]]);
exports.default = QueryModule;
