var $ = Object.defineProperty;
var V = (e, t, n) => t in e ? $(e, t, { enumerable: !0, configurable: !0, writable: !0, value: n }) : e[t] = n;
var I = (e, t, n) => (V(e, typeof t != "symbol" ? t + "" : t, n), n);
import { GridModel as Y, ModelUtil as Z, IndexViewModel as J } from "@ibiz-template/model";
import { PluginStaticResource as T } from "@ibiz-template/runtime";
import { defineComponent as N, h as i, getCurrentInstance as U, computed as w, ref as g, watch as L, onUnmounted as _, onMounted as K } from "vue";
import { useNamespace as C, useGridController as Q } from "@ibiz-template/vue-util";
const X = new T(import.meta.url), ee = N({
  name: "WFToolbar",
  props: {
    wfLinks: {
      type: Array,
      required: !0
    }
  },
  setup(e, {
    emit: t
  }) {
    const n = C("wf-toolbar"), o = async (s, u) => {
      t("wf-link-click", s, u);
    };
    return {
      ns: n,
      handleClick: async (s, u) => {
        setTimeout(() => {
          o(s, u);
        }, 30);
      }
    };
  },
  render() {
    const e = this.wfLinks || [];
    return i("div", {
      class: `${this.ns.b()}`
    }, [e.length > 0 && e.map((t) => {
      const n = t.sequenceFlowName.startsWith("驳回") || t.sequenceFlowName.startsWith("取消"), o = t.sequenceFlowName.startsWith("保存") || t.sequenceFlowName.startsWith("关闭") || t.sequenceFlowName.startsWith("保存并关闭");
      return i("div", {
        key: t.sequenceFlowId,
        class: [this.ns.e("item"), o ? this.ns.em("item", "plain") : "", n ? this.ns.em("item", "reject") : ""]
      }, [i("i-button", {
        attrs: {
          title: t.sequenceFlowName
        },
        on: {
          click: (s) => this.handleClick(t, s)
        }
      }, [t.sequenceFlowName || ""])]);
    })]);
  }
});
function E(e, t) {
  var n, o;
  const s = [];
  e.source.columnType === "GROUPGRIDCOLUMN" && e.children.forEach((l) => {
    s.push(E(l, t));
  });
  const u = {
    title: e.title,
    width: e.source.widthUnit === "STAR" ? void 0 : e.width,
    minWidth: e.width,
    align: ((n = e.source.align) == null ? void 0 : n.toLowerCase()) || "center",
    slot: e.codeName,
    key: e.codeName,
    fieldName: e.deFieldName,
    ellipsis: !0,
    tooltip: !1,
    // todo 表格提示用title
    resizable: !0,
    sortable: !t.noSort && e.source.enableSort ? "custom" : !1,
    columnType: e.source.columnType,
    userParams: e.source.userParams,
    className: (o = e.source.getCellPSSysCss()) == null ? void 0 : o.cssName
  };
  return s.length > 0 && Object.assign(u, { children: s }), u;
}
function te(e) {
  const t = e.model, n = [], o = t.columns.map((s) => E(s, e));
  return t.children.forEach((s) => {
    const u = o.find((l) => l.key === s.codeName);
    u && n.push(u);
  }), e.singleSelect || n.splice(0, 0, { type: "selection", width: 60 }), n;
}
function se(e) {
  const t = g([]);
  return e.nerve.self.evt.on("created", () => {
    t.value = te(e);
  }), [w(() => {
    const n = [...t.value];
    if (!n.find((s) => !s.width)) {
      let s = n.length - 1;
      n[s].key === "rowEdit" && (s -= 1), n[s] = {
        ...n[s],
        width: void 0
      };
    }
    const o = n.find((s) => s.columnType === "UAGRIDCOLUMN");
    if (o) {
      const s = o.userParams;
      s && s.fixed === "true" && (o.fixed = "right");
    }
    return n;
  }), t];
}
function ne(e) {
  const t = (l) => e.items.find((h) => h.srfkey === l.srfkey);
  function n(l) {
    const h = t(l);
    if (e.singleSelect) {
      const d = e.selectedData.find(
        (m) => m.srfkey === l.srfkey
      );
      e.onSelectionChange(d ? [] : [h]);
    }
    e.onRowClick(h);
  }
  function o(l) {
    e.onDbRowClick(t(l));
  }
  function s(l) {
    if (!e.singleSelect) {
      const h = [];
      l.forEach((d) => {
        const m = t(d);
        m && h.push(m);
      }), e.onSelectionChange(h);
    }
  }
  function u(l) {
    const { column: h, order: d } = l, m = d === "asc" || d === "desc" ? d : void 0;
    e.setSort(h.fieldName, m), e.load();
  }
  return { onRowClick: n, onDbRowClick: o, onSelectionChange: s, onSortChange: u };
}
function oe(e) {
  function t(s) {
    !s || s === e.curPage || (e.curPage = s, e.load());
  }
  function n(s) {
    !s || s === e.size || (e.size = s, e.curPage === 1 && e.load());
  }
  function o() {
    e.curPage = 1, e.load();
  }
  return { onPageChange: t, onPageSizeChange: n, onPageReset: o };
}
N({
  props: {
    modelData: Y,
    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: t
    } = U(), n = C("grid"), o = Q(t, e.modelData, e.context, e.params), [s] = se(o), {
      onRowClick: u,
      onDbRowClick: l,
      onSelectionChange: h,
      onSortChange: d
    } = ne(o), {
      onPageChange: m,
      onPageReset: O,
      onPageSizeChange: G
    } = oe(o), A = w(() => {
      var a, r;
      const c = (r = (a = e.modelData) == null ? void 0 : a.source.getPSControlParam()) == null ? void 0 : r.ctrlParams;
      return (c == null ? void 0 : c.HIGHLIGHT) !== "false";
    });
    let b = null;
    const W = (a, r) => {
      b != null && window.clearTimeout(b), b = window.setTimeout(() => {
        const c = t.$refs.grid;
        c && (o.selectedData.find((p) => p.srfkey === a.srfkey) && c.clearCurrentRow(), c.toggleSelect && c.toggleSelect(r)), u(a);
      }, 300);
    }, j = (a) => {
      b != null && window.clearTimeout(b);
      const r = t.$refs.grid;
      r && (o.selectedData.find((c) => c.srfkey === a.srfkey) || r.clearCurrentRow()), l(a);
    }, v = g(0), f = g(null), S = g(null);
    let y = null, x = 0;
    const D = () => {
      var a;
      if (f.value && ((a = e.modal) == null ? void 0 : a.mode) !== "EMBED")
        if (o.model.source.enablePagingBar && S.value) {
          const r = S.value.$el, c = r.offsetHeight + parseFloat(window.getComputedStyle(r).paddingTop);
          v.value = f.value.offsetHeight - c;
        } else
          v.value = f.value.offsetHeight;
      o.model.source.height > 0 && (v.value = o.model.source.height);
    };
    L(f, (a, r) => {
      a && a !== r && (D(), window.ResizeObserver && f.value && (y = new ResizeObserver((c) => {
        const p = c[0].contentRect.height;
        p !== x && (D(), x = p);
      }), y.observe(f.value)));
    }), _(() => {
      y && y.disconnect();
    });
    const q = w(() => [{
      hiddenRow: !0
    }, ...o.items]), k = C("grid-field-column"), B = C("collaborative-satisfaction-grid"), P = g([]), F = w(() => {
      const a = [...s.value];
      return a.splice(1, 0, ...P.value), a;
    }), R = g([]);
    return L(() => o.items, () => {
      P.value = [], R.value = [], Array.isArray(o.items) && (P.value = o.items.map((a) => {
        const r = a.bpjbm, c = a.type;
        return {
          title: r,
          width: 120,
          minWidth: 120,
          align: "right",
          key: c,
          ellipsis: !0,
          tooltip: !1,
          resizable: !0,
          render: (p, {
            index: H
          }) => {
            const z = R.value[H - 1];
            return i("div", {
              class: [k.b()],
              style: k.cssVarBlock({
                "justify-content": "flex-end"
              })
            }, [i("span", {
              class: k.e("text")
            }, [(z == null ? void 0 : z[c]) || ""])]);
          }
        };
      }), R.value = o.items.map((a) => {
        try {
          const r = JSON.parse(a.pjdbs || "[]");
          if (Array.isArray(r) && r.length) {
            const c = {};
            return r.forEach((p) => {
              c[p.type] = p.pjfs || "";
            }), c;
          }
        } catch (r) {
          ibiz.log.error(`${a.pjdbs} 解析错误`);
        }
        return {};
      }));
    }), {
      c: o,
      ns: n,
      columns: s,
      tableData: q,
      onDbRowClick: l,
      onUIRowClick: W,
      onUIDbRowClick: j,
      onSelectionChange: h,
      onSortChange: d,
      onPageChange: m,
      onPageSizeChange: G,
      onPageReset: O,
      tableHeight: v,
      gridRef: f,
      girdPaginationRef: S,
      highlight: A,
      ns2: k,
      ns3: B,
      tableColumns: F
    };
  },
  render() {
    if (!this.c.complete)
      return;
    const e = {};
    return this.c.model.columns.forEach((t) => {
      if (t.source.columnType === "GROUPGRIDCOLUMN")
        return;
      const n = t.codeName;
      e[n] = ({
        row: o,
        index: s
      }) => {
        const u = this.c.rows[s - 1];
        if (o.hiddenRow)
          return i("span", {
            style: "word-break: break-word;white-space: pre-wrap;"
          }, ["隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列"]);
        if (u)
          return i(this.c.providers[n].component, {
            props: {
              controller: this.c.columns[n],
              row: u
            },
            key: o.srfkey + n
          });
      };
    }), i("control-layout", {
      attrs: {
        modelData: this.c.model
      }
    }, [i("div", {
      ref: "gridRef",
      class: [this.ns.b(), this.ns.is("show-header", !this.c.model.source.hideHeader), this.ns.is("enable-page", this.c.model.source.enablePagingBar), this.ns3.b()]
    }, [i("i-table", {
      ref: "grid",
      attrs: {
        height: this.tableHeight,
        "show-header": !this.c.model.source.hideHeader,
        "highlight-row": this.c.singleSelect && this.highlight,
        data: this.tableData,
        columns: this.tableColumns,
        "row-class-name": (t) => t.hiddenRow ? "hidden-row" : ""
      },
      class: this.ns.b("content"),
      on: {
        "on-row-click": this.onUIRowClick,
        "on-row-dblclick": this.onUIDbRowClick,
        "on-selection-change": this.onSelectionChange,
        "on-sort-change": this.onSortChange
      },
      scopedSlots: e
    }), this.c.model.source.enablePagingBar && i("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
      }
    })])]);
  }
});
const ie = {
  mateUrl: import.meta.url,
  install(e) {
    Z.getModelService().then((t) => {
      t.app.userParams.autoWidth === "true" && document.getElementsByClassName("app")[0].classList.add("auto-width");
    }), X.loadStyle(["/style.css"]), e.component("WfToolbar", ee), ibiz.config.enableDataInfoBar = !1, ibiz.config.gridEditShowMode = "all";
  }
};
const ae = new T(import.meta.url);
class le {
  constructor() {
    I(this, "component", "IndexView");
  }
}
function M(e, t) {
  return i("div", {
    class: e.e("logo")
  }, [t.appIconPath ? i("img", {
    class: e.e("logo-img"),
    attrs: {
      src: t.appIconPath
    }
  }) : null, i("div", {
    class: e.e("logo-caption")
  }, [t.caption])]);
}
const re = N({
  name: "UserAppLayout",
  props: {
    model: {
      type: J,
      required: !0
    },
    // 视图是否完成加载
    isComplete: {
      type: Boolean,
      default: !1
    },
    // 是否显示分页导航
    isShowTabPageExp: {
      type: Boolean,
      default: !1
    }
  },
  setup(e, {
    emit: t
  }) {
    const n = C("layout"), {
      proxy: o
    } = U(), s = g(!1), u = () => {
      s.value = !s.value, t("onCollapseChange", s.value);
    }, l = w(() => e.model.source.blankMode === !0), h = g("廉洁风险点提示"), d = g(`风险点名称：<br/>
    1、不合理设定绩效考核指标（SY-ZLGL-C005）<br/>
    2、绩效评分有失公允（SY-ZLGL-C006）<br/>
    3、违规调整绩效考核结果（SY-ZLGL-C007）<br/>
    风险描述：<br/>
    1、在制定战略绩效考核方案时，受其他部门请托，不合理设定绩效考核指标，为本人或相关方谋求不正当利益。<br/>
    2、在绩效考核过程中，受其他部门请托，绩效考核打分时有失公平公正，为本人或相关方谋求不正当利益。<br/>
    3、受其他部门请托，违规调整绩效考核小组、公司领导和公司总经理办公会决定的绩效考核结果，为本人或相关方谋求不正当利益。<br/>
    违规行为处罚措施：<br/>
    制定部门绩效考核计划时、绩效考核过程中、反馈绩效考核结果时，发现违规行为及时纠正，对于情节轻微的，未造成损害后果和不良影响的，给予提醒谈话、批评教育或采取岗位调整等组织处理措施。对于情节严重的，根据《中国共产党纪律处分条例》、《中国移动通信集团有限公司员工违纪违规处分条例》（中移人〔2018〕196号）和《中共中国移动通信集团有限公司党组问责工作管理办法》（中移党组〔2021〕23号）等相关规定进行处罚。`);
    return K(() => {
      o.$Modal.warning({
        title: h.value,
        content: d.value,
        okText: "已阅知",
        width: 1e3
      });
    }), {
      ns: n,
      collapseChange: s,
      isBlank: l,
      collapseMenus: u
    };
  },
  render() {
    return this.isComplete ? i("i-layout", {
      class: [this.ns.b(), this.isBlank ? this.ns.m("blank") : "", this.ns.is("collapse", this.collapseChange), this.ns.is("tab", this.isShowTabPageExp)]
    }, [i("i-sider", {
      attrs: {
        "hide-trigger": !0,
        value: this.collapseChange
      },
      class: [this.ns.b("nav"), this.ns.is("collapse", this.collapseChange)]
    }, [M(this.ns, this.model), this.$slots.menu]), i("i-layout", {
      class: [this.ns.b("content")]
    }, [i("i-header", {
      class: this.ns.b("header")
    }, [i("div", {
      class: this.ns.be("header", "left")
    }, [M(this.ns, this.model), i("div", {
      class: this.ns.be("header", "collapse-icon")
    }, [this.collapseChange ? i("ion-icon", {
      attrs: {
        src: "./assets/img/menu-unfold.svg"
      },
      on: {
        click: () => this.collapseMenus()
      }
    }) : i("ion-icon", {
      attrs: {
        src: "./assets/img/menu-fold.svg"
      },
      on: {
        click: () => this.collapseMenus()
      }
    })]), this.model.source.mainMenuAlign === "TOP" ? i("i-menu", {
      class: this.ns.be("header", "menu"),
      attrs: {
        mode: "horizontal",
        "active-name": "1"
      }
    }) : null]), i("div", {
      class: this.ns.be("header", "right")
    }, [i("app-user")])]), i("i-content", {
      class: this.ns.be("content", "main")
    }, [this.$slots.tabPageExp, this.$slots.default])])]) : null;
  }
});
const me = {
  mateUrl: import.meta.url,
  install(e) {
    ae.loadStyle(["/style.css"]), e.use(ie), ibiz.register.view.register(
      "VIEW_CUSTOM_SyZhbgGsWeb",
      new le()
    ), e.component("AppLayout", re);
  }
};
export {
  me as default
};
