feat: 控件加入Header 参数控制

This commit is contained in:
limingz 2023-03-10 13:46:53 +08:00 committed by 奔跑的面条
parent 35664e7e3d
commit 3f3f54f3b7
2 changed files with 19 additions and 5 deletions

View File

@ -15,9 +15,14 @@ export const eventsCreate = (chartConfig: CreateComponentType, useChartEditStore
if (fnOnEvevnt.length === 0) return if (fnOnEvevnt.length === 0) return
fnOnEvevnt.forEach((item) => { fnOnEvevnt.forEach((item) => {
const index = chartEditStore.fetchTargetIndex(item.components) const index = chartEditStore.fetchTargetIndex(item.components)
const { Params } = toRefs(chartEditStore.componentList[index].request.requestParams) const { Params, Header } = toRefs(chartEditStore.componentList[index].request.requestParams)
Object.keys(item.fn).forEach((key) => { Object.keys(item.fn).forEach((key) => {
Params.value[key] = param[item.fn[key]] if (Params.value[key]) {
Params.value[key] = param[item.fn[key]]
}
if (Header.value[key]) {
Header.value[key] = param[item.fn[key]]
}
}) })
}) })
} }

View File

@ -37,7 +37,16 @@
<CollapseItem name="请求数据绑定" :expanded="false"> <CollapseItem name="请求数据绑定" :expanded="false">
<SettingItemBox name="Params"> <SettingItemBox name="Params">
<SettingItem <SettingItem
v-for="(ovlValue, ovlKey, index) in fnGetRequest(item.components)" v-for="(ovlValue, ovlKey, index) in fnGetRequest(item.components, 'Params')"
:key="ovlKey"
:name="`${ovlKey}`"
>
<n-select size="small" v-model:value="item.fn[ovlKey]" :options="fnDimensionsAndSource(item.on)"></n-select>
</SettingItem>
</SettingItemBox>
<SettingItemBox name="Header">
<SettingItem
v-for="(ovlValue, ovlKey, index) in fnGetRequest(item.components, 'Header')"
:key="ovlKey" :key="ovlKey"
:name="`${ovlKey}`" :name="`${ovlKey}`"
> >
@ -70,9 +79,9 @@ const option = computed(() => {
return chartEditStore.componentList[chartEditStore.fetchTargetIndex()].option return chartEditStore.componentList[chartEditStore.fetchTargetIndex()].option
}) })
// request // request
const fnGetRequest = (id: string | undefined) => { const fnGetRequest = (id: string | undefined, key: 'Params' | 'Header') => {
if (!id) return {} if (!id) return {}
return chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]?.request.requestParams.Params return chartEditStore.componentList[chartEditStore.fetchTargetIndex(id)]?.request.requestParams[key]
} }
const fnDimensionsAndSource = (on: any) => { const fnDimensionsAndSource = (on: any) => {