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