@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,418 lines (1,416 loc) • 44.4 kB
JavaScript
import { computed as N, watch as G, ref as F, createVNode as V, Fragment as L, createTextVNode as H } from "vue";
import { FNotifyService as J } from "../../components/notify/index.esm.js";
function Y(u, t, i, r, s) {
const { getGridHeaderCells: m } = s, d = 120, p = 50, f = N(() => {
var e;
return ((e = u.rowNumber) == null ? void 0 : e.enable) || !1;
}), y = N(() => {
var e, n;
return ((e = u.selection) == null ? void 0 : e.multiSelect) === !0 || ((n = u.selection) == null ? void 0 : n.showCheckbox) === !0;
}), M = N(
() => {
var e;
return 0 + (f.value ? ((e = u.rowNumber) == null ? void 0 : e.width) || 32 : 0) + (y.value ? p : 0);
}
), B = N(() => {
var e;
return (e = u.columnOption) == null ? void 0 : e.fitColumns;
}), C = N(() => {
var e;
return B.value && ((e = u.columnOption) == null ? void 0 : e.fitMode) || "none";
});
function R(e, n, a) {
const g = parseInt(e.width, 10) / 100;
return a * g;
}
function w(e, n, a) {
return typeof e.width == "string" ? R(e, n, a) : e.width || d;
}
function l(e, n) {
const a = [], g = [];
let S = 0;
e.value.primaryColumns.forEach((b) => {
typeof b.width == "string" ? g.push(b) : (b.width = b.width || d, S += b.width, a.push(b));
});
const _ = n * (a.length / e.value.primaryColumns.length);
a.forEach((b) => {
const v = _ * (b.width / S);
b.actualWidth = v, e.value.primaryColumnsWidth += b.actualWidth;
});
const T = n - _;
g.forEach((b) => {
const v = R(b, e.value, T);
b.actualWidth = v, e.value.primaryColumnsWidth += b.actualWidth;
});
}
function c(e, n) {
const a = [], g = [], S = /* @__PURE__ */ new WeakMap();
let _ = 0, T = 0;
if (e.value.primaryColumns.forEach((v) => {
if (typeof v.width == "string") {
const A = R(v, e.value, n);
S.set(v, A), _ += A, g.push(v);
} else
v.width = v.width || d, T += v.width, a.push(v);
}), n - _ > T) {
const v = n - _;
g.forEach((A) => {
A.actualWidth = S.get(A) || d, e.value.primaryColumnsWidth += A.actualWidth;
}), a.forEach((A) => {
A.actualWidth = v * (A.width / T), e.value.primaryColumnsWidth += A.actualWidth;
});
} else
l(e, n);
}
function h(e, n) {
e.value.primaryColumns.forEach((a) => {
a.actualWidth = w(a, e.value, n), e.value.primaryColumnsWidth += a.actualWidth;
});
}
const k = {
expand: c,
none: h,
percentage: l
};
function E(e) {
e.value.leftHeaderColumns = Array.from(m(e.value.leftColumns).values()), e.value.primaryHeaderColumns = Array.from(m(e.value.primaryColumns).values()), e.value.rightHeaderColumns = Array.from(m(e.value.rightColumns).values());
}
function P(e) {
e.value.leftColumnsWidth = 0, e.value.primaryColumnsWidth = 0, e.value.rightColumnsWidth = 0, e.value.leftColumns.forEach((n) => {
e.value.leftColumnsWidth += n.actualWidth || 0;
}), e.value.primaryColumns.forEach((n) => {
e.value.primaryColumnsWidth += n.actualWidth || 0;
}), e.value.rightColumns.forEach((n) => {
e.value.rightColumnsWidth += n.actualWidth || 0;
}), e.value = Object.assign({}, e.value);
}
function W(e, n, a) {
var A;
let g = 0;
const S = e.value.primaryColumns, _ = e.value.rightColumns;
e.value.rightColumns.forEach((I) => {
I.actualWidth = w(I, e.value, n), g += I.actualWidth;
});
const T = a - g, b = k[C.value];
if (b && b(e, T), e.value.primaryColumnsWidth + g <= a)
return e.value.primaryColumns = [...S, ..._], e.value.primaryColumnsWidth += g, e.value.rightColumns = [], e.value.rightColumnsWidth = 0, !0;
const v = /* @__PURE__ */ new Map();
return v.set("primary", []), v.set("right", []), e.value.primaryColumns.reduce((I, $) => {
var O, z;
return $.fixed === "right" ? (O = I.get("right")) == null || O.push($) : (z = I.get("primary")) == null || z.push($), I;
}, v), (A = v.get("right")) != null && A.length && (e.value.primaryColumns = [...v.get("primary") || []], e.value.rightColumns = [...v.get("right") || []]), e.value.primaryColumnsWidth = 0, e.value.rightColumnsWidth = 0, !1;
}
function o() {
if (i.value) {
t.value.leftColumnsWidth = 0, t.value.primaryColumnsWidth = 0, t.value.rightColumnsWidth = 0;
const e = i.value.clientWidth - M.value;
t.value.leftColumns.forEach((a) => {
a.actualWidth = w(a, t.value, e), t.value.leftColumnsWidth += a.actualWidth;
});
const n = e - t.value.leftColumnsWidth;
if (W(t, e, n))
r.value = n;
else {
t.value.rightColumns.forEach((S) => {
S.actualWidth = w(S, t.value, e), t.value.rightColumnsWidth += S.actualWidth;
});
const a = e - t.value.leftColumnsWidth - t.value.rightColumnsWidth, g = k[C.value];
g && g(t, a), r.value = a;
}
E(t), t.value = Object.assign({}, t.value);
}
}
return G(() => {
var e;
return (e = u.columnOption) == null ? void 0 : e.fitColumns;
}, (e, n) => {
e !== n && e && o();
}), G(C, (e, n) => {
e !== n && B.value && o();
}), { calculateColumnHeaders: E, calculateColumnsSize: o, calculateColumnsWidth: P };
}
const q = "";
function Q(u) {
const r = F({
defaultColumnWidth: 120,
headerDepth: 1,
leftColumns: [],
leftColumnsMap: /* @__PURE__ */ new Map(),
leftColumnsWidth: 0,
leftHeaderColumns: [],
primaryColumns: [],
primaryColumnsMap: /* @__PURE__ */ new Map(),
primaryColumnsWidth: 0,
primaryHeaderColumns: [],
rightColumns: [],
rightColumnsMap: /* @__PURE__ */ new Map(),
rightColumnsWidth: 0,
rightHeaderColumns: [],
summaryColumns: []
});
function s() {
r.value = {
defaultColumnWidth: 120,
headerDepth: 1,
leftColumns: [],
leftColumnsMap: /* @__PURE__ */ new Map(),
leftColumnsWidth: 0,
leftHeaderColumns: [],
primaryColumns: [],
primaryColumnsMap: /* @__PURE__ */ new Map(),
primaryColumnsWidth: 0,
primaryHeaderColumns: [],
rightColumns: [],
rightColumnsMap: /* @__PURE__ */ new Map(),
rightColumnsWidth: 0,
rightHeaderColumns: [],
summaryColumns: []
};
}
const m = F(u.summary), d = N(() => {
const o = m.value;
return (o == null ? void 0 : o.groupFields) || [];
});
function p() {
r.value.rightColumns.forEach((n) => {
n.showSetting = !1;
}), r.value.primaryColumns.forEach((n) => {
n.showSetting = !1;
});
const o = r.value.rightColumns, e = r.value.primaryColumns;
o.length > 0 ? o[o.length - 1].showSetting = !0 : e.length > 0 && (e[e.length - 1].showSetting = !0);
}
function f(o) {
s();
const e = /* @__PURE__ */ new Map();
return d.value && d.value.reduce((n, a) => (n.set(a, !0), n), e), o.reduce((n, a) => (a.filter = a.filter || q, a.fixed === "left" ? (r.value.leftColumns.push(a), r.value.leftColumnsMap.set(a.field, a), r.value.leftColumnsWidth += a.actualWidth) : a.fixed === "right" ? (r.value.rightColumns.push(a), r.value.rightColumnsMap.set(a.field, a), r.value.rightColumnsWidth += a.actualWidth) : (r.value.primaryColumns.push(a), r.value.primaryColumnsMap.set(a.field, a), r.value.primaryColumnsWidth += a.actualWidth), e.has(a.field) && r.value.summaryColumns.push(a), n), r), p(), r;
}
f(u.columns);
const y = N(() => r.value.leftColumns.length > 0), M = N(() => r.value.rightColumns.length > 0);
function B(o, e) {
return e.sortable && e.sort && e.sort !== "none" && o.push(e), o;
}
function C(o, e) {
return o.sortOrder = o.sortOrder || 0, e.sortOrder = e.sortOrder || 0, o.sortOrder === e.sortOrder ? 0 : o.sortOrder < e.sortOrder ? -1 : 1;
}
function R(o, e) {
return o.sortOrder = o.sortOrder || 0, e.sortOrder = e.sortOrder || 0, o.sortOrder === e.sortOrder ? 0 : o.sortOrder < e.sortOrder ? 1 : -1;
}
function w(o, e) {
return e.filterable && o.push(e), o;
}
function l() {
const o = [];
return r.value.leftColumns.reduce(w, o), r.value.primaryColumns.reduce(w, o), r.value.rightColumns.reduce(w, o), o;
}
function c() {
const o = [];
r.value.leftColumns.reduce(B, o), r.value.primaryColumns.reduce(B, o), r.value.rightColumns.reduce(B, o);
const e = Math.max(...o.map((n) => n.sortOrder || 0));
return o.sort(R).map((n) => {
const a = n.sortOrder || e + 1;
return n.sortOrder = a, n;
}).sort(C).map((n, a) => {
const g = a + 1;
return n.sortOrder = g, n;
});
}
function h(o, e, n) {
const a = o.map((g) => {
const S = n.getSorterByColumn(g), _ = g.sort === "asc", T = g.sort === "desc", b = _ ? S.ascend : T ? S.decend : void 0;
return { field: g.field, compare: b };
});
e.setSorters(a);
}
function k(o, e) {
const n = c();
h(n, o, e);
}
function E(o) {
}
function P(o) {
}
function W() {
}
return {
applyColumnSorter: k,
collectionFilterableColumns: l,
applySortableColumns: h,
collectionSortableColumns: c,
columnContext: r,
hasLeftFixedColumn: y,
hasRightFixedColumn: M,
updateColumnRenderContext: f,
updateColumnSettingIcon: p,
sortFromServer: E,
createSortConditions: P,
clearSortConditions: W
};
}
function X(u, t, i, r, s, m, d, p) {
const f = F(r.value - 1 + s), y = F(0), { renderDataRow: M } = m, B = d ? d.renderGroupRow : M, C = p ? p.renderSummaryRow : M;
function R(c) {
let h = M;
return c.__fv_data_grid_group_row__ && (h = B), c.__fv_data_grid_group_summary__ && (h = C), h;
}
function w(c, h, k, E) {
const { dataView: P } = i, W = [];
if (P.value.length > 0) {
const o = E ? Date.now().toString() : "";
let e = c, n = 0;
const a = h - c + 1;
for (; W.length < a && e < P.value.length; ) {
const g = P.value[e], S = P.value[e - 1] || k, _ = W[n - 1], T = S ? (S.__fv_data_position__ || 0) + (S.__fv_data_height__ || 0) : 0, v = R(g)(g, S, _, e, T, t.value, W);
v.refreshKey = o, W.push(v), n++, e++;
}
}
return y.value = W.length > 0 ? W[0].index : 0, f.value = W.length > 0 ? W[W.length - 1].index : 0, W;
}
function l(c, h, k) {
const E = h.groupField || "", { groupValue: P, raw: W } = h;
i[c](E, P, W.groupParents || []);
const { dataView: o } = i, e = k[0].index, n = Math.min(e + r.value + s + 1, o.value.length - 1);
return w(e, n);
}
return { getVisualData: w, maxVisibleRowIndex: f, minVisibleRowIndex: y, toggleGroupRow: l };
}
function Z() {
function u(t) {
return {
title: "行配置",
description: "",
properties: {
// height: {
// title: '行高',
// type: 'number',
// description: '行高',
// $converter: '/converter/row-option.converter',
// editor: {
// max: 200,
// min: 28,
// decimals: 0,
// needValid: true
// }
// },
customRowStyle: {
title: "行样式",
type: "string",
description: "自定义行样式",
$converter: "/converter/row-option.converter",
editor: {
type: "code-editor",
language: "javascript",
leftTemplate: () => V(L, null, [V("h5", null, [H("示例代码")]), V("pre", null, [`
(dataItem) => {
if(dataItem.code === '0001') {
return {
class: {
'text-align': true,
'text-red': true
},
style: {
'background-color': '#000',
'font-size': '1rem'
}
};
}
return {};
}
注: dataItem 行数据
`])])
}
},
customCellStyle: {
title: "单元格样式",
type: "string",
description: "自定义单元格样式",
$converter: "/converter/row-option.converter",
editor: {
type: "code-editor",
language: "javascript",
leftTemplate: () => V(L, null, [V("h5", null, [H("示例代码")]), V("pre", null, [`
(cell, row) => {
if(cell.data === '0002') {
return {
class: {
'text-align': true,
'text-red': true
},
style: {
'background-color': '#000',
'font-size': '1rem'
}
};
}
return {};
}
注: cell.data 单元格数据
cell.column 列数据
row.raw 行数据
`])])
}
}
}
};
}
return {
getRowOptionProperties: u
};
}
function x() {
function u(t) {
return {
title: "填充列宽",
description: "控制列宽对表格容器的填充模式",
properties: {
fitMode: {
description: "",
title: "填充模式",
type: "enum",
$converter: "/converter/column-option.converter",
refreshPanelAfterChanged: !0,
editor: {
data: [
{ id: "none", name: "不填充" },
{ id: "average", name: "平均列宽" },
{ id: "expand", name: "等比扩展" }
// { id: 'percentage', name: '混合百分比' }
]
}
}
},
setPropertyRelates(i, r) {
switch (i && i.propertyID) {
case "fitMode": {
const s = i.propertyValue && i.propertyValue !== "none";
if (r.fit = s, r.columns) {
const m = i.propertyValue === "average";
r.columns.forEach((d) => {
d.resizable = !m;
});
}
break;
}
}
}
};
}
return { getColumnOptionProperties: u };
}
function j(u) {
function t(i) {
var r, s, m, d;
return {
title: "操作列",
description: "",
properties: {
// enable: {
// title: '启用',
// type: 'boolean',
// $converter: '/converter/column-command.converter',
// description: '启用操作列',
// refreshPanelAfterChanged: true
// },
enableType: {
title: "操作列",
type: "enum",
$converter: "/converter/column-command.converter",
description: "启用操作列",
refreshPanelAfterChanged: !0,
editor: {
data: [
{ id: "unable", name: "无" },
{ id: "default", name: "编辑和删除" },
{ id: "custom", name: "自定义" }
]
}
},
count: {
description: "平铺操作按钮数量",
title: "平铺按钮数量",
type: "number",
$converter: "/converter/column-command.converter",
visible: ((r = i.command) == null ? void 0 : r.enableType) === "custom",
editor: {
needValid: !0,
min: 0
}
},
commands: {
description: "操作列按钮集合",
title: "操作项",
type: "array",
visible: ((s = i.command) == null ? void 0 : s.enableType) === "custom",
$converter: "/converter/column-command.converter",
editor: {
columns: [
{ field: "value", title: "值", dataType: "string" },
// {
// field: 'text', title: '名称', editor: {
// type: 'language-textbox',
// languages: [
// { code: 'zh-CHS', name: '中文简体' },
// { code: 'en', name: '英文' },
// { code: 'zh-CHT', name: '中文繁体' }
// ]
// },
// formatter: {
// type: 'multilingual'
// }
// }
{ field: "text", title: "名称", dataType: "string" }
],
type: "item-collection-editor",
valueField: "value",
nameField: "text",
requiredFields: ["value", "text"],
uniqueFields: ["value", "text"]
}
},
formatter: {
title: "操作列模板",
$converter: "/converter/column-command.converter",
type: "string",
visible: ((m = i.command) == null ? void 0 : m.enableType) === "custom",
description: "操作列模板",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
columnWidth: {
title: "操作列宽度",
type: "number",
$converter: "/converter/column-command.converter",
description: "操作列宽度",
visible: ((d = i.command) == null ? void 0 : d.enableType) === "custom",
editor: {
needValid: !0,
min: 0,
max: 800
}
}
},
setPropertyRelates(p, f) {
var y;
switch (p && p.propertyID) {
case "enableType": {
(p.propertyValue === "custom" || p.propertyValue === "default") && ((y = u.getFormDesignerInstance()) == null || y.reloadPropertyPanel());
break;
}
}
}
};
}
return { getCommandColumnProperties: t };
}
function ee() {
function u(t) {
var i;
return {
title: "合计行",
description: "",
properties: {
enable: {
title: "启用",
type: "boolean",
description: "启用合计行",
$converter: "/converter/summary.converter",
refreshPanelAfterChanged: !0
},
customRender: {
title: "合计行模板",
type: "string",
description: "合计行模板",
$converter: "/converter/summary.converter",
refreshPanelAfterChanged: !0,
visible: !!((i = t.summary) != null && i.enable),
editor: {
type: "code-editor",
language: "html"
}
}
}
};
}
return { getSummaryProperties: u };
}
var U = /* @__PURE__ */ ((u) => (u.Column = "column", u.Group = "group", u))(U || {});
function te() {
function u(t, i) {
var r, s;
return {
title: "分组",
description: "",
properties: {
enable: {
title: "启用",
type: "boolean",
description: "启用分组",
$converter: "/converter/group.converter",
refreshPanelAfterChanged: !0
},
customRender: {
title: "自定义分组行模板",
type: "string",
visible: !!((r = t.group) != null && r.enable),
description: "自定义分组行模板",
$converter: "/converter/group.converter",
editor: {
type: "code-editor",
language: "html"
}
},
groupFields: {
title: "分组字段",
type: "string",
visible: !!((s = t.group) != null && s.enable),
description: "分组字段",
$converter: "/converter/group.converter",
editor: {
type: "grid-field-editor",
usage: U.Group,
viewModelId: i,
gridData: t,
getLatestGridData: (m) => t
}
}
// showSummary: {
// title: '显示分组合计行',
// type: 'boolean',
// visible: !!propertyData.group?.enable,
// $converter: '/converter/group.converter',
// description: '显示分组合计行'
// }
// groupFields: {
// title: '启用',
// type: 'boolean',
// description: '启用分组',
// refreshPanelAfterChanged: true
// }
}
};
}
return { getGroupProperties: u };
}
function re() {
function u(t) {
var s, m, d, p, f, y;
if (t.displayType === "Card")
return [
{
label: "onClickRow",
name: "行点击事件"
},
{
label: "onSelectionChange",
name: "行切换事件"
},
{
label: "onEndEditCell",
name: "单元格结束编辑事件"
}
];
const i = [
{
label: "onClickRow",
name: "行点击事件"
},
{
label: "onSelectionChange",
name: "行切换事件"
},
{
label: "onDoubleClickRow",
name: "行双击事件"
},
{
label: "onFilterChanged",
name: "过滤事件"
},
{
label: "onSelectItem",
name: "选中行事件"
},
{
label: "onUnSelectItem",
name: "取消选中行事件"
},
{
label: "onSelectAll",
name: "全选事件"
},
{
label: "onUnSelectAll",
name: "取消全选事件"
}
];
return t.type !== "tree-grid" && i.push(
{
label: "onSortChanged",
name: "排序事件"
},
{
label: "onEndEditCell",
name: "单元格结束编辑事件"
},
{
label: "beforeEditCell",
name: "单元格编辑前事件"
}
), t.type === "tree-grid" && i.push({
label: "onExpandNode",
name: "展开事件"
}), ((s = t.pagination) == null ? void 0 : s.enable) !== !1 && i.push(
{
label: "onPageIndexChanged",
name: "切换页码事件"
},
{
label: "onPageSizeChanged",
name: "分页条数变化事件"
}
), (m = t.command) != null && m.enable && ((d = t.command) == null ? void 0 : d.enableType) === "custom" && i.push({
label: "onHandleAction",
name: "自定义操作列点击事件"
}), ((p = t.command) == null ? void 0 : p.enable) && (((f = t.command) == null ? void 0 : f.enableType) === "default" || !((y = t.command) != null && y.enableType) && JSON.stringify(t.command.commands) === JSON.stringify([
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
])) && i.push(
{
label: "onClickEditCommand",
name: "操作列编辑事件"
},
{
label: "onClickDeleteCommand",
name: "操作列删除事件"
}
), i;
}
return { initEvent: u };
}
function ne() {
function u(t, i, r) {
var f, y, M, B;
const s = r === "treeGrid", m = (C) => C === !0 || C !== !1 && C != null, d = (f = t.selection) == null ? void 0 : f.multiSelect, p = s && m(d);
return {
title: "多选配置",
$converter: "/converter/grid-selection.converter",
parentPropertyID: "editor",
properties: {
multiSelect: {
title: "启用多选",
type: "boolean",
$converter: "/converter/grid-selection.converter",
refreshPanelAfterChanged: !0
// editor: self.getPropertyEditorParams(propertyData, ['Const', 'Variable', 'Custom', 'StateMachine'], 'multiSelect')
},
showCheckbox: {
visible: !!((y = t.selection) != null && y.multiSelect),
$converter: "/converter/grid-selection.converter",
readonly: !0,
title: "显示复选框",
type: "boolean",
refreshPanelAfterChanged: !0
},
showSelectAll: {
visible: !!((M = t.selection) != null && M.multiSelect) && !!((B = t.selection) != null && B.showCheckbox),
title: "显示全选",
type: "boolean"
// editor: self.getPropertyEditorParams(propertyData, ['Const', 'Variable', 'Custom'], 'showSelectAll')
},
...s ? {
autoCheckParent: {
visible: p,
title: "向上级联",
type: "boolean",
description: "向上级联",
$converter: "/converter/tree-auto-check.converter"
},
autoCheckChildren: {
visible: p,
title: "向下级联",
type: "boolean",
description: "向下级联",
$converter: "/converter/tree-auto-check.converter"
}
} : {}
},
setPropertyRelates(C, R) {
if (C) {
switch (C.propertyID) {
case "multiSelect":
case "showCheckbox":
case "showSelectAll":
i.afterMutilEditorChanged(t, C);
break;
}
switch (C.propertyID) {
case "multiSelect": {
const w = C.propertyValue;
(w === !0 || w === !1) && (t.selection || (t.selection = {}), t.selection.showCheckbox = w);
break;
}
}
}
}
};
}
return { getSelection: u };
}
function ie() {
function u(t) {
var i, r, s, m;
return {
title: "行号配置",
$converter: "/converter/row-number.converter",
parentPropertyID: "rowNumber",
properties: {
enable: {
title: "显示行号",
type: "boolean",
refreshPanelAfterChanged: !0
},
width: {
visible: !!((i = t.rowNumber) != null && i.enable) || ((r = t.rowNumber) == null ? void 0 : r.enable) === void 0,
title: "宽度",
type: "number"
},
heading: {
visible: !!((s = t.rowNumber) != null && s.enable) || ((m = t.rowNumber) == null ? void 0 : m.enable) === void 0,
title: "标题",
type: "string"
}
}
};
}
return { getRowNumber: u };
}
function ae() {
function u(i) {
var s;
const r = (s = i.pagination) == null ? void 0 : s.sizeLimits;
if (Array.isArray(r) && r.length > 0) {
const m = [...new Set(
r.map((d) => parseInt(String(d), 10)).filter((d) => !Number.isNaN(d) && d > 0)
)];
if (m.length > 0)
return m.map((d) => ({ key: d, value: d }));
}
return [
{ key: 10, value: 10 },
{ key: 20, value: 20 },
{ key: 30, value: 30 },
{ key: 50, value: 50 },
{ key: 100, value: 100 }
];
}
function t(i, r, s) {
var m, d, p, f, y;
return {
title: "分页",
$converter: "/converter/pagination.converter",
parentPropertyID: "pagination",
properties: {
enable: {
title: "启用分页",
type: "boolean",
refreshPanelAfterChanged: !0,
editor: {
readonly: r
}
},
// mode: {
// visible: propertyData.pagination?.enable || false,
// title: '分页交互模式',
// type: "enum",
// editor: {
// type: "combo-list",
// textField: "value",
// valueField: "key",
// data: [{ "key": "client", "value": "客户端" }, { "key": "server", "value": "服务器端" }]
// }
// },
showIndex: {
visible: !!((m = i.pagination) != null && m.enable),
title: "显示页码",
type: "boolean"
},
showLimits: {
visible: !!((d = i.pagination) != null && d.enable),
title: "显示分页条数",
type: "boolean"
},
// disabled: {
// visible: !!propertyData.pagination?.enable,
// title: '锁定分页',
// type: 'boolean',
// // editor: self.getPropertyEditorParams(propertyData, ['Const', 'Custom'], 'disabled')
// },
sizeLimits: {
visible: !!((p = i.pagination) != null && p.enable),
title: "分页条数",
type: "string",
refreshPanelAfterChanged: !0
},
size: {
visible: !!((f = i.pagination) != null && f.enable),
title: "默认分页条数",
type: "enum",
defaultValue: 20,
editor: {
type: "combo-list",
textField: "value",
valueField: "key",
data: u(i)
}
},
showGoto: {
visible: !!((y = i.pagination) != null && y.enable),
title: "显示页码输入框",
type: "boolean"
}
},
setPropertyRelates(M, B) {
var C, R, w;
if (M)
switch (M.propertyID) {
case "disabled":
s.afterMutilEditorChanged(i, M);
break;
case "sizeLimits": {
const l = (C = i.pagination) == null ? void 0 : C.sizeLimits;
if (Array.isArray(l) && l.length > 0) {
const c = Number((R = i.pagination) == null ? void 0 : R.size);
l.includes(c) || (i.pagination.size = l[0]);
} else {
const c = [10, 20, 30, 50, 100], h = Number((w = i.pagination) == null ? void 0 : w.size);
c.includes(h) || (i.pagination.size = 20);
}
break;
}
}
}
};
}
return { getPagination: t };
}
function le(u) {
function t(s) {
return s.displayType === "Card" ? {
showStripe: {
title: "显示条纹",
type: "boolean",
description: "是否显示条纹"
},
showBorder: {
title: "显示边框",
type: "boolean",
description: "是否显示边框"
}
} : {
showStripe: {
title: "显示条纹",
type: "boolean",
description: "是否显示条纹"
},
showBorder: {
title: "显示边框",
type: "boolean",
description: "是否显示边框"
},
showSetting: {
title: "显示设置按钮",
type: "boolean",
description: "是否显示设置按钮",
refreshPanelAfterChanged: !0
},
enableColumnSettingSolution: {
title: "启用列设置方案",
type: "boolean",
description: "启用列设置方案",
visible: !!s.showSetting
},
emptyTemplate: {
title: "空模板",
type: "string",
description: "空模板",
editor: {
type: "code-editor",
language: "html"
}
},
virtualized: {
title: "是否虚拟加载",
type: "boolean",
description: "是否虚拟加载"
}
// disabled: {
// title: '禁用',
// type: 'boolean',
// refreshPanelAfterChanged: true,
// editor: self.getPropertyEditorParams(propertyData, ['Const', 'Custom'])
// },
};
}
function i(s, m) {
return {
title: "外观",
properties: {
class: {
title: "class样式",
type: "string",
description: "组件的class样式"
},
columns: {
title: "列设置",
description: "列设置",
type: "array",
editor: {
type: "grid-field-editor",
viewModelId: m,
gridData: s,
getLatestGridData: (d) => s
},
// 这个属性,标记当属性变更得时候触发重新更新属性
refreshPanelAfterChanged: !0
},
...t(s)
// useBlankWhenDataIsEmpty: {
// title: '空数据表格显示空白行',
// description: '表格没有数据时是否显示空白行',
// type: 'boolean',
// refreshPanelAfterChanged: true
// },
// emptyDataHeight: {
// title: '空数据高度',
// type: 'number',
// description: '空数据行高度设置',
// min: 1,
// max: 1000
// },
},
setPropertyRelates(d, p) {
switch (d && d.propertyID) {
case "useBlankWhenDataIsEmpty":
s.emptyDataHeight = s.useBlankWhenDataIsEmpty ? 36 : 240;
break;
case "columns":
s.columns = d.propertyValue || [];
break;
}
}
};
}
function r(s, m, d) {
const p = d.schemaService.getTreeGridUdtFields(m);
return {
title: "外观",
properties: {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式"
},
columns: {
title: "列设置",
description: "列设置",
$converter: "/converter/items-count.converter",
editor: {
type: "grid-field-editor",
viewModelId: m,
gridData: s,
gridType: "tree-grid-column"
},
// 这个属性,标记当属性变更得时候触发重新更新属性
refreshPanelAfterChanged: !0
},
udtField: {
title: "分级码字段",
type: "enum",
description: "分级码字段",
refreshPanelAfterChanged: !0,
editor: {
data: p.map((f) => ({ id: f.key, name: f.value }))
}
},
searchable: {
title: "启用搜索定位",
type: "boolean",
description: "启用搜索定位"
},
...t(s)
// showTreeNodeIcons: {
// title: '显示图标',
// type: "boolean",
// description: '是否显示图标'
// },
// showSetting: {
// title: '显示设置按钮',
// type: "boolean",
// description: '是否显示设置按钮',
// visible:false
// }
},
setPropertyRelates(f, y) {
switch (f && f.propertyID) {
case "useBlankWhenDataIsEmpty":
s.emptyDataHeight = s.useBlankWhenDataIsEmpty ? 36 : 240;
break;
case "fields":
s.fields = f.propertyValue || [];
break;
}
}
};
}
return { getDataGrid: i, getTreeGrid: r };
}
function oe() {
function u(t) {
return {
title: "排序",
description: "",
properties: {
mode: {
title: "类型",
type: "enum",
description: "排序类型",
$converter: "/converter/grid-sort.converter",
editor: {
data: [
{ id: "client", name: "客户端" },
{ id: "server", name: "服务端" }
]
}
}
// multiSort: {
// title: '启用多列排序',
// type: 'boolean',
// description: '启用多列排序',
// $converter: '/converter/grid-sort.converter'
// }
}
};
}
return { getSort: u };
}
function se() {
function u(t) {
return {
title: "过滤",
description: "",
properties: {
filterStyle: {
title: "过滤风格",
type: "enum",
description: "过滤风格",
$converter: "/converter/grid-filter.converter",
editor: {
data: [
{ id: "filter-column", name: "智能过滤" },
{ id: "filter-row", name: "过滤行" }
]
}
},
mode: {
title: "类型",
type: "enum",
description: "过滤类型",
$converter: "/converter/grid-filter.converter",
editor: {
data: [
{ id: "client", name: "客户端" },
{ id: "server", name: "服务端" }
]
}
}
}
};
}
return { getFilter: u };
}
function ue(u, t) {
const { messagerService: i, designViewModelUtils: r, controlCreatorUtils: s, formStateMachineUtils: m, formSchemaUtils: d } = u, p = new J();
let f = "editable";
function y(l) {
l.renderState || (l.renderState = {});
const c = {
condition: [
{ lBracket: null, source: "state", compare: "===", target: "'add'", relation: "or", rBracket: "" },
{ lBracket: null, source: "state", compare: "===", target: "'edit'", relation: "", rBracket: "" }
],
name: "可编辑",
description: ""
};
return l.renderState.editable ? l.renderState.editable.condition && JSON.stringify(l.renderState.editable.condition) === JSON.stringify(c.condition) ? !1 : (l.renderState.gridEditable = Object.assign(c, { name: "表格可编辑" }), f = "gridEditable", !0) : (l.renderState.editable = c, !0);
}
function M() {
return {
renderState: {
canAdd: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'add'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'init'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'edit'",
relation: "",
rBracket: ""
}
],
name: "新增",
description: ""
},
canEdit: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'init'",
relation: "",
rBracket: ""
}
],
name: "编辑",
description: ""
},
canCancel: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'add'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'edit'",
relation: "",
rBracket: ""
}
],
name: "取消",
description: ""
},
canSave: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'add'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'edit'",
relation: "",
rBracket: ""
}
],
name: "保存",
description: ""
},
canRemove: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'add'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'edit'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'init'",
relation: "",
rBracket: ""
}
],
name: "删除",
description: ""
},
editable: {
condition: [
{
lBracket: null,
source: "state",
compare: "===",
target: "'add'",
relation: "or",
rBracket: ""
},
{
lBracket: null,
source: "state",
compare: "===",
target: "'edit'",
relation: "",
rBracket: ""
}
],
name: "可编辑",
description: ""
}
},
state: [
{
state: "add",
name: "新增",
description: "处于新增状态"
},
{
state: "init",
name: "初始",
description: "处于初始状态"
},
{
state: "edit",
name: "编辑",
description: "处于编辑状态"
}
],
initialState: "init",
action: {
Create: {
name: "创建",
transitTo: "add",
description: "新建并切换至新增状态"
},
Edit: {
name: "编辑",
transitTo: "edit",
description: "编辑并切换至编辑状态"
},
Cancel: {
name: "取消",
transitTo: "init",
description: "取消并切换至初始状态"
},
Save: {
name: "保存",
transitTo: "init",
description: "保存并切换至初始状态"
}
}
};
}
async function B() {
var E, P;
const l = M(), c = await m.createStateMachine(l), h = d.getFormSchema().module;
((E = h.stateMachines) == null ? void 0 : E.length) === 0 && h.stateMachines.push({
id: `${h.code}_state_machine`,
name: c.name,
uri: c.id,
code: c.code,
nameSpace: c.nameSpace
});
const k = ((P = h.viewmodels) == null ? void 0 : P.length) > 0 ? h.viewmodels[0] : null;
k && (k.stateMachine = `${h.code}_state_machine`);
}
async function C() {
const l = m.getStateMachineMetadata();
let c = !1;
l.state || (l.state = []), l.state.find((h) => h.state === "init") || (l.state.push({ state: "init", name: "初始", description: "处于初始状态" }), c = !0), l.state.find((h) => h.state === "add") || (l.state.push({ state: "add", name: "新增", description: "处于新增状态" }), c = !0), l.state.find((h) => h.state === "edit") || (l.state.push({ state: "edit", name: "编辑", description: "处于编辑状态" }), c = !0), l.action || (l.action = {}), l.action.Cancel || (l.action.Cancel = { name: "取消", transitTo: "init", description: "取消并切换至初始状态" }, c = !0), l.action.Create || (l.action.Create = { name: "创建", transitTo: "add", description: "新建并切换至新增状态" }, c = !0), l.action.Edit || (l.action.Edit = { name: "编辑", transitTo: "edit", description: "编辑并切换至编辑状态" }, c = !0), l.action.Save || (l.action.Save = { name: "保存", transitTo: "init", description: "保存并切换至初始状态" }, c = !0), y(l) && (c = !0), c && await m.saveStateMachineMetadata(l);
}
async function R(l) {
var k;
m.getStateMachineMetadata() ? await C() : await B(), l.fieldEditable = !0, l.editable = `viewModel.stateMachine['${f}']`, (k = l.pagination) != null && k.enable && (l.pagination.disabled = `viewModel.stateMachine['${f}']`), l.disabled = !1;
const h = r.getDgViewModel(t);
l.columns.map((E) => {
const P = h.fields.find((o) => o.id === E.binding.field);
if (!P)
return;
const W = s.setFormFieldProperty(P);
E.editor = W.editor, E.editor.readonly && typeof E.editor.readonly == "object" && (E.editor.readonly.field = f);
}), p.success({ position: "top-center", message: "已启用单元格编辑" });
}
function w(l) {
return {
title: "单元格编辑",
description: "",
properties: {
fieldEditable: {
title: "启用",
type: "boolean",
description: "单元格是否可编辑",
refreshPanelAfterChanged: !0,
readonly: l.fieldEditable
}
},
async setPropertyRelates(c, h) {
return await new Promise((k) => {
c.propertyValue && i.question("启用单元格编辑后,将根据表格或者树表列绑定的字段类型自动分配编辑器,此操作不可撤销,是否继续?", "", async () => {
await R(l), k();
}, () => {
h.fieldEditable = !1, k();
});
});
}
};
}
return { getCellEditableProperties: w };
}
export {
le as useAppearance,
ue as useCellEditable,
x as useColumnOption,
j as useCommandOption,
re as useDataGridEvent,
Q as useDesignerColumn,
Y as useDesignerFitColumn,
X as useDesignerVisualData,
se as useFilter,
te as useGroup,
ae as usePagination,
ie as useRowNumber,
Z as useRowOption,
ne as useSelection,
oe as useSort,
ee as useSummary
};