@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
1,392 lines (1,390 loc) • 43.5 kB
JavaScript
import { computed as V, watch as H, ref as $, createVNode as F, Fragment as z, createTextVNode as D } from "vue";
import { FNotifyService as U } from "../../components/notify/index.esm.js";
function Y(s, t, u, n, l) {
const { getGridHeaderCells: c } = l, m = 120, f = 50, h = V(() => {
var e;
return ((e = s.rowNumber) == null ? void 0 : e.enable) || !1;
}), b = V(() => {
var e, r;
return ((e = s.selection) == null ? void 0 : e.multiSelect) === !0 || ((r = s.selection) == null ? void 0 : r.showCheckbox) === !0;
}), R = V(
() => {
var e;
return 0 + (h.value ? ((e = s.rowNumber) == null ? void 0 : e.width) || 32 : 0) + (b.value ? f : 0);
}
), P = V(() => {
var e;
return (e = s.columnOption) == null ? void 0 : e.fitColumns;
}), w = V(() => {
var e;
return P.value && ((e = s.columnOption) == null ? void 0 : e.fitMode) || "none";
});
function A(e, r, i) {
const g = parseInt(e.width, 10) / 100;
return i * g;
}
function W(e, r, i) {
return typeof e.width == "string" ? A(e, r, i) : e.width || m;
}
function o(e, r) {
const i = [], g = [];
let y = 0;
e.value.primaryColumns.forEach((C) => {
typeof C.width == "string" ? g.push(C) : (C.width = C.width || m, y += C.width, i.push(C));
});
const _ = r * (i.length / e.value.primaryColumns.length);
i.forEach((C) => {
const v = _ * (C.width / y);
C.actualWidth = v, e.value.primaryColumnsWidth += C.actualWidth;
});
const T = r - _;
g.forEach((C) => {
const v = A(C, e.value, T);
C.actualWidth = v, e.value.primaryColumnsWidth += C.actualWidth;
});
}
function d(e, r) {
const i = [], g = [], y = /* @__PURE__ */ new WeakMap();
let _ = 0, T = 0;
if (e.value.primaryColumns.forEach((v) => {
if (typeof v.width == "string") {
const B = A(v, e.value, r);
y.set(v, B), _ += B, g.push(v);
} else
v.width = v.width || m, T += v.width, i.push(v);
}), r - _ > T) {
const v = r - _;
g.forEach((B) => {
B.actualWidth = y.get(B) || m, e.value.primaryColumnsWidth += B.actualWidth;
}), i.forEach((B) => {
B.actualWidth = v * (B.width / T), e.value.primaryColumnsWidth += B.actualWidth;
});
} else
o(e, r);
}
function p(e, r) {
e.value.primaryColumns.forEach((i) => {
i.actualWidth = W(i, e.value, r), e.value.primaryColumnsWidth += i.actualWidth;
});
}
const k = {
expand: d,
none: p,
percentage: o
};
function E(e) {
e.value.leftHeaderColumns = Array.from(c(e.value.leftColumns).values()), e.value.primaryHeaderColumns = Array.from(c(e.value.primaryColumns).values()), e.value.rightHeaderColumns = Array.from(c(e.value.rightColumns).values());
}
function M(e) {
e.value.leftColumnsWidth = 0, e.value.primaryColumnsWidth = 0, e.value.rightColumnsWidth = 0, e.value.leftColumns.forEach((r) => {
e.value.leftColumnsWidth += r.actualWidth || 0;
}), e.value.primaryColumns.forEach((r) => {
e.value.primaryColumnsWidth += r.actualWidth || 0;
}), e.value.rightColumns.forEach((r) => {
e.value.rightColumnsWidth += r.actualWidth || 0;
}), e.value = Object.assign({}, e.value);
}
function S(e, r, i) {
var B;
let g = 0;
const y = e.value.primaryColumns, _ = e.value.rightColumns;
e.value.rightColumns.forEach((I) => {
I.actualWidth = W(I, e.value, r), g += I.actualWidth;
});
const T = i - g, C = k[w.value];
if (C && C(e, T), e.value.primaryColumnsWidth + g <= i)
return e.value.primaryColumns = [...y, ..._], 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, N) => {
var O, G;
return N.fixed === "right" ? (O = I.get("right")) == null || O.push(N) : (G = I.get("primary")) == null || G.push(N), I;
}, v), (B = v.get("right")) != null && B.length && (e.value.primaryColumns = [...v.get("primary") || []], e.value.rightColumns = [...v.get("right") || []]), e.value.primaryColumnsWidth = 0, e.value.rightColumnsWidth = 0, !1;
}
function a() {
if (u.value) {
t.value.leftColumnsWidth = 0, t.value.primaryColumnsWidth = 0, t.value.rightColumnsWidth = 0;
const e = u.value.clientWidth - R.value;
t.value.leftColumns.forEach((i) => {
i.actualWidth = W(i, t.value, e), t.value.leftColumnsWidth += i.actualWidth;
});
const r = e - t.value.leftColumnsWidth;
if (S(t, e, r))
n.value = r;
else {
t.value.rightColumns.forEach((y) => {
y.actualWidth = W(y, t.value, e), t.value.rightColumnsWidth += y.actualWidth;
});
const i = e - t.value.leftColumnsWidth - t.value.rightColumnsWidth, g = k[w.value];
g && g(t, i), n.value = i;
}
E(t), t.value = Object.assign({}, t.value);
}
}
return H(() => {
var e;
return (e = s.columnOption) == null ? void 0 : e.fitColumns;
}, (e, r) => {
e !== r && e && a();
}), H(w, (e, r) => {
e !== r && P.value && a();
}), { calculateColumnHeaders: E, calculateColumnsSize: a, calculateColumnsWidth: M };
}
const J = "";
function Q(s) {
const n = $({
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 l() {
n.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 c = $(s.summary), m = V(() => {
const a = c.value;
return (a == null ? void 0 : a.groupFields) || [];
});
function f() {
n.value.rightColumns.forEach((r) => {
r.showSetting = !1;
}), n.value.primaryColumns.forEach((r) => {
r.showSetting = !1;
});
const a = n.value.rightColumns, e = n.value.primaryColumns;
a.length > 0 ? a[a.length - 1].showSetting = !0 : e.length > 0 && (e[e.length - 1].showSetting = !0);
}
function h(a) {
l();
const e = /* @__PURE__ */ new Map();
return m.value && m.value.reduce((r, i) => (r.set(i, !0), r), e), a.reduce((r, i) => (i.filter = i.filter || J, i.fixed === "left" ? (n.value.leftColumns.push(i), n.value.leftColumnsMap.set(i.field, i), n.value.leftColumnsWidth += i.actualWidth) : i.fixed === "right" ? (n.value.rightColumns.push(i), n.value.rightColumnsMap.set(i.field, i), n.value.rightColumnsWidth += i.actualWidth) : (n.value.primaryColumns.push(i), n.value.primaryColumnsMap.set(i.field, i), n.value.primaryColumnsWidth += i.actualWidth), e.has(i.field) && n.value.summaryColumns.push(i), r), n), f(), n;
}
h(s.columns);
const b = V(() => n.value.leftColumns.length > 0), R = V(() => n.value.rightColumns.length > 0);
function P(a, e) {
return e.sortable && e.sort && e.sort !== "none" && a.push(e), a;
}
function w(a, e) {
return a.sortOrder = a.sortOrder || 0, e.sortOrder = e.sortOrder || 0, a.sortOrder === e.sortOrder ? 0 : a.sortOrder < e.sortOrder ? -1 : 1;
}
function A(a, e) {
return a.sortOrder = a.sortOrder || 0, e.sortOrder = e.sortOrder || 0, a.sortOrder === e.sortOrder ? 0 : a.sortOrder < e.sortOrder ? 1 : -1;
}
function W(a, e) {
return e.filterable && a.push(e), a;
}
function o() {
const a = [];
return n.value.leftColumns.reduce(W, a), n.value.primaryColumns.reduce(W, a), n.value.rightColumns.reduce(W, a), a;
}
function d() {
const a = [];
n.value.leftColumns.reduce(P, a), n.value.primaryColumns.reduce(P, a), n.value.rightColumns.reduce(P, a);
const e = Math.max(...a.map((r) => r.sortOrder || 0));
return a.sort(A).map((r) => {
const i = r.sortOrder || e + 1;
return r.sortOrder = i, r;
}).sort(w).map((r, i) => {
const g = i + 1;
return r.sortOrder = g, r;
});
}
function p(a, e, r) {
const i = a.map((g) => {
const y = r.getSorterByColumn(g), _ = g.sort === "asc", T = g.sort === "desc", C = _ ? y.ascend : T ? y.decend : void 0;
return { field: g.field, compare: C };
});
e.setSorters(i);
}
function k(a, e) {
const r = d();
p(r, a, e);
}
function E(a) {
}
function M(a) {
}
function S() {
}
return {
applyColumnSorter: k,
collectionFilterableColumns: o,
applySortableColumns: p,
collectionSortableColumns: d,
columnContext: n,
hasLeftFixedColumn: b,
hasRightFixedColumn: R,
updateColumnRenderContext: h,
updateColumnSettingIcon: f,
sortFromServer: E,
createSortConditions: M,
clearSortConditions: S
};
}
function X(s, t, u, n, l, c, m, f) {
const h = $(n.value - 1 + l), b = $(0), { renderDataRow: R } = c, P = m ? m.renderGroupRow : R, w = f ? f.renderSummaryRow : R;
function A(d) {
let p = R;
return d.__fv_data_grid_group_row__ && (p = P), d.__fv_data_grid_group_summary__ && (p = w), p;
}
function W(d, p, k, E) {
const { dataView: M } = u, S = [];
if (M.value.length > 0) {
const a = E ? Date.now().toString() : "";
let e = d, r = 0;
const i = p - d + 1;
for (; S.length < i && e < M.value.length; ) {
const g = M.value[e], y = M.value[e - 1] || k, _ = S[r - 1], T = y ? (y.__fv_data_position__ || 0) + (y.__fv_data_height__ || 0) : 0, v = A(g)(g, y, _, e, T, t.value, S);
v.refreshKey = a, S.push(v), r++, e++;
}
}
return b.value = S.length > 0 ? S[0].index : 0, h.value = S.length > 0 ? S[S.length - 1].index : 0, S;
}
function o(d, p, k) {
const E = p.groupField || "", { groupValue: M, raw: S } = p;
u[d](E, M, S.groupParents || []);
const { dataView: a } = u, e = k[0].index, r = Math.min(e + n.value + l + 1, a.value.length - 1);
return W(e, r);
}
return { getVisualData: W, maxVisibleRowIndex: h, minVisibleRowIndex: b, toggleGroupRow: o };
}
function Z() {
function s(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: () => F(z, null, [F("h5", null, [D("示例代码")]), F("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: () => F(z, null, [F("h5", null, [D("示例代码")]), F("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: s
};
}
function x() {
function s(t) {
return {
title: "填充列宽",
description: "",
properties: {
fitColumns: {
title: "启用",
type: "boolean",
description: "启用填充列宽",
$converter: "/converter/column-option.converter",
refreshPanelAfterChanged: !0
}
// fitMode: {
// description: '',
// title: '填充模式',
// type: 'enum',
// visible: !!propertyData.column?.fitColumns,
// $converter: '/converter/column-option.converter',
// editor: {
// data: [
// { id: 'average', name: '平分' },
// { id: 'expand', name: '等比' }
// ]
// }
// },
},
setPropertyRelates(u, n) {
switch (u && u.propertyID) {
case "fitColumns": {
n.fit = u.propertyValue, n.columns && (u.propertyValue ? n.columns.forEach((l) => {
l.resizable = !1;
}) : n.columns.forEach((l) => {
l.resizable = !0;
}));
break;
}
}
}
};
}
return { getColumnOptionProperties: s };
}
function j(s) {
function t(u) {
var n, l, c, m;
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: ((n = u.command) == null ? void 0 : n.enableType) === "custom",
editor: {
needValid: !0,
min: 0
}
},
commands: {
description: "操作列按钮集合",
title: "操作项",
type: "array",
visible: ((l = u.command) == null ? void 0 : l.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: ((c = u.command) == null ? void 0 : c.enableType) === "custom",
description: "操作列模板",
refreshPanelAfterChanged: !0,
editor: {
type: "code-editor",
language: "html"
}
},
columnWidth: {
title: "操作列宽度",
type: "number",
$converter: "/converter/column-command.converter",
description: "操作列宽度",
visible: ((m = u.command) == null ? void 0 : m.enableType) === "custom",
editor: {
needValid: !0,
min: 0,
max: 800
}
}
},
setPropertyRelates(f, h) {
var b;
switch (f && f.propertyID) {
case "enableType": {
(f.propertyValue === "custom" || f.propertyValue === "default") && ((b = s.getFormDesignerInstance()) == null || b.reloadPropertyPanel());
break;
}
}
}
};
}
return { getCommandColumnProperties: t };
}
function ee() {
function s(t) {
var u;
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: !!((u = t.summary) != null && u.enable),
editor: {
type: "code-editor",
language: "html"
}
}
}
};
}
return { getSummaryProperties: s };
}
var L = /* @__PURE__ */ ((s) => (s.Column = "column", s.Group = "group", s))(L || {});
function te() {
function s(t, u) {
var n, l;
return {
title: "分组",
description: "",
properties: {
enable: {
title: "启用",
type: "boolean",
description: "启用分组",
$converter: "/converter/group.converter",
refreshPanelAfterChanged: !0
},
customRender: {
title: "自定义分组行模板",
type: "string",
visible: !!((n = t.group) != null && n.enable),
description: "自定义分组行模板",
$converter: "/converter/group.converter",
editor: {
type: "code-editor",
language: "html"
}
},
groupFields: {
title: "分组字段",
type: "string",
visible: !!((l = t.group) != null && l.enable),
description: "分组字段",
$converter: "/converter/group.converter",
editor: {
type: "grid-field-editor",
usage: L.Group,
viewModelId: u,
gridData: t,
getLatestGridData: (c) => t
}
}
// showSummary: {
// title: '显示分组合计行',
// type: 'boolean',
// visible: !!propertyData.group?.enable,
// $converter: '/converter/group.converter',
// description: '显示分组合计行'
// }
// groupFields: {
// title: '启用',
// type: 'boolean',
// description: '启用分组',
// refreshPanelAfterChanged: true
// }
}
};
}
return { getGroupProperties: s };
}
function re() {
function s(t) {
var l, c, m, f, h, b;
if (t.displayType === "Card")
return [
{
label: "onClickRow",
name: "行点击事件"
},
{
label: "onSelectionChange",
name: "行切换事件"
},
{
label: "onEndEditCell",
name: "单元格结束编辑事件"
}
];
const u = [
{
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" && u.push(
{
label: "onSortChanged",
name: "排序事件"
},
{
label: "onEndEditCell",
name: "单元格结束编辑事件"
},
{
label: "beforeEditCell",
name: "单元格编辑前事件"
}
), t.type === "tree-grid" && u.push({
label: "onExpandNode",
name: "展开事件"
}), ((l = t.pagination) == null ? void 0 : l.enable) !== !1 && u.push(
{
label: "onPageIndexChanged",
name: "切换页码事件"
},
{
label: "onPageSizeChanged",
name: "分页条数变化事件"
}
), (c = t.command) != null && c.enable && ((m = t.command) == null ? void 0 : m.enableType) === "custom" && u.push({
label: "onHandleAction",
name: "自定义操作列点击事件"
}), ((f = t.command) == null ? void 0 : f.enable) && (((h = t.command) == null ? void 0 : h.enableType) === "default" || !((b = t.command) != null && b.enableType) && JSON.stringify(t.command.commands) === JSON.stringify([
{
text: "编辑",
type: "primary",
command: "edit"
},
{
text: "删除",
type: "danger",
command: "remove"
}
])) && u.push(
{
label: "onClickEditCommand",
name: "操作列编辑事件"
},
{
label: "onClickDeleteCommand",
name: "操作列删除事件"
}
), u;
}
return { initEvent: s };
}
function ne() {
function s(t, u, n) {
var h, b, R, P;
const l = n === "treeGrid", c = (w) => w === !0 || w !== !1 && w != null, m = (h = t.selection) == null ? void 0 : h.multiSelect, f = l && c(m);
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: !!((b = t.selection) != null && b.multiSelect),
$converter: "/converter/grid-selection.converter",
readonly: !0,
title: "显示复选框",
type: "boolean",
refreshPanelAfterChanged: !0
},
showSelectAll: {
visible: !!((R = t.selection) != null && R.multiSelect) && !!((P = t.selection) != null && P.showCheckbox),
title: "显示全选",
type: "boolean"
// editor: self.getPropertyEditorParams(propertyData, ['Const', 'Variable', 'Custom'], 'showSelectAll')
},
...l ? {
autoCheckParent: {
visible: f,
title: "向上级联",
type: "boolean",
description: "向上级联",
$converter: "/converter/tree-auto-check.converter"
},
autoCheckChildren: {
visible: f,
title: "向下级联",
type: "boolean",
description: "向下级联",
$converter: "/converter/tree-auto-check.converter"
}
} : {}
},
setPropertyRelates(w, A) {
if (w) {
switch (w.propertyID) {
case "multiSelect":
case "showCheckbox":
case "showSelectAll":
u.afterMutilEditorChanged(t, w);
break;
}
switch (w.propertyID) {
case "multiSelect": {
const W = w.propertyValue;
(W === !0 || W === !1) && (t.selection || (t.selection = {}), t.selection.showCheckbox = W);
break;
}
}
}
}
};
}
return { getSelection: s };
}
function ie() {
function s(t) {
var u, n, l, c;
return {
title: "行号配置",
$converter: "/converter/row-number.converter",
parentPropertyID: "rowNumber",
properties: {
enable: {
title: "显示行号",
type: "boolean",
refreshPanelAfterChanged: !0
},
width: {
visible: !!((u = t.rowNumber) != null && u.enable) || ((n = t.rowNumber) == null ? void 0 : n.enable) === void 0,
title: "宽度",
type: "number"
},
heading: {
visible: !!((l = t.rowNumber) != null && l.enable) || ((c = t.rowNumber) == null ? void 0 : c.enable) === void 0,
title: "标题",
type: "string"
}
}
};
}
return { getRowNumber: s };
}
function ae() {
function s(t, u, n) {
var l, c, m, f;
return {
title: "分页",
$converter: "/converter/pagination.converter",
parentPropertyID: "pagination",
properties: {
enable: {
title: "启用分页",
type: "boolean",
refreshPanelAfterChanged: !0,
editor: {
readonly: u
}
},
// 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: !!((l = t.pagination) != null && l.enable),
title: "显示页码",
type: "boolean"
},
showLimits: {
visible: !!((c = t.pagination) != null && c.enable),
title: "显示分页条数",
type: "boolean"
},
// disabled: {
// visible: !!propertyData.pagination?.enable,
// title: '锁定分页',
// type: 'boolean',
// // editor: self.getPropertyEditorParams(propertyData, ['Const', 'Custom'], 'disabled')
// },
size: {
visible: !!((m = t.pagination) != null && m.enable),
title: "默认分页条数",
type: "enum",
defaultValue: 20,
editor: {
type: "combo-list",
textField: "value",
valueField: "key",
data: [
{ key: 10, value: 10 },
{ key: 20, value: 20 },
{ key: 30, value: 30 },
{ key: 50, value: 50 },
{ key: 100, value: 100 }
]
}
},
// sizeLimits: {
// visible: !!propertyData.pagination?.enable,
// $converter: '/converter/pagination.converter',
// title: '分页条数',
// type: 'string'
// },
showGoto: {
visible: !!((f = t.pagination) != null && f.enable),
title: "显示页码输入框",
type: "boolean"
}
},
setPropertyRelates(h, b) {
if (h)
switch (h.propertyID) {
case "disabled":
n.afterMutilEditorChanged(t, h);
break;
}
}
};
}
return { getPagination: s };
}
function le(s) {
function t(l) {
return l.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: !!l.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 u(l, c) {
return {
title: "外观",
properties: {
class: {
title: "class样式",
type: "string",
description: "组件的class样式"
},
columns: {
title: "列设置",
description: "列设置",
type: "array",
editor: {
type: "grid-field-editor",
viewModelId: c,
gridData: l,
getLatestGridData: (m) => l
},
// 这个属性,标记当属性变更得时候触发重新更新属性
refreshPanelAfterChanged: !0
},
...t(l)
// useBlankWhenDataIsEmpty: {
// title: '空数据表格显示空白行',
// description: '表格没有数据时是否显示空白行',
// type: 'boolean',
// refreshPanelAfterChanged: true
// },
// emptyDataHeight: {
// title: '空数据高度',
// type: 'number',
// description: '空数据行高度设置',
// min: 1,
// max: 1000
// },
},
setPropertyRelates(m, f) {
switch (m && m.propertyID) {
case "useBlankWhenDataIsEmpty":
l.emptyDataHeight = l.useBlankWhenDataIsEmpty ? 36 : 240;
break;
case "columns":
l.columns = m.propertyValue || [];
break;
}
}
};
}
function n(l, c, m) {
const f = m.schemaService.getTreeGridUdtFields(c);
return {
title: "外观",
properties: {
class: {
title: "class样式",
type: "string",
description: "组件的CSS样式"
},
columns: {
title: "列设置",
description: "列设置",
$converter: "/converter/items-count.converter",
editor: {
type: "grid-field-editor",
viewModelId: c,
gridData: l,
gridType: "tree-grid-column"
},
// 这个属性,标记当属性变更得时候触发重新更新属性
refreshPanelAfterChanged: !0
},
udtField: {
title: "分级码字段",
type: "enum",
description: "分级码字段",
refreshPanelAfterChanged: !0,
editor: {
data: f.map((h) => ({ id: h.key, name: h.value }))
}
},
...t(l)
// showTreeNodeIcons: {
// title: '显示图标',
// type: "boolean",
// description: '是否显示图标'
// },
// showSetting: {
// title: '显示设置按钮',
// type: "boolean",
// description: '是否显示设置按钮',
// visible:false
// }
},
setPropertyRelates(h, b) {
switch (h && h.propertyID) {
case "useBlankWhenDataIsEmpty":
l.emptyDataHeight = l.useBlankWhenDataIsEmpty ? 36 : 240;
break;
case "fields":
l.fields = h.propertyValue || [];
break;
}
}
};
}
return { getDataGrid: u, getTreeGrid: n };
}
function oe() {
function s(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: s };
}
function se() {
function s(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: s };
}
function ue(s, t) {
const { messagerService: u, designViewModelUtils: n, controlCreatorUtils: l, formStateMachineUtils: c, formSchemaUtils: m } = s, f = new U();
let h = "editable";
function b(o) {
o.renderState || (o.renderState = {});
const d = {
condition: [
{ lBracket: null, source: "state", compare: "===", target: "'add'", relation: "or", rBracket: "" },
{ lBracket: null, source: "state", compare: "===", target: "'edit'", relation: "", rBracket: "" }
],
name: "可编辑",
description: ""
};
return o.renderState.editable ? o.renderState.editable.condition && JSON.stringify(o.renderState.editable.condition) === JSON.stringify(d.condition) ? !1 : (o.renderState.gridEditable = Object.assign(d, { name: "表格可编辑" }), h = "gridEditable", !0) : (o.renderState.editable = d, !0);
}
function R() {
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 P() {
var E, M;
const o = R(), d = await c.createStateMachine(o), p = m.getFormSchema().module;
((E = p.stateMachines) == null ? void 0 : E.length) === 0 && p.stateMachines.push({
id: `${p.code}_state_machine`,
name: d.name,
uri: d.id,
code: d.code,
nameSpace: d.nameSpace
});
const k = ((M = p.viewmodels) == null ? void 0 : M.length) > 0 ? p.viewmodels[0] : null;
k && (k.stateMachine = `${p.code}_state_machine`);
}
async function w() {
const o = c.getStateMachineMetadata();
let d = !1;
o.state || (o.state = []), o.state.find((p) => p.state === "init") || (o.state.push({ state: "init", name: "初始", description: "处于初始状态" }), d = !0), o.state.find((p) => p.state === "add") || (o.state.push({ state: "add", name: "新增", description: "处于新增状态" }), d = !0), o.state.find((p) => p.state === "edit") || (o.state.push({ state: "edit", name: "编辑", description: "处于编辑状态" }), d = !0), o.action || (o.action = {}), o.action.Cancel || (o.action.Cancel = { name: "取消", transitTo: "init", description: "取消并切换至初始状态" }, d = !0), o.action.Create || (o.action.Create = { name: "创建", transitTo: "add", description: "新建并切换至新增状态" }, d = !0), o.action.Edit || (o.action.Edit = { name: "编辑", transitTo: "edit", description: "编辑并切换至编辑状态" }, d = !0), o.action.Save || (o.action.Save = { name: "保存", transitTo: "init", description: "保存并切换至初始状态" }, d = !0), b(o) && (d = !0), d && await c.saveStateMachineMetadata(o);
}
async function A(o) {
var k;
c.getStateMachineMetadata() ? await w() : await P(), o.fieldEditable = !0, o.editable = `viewModel.stateMachine['${h}']`, (k = o.pagination) != null && k.enable && (o.pagination.disabled = `viewModel.stateMachine['${h}']`);
const p = n.getDgViewModel(t);
o.columns.map((E) => {
const M = p.fields.find((a) => a.id === E.binding.field);
if (!M)
return;
const S = l.setFormFieldProperty(M);
E.editor = S.editor, E.editor.readonly && typeof E.editor.readonly == "object" && (E.editor.readonly.field = h);
}), f.success({ position: "top-center", message: "已启用单元格编辑" });
}
function W(o) {
return {
title: "单元格编辑",
description: "",
properties: {
fieldEditable: {
title: "启用",
type: "boolean",
description: "单元格是否可编辑",
refreshPanelAfterChanged: !0,
readonly: o.fieldEditable
}
},
async setPropertyRelates(d, p) {
return await new Promise((k) => {
d.propertyValue && u.question("启用单元格编辑后,将根据表格或者树表列绑定的字段类型自动分配编辑器,此操作不可撤销,是否继续?", "", async () => {
await A(o), k();
}, () => {
p.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
};