var ue = Object.defineProperty;
var he = (e, s, t) => s in e ? ue(e, s, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[s] = t;
var I = (e, s, t) => (he(e, typeof s != "symbol" ? s + "" : s, t), t);
import { IndexViewModel as me, GridModel as pe, ViewType as fe, ModelUtil as ge } from "@ibiz-template/model";
import { GridFieldColumnController as X, GridRowController as J, WFStepTraceViewController as ve, UploadEditorController as Q, GridController as we, GridNotifyState as be, WFDynaEditView3Controller as ye } from "@ibiz-template/controller";
import { defineComponent as U, computed as $, h as c, getCurrentInstance as A, ref as v, watch as T, toRefs as z, onUnmounted as Ce } from "vue";
import { useNamespace as N, useViewController as K, usePropsWatch as B, getUploadProps as xe, getEditorEmits as Y, getGridUploadProps as _, getGridEditorEmits as j, useClickOutside as ke, useEventListener as Fe, getInputProps as Se, getGridInputProps as Le, useGridCellEditor as Ee, useControlController as Ue, useWFStepTraceViewController as Pe, useEditView3Controller as Ne } from "@ibiz-template/vue-util";
import { colorBlend as Ie, HttpError as ee, isImage as Te, uploadFile as De, RuntimeError as Me } from "@ibiz-template/core";
import { getCookie as $e, createUUID as V } from "qx-util";
import { debounce as Re } from "lodash-es";
import { safeRedirect as Ae, ViewMode as te, UIActionHandler as se, PluginStaticResource as Ge } from "@ibiz-template/runtime";
const Oe = U({
  name: "CodeListGridColumn",
  props: {
    controller: {
      type: X,
      required: !0
    },
    row: {
      type: J,
      required: !0
    }
  },
  setup(e) {
    const s = N("grid-field-column"), t = $(() => {
      var n;
      if (e.controller.model.source.cLConvertMode !== "FRONT")
        return [];
      const r = e.row.data[e.controller.model.codeName];
      return (n = e.controller.codeListItems) != null && n.length && r ? r.split(",").map((h) => {
        const p = e.controller.codeListItems.find((g) => g.value === h);
        if (p) {
          const g = p.color || "#515a6e";
          return {
            text: p.text,
            colorStyle: s.cssVarBlock({
              color: g,
              "border-color": g,
              "bg-color": Ie(g, "#fff")
            })
          };
        }
      }).filter(Boolean) : [];
    }), o = (r) => {
      e.controller.isLinkColumn && e.controller.openLinkView(e.row, r);
    }, i = $(() => {
      let r = "";
      switch (e.controller.model.align) {
        case "LEFT":
          r = "flex-start";
          break;
        case "RIGHT":
          r = "flex-end";
          break;
        default:
          r = "center";
          break;
      }
      return s.cssVarBlock({
        "justify-content": r
      });
    });
    return {
      ns: s,
      alignStyle: i,
      selectedItems: t,
      onCellClick: o
    };
  },
  render() {
    const e = this.controller, s = this.row.data[e.model.codeName];
    return c("div", {
      class: [this.ns.b(), e.isLinkColumn && this.ns.m("link-column")],
      style: this.alignStyle,
      on: {
        click: this.onCellClick
      }
    }, [this.selectedItems.length > 0 ? this.selectedItems.map((t) => c("span", {
      class: this.ns.e("code-list-item"),
      style: t.colorStyle
    }, [t.text])) : c("span", {
      class: this.ns.e("text")
    }, [s])]);
  }
});
class ze extends ve {
  constructor() {
    super(...arguments);
    /**
     * 流程图url
     *
     * @type {string}
     * @memberof PresetWFChartViewController
     */
    I(this, "imgSrc");
  }
  async getUIData() {
    const t = Object.assign(this.context.clone(), this.params), o = await this.entityService.wf.getWFProcessDiagram(t), i = new Blob([o.data], {
      type: "image/svg+xml"
    });
    this.imgSrc = URL.createObjectURL(i);
  }
}
const Be = U({
  name: "PresetWFChartView",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const s = N("preset-wf-chart-view"), {
      proxy: t
    } = A(), o = K(t, (i, r) => new ze(e.modelPath, i, r));
    return B(t, "deName", o.setDeName.bind(o)), {
      c: o,
      ns: s
    };
  },
  render() {
    return c("div", {
      class: this.ns.b()
    }, [c("img", {
      attrs: {
        src: this.c.imgSrc
      }
    })]);
  }
});
const _e = U({
  name: "WFToolbar",
  props: {
    wfLinks: {
      type: Array,
      required: !0
    }
  },
  setup(e, {
    emit: s
  }) {
    const t = N("wf-toolbar"), o = async (r, n) => {
      s("wf-link-click", r, n);
    };
    return {
      ns: t,
      handleClick: async (r, n) => {
        setTimeout(() => {
          o(r, n);
        }, 30);
      }
    };
  },
  render() {
    const e = this.wfLinks || [];
    return c("div", {
      class: `${this.ns.b()}`
    }, [e.length > 0 && e.map((s) => {
      const t = s.sequenceFlowName == "驳回" || s.sequenceFlowName == "取消", o = s.sequenceFlowName.startsWith("保存") || s.sequenceFlowName.startsWith("关闭") || s.sequenceFlowName.startsWith("保存并关闭");
      return c("div", {
        key: s.sequenceFlowId,
        class: [this.ns.e("item"), o ? this.ns.em("item", "plain") : "", t ? this.ns.em("item", "reject") : ""]
      }, [c("i-button", {
        attrs: {
          title: s.sequenceFlowName
        },
        on: {
          click: (i) => this.handleClick(s, i)
        }
      }, [s.sequenceFlowName || ""])]);
    })]);
  }
}), je = typeof btoa == "function", W = typeof Buffer == "function";
typeof TextDecoder == "function" && new TextDecoder();
const q = typeof TextEncoder == "function" ? new TextEncoder() : void 0, We = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", R = Array.prototype.slice.call(We);
((e) => {
  let s = {};
  return e.forEach((t, o) => s[t] = o), s;
})(R);
const M = String.fromCharCode.bind(String);
typeof Uint8Array.from == "function" && Uint8Array.from.bind(Uint8Array);
const Ve = (e) => e.replace(/=/g, "").replace(/[+\/]/g, (s) => s == "+" ? "-" : "_"), qe = (e) => {
  let s, t, o, i, r = "";
  const n = e.length % 3;
  for (let a = 0; a < e.length; ) {
    if ((t = e.charCodeAt(a++)) > 255 || (o = e.charCodeAt(a++)) > 255 || (i = e.charCodeAt(a++)) > 255)
      throw new TypeError("invalid character found");
    s = t << 16 | o << 8 | i, r += R[s >> 18 & 63] + R[s >> 12 & 63] + R[s >> 6 & 63] + R[s & 63];
  }
  return n ? r.slice(0, n - 3) + "===".substring(n) : r;
}, oe = je ? (e) => btoa(e) : W ? (e) => Buffer.from(e, "binary").toString("base64") : qe, He = W ? (e) => Buffer.from(e).toString("base64") : (e) => {
  let t = [];
  for (let o = 0, i = e.length; o < i; o += 4096)
    t.push(M.apply(null, e.subarray(o, o + 4096)));
  return oe(t.join(""));
}, Ze = (e) => {
  if (e.length < 2) {
    var s = e.charCodeAt(0);
    return s < 128 ? e : s < 2048 ? M(192 | s >>> 6) + M(128 | s & 63) : M(224 | s >>> 12 & 15) + M(128 | s >>> 6 & 63) + M(128 | s & 63);
  } else {
    var s = 65536 + (e.charCodeAt(0) - 55296) * 1024 + (e.charCodeAt(1) - 56320);
    return M(240 | s >>> 18 & 7) + M(128 | s >>> 12 & 63) + M(128 | s >>> 6 & 63) + M(128 | s & 63);
  }
}, Xe = /[\uD800-\uDBFF][\uDC00-\uDFFFF]|[^\x00-\x7F]/g, Je = (e) => e.replace(Xe, Ze), H = W ? (e) => Buffer.from(e, "utf8").toString("base64") : q ? (e) => He(q.encode(e)) : (e) => oe(Je(e)), ie = (e, s = !1) => s ? Ve(H(e)) : H(e);
function Qe(e, s, t) {
  var y;
  const o = v([]), i = v({
    Authorization: `Bearer ${$e("access_token")}`
  }), r = v(""), n = v(""), a = {
    count: 0,
    cacheFiles: []
    // iview上传过程中不能改default-file-list,所以需要缓存
  }, l = (y = t.editorParams) == null ? void 0 : y.blackList;
  let h = [];
  l && typeof l == "string" && (h = l.split(",")), T(
    () => e.value,
    (d) => {
      o.value = d ? JSON.parse(d) : [];
    },
    { immediate: !0 }
  ), T(
    () => e.data,
    (d) => {
      if (d) {
        const m = t.calcBaseUrl(d);
        r.value = m.uploadUrl, n.value = m.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), T(
    o,
    (d) => {
      d != null && d.length && n.value && d.forEach((m) => {
        m.url = m.url || n.value.replace("%fileId%", m.id);
      });
    },
    { immediate: !0 }
  ), T(
    n,
    (d) => {
      d && o.value.length && o.value.forEach((m) => {
        m.url = n.value.replace("%fileId%", m.id);
      });
    },
    { immediate: !0 }
  );
  const p = () => {
    const d = [...o.value, ...a.cacheFiles], m = d.length > 0 ? JSON.stringify(d.map((w) => ({ name: w.name, id: w.id }))) : null;
    a.cacheFiles = [], s(m);
  }, g = (d) => {
    const m = d.name.split(".").pop() || "";
    if (t.whiteList && t.whiteList.length > 0 && !t.whiteList.includes(m))
      return ibiz.message.error(`${d.name} 文件格式不正确`, 2.5, !0), !1;
    if (d.size > t.defaultSize * 1024 * 1024)
      return ibiz.message.error(
        `${d.name} 超出限制，请选择小于${t.defaultSize}MB的文件`,
        2.5,
        !0
      ), !1;
    const w = d.name.trim().toLowerCase();
    if (h.some((F) => w.endsWith(`.${F}`)))
      return ibiz.message.error(`不可上传 ${h.join("、")}类型的文件！`), !1;
    a.count += 1;
  }, C = (d) => {
    d && (a.cacheFiles.push({
      name: d.filename,
      id: d.fileid
    }), a.count -= 1, a.count === 0 && p());
  }, b = (d, m) => {
    throw a.count -= 1, new ee({
      response: { data: m, status: d.status }
      // eslint-disable-next-line @typescript-eslint/no-explicit-any
    });
  }, x = (d) => {
    if (e.disabled)
      return;
    const m = o.value.findIndex((w) => w.id === d.id);
    m !== -1 && o.value.splice(m, 1), p();
  }, k = (d) => {
    const w = (t.parent.form || t.parent.grid).model.appEntity.deName, P = `${d.id}|${w}|${e.data.srfkey}|${t.context.srfpersonid || t.context.srfuserid}`, F = d.url || n.value.replace("%fileId%", d.id);
    t.fileDownload({
      url: `${F}?key=${window.btoa(P)}${Math.floor(
        1e3 + Math.random() * 9e3
      )}`,
      name: d.name
    });
  }, u = v(!1), f = v(""), E = v("");
  return {
    uploadUrl: r,
    downloadUrl: n,
    headers: i,
    files: o,
    onDownload: k,
    onError: b,
    onRemove: x,
    onSuccess: C,
    beforeUpload: g,
    showModal: u,
    modalTitle: f,
    iframeUrl: E,
    onModalCancel: () => {
      u.value = !1, f.value = "", E.value = "";
    },
    previewFile: (d) => {
      u.value = !0, f.value = d.name;
      const m = window.Environment.previewFileUrl;
      if (m) {
        const w = encodeURIComponent(
          ie(
            `${window.location.origin}${d.url}?fullfilename=${d.name}`
          )
        );
        E.value = `${m}/onlinePreview?url=${w}`;
      }
    }
  };
}
const Ke = U({
  name: "SyFileUpload",
  props: xe(),
  emits: Y(),
  setup(e, {
    emit: s
  }) {
    const t = N("sy-file-upload"), o = e.controller, {
      uploadUrl: i,
      headers: r,
      files: n,
      onDownload: a,
      onError: l,
      onRemove: h,
      onSuccess: p,
      beforeUpload: g,
      showModal: C,
      modalTitle: b,
      iframeUrl: x,
      onModalCancel: k,
      previewFile: u
    } = Qe(e, (D) => {
      s("change", D);
    }, o), f = $(() => o.editorParams.showPreview ? o.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: t,
      c: o,
      uploadUrl: i,
      headers: r,
      files: n,
      onDownload: a,
      onError: l,
      onRemove: h,
      onSuccess: p,
      beforeUpload: g,
      showModal: C,
      modalTitle: b,
      iframeUrl: x,
      onModalCancel: k,
      onPreview: (D) => {
        f.value && u(D);
      },
      showPreview: f
    };
  },
  render(e) {
    return e("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [e("IUpload", {
      ref: "fileUpload",
      props: {
        action: this.uploadUrl,
        headers: this.headers,
        disabled: this.disabled,
        "default-file-list": this.files,
        multiple: this.c.model.multiple,
        type: this.c.model.isDrag ? "drag" : "select",
        accept: this.c.model.accept,
        "before-upload": this.beforeUpload,
        "on-success": this.onSuccess,
        "on-error": this.onError,
        "on-remove": this.onRemove,
        "on-preview": this.onDownload,
        "show-upload-list": !1
      }
    }, [this.c.model.isDrag ? e("div", {
      class: this.ns.bm("box", "drag")
    }, [e("i-icon", {
      attrs: {
        type: "md-cloud-upload"
      }
    }), e("div", {
      class: this.ns.be("box", "title")
    }, [e("span", ["将文件拖到此处，或"]), e("span", ["点击上传"])])]) : e("i-button", {
      class: this.ns.bm("box", "select")
    }, [e("svg", {
      attrs: {
        xmlns: "http://www.w3.org/2000/svg",
        viewBox: "0 0 1024 1024"
      }
    }, [e("path", {
      attrs: {
        fill: "currentColor",
        d: "M160 832h704a32 32 0 1 1 0 64H160a32 32 0 1 1 0-64m384-578.304V704h-64V247.296L237.248 490.048 192 444.8 508.8 128l316.8 316.8-45.312 45.248z"
      }
    })]), e("span", ["上传文件"])]), this.c.uploadDescription && !this.readonly && e("div", {
      class: this.ns.b("accept-description")
    }, [this.c.uploadDescription])]), e("div", {
      class: this.ns.b("file-list")
    }, [this.files.map((s) => e("div", {
      class: this.ns.b("file-item"),
      key: s.id
    }, [e("div", {
      class: this.ns.b("file-item-right")
    }, [e("div", {
      class: this.ns.b("file-item-right-icon")
    }, [e("svg", {
      attrs: {
        viewBox: "0 0 16 16",
        version: "1.1"
      }
    }, [e("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [e("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-128.000000, -1899.000000)",
        "fill-rule": "nonzero"
      }
    }, [e("g", {
      attrs: {
        id: "关联",
        transform: "translate(128.000000, 1899.000000)"
      }
    }, [e("rect", {
      attrs: {
        id: "矩形备份-20",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), e("path", {
      attrs: {
        d: "M8,6.25590375 C9.72432306,6.25590375 11.1277921,7.62964308 11.175675,9.34238963 L11.1769379,9.43284162 L11.1769379,12.7456325 C11.1769379,14.5002069 9.75457434,15.9225704 8,15.9225704 C6.27567694,15.9225704 4.8722079,14.5488311 4.824325,12.8360845 L4.82306213,12.7456325 L4.82306213,10.7559037 C4.82306213,10.4797614 5.04691975,10.2559037 5.32306213,10.2559037 C5.58296083,10.2559037 5.79654502,10.4541998 5.82077327,10.7077504 L5.82306213,10.7559037 L5.82306213,12.7456325 C5.82306213,13.9479221 6.79771041,14.9225704 8,14.9225704 C9.17615286,14.9225704 10.1344543,13.9898375 10.1755637,12.8237123 L10.1769379,12.7456325 L10.1769379,9.43284162 C10.1769379,8.23055203 9.20228959,7.25590375 8,7.25590375 C7.72385763,7.25590375 7.5,7.03204612 7.5,6.75590375 C7.5,6.47976137 7.72385763,6.25590375 8,6.25590375 Z M8,0.0774295852 C9.72432306,0.0774295852 11.1277921,1.45116892 11.175675,3.16391546 L11.1769379,3.25436746 L11.1769379,5.24409625 C11.1769379,5.52023863 10.9530802,5.74409625 10.6769379,5.74409625 C10.4170392,5.74409625 10.203455,5.54580022 10.1792267,5.29224959 L10.1769379,5.24409625 L10.1769379,3.25436746 C10.1769379,2.05207787 9.20228959,1.07742959 8,1.07742959 C6.82384714,1.07742959 5.86554572,2.01016247 5.82443628,3.17628769 L5.82306213,3.25436746 L5.82306213,6.56715838 C5.82306213,7.76944797 6.79771041,8.74409625 8,8.74409625 C8.27614237,8.74409625 8.5,8.96795388 8.5,9.24409625 C8.5,9.52023863 8.27614237,9.74409625 8,9.74409625 C6.27567694,9.74409625 4.8722079,8.37035692 4.824325,6.65761037 L4.82306213,6.56715838 L4.82306213,3.25436746 C4.82306213,1.49979312 6.24542566,0.0774295852 8,0.0774295852 Z",
        id: "形状结合",
        fill: "currentColor",
        transform: "translate(8.000000, 8.000000) rotate(-315.000000) translate(-8.000000, -8.000000) "
      }
    })])])])])]), e("div", {
      class: this.ns.b("file-item-right-title"),
      on: {
        click: () => this.onPreview(s)
      }
    }, [s.name]), e("div", {
      class: this.ns.b("file-item-right-action")
    }, [e("span", {
      class: this.ns.e("icon-download"),
      on: {
        click: () => this.onDownload(s)
      }
    }, [e("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [e("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        "fill-rule": "evenodd"
      }
    }, [e("g", {
      attrs: {
        id: "编组"
      }
    }, [e("path", {
      attrs: {
        d: "M7.33333333,8.77086667 L7.33333333,1.66666667 L8.66666667,1.66666667 L8.66666667,8.7716 L10.5526333,6.88563333 L11.4954333,7.82843333 L8.00036667,11.3235333 L4.50526667,7.82843333 L5.44806667,6.88563333 L7.33333333,8.77086667 Z M2,13 L2,14.3333333 L14,14.3333333 L14,13 L2,13 Z",
        id: "形状",
        fill: "currentColor",
        "fill-rule": "nonzero"
      }
    }), e("rect", {
      attrs: {
        id: "矩形",
        fill: "#000000",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])]), this.showPreview ? e("span", {
      class: this.ns.e("icon-preview"),
      on: {
        click: () => this.onPreview(s)
      }
    }, [e("svg", {
      attrs: {
        width: "16px",
        height: "17px",
        viewBox: "0 0 16 17",
        version: "1.1",
        fill: "currentColor",
        xmlns: "http://www.w3.org/2000/svg"
      }
    }, [e("g", {
      attrs: {
        id: "icon",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [e("g", {
      attrs: {
        id: "eye",
        transform: "translate(-7.9982, -7.6008)",
        fill: "currentColor"
      }
    }, [e("g", {
      attrs: {
        transform: "translate(8, 8)",
        id: "编组"
      }
    }, [e("path", {
      attrs: {
        d: "M1.43340667,7.64873333 C3.27632667,4.67586667 5.45346667,3 8.00003333,3 C10.5466,3 12.7237333,4.67586667 14.5666667,7.64873333 L14.7844,8 L14.5666667,8.35126667 C12.7237333,11.3241333 10.5466,13 8.00003333,13 C5.45346667,13 3.27632667,11.3241333 1.43340667,8.35126667 L1.21565667,8 L1.43340667,7.64873333 Z M2.79026333,8 C4.4615,10.5552333 6.2084,11.6666667 8.00003333,11.6666667 C9.79166667,11.6666667 11.5385667,10.5552333 13.2098,8 C11.5385667,5.44476667 9.79166667,4.33333333 8.00003333,4.33333333 C6.2084,4.33333333 4.4615,5.44476667 2.79026333,8 Z M8.00003333,7 C7.44773333,7 7.00003333,7.4477 7.00003333,8 C7.00003333,8.5523 7.44773333,9 8.00003333,9 C8.5523,9 9.00003333,8.5523 9.00003333,8 C9.00003333,7.4477 8.5523,7 8.00003333,7 Z M5.6667,8 C5.6667,6.71133333 6.71136667,5.66666667 8.00003333,5.66666667 C9.2887,5.66666667 10.3333667,6.71133333 10.3333667,8 C10.3333667,9.28866667 9.2887,10.3333333 8.00003333,10.3333333 C6.71136667,10.3333333 5.6667,9.28866667 5.6667,8 Z",
        id: "形状",
        "fill-rule": "nonzero"
      }
    }), e("rect", {
      attrs: {
        id: "矩形",
        "fill-rule": "nonzero",
        opacity: "0",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    })])])])])]) : null, this.disabled || this.readonly ? null : e("span", {
      class: this.ns.e("icon-remove"),
      on: {
        click: () => this.onRemove(s)
      }
    }, [e("svg", {
      attrs: {
        width: "16px",
        height: "16px",
        viewBox: "0 0 16 16",
        version: "1.1",
        fill: "currentColor"
      }
    }, [e("g", {
      attrs: {
        id: "基础组件",
        stroke: "none",
        "stroke-width": "1",
        fill: "none",
        "fill-rule": "evenodd"
      }
    }, [e("g", {
      attrs: {
        id: "Upload上传",
        transform: "translate(-544.000000, -930.000000)",
        "fill-rule": "nonzero"
      }
    }, [e("g", {
      attrs: {
        id: "删除",
        transform: "translate(544.000000, 930.000000)"
      }
    }, [e("rect", {
      attrs: {
        id: "矩形备份-12",
        x: "0",
        y: "0",
        width: "16",
        height: "16"
      }
    }), e("path", {
      attrs: {
        d: "M14.484375,2.84895833 C14.7609375,2.84895833 14.984375,3.07239583 14.984375,3.34895833 C14.984375,3.62552083 14.7609375,3.84895833 14.484375,3.84895833 L13,3.84895833 L13,14.1822917 C13,14.5504815 12.7015232,14.8489583 12.3333333,14.8489583 L3.66666667,14.8489583 C3.29847683,14.8489583 3,14.5504815 3,14.1822917 L3,3.84895833 L3,3.84895833 L1.5,3.84895833 C1.2234375,3.84895833 1,3.62552083 1,3.34895833 C1,3.07239583 1.2234375,2.84895833 1.5,2.84895833 L14.484375,2.84895833 Z M12,3.84895833 L4,3.84895833 L4,13.8489583 L12,13.8489583 L12,3.84895833 Z M6.5,5.84895833 C6.7765625,5.84895833 7,6.07239583 7,6.34895833 L7,11.3458333 C7,11.6223958 6.775,11.8458333 6.5,11.8458333 C6.2234375,11.8458333 6,11.6223958 6,11.3458333 L6,6.34895833 C6,6.07239583 6.2234375,5.84895833 6.5,5.84895833 Z M9.5,5.84895833 C9.7765625,5.84895833 10,6.07239583 10,6.34895833 L10,11.3458333 C10,11.6223958 9.775,11.8458333 9.5,11.8458333 C9.2234375,11.8458333 9,11.6223958 9,11.3458333 L9,6.34895833 C9,6.07239583 9.2234375,5.84895833 9.5,5.84895833 Z M10.5,0.847395833 C10.7765625,0.847395833 11,1.07083333 11,1.34739583 C11,1.62395833 10.7765625,1.84739583 10.5,1.84739583 L5.484375,1.84739583 C5.2078125,1.84739583 4.984375,1.62395833 4.984375,1.34739583 C4.984375,1.07083333 5.2078125,0.847395833 5.484375,0.847395833 L10.5,0.847395833 Z",
        id: "形状结合",
        fill: "currentColor"
      }
    })])])])])])])])]))]), e("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [e("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
});
function O(e, s, t, o) {
  var n, a;
  const i = s.replace("%fileId%", e.id), r = ((n = t.parent) == null ? void 0 : n.form) || ((a = t.parent) == null ? void 0 : a.grid);
  if (r) {
    const l = r.model.appEntity.deName, h = `${e.id}|${l}|${o.srfkey}|${t.context.srfpersonid || t.context.srfuserid}`;
    e.url = `${i}?key=${window.btoa(h)}${Math.floor(
      1e3 + Math.random() * 9e3
    )}`;
  }
  if (e.status || (e.status = "finished"), !e.fileName) {
    const l = e.name.lastIndexOf(".");
    e.fileName = e.name.substring(0, l), e.fileExt = e.name.substring(l), e.isImage = Te(e.name);
  }
  return e;
}
function ne(e) {
  const s = v(""), t = v(""), o = v([]);
  return T(
    e.data,
    (i) => {
      if (i) {
        const r = e.controller.value.calcBaseUrl(i);
        s.value = r.uploadUrl, t.value = r.downloadUrl;
      }
    },
    { immediate: !0, deep: !0 }
  ), T(
    e.value,
    (i) => {
      o.value = i ? JSON.parse(i) : [], o.value.length && t.value && o.value.forEach((r) => {
        O(
          r,
          t.value,
          e.controller.value,
          e.data.value
        );
      });
    },
    { immediate: !0 }
  ), T(
    t,
    (i) => {
      i && o.value.length && o.value.forEach((r) => {
        O(
          r,
          i,
          e.controller.value,
          e.data.value
        );
      });
    },
    { immediate: !0 }
  ), {
    downloadUrl: t,
    uploadUrl: s,
    valueList: o
  };
}
function re(e) {
  var y, d;
  const s = v("undo"), t = v([]), { downloadUrl: o, value: i, uploadUrl: r, controller: n, data: a } = e, l = (d = (y = n == null ? void 0 : n.value) == null ? void 0 : y.editorParams) == null ? void 0 : d.blackList;
  let h = [];
  l && typeof l == "string" && (h = l.split(",")), T(
    i,
    (m) => {
      m.length > 0 && (t.value = [], m.forEach((w) => {
        t.value.push(
          O(
            w,
            o.value,
            n.value,
            a.value
          )
        );
      }));
    },
    {
      immediate: !0,
      deep: !0
    }
  );
  const p = (m, w) => {
    if (m.some((L) => L.size > n.value.defaultSize * 1024 * 1024 ? (ibiz.message.error(
      `${L.name} 超出限制，请选择小于${n.value.defaultSize}MB的文件`,
      2.5,
      !0
    ), !0) : n.value.whiteList && n.value.whiteList.length > 0 && !n.value.whiteList.includes(L.name) ? (ibiz.message.error(`${L.name} 文件格式不正确`, 2.5, !0), !0) : !1))
      return !1;
    const F = [];
    return w.forEach((L, G) => {
      const ce = L.name.trim().toLowerCase();
      if (h.some((de) => ce.endsWith(`.${de}`))) {
        F.push(G);
        return;
      }
      t.value.push({
        name: L.name,
        status: L.status,
        percentage: L.percentage,
        id: L.uid,
        url: ""
      });
    }), F.length === w.length ? (ibiz.message.error(`不可上传 ${h.join("、")}类型的文件！`), !1) : (F.length && (F.forEach((L) => {
      m.splice(L, 1), w.splice(L, 1);
    }), ibiz.message.error(`不可上传 ${h.join("、")}类型的文件！`)), !0);
  }, g = (m) => {
    m.forEach((w) => {
      t.value.find((P) => P.id === w.uid ? (P.percentage = w.percentage, !0) : !1);
    });
  }, C = (m, w) => {
    m.forEach((P) => {
      t.value.find((F) => F.id === P.uid ? (F.status = P.status, F.id = w.data.fileid, F.name = w.data.filename, O(F, o.value, n.value, a.value), !0) : !1);
    });
  }, b = (m, w) => {
    var F;
    m.forEach((L) => {
      t.value.find((G) => G.id === L.uid ? (G.status = L.status, !0) : !1);
    });
    const P = new ee(w);
    ibiz.notification.error({
      title: (F = P.status) == null ? void 0 : F.toString(),
      desc: P.message,
      duration: 10
    });
  }, x = (m) => {
    t.value = t.value.filter((w) => w.status === "finished"), s.value = "done";
  }, k = () => {
    De({
      multiple: e.multiple,
      accept: e.accept,
      uploadUrl: r.value,
      beforeUpload: p,
      progress: g,
      success: C,
      error: b,
      finish: x
    });
  }, u = v(!1), f = v(""), E = v("");
  return {
    selectFile: k,
    fileList: t,
    uploadState: s,
    showModal: u,
    modalTitle: f,
    iframeUrl: E,
    onModalCancel: () => {
      u.value = !1, f.value = "", E.value = "";
    },
    previewFile: (m) => {
      u.value = !0, f.value = m.name;
      const w = window.Environment.previewFileUrl;
      if (w) {
        const P = encodeURIComponent(
          ie(
            `${window.location.origin}${m.url}?fullfilename=${m.name}`
          )
        );
        E.value = `${w}/onlinePreview?url=${P}`;
      }
    }
  };
}
const Ye = U({
  name: "SyGridFileUpload",
  props: _(),
  setup(e) {
    const s = N("sy-grid-file-upload"), {
      value: t,
      data: o,
      controller: i
    } = z(e), {
      downloadUrl: r,
      uploadUrl: n,
      valueList: a
    } = ne({
      value: t,
      data: o,
      controller: i
    }), {
      fileList: l,
      showModal: h,
      modalTitle: p,
      iframeUrl: g,
      previewFile: C,
      onModalCancel: b
    } = re({
      downloadUrl: r,
      uploadUrl: n,
      value: a,
      controller: i,
      data: o
    }), x = (u) => {
      const f = e.controller, D = f.parent.grid.model.appEntity.deName, S = `${u.id}|${D}|${o.value.srfkey}|${f.context.srfpersonid || f.context.srfuserid}`, y = u.url || r.value.replace("%fileId%", u.id);
      f.fileDownload({
        url: `${y}?key=${window.btoa(S)}${Math.floor(1e3 + Math.random() * 9e3)}`,
        name: u.name
      });
    }, k = $(() => e.controller.editorParams.showPreview ? e.controller.editorParams.showPreview === "true" : window.Environment.kkviewon);
    return {
      ns: s,
      fileList: l,
      showModal: h,
      modalTitle: p,
      iframeUrl: g,
      showPreview: k,
      downloadFile: x,
      previewFile: C,
      onModalCancel: b
    };
  },
  render() {
    return c("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [c("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((e) => c("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [c("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(e)
      }
    }, [e.name]), c("div", {
      class: this.ns.b("file-item-action")
    }, [this.showPreview ? c("i-icon", {
      attrs: {
        type: "md-eye"
      },
      on: {
        click: () => this.previewFile(e)
      }
    }) : null])]))]), c("i-modal", {
      attrs: {
        value: this.showModal,
        title: this.modalTitle,
        "class-name": this.ns.b("modal"),
        width: "70%",
        transfer: !1,
        "footer-hide": !0
      },
      on: {
        "on-cancel": this.onModalCancel
      }
    }, [c("iframe", {
      class: this.ns.b("iframe"),
      attrs: {
        src: this.iframeUrl
      }
    })])]);
  }
}), et = U({
  name: "SyGridFileUploadContainer",
  props: _(),
  emits: j(),
  render(e) {
    return this.disabled || this.readonly ? e("SyGridFileUpload", {
      props: {
        ...this.$props
      }
    }) : e("SyEditGridFileUpload", {
      props: {
        ...this.$props
      },
      on: {
        change: (s, t) => {
          this.$emit("change", s, t);
        },
        rowSave: () => {
          this.$emit("rowSave");
        }
      }
    });
  }
});
const tt = U({
  name: "SyEditGridFileUploadPopover",
  props: {
    uploadUrl: {
      type: String,
      required: !0
    },
    downloadUrl: {
      type: String,
      required: !0
    },
    value: {
      type: Array,
      required: !0
    },
    controller: {
      type: Q,
      required: !0
    },
    data: {
      type: Object,
      required: !0
    }
  },
  emits: {
    close: (e) => !0
  },
  setup(e, {
    emit: s
  }) {
    const t = N("sy-edit-grid-file-upload-popover"), {
      downloadUrl: o,
      value: i,
      uploadUrl: r,
      controller: n,
      data: a
    } = z(e), {
      fileList: l,
      uploadState: h,
      selectFile: p
    } = re({
      downloadUrl: o,
      value: i,
      uploadUrl: r,
      controller: n,
      data: a
    }), g = v(), C = v(!1), b = ke(g, async (u) => {
      s("close", {
        isModified: C.value,
        resultFiles: l.value
      });
    });
    return T(h, (u) => {
      u === "done" ? (C.value = !0, b.proceed()) : u === "loading" && b.pause();
    }), {
      ns: t,
      componentRef: g,
      fileList: l,
      deleteFile: (u) => {
        const f = l.value.findIndex((E) => E.id === u.id);
        l.value.splice(f, 1), C.value = !0;
      },
      selectFile: p,
      downloadFile: (u) => {
        const f = e.controller, D = f.parent.grid.model.appEntity.deName, S = `${u.id}|${D}|${e.data.srfkey}|${f.context.srfpersonid || f.context.srfuserid}`, y = u.url || o.value.replace("%fileId%", u.id);
        f.fileDownload({
          url: `${y}?key=${window.btoa(S)}${Math.floor(1e3 + Math.random() * 9e3)}`,
          name: u.name
        });
      }
    };
  },
  render() {
    return c("div", {
      ref: "componentRef",
      style: "width:300px",
      class: this.ns.b()
    }, [c("div", {
      class: this.ns.b("file-list")
    }, [this.fileList.map((e) => c("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [c("div", {
      class: this.ns.b("file-item-title"),
      on: {
        click: () => this.downloadFile(e)
      }
    }, [e.name]), c("div", {
      class: this.ns.b("file-item-action")
    }, [c("i-icon", {
      attrs: {
        type: "md-close"
      },
      on: {
        click: () => this.deleteFile(e)
      }
    })])]))]), c("div", {
      on: {
        click: () => this.selectFile()
      },
      class: this.ns.e("button")
    }, [c("i-icon", {
      attrs: {
        type: "md-add"
      }
    }), "添加文件"]), c("div", {
      class: this.ns.e("description")
    }, [this.controller.uploadDescription])]);
  }
});
const st = U({
  name: "SyEditGridFileUpload",
  props: _(),
  emits: j(),
  setup(e, {
    emit: s
  }) {
    const t = N("sy-edit-grid-file-upload"), {
      value: o,
      data: i,
      controller: r
    } = z(e), {
      downloadUrl: n,
      uploadUrl: a,
      valueList: l
    } = ne({
      value: o,
      data: i,
      controller: r
    }), h = v(), p = async () => {
      if (!h.value)
        throw new Me("容器元素不存在");
      const g = h.value.$el, C = g.offsetHeight, b = ibiz.overlay.createPopover((u) => u(tt, {
        props: {
          value: l.value,
          data: i.value,
          uploadUrl: a.value,
          downloadUrl: n.value,
          controller: r.value
        },
        on: {
          close: (f) => {
            b.dismiss(f);
          }
        }
      }), void 0, {
        noArrow: !0,
        placement: "bottom-start",
        offsetOpts: {
          mainAxis: -C,
          crossAxis: 0
        }
      });
      await b.present(g);
      const {
        isModified: x,
        resultFiles: k
      } = await b.onWillDismiss();
      if (x) {
        const u = k.length > 0 ? JSON.stringify(k.map((f) => ({
          name: f.name,
          id: f.id
        }))) : null;
        s("change", u), s("rowSave");
      }
    };
    return Fe(h, "click", (g) => {
      !e.disabled && !e.readonly && p();
    }), {
      ns: t,
      valueList: l,
      componentRef: h
    };
  },
  render() {
    return c("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      ref: "componentRef",
      class: this.ns.b()
    }, [c("div", {
      class: this.ns.b("file-list")
    }, [this.valueList.map((e) => c("div", {
      class: this.ns.b("file-item"),
      key: e.id
    }, [c("div", {
      class: this.ns.b("file-item-title")
    }, [e.name])]))])]);
  }
});
U({
  name: "SyInput",
  props: Se(),
  emits: Y(),
  setup(e, {
    emit: s
  }) {
    const t = N("input"), i = e.controller.model, r = v(), n = v(2);
    i.editorType === "TEXTAREA_10" && (n.value = 10);
    const a = $(() => {
      switch (i.editorType) {
        case "TEXTBOX":
          return "text";
        case "PASSWORD":
          return "password";
        case "TEXTAREA":
        case "TEXTAREA_10":
          return "textarea";
        default:
          return "string";
      }
    }), l = v("");
    T(() => e.value, (u, f) => {
      u !== f && (u ? l.value = u : l.value = "");
    }, {
      immediate: !0
    });
    let h = !1, p, g;
    const C = Re((u) => {
      g !== u.target.value && s("change", u.target.value), g = void 0, h = !1, p && p();
    }, 300, {
      leading: !0
    }), b = (u) => {
      h = !0, C(u);
    }, x = (u) => {
      u && u.code === "Enter" && h && (p = () => {
        r.value.$el.dispatchEvent(u);
      });
    }, k = () => {
      g = r.value.currentValue, s("change", g);
    };
    return e.autoFocus && T(r, (u) => {
      u && u.$el.getElementsByTagName("input")[0].focus();
    }), {
      ns: t,
      rows: n,
      type: a,
      currentVal: l,
      handleChange: b,
      handleKeyUp: x,
      handleBlur: k,
      inputRef: r
    };
  },
  render() {
    return c("div", {
      class: [this.ns.b(), this.ns.b("sy-input"), this.ns.is("textarea", Object.is(this.type, "textarea")), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [this.readonly ? this.currentVal : c("i-input", {
      ref: "inputRef",
      attrs: {
        value: this.currentVal,
        placeholder: this.controller.placeHolder,
        type: this.type,
        rows: this.rows,
        disabled: this.disabled,
        autosize: Object.is(this.type, "textarea")
      },
      on: {
        "on-change": this.handleChange,
        "on-blur": this.handleBlur
      },
      nativeOn: {
        keyup: this.handleKeyUp
      },
      class: this.ns.b("input")
    }, [this.controller.model.unitName && c("i", {
      class: this.ns.e("unit"),
      slot: "suffix"
    }, [this.controller.model.unitName])])]);
  }
});
U({
  name: "SyGridInput",
  props: Le(),
  emits: j(),
  setup(e, {
    emit: s
  }) {
    const t = N("grid-input"), {
      isInfoMode: o,
      autoFocus: i,
      componentRef: r,
      onOperateChange: n,
      onChange: a
    } = Ee(e, {
      emit: s
    });
    return {
      ns: t,
      isInfoMode: o,
      autoFocus: i,
      componentRef: r,
      onOperateChange: n,
      onChange: a
    };
  },
  render(e) {
    return e("grid-editor", {
      attrs: {
        disabled: this.disabled,
        readonly: this.readonly
      },
      ref: "componentRef",
      class: `${this.ns.b()}`
    }, [e("SyInput", {
      props: {
        ...this.$props,
        readonly: this.isInfoMode,
        disabled: this.disabled,
        autoFocus: this.autoFocus
      },
      on: {
        change: this.onChange,
        operate: this.onOperateChange
      }
    })]);
  }
});
function Z(e, s) {
  return c("div", {
    class: e.e("logo")
  }, [s.appIconPath ? c("img", {
    class: e.e("logo-img"),
    attrs: {
      src: s.appIconPath
    }
  }) : null, c("div", {
    class: e.e("logo-caption")
  }, [s.caption])]);
}
const ot = U({
  name: "UserAppLayout",
  props: {
    model: {
      type: me,
      required: !0
    },
    // 视图是否完成加载
    isComplete: {
      type: Boolean,
      default: !1
    },
    // 是否显示分页导航
    isShowTabPageExp: {
      type: Boolean,
      default: !1
    }
  },
  setup(e, {
    emit: s
  }) {
    const t = N("layout"), o = v(!1), i = () => {
      o.value = !o.value, s("onCollapseChange", o.value);
    }, r = $(() => e.model.source.blankMode === !0), n = $(() => !!(window.Environment.manualdownloadurl || ibiz.env.manualdownloadurl));
    return {
      ns: t,
      collapseChange: o,
      isBlank: r,
      collapseMenus: i,
      isShowDownload: n,
      downloadUserBook: () => {
        const l = window.Environment.manualdownloadurl || ibiz.env.manualdownloadurl;
        l ? Ae(l, {
          type: "_blank"
        }) : console.log("环境变量里没有manualdownloadurl");
      }
    };
  },
  render() {
    return this.isComplete ? c("i-layout", {
      class: [this.ns.b(), this.isBlank ? this.ns.m("blank") : "", this.ns.is("collapse", this.collapseChange), this.ns.is("tab", this.isShowTabPageExp), "user-layout"]
    }, [c("i-sider", {
      attrs: {
        "hide-trigger": !0,
        value: this.collapseChange
      },
      class: [this.ns.b("nav"), this.ns.is("collapse", this.collapseChange)]
    }, [Z(this.ns, this.model), this.$slots.menu]), c("i-layout", {
      class: [this.ns.b("content")]
    }, [c("i-header", {
      class: this.ns.b("header")
    }, [c("div", {
      class: this.ns.be("header", "left")
    }, [Z(this.ns, this.model), c("div", {
      class: this.ns.be("header", "collapse-icon")
    }, [this.collapseChange ? c("ion-icon", {
      attrs: {
        src: "./assets/img/menu-unfold.svg"
      },
      on: {
        click: () => this.collapseMenus()
      }
    }) : c("ion-icon", {
      attrs: {
        src: "./assets/img/menu-fold.svg"
      },
      on: {
        click: () => this.collapseMenus()
      }
    })]), this.model.source.mainMenuAlign === "TOP" ? c("i-menu", {
      class: this.ns.be("header", "menu"),
      attrs: {
        mode: "horizontal",
        "active-name": "1"
      }
    }) : null]), c("div", {
      class: this.ns.be("header", "right")
    }, [this.isShowDownload && c("div", {
      class: "user-download",
      on: {
        click: () => this.downloadUserBook()
      }
    }, ["用户手册下载"]), c("app-user")])]), c("i-content", {
      class: this.ns.be("content", "main")
    }, [this.$slots.tabPageExp, this.$slots.default])])]) : null;
  }
});
function ae(e, s) {
  var r;
  const t = s.firstColName, o = [];
  e.source.columnType === "GROUPGRIDCOLUMN" && e.children.forEach((n) => {
    o.push(ae(n, s));
  });
  const i = {
    title: e.title,
    width: e.source.widthUnit === "STAR" ? void 0 : e.width,
    minWidth: e.width,
    align: ((r = e.source.align) == null ? void 0 : r.toLowerCase()) || "center",
    slot: e.codeName,
    key: e.codeName,
    fieldName: e.deFieldName,
    ellipsis: !0,
    tooltip: !1,
    // todo 表格提示用title
    resizable: !0,
    sortable: !s.noSort && e.source.enableSort ? "custom" : !1,
    columnType: e.source.columnType,
    tree: e.codeName === t,
    className: e.codeName === t ? "grid-group-grid-column" : ""
  };
  return o.length > 0 && Object.assign(i, { children: o }), i;
}
function it(e) {
  const s = e.model, t = [], o = s.columns.map((i) => ae(i, e));
  return s.children.forEach((i) => {
    const r = o.find((a) => a.key === i.codeName), n = e.groupField;
    r && i.codeName !== n && t.push(r);
  }), e.singleSelect || t.splice(0, 0, { type: "selection", width: 60 }), t;
}
function nt(e) {
  const s = v([]);
  return e.nerve.self.evt.on("created", () => {
    s.value = it(e);
  }), [$(() => {
    const o = [...s.value];
    if (!o.find((n) => !n.width)) {
      let n = o.length - 1;
      o[n].key === "rowEdit" && (n -= 1), o[n] = {
        ...o[n],
        width: void 0
      };
    }
    const r = o.find((n) => n.columnType === "UAGRIDCOLUMN");
    return r && (r.fixed = "right"), o;
  }), s];
}
function rt(e) {
  const s = (n) => e.items.find((a) => a.srfkey === n.srfkey);
  function t(n) {
    const a = s(n);
    e.singleSelect && e.onSelectionChange([a]), e.onRowClick(a);
  }
  function o(n) {
    e.onDbRowClick(s(n));
  }
  function i(n) {
    if (!e.singleSelect) {
      const a = [];
      n.forEach((l) => {
        const h = s(l);
        h && a.push(h);
      }), e.onSelectionChange(a);
    }
  }
  function r(n) {
    const { column: a, order: l } = n, h = l === "asc" || l === "desc" ? l : void 0;
    e.setSort(a.fieldName, h), e.load();
  }
  return { onRowClick: t, onDbRowClick: o, onSelectionChange: i, onSortChange: r };
}
function at(e) {
  function s(i) {
    !i || i === e.curPage || (e.curPage = i, e.load());
  }
  function t(i) {
    !i || i === e.size || (e.size = i, e.curPage === 1 && e.load());
  }
  function o() {
    e.curPage = 1, e.load();
  }
  return { onPageChange: s, onPageSizeChange: t, onPageReset: o };
}
class lt extends we {
  constructor() {
    super(...arguments);
    /**
     * 分组数据
     * @return {*}
     * @author: zhujiamin
     * @Date: 2023-10-09 14:00:38
     */
    I(this, "groups", []);
    /**
     * 分组名称属性
     *
     * @author zhanghengfeng
     * @date 2024-12-19 10:12:56
     * @type {string}
     */
    I(this, "groupField", "");
    /**
     * 第一列名称
     *
     * @author zhanghengfeng
     * @date 2024-12-19 10:12:30
     * @type {string}
     */
    I(this, "firstColName", "");
  }
  async onInit() {
    const t = this.model.columns.find(
      (i) => {
        var r;
        return (r = i.source) == null ? void 0 : r.groupItem;
      }
    );
    t && (this.groupField = t.codeName);
    const o = this.model.columns.find((i) => i.codeName !== this.groupField && !i.source.hideDefault && !i.source.hiddenDataItem);
    o && (this.firstColName = o.codeName), await super.onInit();
  }
  /**
   * 部件加载后处理
   *
   * @author lxm
   * @date 2022-08-19 14:08:50
   */
  async afterLoad(t) {
    return await Promise.allSettled(
      Object.values(this.fieldColumns).map(async (o) => {
        await o.loadCodeList();
      })
    ), this.rows = t.map((o) => {
      const i = new J(o, this);
      return this.gridStateNotify(i, be.LOAD), i;
    }), this.handleGroup(t), t;
  }
  /**
   * 处理分组数据
   * @param {ControlVO} items
   * @return {*}
   * @author: zhujiamin
   * @Date: 2023-10-09 14:03:17
   */
  handleGroup(t) {
    const o = /* @__PURE__ */ new Map();
    t.forEach((i) => {
      const r = i[this.groupField];
      o.has(r) || o.set(r, []), o.has(r) && o.get(r).push(i);
    }), this.groups = [], o.forEach((i, r) => {
      this.groups.push({
        caption: `${r}`,
        key: r,
        children: i
      });
    });
  }
}
function ct(e, s, t, o = {}) {
  return Ue(e, () => {
    const i = new lt(s, t, o);
    return B(e, "gridRowActiveMode", i.setGridRowActiveMode.bind(i)), i;
  });
}
const dt = U({
  props: {
    modelData: pe,
    context: {
      type: Object,
      required: !0
    },
    params: {
      type: Object,
      default: () => ({})
    },
    /**
     * 表格行数据默认激活模式
     * - 0 不激活
     * - 1 单击激活
     * - 2 双击激活(默认值)
     *
     * @type {(number | 0 | 1 | 2)}
     */
    gridRowActiveMode: {
      type: Number,
      default: 2
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = A(), t = N("grid"), o = ct(s, e.modelData, e.context, e.params), [i] = nt(o), {
      onRowClick: r,
      onDbRowClick: n,
      onSelectionChange: a,
      onSortChange: l
    } = rt(o), {
      onPageChange: h,
      onPageReset: p,
      onPageSizeChange: g
    } = at(o), C = (S, y) => {
      const d = s.$refs.grid;
      d && (d.toggleSelect && d.toggleSelect(y), d.highlightCurrentRow && d.highlightCurrentRow(y)), r(S);
    }, b = v(0), x = v(null), k = v(null);
    let u = null, f = 0;
    const E = () => {
      var S;
      if (x.value && ((S = e.modal) == null ? void 0 : S.mode) !== "EMBED")
        if (o.model.source.enablePagingBar && k.value) {
          const y = k.value.$el, d = y.offsetHeight + parseFloat(window.getComputedStyle(y).paddingTop);
          b.value = x.value.offsetHeight - d;
        } else
          b.value = x.value.offsetHeight;
      o.model.source.height > 0 && (b.value = o.model.source.height);
    };
    T(x, (S, y) => {
      S && S !== y && (E(), window.ResizeObserver && x.value && (u = new ResizeObserver((d) => {
        const m = d[0].contentRect.height;
        m !== f && (E(), f = m);
      }), u.observe(x.value)));
    }), Ce(() => {
      u && u.disconnect();
    });
    const D = $(() => {
      const S = [];
      return o.groups.forEach((y) => {
        if (!y.children.length)
          return;
        const m = [...y.children].shift();
        S.push({
          srfkey: y.caption,
          isGroupData: !0,
          first: m,
          children: y.children,
          _showChildren: !0
        });
      }), S;
    });
    return {
      c: o,
      ns: t,
      columns: i,
      tableData: D,
      onDbRowClick: n,
      onUIRowClick: C,
      onSelectionChange: a,
      onSortChange: l,
      onPageChange: h,
      onPageSizeChange: g,
      onPageReset: p,
      tableHeight: b,
      gridRef: x,
      girdPaginationRef: k
    };
  },
  render() {
    if (!this.c.complete)
      return;
    const e = {};
    return this.c.model.columns.forEach((s) => {
      if (s.source.columnType === "GROUPGRIDCOLUMN")
        return;
      const t = s.codeName;
      e[t] = (o) => {
        const {
          row: i,
          column: r
        } = o;
        if (i.isGroupData && r.key === this.c.firstColName)
          return c("div", {
            class: this.ns.b("sum"),
            attrs: {
              title: i.first[this.c.groupField]
            }
          }, [c("span", [i.first[this.c.groupField]])]);
        const n = this.c.rows.find((a) => a.data.srfkey === i.srfkey);
        if (n)
          return c(this.c.providers[t].component, {
            props: {
              controller: this.c.columns[t],
              row: n
            },
            key: i.srfkey + t
          });
      };
    }), c("control-layout", {
      attrs: {
        modelData: this.c.model
      }
    }, [c("div", {
      ref: "gridRef",
      class: [this.ns.b(), this.ns.b("group-grid"), this.ns.is("show-header", !this.c.model.source.hideHeader), this.ns.is("enable-page", this.c.model.source.enablePagingBar)]
    }, [this.c.groups.length > 0 && c("i-table", {
      ref: "grid",
      attrs: {
        height: this.tableHeight,
        "show-header": !this.c.model.source.hideHeader,
        "highlight-row": !0,
        data: this.tableData,
        columns: this.columns,
        "row-key": "srfkey"
      },
      class: this.ns.b("content"),
      on: {
        "on-row-click": this.onUIRowClick,
        "on-row-dblclick": this.onDbRowClick,
        "on-selection-change": this.onSelectionChange,
        "on-sort-change": this.onSortChange
      },
      scopedSlots: e
    }), this.c.model.source.enablePagingBar && c("app-grid-pagination", {
      ref: "girdPaginationRef",
      attrs: {
        total: this.c.total,
        curPage: this.c.curPage,
        size: this.c.size
      },
      on: {
        change: this.onPageChange,
        "page-size-change": this.onPageSizeChange,
        "page-reset": this.onPageReset
      }
    })])]);
  }
});
class ut {
  constructor() {
    I(this, "component", Be);
  }
}
class ht {
  constructor() {
    I(this, "component", Oe);
  }
  async createController(s, t) {
    const o = new X(s, t);
    return await o.init(), o;
  }
}
class mt {
  constructor() {
    I(this, "component", "IndexView");
  }
}
const le = U({
  name: "WFStepTraceGrid",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    deName: {
      type: String,
      required: !0
    }
  },
  setup(e) {
    const {
      proxy: s
    } = A(), t = Pe(s, e.modelPath);
    B(s, "deName", t.setDeName.bind(t));
    const o = N("wf-step-trace-grid"), i = v([]), r = (a, l, h = !1) => {
      a.identitylinks.length > 0 || a.comments.length > 0 && a.comments.forEach((p) => {
        var g, C, b;
        h && p.type === "启动流程" || l.push({
          id: V(),
          nodeName: a.userTaskName,
          personName: (g = p.authorName) == null ? void 0 : g.replace(/\([^)]*\)[^(]*$/, ""),
          deptName: ((b = (C = p.authorName) == null ? void 0 : C.match(/.*\(([^)]*)\)[^(]*$/)) == null ? void 0 : b[1]) || "",
          time: p.time,
          content: p.type,
          comment: p.fullMessage
        });
      });
    };
    t.nerve.self.evt.on("mounted", () => {
      var a;
      t.data && ((a = t.data.usertasks) == null || a.forEach((l) => {
        if (l.usertasks && l.usertasks.length > 0) {
          const h = [];
          l.usertasks.forEach((p) => {
            r(p, h, !0);
          }), i.value.push({
            id: V(),
            nodeName: `${l.userTaskName}`,
            personName: "",
            deptName: "",
            time: "",
            content: "",
            comment: "",
            children: h,
            _showChildren: !0
          });
        } else
          r(l, i.value);
      }), i.value.sort((l, h) => Date.parse(l.time) - Date.parse(h.time)));
    });
    const n = v([{
      title: "序号",
      key: "index",
      width: 60,
      resizable: !0,
      render: (a, l) => i.value.findIndex((p) => p.id === l.row.id) === -1 ? null : a("span", {
        style: {
          textAlign: "center"
        }
      }, l.index + 1)
    }, {
      title: "审批人",
      key: "personName",
      width: 180,
      tree: !0,
      resizable: !0
    }, {
      title: "审批部门",
      key: "deptName",
      width: 170,
      resizable: !0
    }, {
      title: "处理环节",
      key: "nodeName",
      width: 200,
      resizable: !0,
      className: "clhj"
    }, {
      title: "审批(递交时间)",
      key: "time",
      width: 170,
      resizable: !0
    }, {
      title: "审批动作",
      key: "content",
      width: 150,
      resizable: !0
    }, {
      title: "审批意见",
      key: "comment",
      width: 100
    }]);
    return {
      c: t,
      ns: o,
      gridData: i,
      columns: n
    };
  },
  render() {
    return c("div", {
      class: this.ns.b()
    }, [c("div", {
      class: this.ns.e("title")
    }, ["审批信息"]), c("i-table", {
      attrs: {
        "disabled-hover": !0,
        columns: this.columns,
        data: this.gridData,
        "row-key": "id"
      },
      class: this.ns.e("grid")
    })]);
  }
});
class pt extends ye {
  async calcWfToolbar() {
    await super.calcWfToolbar(), this.isEditable && this.wfLinks.unshift({
      sequenceFlowName: "保存",
      type: "FORM_SAVE"
    });
  }
  async onLinkClick(s) {
    s.type === "FORM_SAVE" ? await this.save() : super.onLinkClick(s);
  }
}
U({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = A(), t = K(s, (n, a) => new pt(e.modelPath, n, a)), o = N(`view-${fe.DE_WF_DYNA_EDIT_VIEW3}`.toLowerCase()), i = v(["mainForm"]);
    return {
      c: t,
      ns: o,
      onTabClick: (n) => {
        i.value.includes(n) || i.value.push(n);
      },
      lazyList: i
    };
  },
  render(e) {
    const s = [];
    if (this.c.complete) {
      const {
        activeForm: t
      } = this.c;
      t && this.c.providers[t.name] && s.push(e(this.c.providers[t.name].component, {
        props: {
          modelData: t,
          context: this.c.context,
          params: this.c.params
        },
        style: {
          height: "auto"
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit("form")
        }
      }));
    }
    if (this.c.complete && this.c.model.drTab.pages[0]) {
      const t = this.c.model.drTab.pages[0], o = this.c.drPages[t.source.name];
      s.push(e(le, {
        attrs: {
          context: o.context,
          params: o.params,
          deName: this.c.model.appEntity.source.codeName,
          modal: this.modal,
          modelPath: t.embedView.source.modelPath
        }
      }));
    }
    return e("view-base", {
      attrs: {
        controller: this.c
      },
      scopedSlots: {
        toolbar: () => this.c.complete ? [this.c.wfLinks.length > 0 && e("wf-toolbar", {
          attrs: {
            wfLinks: this.c.wfLinks
          },
          on: {
            "wf-link-click": (t) => {
              this.c.onLinkClick(t);
            }
          }
        })] : null
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [s]), this.c.model.drTab.pages.map((t) => {
      const o = this.c.drPages[t.source.name];
      return e("i-tab-pane", {
        class: this.ns.be("", "tab-item"),
        attrs: {
          tab: this.c.model.drTab.source.name,
          disabled: this.c.isNewData,
          label: t.source.caption,
          name: t.source.name
        }
      }, [!this.c.isNewData && this.lazyList.includes(t.source.name) && e("ViewShell", {
        attrs: {
          context: o.context,
          params: o.params,
          modal: {
            mode: te.EMBED
          },
          modelPath: t.embedView.source.modelPath,
          // 流程跟踪视图用
          deName: this.c.model.appEntity.source.codeName
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(t.source.name)
        },
        key: o.key
      })]);
    })])]);
  }
});
U({
  name: "SyEditView3",
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    }
  },
  setup(e) {
    const {
      proxy: s
    } = A(), t = Ne(s, e.modelPath), o = N("view-deeditview3"), i = v(["mainForm"]);
    return {
      c: t,
      ns: o,
      onTabClick: (n) => {
        i.value.includes(n) || i.value.push(n);
      },
      lazyList: i
    };
  },
  render(e) {
    return e("view-base", {
      attrs: {
        controller: this.c
      }
    }, [this.c.complete && e("i-tabs", {
      class: [this.ns.be("", "tab")],
      attrs: {
        name: this.c.model.drTab.source.name
      },
      on: {
        "on-click": this.onTabClick
      }
    }, [e("i-tab-pane", {
      class: this.ns.be("", "tab-item"),
      attrs: {
        tab: this.c.model.drTab.source.name,
        label: this.c.model.drTab.source.editItemCaption,
        name: "mainForm"
      }
    }, [e("edit-form-control", {
      attrs: {
        modelData: this.c.model.form,
        context: this.c.context,
        params: this.c.params
      },
      style: {
        height: "auto"
      },
      on: {
        neuronInit: this.c.nerve.onNeuronInit(this.c.model.form.source.name)
      }
    }), e(le, {
      attrs: {
        context: this.c.drPages[this.c.model.drTab.pages[0].source.name].context,
        params: this.c.drPages[this.c.model.drTab.pages[0].source.name].params,
        deName: this.c.model.appEntity.source.codeName,
        modal: this.modal,
        modelPath: this.c.model.drTab.pages[0].embedView.source.modelPath
      }
    })]), this.c.model.drTab.pages.map((s) => {
      const t = this.c.drPages[s.source.name];
      if (t)
        return e("i-tab-pane", {
          class: this.ns.be("", "tab-item"),
          attrs: {
            tab: this.c.model.drTab.source.name,
            disabled: this.c.isNewData,
            label: s.source.caption,
            name: s.source.name
          }
        }, [!this.c.isNewData && this.lazyList.includes(s.source.name) && e("ViewShell", {
          attrs: {
            context: t.context,
            params: t.params,
            modal: {
              mode: te.EMBED
            },
            modelPath: s.embedView.source.modelPath,
            // 流程跟踪视图用
            deName: this.c.model.appEntity.source.codeName
          },
          on: {
            neuronInit: this.c.nerve.onNeuronInit(s.source.name)
          },
          key: t.key
        })]);
    })])]);
  }
});
class ft {
  constructor() {
    I(this, "formEditor", "SyFileUpload");
    I(this, "gridEditor", "SyGridFileUploadContainer");
  }
  async createController(s, t) {
    const o = new Q(s, t);
    return await o.init(), o;
  }
}
class gt extends se {
  async execAction(s, t, o, i, r) {
    if (o && o.length > 0) {
      const a = (await ibiz.entityService.getService("XQFBXQPS", t)).local.getList(t);
      o.forEach((l) => {
        const h = a.find((p) => p.srfkey === l.srfkey);
        h && (h.psjg = "10", l.psjg = "10");
      });
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
}
class vt {
  constructor() {
    I(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new gt()), this.handler;
  }
}
class wt extends se {
  async execAction(s, t, o, i, r) {
    if (o && o.length > 0) {
      const a = (await ibiz.entityService.getService("XQFBXQPS", t)).local.getList(t);
      o.forEach((l) => {
        const h = a.find((p) => p.srfkey === l.srfkey);
        h && (h.psjg = "20", l.psjg = "20");
      });
    }
    return {
      refresh: !1,
      closeView: !1
    };
  }
}
class bt {
  constructor() {
    I(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new wt()), this.handler;
  }
}
class yt {
  constructor() {
    I(this, "component", "GroupGrid");
  }
}
const Ct = new Ge(import.meta.url), Tt = {
  mateUrl: import.meta.url,
  install(e) {
    ge.getModelService().then((s) => {
      var o;
      ((o = s.app.userParams) == null ? void 0 : o.autoWidth) === "true" && document.getElementsByClassName("app")[0].classList.add("auto-width");
    }), Ct.loadStyle(["/style.css"]), ibiz.config.enableDataInfoBar = !1, ibiz.config.gridEditShowMode = "all", e.component("WfToolbar", _e), ibiz.register.view.register(
      "VIEW_CUSTOM_SyWebIndexView",
      new mt()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_PresetWFChartView",
      new ut()
    ), ibiz.register.gridColumn.register(
      "GRID_COLRENDER_CodeListGridColumn",
      new ht()
    ), e.component("SyFileUpload", Ke), e.component("SyGridFileUpload", Ye), e.component("SyEditGridFileUpload", st), e.component("SyGridFileUploadContainer", et), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_SyFileUpload",
      new ft()
    ), e.component("AppLayout", ot), ibiz.register.uiAction.register(
      "DEUIACTION_BatchApprovalOrdersId",
      new vt()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_BatchNoApprovalOrdersId",
      new bt()
    ), e.component("GroupGrid", dt), ibiz.register.control.register(
      "GRID_RENDER_GROUP_GRID",
      new yt()
    );
  }
};
export {
  Tt as default
};
