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