import{_ as n,c as a,a as p,o as e}from"./app-CDlLWk6N.js";const t={};function l(o,s){return e(),a("div",null,s[0]||(s[0]=[p(`

使用远程数据源

如果有些组件(联想弹层、下拉框等)的显示数据不想使用预设的数据源或者magicAPI,也可以使用自写的接口。

如下代码所示,可以在config.ts文件中通过修改对应组件项中的componentProps中的apiCconfig属性来使用自写的接口,datasourceType的属性值应为api。apiParams则为对应的接口请求参数,其中也可以使用当前表单中的参数来充当请求接口的参数,如例子所示。

{
    datasourceType: 'api',
    params: { itemId: '' },
    apiConfig: {
        path: 'CodeGeneration/selection',
        method: 'GET',
        apiId: '93d735dcb7364a0f8102188ec4d77ac7',
        apiParams: [
            { key: '1', title: 'Query Params', tableInfo: [
            {
                name: 'projectId', // 参数名称
                value: '{"bindField":"selectProjectId","fieldKey":"xxxxxxxxxxxx"}',
                // bindField是表单中的字段名即field,fieldKey是的key值,这两个值需要和表单中的值对应。
                // 当绑定的表单字段值发生变化时,会自动用新参数重新请求接口。
                // value 也可以是一个固定值,写为正常的字符串即可。
                description: null,
                required: false,
                dataType: 'String',
                type: null,
                defaultValue: null,
                validateType: null,
                error: null,
                expression: null,
                children: null,
                bindType: 'data',
            },
            //多个参数时,只需要在数组中添加即可。
            ] },
            { key: '2', title: 'Header', tableInfo: [] },
            { key: '3', title: 'Body' },
        ],
    },
},
`,4)]))}const c=n(t,[["render",l]]),i=JSON.parse('{"path":"/front_dev/base/ajax.html","title":"使用远程数据源","lang":"en-US","frontmatter":{},"headers":[],"git":{"updatedTime":1744278865000,"contributors":[{"name":"DESKTOP-45LLIKH\\\\11405","username":"","email":"1140589958@qq.com","commits":3}],"changelog":[{"hash":"a3e2cde9db0dbccdbce661749aef03650a6b701f","time":1744278865000,"email":"1140589958@qq.com","author":"DESKTOP-45LLIKH\\\\11405","message":"feat: 二开文档优化"},{"hash":"51b826e36d1d26ef2ed843c669a1ab12b3fcb8f5","time":1744257372000,"email":"1140589958@qq.com","author":"DESKTOP-45LLIKH\\\\11405","message":"feat: 文档优化 新写 为工具栏添加按钮, 为表单新添加新字段"},{"hash":"bb33c9cfb0a16dc1df1c8e1434b41b052a489710","time":1744192947000,"email":"1140589958@qq.com","author":"DESKTOP-45LLIKH\\\\11405","message":"feat: 值计算,修改组件值,自定义校验,使用远程数据源"}]},"filePathRelative":"front_dev/base/ajax.md"}');export{c as comp,i as data};