var de = Object.defineProperty;
var ue = (s, e, a) => e in s ? de(s, e, { enumerable: !0, configurable: !0, writable: !0, value: a }) : s[e] = a;
var D = (s, e, a) => (ue(s, typeof e != "symbol" ? e + "" : e, a), a);
import { EditFormModel as me, FormMDCtrlModel as pe, DefectModelError as he, AppEntityModel as H } from "@ibiz-template/model";
import { useNamespace as B, useControlController as fe, usePropsWatch as ve, getDatePickerProps as ye, getEditorEmits as G, useController as ge, getDataPickerProps as se, useViewController as we } from "@ibiz-template/vue-util";
import { defineComponent as M, getCurrentInstance as W, ref as C, watch as L, h as r, onMounted as Ee, computed as _ } from "vue";
import { createUUID as te } from "qx-util";
import { ViewMode as ae, PluginStaticResource as De, OpenAppViewCommand as q, UIActionHandler as Ce, FrontUIActionHandler as re } from "@ibiz-template/runtime";
import { EditFormController as be, FormMDCtrlController as Pe, EditViewController as Ae, DatePickerEditorController as ke, UploadEditorController as Fe, PickerEditorController as oe } from "@ibiz-template/controller";
import { ControlVO as xe, calcResPath as K } from "@ibiz-template/service";
import $ from "dayjs";
import { RuntimeError as Se, StringUtil as ne } from "@ibiz-template/core";
class Ie extends be {
  constructor() {
    super(...arguments);
    /**
     *   基础数据
     *
     * @author fangZhiHao
     * @date 2024-04-26 17:04:49
     * @type {IData}
     */
    D(this, "baseResData", []);
    /**
     *   对比数据
     *
     * @author fangZhiHao
     * @date 2024-04-26 17:04:49
     * @type {IData}
     */
    D(this, "compareResData", []);
    /**
     * 表单旧数据
     *
     * @author zk
     * @date 2023-12-20 11:12:43
     * @protected
     * @type {IData}
     * @memberof FormController
     */
    D(this, "oldData", new xe());
    /**
     * version数据
     *
     * @author fangZhiHao
     * @date 2024-04-26 16:04:37
     * @type {IData[]}
     */
    D(this, "versionData", []);
    /**
     *  对比数据
     *
     * @author fangZhiHao
     * @date 2024-04-26 16:04:37
     * @type {IData[]}
     */
    D(this, "comparisonArr", {});
    /**
     *  基础表格数据
     *
     * @author fangZhiHao
     * @date 2024-05-06 11:05:57
     * @type {IData[]}
     */
    D(this, "gridData", []);
    /**
     *  展示完全数据
     *
     * @author fangZhiHao
     * @date 2024-05-06 11:05:04
     * @type {IData[]}
     */
    D(this, "AllGridData", []);
    /**
     *  去除相同数据
     *
     * @author fangZhiHao
     * @date 2024-05-06 11:05:15
     * @type {IData[]}
     */
    D(this, "removeSameGridData", []);
    /**
     *  关系界面数据
     *
     * @author fangZhiHao
     * @date 2024-04-30 10:04:33
     * @type {IData}
     */
    D(this, "AlldruipartData", /* @__PURE__ */ new Map());
    /**
     *  关系界面数据长度
     *
     * @author fangZhiHao
     * @date 2024-05-06 11:05:56
     * @type {number}
     */
    D(this, "druipartDataSize", 0);
    /**
     *   关系界面实际数据
     *
     * @author fangZhiHao
     * @date 2024-05-06 11:05:13
     * @type {IData}
     */
    D(this, "newDruipartData", {});
  }
  /**
   * 加载数据
   *
   * @return {*}  {Promise<ControlVO>}
   * @memberof FormDataComparisonController
   */
  async loadGridData() {
    await this.startLoading();
    const a = this.model.source.M.getPSControlParam.ctrlParams, { BASEENTITY: t, COMPAREENTITY: c } = a, n = await ibiz.entityService.getService(t), l = await ibiz.entityService.getService(c), v = Object.assign({}, this.context.clone(), {
      [t.toLowerCase()]: this.params.base_version
    }), p = Object.assign({}, this.context.clone(), {
      [c.toLowerCase()]: this.params.compare_version
    }), h = await n.exec("Get", v, this.params), g = await l.exec(
      "Get",
      p,
      this.params
    );
    return this.isLoaded = !0, {
      baseData: h.data.data,
      compareData: g.data.data
    };
  }
  /**
   * 判断值是否为空
   *
   * @param {(string | IData[] | null | undefined)} value
   * @return {*}
   * @memberof FormDataComparisonController
   */
  isFalseyButNotEmpty(a) {
    return a == null || typeof a == "string" && a === "" || Array.isArray(a) && a.length === 0 || typeof a == "object" && Object.keys(a).length === 0;
  }
  /**
   * 比较两个值
   *
   * @param {IData} objA
   * @param {IData} objB
   * @return {*}
   * @memberof FormDataComparisonController
   */
  compareObjectValues(a, t) {
    return JSON.stringify(a) !== JSON.stringify(t);
  }
}
const Ne = M({
  name: "IBizFormDataComparison",
  props: {
    modelData: {
      type: me,
      required: !0
    },
    context: {
      type: Object,
      required: !0
    },
    params: {
      type: Object,
      default: () => ({})
    },
    enableAutoSave: {
      type: Boolean,
      required: !1
    }
  },
  setup(s) {
    const e = B("form-data-comparison"), {
      proxy: a
    } = W(), t = fe(a, () => {
      const o = new Ie(s.modelData, s.context, s.params);
      return ve(a, "enableAutoSave", o.setEnableAutoSave.bind(o)), o;
    }), c = C(!0), n = C(!1), l = C({}), v = C({}), p = C([]), h = [], g = C([]), i = C([]), y = C([]), f = /* @__PURE__ */ new Map(), u = C(0), m = (o) => {
      const d = [];
      if (d.push(o), o && o.children) {
        const A = [];
        o.children.forEach((k) => {
          const O = m(k);
          A.push(...O);
        }), d.push(...A);
      }
      return d;
    }, E = m(s.modelData);
    h.push(...E);
    const P = (o) => {
      const d = t.details[o.source.name], A = r("not-supported-editor", {
        attrs: {
          modelData: o.editor
        }
      });
      return r("div", {
        class: [e.e("form-grid-item"), e.is("add", g.value.includes(o.source.name)), e.is("update", y.value.includes(o.source.name)), e.is("delete", i.value.includes(o.source.name))]
      }, [r("div", {
        class: e.em("form-grid-item", "name")
      }, [o.source.caption]), r("div", {
        class: e.em("form-grid-item", "left")
      }, [d.editorProvider ? r(d.editorProvider.formEditor, {
        props: {
          value: v.value[o.source.name],
          data: d.data,
          controller: d.editor,
          disabled: d.disabled,
          readonly: !0
        }
      }) : A]), r("div", {
        class: e.em("form-grid-item", "right")
      }, [d.editorProvider ? r(d.editorProvider.formEditor, {
        props: {
          value: l.value[o.source.name],
          data: d.data,
          controller: d.editor,
          disabled: d.disabled,
          readonly: !0
        }
      }) : A])]);
    }, S = (o, d) => {
      f.set(o.source.id, d), d.evt.on("mounted", () => {
        c.value && t.startLoading(), u.value += 1, d.call.refresh();
      }), d.evt.on("refreshed", () => {
        u.value -= 1, setTimeout(() => {
          c.value && t.endLoading();
        }, 500);
      });
    }, w = (o) => {
      const d = h.find((V) => V.id === `${o.source.id}_srfcopy`), A = o.embedView.source.modelPath, k = d == null ? void 0 : d.embedView.source.modelPath, O = t.context.clone(), N = {
        base_version: s.params.base_version
      }, T = t.context.clone();
      Object.assign(T, {
        gysrlzy_info: s.params.compare_version,
        compare_version: s.params.compare_version
      });
      const j = {
        compare_version: s.params.compare_version
      }, R = l.value[o.source.userTag], U = v.value[d == null ? void 0 : d.source.userTag];
      let J = !1, Y = !1, X = !1;
      if (o.source.userTag2) {
        const V = JSON.parse(o.source.userTag2), {
          comparekey: Z,
          comparelist: ce
        } = V;
        R && U && Array.isArray(R) && Array.isArray(U) && (R.length === 0 && U.length !== 0 ? X = !0 : R.length !== 0 && U.length === 0 ? J = !0 : R.length !== 0 && U.length !== 0 && (R.length !== U.length ? Y = !0 : R.some((Q) => {
          const ee = U.find((z) => Q[Z] === z[Z]);
          return ee ? ce.some((z) => Q[z] !== ee[z] ? (Y = !0, !0) : !1) : (Y = !0, !0);
        })));
      }
      return r("div", {
        class: [e.e("druipart"), e.is("add", J), e.is("update", Y), e.is("delete", X)]
      }, [r("div", {
        class: e.em("druipart", "caption")
      }, [o.source.caption]), r("div", {
        class: e.em("druipart", "left")
      }, [k && r("ViewShell", {
        attrs: {
          context: T,
          params: j,
          modal: {
            mode: ae.EMBED
          },
          modelPath: k,
          noLoadDefault: !0,
          name: d == null ? void 0 : d.source.id
        },
        key: te(),
        on: {
          neuronInit: (V) => S(d, V)
        }
      })]), r("div", {
        class: e.em("druipart", "right")
      }, [A && r("ViewShell", {
        attrs: {
          context: O,
          params: N,
          modal: {
            mode: ae.EMBED
          },
          modelPath: A,
          noLoadDefault: !0,
          name: o.source.id
        },
        key: te(),
        on: {
          neuronInit: (V) => S(o, V)
        }
      })])]);
    }, b = (o) => {
      const d = {
        modelData: o,
        controller: t.details[o.source.name]
      }, A = t.providers[o.source.name], k = r(A.component, {
        props: {
          ...d
        },
        key: o.id
      }), O = r(A.component, {
        props: {
          ...d
        },
        key: `compare_${o.id}`
      });
      return r("div", {
        class: e.e("mdctrl")
      }, [r("div", {
        class: e.em("mdctrl", "caption")
      }, [o.source.caption]), r("div", {
        class: e.em("mdctrl", "left")
      }, [k]), r("div", {
        class: e.em("mdctrl", "right")
      }, [O])]);
    }, F = (o) => {
      c.value = !1;
      const d = p.value.findIndex((A) => A === o.source.name);
      d > -1 ? p.value.splice(d, 1) : p.value.push(o.source.name);
    }, I = (o) => {
      if (!o.source.hidden) {
        if (o.source.detailType === "FORMPAGE")
          return r("div", {
            class: e.e("form-page")
          }, [o.children.map((d) => I(d))]);
        if (o.source.detailType === "FORMITEM") {
          const d = g.value.includes(o.source.name), A = i.value.includes(o.source.name), k = y.value.includes(o.source.name);
          return n.value && !d && !A && !k ? null : P(o);
        }
        if (o.source.detailType === "GROUPPANEL") {
          const d = p.value.includes(o.source.name);
          return r("div", {
            class: e.b("group")
          }, [r("div", {
            class: [e.be("group", "header"), e.is("hide-caption", !o.source.showCaption)]
          }, [r("div", {
            class: e.bem("group", "header", "name")
          }, [d ? r("i-icon", {
            class: e.bem("group", "header", "icon"),
            attrs: {
              type: "ios-arrow-forward",
              title: "展开"
            },
            on: {
              click: () => F(o)
            }
          }) : r("i-icon", {
            class: e.bem("group", "header", "icon"),
            attrs: {
              type: "ios-arrow-down",
              title: "收缩"
            },
            on: {
              click: () => F(o)
            }
          }), r("span", {
            class: e.bem("group", "header", "name-text")
          }, [o.source.caption || o.source.title])]), r("div", ["---"]), r("div", ["---"])]), r("div", {
            class: [e.be("group", "content"), e.is("collapse", d)]
          }, [o.children.map((A) => I(A))])]);
        }
        return o.source.detailType === "DRUIPART" && !o.source.name.endsWith("_srfcopy") ? w(o) : o.source.detailType === "MDCTRL" ? b(o) : null;
      }
    }, x = (o, d) => {
      const A = [], k = [], O = [];
      return Object.keys(d).forEach((N) => {
        const T = o[N], j = d[N];
        t.isFalseyButNotEmpty(T) && !t.isFalseyButNotEmpty(j) && A.push(N), !t.isFalseyButNotEmpty(T) && !t.isFalseyButNotEmpty(j) && t.compareObjectValues(T, j) && k.push(N);
      }), Object.keys(o).forEach((N) => {
        if (!Object.prototype.hasOwnProperty.call(d, N) || t.isFalseyButNotEmpty(d[N])) {
          const T = o[N];
          t.isFalseyButNotEmpty(T) || O.push(N);
        }
      }), {
        added: A,
        modified: k,
        deleted: O
      };
    };
    return L(() => s.params, async () => {
      const o = await t.loadGridData();
      l.value = o.baseData, v.value = o.compareData;
      const {
        added: d,
        modified: A,
        deleted: k
      } = x(v.value, l.value);
      g.value = d, y.value = A, i.value = k;
    }, {
      immediate: !0
    }), {
      ns: e,
      c: t,
      switchValue: n,
      druipartNum: u,
      renderEditor: P,
      renderByDetailType: I
    };
  },
  render() {
    return this.c.complete ? r("control-layout", {
      attrs: {
        modelData: this.c.model
      }
    }, [r("div", {
      class: this.ns.b()
    }, [r("div", {
      class: this.ns.e("top")
    }, [r("div", {
      class: this.ns.e("top-hidesame-content")
    }, [r("div", {
      class: this.ns.e("top-hidesame-content-left")
    }, ["隐藏相同项 ", r("i-switch", {
      model: {
        value: this.switchValue,
        callback: (s) => {
          this.switchValue = s;
        }
      }
    })]), r("div", {
      class: this.ns.e("top-hidesame-content-right")
    }, [r("div", {
      class: this.ns.e("top-hidesame-content-right-item")
    }, ["新增", r("div", {
      class: this.ns.e("top-hidesame-content-right-item-add")
    })]), r("div", {
      class: this.ns.e("top-hidesame-content-right-item")
    }, ["修改", r("div", {
      class: this.ns.e("top-hidesame-content-right-item-change")
    })]), r("div", {
      class: this.ns.e("top-hidesame-content-right-item")
    }, ["删除", r("div", {
      class: this.ns.e("top-hidesame-content-right-item-delete")
    })])])]), r("div", {
      class: this.ns.e("top-content")
    }, [r("div", {
      class: this.ns.em("top-content", "attr")
    }, ["信息项"]), r("div", {
      class: [this.ns.em("top-content", "left")]
    }, ["更新前内容"]), r("div", {
      class: [this.ns.em("top-content", "right")]
    }, ["更新后内容"])])]), r("div", {
      class: this.ns.e("content")
    }, [this.modelData.children.map((s) => this.renderByDetailType(s))])])]) : null;
  }
});
const Oe = M({
  name: "CustomDataImport",
  props: {
    templateUrl: {
      type: String,
      required: !0
    },
    importUrl: {
      type: String,
      required: !0
    },
    dismiss: {
      type: Function
    }
  },
  setup(s, {
    emit: e
  }) {
    const a = B("data-import"), t = C(), c = C({
      state: "ready",
      message: "",
      rowError: []
    }), n = C(""), l = async (i) => {
      const y = new FormData(), f = $(n.value).format("YYYY-MM");
      y.append("file", i), y.append("ny", f);
      try {
        const u = await ibiz.net.request(s.importUrl, {
          method: "post",
          data: y,
          headers: {
            "Content-Type": "multipart/form-data"
          }
        });
        c.value.state = "success", c.value.message = "导入成功";
        const {
          errorinfo: m,
          success: E,
          total: P
        } = u.data, S = P ? Number(P) : 0, w = E ? Number(E) : 0, b = P - E;
        c.value.message = `共计导入数据 ${S} 条，错误[${b}]，成功[${w}]`, m && Object.keys(m).length > 0 && (c.value.rowError = [], Object.keys(m).forEach((F) => {
          c.value.rowError.push({
            index: Number(F) + 1,
            info: m[F].errorInfo
          });
        }));
      } catch (u) {
        c.value.state = "fail", c.value.message = `导入失败！${u.message}`;
      }
    }, v = (i) => {
      const y = i.target;
      if (!y.files)
        return;
      const f = y.files[0];
      y.value = null, l(f);
    }, p = async () => {
      var y;
      const i = await ibiz.net.request(s.templateUrl, {
        responseType: "blob"
      });
      if (i.status === 200) {
        let f = ((y = i.headers["content-disposition"].split(";").find((E) => E.indexOf("filename=") !== -1)) == null ? void 0 : y.slice(9)) || "";
        f = decodeURIComponent(f);
        const u = new Blob([i.data], {
          type: "application/vnd.ms-excel"
        }), m = document.createElement("a");
        m.download = f, m.style.display = "none", m.href = URL.createObjectURL(u), document.body.appendChild(m), m.click(), URL.revokeObjectURL(m.href), document.body.removeChild(m);
      }
    }, h = () => {
      t.value.click();
    }, g = () => {
      var i;
      e("close", {
        ok: !1,
        data: {}
      }), (i = s.dismiss) == null || i.call(s, {
        ok: !1,
        data: {}
      });
    };
    return Ee(() => {
      n.value = $().format("YYYY年MM月");
    }), {
      ns: a,
      curDate: n,
      onLinkClick: p,
      selectFile: h,
      onCancelButtonClick: g,
      onFileChange: v,
      inputUpLoad: t,
      message: c
    };
  },
  render() {
    return r("div", {
      class: [this.ns.b(), this.ns.is("custom", !0)]
    }, [r("input", {
      ref: "inputUpLoad",
      attrs: {
        type: "file",
        accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
      },
      style: "display: none",
      on: {
        change: this.onFileChange
      }
    }), r("div", {
      class: this.ns.e("caption")
    }, ["导入数据"]), r("div", {
      class: this.ns.e("date")
    }, [r("span", ["导入数据所属月份"]), r("i-datePicker", {
      attrs: {
        format: "yyyy年MM月",
        type: "month",
        clearable: !1
      },
      model: {
        value: this.curDate,
        callback: (s) => {
          this.curDate = s;
        }
      }
    })]), this.message.state === "ready" ? r("div", {
      class: this.ns.b("upload"),
      on: {
        click: this.selectFile
      }
    }, [r("img", {
      class: this.ns.be("upload", "img"),
      attrs: {
        src: "./assets/img/icon-import.svg"
      }
    }), r("span", {
      class: this.ns.be("upload", "text")
    }, ["单击此区域进行上传"])]) : r("div", {
      class: this.ns.b("message")
    }, [r("div", {
      class: this.ns.be("message", "title")
    }, ["导入结果"]), r("div", {
      class: this.ns.be("message", "content")
    }, [this.message.message]), this.message.rowError.length > 0 && [r("div", {
      class: this.ns.be("message", "title")
    }, ["错误信息"]), r("div", {
      class: this.ns.be("message", "content")
    }, [this.message.rowError.map((s) => r("div", [`第 ${s.index} 行：${s.info}`]))])]]), r("div", {
      class: this.ns.e("template-container")
    }, [r("div", {
      class: this.ns.e("template-description")
    }, ["下载导入模版，并按要求填写："]), r("div", {
      class: this.ns.e("template-link"),
      on: {
        click: this.onLinkClick
      }
    }, [r("i-icon", {
      attrs: {
        type: "ios-link"
      }
    }), "数据导入模板文件"])]), r("div", {
      class: this.ns.e("button-bar")
    }, [this.message.state !== "ready" && r("i-button", {
      on: {
        click: this.selectFile
      }
    }, ["重新上传"])])]);
  }
});
const Te = M({
  name: "YearMonthPicker",
  props: ye(),
  emits: G(),
  setup(s, {
    emit: e
  }) {
    const a = B("date-picker"), t = s.controller, c = t.model, n = C("date"), l = C("yyyy-MM-dd"), v = C(!1);
    switch (c.editorType) {
      case "DATEPICKEREX":
      case "DATEPICKEREX_NOTIME":
        n.value = "date";
        break;
      case "DATEPICKEREX_NODAY":
      case "DATEPICKEREX_NODAY_NOSECOND":
        v.value = !0, n.value = "time";
        break;
      case "DATEPICKEREX_HOUR":
      case "DATEPICKEREX_MINUTE":
      case "DATEPICKEREX_SECOND":
      case "DATEPICKEREX_NOSECOND":
      case "DATEPICKER":
      default:
        n.value = "datetime";
    }
    const p = t.valueFormat;
    if (p) {
      p === "YYYY-MM" ? n.value = "month" : p === "YYYY" && (n.value = "year");
      const f = p.replace("YYYY", "yyyy").replace("DD", "dd");
      l.value = f;
    }
    c.editorParams.formatText && (l.value = c.editorParams.formatText.replace("YYYY", "yyyy").replace("DD", "dd"));
    const h = C();
    L(() => s.value, (f, u) => {
      f && f !== u && (h.value = $(f).format(p));
    }, {
      immediate: !0
    });
    const g = (f, u) => {
      if (f) {
        const m = $(f.replace(/[年月]/g, "-")).format(p);
        e("change", m);
      } else
        e("change", f);
    }, i = (f) => {
      e("operate", f);
    }, y = C();
    return s.autoFocus && L(y, (f) => {
      f && f.$el.getElementsByTagName("input")[0].click();
    }), {
      ns: a,
      c: t,
      editorModel: c,
      type: n,
      format: l,
      formatValue: h,
      handleChange: g,
      onOpenChange: i,
      inputRef: y,
      isTimePicker: v
    };
  },
  render(s) {
    return s("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [[this.readonly && this.formatValue, !this.readonly && this.isTimePicker && s("ITimePicker", {
      ref: "inputRef",
      props: {
        ...this.c.customProps,
        value: this.value,
        type: this.type,
        format: this.format,
        placeholder: this.c.placeHolder,
        disabled: this.disabled,
        transfer: !0
      },
      on: {
        "on-change": this.handleChange,
        "on-open-change": this.onOpenChange
      }
    }), !this.readonly && !this.isTimePicker && s("ICalendarPicker", {
      ref: "inputRef",
      props: {
        ...this.c.customProps,
        value: this.value,
        type: this.type,
        format: this.format,
        placeholder: this.c.placeHolder,
        disabled: this.disabled,
        transfer: !0
      },
      on: {
        "on-change": this.handleChange,
        "on-open-change": this.onOpenChange
      }
    })]]);
  }
});
const ie = new De(import.meta.url), Me = M({
  name: "DownLoadSafeFile",
  props: {},
  setup() {
    const s = B("download-safe-file"), e = ie.dir("/assets/doc/safe-file.doc");
    return {
      ns: s,
      url: e
    };
  },
  render() {
    return r("div", {
      class: this.ns.b()
    }, [r("a", {
      attrs: {
        download: "网络信息安全承诺书.doc",
        href: this.url
      }
    }, ["网络信息安全承诺书.doc"])]);
  }
});
class le extends Pe {
  constructor() {
    super(...arguments);
    /**
     * 激活的分页下标
     *
     * @type {number}
     * @memberof FormMDCtrlFormStyle2Controller
     */
    D(this, "active", 0);
  }
  connect(a, t) {
    this.formNeurons.get(a) || (this.formNeurons.set(a, t), t.evt.on("mounted", () => {
      t.call.load();
    }), t.evt.on("destroyed", () => {
      this.formNeurons.delete(a);
    }), t.evt.on("valueChange", (c) => {
      if (c) {
        const n = this.contentCtrlData.find((l) => l.srfkey === c.srfkey);
        n && Object.assign(n, c), this.force();
      }
    }));
  }
  /**
   * 校验
   *
   * @return {*}  {Promise<boolean>}
   * @memberof FormMDCtrlFormStyle2Controller
   */
  async validate() {
    const a = [];
    this.formNeurons.forEach((n, l) => {
      const v = n.call.getFormController();
      a.push({ key: l, controller: v });
    });
    let t = "";
    const c = await Promise.all(
      a.map(async (n) => {
        const l = await n.controller.validate();
        return !t && !l && (t = n.key), l;
      })
    );
    if (t) {
      const n = this.contentCtrlData.findIndex((l) => l.srfkey === t);
      n > -1 && (this.active = n);
    }
    return c.findIndex((n) => !n) === -1;
  }
  /**
   * 静默校验
   *
   * @return {*}  {Promise<boolean>}
   * @memberof FormMDCtrlFormStyle2Controller
   */
  async silentValidate() {
    const a = [];
    this.formNeurons.forEach((n, l) => {
      const v = n.call.getFormController();
      a.push({ key: l, controller: v });
    });
    let t = "";
    const c = await Promise.all(
      a.map(async (n) => {
        const l = await n.controller.silentValidate();
        return !t && !l && (t = n.key), l;
      })
    );
    if (t) {
      const n = this.contentCtrlData.findIndex((l) => l.srfkey === t);
      n > -1 && (this.active = n);
    }
    return c.findIndex((n) => !n) === -1;
  }
}
const Re = M({
  name: "FormMDCtrlFormStyle2",
  props: {
    controller: {
      type: le,
      required: !0
    },
    modelData: {
      type: pe,
      required: !0
    }
  },
  setup(s) {
    const e = B("form-mdctrl-form-style2"), a = s.controller, {
      proxy: t
    } = W();
    ge(t, s.controller);
    const c = async (h, g, i) => {
      i.stopPropagation(), i.preventDefault();
      const y = a.contentCtrlData.length;
      await a.handleRemove(h, g), y !== a.contentCtrlData.length && g <= a.active && a.active !== 0 && (a.active -= 1);
    }, n = (h) => {
      a.active = h, a.force();
    }, l = async () => {
      const h = JSON.parse(JSON.stringify(a.contentCtrlData)).length;
      await a.handleAdd(), h < a.contentCtrlData.length && (a.active = a.contentCtrlData.length - 1);
    }, v = () => {
      const h = s.modelData.source.userTag;
      let g = {};
      h && (g = JSON.parse(h));
      const {
        tabtitle: i,
        addtitle: y
      } = g;
      return r("div", {
        class: e.e("header")
      }, [a.contentCtrlData.map((f, u) => {
        let m = `新建${u + 1}`;
        return f.srfmajortext ? m = f.srfmajortext : i && f[i] ? m = f[i] : y && (m = `${y}${u + 1}`), r("div", {
          class: [e.e("header-item"), e.is("actived", u === a.active)],
          on: {
            click: () => n(u)
          }
        }, [r("div", {
          class: e.em("header-item", "title")
        }, [m]), a.enableDelete && r("div", {
          class: e.em("header-item", "delete"),
          attrs: {
            title: "移除"
          },
          on: {
            click: (E) => c(f, u, E)
          }
        }, [r("i", {
          class: "fa fa-close"
        })])]);
      }), a.enableCreate && r("div", {
        class: [e.e("header-item"), e.e("add")],
        attrs: {
          title: "添加"
        },
        on: {
          click: () => l()
        }
      }, [r("span", ["添加"]), r("i", {
        class: "fa fa-plus"
      })])]);
    };
    return L(() => a.form.isLoaded, (h, g) => {
      h !== g && h === !0 && a.loadData();
    }), {
      ns: e,
      rendertanHeader: v,
      renderTabs: () => a.contentCtrlData.map((h, g) => {
        var f;
        let i = null;
        const {
          form: y
        } = a.model;
        if (y && a.providers[y.name] && a.model.appEntity) {
          const u = Object.assign(a.form.context.clone(), {
            [(f = a.model.appEntity.codeName) == null ? void 0 : f.toLowerCase()]: h[a.model.appEntity.keyName]
          });
          i = r(a.providers[y.name].component, {
            props: {
              modelData: y,
              context: u,
              params: a.form.params,
              enableAutoSave: !0,
              silentVerify: !0
            },
            on: {
              neuronInit: a.onNeuronInit(h.srfkey)
            }
          });
        }
        return r("div", {
          class: [e.e("content"), e.is("actived", g === a.active)],
          key: h.srfkey
        }, [i]);
      })
    };
  },
  render() {
    return r("div", {
      class: this.ns.b()
    }, [this.rendertanHeader(), this.renderTabs()]);
  }
}), Ue = M({
  name: "AutoSelectAll",
  props: se(),
  emits: G(),
  setup(s, {
    emit: e
  }) {
    const a = B("mpicker"), t = s.controller, c = C([]), n = C([]), l = C([]), v = C(!1), p = C(!1), h = C(null), g = C([]), i = _(() => {
      const w = t.editorParams.followitem;
      return w ? s.data[w] : "";
    });
    L(() => s.value, (w) => {
      c.value = [], l.value = [], w && (l.value = JSON.parse(w), l.value.length > 0 && l.value.forEach((b) => {
        n.value.findIndex((I) => Object.is(I.srfkey, b.srfkey)) < 0 && (n.value.push(b), g.value.push(b.srfmajortext)), c.value.push(b.srfkey);
      }));
    }, {
      immediate: !0,
      deep: !0
    });
    const y = async (w) => {
      const b = [];
      if (w && Array.isArray(w))
        for (let I = 0; I < w.length; I++) {
          const x = w[I], o = {
            srfkey: x[t.keyName] || x.srfkey,
            srfmajortext: x[t.textName] || x.srfmajortext
          }, d = await t.calcFillDataItems(x);
          d.length > 0 && d.forEach((k) => {
            Object.assign(o, {
              [k.name]: k.value
            });
          }), b.push(o), n.value.findIndex((k) => Object.is(k[t.keyName], x[t.keyName])) < 0 && n.value.push(o);
        }
      const F = b.length > 0 ? JSON.stringify(b) : "";
      e("change", F);
    }, f = async () => {
      let w;
      l.value.length && (w = JSON.stringify(l.value));
      const b = await t.openPickUpView(s.data, w);
      b && y(b);
    }, u = (w) => {
      const b = [];
      if (w.length > 0) {
        w.forEach((I) => {
          let x = n.value.findIndex((d) => Object.is(d.srfkey, I)), o = null;
          x >= 0 ? o = n.value[x] : (x = l.value.findIndex((d) => Object.is(d.srfkey, I)), x >= 0 && (o = l.value[x])), o && b.push(o);
        });
        const F = b.length > 0 ? JSON.stringify(b) : "";
        e("change", F);
      } else
        e("change", "");
    }, m = async (w) => {
      if (t.model.appDataEntity) {
        p.value = !0;
        try {
          const b = await t.getServiceData(w, s.data);
          p.value = !1, n.value = [], b.data.length > 0 && (n.value = b.data.map((F) => ({
            srfkey: F[t.keyName],
            srfmajortext: F[t.textName]
          })));
        } catch (b) {
          p.value = !1;
        }
      }
    }, E = (w) => {
      v.value = w, e("operate", w), v.value && m("");
    }, P = _(() => l.value.map((w) => w.srfmajortext).join("、")), S = (w) => {
      n.value = w;
    };
    return L(() => i.value, async (w) => {
      if (w) {
        await m("");
        const b = n.value.map((F) => F.srfkey);
        u(b);
      } else
        n.value = [], e("change", "");
    }, {
      immediate: !0
    }), {
      ns: a,
      c: t,
      selectRef: h,
      curValue: c,
      loading: p,
      items: n,
      defaultLabel: g,
      valueText: P,
      onSearch: m,
      onOpenChange: E,
      onSelect: u,
      openPickUpView: f,
      setDefaultOptions: S
    };
  },
  render(s) {
    return s("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [this.readonly && this.valueText, !this.readonly && s("iSelect", {
      ref: "selectRef",
      props: {
        ...this.c.customProps,
        value: this.curValue,
        filterable: !0,
        transfer: !0,
        multiple: !0,
        defaultLabel: this.defaultLabel,
        loading: this.loading,
        placeholder: this.c.placeHolder,
        disabled: this.disabled,
        remoteMethod: this.onSearch
      },
      on: {
        "on-change": this.onSelect,
        "on-open-change": this.onOpenChange
      }
    }, [this.items.map((e) => s("i-option", {
      key: e.srfkey,
      attrs: {
        value: e.srfkey,
        label: e.srfmajortext
      }
    }, [e.srfmajortext]))]), !this.readonly && s("div", {
      class: this.ns.e("buns-position")
    }, [s("div", {
      class: this.ns.e("btns")
    }, [this.c.pickupView ? s("i-button", {
      attrs: {
        icon: "ios-search",
        type: "text"
      },
      on: {
        click: this.openPickUpView
      }
    }) : null])])]);
  }
});
const Ve = M({
  name: "MPickerCheckbox",
  props: se(),
  emits: G(),
  setup(s, {
    emit: e
  }) {
    const a = B("checkbox"), t = s.controller, c = C([]), n = C([]), l = ",", v = _({
      get() {
        var u;
        return ((u = s.value) == null ? void 0 : u.split(",")) || [];
      },
      set(u) {
        let m = null;
        const E = [];
        c.value.length > 0 && (c.value.forEach((P) => {
          u.findIndex((w) => Object.is(P.value, w)) !== -1 && E.push(P.value);
        }), m = E.join(l)), e("change", m);
      }
    }), p = async (u) => {
      const {
        context: m,
        params: E
      } = t.handlePublicParams(u, t.context, t.params);
      if (t.editorParams.codeTag) {
        let P = [];
        const S = t.editorParams.codeTag;
        return P = await ibiz.codeListService.get(S, m, E), P;
      }
      throw new he(t.model.source, "请配置代码表");
    }, h = (u) => {
      v.value = u;
    }, g = _(() => {
      const u = Array.isArray(v.value) ? v.value : [v.value];
      return c.value.filter((m) => u.includes(m.srfkey)).map((m) => m.srfmajortext).join("、");
    }), i = async (u) => {
      if (t.model.appDataEntity)
        try {
          const m = await t.getServiceData(u, s.data);
          n.value = [], m.data.length > 0 && (n.value = m.data.map((E) => ({
            srfkey: E[t.keyName],
            srfmajortext: E[t.textName]
          })));
        } catch (m) {
          console.error(m);
        }
    }, y = _(() => {
      const u = t.editorParams.followitem;
      return u ? s.data[u] : "";
    }), f = () => {
      const u = [];
      c.value.forEach((m) => {
        n.value.findIndex((P) => P.srfkey === m.value) > -1 && u.push(m.value);
      }), h(u);
    };
    return L(() => y, async (u) => {
      await p(u).then((m) => {
        c.value = m;
      }), await i(""), f();
    }, {
      immediate: !0,
      deep: !0
    }), {
      ns: a,
      c: t,
      valueText: g,
      selectArray: v,
      items: c,
      onSearch: i,
      onSelectArrayChange: h
    };
  },
  render(s) {
    return s("div", {
      class: [this.ns.b(), this.disabled ? this.ns.m("disabled") : "", this.readonly ? this.ns.m("readonly") : ""]
    }, [this.readonly && this.valueText, !this.readonly && s("ICheckboxGroup", {
      props: {
        ...this.c.customProps,
        value: this.selectArray
      },
      on: {
        "on-change": this.onSelectArrayChange
      }
    }, [this.items.map((e, a) => s("i-checkbox", {
      key: a,
      attrs: {
        label: e.value,
        disabled: this.disabled
      }
    }, [s("span", {
      class: this.ns.e("text")
    }, [e.text])]))])]);
  }
});
class Le extends Ae {
  constructor() {
    super(...arguments);
    /**
     * 自定义行为
     *
     * @type {string}
     * @memberof WfEditViewController
     */
    D(this, "userAction");
  }
  async onInit() {
    await super.onInit(), this.getUserAction();
  }
  /**
   * 工作流启动
   *
   * @author lxm
   * @date 2022-09-29 20:09:27
   * @returns {*}  {Promise<void>}
   */
  async wfStart() {
    var h;
    await this.save(), await this.execUserAction();
    const a = await this.entityService.wf.getWFVersion();
    if (a.data.length === 0)
      throw new Se("当前工作流版本不存在");
    const t = a.data[0], c = `WFSTART@${t.wfversion}`, n = Object.assign(this.context.clone(), {
      activeForm: t["process-form"]
    }), l = {
      processDefinitionKey: t.definitionkey
    }, v = (h = this.model.source.findPSAppViewRef(c)) == null ? void 0 : h.getRefPSAppView();
    if (!v) {
      await this.nerve.form.call.wfStart(l), await this.closeView();
      return;
    }
    (await ibiz.commands.execute(
      q.TAG,
      v,
      n,
      l
    )).ok && await this.closeView();
  }
  /**
   * 获取自定义行为
   *
   * @memberof EditViewController
   */
  getUserAction() {
    const { form: a } = this.model, t = a.source.getPSControlHandler();
    if (t) {
      const c = t.findPSControlHandlerAction("user");
      c && c.getPSAppDEMethod() && (this.userAction = c.getPSAppDEMethod().codeName);
    }
  }
  /**
   * 执行自定义行为
   *
   * @memberof EditViewController
   */
  async execUserAction() {
    if (this.userAction) {
      const a = this.getData();
      await this.entityService.exec(this.userAction, this.context, a[0]);
    }
  }
}
function Be(s, e) {
  return we(
    s,
    (a, t) => new Le(e, a, t)
  );
}
const je = M({
  props: {
    context: Object,
    params: {
      type: Object
    },
    modelPath: {
      type: String,
      required: !0
    },
    modal: {
      type: Object
    },
    noLoadDefault: {
      type: Boolean,
      required: !1
    }
  },
  setup(s) {
    const {
      proxy: e
    } = W();
    return {
      c: Be(e, s.modelPath)
    };
  },
  render(s) {
    let e = null;
    if (this.c.complete) {
      const {
        form: a
      } = this.c.model;
      this.c.providers[a.name] && (e = s(this.c.providers[a.name].component, {
        props: {
          modelData: a,
          context: this.c.context,
          params: this.c.params
        },
        on: {
          neuronInit: this.c.nerve.onNeuronInit(a.name)
        }
      }));
    }
    return s("view-base", {
      attrs: {
        controller: this.c
      }
    }, [e]);
  }
});
class _e {
  constructor() {
    D(this, "component", "IBizFormDataComparison");
  }
}
class Ye extends Ce {
  async execAction(e, a, t, c) {
    const n = {}, l = e.getPSAppDataEntity();
    if (l) {
      l.isFill === !1 && await l.fill(!0);
      const v = new H(l);
      await v.init();
      const { resultContext: p } = await this.handleParams(
        e,
        a,
        t,
        c
      ), h = ibiz.resourcePathUtil.calcPaths(
        p,
        v.codeName
      ), g = K(p, h);
      let i = `${g}/${v.deNamePlural}/importtemplate`, y = `${g}/${v.deNamePlural}/importdata2`;
      const f = e.getPSAppDEDataImport();
      f && (i += `?srfimporttag=${f.codeName}`, y += `?srfimporttag=${f.codeName}`);
      const u = ibiz.overlay.createModal(
        "CustomDataImport",
        {
          templateUrl: i,
          importUrl: y,
          dismiss: (m) => {
            u.dismiss(m);
          }
        },
        {
          width: "auto",
          placement: "center"
        }
      );
      return u.present(), await u.onWillDismiss(), {
        refresh: !0
      };
    }
    return n;
  }
}
class ze {
  constructor() {
    D(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new Ye()), this.handler;
  }
}
class $e {
  constructor() {
    D(this, "gridEditor", "YearMonthPicker");
    D(this, "formEditor", "YearMonthPicker");
  }
  async createController(e, a) {
    const t = new ke(e, a);
    return await t.init(), t;
  }
}
class He {
  constructor() {
    D(this, "formEditor", "DownLoadSafeFile");
    D(this, "gridEditor", "DownLoadSafeFile");
  }
  async createController(e, a) {
    const t = new Fe(e, a);
    return await t.init(), t;
  }
}
class Ge extends re {
  async execAction(e, a, t, c, n) {
    const l = {}, { frontProcessType: v } = e;
    if (v === "OPENHTMLPAGE") {
      const p = ne.fill(e.htmlPageUrl, a, t == null ? void 0 : t[0]);
      window.open(p, "_blank");
    }
    if (v === "DATAIMP") {
      const p = e.getPSAppDataEntity();
      if (p) {
        p.isFill === !1 && await p.fill(!0);
        const h = new H(p);
        await h.init();
        const { resultContext: g } = await this.handleParams(
          e,
          a,
          t,
          c
        ), i = ibiz.resourcePathUtil.calcPaths(
          g,
          h.codeName
        ), y = K(g, i);
        let f = `${y}/${h.deNamePlural}/importtemplate`, u = `${y}/${h.deNamePlural}/importdata2`;
        const m = e.getPSAppDEDataImport();
        m && (f += `?srfimporttag=${m.codeName}`, u += `?srfimporttag=${m.codeName}`);
        const E = ibiz.overlay.createModal(
          "DataImport",
          {
            templateUrl: f,
            importUrl: u,
            dismiss: (P) => {
              E.dismiss(P);
            }
          },
          {
            width: "auto",
            placement: "center"
          }
        );
        return E.present(), await E.onWillDismiss(), {
          refresh: !0
        };
      }
    }
    if (["TOP", "WIZARD"].includes(v)) {
      const p = e.getFrontPSAppView();
      if (!p)
        throw new Error("未配置打开视图");
      await p.fill(!0);
      const { resultContext: h, resultParams: g } = await this.handleParams(
        e,
        a,
        t,
        c
      ), i = await ibiz.commands.execute(
        q.TAG,
        p,
        h,
        g,
        n
      );
      (i == null ? void 0 : i.ok) === !1 && (l.closeView = !1, l.refresh = !1, l.cancel = !0), i != null && i.ok && i.data && (l.data = i.data);
    } else if (n) {
      const { neuron: p } = n, g = p.call.getFormController().call.getFormController(), { druipart1: i, druipart2: y, druipart3: f } = g.details;
      [
        {
          message: "服务履历为空",
          neuron: i
        },
        {
          message: "教育经验为空",
          neuron: y
        },
        {
          message: "项目经验为空",
          neuron: f
        }
      ].some((E) => {
        const P = E.neuron.neuron.call.getGridController();
        if (P) {
          const S = P.call.getGridController();
          if (S && S.items && S.items.length > 0)
            return !1;
        }
        return ibiz.message.error(`${E.message}`, 1.5, !0), !0;
      }) || await p.call.wfStart();
    }
    return l;
  }
}
class We {
  constructor() {
    D(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new Ge()), this.handler;
  }
}
class qe {
  constructor() {
    D(this, "component", "FormMDCtrlFormStyle2");
  }
  async createController(e, a, t) {
    const c = new le(e, a, t);
    return await c.init(), c;
  }
}
class Ke {
  constructor() {
    D(this, "formEditor", "AutoSelectAll");
    D(this, "gridEditor", "AutoSelectAll");
  }
  async createController(e, a) {
    const t = new oe(e, a);
    return await t.init(), t;
  }
}
class Je {
  constructor() {
    D(this, "formEditor", "MPickerCheckbox");
    D(this, "gridEditor", "IBizGridPicker");
  }
  async createController(e, a) {
    const t = new oe(e, a);
    return await t.init(), t;
  }
}
class Xe extends re {
  async execAction(e, a, t, c, n) {
    const l = {}, { frontProcessType: v } = e;
    if (v === "OPENHTMLPAGE") {
      const p = ne.fill(e.htmlPageUrl, a, t == null ? void 0 : t[0]);
      window.open(p, "_blank");
    }
    if (v === "DATAIMP") {
      const p = e.getPSAppDataEntity();
      if (p) {
        p.isFill === !1 && await p.fill(!0);
        const h = new H(p);
        await h.init();
        const { resultContext: g } = await this.handleParams(
          e,
          a,
          t,
          c
        ), i = ibiz.resourcePathUtil.calcPaths(
          g,
          h.codeName
        ), y = K(g, i);
        let f = `${y}/${h.deNamePlural}/importtemplate`, u = `${y}/${h.deNamePlural}/importdata2`;
        const m = e.getPSAppDEDataImport();
        m && (f += `?srfimporttag=${m.codeName}`, u += `?srfimporttag=${m.codeName}`);
        const E = ibiz.overlay.createModal(
          "DataImport",
          {
            templateUrl: f,
            importUrl: u,
            dismiss: (P) => {
              E.dismiss(P);
            }
          },
          {
            width: "auto",
            placement: "center"
          }
        );
        return E.present(), await E.onWillDismiss(), {
          refresh: !0
        };
      }
    }
    if (["TOP", "WIZARD"].includes(v)) {
      const p = e.getFrontPSAppView();
      if (!p)
        throw new Error("未配置打开视图");
      await p.fill(!0);
      const { resultContext: h, resultParams: g } = await this.handleParams(
        e,
        a,
        t,
        c
      ), i = await ibiz.commands.execute(
        q.TAG,
        p,
        h,
        g,
        n
      );
      (i == null ? void 0 : i.ok) === !1 && (l.closeView = !1, l.refresh = !1, l.cancel = !0), i != null && i.ok && i.data && (l.data = i.data);
    } else if (t && t.length > 0 && n) {
      const { neuron: p } = n, i = await p.call.getFormController().call.getFormController().autoSave();
      i && i.rcryqd && Array.isArray(i.rcryqd) && i.rcryqd.length > 0 ? await p.call.wfStart() : ibiz.message.error("入场信息为空");
    }
    return l;
  }
}
class Ze {
  constructor() {
    D(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new Xe()), this.handler;
  }
}
class Qe {
  constructor() {
    D(this, "component", "WfEditView");
  }
}
const dt = {
  mateUrl: import.meta.url,
  install(s) {
    ie.loadStyle(["/style.css"]), s.component("IBizFormDataComparison", Ne), s.component("CustomDataImport", Oe), s.component("YearMonthPicker", Te), s.component("DownLoadSafeFile", Me), s.component("FormMDCtrlFormStyle2", Re), s.component("AutoSelectAll", Ue), s.component("MPickerCheckbox", Ve), s.component("WfEditView", je), ibiz.register.control.register(
      "EDITFORM_RENDER_FORM_DATA_COMPARISON",
      new _e()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_CUSTOM_IMPORT",
      new ze()
    ), ibiz.register.editor.register(
      "DATEPICKEREX_NOTIME_YEAR_MONTH_PICKER",
      new $e()
    ), ibiz.register.editor.register(
      "FILEUPLOADER_ONE_DOWNLOAD_FILE",
      new He()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_JUDEG_ENABLE_UPDATE",
      new We()
    ), ibiz.register.formDetail.register(
      "FORM_USERCONTROL_MUL_FORM_CARD",
      new qe()
    ), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_AUTO_SELECT_ALL",
      new Ke()
    ), ibiz.register.editor.register(
      "EDITOR_CUSTOMSTYLE_MULTIPLE_CHECKBOX",
      new Je()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_check_rcxx",
      new Ze()
    ), ibiz.register.view.register(
      "VIEW_CUSTOM_CUSTOM_WF",
      new Qe()
    );
  }
};
export {
  dt as default
};
