@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
193 lines (192 loc) • 4.95 kB
JavaScript
import { isMobilePhone as m, withInstall as h } from "../common/index.esm.js";
import { defineComponent as w, ref as L, onMounted as v, watch as S, createVNode as b } from "vue";
import { getPropsResolverGenerator as F } from "../dynamic-resolver/index.esm.js";
import { DgControl as T } from "../designer-canvas/index.esm.js";
const I = "https://json-schema.org/draft/2020-12/schema", H = "https://farris-design.gitee.io/approval-logs.schema.json", C = "approval-logs", A = "A Farris Business Component", P = "object", k = {
id: {
description: "The unique identifier for a component",
type: "string"
},
type: {
description: "The type string of a component",
type: "string",
default: "approval-logs"
},
dataId: {
type: "string",
default: ""
},
displayType: {
type: "string",
default: "card"
},
showForecastLogs: {
type: "boolean",
default: !1
},
showHistoryLogs: {
type: "boolean",
default: !1
},
workflowScriptUrl: {
type: "string",
default: "/platform/runtime/wf/webapp/mobiletaskcenter/taskComment.js"
}
}, B = [
"id",
"type",
"displayType",
"showForecastLogs",
"showHistoryLogs"
], E = {
$schema: I,
$id: H,
title: C,
description: A,
type: P,
properties: k,
required: B
}, M = /* @__PURE__ */ new Map([]);
function j(e, d, s) {
var l, r;
const n = d, t = (l = s.bindingSourceContext) == null ? void 0 : l.entityFieldNode;
t && (n.binding = {
type: "Form",
path: t.bindingField,
field: t.id,
fullPath: t.path
});
const a = s.parentComponentInstance, o = (r = a == null ? void 0 : a.schema) == null ? void 0 : r.type;
if (!o || o === T.section.type)
return n;
const i = e.getSchemaByType("section"), c = Math.random().toString().slice(2, 6);
return Object.assign(i, {
id: `section-${c}`,
appearance: {
class: "f-section-in-mainsubcard"
},
mainTitle: "审批记录",
contents: [n]
}), i;
}
const g = {
/** 单据ID */
dataId: { type: String, default: "" },
/** 展示类型 */
displayType: { type: String, default: "card" },
/** 是否展示预测日志 */
showForecastLogs: { type: Boolean, default: !1 },
/** 是否展示历史日志 */
showHistoryLogs: { type: Boolean, default: !1 },
/** 审批流脚本地址 */
workflowScriptUrl: { type: String, default: "" }
}, R = F(
g,
E,
M,
j
), p = {};
function $() {
function e(s = 1) {
const n = s * 60 * 60 * 1e3, t = Date.now();
return t - t % n;
}
function d(s) {
if (!s)
return Promise.resolve();
if (p[s])
return p[s];
const n = new Promise((t, a) => {
const o = document.createElement("script");
o.src = s + `?v=${e()}`, o.type = "text/javascript", o.async = !0;
function i() {
o.removeEventListener("load", c), o.removeEventListener("error", l);
}
function c() {
i(), t();
}
function l(r) {
i(), delete p[s], a(r);
}
o.addEventListener("load", c), o.addEventListener("error", l), document.head.appendChild(o);
});
return p[s] = n, n;
}
return {
loadJsScript: d
};
}
const z = /* @__PURE__ */ w({
name: "FApprovalLogs",
props: g,
emits: [],
setup(e, d) {
const {
loadJsScript: s
} = $(), n = m(), t = L();
function a() {
return !!window.gspTaskCenterBizLog;
}
function o() {
return window.gspTaskCenterBizLog.ApprovalLogUtil;
}
function i() {
return e.displayType === "data-grid" && !n ? "datagrid" : "card";
}
function c() {
t.value && (t.value.innerHTML = "");
}
function l() {
if (i() === "datagrid") {
const f = {
bizInstId: e.dataId,
container: t.value,
showHeader: !1,
showViewProcess: !1,
ifForecast: !!e.showForecastLogs,
isIncludeHistory: !!e.showHistoryLogs
};
o().getWebHtml(f);
} else {
const f = {
bizInstId: e.dataId,
container: t.value,
terminal: n ? "mobile" : "web",
typeId: "wf",
showHeader: !1,
showForecastBtn: n,
ifForecast: !!e.showForecastLogs,
isIncludeHistory: !!e.showHistoryLogs
};
o().getWebLogsHtml(f);
}
}
async function r() {
if (!e.dataId || !t.value) {
c();
return;
}
a() || await s(e.workflowScriptUrl).catch((u) => {
console.error(u);
}), a() && l();
}
v(r), S([() => e.dataId, () => e.displayType, () => e.showForecastLogs, () => e.showHistoryLogs], () => {
c(), r();
});
function y() {
r();
}
return d.expose({
refreshData: y
}), () => b("div", {
ref: t,
class: "fv-approval-logs"
}, null);
}
}), V = h(z);
export {
V as FApprovalLogs,
g as approvalLogsProps,
V as default,
R as propsResolverGenerator
};