import { defineComponent as z, ref as J, watch as L, resolveComponent as h, openBlock as o, createElementBlock as r, createElementVNode as W, createVNode as u, unref as f, createCommentVNode as x, normalizeStyle as I, withCtx as g, Fragment as k, renderList as w, createBlock as b, normalizeClass as D } from "vue";
import { aG as j, x as A, V as K, y as P, s as R, w as S, al as N, G as q, _ as H } from "./index-D9_Q0ZzG.js";
const Q = { class: "move" }, T = {
  key: 0,
  class: "widget-view-drag"
}, U = ["onMousedown"], X = {
  key: 0,
  class: "item-action"
}, Y = {
  key: 0,
  class: "item-action"
}, Z = /* @__PURE__ */ z({
  __name: "FormGridCopy",
  props: {
    list: {
      type: Array,
      default: []
    },
    data: {
      type: Object,
      default: null
    },
    activeIndex: {
      type: String,
      default: ""
    },
    index: {
      type: String,
      default: ""
    }
  },
  emits: ["childConfig", "index"],
  setup(e, { emit: O }) {
    const p = j(), { formData: _ } = p, a = e, i = J("-1");
    L(
      () => a.activeIndex,
      (t, n) => {
        i.value = t;
      }
    );
    const m = O;
    function C(t, n, l) {
      i.value = n, m("childConfig", t), m("index", i.value), l.stopPropagation(), l.preventDefault();
    }
    function $() {
      i.value = "-1", console.log("开始拖拽");
    }
    function V(t, n) {
      t.to.className == "widget-col-list" ? i.value = a.index + "-" + n + "-" + t.newIndex : i.value = t.newIndex, m("index", i.value);
    }
    function E(t) {
      const n = JSON.parse(JSON.stringify(t));
      if (a.data.columns && a.data.columns.length > 0) {
        let l = a.data.columns.findIndex((v) => v.key == t.key);
        l > -1 && (n.key = N(), n.id = N(), a.data.columns.splice(l + 1, 0, n));
      }
    }
    function F(t) {
      let n = a.data.columns.findIndex((l) => l.key == t.key);
      n > -1 && a.data.columns.splice(n, 1);
    }
    function G() {
      if (a.data.columns.length > 0)
        q.confirm({
          title: "确定要删除该栅格布局吗?",
          content: "如果该布局存在表单，将会一并删除",
          onOk() {
            const t = a.list.findIndex((n) => n.id == a.data.id);
            t != -1 && a.list.splice(t, 1);
          },
          onCancel() {
          }
        });
      else {
        const t = a.list.findIndex((n) => n.id == a.data.id);
        t != -1 && a.list.splice(t, 1);
      }
    }
    return (t, n) => {
      const l = h("a-col"), v = h("a-row"), M = h("a-form");
      return o(), r("div", null, [
        W("div", Q, [
          e.activeIndex == e.index ? (o(), r("div", T, [
            u(f(A), { style: { padding: "6px" } })
          ])) : x("", !0)
        ]),
        u(M, {
          style: I({ padding: `${e.data.top || 0}px ${e.data.right || 0}px ${e.data.bottom || 0}px ${e.data.left || 0}px` }),
          "label-col": { style: { width: f(p).formData.config.labelWidth + "px" } },
          labelWrap: !0
        }, {
          default: g(() => [
            u(v, {
              gutter: [e.data.options.gutter, 8],
              tyle: "flex",
              style: I({ marginLeft: -e.data.options.gutter / 2 + "px", marginRight: -e.data.options.gutter / 2 + "px" })
            }, {
              default: g(() => [
                (o(!0), r(k, null, w(e.data.columns, (d, c) => (o(), b(l, {
                  class: D(["widget-col-item", { active: i.value == "col-" + e.index + "-" + c }]),
                  span: d.options.span,
                  offset: d.options.offset,
                  onMousedown: (s) => C(d, "col-" + e.index + "-" + c, s)
                }, {
                  default: g(() => [
                    u(f(K), {
                      class: "widget-col-list",
                      style: { "min-height": "50px" },
                      "ghost-class": "ghost",
                      list: d.list,
                      "force-fallback": !0,
                      "chosen-class": "chosenClass2",
                      "drag-class": "dragClass1",
                      onStart: $,
                      onEnd: (s) => V(s, c),
                      group: "itxst",
                      sort: !1,
                      animation: "300",
                      handle: ".move",
                      itemKey: ""
                    }, {
                      default: g(() => [
                        (o(!0), r(k, null, w(d.list, (s, y) => (o(), r("div", {
                          class: D(["widget-view", { active: i.value == e.index + "-" + c + "-" + y }]),
                          onMousedown: (B) => C(s, e.index + "-" + c + "-" + y, B)
                        }, [
                          u(P, {
                            data: s,
                            list: d.list,
                            activeIndex: i.value,
                            index: e.index + "-" + c + "-" + y
                          }, null, 8, ["data", "list", "activeIndex", "index"])
                        ], 42, U))), 256))
                      ]),
                      _: 2
                    }, 1032, ["list", "onEnd"]),
                    e.activeIndex === "col-" + e.index + "-" + c ? (o(), r("div", X, [
                      u(f(R), {
                        style: { padding: "3px 5px" },
                        onClick: (s) => E(d)
                      }, null, 8, ["onClick"]),
                      e.data.columns.length !== 1 ? (o(), b(f(S), {
                        key: 0,
                        onClick: (s) => F(d)
                      }, null, 8, ["onClick"])) : x("", !0)
                    ])) : x("", !0)
                  ]),
                  _: 2
                }, 1032, ["span", "class", "offset", "onMousedown"]))), 256)),
                e.activeIndex === e.index ? (o(), r("div", Y, [
                  u(f(S), {
                    style: { padding: "3px 5px", color: "#fff" },
                    onClick: n[0] || (n[0] = (d) => G())
                  })
                ])) : x("", !0)
              ]),
              _: 1
            }, 8, ["gutter", "style"])
          ]),
          _: 1
        }, 8, ["style", "label-col"])
      ]);
    };
  }
}), ne = /* @__PURE__ */ H(Z, [["__scopeId", "data-v-e3b465b8"]]);
export {
  ne as default
};
