mirror of https://github.com/certd/certd
perf: aaWaf、cdnfly站点选择支持查询
parent
094565ccd6
commit
8af3463668
|
@ -38,6 +38,7 @@ export function createRemoteSelectInputDefine(opts?: {
|
||||||
required?: boolean;
|
required?: boolean;
|
||||||
rules?: any;
|
rules?: any;
|
||||||
mergeScript?: string;
|
mergeScript?: string;
|
||||||
|
search?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const title = opts?.title || "请选择";
|
const title = opts?.title || "请选择";
|
||||||
const certDomainsInputKey = opts?.certDomainsInputKey || "certDomains";
|
const certDomainsInputKey = opts?.certDomainsInputKey || "certDomains";
|
||||||
|
@ -47,6 +48,7 @@ export function createRemoteSelectInputDefine(opts?: {
|
||||||
const type = opts?.type || "plugin";
|
const type = opts?.type || "plugin";
|
||||||
const watches = opts?.watches || [];
|
const watches = opts?.watches || [];
|
||||||
const helper = opts?.helper || "请选择";
|
const helper = opts?.helper || "请选择";
|
||||||
|
const search = opts?.search ?? false;
|
||||||
let mode = "tags";
|
let mode = "tags";
|
||||||
if (opts.multi === false) {
|
if (opts.multi === false) {
|
||||||
mode = undefined;
|
mode = undefined;
|
||||||
|
@ -63,6 +65,7 @@ export function createRemoteSelectInputDefine(opts?: {
|
||||||
type,
|
type,
|
||||||
typeName,
|
typeName,
|
||||||
action,
|
action,
|
||||||
|
search,
|
||||||
watches: [certDomainsInputKey, accessIdInputKey, ...watches],
|
watches: [certDomainsInputKey, accessIdInputKey, ...watches],
|
||||||
},
|
},
|
||||||
rules: opts?.rules,
|
rules: opts?.rules,
|
||||||
|
|
|
@ -1,7 +1,26 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="remote-select">
|
<div class="remote-select">
|
||||||
<div class="flex flex-row">
|
<div class="flex flex-row">
|
||||||
<a-select class="remote-select-input" show-search :filter-option="filterOption" :options="optionsRef" :value="value" v-bind="attrs" @click="onClick" @update:value="emit('update:value', $event)" />
|
<a-select class="remote-select-input" show-search :filter-option="filterOption" :options="optionsRef" :value="value" v-bind="attrs" @click="onClick" @update:value="emit('update:value', $event)">
|
||||||
|
<template #dropdownRender="{ menuNode: menu }">
|
||||||
|
<template v-if="search">
|
||||||
|
<div class="flex w-full" style="padding: 4px 8px">
|
||||||
|
<a-input ref="inputRef" v-model:value="searchKeyRef" class="flex-1" allow-clear placeholder="查询关键字" @keydown.enter="doSearch" />
|
||||||
|
<a-button class="ml-2" :loading="loading" type="text" @click="doSearch">
|
||||||
|
<template #icon>
|
||||||
|
<search-outlined />
|
||||||
|
</template>
|
||||||
|
查询
|
||||||
|
</a-button>
|
||||||
|
</div>
|
||||||
|
<div v-if="hasError" class="helper p-2" :class="{ error: hasError }">
|
||||||
|
{{ message }}
|
||||||
|
</div>
|
||||||
|
<a-divider style="margin: 4px 0" />
|
||||||
|
</template>
|
||||||
|
<v-nodes :vnodes="menu" />
|
||||||
|
</template>
|
||||||
|
</a-select>
|
||||||
<div class="ml-5">
|
<div class="ml-5">
|
||||||
<fs-button :loading="loading" title="刷新选项" icon="ion:refresh-outline" @click="refreshOptions"></fs-button>
|
<fs-button :loading="loading" title="刷新选项" icon="ion:refresh-outline" @click="refreshOptions"></fs-button>
|
||||||
</div>
|
</div>
|
||||||
|
@ -13,16 +32,29 @@
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ComponentPropsType, doRequest } from "/@/components/plugins/lib";
|
import { ComponentPropsType, doRequest } from "/@/components/plugins/lib";
|
||||||
import { inject, ref, useAttrs, watch } from "vue";
|
import { defineComponent, inject, ref, useAttrs, watch } from "vue";
|
||||||
import { PluginDefine } from "@certd/pipeline";
|
import { PluginDefine } from "@certd/pipeline";
|
||||||
|
|
||||||
defineOptions({
|
defineOptions({
|
||||||
name: "RemoteSelect",
|
name: "RemoteSelect",
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const VNodes = defineComponent({
|
||||||
|
props: {
|
||||||
|
vnodes: {
|
||||||
|
type: Object,
|
||||||
|
required: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
return this.vnodes;
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const props = defineProps<
|
const props = defineProps<
|
||||||
{
|
{
|
||||||
watches: string[];
|
watches: string[];
|
||||||
|
search: boolean;
|
||||||
} & ComponentPropsType
|
} & ComponentPropsType
|
||||||
>();
|
>();
|
||||||
|
|
||||||
|
@ -36,6 +68,7 @@ const getCurrentPluginDefine: any = inject("getCurrentPluginDefine");
|
||||||
const getScope: any = inject("get:scope");
|
const getScope: any = inject("get:scope");
|
||||||
const getPluginType: any = inject("get:plugin:type");
|
const getPluginType: any = inject("get:plugin:type");
|
||||||
|
|
||||||
|
const searchKeyRef = ref("");
|
||||||
const optionsRef = ref([]);
|
const optionsRef = ref([]);
|
||||||
const message = ref("");
|
const message = ref("");
|
||||||
const hasError = ref(false);
|
const hasError = ref(false);
|
||||||
|
@ -81,6 +114,9 @@ const getOptions = async () => {
|
||||||
typeName: form.type,
|
typeName: form.type,
|
||||||
action: props.action,
|
action: props.action,
|
||||||
input,
|
input,
|
||||||
|
data: {
|
||||||
|
searchKey: props.search ? searchKeyRef.value : "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
onError(err: any) {
|
onError(err: any) {
|
||||||
|
@ -114,6 +150,10 @@ async function refreshOptions() {
|
||||||
await getOptions();
|
await getOptions();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function doSearch() {
|
||||||
|
await refreshOptions();
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => {
|
() => {
|
||||||
const values = [];
|
const values = [];
|
||||||
|
|
Loading…
Reference in New Issue