提交 3b864357 编写于 作者: J JinMao

feat: ApiTree add afterFetch props,add ApiTree demo

上级 e3637e7a
......@@ -24,6 +24,7 @@
params: { type: Object },
immediate: { type: Boolean, default: true },
resultField: propTypes.string.def(''),
afterFetch: { type: Function as PropType<Fn> },
},
emits: ['options-change', 'change'],
setup(props, { attrs, emit }) {
......@@ -61,7 +62,7 @@
});
async function fetch() {
const { api } = props;
const { api, afterFetch } = props;
if (!api || !isFunction(api)) return;
loading.value = true;
treeData.value = [];
......@@ -71,6 +72,9 @@
} catch (e) {
console.error(e);
}
if (afterFetch && isFunction(afterFetch)) {
result = afterFetch(result);
}
loading.value = false;
if (!result) return;
if (!isArray(result)) {
......
......@@ -460,6 +460,27 @@
span: 8,
},
},
{
field: 'field36',
component: 'ApiTree',
label: '远程Tree',
helpMessage: ['ApiTree组件', '使用接口提供的数据生成选项'],
required: true,
componentProps: {
api: treeOptionsListApi,
params: {
count: 2,
},
afterFetch: (v) => {
//do something
return v;
},
resultField: 'list',
},
colProps: {
span: 8,
},
},
{
field: 'divider-linked',
component: 'Divider',
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册