"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                                                                 */
const Vue = require("vue");
const _default = require("./default.js");
const vueDraggablePlus = require("../../../../node_modules/vue-draggable-plus/dist/vue-draggable-plus.js");
const index$6 = require("../../../../node_modules/@element-plus/icons-vue/dist/index.js");
const TableSetting = require("./TableSetting.vue.js");
const index = ;/* empty css                       */
const tablePagination = require("./tablePagination.vue.js");
const tableSummary = require("./tableSummary.vue.js");
const common = require("../utils/common.js");
;/* empty css                                                              */
;/* empty css                                                                */
;/* empty css            */
const _pluginVue_exportHelper = require("../../../../_virtual/_plugin-vue_export-helper.js");
const index$1 = require("../../../../node_modules/element-plus/es/components/checkbox/index.js");
const index$2 = require("../../../../node_modules/element-plus/es/components/radio/index.js");
const index$3 = require("../../../../node_modules/element-plus/es/components/scrollbar/index.js");
const index$4 = require("../../../../node_modules/element-plus/es/components/icon/index.js");
const index$5 = require("../../../../node_modules/element-plus/es/components/link/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/message/index.js");
const _hoisted_1 = { class: "table-work-area" };
const _hoisted_2 = {
  key: 0,
  class: "table-selectMode"
};
const _hoisted_3 = { class: "widgets" };
const _hoisted_4 = { class: "field-label" };
const _hoisted_5 = {
  key: 1,
  class: "table-indexMode"
};
const _hoisted_6 = ["name", "onMouseenter", "onClick"];
const _hoisted_7 = { class: "widgets" };
const _hoisted_8 = { class: "field-label" };
const _hoisted_9 = { key: 1 };
const _hoisted_10 = { class: "quick-operation" };
const _hoisted_11 = { class: "widgets" };
const _sfc_main = {
  __name: "index",
  setup(__props) {
    function getItemStyle(item) {
      const style = {};
      if (item.widthMode === "fixed" && item.width) {
        style.width = item.width + "px";
      }
      if (item.widthMode === "auto" && item.minWidth) {
        style.minWidth = item.minWidth + "px";
      }
      if (!item.widthMode && item.width) {
        style.width = item.width + "px";
      }
      return style;
    }
    function getAlignClass(item) {
      const alignClass = {};
      if (item.headerAlign) {
        alignClass[`align-header-${item.headerAlign}`] = true;
      }
      if (item.align) {
        alignClass[`align-${item.align}`] = true;
      }
      return alignClass;
    }
    const tableOptions = Vue.computed(() => {
      return common.getEditConfigData();
    });
    Vue.ref(/* @__PURE__ */ new Map());
    function addOptBtns() {
      tableOptions.value.optBtns.push({
        id: Date.now(),
        ..._default.defaultOptBtn
      });
    }
    function deleteOptBtn(btn) {
      const index2 = tableOptions.value.optBtns.findIndex(
        (item) => item.id === btn.id
      );
      if (index2 !== -1) {
        tableOptions.value.optBtns.splice(index2, 1);
      }
      common.setSelectedItem();
    }
    function deleteWidgets(item) {
      var _a;
      const index2 = tableOptions.value.fieldsData.findIndex(
        (col) => col.id === item.id
      );
      if (index2 !== -1) {
        const deletedItem = tableOptions.value.fieldsData[index2];
        if (!tableOptions.value.deletedFields) {
          tableOptions.value.deletedFields = [];
        }
        const deletedField = {
          label: (deletedItem == null ? void 0 : deletedItem.label) || "",
          fieldName: (deletedItem == null ? void 0 : deletedItem.fieldName) || "",
          fieldType: (deletedItem == null ? void 0 : deletedItem.fieldType) || "",
          deleteTime: (/* @__PURE__ */ new Date()).toLocaleString("zh-CN"),
          data: deletedItem
        };
        tableOptions.value.deletedFields.push(deletedField);
        tableOptions.value.fieldsData.splice(index2, 1);
        const filterIndex = (_a = tableOptions.value.queryConfig) == null ? void 0 : _a.filterFields.findIndex(
          (field) => field.fieldId == item.id
        );
        if (filterIndex !== -1) {
          tableOptions.value.queryConfig.filterFields.splice(filterIndex, 1);
        }
        index$8.ElMessage.success("字段已移至回收站");
      }
      common.setSelectedItem();
    }
    function handleHide(item) {
      const index2 = tableOptions.value.fieldsData.findIndex(
        (cell) => cell.id == item.id
      );
      if (index2 !== -1) {
        if (!tableOptions.value.hiddenFields) {
          tableOptions.value.hiddenFields = [];
        }
        tableOptions.value.hiddenFields.push(item);
        tableOptions.value.fieldsData.splice(index2, 1);
      }
    }
    function getVisibleColCount() {
      return tableOptions.value.fieldsData.filter((col) => col.isShow).length;
    }
    function onDragEnd(event) {
    }
    return (_ctx, _cache) => {
      const _component_el_checkbox = index$1.ElCheckbox;
      const _component_el_radio = index$2.ElRadio;
      const _component_DCaret = Vue.resolveComponent("DCaret");
      const _component_el_icon = index$4.ElIcon;
      const _component_el_link = index$5.ElLink;
      const _component_CopyDocument = Vue.resolveComponent("CopyDocument");
      const _component_el_scrollbar = index$3.ElScrollbar;
      const _component_el_tag = index$7.ElTag;
      return Vue.openBlock(), Vue.createElementBlock(Vue.Fragment, null, [
        Vue.createVNode(Vue.unref(index.default)),
        Vue.createVNode(TableSetting.default),
        Vue.createElementVNode("div", _hoisted_1, [
          Vue.unref(tableOptions).selectMode !== "none" ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_2, [
            Vue.createElementVNode("div", _hoisted_3, [
              Vue.unref(tableOptions).selectMode === "multiple" ? (Vue.openBlock(), Vue.createBlock(_component_el_checkbox, {
                key: 0,
                disabled: ""
              })) : (Vue.openBlock(), Vue.createBlock(_component_el_radio, {
                key: 1,
                disabled: ""
              }))
            ]),
            Vue.createElementVNode("div", _hoisted_4, [
              Vue.unref(tableOptions).selectMode === "multiple" ? (Vue.openBlock(), Vue.createBlock(_component_el_checkbox, {
                key: 0,
                disabled: ""
              })) : (Vue.openBlock(), Vue.createBlock(_component_el_radio, {
                key: 1,
                disabled: ""
              }))
            ])
          ])) : Vue.createCommentVNode("", true),
          Vue.unref(tableOptions).showIndex ? (Vue.openBlock(), Vue.createElementBlock("div", _hoisted_5, _cache[5] || (_cache[5] = [
            Vue.createElementVNode("div", { class: "widgets" }, "序号", -1),
            Vue.createElementVNode("div", { class: "field-label" }, "1", -1)
          ]))) : Vue.createCommentVNode("", true),
          Vue.createVNode(_component_el_scrollbar, { style: { "flex": "1" } }, {
            default: Vue.withCtx(() => [
              Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
                modelValue: Vue.unref(tableOptions).fieldsData,
                "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => Vue.unref(tableOptions).fieldsData = $event),
                animation: 150,
                group: "dev",
                ghostClass: "ghost",
                class: "edit-table-draggable",
                onEnd: onDragEnd
              }, {
                default: Vue.withCtx(() => [
                  (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(tableOptions).fieldsData, (item) => {
                    return Vue.withDirectives((Vue.openBlock(), Vue.createElementBlock("div", {
                      class: Vue.normalizeClass(["table-item", [
                        Vue.unref(common.getCurrentClass)(item),
                        getAlignClass(item),
                        { "flex-auto": item.widthMode === "auto" }
                      ]]),
                      name: item.fieldName,
                      onMouseenter: ($event) => Vue.unref(common.setHoverItem)(item),
                      onMouseleave: _cache[0] || (_cache[0] = ($event) => Vue.unref(common.setHoverItem)()),
                      onClick: Vue.withModifiers(($event) => Vue.unref(common.setSelectedItem)(item), ["stop"]),
                      style: Vue.normalizeStyle(getItemStyle(item))
                    }, [
                      Vue.createElementVNode("div", _hoisted_7, [
                        Vue.createTextVNode(Vue.toDisplayString(item.label) + " ", 1),
                        item.sortRule == "static" ? (Vue.openBlock(), Vue.createBlock(_component_el_icon, { key: 0 }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_DCaret)
                          ]),
                          _: 1
                        })) : item.sortRule == "server" ? (Vue.openBlock(), Vue.createBlock(_component_el_icon, {
                          key: 1,
                          style: { "color": "#8dd0f0" }
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_DCaret)
                          ]),
                          _: 1
                        })) : Vue.createCommentVNode("", true)
                      ]),
                      Vue.createElementVNode("div", _hoisted_8, [
                        item.isLink ? (Vue.openBlock(), Vue.createBlock(_component_el_link, {
                          key: 0,
                          type: "primary",
                          underline: "always",
                          style: { "height": "20px" }
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createTextVNode(Vue.toDisplayString(item.fieldName), 1)
                          ]),
                          _: 2
                        }, 1024)) : (Vue.openBlock(), Vue.createElementBlock("span", _hoisted_9, Vue.toDisplayString(item.fieldName), 1)),
                        item.canCopy ? (Vue.openBlock(), Vue.createBlock(_component_el_icon, { key: 2 }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(_component_CopyDocument)
                          ]),
                          _: 1
                        })) : Vue.createCommentVNode("", true)
                      ]),
                      Vue.createElementVNode("div", _hoisted_10, [
                        getVisibleColCount() > 1 ? (Vue.openBlock(), Vue.createBlock(_component_el_icon, {
                          key: 0,
                          class: "icon-action setting-icon",
                          onClick: Vue.withModifiers(($event) => handleHide(item), ["stop"])
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(Vue.unref(index$6.Hide))
                          ]),
                          _: 2
                        }, 1032, ["onClick"])) : Vue.createCommentVNode("", true),
                        getVisibleColCount() > 1 ? (Vue.openBlock(), Vue.createBlock(_component_el_icon, {
                          key: 1,
                          class: "icon-action delete",
                          onClick: Vue.withModifiers(($event) => deleteWidgets(item), ["stop"])
                        }, {
                          default: Vue.withCtx(() => [
                            Vue.createVNode(Vue.unref(index$6.Delete))
                          ]),
                          _: 2
                        }, 1032, ["onClick"])) : Vue.createCommentVNode("", true)
                      ])
                    ], 46, _hoisted_6)), [
                      [Vue.vShow, item.isShow]
                    ]);
                  }), 256))
                ]),
                _: 1
              }, 8, ["modelValue"]),
              _cache[6] || (_cache[6] = Vue.createElementVNode("div", { class: "widgets-opt-tools" }, null, -1))
            ]),
            _: 1
          }),
          Vue.createElementVNode("div", {
            class: Vue.normalizeClass(["table-item table-btn", { close: !Vue.unref(tableOptions).isOptBtns }])
          }, [
            Vue.createElementVNode("div", _hoisted_11, [
              Vue.createVNode(_component_el_checkbox, {
                class: "isOptBtns",
                modelValue: Vue.unref(tableOptions).isOptBtns,
                "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => Vue.unref(tableOptions).isOptBtns = $event)
              }, null, 8, ["modelValue"]),
              _cache[8] || (_cache[8] = Vue.createElementVNode("span", { class: "widgets-label" }, "操作", -1)),
              Vue.createVNode(_component_el_link, {
                class: "addLink",
                underline: "never",
                type: "primary",
                icon: Vue.unref(index$6.Plus),
                onClick: Vue.withModifiers(addOptBtns, ["stop"])
              }, {
                default: Vue.withCtx(() => _cache[7] || (_cache[7] = [
                  Vue.createTextVNode("按钮")
                ])),
                _: 1
              }, 8, ["icon"])
            ]),
            Vue.createVNode(Vue.unref(vueDraggablePlus.VueDraggable), {
              modelValue: Vue.unref(tableOptions).optBtns,
              "onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => Vue.unref(tableOptions).optBtns = $event),
              animation: 150,
              ghostClass: "ghost",
              class: "table-btn-option"
            }, {
              default: Vue.withCtx(() => [
                (Vue.openBlock(true), Vue.createElementBlock(Vue.Fragment, null, Vue.renderList(Vue.unref(tableOptions).optBtns, (btn) => {
                  return Vue.openBlock(), Vue.createBlock(_component_el_tag, {
                    class: Vue.normalizeClass(["opt-btn", Vue.unref(common.getCurrentClass)(btn)]),
                    closable: "",
                    effect: "plain",
                    size: "small",
                    onClose: ($event) => deleteOptBtn(btn),
                    onMouseenter: ($event) => Vue.unref(common.setHoverItem)(btn),
                    onMouseleave: _cache[3] || (_cache[3] = ($event) => Vue.unref(common.setHoverItem)()),
                    onClick: Vue.withModifiers(($event) => Vue.unref(common.setSelectedItem)(btn), ["stop"])
                  }, {
                    default: Vue.withCtx(() => [
                      Vue.createTextVNode(Vue.toDisplayString(btn.label), 1)
                    ]),
                    _: 2
                  }, 1032, ["class", "onClose", "onMouseenter", "onClick"]);
                }), 256))
              ]),
              _: 1
            }, 8, ["modelValue"])
          ], 2)
        ]),
        Vue.createVNode(tableSummary.default),
        Vue.createVNode(tablePagination.default)
      ], 64);
    };
  }
};
const tableWorkArea = /* @__PURE__ */ _pluginVue_exportHelper.default(_sfc_main, [["__scopeId", "data-v-87fe3266"]]);
exports.default = tableWorkArea;
