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                                                               */
import { computed, reactive, watch, createElementBlock, openBlock, createElementVNode, createVNode, withCtx, Fragment, renderList, createBlock } from "vue";
import { getEditConfigData } from "../utils/common.mjs";
/* empty css                   */
import _export_sfc from "../../../../_virtual/_plugin-vue_export-helper.mjs";
import { ElSwitch } from "../../../../node_modules/element-plus/es/components/switch/index.mjs";
import { ElDivider } from "../../../../node_modules/element-plus/es/components/divider/index.mjs";
import { ElSelect, ElOption } from "../../../../node_modules/element-plus/es/components/select/index.mjs";
import { ElRadioGroup, ElRadioButton } from "../../../../node_modules/element-plus/es/components/radio/index.mjs";
const _hoisted_1 = { class: "table-summary-config" };
const _hoisted_2 = { class: "config-row" };
const _sfc_main = {
  __name: "tableSummary",
  setup(__props) {
    var _a;
    const editConfigData = computed(() => getEditConfigData());
    const availableFields = computed(() => {
      var _a2;
      const fields = ((_a2 = editConfigData.value) == null ? void 0 : _a2.fieldsData) || [];
      return fields.filter((field) => field.isShow && field.fieldType === "number");
    });
    const summaryConfig = reactive({
      enabled: false,
      mode: "current",
      summaryFields: [],
      ...((_a = editConfigData.value) == null ? void 0 : _a.summaryConfig) || {}
    });
    watch(
      summaryConfig,
      (val) => {
        editConfigData.value.summaryConfig = val;
      },
      { deep: true }
    );
    return (_ctx, _cache) => {
      const _component_el_switch = ElSwitch;
      const _component_el_divider = ElDivider;
      const _component_el_option = ElOption;
      const _component_el_select = ElSelect;
      const _component_el_radio_button = ElRadioButton;
      const _component_el_radio_group = ElRadioGroup;
      return openBlock(), createElementBlock("div", _hoisted_1, [
        createElementVNode("div", _hoisted_2, [
          _cache[3] || (_cache[3] = createElementVNode("span", { class: "config-label" }, "开启合计:", -1)),
          createVNode(_component_el_switch, {
            modelValue: summaryConfig.enabled,
            "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => summaryConfig.enabled = $event),
            size: "small"
          }, null, 8, ["modelValue"]),
          createVNode(_component_el_divider, { direction: "vertical" }),
          _cache[4] || (_cache[4] = createElementVNode("span", { class: "config-label" }, "合计列:", -1)),
          createVNode(_component_el_select, {
            modelValue: summaryConfig.summaryFields,
            "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => summaryConfig.summaryFields = $event),
            multiple: "",
            size: "small",
            style: { "width": "200px" },
            "collapse-tags": "",
            "collapse-tags-tooltip": "",
            placeholder: "请选择要合计的列"
          }, {
            default: withCtx(() => [
              (openBlock(true), createElementBlock(Fragment, null, renderList(availableFields.value, (field) => {
                return openBlock(), createBlock(_component_el_option, {
                  key: field.fieldName,
                  label: field.label || field.fieldName,
                  value: field.fieldName
                }, null, 8, ["label", "value"]);
              }), 128))
            ]),
            _: 1
          }, 8, ["modelValue"]),
          createVNode(_component_el_divider, { direction: "vertical" }),
          _cache[5] || (_cache[5] = createElementVNode("span", { class: "config-label" }, "合计模式:", -1)),
          createVNode(_component_el_radio_group, {
            modelValue: summaryConfig.mode,
            "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => summaryConfig.mode = $event),
            size: "small"
          }, {
            default: withCtx(() => [
              createVNode(_component_el_radio_button, {
                label: "当前页数据",
                value: "current"
              }),
              createVNode(_component_el_radio_button, {
                label: "全部数据",
                value: "all"
              })
            ]),
            _: 1
          }, 8, ["modelValue"])
        ])
      ]);
    };
  }
};
const TableSummary = /* @__PURE__ */ _export_sfc(_sfc_main, [["__scopeId", "data-v-29acfeb4"]]);
export {
  TableSummary as default
};
