feat: 运行环境应用和版本增加联动 (#545)

This commit is contained in:
zhengkunwang223 2023-04-09 20:58:16 +08:00 committed by GitHub
parent 5c524f0d23
commit 49ab26200d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -34,7 +34,11 @@
<el-form-item :label="$t('runtime.app')" prop="appId">
<el-row :gutter="20">
<el-col :span="12">
<el-select v-model="runtime.appId" :disabled="mode === 'edit'">
<el-select
v-model="runtime.appId"
:disabled="mode === 'edit'"
@change="changeApp(runtime.appId)"
>
<el-option
v-for="(app, index) in apps"
:key="index"
@ -120,10 +124,10 @@ const runtimeForm = ref<FormInstance>();
const loading = ref(false);
const initParam = ref(false);
const mode = ref('create');
let appParams = ref<App.AppParams>();
let editParams = ref<App.InstallParams[]>();
let appVersions = ref<string[]>([]);
let appReq = reactive({
const appParams = ref<App.AppParams>();
const editParams = ref<App.InstallParams[]>();
const appVersions = ref<string[]>([]);
const appReq = reactive({
type: 'php',
page: 1,
pageSize: 20,
@ -136,7 +140,7 @@ const runtime = ref<Runtime.RuntimeCreate>({
type: 'php',
resource: 'appstore',
});
let rules = ref<any>({
const rules = ref<any>({
name: [Rules.appName],
resource: [Rules.requiredInput],
appId: [Rules.requiredSelect],
@ -180,6 +184,16 @@ const searchApp = (appId: number) => {
}
});
};
const changeApp = (appId: number) => {
for (const app of apps.value) {
if (app.id === appId) {
getApp(app.key, mode.value);
break;
}
}
};
const getApp = (appkey: string, mode: string) => {
GetApp(appkey).then((res) => {
appVersions.value = res.data.versions || [];