refactor: rsa存储方式调整等

This commit is contained in:
meilin.huang
2023-12-17 01:43:38 +08:00
parent 970d74bd70
commit 7d62841783
8 changed files with 209 additions and 80 deletions

View File

@@ -67,7 +67,7 @@ const handleSearchProps = computed(() => {
// 处理透传的 事件
const handleEvents = computed(() => {
let itemEvents = props.item?.props ?? {};
let itemEvents = props.item?.events ?? {};
return itemEvents;
});

View File

@@ -49,6 +49,13 @@ export class OptionsApi {
*/
convertFn: (apiResp: any) => any;
// remote: boolean = false;
/**
* 远程方法参数属性字段存在该值则说明使用remote-method进行远程搜索
*/
remoteMethodParamProp: string;
withConvertFn(fn: (apiResp: any) => any) {
this.convertFn = fn;
return this;
@@ -72,6 +79,15 @@ export class OptionsApi {
return this;
}
/**
* 是否使用select的remote方式远程搜索调用
* @param remoteReqParamKey remote请求参数对应的prop需要将输入的value赋值给params[paramProp]进行远程搜索
*/
isRemote(paramProp: string) {
this.remoteMethodParamProp = paramProp;
return this;
}
/**
* 调用api获取组件可选项
* @returns 组件可选项信息
@@ -228,7 +244,7 @@ export class SearchItem {
if (!this.events) {
this.events = {};
}
this.props[event] = eventFn;
this.events[event] = eventFn;
return this;
}
@@ -252,6 +268,19 @@ export class SearchItem {
// 使用api获取组件可选项需要将options转为响应式否则组件无法响应式获取组件可选项
this.options = ref(null);
// 存在远程搜索请求参数prop则为使用远程搜索可选项
if (optionsApi.remoteMethodParamProp) {
return this.withOneProps('remote', true).withOneProps('remote-method', async (value: any) => {
if (!value) {
this.options.value = [];
return;
}
// 将输入的内容赋值为真实api请求参数中指定的属性字段
optionsApi.params[optionsApi.remoteMethodParamProp] = value;
this.options.value = await this.optionsApi.getOptions();
});
}
// 立即执行则直接调用api获取并赋值options
if (this.optionsApi.immediate) {
this.optionsApi.getOptions().then((res) => {
@@ -277,4 +306,13 @@ export class SearchItem {
this.options = options;
return this;
}
/**
* 赋值placeholder
* @param val placeholder
* @returns
*/
withPlaceholder(val: string): SearchItem {
return this.withOneProps('placeholder', val);
}
}