ibiz-template-plugin.es.js 11.9 KB
Newer Older
zhf's avatar
zhf committed
1
var W = Object.defineProperty;
fzh's avatar
fzh committed
2 3
var q = (e, t, i) => t in e ? W(e, t, { enumerable: !0, configurable: !0, writable: !0, value: i }) : e[t] = i;
var v = (e, t, i) => (q(e, typeof t != "symbol" ? t + "" : t, i), i);
zhf's avatar
zhf committed
4
import { GridModel as B, ModelUtil as $ } from "@ibiz-template/model";
fzh's avatar
fzh committed
5 6 7 8 9
import { defineComponent as z, h, ref as C, computed as S, getCurrentInstance as V, watch as T, onUnmounted as J } from "vue";
import { useNamespace as P, useGridController as K } from "@ibiz-template/vue-util";
import { PluginStaticResource as Q, UIActionHandler as X } from "@ibiz-template/runtime";
import { RuntimeError as U, downloadFileFromBlob as Y } from "@ibiz-template/core";
const Z = z({
zhujiamin's avatar
zhujiamin committed
10 11 12 13 14 15 16
  name: "WFToolbar",
  props: {
    wfLinks: {
      type: Array,
      required: !0
    }
  },
zhf's avatar
zhf committed
17 18
  setup(e, {
    emit: t
zhujiamin's avatar
zhujiamin committed
19
  }) {
fzh's avatar
fzh committed
20
    const i = P("wf-toolbar"), o = async (a, n) => {
zhf's avatar
zhf committed
21
      t("wf-link-click", a, n);
zhujiamin's avatar
zhujiamin committed
22 23
    };
    return {
fzh's avatar
fzh committed
24
      ns: i,
zhf's avatar
zhf committed
25
      handleClick: async (a, n) => {
zhujiamin's avatar
zhujiamin committed
26
        setTimeout(() => {
zhf's avatar
zhf committed
27
          o(a, n);
zhujiamin's avatar
zhujiamin committed
28 29 30 31 32
        }, 30);
      }
    };
  },
  render() {
zhf's avatar
zhf committed
33
    const e = this.wfLinks || [];
fzh's avatar
fzh committed
34
    return h("div", {
zhujiamin's avatar
zhujiamin committed
35
      class: `${this.ns.b()}`
zhf's avatar
zhf committed
36
    }, [e.length > 0 && e.map((t) => {
fzh's avatar
fzh committed
37 38
      const i = t.sequenceFlowName.startsWith("驳回") || t.sequenceFlowName.startsWith("取消");
      return h("div", {
zhf's avatar
zhf committed
39
        key: t.sequenceFlowId,
fzh's avatar
fzh committed
40 41
        class: [this.ns.e("item"), i ? this.ns.em("item", "reject") : ""]
      }, [h("i-button", {
zhujiamin's avatar
zhujiamin committed
42
        attrs: {
zhf's avatar
zhf committed
43
          title: t.sequenceFlowName
zhujiamin's avatar
zhujiamin committed
44 45
        },
        on: {
zhf's avatar
zhf committed
46
          click: (o) => this.handleClick(t, o)
zhujiamin's avatar
zhujiamin committed
47
        }
zhf's avatar
zhf committed
48
      }, [t.sequenceFlowName || ""])]);
zhujiamin's avatar
zhujiamin committed
49 50
    })]);
  }
zhf's avatar
zhf committed
51
});
fzh's avatar
fzh committed
52 53 54
function x(e, t) {
  var s, a;
  const i = [];
zhf's avatar
zhf committed
55
  e.source.columnType === "GROUPGRIDCOLUMN" && e.children.forEach((n) => {
fzh's avatar
fzh committed
56
    i.push(x(n, t));
zhf's avatar
zhf committed
57 58 59 60 61
  });
  const o = {
    title: e.title,
    width: e.source.widthUnit === "STAR" ? void 0 : e.width,
    minWidth: e.width,
fzh's avatar
fzh committed
62
    align: ((s = e.source.align) == null ? void 0 : s.toLowerCase()) || "center",
zhf's avatar
zhf committed
63 64 65 66 67 68 69 70 71 72 73 74
    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: (a = e.source.getCellPSSysCss()) == null ? void 0 : a.cssName
  };
fzh's avatar
fzh committed
75
  return i.length > 0 && Object.assign(o, { children: i }), o;
zhf's avatar
zhf committed
76
}
fzh's avatar
fzh committed
77 78 79 80 81 82
function ee(e) {
  const t = e.model, i = [], o = t.columns.map((s) => x(s, e));
  return t.children.forEach((s) => {
    const a = o.find((n) => n.key === s.codeName);
    a && i.push(a);
  }), e.singleSelect || i.splice(0, 0, { type: "selection", width: 60 }), i;
zhf's avatar
zhf committed
83
}
fzh's avatar
fzh committed
84
function te(e) {
zhf's avatar
zhf committed
85 86
  const t = C([]);
  return e.nerve.self.evt.on("created", () => {
fzh's avatar
fzh committed
87 88
    t.value = ee(e);
  }), [S(() => {
zhf's avatar
zhf committed
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104
    const o = [...t.value];
    if (!o.find((n) => !n.width)) {
      let n = o.length - 1;
      o[n].key === "rowEdit" && (n -= 1), o[n] = {
        ...o[n],
        width: void 0
      };
    }
    const a = o.find((n) => n.columnType === "UAGRIDCOLUMN");
    if (a) {
      const n = a.userParams;
      n && n.fixed === "true" && (a.fixed = "right");
    }
    return o;
  }), t];
}
fzh's avatar
fzh committed
105
function oe(e) {
zhf's avatar
zhf committed
106
  const t = (n) => e.items.find((u) => u.srfkey === n.srfkey);
fzh's avatar
fzh committed
107
  function i(n) {
zhf's avatar
zhf committed
108 109
    const u = t(n);
    if (e.singleSelect) {
fzh's avatar
fzh committed
110 111
      const d = e.selectedData.find(
        (f) => f.srfkey === n.srfkey
zhf's avatar
zhf committed
112
      );
fzh's avatar
fzh committed
113
      e.onSelectionChange(d ? [] : [u]);
zhf's avatar
zhf committed
114 115 116 117 118 119
    }
    e.onRowClick(u);
  }
  function o(n) {
    e.onDbRowClick(t(n));
  }
fzh's avatar
fzh committed
120
  function s(n) {
zhf's avatar
zhf committed
121 122
    if (!e.singleSelect) {
      const u = [];
fzh's avatar
fzh committed
123 124 125
      n.forEach((d) => {
        const f = t(d);
        f && u.push(f);
zhf's avatar
zhf committed
126 127 128 129
      }), e.onSelectionChange(u);
    }
  }
  function a(n) {
fzh's avatar
fzh committed
130 131
    const { column: u, order: d } = n, f = d === "asc" || d === "desc" ? d : void 0;
    e.setSort(u.fieldName, f), e.load();
zhf's avatar
zhf committed
132
  }
fzh's avatar
fzh committed
133
  return { onRowClick: i, onDbRowClick: o, onSelectionChange: s, onSortChange: a };
zhf's avatar
zhf committed
134
}
fzh's avatar
fzh committed
135 136 137
function ne(e) {
  function t(s) {
    !s || s === e.curPage || (e.curPage = s, e.load());
zhf's avatar
zhf committed
138
  }
fzh's avatar
fzh committed
139 140
  function i(s) {
    !s || s === e.size || (e.size = s, e.curPage === 1 && e.load());
zhf's avatar
zhf committed
141 142 143 144
  }
  function o() {
    e.curPage = 1, e.load();
  }
fzh's avatar
fzh committed
145
  return { onPageChange: t, onPageSizeChange: i, onPageReset: o };
zhf's avatar
zhf committed
146
}
fzh's avatar
fzh committed
147
const ie = z({
zhf's avatar
zhf committed
148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176
  props: {
    modelData: B,
    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
fzh's avatar
fzh committed
177
    } = V(), i = P("grid"), o = K(t, e.modelData, e.context, e.params), [s] = te(o), {
zhf's avatar
zhf committed
178 179 180
      onRowClick: a,
      onDbRowClick: n,
      onSelectionChange: u,
fzh's avatar
fzh committed
181 182 183
      onSortChange: d
    } = oe(o), {
      onPageChange: f,
zhf's avatar
zhf committed
184
      onPageReset: O,
fzh's avatar
fzh committed
185 186
      onPageSizeChange: H
    } = ne(o), A = S(() => {
zhf's avatar
zhf committed
187
      var l, c;
fzh's avatar
fzh committed
188 189
      const r = (c = (l = e.modelData) == null ? void 0 : l.source.getPSControlParam()) == null ? void 0 : c.ctrlParams;
      return (r == null ? void 0 : r.HIGHLIGHT) !== "false";
zhf's avatar
zhf committed
190 191
    });
    let p = null;
fzh's avatar
fzh committed
192
    const E = (r, l) => {
zhf's avatar
zhf committed
193 194
      p != null && window.clearTimeout(p), p = window.setTimeout(() => {
        const c = t.$refs.grid;
fzh's avatar
fzh committed
195
        c && (o.selectedData.find((D) => D.srfkey === r.srfkey) && c.clearCurrentRow(), c.toggleSelect && c.toggleSelect(l)), a(r);
zhf's avatar
zhf committed
196
      }, 300);
fzh's avatar
fzh committed
197
    }, M = (r) => {
zhf's avatar
zhf committed
198 199
      p != null && window.clearTimeout(p);
      const l = t.$refs.grid;
fzh's avatar
fzh committed
200 201 202 203 204 205 206 207 208
      l && (o.selectedData.find((m) => m.srfkey === r.srfkey) || l.clearCurrentRow()), n(r);
    }, w = C(0), g = C(null), R = C(null);
    let b = null, N = 0;
    const G = () => {
      var r;
      if (g.value && ((r = e.modal) == null ? void 0 : r.mode) !== "EMBED")
        if (o.model.source.enablePagingBar && R.value) {
          const l = R.value.$el, c = l.offsetHeight + parseFloat(window.getComputedStyle(l).paddingTop);
          w.value = g.value.offsetHeight - c;
zhf's avatar
zhf committed
209
        } else
fzh's avatar
fzh committed
210
          w.value = g.value.offsetHeight;
zhf's avatar
zhf committed
211 212
      o.model.source.height > 0 && (w.value = o.model.source.height);
    };
fzh's avatar
fzh committed
213 214 215 216 217 218
    T(g, (r, l) => {
      r && r !== l && (G(), window.ResizeObserver && g.value && (b = new ResizeObserver((c) => {
        const m = c[0].contentRect.height;
        m !== N && (G(), N = m);
      }), b.observe(g.value)));
    }), J(() => {
zhf's avatar
zhf committed
219 220
      b && b.disconnect();
    });
fzh's avatar
fzh committed
221
    const L = S(() => [{
zhf's avatar
zhf committed
222
      hiddenRow: !0
fzh's avatar
fzh committed
223 224 225 226
    }, ...o.items]), y = P("grid-field-column"), j = P("collaborative-satisfaction-grid"), k = C([]), _ = S(() => {
      const r = [...s.value];
      return r.splice(1, 0, ...k.value), r;
    }), I = C([]);
zhf's avatar
zhf committed
227
    return T(() => o.items, () => {
fzh's avatar
fzh committed
228 229
      k.value = [], I.value = [], Array.isArray(o.items) && (k.value = o.items.map((r) => {
        const l = r.bpjbm, c = r.type;
zhf's avatar
zhf committed
230 231 232 233 234 235 236 237 238
        return {
          title: l,
          width: 120,
          minWidth: 120,
          align: "right",
          key: c,
          ellipsis: !0,
          tooltip: !1,
          resizable: !0,
fzh's avatar
fzh committed
239 240
          render: (m, {
            index: D
zhf's avatar
zhf committed
241
          }) => {
fzh's avatar
fzh committed
242 243
            const F = I.value[D - 1];
            return h("div", {
zhf's avatar
zhf committed
244 245 246 247
              class: [y.b()],
              style: y.cssVarBlock({
                "justify-content": "flex-end"
              })
fzh's avatar
fzh committed
248
            }, [h("span", {
zhf's avatar
zhf committed
249
              class: y.e("text")
fzh's avatar
fzh committed
250
            }, [(F == null ? void 0 : F[c]) || ""])]);
zhf's avatar
zhf committed
251 252
          }
        };
fzh's avatar
fzh committed
253
      }), I.value = o.items.map((r) => {
zhf's avatar
zhf committed
254
        try {
fzh's avatar
fzh committed
255
          const l = JSON.parse(r.pjdbs || "[]");
zhf's avatar
zhf committed
256 257
          if (Array.isArray(l) && l.length) {
            const c = {};
fzh's avatar
fzh committed
258 259
            return l.forEach((m) => {
              c[m.type] = m.value || "";
zhf's avatar
zhf committed
260 261 262
            }), c;
          }
        } catch (l) {
fzh's avatar
fzh committed
263
          ibiz.log.error(`${r.pjdbs} 解析错误`);
zhf's avatar
zhf committed
264 265 266 267 268
        }
        return {};
      }));
    }), {
      c: o,
fzh's avatar
fzh committed
269 270 271
      ns: i,
      columns: s,
      tableData: L,
zhf's avatar
zhf committed
272
      onDbRowClick: n,
fzh's avatar
fzh committed
273 274
      onUIRowClick: E,
      onUIDbRowClick: M,
zhf's avatar
zhf committed
275
      onSelectionChange: u,
fzh's avatar
fzh committed
276 277 278
      onSortChange: d,
      onPageChange: f,
      onPageSizeChange: H,
zhf's avatar
zhf committed
279 280
      onPageReset: O,
      tableHeight: w,
fzh's avatar
fzh committed
281 282 283
      gridRef: g,
      girdPaginationRef: R,
      highlight: A,
zhf's avatar
zhf committed
284
      ns2: y,
fzh's avatar
fzh committed
285 286
      ns3: j,
      tableColumns: _
zhf's avatar
zhf committed
287 288 289 290 291 292 293 294 295
    };
  },
  render() {
    if (!this.c.complete)
      return;
    const e = {};
    return this.c.model.columns.forEach((t) => {
      if (t.source.columnType === "GROUPGRIDCOLUMN")
        return;
fzh's avatar
fzh committed
296 297
      const i = t.codeName;
      e[i] = ({
zhf's avatar
zhf committed
298
        row: o,
fzh's avatar
fzh committed
299
        index: s
zhf's avatar
zhf committed
300
      }) => {
fzh's avatar
fzh committed
301
        const a = this.c.rows[s - 1];
zhf's avatar
zhf committed
302
        if (o.hiddenRow)
fzh's avatar
fzh committed
303
          return h("span", {
zhf's avatar
zhf committed
304 305 306
            style: "word-break: break-word;white-space: pre-wrap;"
          }, ["隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列隐藏行的列"]);
        if (a)
fzh's avatar
fzh committed
307
          return h(this.c.providers[i].component, {
zhf's avatar
zhf committed
308
            props: {
fzh's avatar
fzh committed
309
              controller: this.c.columns[i],
zhf's avatar
zhf committed
310 311
              row: a
            },
fzh's avatar
fzh committed
312
            key: o.srfkey + i
zhf's avatar
zhf committed
313 314
          });
      };
fzh's avatar
fzh committed
315
    }), h("control-layout", {
zhf's avatar
zhf committed
316 317 318
      attrs: {
        modelData: this.c.model
      }
fzh's avatar
fzh committed
319
    }, [h("div", {
zhf's avatar
zhf committed
320 321
      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()]
fzh's avatar
fzh committed
322
    }, [h("i-table", {
zhf's avatar
zhf committed
323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339
      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
fzh's avatar
fzh committed
340
    }), this.c.model.source.enablePagingBar && h("app-grid-pagination", {
zhf's avatar
zhf committed
341 342 343 344 345 346 347 348 349 350 351 352 353 354
      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
      }
    })])]);
  }
});
fzh's avatar
fzh committed
355
class se {
zhf's avatar
zhf committed
356
  constructor() {
fzh's avatar
fzh committed
357
    v(this, "component", "IndexView");
zhf's avatar
zhf committed
358 359
  }
}
fzh's avatar
fzh committed
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390
const re = new Q(import.meta.url);
class ae extends X {
  async execAction(t, i, o, s, a) {
    const n = "/ibzsy/xtmydcphzdc";
    return ibiz.net.request(n, {
      method: "post",
      data: s,
      responseType: "blob",
      baseURL: ibiz.env.baseUrl
    }).then((u) => {
      if (u.status !== 200)
        throw new U("下载文件失败");
      if (u.data) {
        const d = u.headers.filename, f = decodeURIComponent(d);
        Y(u.data, f);
      } else
        throw new U("文件流数据不存在");
    }), {
      refresh: !1
    };
  }
}
class le {
  constructor() {
    v(this, "handler");
  }
  async getHandler() {
    return this.handler || (this.handler = new ae()), this.handler;
  }
}
class ce {
zhf's avatar
zhf committed
391
  constructor() {
fzh's avatar
fzh committed
392
    v(this, "component", "CollaborativeSatisfactionGrid");
zhf's avatar
zhf committed
393 394
  }
}
fzh's avatar
fzh committed
395
const Ce = {
396
  mateUrl: import.meta.url,
zhf's avatar
zhf committed
397 398 399
  install(e) {
    $.getModelService().then((t) => {
      t.app.userParams.autoWidth === "true" && document.getElementsByClassName("app")[0].classList.add("auto-width");
fzh's avatar
fzh committed
400
    }), re.loadStyle(["/style.css"]), e.component("WfToolbar", Z), ibiz.config.enableDataInfoBar = !1, ibiz.config.gridEditShowMode = "all", ibiz.register.view.register(
401
      "VIEW_CUSTOM_GsIndexCSS",
fzh's avatar
fzh committed
402
      new se()
zhf's avatar
zhf committed
403 404
    ), e.component(
      "CollaborativeSatisfactionGrid",
fzh's avatar
fzh committed
405
      ie
zhf's avatar
zhf committed
406 407
    ), ibiz.register.control.register(
      "CUSTOM_CollaborativeSatisfactionGrid",
fzh's avatar
fzh committed
408 409 410 411
      new ce()
    ), ibiz.register.uiAction.register(
      "DEUIACTION_CollaborativeSatisfactionPort",
      new le()
412 413 414 415
    );
  }
};
export {
fzh's avatar
fzh committed
416
  Ce as default
417
};