This commit is contained in:
LIghtJUNction
2025-10-26 15:41:36 +08:00

View File

@@ -1,5 +1,5 @@
<template> <template>
<v-dialog v-model="showDialog" max-width="800px" height="90%"> <v-dialog v-model="showDialog" max-width="800px" height="90%" @after-enter="prepareData">
<v-card <v-card
:title="updatingMode ? `${tm('dialog.edit')} ${updatingPlatformConfig.id} ${tm('dialog.adapter')}` : tm('dialog.addPlatform')"> :title="updatingMode ? `${tm('dialog.edit')} ${updatingPlatformConfig.id} ${tm('dialog.adapter')}` : tm('dialog.addPlatform')">
<v-card-text class="pa-4 ml-2" style="overflow-y: auto;"> <v-card-text class="pa-4 ml-2" style="overflow-y: auto;">
@@ -145,32 +145,38 @@
添加路由规则 添加路由规则
</v-btn> </v-btn>
</div> </div>
<v-btn :color="isEditingRoutes ? 'grey' : 'primary'" variant="tonal" size="small" @click="toggleEditMode"> <v-btn :color="isEditingRoutes ? 'grey' : 'primary'" variant="tonal" size="small"
@click="toggleEditMode">
<v-icon start>{{ isEditingRoutes ? 'mdi-eye' : 'mdi-pencil' }}</v-icon> <v-icon start>{{ isEditingRoutes ? 'mdi-eye' : 'mdi-pencil' }}</v-icon>
{{ isEditingRoutes ? '查看' : '编辑' }} {{ isEditingRoutes ? '查看' : '编辑' }}
</v-btn> </v-btn>
</div> </div>
<v-data-table :headers="routeTableHeaders" :items="platformRoutes" item-value="umop" <v-data-table :headers="routeTableHeaders" :items="platformRoutes" item-value="umop"
no-data-text="该平台暂无路由规则将使用默认配置文件" hide-default-footer :items-per-page="-1" class="mt-2" variant="outlined"> no-data-text="该平台暂无路由规则将使用默认配置文件" hide-default-footer :items-per-page="-1" class="mt-2"
variant="outlined">
<template v-slot:item.source="{ item }"> <template v-slot:item.source="{ item }">
<div class="d-flex align-center" style="min-width: 250px;"> <div class="d-flex align-center" style="min-width: 250px;">
<v-select v-if="isEditingRoutes" v-model="item.messageType" :items="messageTypeOptions" item-title="label" item-value="value" <v-select v-if="isEditingRoutes" v-model="item.messageType" :items="messageTypeOptions"
variant="outlined" density="compact" hide-details style="max-width: 120px;" class="mr-2"> item-title="label" item-value="value" variant="outlined" density="compact" hide-details
style="max-width: 120px;" class="mr-2">
</v-select> </v-select>
<span v-else class="mr-2">{{ getMessageTypeLabel(item.messageType) }}</span> <span v-else class="mr-2">{{ getMessageTypeLabel(item.messageType) }}</span>
<span class="mx-1">:</span> <span class="mx-1">:</span>
<v-text-field v-if="isEditingRoutes" v-model="item.sessionId" variant="outlined" density="compact" hide-details <v-text-field v-if="isEditingRoutes" v-model="item.sessionId" variant="outlined" density="compact"
placeholder="会话ID或*" style="max-width: 120px;"> hide-details placeholder="会话ID或*" style="max-width: 120px;">
</v-text-field> </v-text-field>
<span v-else>{{ item.sessionId === '*' ? '全部会话' : item.sessionId }}</span> <span v-else>{{ item.sessionId === '*' ? '全部会话' : item.sessionId }}</span>
</div> </div>
</template> </template>
<template v-slot:item.configId="{ item }"> <template v-slot:item.configId="{ item }">
<v-select v-if="isEditingRoutes" v-model="item.configId" :items="configInfoList" item-title="name" item-value="id" <v-select v-if="isEditingRoutes" v-model="item.configId" :items="configInfoList" item-title="name"
variant="outlined" density="compact" hide-details style="min-width: 200px;"> item-value="id" variant="outlined" density="compact" style="min-width: 200px;"
:hide-details="configInfoList.findIndex(c => c.id === item.configId) !== -1"
:error="configInfoList.findIndex(c => c.id === item.configId) === -1"
:error-messages="configInfoList.findIndex(c => c.id === item.configId) === -1 ? '配置文件不存在' : ''">
</v-select> </v-select>
<span v-else>{{ getConfigName(item.configId) }}</span> <span v-else>{{ getConfigName(item.configId) }}</span>
</template> </template>
@@ -180,7 +186,8 @@
<v-btn icon size="x-small" variant="text" @click="moveRouteUp(index)" :disabled="index === 0"> <v-btn icon size="x-small" variant="text" @click="moveRouteUp(index)" :disabled="index === 0">
<v-icon>mdi-arrow-up</v-icon> <v-icon>mdi-arrow-up</v-icon>
</v-btn> </v-btn>
<v-btn icon size="x-small" variant="text" @click="moveRouteDown(index)" :disabled="index === platformRoutes.length - 1"> <v-btn icon size="x-small" variant="text" @click="moveRouteDown(index)"
:disabled="index === platformRoutes.length - 1">
<v-icon>mdi-arrow-down</v-icon> <v-icon>mdi-arrow-down</v-icon>
</v-btn> </v-btn>
<v-btn icon size="x-small" variant="text" color="error" @click="deleteRoute(index)"> <v-btn icon size="x-small" variant="text" color="error" @click="deleteRoute(index)">
@@ -191,7 +198,8 @@
</template> </template>
</v-data-table> </v-data-table>
<small class="ml-2 mt-2 d-block">*消息下发时根据会话来源按顺序从上到下匹配首个符合条件的配置文件使用 * 表示匹配所有使用 /sid 指令获取会话 ID</small> <small class="ml-2 mt-2 d-block">*消息下发时,根据会话来源按顺序从上到下匹配首个符合条件的配置文件。使用 * 表示匹配所有。使用 /sid 指令获取会话
ID。全部不匹配时将使用默认配置文件。</small>
</div> </div>
</div> </div>
@@ -674,7 +682,7 @@ export default {
const newConfigId = createRes.data.data.conf_id; const newConfigId = createRes.data.data.conf_id;
console.log(`成功创建新配置文件 ${configName}ID: ${newConfigId}`); console.log(`成功创建新配置文件 ${configName}ID: ${newConfigId}`);
return newConfigId; return newConfigId;
} catch (err) { } catch (err) {
console.error('创建新配置文件失败:', err); console.error('创建新配置文件失败:', err);
@@ -754,7 +762,7 @@ export default {
} }
this.platformRoutes = routes; this.platformRoutes = routes;
// 如果没有路由,添加一个默认的空路由供用户编辑 // 如果没有路由,添加一个默认的空路由供用户编辑
if (this.platformRoutes.length === 0) { if (this.platformRoutes.length === 0) {
this.platformRoutes.push({ this.platformRoutes.push({
@@ -833,7 +841,7 @@ export default {
const messageType = route.messageType === '*' ? '*' : route.messageType; const messageType = route.messageType === '*' ? '*' : route.messageType;
const sessionId = route.sessionId === '*' ? '*' : route.sessionId; const sessionId = route.sessionId === '*' ? '*' : route.sessionId;
const newUmop = `${platformId}:${messageType}:${sessionId}`; const newUmop = `${platformId}:${messageType}:${sessionId}`;
if (route.configId) { if (route.configId) {
fullRoutingTable[newUmop] = route.configId; fullRoutingTable[newUmop] = route.configId;
} }
@@ -882,16 +890,17 @@ export default {
toggleShowConfigSection() { toggleShowConfigSection() {
this.showConfigSection = false; this.showConfigSection = false;
this.showConfigSection = true; this.showConfigSection = true;
},
prepareData() {
this.getConfigInfoList();
this.getConfigForPreview(this.selectedAbConfId);
if (this.updatingMode && this.updatingPlatformConfig && this.updatingPlatformConfig.id) {
this.getPlatformConfigs(this.updatingPlatformConfig.id);
}
} }
}, },
mounted() {
this.getConfigInfoList();
this.getConfigForPreview(this.selectedAbConfId);
if (this.updatingMode && this.updatingPlatformConfig && this.updatingPlatformConfig.id) {
this.getPlatformConfigs(this.updatingPlatformConfig.id);
}
}
} }
</script> </script>