/*! @ecan-bi/pivot-table@1.0.73 */
import { defineComponent as ne, inject as W, ref as f, reactive as ie, computed as se, unref as t, watch as ae, resolveComponent as L, openBlock as M, createBlock as U, withCtx as q, createElementVNode as z, toDisplayString as J, createVNode as X, normalizeClass as A, createElementBlock as re, normalizeStyle as de, mergeProps as ce, createCommentVNode as ue, nextTick as Y } from "vue";
import { _ as me, B as fe, S as pe, C as he, E as ge, n as Z, d as ve } from "./index-c36e79f0.mjs";
import { cloneDeep as Ce } from "lodash-es";
import "dayjs";
import "axios";
import "ant-design-vue";
import "ant-design-vue/es/input-number/style";
import "ant-design-vue/es/form/style";
import "echarts";
import "vuedraggable";
const be = ne({
  name: "DrillModal",
  props: {
    scaleValue: {
      type: Object,
      default: () => ({
        widthScale: 1,
        heightScale: 1
      })
    },
    isIframeMode: {
      type: Boolean,
      default: !1
    }
  },
  components: {
    BorderOutlined: fe,
    SwitcherOutlined: pe,
    CloseOutlined: he,
    EcanPivotTable: ge
  },
  setup(e, { expose: p }) {
    const K = {
      IN: "属于",
      NOT_IN: "不属于",
      LIKE: "包含",
      NOT_LIKE: "不包含",
      "LIKE%": "开头是",
      "%LIKE": "结尾是",
      EQUAL: "等于",
      LESS: "小于",
      LESS_EQUAL: "小于等于",
      GREATER: "大于",
      GREATER_EQUAL: "大于等于",
      NOT_EQUAL: "不等于"
    }, D = 0.37, N = 0.6, O = 0.97, F = 0.9, h = `dmodal_${Z(6)}`, $ = () => document.querySelector("#ProviderConfig > #container") || document.body, w = W("theme", "light"), g = f({}), y = f([]), x = W("indicatorUrl", ""), j = f([]), v = f(!1), C = f({}), _ = ie({
      keyName: "",
      visible: !1,
      columns: [],
      title: ""
    }), B = f([]), P = f(), ee = se(() => {
      let o = `drill-modal ${h}`;
      return v.value && (o += " full"), t(w) && (o += ` ${t(w)}`), o;
    }), I = (o) => {
      const l = document.querySelector(`.${h} .ant-modal-header`);
      if (l)
        if (o)
          l.addEventListener("mousedown", H);
        else {
          const r = l.parentElement;
          r && (r.style.left = "", r.style.top = ""), l.removeEventListener("mousedown", H);
        }
    }, R = (o) => {
      const l = document.querySelector(`.${h} .ant-modal-header`);
      l && (o ? l.addEventListener("dblclick", k) : l.removeEventListener("dblclick", k));
    }, H = (o) => {
      ve(o, `.${h} .ant-modal-header`);
    }, k = () => {
      v.value = !v.value, Y(() => {
        v.value ? (t(C).width = parseFloat(t(g).width) * O + "px", t(C).height = (e.isIframeMode ? parseFloat(t(g).height) : window.screen.height) * F + "px", I(!1)) : (t(C).width = parseFloat(t(g).width) * D + "px", t(C).height = (e.isIframeMode ? parseFloat(t(g).height) : window.screen.height) * N + "px", I(!0));
      });
    }, oe = () => {
      v.value = !1, R(!1), I(!1);
    }, le = ({ drillDimension: o, drillFieldData: l, usedDimensionFields: r, tableProps: c, splitSymbol: i }) => {
      const T = Ce(c), { graphicConfig: d, allDimensions: E, pageConfig: s } = T, b = Z(6), n = [];
      B.value = [...r, o.label], E.value = E, s.value = s;
      const a = d.indicators.filter((m) => m.show).map((m) => m.label);
      a != null && a.length && (_.title = `下钻：${a.join("、")}`);
      for (const m of l) {
        const u = E.find((G) => [G.title, G.label].includes(m.dimensionKey)), S = m.value.split(i);
        let Q = m.value;
        S != null && S.length && (Q = S[S.length - 1]), n.push({
          conditionKey: u.label,
          conditionLabel: u.title || u.label,
          conditionName: u.name,
          conditionValueType: u.genericType,
          indexCode: u.indexCode,
          typeGuid: u.typeGuid,
          indexCodeNum: u.indexCodeNum,
          rule: "EQUAL",
          dataType: "",
          customValue: Q
        });
      }
      d.queryColumnList = [o], n != null && n.length && (d.controlList || (d.controlList = []), d.controlList.push(...n), d.controlList = [
        {
          join: "&&",
          conditions: d.controlList
        }
      ]), C.value = {
        ...T,
        id: b,
        keyName: `透视表_${b}`,
        position: "relative",
        top: 0,
        left: 0,
        width: parseFloat(t(s).width) * D + "px",
        height: (e.isIframeMode ? parseFloat(t(s).height) : window.screen.height) * N + "px",
        graphicConfig: d
      }, _.visible = !0, Y(() => {
        t(P).refreshData(), R(!0), I(!0);
      });
    }, te = ({ type: o, data: l }) => {
      if (o === "11" && l) {
        const {
          indicatorList: r = [],
          queryColumns: c = []
        } = l, T = r.concat(c).filter((s) => s.conditions || s.filter), d = V(T, "conditions", !0), E = V(l.sqlConditions, "sqlConditions", !1);
        j.value = d.concat(E).map((s) => {
          const b = t(y).find((a) => a.label === s.label);
          let n = s.fieldValue;
          if (n && typeof n == "string") {
            const a = n.split(",");
            (a == null ? void 0 : a.length) > 3 && (n = a.slice(0, 3).join(",") + "等");
          } else
            n || (n = '""');
          return `${(b == null ? void 0 : b.title) || s.label} ${K[s.rule]} ${n}`;
        }) || [];
      }
    };
    function V(o, l, r) {
      const c = [];
      for (const i of o)
        i[l] ? c.push(...V(i[l], l, r)) : i.filter ? c.push({
          ...i.filter,
          label: i.label
        }) : (!r || i.dataType !== "component" && !(i.fieldValue.startsWith("${") && i.fieldValue.endsWith("}"))) && c.push(i);
      return c;
    }
    return ae(_.visible, (o) => {
      window.modalShow && window.modalShow(o);
    }), p({
      showModal: le
    }), {
      theme: w,
      wrapClassName: ee,
      conditionInfo: j,
      drillInfo: _,
      pivotTableConfig: C,
      indicatorUrl: x,
      isIndFullScreen: v,
      usedDimensionFields: B,
      pivotTableRef: P,
      toggleFullScreen: k,
      onDetailCancel: oe,
      onPivotTableChange: te,
      getContainer: $
    };
  }
}), we = ["title"];
function ye(e, p, K, D, N, O) {
  const F = L("close-outlined"), h = L("switcher-outlined"), $ = L("border-outlined"), w = L("ecan-pivot-table"), g = L("a-modal");
  return M(), U(g, {
    "wrap-class-name": e.wrapClassName,
    visible: e.drillInfo.visible,
    "onUpdate:visible": p[1] || (p[1] = (y) => e.drillInfo.visible = y),
    width: "60%",
    footer: null,
    maskClosable: !1,
    destroyOnClose: !0,
    getContainer: e.getContainer,
    onCancel: e.onDetailCancel
  }, {
    title: q(() => [
      z("div", {
        class: "modal-title",
        title: e.conditionInfo.join("、")
      }, J(e.drillInfo.title) + " " + J(e.conditionInfo.join("、")), 9, we)
    ]),
    closeIcon: q(() => [
      X(F, {
        class: A(["modal-icon", e.theme])
      }, null, 8, ["class"])
    ]),
    default: q(() => [
      z("div", {
        class: "zoom-btn",
        onClick: p[0] || (p[0] = (...y) => e.toggleFullScreen && e.toggleFullScreen(...y))
      }, [
        e.isIndFullScreen ? (M(), U(h, {
          key: 0,
          class: A(["modal-icon", e.theme])
        }, null, 8, ["class"])) : (M(), U($, {
          key: 1,
          class: A(["modal-icon", e.theme])
        }, null, 8, ["class"]))
      ]),
      e.drillInfo.visible ? (M(), re("div", {
        key: 0,
        style: de({
          position: "relative",
          width: e.pivotTableConfig.width,
          height: e.pivotTableConfig.height
        })
      }, [
        X(w, ce({ ref: "pivotTableRef" }, e.pivotTableConfig, {
          theme: e.theme,
          fullMode: !1,
          allowDrill: !0,
          showFullScreen: !1,
          showClear: !1,
          isAllowSaveConfig: !1,
          indicatorUrl: e.indicatorUrl,
          relateKeyName: e.drillInfo.keyName,
          usedDimensionFields: e.usedDimensionFields,
          scaleValue: e.scaleValue,
          onTableChange: e.onPivotTableChange
        }), null, 16, ["theme", "indicatorUrl", "relateKeyName", "usedDimensionFields", "scaleValue", "onTableChange"])
      ], 4)) : ue("", !0)
    ]),
    _: 1
  }, 8, ["wrap-class-name", "visible", "getContainer", "onCancel"]);
}
const $e = /* @__PURE__ */ me(be, [["render", ye], ["__scopeId", "data-v-412e66d4"]]);
export {
  $e as default
};
//# sourceMappingURL=DrillModal-e9b34ae7.mjs.map
