feat: 所有租户选择改为下拉列表
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
111
2026-01-24 10:31:57 +08:00
parent 1c95fef01a
commit b055be1bb6
2 changed files with 60 additions and 25 deletions

View File

@@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, reactive, onMounted, computed } from 'vue' import { ref, reactive, onMounted, computed, watch } from 'vue'
import { ElMessage, ElMessageBox } from 'element-plus' import { ElMessage, ElMessageBox } from 'element-plus'
import api from '@/api' import api from '@/api'
import { useAuthStore } from '@/stores/auth' import { useAuthStore } from '@/stores/auth'
@@ -16,6 +16,9 @@ const query = reactive({
app_code: '' app_code: ''
}) })
// 租户列表
const tenantList = ref([])
// 应用列表(从应用管理获取) // 应用列表(从应用管理获取)
const appList = ref([]) const appList = ref([])
const appRequireJssdk = ref({}) // app_code -> require_jssdk const appRequireJssdk = ref({}) // app_code -> require_jssdk
@@ -53,15 +56,34 @@ const validateAppCode = (rule, value, callback) => {
} }
const rules = { const rules = {
tenant_id: [{ required: true, message: '请输入租户ID', trigger: 'blur' }], tenant_id: [{ required: true, message: '请选择租户', trigger: 'change' }],
app_code: [{ required: true, validator: validateAppCode, trigger: 'change' }] app_code: [{ required: true, validator: validateAppCode, trigger: 'change' }]
} }
// 监听租户选择变化
watch(() => form.tenant_id, async (newVal) => {
if (newVal) {
await fetchWechatApps(newVal)
} else {
wechatAppList.value = []
}
form.wechat_app_id = null
})
// 查看 Token 对话框 // 查看 Token 对话框
const tokenDialogVisible = ref(false) const tokenDialogVisible = ref(false)
const currentToken = ref('') const currentToken = ref('')
const currentAppUrl = ref('') const currentAppUrl = ref('')
async function fetchTenants() {
try {
const res = await api.get('/api/tenants', { params: { size: 1000 } })
tenantList.value = res.data.items || []
} catch (e) {
console.error('获取租户列表失败:', e)
}
}
async function fetchApps() { async function fetchApps() {
try { try {
const res = await api.get('/api/apps', { params: { size: 100 } }) const res = await api.get('/api/apps', { params: { size: 100 } })
@@ -139,10 +161,6 @@ async function handleEdit(row) {
dialogVisible.value = true dialogVisible.value = true
} }
async function handleTenantChange() {
form.wechat_app_id = null
await fetchWechatApps(form.tenant_id)
}
async function handleSubmit() { async function handleSubmit() {
await formRef.value.validate() await formRef.value.validate()
@@ -220,6 +238,7 @@ async function handleViewToken(row) {
} }
onMounted(() => { onMounted(() => {
fetchTenants()
fetchApps() fetchApps()
fetchList() fetchList()
}) })
@@ -243,14 +262,15 @@ onMounted(() => {
<!-- 搜索栏 --> <!-- 搜索栏 -->
<div class="search-bar"> <div class="search-bar">
<el-input <el-select v-model="query.tenant_id" placeholder="选择租户" clearable filterable style="width: 200px">
v-model="query.tenant_id" <el-option
placeholder="租户ID" v-for="tenant in tenantList"
clearable :key="tenant.code"
style="width: 160px" :label="`${tenant.name} (${tenant.code})`"
@keyup.enter="handleSearch" :value="tenant.code"
/> />
<el-select v-model="query.app_code" placeholder="应用" clearable style="width: 150px"> </el-select>
<el-select v-model="query.app_code" placeholder="选择应用" clearable style="width: 150px">
<el-option v-for="app in appList" :key="app.app_code" :label="app.app_name" :value="app.app_code" /> <el-option v-for="app in appList" :key="app.app_code" :label="app.app_name" :value="app.app_code" />
</el-select> </el-select>
<el-button type="primary" @click="handleSearch">搜索</el-button> <el-button type="primary" @click="handleSearch">搜索</el-button>
@@ -307,13 +327,21 @@ onMounted(() => {
<!-- 编辑对话框 --> <!-- 编辑对话框 -->
<el-dialog v-model="dialogVisible" :title="dialogTitle" width="550px"> <el-dialog v-model="dialogVisible" :title="dialogTitle" width="550px">
<el-form ref="formRef" :model="form" :rules="rules" label-width="120px"> <el-form ref="formRef" :model="form" :rules="rules" label-width="120px">
<el-form-item label="租户ID" prop="tenant_id"> <el-form-item label="租户" prop="tenant_id">
<el-input <el-select
v-model="form.tenant_id" v-model="form.tenant_id"
:disabled="!!editingId" :disabled="!!editingId"
placeholder="如: qiqi" placeholder="请选择租户"
@blur="handleTenantChange" filterable
/> style="width: 100%"
>
<el-option
v-for="tenant in tenantList"
:key="tenant.code"
:label="`${tenant.name} (${tenant.code})`"
:value="tenant.code"
/>
</el-select>
</el-form-item> </el-form-item>
<el-form-item label="应用" prop="app_code"> <el-form-item label="应用" prop="app_code">
<el-select v-model="form.app_code" :disabled="!!editingId" placeholder="选择要订阅的应用" style="width: 100%"> <el-select v-model="form.app_code" :disabled="!!editingId" placeholder="选择要订阅的应用" style="width: 100%">

View File

@@ -189,13 +189,20 @@ onMounted(() => {
<!-- 搜索栏 --> <!-- 搜索栏 -->
<div class="search-bar"> <div class="search-bar">
<el-input <el-select
v-model="query.tenant_id" v-model="query.tenant_id"
placeholder="租户ID" placeholder="选择租户"
clearable clearable
filterable
style="width: 200px" style="width: 200px"
@keyup.enter="handleSearch" >
/> <el-option
v-for="tenant in tenantList"
:key="tenant.code"
:label="`${tenant.name} (${tenant.code})`"
:value="tenant.code"
/>
</el-select>
<el-button type="primary" @click="handleSearch">搜索</el-button> <el-button type="primary" @click="handleSearch">搜索</el-button>
</div> </div>