@tmagic/editor 1.8.0-beta.23 → 1.8.0-beta.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/es/fields/CodeSelectCol.vue_vue_type_script_setup_true_lang.js +5 -4
- package/dist/es/fields/CondOpSelect.vue_vue_type_script_setup_true_lang.js +3 -2
- package/dist/es/fields/DataSourceFieldSelect/Index.vue_vue_type_script_setup_true_lang.js +8 -5
- package/dist/es/fields/DataSourceFields.vue_vue_type_script_setup_true_lang.js +10 -6
- package/dist/es/fields/DataSourceMethodSelect.vue_vue_type_script_setup_true_name_true_lang.js +6 -4
- package/dist/es/fields/DataSourceMethods.vue_vue_type_script_setup_true_lang.js +4 -1
- package/dist/es/fields/DataSourceMocks.vue_vue_type_script_setup_true_lang.js +6 -4
- package/dist/es/fields/DisplayConds.vue_vue_type_script_setup_true_lang.js +12 -7
- package/dist/es/fields/EventSelect.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/fields/KeyValue.vue_vue_type_script_setup_true_lang.js +4 -2
- package/dist/es/fields/StyleSetter/pro/Font.vue_vue_type_script_setup_true_lang.js +2 -2
- package/dist/es/hooks/use-compare-form.js +1 -2
- package/dist/es/index.js +3 -3
- package/dist/es/plugin.js +9 -1
- package/dist/es/services/editor.js +43 -37
- package/dist/es/services/props.js +1 -1
- package/dist/es/style.css +4 -0
- package/dist/es/utils/event.js +1 -1
- package/dist/es/utils/props.js +1 -29
- package/dist/es/utils/type-match-rules.js +21 -20
- package/dist/style.css +4 -0
- package/dist/themes/magic-admin.css +4 -0
- package/dist/tmagic-editor.umd.cjs +412 -398
- package/package.json +8 -8
- package/src/fields/CodeSelectCol.vue +4 -2
- package/src/fields/CondOpSelect.vue +3 -2
- package/src/fields/DataSourceFieldSelect/Index.vue +9 -4
- package/src/fields/DataSourceFields.vue +6 -0
- package/src/fields/DataSourceMethodSelect.vue +4 -1
- package/src/fields/DataSourceMethods.vue +11 -2
- package/src/fields/DataSourceMocks.vue +10 -1
- package/src/fields/DisplayConds.vue +11 -7
- package/src/fields/EventSelect.vue +3 -3
- package/src/fields/KeyValue.vue +4 -3
- package/src/fields/StyleSetter/pro/Font.vue +2 -2
- package/src/hooks/use-compare-form.ts +1 -4
- package/src/plugin.ts +9 -1
- package/src/services/editor.ts +53 -85
- package/src/type.ts +23 -0
- package/src/utils/event.ts +2 -2
- package/src/utils/props.ts +0 -32
- package/src/utils/type-match-rules.ts +29 -28
- package/types/index.d.ts +39 -61
|
@@ -12,6 +12,8 @@ import { NodeType } from "@tmagic/core";
|
|
|
12
12
|
import { nextTick, reactive, toRaw } from "vue";
|
|
13
13
|
import { cloneDeep as cloneDeep$1, isEmpty, isEqual, isObject, mergeWith, uniq } from "lodash-es";
|
|
14
14
|
//#region packages/editor/src/services/editor.ts
|
|
15
|
+
/** 历史插回时把记录的下标收敛到 [0, length],越界(含未记录)一律追加到末尾 */
|
|
16
|
+
var clampIndex = (index, length) => typeof index === "number" && index >= 0 && index <= length ? index : length;
|
|
15
17
|
/**
|
|
16
18
|
* 把「变更前后节点快照」列表归一成 update 类型的 {@link StepDiffItem} 列表,供 {@link StepValue.diff} 使用。
|
|
17
19
|
* `changeRecords` 来自 form 端的 propPath/value 列表,撤销/重做时只对这些 propPath 做局部更新;
|
|
@@ -51,6 +53,11 @@ var Editor = class extends BaseService {
|
|
|
51
53
|
* 普通操作不会读取它,调用前由 *AndGetHistoryId 重置为 null。
|
|
52
54
|
*/
|
|
53
55
|
lastPushedHistoryId = null;
|
|
56
|
+
/**
|
|
57
|
+
* 上一次 doAdd 的插入记忆:nodeId 为插入的节点,selectedId 为当时的选中节点。
|
|
58
|
+
* 仅在选中节点未变化时复用(连续 add / doNotSelect / 批量粘贴),选中变化后自动失效,无需手动清理。
|
|
59
|
+
*/
|
|
60
|
+
lastAdded = null;
|
|
54
61
|
constructor() {
|
|
55
62
|
super(canUsePluginMethods.async.map((methodName) => ({
|
|
56
63
|
name: methodName,
|
|
@@ -246,24 +253,29 @@ var Editor = class extends BaseService {
|
|
|
246
253
|
this.set("stage", null);
|
|
247
254
|
this.set("highlightNode", null);
|
|
248
255
|
}
|
|
249
|
-
async doAdd(node, parent) {
|
|
256
|
+
async doAdd(node, parent, _options = {}) {
|
|
250
257
|
const root = this.get("root");
|
|
251
258
|
if (!root) throw new Error("root为空");
|
|
252
259
|
const curNode = this.get("node");
|
|
253
260
|
const stage = this.get("stage");
|
|
254
261
|
if (!curNode) throw new Error("当前选中节点为空");
|
|
255
262
|
if ((parent.type === NodeType.ROOT || curNode?.type === NodeType.ROOT) && !isPageOrFragment(node)) throw new Error("app下不能添加组件");
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
263
|
+
const anchorId = this.lastAdded?.selectedId === curNode.id ? this.lastAdded.nodeId : curNode.id;
|
|
264
|
+
const anchorIndex = isPageOrFragment(node) ? -1 : Math.max(getNodeIndex(anchorId, parent), getNodeIndex(curNode.id, parent));
|
|
265
|
+
const insertIndex = anchorIndex < 0 ? parent.items.length : anchorIndex + 1;
|
|
266
|
+
parent.items.splice(insertIndex, 0, node);
|
|
267
|
+
this.lastAdded = {
|
|
268
|
+
selectedId: curNode.id,
|
|
269
|
+
nodeId: node.id
|
|
270
|
+
};
|
|
260
271
|
const layout = await this.getLayout(toRaw(parent), node);
|
|
261
272
|
node.style = getInitPositionStyle(node.style, layout);
|
|
262
273
|
await stage?.add({
|
|
263
274
|
config: cloneDeep$1(node),
|
|
264
275
|
parent: cloneDeep$1(parent),
|
|
265
276
|
parentId: parent.id,
|
|
266
|
-
root: cloneDeep$1(root)
|
|
277
|
+
root: cloneDeep$1(root),
|
|
278
|
+
index: insertIndex
|
|
267
279
|
});
|
|
268
280
|
const newStyle = fixNodePosition(node, parent, stage);
|
|
269
281
|
if (newStyle && (newStyle.top !== node.style.top || newStyle.left !== node.style.left)) {
|
|
@@ -281,14 +293,12 @@ var Editor = class extends BaseService {
|
|
|
281
293
|
* 向指点容器添加组件节点
|
|
282
294
|
* @param addConfig 将要添加的组件节点配置
|
|
283
295
|
* @param parent 要添加到的容器组件节点配置,如果不设置,默认为当前选中的组件的父节点
|
|
284
|
-
* @param options
|
|
285
|
-
* @param options.doNotSelect 添加后是否不更新当前选中节点(默认 false,添加后会选中新增的节点)
|
|
286
|
-
* @param options.doNotSwitchPage 添加后是否不切换当前页面(默认 false;新增页面 / 跨页新增时为 true 会跳过会引发页面切换的选中操作)
|
|
287
|
-
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
296
|
+
* @param options 可选配置,见 {@link DslOpOptions}
|
|
288
297
|
* @returns 添加后的节点
|
|
289
298
|
*/
|
|
290
|
-
async add(addNode, parent,
|
|
299
|
+
async add(addNode, parent, options = {}) {
|
|
291
300
|
this.captureSelectionBeforeOp();
|
|
301
|
+
const { doNotSelect = false, doNotSwitchPage = false, doNotPushHistory = false, historyDescription, historySource } = options;
|
|
292
302
|
const stage = this.get("stage");
|
|
293
303
|
const addNodes = [];
|
|
294
304
|
if (!Array.isArray(addNode)) {
|
|
@@ -296,13 +306,13 @@ var Editor = class extends BaseService {
|
|
|
296
306
|
if (!type) throw new Error("组件类型不能为空");
|
|
297
307
|
addNodes.push({ ...toRaw(await props_default.getPropsValue(type, config)) });
|
|
298
308
|
} else addNodes.push(...addNode);
|
|
299
|
-
const newNodes =
|
|
309
|
+
const newNodes = [];
|
|
310
|
+
for (const node of addNodes) {
|
|
300
311
|
const root = this.get("root");
|
|
301
|
-
|
|
302
|
-
const parentNode = parent ?? getAddParent(node);
|
|
312
|
+
const parentNode = isPageOrFragment(node) && root ? root : parent ?? getAddParent(node);
|
|
303
313
|
if (!parentNode) throw new Error("未找到父元素");
|
|
304
|
-
|
|
305
|
-
}
|
|
314
|
+
newNodes.push(await this.doAdd(node, parentNode, options));
|
|
315
|
+
}
|
|
306
316
|
if (newNodes.length > 1) {
|
|
307
317
|
const wouldSwitchPage = newNodes.some((n) => this.isOnDifferentPage(n));
|
|
308
318
|
if (!doNotSelect && !(doNotSwitchPage && wouldSwitchPage)) {
|
|
@@ -418,7 +428,8 @@ var Editor = class extends BaseService {
|
|
|
418
428
|
* @param options.doNotSwitchPage 删除后是否不切换当前页面(默认 false;删除页面 / 页面片段时为 true 会跳过自动切换到首个剩余页面)
|
|
419
429
|
* @param options.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
420
430
|
*/
|
|
421
|
-
async remove(nodeOrNodeList,
|
|
431
|
+
async remove(nodeOrNodeList, options = {}) {
|
|
432
|
+
const { doNotPushHistory = false, historyDescription, historySource } = options;
|
|
422
433
|
this.captureSelectionBeforeOp();
|
|
423
434
|
const nodes = Array.isArray(nodeOrNodeList) ? nodeOrNodeList : [nodeOrNodeList];
|
|
424
435
|
const changeItems = nodes.map((node) => ({
|
|
@@ -442,10 +453,7 @@ var Editor = class extends BaseService {
|
|
|
442
453
|
});
|
|
443
454
|
}
|
|
444
455
|
}
|
|
445
|
-
await Promise.all(nodes.map((node) => this.doRemove(node,
|
|
446
|
-
doNotSelect,
|
|
447
|
-
doNotSwitchPage
|
|
448
|
-
})));
|
|
456
|
+
await Promise.all(nodes.map((node) => this.doRemove(node, options)));
|
|
449
457
|
this.removeInvalidNodesBySubtree(nodes);
|
|
450
458
|
if (removedItems.length > 0 && pageForOp) if (!doNotPushHistory) this.pushOpHistory("remove", {
|
|
451
459
|
diff: removedItems,
|
|
@@ -467,7 +475,8 @@ var Editor = class extends BaseService {
|
|
|
467
475
|
remove: removedPages
|
|
468
476
|
});
|
|
469
477
|
}
|
|
470
|
-
async doUpdate(config,
|
|
478
|
+
async doUpdate(config, data = {}) {
|
|
479
|
+
const { changeRecords = [], historySource, replace = false } = data;
|
|
471
480
|
if (!this.get("root")) throw new Error("root为空");
|
|
472
481
|
if (!config?.id) throw new Error("没有配置或者配置缺少id值");
|
|
473
482
|
const info = this.getNodeInfo(config.id, false);
|
|
@@ -516,24 +525,18 @@ var Editor = class extends BaseService {
|
|
|
516
525
|
* 更新节点
|
|
517
526
|
* update后会触发依赖收集,收集完后会掉stage.update方法
|
|
518
527
|
* @param config 新的节点配置,配置中需要有id信息
|
|
519
|
-
* @param data
|
|
520
|
-
* @param data.changeRecords 单节点 form 端变更记录(多节点场景下被忽略,使用 changeRecordList)
|
|
521
|
-
* @param data.changeRecordList 多节点 form 端变更记录列表,按 config 数组同序对应每个节点;优先级高于 changeRecords
|
|
522
|
-
* @param data.doNotPushHistory 是否不写入历史记录(默认 false)
|
|
523
|
-
* @param data.historyDescription 入栈时附带的人类可读描述,用于历史面板展示(不影响 undo/redo 行为)
|
|
524
|
-
* @param data.replace 是否整节点替换:为 true 时跳过 mergeWith / toggleFixedPosition / setChildrenLayout,直接用传入配置覆盖(默认 false)
|
|
528
|
+
* @param data 额外数据,见 {@link UpdateOptions}
|
|
525
529
|
* @returns 更新后的节点配置
|
|
526
530
|
*/
|
|
527
531
|
async update(config, data = {}) {
|
|
528
532
|
this.captureSelectionBeforeOp();
|
|
529
|
-
const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource,
|
|
533
|
+
const { doNotPushHistory = false, changeRecordList, changeRecords, historyDescription, historySource, invalidInfo } = data;
|
|
530
534
|
const nodes = Array.isArray(config) ? config : [config];
|
|
531
535
|
const updateData = await Promise.all(nodes.map((node, index) => {
|
|
532
536
|
const recordsForNode = changeRecordList ? changeRecordList[index] ?? [] : changeRecords ?? [];
|
|
533
537
|
return this.doUpdate(node, {
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
replace
|
|
538
|
+
...data,
|
|
539
|
+
changeRecords: recordsForNode
|
|
537
540
|
});
|
|
538
541
|
}));
|
|
539
542
|
this.applyInvalidInfo(config, invalidInfo);
|
|
@@ -1376,14 +1379,15 @@ var Editor = class extends BaseService {
|
|
|
1376
1379
|
const parent = this.getNodeById(parentId, false);
|
|
1377
1380
|
if (parent?.items) {
|
|
1378
1381
|
const addedNode = cloneDeep$1(newSchema);
|
|
1379
|
-
|
|
1380
|
-
|
|
1382
|
+
const insertIndex = clampIndex(index, parent.items.length);
|
|
1383
|
+
parent.items.splice(insertIndex, 0, addedNode);
|
|
1381
1384
|
addedNodes.push(addedNode);
|
|
1382
1385
|
await stage?.add({
|
|
1383
1386
|
config: cloneDeep$1(newSchema),
|
|
1384
1387
|
parent: cloneDeep$1(parent),
|
|
1385
1388
|
parentId: parent.id,
|
|
1386
|
-
root: cloneDeep$1(root)
|
|
1389
|
+
root: cloneDeep$1(root),
|
|
1390
|
+
index: insertIndex
|
|
1387
1391
|
});
|
|
1388
1392
|
}
|
|
1389
1393
|
}
|
|
@@ -1401,13 +1405,15 @@ var Editor = class extends BaseService {
|
|
|
1401
1405
|
const parent = this.getNodeById(parentId, false);
|
|
1402
1406
|
if (parent?.items) {
|
|
1403
1407
|
const addedNode = cloneDeep$1(oldSchema);
|
|
1404
|
-
|
|
1408
|
+
const insertIndex = clampIndex(index, parent.items.length);
|
|
1409
|
+
parent.items.splice(insertIndex, 0, addedNode);
|
|
1405
1410
|
addedNodes.push(addedNode);
|
|
1406
1411
|
await stage?.add({
|
|
1407
1412
|
config: cloneDeep$1(oldSchema),
|
|
1408
1413
|
parent: cloneDeep$1(parent),
|
|
1409
1414
|
parentId,
|
|
1410
|
-
root: cloneDeep$1(root)
|
|
1415
|
+
root: cloneDeep$1(root),
|
|
1416
|
+
index: insertIndex
|
|
1411
1417
|
});
|
|
1412
1418
|
}
|
|
1413
1419
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { fillConfig } from "../utils/props.js";
|
|
2
1
|
import BaseService from "./BaseService.js";
|
|
2
|
+
import { fillConfig } from "../utils/props.js";
|
|
3
3
|
import editor_default from "./editor.js";
|
|
4
4
|
import { getNodePath, getValueByKeyPath, guid, setValueByKeyPath, toLine } from "@tmagic/utils";
|
|
5
5
|
import { Target, Watcher } from "@tmagic/core";
|
package/dist/es/style.css
CHANGED
|
@@ -572,7 +572,11 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
572
572
|
.m-form-box .el-box__header {
|
|
573
573
|
margin: 0;
|
|
574
574
|
}
|
|
575
|
+
.m-form-box .m-box-body {
|
|
576
|
+
min-height: 0;
|
|
577
|
+
}
|
|
575
578
|
.m-form-box .dialog-footer {
|
|
579
|
+
flex-shrink: 0;
|
|
576
580
|
display: flex;
|
|
577
581
|
align-items: center;
|
|
578
582
|
justify-content: space-between;
|
package/dist/es/utils/event.js
CHANGED
|
@@ -19,7 +19,7 @@ var normalizeCompActionValue = (value) => {
|
|
|
19
19
|
var getEventNameOptions = (src, formValue = {}) => {
|
|
20
20
|
if (!formValue.type) return [];
|
|
21
21
|
if (src === "component") {
|
|
22
|
-
const sourceNode = editor_default.getNodeById(formValue.id);
|
|
22
|
+
const sourceNode = editor_default.getNodeById(formValue.id) || formValue;
|
|
23
23
|
let events = events_default.getEvent(formValue.type, { node: sourceNode }) || [];
|
|
24
24
|
if (formValue.type === "page-fragment-container" && formValue.pageFragmentId) {
|
|
25
25
|
const pageFragment = editor_default.get("root")?.items?.find((page) => page.id === formValue.pageFragmentId);
|
package/dist/es/utils/props.js
CHANGED
|
@@ -62,7 +62,6 @@ var getCondOpOptionsByFieldType = (type) => {
|
|
|
62
62
|
};
|
|
63
63
|
var styleTabConfig = {
|
|
64
64
|
title: "样式",
|
|
65
|
-
lazy: true,
|
|
66
65
|
display: ({ services }) => !(services?.uiService?.get("showStylePanel") ?? true),
|
|
67
66
|
items: [{
|
|
68
67
|
name: "style",
|
|
@@ -127,7 +126,6 @@ var styleTabConfig = {
|
|
|
127
126
|
};
|
|
128
127
|
var eventTabConfig = {
|
|
129
128
|
title: "事件",
|
|
130
|
-
lazy: true,
|
|
131
129
|
items: [{
|
|
132
130
|
name: "events",
|
|
133
131
|
src: "component",
|
|
@@ -138,7 +136,6 @@ var eventTabConfig = {
|
|
|
138
136
|
};
|
|
139
137
|
var advancedTabConfig = {
|
|
140
138
|
title: "高级",
|
|
141
|
-
lazy: true,
|
|
142
139
|
items: [
|
|
143
140
|
{
|
|
144
141
|
name: NODE_DISABLE_CODE_BLOCK_KEY,
|
|
@@ -288,30 +285,5 @@ var fillConfig = (config = [], { labelWidth = "80px", disabledDataSource = false
|
|
|
288
285
|
if (!disabledDataSource) tabConfig.items.push({ ...displayTabConfig });
|
|
289
286
|
return [tabConfig];
|
|
290
287
|
};
|
|
291
|
-
/**
|
|
292
|
-
* 将属性表单配置中「样式」tab-pane 的 `display` 强制置为 `true`。
|
|
293
|
-
*
|
|
294
|
-
* `propsService.getPropsConfig` 返回的样式 tab 默认带有
|
|
295
|
-
* `display: ({ services }) => !(services?.uiService?.get('showStylePanel') ?? true)`,
|
|
296
|
-
* 在对比 / 只读展示场景(CompareForm / ViewForm)下并不需要跟随 uiService 状态隐藏,
|
|
297
|
-
* 这里统一放开,保证样式 tab 始终可见。
|
|
298
|
-
*
|
|
299
|
-
* @param formConfig 组件属性表单配置
|
|
300
|
-
* @returns 处理后的表单配置(不修改入参,返回浅拷贝)
|
|
301
|
-
*/
|
|
302
|
-
var removeStyleDisplayConfig = (formConfig) => formConfig.map((item) => {
|
|
303
|
-
if (!("type" in item)) return item;
|
|
304
|
-
if (item?.type !== "tab" || !Array.isArray(item.items)) return item;
|
|
305
|
-
return {
|
|
306
|
-
...item,
|
|
307
|
-
items: item.items.map((tabPane) => {
|
|
308
|
-
if (tabPane?.title !== "样式" || !Array.isArray(tabPane.items)) return tabPane;
|
|
309
|
-
return {
|
|
310
|
-
...tabPane,
|
|
311
|
-
display: true
|
|
312
|
-
};
|
|
313
|
-
})
|
|
314
|
-
};
|
|
315
|
-
});
|
|
316
288
|
//#endregion
|
|
317
|
-
export { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions,
|
|
289
|
+
export { advancedTabConfig, arrayOptions, booleanOptions, displayTabConfig, eqOptions, eventTabConfig, fillConfig, getCondOpOptionsByFieldType, numberOptions, styleTabConfig };
|
|
@@ -152,24 +152,20 @@ var displayCondSuggestion = () => {
|
|
|
152
152
|
};
|
|
153
153
|
var validateDataSourceFieldPath = (path, options = {}) => {
|
|
154
154
|
if (!getDataSources().length) return;
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
if (!dsId) {
|
|
158
|
-
if (!path.length) return defaultMessage(options.message, "值不在可选项中", dataSourceIdSuggestion());
|
|
159
|
-
const rawDsId = path[0];
|
|
160
|
-
dsId = options.valueMode === "key" || !`${rawDsId}`.startsWith(DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX) ? `${rawDsId}` : removeDataSourceFieldPrefix(`${rawDsId}`);
|
|
161
|
-
fieldNames = path.slice(1);
|
|
162
|
-
}
|
|
155
|
+
const dsId = options.dataSourceId;
|
|
156
|
+
if (!dsId) return defaultMessage(options.message, "数据源不存在", dataSourceIdSuggestion());
|
|
163
157
|
const ds = findDataSource(`${dsId}`);
|
|
164
158
|
if (!ds) return defaultMessage(options.message, `数据源(${dsId})不存在`, dataSourceIdSuggestion());
|
|
165
|
-
if (!
|
|
166
|
-
const { field, ok, fields, failedName } = resolveFieldByPath(ds.fields,
|
|
159
|
+
if (!path.length) return;
|
|
160
|
+
const { field, ok, fields, failedName } = resolveFieldByPath(ds.fields, path);
|
|
167
161
|
if (!ok) return defaultMessage(options.message, `数据源字段(${failedName})不存在`, listSuggestion(fields.map((item) => item.name)));
|
|
168
162
|
const allowedTypes = options.dataSourceFieldType || ["any"];
|
|
169
163
|
if (!allowedTypes.length || allowedTypes.includes("any")) return;
|
|
170
164
|
const leafType = field?.type || "any";
|
|
171
|
-
if (leafType
|
|
172
|
-
|
|
165
|
+
if (leafType !== "any" && !allowedTypes.includes(leafType)) {
|
|
166
|
+
const fieldName = field?.name || path[path.length - 1];
|
|
167
|
+
return defaultMessage(options.message, `请选择类型为${allowedTypes.join("或")}的字段,字段(${fieldName})的类型为${leafType}`);
|
|
168
|
+
}
|
|
173
169
|
};
|
|
174
170
|
var validateDataSourceMethodTuple = (value, message) => {
|
|
175
171
|
if (!Array.isArray(value) || value.length !== 2 || value.some((item) => typeof item !== "string")) return defaultMessage(message, `${value}类型应为长度为 2 的字符串数组`, methodTupleSuggestion());
|
|
@@ -215,7 +211,7 @@ var validateCondOpSelect = (value, { message, props }) => {
|
|
|
215
211
|
const parentFields = props.config?.parentFields || [];
|
|
216
212
|
const fieldPath = Array.isArray(props.model?.field) ? props.model.field : [];
|
|
217
213
|
const [id, ...fieldNames] = [...parentFields, ...fieldPath];
|
|
218
|
-
const ds = id ? findDataSource(`${id}`) : void 0;
|
|
214
|
+
const ds = id ? findDataSource(removeDataSourceFieldPrefix(`${id}`)) : void 0;
|
|
219
215
|
const allowed = getCondOpsByFieldType(getFieldType(ds, fieldNames));
|
|
220
216
|
if (!allowed.has(value)) return defaultMessage(message, `${value} 不在可选项中`, listSuggestion([...allowed]));
|
|
221
217
|
};
|
|
@@ -251,7 +247,7 @@ var isDataSourceFieldPathValue = (value, config) => {
|
|
|
251
247
|
/**
|
|
252
248
|
* data-source-field-select 的 typeMatch 校验逻辑,可供自定义 rules.validator 复用。
|
|
253
249
|
*/
|
|
254
|
-
var
|
|
250
|
+
var validateDataSourceFieldSelect = (value, context, options) => {
|
|
255
251
|
const { mForm, message, props } = context;
|
|
256
252
|
const config = props.config || {};
|
|
257
253
|
if (!isDataSourceFieldPathValue(value, config)) {
|
|
@@ -265,14 +261,18 @@ var validateDataSourceFieldSelectValue = (value, context, options) => {
|
|
|
265
261
|
}, message);
|
|
266
262
|
}
|
|
267
263
|
if (!Array.isArray(value) || value.some((item) => typeof item !== "string")) return defaultMessage(message, `${value}类型应为字符串数组`, dataSourceFieldPathSuggestion());
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
264
|
+
let dataSourceId = config.dataSourceId ? `${config.dataSourceId}` : void 0;
|
|
265
|
+
let fieldNames = value;
|
|
266
|
+
if (!dataSourceId) {
|
|
267
|
+
dataSourceId = value.length ? removeDataSourceFieldPrefix(value[0]) : void 0;
|
|
268
|
+
fieldNames = value.slice(1);
|
|
269
|
+
}
|
|
270
|
+
return validateDataSourceFieldPath(fieldNames, {
|
|
271
|
+
dataSourceId,
|
|
271
272
|
dataSourceFieldType: config.dataSourceFieldType,
|
|
272
273
|
message
|
|
273
274
|
});
|
|
274
275
|
};
|
|
275
|
-
var validateDataSourceFieldSelect = (value, context) => validateDataSourceFieldSelectValue(value, context);
|
|
276
276
|
var validateDataSourceSelect = (value, { message, props }) => {
|
|
277
277
|
const config = props.config || {};
|
|
278
278
|
const dataSources = getDataSources();
|
|
@@ -342,7 +342,8 @@ var editorTypeMatchRules = {
|
|
|
342
342
|
"ui-select": validateUiSelect,
|
|
343
343
|
"data-source-input": validateDataSourceInput,
|
|
344
344
|
"data-source-method-select": validateDataSourceMethodSelect,
|
|
345
|
-
|
|
345
|
+
/** 注册进 typeMatch 规则表的入口,收窄为 TypeMatchValidator,避免调用方误传第三个参数 */
|
|
346
|
+
"data-source-field-select": (value, context) => validateDataSourceFieldSelect(value, context),
|
|
346
347
|
"data-source-select": validateDataSourceSelect,
|
|
347
348
|
"code-select": validateCodeSelect,
|
|
348
349
|
"data-source-fields": validateDataSourceFields,
|
|
@@ -352,4 +353,4 @@ var editorTypeMatchRules = {
|
|
|
352
353
|
"display-conds": validateDisplayConds
|
|
353
354
|
};
|
|
354
355
|
//#endregion
|
|
355
|
-
export { ALL_COND_OPS, editorTypeMatchRules,
|
|
356
|
+
export { ALL_COND_OPS, editorTypeMatchRules, validateDataSourceFieldSelect };
|
package/dist/style.css
CHANGED
|
@@ -572,7 +572,11 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
572
572
|
.m-form-box .el-box__header {
|
|
573
573
|
margin: 0;
|
|
574
574
|
}
|
|
575
|
+
.m-form-box .m-box-body {
|
|
576
|
+
min-height: 0;
|
|
577
|
+
}
|
|
575
578
|
.m-form-box .dialog-footer {
|
|
579
|
+
flex-shrink: 0;
|
|
576
580
|
display: flex;
|
|
577
581
|
align-items: center;
|
|
578
582
|
justify-content: space-between;
|
|
@@ -603,7 +603,11 @@ fieldset.m-fieldset .m-form-tip {
|
|
|
603
603
|
.m-form-box .el-box__header {
|
|
604
604
|
margin: 0;
|
|
605
605
|
}
|
|
606
|
+
.m-form-box .m-box-body {
|
|
607
|
+
min-height: 0;
|
|
608
|
+
}
|
|
606
609
|
.m-form-box .dialog-footer {
|
|
610
|
+
flex-shrink: 0;
|
|
607
611
|
display: flex;
|
|
608
612
|
align-items: center;
|
|
609
613
|
justify-content: space-between;
|