Merge branch 'v2-dev' into v2_admin_mode

This commit is contained in:
xiaojunnuo
2026-02-09 23:13:43 +08:00
40 changed files with 243 additions and 148 deletions
@@ -23,7 +23,7 @@ defineOptions({
const props = defineProps<
{
watches: string[];
watches?: string[];
} & ComponentPropsType
>();
@@ -48,6 +48,18 @@ const message = ref("");
const hasError = 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 () => {
if (loading.value) {
return;
@@ -63,15 +75,14 @@ const getOptions = async () => {
}
const pluginType = getPluginType();
const { form } = getScope();
const input = (pluginType === "plugin" ? form?.input : form) || {};
const input = getInputFromForm(form, pluginType);
for (let key in define.input) {
const inWatches = props.watches?.includes(key);
const inputDefine = define.input[key];
if (inWatches && inputDefine.required) {
const value = input[key];
if (value == null || value === "") {
console.log("remote-select required", key);
console.log("remote-auto-complete required", key);
return;
}
}
@@ -129,12 +140,14 @@ watch(
() => {
const pluginType = getPluginType();
const { form, key } = getScope();
const input = (pluginType === "plugin" ? form?.input : form) || {};
const watches = {};
for (const key of props.watches) {
//@ts-ignore
watches[key] = input[key];
const input = getInputFromForm(form, pluginType);
const watches: any = {};
if (props.watches && props.watches.length > 0) {
for (const key of props.watches) {
watches[key] = input[key];
}
}
return {
form: watches,
key,
@@ -144,6 +157,9 @@ watch(
const { form } = value;
const oldForm: any = oldValue?.form;
let changed = oldForm == null || optionsRef.value.length == 0;
if (!props.watches || props.watches.length === 0) {
return;
}
for (const key of props.watches) {
//@ts-ignore
if (oldForm && form[key] != oldForm[key]) {
@@ -57,7 +57,7 @@ const VNodes = defineComponent({
const props = defineProps<
{
watches: string[];
watches?: string[];
search?: boolean;
pager?: boolean;
} & ComponentPropsType
@@ -79,6 +79,17 @@ const getPluginType: any = inject("get:plugin:type", () => {
return "plugin";
});
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 searchKeyRef = ref("");
const optionsRef = ref([]);
const message = ref("");
@@ -104,7 +115,7 @@ const getOptions = async () => {
}
const pluginType = getPluginType();
const { form } = getScope();
const input = (pluginType === "plugin" ? form?.input : form) || {};
const input = getInputFromForm(form, pluginType);
for (let key in define.input) {
const inWatches = props.watches?.includes(key);
@@ -200,12 +211,14 @@ watch(
() => {
const pluginType = getPluginType();
const { form, key } = getScope();
const input = (pluginType === "plugin" ? form?.input : form) || {};
const watches = {};
for (const key of props.watches) {
//@ts-ignore
watches[key] = input[key];
const input = getInputFromForm(form, pluginType);
const watches: any = {};
if (props.watches && props.watches.length > 0) {
for (const key of props.watches) {
watches[key] = input[key];
}
}
return {
form: watches,
key,
@@ -215,11 +228,12 @@ watch(
const { form } = value;
const oldForm: any = oldValue?.form;
let changed = oldForm == null || optionsRef.value.length == 0;
for (const key of props.watches) {
//@ts-ignore
if (oldForm && form[key] != oldForm[key]) {
changed = true;
break;
if (props.watches && props.watches.length > 0) {
for (const key of props.watches) {
if (oldForm && form[key] != oldForm[key]) {
changed = true;
break;
}
}
}
if (changed) {