mirror of
https://github.com/certd/certd.git
synced 2026-04-24 12:27:25 +08:00
perf: 优化access授权支持remote-auto-complete
This commit is contained in:
@@ -23,7 +23,7 @@ defineOptions({
|
|||||||
|
|
||||||
const props = defineProps<
|
const props = defineProps<
|
||||||
{
|
{
|
||||||
watches: string[];
|
watches?: string[];
|
||||||
} & ComponentPropsType
|
} & ComponentPropsType
|
||||||
>();
|
>();
|
||||||
|
|
||||||
@@ -48,6 +48,18 @@ const message = ref("");
|
|||||||
const hasError = ref(false);
|
const hasError = ref(false);
|
||||||
const loading = ref(false);
|
const loading = ref(false);
|
||||||
|
|
||||||
|
function getInputFromForm(form: any, pluginType: string) {
|
||||||
|
let input: any = {};
|
||||||
|
if (pluginType === "plugin") {
|
||||||
|
input = form?.input || {};
|
||||||
|
} else if (pluginType === "access") {
|
||||||
|
input = form?.access || {};
|
||||||
|
} else {
|
||||||
|
input = form || {};
|
||||||
|
}
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
const getOptions = async () => {
|
const getOptions = async () => {
|
||||||
if (loading.value) {
|
if (loading.value) {
|
||||||
return;
|
return;
|
||||||
@@ -63,15 +75,14 @@ const getOptions = async () => {
|
|||||||
}
|
}
|
||||||
const pluginType = getPluginType();
|
const pluginType = getPluginType();
|
||||||
const { form } = getScope();
|
const { form } = getScope();
|
||||||
const input = (pluginType === "plugin" ? form?.input : form) || {};
|
const input = getInputFromForm(form, pluginType);
|
||||||
|
|
||||||
for (let key in define.input) {
|
for (let key in define.input) {
|
||||||
const inWatches = props.watches?.includes(key);
|
const inWatches = props.watches?.includes(key);
|
||||||
const inputDefine = define.input[key];
|
const inputDefine = define.input[key];
|
||||||
if (inWatches && inputDefine.required) {
|
if (inWatches && inputDefine.required) {
|
||||||
const value = input[key];
|
const value = input[key];
|
||||||
if (value == null || value === "") {
|
if (value == null || value === "") {
|
||||||
console.log("remote-select required", key);
|
console.log("remote-auto-complete required", key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -129,12 +140,14 @@ watch(
|
|||||||
() => {
|
() => {
|
||||||
const pluginType = getPluginType();
|
const pluginType = getPluginType();
|
||||||
const { form, key } = getScope();
|
const { form, key } = getScope();
|
||||||
const input = (pluginType === "plugin" ? form?.input : form) || {};
|
const input = getInputFromForm(form, pluginType);
|
||||||
const watches = {};
|
const watches: any = {};
|
||||||
for (const key of props.watches) {
|
if (props.watches && props.watches.length > 0) {
|
||||||
//@ts-ignore
|
for (const key of props.watches) {
|
||||||
watches[key] = input[key];
|
watches[key] = input[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
form: watches,
|
form: watches,
|
||||||
key,
|
key,
|
||||||
@@ -144,6 +157,9 @@ watch(
|
|||||||
const { form } = value;
|
const { form } = value;
|
||||||
const oldForm: any = oldValue?.form;
|
const oldForm: any = oldValue?.form;
|
||||||
let changed = oldForm == null || optionsRef.value.length == 0;
|
let changed = oldForm == null || optionsRef.value.length == 0;
|
||||||
|
if (!props.watches || props.watches.length === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
for (const key of props.watches) {
|
for (const key of props.watches) {
|
||||||
//@ts-ignore
|
//@ts-ignore
|
||||||
if (oldForm && form[key] != oldForm[key]) {
|
if (oldForm && form[key] != oldForm[key]) {
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ const VNodes = defineComponent({
|
|||||||
|
|
||||||
const props = defineProps<
|
const props = defineProps<
|
||||||
{
|
{
|
||||||
watches: string[];
|
watches?: string[];
|
||||||
search?: boolean;
|
search?: boolean;
|
||||||
pager?: boolean;
|
pager?: boolean;
|
||||||
} & ComponentPropsType
|
} & ComponentPropsType
|
||||||
@@ -201,11 +201,13 @@ watch(
|
|||||||
const pluginType = getPluginType();
|
const pluginType = getPluginType();
|
||||||
const { form, key } = getScope();
|
const { form, key } = getScope();
|
||||||
const input = (pluginType === "plugin" ? form?.input : form) || {};
|
const input = (pluginType === "plugin" ? form?.input : form) || {};
|
||||||
const watches = {};
|
const watches: any = {};
|
||||||
for (const key of props.watches) {
|
if (props.watches && props.watches.length > 0) {
|
||||||
//@ts-ignore
|
for (const key of props.watches) {
|
||||||
watches[key] = input[key];
|
watches[key] = input[key];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
form: watches,
|
form: watches,
|
||||||
key,
|
key,
|
||||||
@@ -215,11 +217,12 @@ watch(
|
|||||||
const { form } = value;
|
const { form } = value;
|
||||||
const oldForm: any = oldValue?.form;
|
const oldForm: any = oldValue?.form;
|
||||||
let changed = oldForm == null || optionsRef.value.length == 0;
|
let changed = oldForm == null || optionsRef.value.length == 0;
|
||||||
for (const key of props.watches) {
|
if (props.watches && props.watches.length > 0) {
|
||||||
//@ts-ignore
|
for (const key of props.watches) {
|
||||||
if (oldForm && form[key] != oldForm[key]) {
|
if (oldForm && form[key] != oldForm[key]) {
|
||||||
changed = true;
|
changed = true;
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (changed) {
|
if (changed) {
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ export class HandleController extends BaseController {
|
|||||||
const accessGetter = new AccessGetter(userId, this.accessService.getById.bind(this.accessService));
|
const accessGetter = new AccessGetter(userId, this.accessService.getById.bind(this.accessService));
|
||||||
const access = await newAccess(body.typeName, inputAccess,accessGetter);
|
const access = await newAccess(body.typeName, inputAccess,accessGetter);
|
||||||
|
|
||||||
|
mergeUtils.merge(access, body.input);
|
||||||
const res = await access.onRequest(body);
|
const res = await access.onRequest(body);
|
||||||
|
|
||||||
return this.ok(res);
|
return this.ok(res);
|
||||||
|
|||||||
Reference in New Issue
Block a user