@tmagic/editor 1.4.10 → 1.4.11
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/tmagic-editor.js +77 -39
- package/dist/tmagic-editor.umd.cjs +77 -39
- package/package.json +9 -9
- package/src/components/CodeParams.vue +11 -1
- package/src/fields/DataSourceFieldSelect/FieldSelect.vue +61 -30
- package/src/fields/DisplayConds.vue +1 -1
- package/src/hooks/use-data-source-method.ts +1 -1
- package/src/type.ts +2 -2
- package/types/type.d.ts +2 -2
package/dist/tmagic-editor.js
CHANGED
|
@@ -3003,7 +3003,17 @@ const _sfc_main$T = /* @__PURE__ */ defineComponent({
|
|
|
3003
3003
|
name: props.name
|
|
3004
3004
|
}
|
|
3005
3005
|
];
|
|
3006
|
-
const codeParamsConfig = computed(
|
|
3006
|
+
const codeParamsConfig = computed(
|
|
3007
|
+
() => getFormConfig(
|
|
3008
|
+
props.paramsConfig.map(({ name, text, extra, ...config }) => ({
|
|
3009
|
+
type: "data-source-field-select",
|
|
3010
|
+
name,
|
|
3011
|
+
text,
|
|
3012
|
+
extra,
|
|
3013
|
+
fieldConfig: config
|
|
3014
|
+
}))
|
|
3015
|
+
)
|
|
3016
|
+
);
|
|
3007
3017
|
const onParamsChangeHandler = async () => {
|
|
3008
3018
|
try {
|
|
3009
3019
|
const value = await form.value?.submitForm(true);
|
|
@@ -3487,7 +3497,9 @@ const useDataSourceMethod = () => {
|
|
|
3487
3497
|
tMagicMessage.error("获取数据源方法失败");
|
|
3488
3498
|
return;
|
|
3489
3499
|
}
|
|
3490
|
-
let codeContent = method.content
|
|
3500
|
+
let codeContent = method.content || `({ params, dataSource, app }) => {
|
|
3501
|
+
// place your code here
|
|
3502
|
+
}`;
|
|
3491
3503
|
if (typeof codeContent !== "string") {
|
|
3492
3504
|
codeContent = codeContent.toString();
|
|
3493
3505
|
}
|
|
@@ -4236,6 +4248,14 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
4236
4248
|
if (!ds) return [];
|
|
4237
4249
|
return getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType);
|
|
4238
4250
|
});
|
|
4251
|
+
const cascaderOptions = computed(() => {
|
|
4252
|
+
const options = dataSources.value?.map((ds) => ({
|
|
4253
|
+
label: ds.title || ds.id,
|
|
4254
|
+
value: valueIsKey.value ? ds.id : `${DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
4255
|
+
children: getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType)
|
|
4256
|
+
})) || [];
|
|
4257
|
+
return options.filter((option) => option.children.length);
|
|
4258
|
+
});
|
|
4239
4259
|
const dsChangeHandler = (v) => {
|
|
4240
4260
|
modelValue.value = [v];
|
|
4241
4261
|
emit("change", modelValue.value);
|
|
@@ -4244,6 +4264,10 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
4244
4264
|
modelValue.value = [selectDataSourceId.value, ...v];
|
|
4245
4265
|
emit("change", modelValue.value);
|
|
4246
4266
|
};
|
|
4267
|
+
const onChangeHandler = (v = []) => {
|
|
4268
|
+
modelValue.value = v;
|
|
4269
|
+
emit("change", v);
|
|
4270
|
+
};
|
|
4247
4271
|
const hasDataSourceSidePanel = computed(
|
|
4248
4272
|
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
4249
4273
|
);
|
|
@@ -4252,50 +4276,64 @@ const _sfc_main$O = /* @__PURE__ */ defineComponent({
|
|
|
4252
4276
|
};
|
|
4253
4277
|
return (_ctx, _cache) => {
|
|
4254
4278
|
return openBlock(), createElementBlock("div", _hoisted_1$s, [
|
|
4255
|
-
|
|
4256
|
-
|
|
4279
|
+
_ctx.checkStrictly ? (openBlock(), createElementBlock(Fragment, { key: 0 }, [
|
|
4280
|
+
createVNode(unref(TMagicSelect), {
|
|
4281
|
+
"model-value": selectDataSourceId.value,
|
|
4282
|
+
clearable: "",
|
|
4283
|
+
filterable: "",
|
|
4284
|
+
size: _ctx.size,
|
|
4285
|
+
disabled: _ctx.disabled,
|
|
4286
|
+
onChange: dsChangeHandler
|
|
4287
|
+
}, {
|
|
4288
|
+
default: withCtx(() => [
|
|
4289
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(dataSourcesOptions.value, (option) => {
|
|
4290
|
+
return openBlock(), createBlock(resolveDynamicComponent(unref(optionComponent)?.component || "el-option"), mergeProps(
|
|
4291
|
+
{
|
|
4292
|
+
class: "tmagic-design-option",
|
|
4293
|
+
key: option.value,
|
|
4294
|
+
ref_for: true
|
|
4295
|
+
},
|
|
4296
|
+
unref(optionComponent)?.props({
|
|
4297
|
+
label: option.text,
|
|
4298
|
+
value: option.value,
|
|
4299
|
+
disabled: option.disabled
|
|
4300
|
+
}) || {
|
|
4301
|
+
label: option.text,
|
|
4302
|
+
value: option.value,
|
|
4303
|
+
disabled: option.disabled
|
|
4304
|
+
}
|
|
4305
|
+
), null, 16);
|
|
4306
|
+
}), 128))
|
|
4307
|
+
]),
|
|
4308
|
+
_: 1
|
|
4309
|
+
}, 8, ["model-value", "size", "disabled"]),
|
|
4310
|
+
createVNode(unref(TMagicCascader), {
|
|
4311
|
+
"model-value": selectFieldsId.value,
|
|
4312
|
+
clearable: "",
|
|
4313
|
+
filterable: "",
|
|
4314
|
+
size: _ctx.size,
|
|
4315
|
+
disabled: _ctx.disabled,
|
|
4316
|
+
options: fieldsOptions.value,
|
|
4317
|
+
props: {
|
|
4318
|
+
checkStrictly: _ctx.checkStrictly
|
|
4319
|
+
},
|
|
4320
|
+
onChange: fieldChangeHandler
|
|
4321
|
+
}, null, 8, ["model-value", "size", "disabled", "options", "props"])
|
|
4322
|
+
], 64)) : (openBlock(), createBlock(unref(TMagicCascader), {
|
|
4323
|
+
key: 1,
|
|
4257
4324
|
clearable: "",
|
|
4258
4325
|
filterable: "",
|
|
4259
|
-
|
|
4326
|
+
"model-value": modelValue.value,
|
|
4260
4327
|
disabled: _ctx.disabled,
|
|
4261
|
-
onChange: dsChangeHandler
|
|
4262
|
-
}, {
|
|
4263
|
-
default: withCtx(() => [
|
|
4264
|
-
(openBlock(true), createElementBlock(Fragment, null, renderList(dataSourcesOptions.value, (option) => {
|
|
4265
|
-
return openBlock(), createBlock(resolveDynamicComponent(unref(optionComponent)?.component || "el-option"), mergeProps(
|
|
4266
|
-
{
|
|
4267
|
-
class: "tmagic-design-option",
|
|
4268
|
-
key: option.value,
|
|
4269
|
-
ref_for: true
|
|
4270
|
-
},
|
|
4271
|
-
unref(optionComponent)?.props({
|
|
4272
|
-
label: option.text,
|
|
4273
|
-
value: option.value,
|
|
4274
|
-
disabled: option.disabled
|
|
4275
|
-
}) || {
|
|
4276
|
-
label: option.text,
|
|
4277
|
-
value: option.value,
|
|
4278
|
-
disabled: option.disabled
|
|
4279
|
-
}
|
|
4280
|
-
), null, 16);
|
|
4281
|
-
}), 128))
|
|
4282
|
-
]),
|
|
4283
|
-
_: 1
|
|
4284
|
-
}, 8, ["model-value", "size", "disabled"]),
|
|
4285
|
-
createVNode(unref(TMagicCascader), {
|
|
4286
|
-
"model-value": selectFieldsId.value,
|
|
4287
|
-
clearable: "",
|
|
4288
|
-
filterable: "",
|
|
4289
4328
|
size: _ctx.size,
|
|
4290
|
-
|
|
4291
|
-
options: fieldsOptions.value,
|
|
4329
|
+
options: cascaderOptions.value,
|
|
4292
4330
|
props: {
|
|
4293
4331
|
checkStrictly: _ctx.checkStrictly
|
|
4294
4332
|
},
|
|
4295
|
-
onChange:
|
|
4296
|
-
}, null, 8, ["model-value", "
|
|
4333
|
+
onChange: onChangeHandler
|
|
4334
|
+
}, null, 8, ["model-value", "disabled", "size", "options", "props"])),
|
|
4297
4335
|
selectDataSourceId.value && hasDataSourceSidePanel.value ? (openBlock(), createBlock(unref(TMagicButton), {
|
|
4298
|
-
key:
|
|
4336
|
+
key: 2,
|
|
4299
4337
|
class: "m-fields-select-action-button",
|
|
4300
4338
|
size: _ctx.size,
|
|
4301
4339
|
onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectDataSourceId.value))
|
|
@@ -5644,7 +5682,7 @@ const _sfc_main$G = /* @__PURE__ */ defineComponent({
|
|
|
5644
5682
|
{
|
|
5645
5683
|
name: "value",
|
|
5646
5684
|
type: (mForm2, { model }) => {
|
|
5647
|
-
const [id, ...fieldNames] = model.field;
|
|
5685
|
+
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
5648
5686
|
const ds = dataSourceService?.getDataSourceById(id);
|
|
5649
5687
|
let fields = ds?.fields || [];
|
|
5650
5688
|
let type = "";
|
|
@@ -3007,7 +3007,17 @@
|
|
|
3007
3007
|
name: props.name
|
|
3008
3008
|
}
|
|
3009
3009
|
];
|
|
3010
|
-
const codeParamsConfig = vue.computed(
|
|
3010
|
+
const codeParamsConfig = vue.computed(
|
|
3011
|
+
() => getFormConfig(
|
|
3012
|
+
props.paramsConfig.map(({ name, text, extra, ...config }) => ({
|
|
3013
|
+
type: "data-source-field-select",
|
|
3014
|
+
name,
|
|
3015
|
+
text,
|
|
3016
|
+
extra,
|
|
3017
|
+
fieldConfig: config
|
|
3018
|
+
}))
|
|
3019
|
+
)
|
|
3020
|
+
);
|
|
3011
3021
|
const onParamsChangeHandler = async () => {
|
|
3012
3022
|
try {
|
|
3013
3023
|
const value = await form$1.value?.submitForm(true);
|
|
@@ -3491,7 +3501,9 @@
|
|
|
3491
3501
|
design.tMagicMessage.error("获取数据源方法失败");
|
|
3492
3502
|
return;
|
|
3493
3503
|
}
|
|
3494
|
-
let codeContent = method.content
|
|
3504
|
+
let codeContent = method.content || `({ params, dataSource, app }) => {
|
|
3505
|
+
// place your code here
|
|
3506
|
+
}`;
|
|
3495
3507
|
if (typeof codeContent !== "string") {
|
|
3496
3508
|
codeContent = codeContent.toString();
|
|
3497
3509
|
}
|
|
@@ -4240,6 +4252,14 @@
|
|
|
4240
4252
|
if (!ds) return [];
|
|
4241
4253
|
return getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType);
|
|
4242
4254
|
});
|
|
4255
|
+
const cascaderOptions = vue.computed(() => {
|
|
4256
|
+
const options = dataSources.value?.map((ds) => ({
|
|
4257
|
+
label: ds.title || ds.id,
|
|
4258
|
+
value: valueIsKey.value ? ds.id : `${utils.DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
4259
|
+
children: getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType)
|
|
4260
|
+
})) || [];
|
|
4261
|
+
return options.filter((option) => option.children.length);
|
|
4262
|
+
});
|
|
4243
4263
|
const dsChangeHandler = (v) => {
|
|
4244
4264
|
modelValue.value = [v];
|
|
4245
4265
|
emit("change", modelValue.value);
|
|
@@ -4248,6 +4268,10 @@
|
|
|
4248
4268
|
modelValue.value = [selectDataSourceId.value, ...v];
|
|
4249
4269
|
emit("change", modelValue.value);
|
|
4250
4270
|
};
|
|
4271
|
+
const onChangeHandler = (v = []) => {
|
|
4272
|
+
modelValue.value = v;
|
|
4273
|
+
emit("change", v);
|
|
4274
|
+
};
|
|
4251
4275
|
const hasDataSourceSidePanel = vue.computed(
|
|
4252
4276
|
() => (services?.uiService.get("sideBarItems") || []).find((item) => item.$key === SideItemKey.DATA_SOURCE)
|
|
4253
4277
|
);
|
|
@@ -4256,50 +4280,64 @@
|
|
|
4256
4280
|
};
|
|
4257
4281
|
return (_ctx, _cache) => {
|
|
4258
4282
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$s, [
|
|
4259
|
-
vue.
|
|
4260
|
-
|
|
4283
|
+
_ctx.checkStrictly ? (vue.openBlock(), vue.createElementBlock(vue.Fragment, { key: 0 }, [
|
|
4284
|
+
vue.createVNode(vue.unref(design.TMagicSelect), {
|
|
4285
|
+
"model-value": selectDataSourceId.value,
|
|
4286
|
+
clearable: "",
|
|
4287
|
+
filterable: "",
|
|
4288
|
+
size: _ctx.size,
|
|
4289
|
+
disabled: _ctx.disabled,
|
|
4290
|
+
onChange: dsChangeHandler
|
|
4291
|
+
}, {
|
|
4292
|
+
default: vue.withCtx(() => [
|
|
4293
|
+
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(dataSourcesOptions.value, (option) => {
|
|
4294
|
+
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(optionComponent)?.component || "el-option"), vue.mergeProps(
|
|
4295
|
+
{
|
|
4296
|
+
class: "tmagic-design-option",
|
|
4297
|
+
key: option.value,
|
|
4298
|
+
ref_for: true
|
|
4299
|
+
},
|
|
4300
|
+
vue.unref(optionComponent)?.props({
|
|
4301
|
+
label: option.text,
|
|
4302
|
+
value: option.value,
|
|
4303
|
+
disabled: option.disabled
|
|
4304
|
+
}) || {
|
|
4305
|
+
label: option.text,
|
|
4306
|
+
value: option.value,
|
|
4307
|
+
disabled: option.disabled
|
|
4308
|
+
}
|
|
4309
|
+
), null, 16);
|
|
4310
|
+
}), 128))
|
|
4311
|
+
]),
|
|
4312
|
+
_: 1
|
|
4313
|
+
}, 8, ["model-value", "size", "disabled"]),
|
|
4314
|
+
vue.createVNode(vue.unref(design.TMagicCascader), {
|
|
4315
|
+
"model-value": selectFieldsId.value,
|
|
4316
|
+
clearable: "",
|
|
4317
|
+
filterable: "",
|
|
4318
|
+
size: _ctx.size,
|
|
4319
|
+
disabled: _ctx.disabled,
|
|
4320
|
+
options: fieldsOptions.value,
|
|
4321
|
+
props: {
|
|
4322
|
+
checkStrictly: _ctx.checkStrictly
|
|
4323
|
+
},
|
|
4324
|
+
onChange: fieldChangeHandler
|
|
4325
|
+
}, null, 8, ["model-value", "size", "disabled", "options", "props"])
|
|
4326
|
+
], 64)) : (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicCascader), {
|
|
4327
|
+
key: 1,
|
|
4261
4328
|
clearable: "",
|
|
4262
4329
|
filterable: "",
|
|
4263
|
-
|
|
4330
|
+
"model-value": modelValue.value,
|
|
4264
4331
|
disabled: _ctx.disabled,
|
|
4265
|
-
onChange: dsChangeHandler
|
|
4266
|
-
}, {
|
|
4267
|
-
default: vue.withCtx(() => [
|
|
4268
|
-
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(dataSourcesOptions.value, (option) => {
|
|
4269
|
-
return vue.openBlock(), vue.createBlock(vue.resolveDynamicComponent(vue.unref(optionComponent)?.component || "el-option"), vue.mergeProps(
|
|
4270
|
-
{
|
|
4271
|
-
class: "tmagic-design-option",
|
|
4272
|
-
key: option.value,
|
|
4273
|
-
ref_for: true
|
|
4274
|
-
},
|
|
4275
|
-
vue.unref(optionComponent)?.props({
|
|
4276
|
-
label: option.text,
|
|
4277
|
-
value: option.value,
|
|
4278
|
-
disabled: option.disabled
|
|
4279
|
-
}) || {
|
|
4280
|
-
label: option.text,
|
|
4281
|
-
value: option.value,
|
|
4282
|
-
disabled: option.disabled
|
|
4283
|
-
}
|
|
4284
|
-
), null, 16);
|
|
4285
|
-
}), 128))
|
|
4286
|
-
]),
|
|
4287
|
-
_: 1
|
|
4288
|
-
}, 8, ["model-value", "size", "disabled"]),
|
|
4289
|
-
vue.createVNode(vue.unref(design.TMagicCascader), {
|
|
4290
|
-
"model-value": selectFieldsId.value,
|
|
4291
|
-
clearable: "",
|
|
4292
|
-
filterable: "",
|
|
4293
4332
|
size: _ctx.size,
|
|
4294
|
-
|
|
4295
|
-
options: fieldsOptions.value,
|
|
4333
|
+
options: cascaderOptions.value,
|
|
4296
4334
|
props: {
|
|
4297
4335
|
checkStrictly: _ctx.checkStrictly
|
|
4298
4336
|
},
|
|
4299
|
-
onChange:
|
|
4300
|
-
}, null, 8, ["model-value", "
|
|
4337
|
+
onChange: onChangeHandler
|
|
4338
|
+
}, null, 8, ["model-value", "disabled", "size", "options", "props"])),
|
|
4301
4339
|
selectDataSourceId.value && hasDataSourceSidePanel.value ? (vue.openBlock(), vue.createBlock(vue.unref(design.TMagicButton), {
|
|
4302
|
-
key:
|
|
4340
|
+
key: 2,
|
|
4303
4341
|
class: "m-fields-select-action-button",
|
|
4304
4342
|
size: _ctx.size,
|
|
4305
4343
|
onClick: _cache[0] || (_cache[0] = ($event) => editHandler(selectDataSourceId.value))
|
|
@@ -5648,7 +5686,7 @@
|
|
|
5648
5686
|
{
|
|
5649
5687
|
name: "value",
|
|
5650
5688
|
type: (mForm2, { model }) => {
|
|
5651
|
-
const [id, ...fieldNames] = model.field;
|
|
5689
|
+
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
5652
5690
|
const ds = dataSourceService?.getDataSourceById(id);
|
|
5653
5691
|
let fields = ds?.fields || [];
|
|
5654
5692
|
let type = "";
|
package/package.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "1.4.
|
|
2
|
+
"version": "1.4.11",
|
|
3
3
|
"name": "@tmagic/editor",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"sideEffects": [
|
|
@@ -55,8 +55,8 @@
|
|
|
55
55
|
"moveable": "^0.53.0",
|
|
56
56
|
"serialize-javascript": "^6.0.0",
|
|
57
57
|
"sortablejs": "^1.15.2",
|
|
58
|
-
"@tmagic/dep": "1.4.
|
|
59
|
-
"@tmagic/table": "1.4.
|
|
58
|
+
"@tmagic/dep": "1.4.11",
|
|
59
|
+
"@tmagic/table": "1.4.11"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
62
|
"@types/events": "^3.0.0",
|
|
@@ -78,12 +78,12 @@
|
|
|
78
78
|
"monaco-editor": "^0.48.0",
|
|
79
79
|
"typescript": "*",
|
|
80
80
|
"vue": "^3.4.27",
|
|
81
|
-
"@tmagic/
|
|
82
|
-
"@tmagic/
|
|
83
|
-
"@tmagic/
|
|
84
|
-
"@tmagic/
|
|
85
|
-
"@tmagic/
|
|
86
|
-
"@tmagic/utils": "1.4.
|
|
81
|
+
"@tmagic/form": "1.4.11",
|
|
82
|
+
"@tmagic/schema": "1.4.11",
|
|
83
|
+
"@tmagic/core": "1.4.11",
|
|
84
|
+
"@tmagic/stage": "1.4.11",
|
|
85
|
+
"@tmagic/design": "1.4.11",
|
|
86
|
+
"@tmagic/utils": "1.4.11"
|
|
87
87
|
},
|
|
88
88
|
"peerDependenciesMeta": {
|
|
89
89
|
"typescript": {
|
|
@@ -44,7 +44,17 @@ const getFormConfig = (items: FormConfig = []) => [
|
|
|
44
44
|
},
|
|
45
45
|
];
|
|
46
46
|
|
|
47
|
-
const codeParamsConfig = computed(() =>
|
|
47
|
+
const codeParamsConfig = computed(() =>
|
|
48
|
+
getFormConfig(
|
|
49
|
+
props.paramsConfig.map(({ name, text, extra, ...config }) => ({
|
|
50
|
+
type: 'data-source-field-select',
|
|
51
|
+
name,
|
|
52
|
+
text,
|
|
53
|
+
extra,
|
|
54
|
+
fieldConfig: config,
|
|
55
|
+
})),
|
|
56
|
+
),
|
|
57
|
+
);
|
|
48
58
|
|
|
49
59
|
/**
|
|
50
60
|
* 参数值修改更新
|
|
@@ -1,44 +1,60 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="m-editor-data-source-field-select">
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
<component
|
|
12
|
-
v-for="option in dataSourcesOptions"
|
|
13
|
-
class="tmagic-design-option"
|
|
14
|
-
:key="option.value"
|
|
15
|
-
:is="optionComponent?.component || 'el-option'"
|
|
16
|
-
v-bind="
|
|
17
|
-
optionComponent?.props({
|
|
18
|
-
label: option.text,
|
|
19
|
-
value: option.value,
|
|
20
|
-
disabled: option.disabled,
|
|
21
|
-
}) || {
|
|
22
|
-
label: option.text,
|
|
23
|
-
value: option.value,
|
|
24
|
-
disabled: option.disabled,
|
|
25
|
-
}
|
|
26
|
-
"
|
|
3
|
+
<template v-if="checkStrictly">
|
|
4
|
+
<TMagicSelect
|
|
5
|
+
:model-value="selectDataSourceId"
|
|
6
|
+
clearable
|
|
7
|
+
filterable
|
|
8
|
+
:size="size"
|
|
9
|
+
:disabled="disabled"
|
|
10
|
+
@change="dsChangeHandler"
|
|
27
11
|
>
|
|
28
|
-
|
|
29
|
-
|
|
12
|
+
<component
|
|
13
|
+
v-for="option in dataSourcesOptions"
|
|
14
|
+
class="tmagic-design-option"
|
|
15
|
+
:key="option.value"
|
|
16
|
+
:is="optionComponent?.component || 'el-option'"
|
|
17
|
+
v-bind="
|
|
18
|
+
optionComponent?.props({
|
|
19
|
+
label: option.text,
|
|
20
|
+
value: option.value,
|
|
21
|
+
disabled: option.disabled,
|
|
22
|
+
}) || {
|
|
23
|
+
label: option.text,
|
|
24
|
+
value: option.value,
|
|
25
|
+
disabled: option.disabled,
|
|
26
|
+
}
|
|
27
|
+
"
|
|
28
|
+
>
|
|
29
|
+
</component>
|
|
30
|
+
</TMagicSelect>
|
|
31
|
+
|
|
32
|
+
<TMagicCascader
|
|
33
|
+
:model-value="selectFieldsId"
|
|
34
|
+
clearable
|
|
35
|
+
filterable
|
|
36
|
+
:size="size"
|
|
37
|
+
:disabled="disabled"
|
|
38
|
+
:options="fieldsOptions"
|
|
39
|
+
:props="{
|
|
40
|
+
checkStrictly,
|
|
41
|
+
}"
|
|
42
|
+
@change="fieldChangeHandler"
|
|
43
|
+
></TMagicCascader>
|
|
44
|
+
</template>
|
|
30
45
|
|
|
31
46
|
<TMagicCascader
|
|
32
|
-
|
|
47
|
+
v-else
|
|
33
48
|
clearable
|
|
34
49
|
filterable
|
|
35
|
-
:
|
|
50
|
+
:model-value="modelValue"
|
|
36
51
|
:disabled="disabled"
|
|
37
|
-
:
|
|
52
|
+
:size="size"
|
|
53
|
+
:options="cascaderOptions"
|
|
38
54
|
:props="{
|
|
39
55
|
checkStrictly,
|
|
40
56
|
}"
|
|
41
|
-
@change="
|
|
57
|
+
@change="onChangeHandler"
|
|
42
58
|
></TMagicCascader>
|
|
43
59
|
|
|
44
60
|
<TMagicButton
|
|
@@ -132,6 +148,16 @@ const fieldsOptions = computed(() => {
|
|
|
132
148
|
return getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType);
|
|
133
149
|
});
|
|
134
150
|
|
|
151
|
+
const cascaderOptions = computed(() => {
|
|
152
|
+
const options =
|
|
153
|
+
dataSources.value?.map((ds) => ({
|
|
154
|
+
label: ds.title || ds.id,
|
|
155
|
+
value: valueIsKey.value ? ds.id : `${DATA_SOURCE_FIELDS_SELECT_VALUE_PREFIX}${ds.id}`,
|
|
156
|
+
children: getCascaderOptionsFromFields(ds.fields, props.dataSourceFieldType),
|
|
157
|
+
})) || [];
|
|
158
|
+
return options.filter((option) => option.children.length);
|
|
159
|
+
});
|
|
160
|
+
|
|
135
161
|
const dsChangeHandler = (v: string) => {
|
|
136
162
|
modelValue.value = [v];
|
|
137
163
|
emit('change', modelValue.value);
|
|
@@ -142,6 +168,11 @@ const fieldChangeHandler = (v: string[] = []) => {
|
|
|
142
168
|
emit('change', modelValue.value);
|
|
143
169
|
};
|
|
144
170
|
|
|
171
|
+
const onChangeHandler = (v: string[] = []) => {
|
|
172
|
+
modelValue.value = v;
|
|
173
|
+
emit('change', v);
|
|
174
|
+
};
|
|
175
|
+
|
|
145
176
|
const hasDataSourceSidePanel = computed(() =>
|
|
146
177
|
(services?.uiService.get('sideBarItems') || []).find((item) => item.$key === SideItemKey.DATA_SOURCE),
|
|
147
178
|
);
|
|
@@ -103,7 +103,7 @@ const config = computed<GroupListConfig>(() => ({
|
|
|
103
103
|
{
|
|
104
104
|
name: 'value',
|
|
105
105
|
type: (mForm, { model }) => {
|
|
106
|
-
const [id, ...fieldNames] = model.field;
|
|
106
|
+
const [id, ...fieldNames] = [...parentFields.value, ...model.field];
|
|
107
107
|
|
|
108
108
|
const ds = dataSourceService?.getDataSourceById(id);
|
|
109
109
|
|
|
@@ -41,7 +41,7 @@ export const useDataSourceMethod = () => {
|
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
let codeContent = method.content
|
|
44
|
+
let codeContent = method.content || `({ params, dataSource, app }) => {\n // place your code here\n}`;
|
|
45
45
|
|
|
46
46
|
if (typeof codeContent !== 'string') {
|
|
47
47
|
codeContent = codeContent.toString();
|
package/src/type.ts
CHANGED
|
@@ -774,7 +774,7 @@ export type PropsFormValueFunction = (data: { editorService: EditorService }) =>
|
|
|
774
774
|
export type PartSortableOptions = Omit<Options, 'onStart' | 'onUpdate'>;
|
|
775
775
|
export interface PageBarSortOptions extends PartSortableOptions {
|
|
776
776
|
/** 在onUpdate之后调用 */
|
|
777
|
-
afterUpdate
|
|
777
|
+
afterUpdate?: (event: SortableEvent, sortable: Sortable) => void;
|
|
778
778
|
/** 在onStart之前调用 */
|
|
779
|
-
beforeStart
|
|
779
|
+
beforeStart?: (event: SortableEvent, sortable: Sortable) => void;
|
|
780
780
|
}
|
package/types/type.d.ts
CHANGED
|
@@ -645,7 +645,7 @@ export type PropsFormValueFunction = (data: {
|
|
|
645
645
|
export type PartSortableOptions = Omit<Options, 'onStart' | 'onUpdate'>;
|
|
646
646
|
export interface PageBarSortOptions extends PartSortableOptions {
|
|
647
647
|
/** 在onUpdate之后调用 */
|
|
648
|
-
afterUpdate
|
|
648
|
+
afterUpdate?: (event: SortableEvent, sortable: Sortable) => void;
|
|
649
649
|
/** 在onStart之前调用 */
|
|
650
|
-
beforeStart
|
|
650
|
+
beforeStart?: (event: SortableEvent, sortable: Sortable) => void;
|
|
651
651
|
}
|