feat: ApiTree add afterFetch props,add ApiTree demo
This commit is contained in:
parent
e3637e7af4
commit
3b86435766
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in New Issue