Skip to content

Commit 62460ec

Browse files
committed
feat: datasource link support location and member
1 parent e752be3 commit 62460ec

File tree

2 files changed

+44
-8
lines changed

2 files changed

+44
-8
lines changed

frontend/packages/web/src/components/business/crm-form-create/index.vue

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@
8383
import { formKeyMap } from '../crm-data-source-select/config';
8484
import { FormulaDataSourceMap } from '../crm-formula/formula-runtime/types';
8585
import { safeParseFormula } from '../crm-formula-editor/utils';
86-
import { getFormConfigApiMap } from './config';
86+
import { getFormConfigApiMap, multipleValueTypeList } from './config';
8787
8888
const props = defineProps<{
8989
isEdit?: boolean;
@@ -295,10 +295,14 @@
295295
currentDatasourceFormField.businessKey
296296
]
297297
: currentSource?.[linkField.link];
298-
// 处理多选/单选数据源
299-
formDetail.value[targetField.id] = Array.isArray(currentSourceValue)
300-
? currentSourceValue
301-
: [currentSourceValue];
298+
// 处理多选/单选值
299+
if (multipleValueTypeList.includes(targetField.type)) {
300+
formDetail.value[targetField.id] = Array.isArray(currentSourceValue)
301+
? currentSourceValue
302+
: [currentSourceValue];
303+
} else {
304+
formDetail.value[targetField.id] = currentSourceValue;
305+
}
302306
if (!targetField.initialOptions) {
303307
targetField.initialOptions = Array.isArray(currentSourceValue)
304308
? currentSourceValue.map((e, i) => ({

frontend/packages/web/src/components/business/crm-form-design/components/formAttrConfig/datasourceLinkModal.vue

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,15 @@
378378
try {
379379
const res = await getFieldDisplayList(formKey.value);
380380
linkFieldOptions.value = res.fields
381-
.filter((e) => [FieldTypeEnum.DATA_SOURCE, FieldTypeEnum.DATA_SOURCE_MULTIPLE].includes(e.type))
381+
.filter((e) =>
382+
[
383+
FieldTypeEnum.DATA_SOURCE,
384+
FieldTypeEnum.DATA_SOURCE_MULTIPLE,
385+
FieldTypeEnum.MEMBER,
386+
FieldTypeEnum.MEMBER_MULTIPLE,
387+
FieldTypeEnum.LOCATION,
388+
].includes(e.type)
389+
)
382390
.map((item) => {
383391
return {
384392
label: item.name,
@@ -403,7 +411,25 @@
403411
const currentField = props.formFields.find((f) => f.id === currentFieldId);
404412
if (currentField?.type === FieldTypeEnum.DATA_SOURCE) {
405413
// 单选数据源不能填充多选数据源
406-
return linkFieldOptions.value.filter((f) => f.type !== FieldTypeEnum.DATA_SOURCE_MULTIPLE);
414+
return linkFieldOptions.value.filter((f) => f.type === FieldTypeEnum.DATA_SOURCE);
415+
}
416+
if (currentField?.type === FieldTypeEnum.DATA_SOURCE_MULTIPLE) {
417+
return linkFieldOptions.value.filter((f) =>
418+
[FieldTypeEnum.DATA_SOURCE, FieldTypeEnum.DATA_SOURCE_MULTIPLE].includes(f.type)
419+
);
420+
}
421+
if (currentField?.type === FieldTypeEnum.MEMBER) {
422+
// 单选成员不能填充多选成员
423+
return linkFieldOptions.value.filter((f) => f.type === FieldTypeEnum.MEMBER);
424+
}
425+
if (currentField?.type === FieldTypeEnum.MEMBER_MULTIPLE) {
426+
// 多选成员不能填充单选成员
427+
return linkFieldOptions.value.filter((f) =>
428+
[FieldTypeEnum.MEMBER, FieldTypeEnum.MEMBER_MULTIPLE].includes(f.type)
429+
);
430+
}
431+
if (currentField?.type === FieldTypeEnum.LOCATION) {
432+
return linkFieldOptions.value.filter((f) => f.type === FieldTypeEnum.LOCATION);
407433
}
408434
return linkFieldOptions.value;
409435
}
@@ -413,7 +439,13 @@
413439
return props.formFields
414440
.filter(
415441
(f) =>
416-
[FieldTypeEnum.DATA_SOURCE, FieldTypeEnum.DATA_SOURCE_MULTIPLE].includes(f.type) &&
442+
[
443+
FieldTypeEnum.DATA_SOURCE,
444+
FieldTypeEnum.DATA_SOURCE_MULTIPLE,
445+
FieldTypeEnum.LOCATION,
446+
FieldTypeEnum.MEMBER,
447+
FieldTypeEnum.MEMBER_MULTIPLE,
448+
].includes(f.type) &&
417449
f.id !== props.fieldConfig.id &&
418450
(f.id === currentFieldId || !alreadySelectedFields.includes(f.id)) &&
419451
!f.resourceFieldId

0 commit comments

Comments
 (0)