提交 d53d981f 编写于 作者: zhangkang's avatar zhangkang

update:datapicker选择器值抛出逻辑

上级 fe3f56b6
......@@ -83,6 +83,11 @@ interface DataPickerProps {
*/
sort?: string;
/**
* @description 分割符
*/
separator?: string;
/**
* @description 外键值附加数据
*/
......@@ -103,6 +108,7 @@ const props = withDefaults(defineProps<DataPickerProps>(), {
linkOnly: false,
isAC: false,
isDropdown: false,
separator: ';',
});
const emit = defineEmits<EditorEmit>();
const { handleEditorNavParams, openLinkView, openPickUpView } = new EditorBase();
......@@ -195,8 +201,19 @@ const onSelect = (value: any) => {
fillPickUpData(selectItem);
};
const initValue = (data: any) => {
// todo
// 编辑器抛值
const doEditorEmit = (data: any[]): any => {
let majorValue: any = '';
let keyValue: any = '';
data.forEach((item: any) => {
majorValue = majorValue + (majorValue ? props.separator : '') + item[props.deMajorField];
keyValue = keyValue + (keyValue ? props.separator : '') + item[props.deKeyField];
});
if (props.valueItem) {
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: keyValue });
}
emit('editorEvent', { tag: props.name, action: 'valueChange', data: majorValue });
return;
};
// 打开视图
......@@ -211,8 +228,7 @@ const openView = () => {
const subject = App.getOpenViewService().openView(view, {});
const subjectEvent = subject?.subscribe((data: any) => {
if (data?.ret == 'OK' && data.resultData) {
const value = initValue(data.resultData);
emit('editorEvent', { tag: props.valueItem, action: 'valueChange', data: value });
doEditorEmit(data.resultData);
}
subjectEvent?.unsubscribe();
});
......@@ -221,7 +237,7 @@ const openView = () => {
<template>
<template v-if="linkOnly" :class="['app-data-picker', `app-data-picker-${name}`]">
<a @click="openLinkView">{{ value }}</a>
<a @click="openLinkView"></a>
</template>
<template v-else-if="!isAC && !isDropdown">
<a-auto-complete
......
Markdown 格式
0% or
您添加了 0 到此讨论。请谨慎行事。
先完成此消息的编辑!
想要评论请 注册