mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 07:03:53 +08:00
@@ -1,18 +1,25 @@
|
||||
<template>
|
||||
<el-dialog :title="title" :visible.sync="dialogVisible" :close-on-click-modal="false" @close="handleClose"
|
||||
@open="handleOpen">
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="auto">
|
||||
<CustomDialog
|
||||
:title="title"
|
||||
:visible.sync="visible"
|
||||
width="800px"
|
||||
@confirm="submit"
|
||||
@close="cancel"
|
||||
@open="handleOpen"
|
||||
:confirmLoading="saving"
|
||||
>
|
||||
<el-form ref="form" :model="form" :rules="rules" label-width="auto" label-position="left" class="firmware-form">
|
||||
<el-form-item :label="$t('firmwareDialog.firmwareName')" prop="firmwareName">
|
||||
<el-input v-model="form.firmwareName" :placeholder="$t('firmwareDialog.firmwareNamePlaceholder')"></el-input>
|
||||
<el-input v-model="form.firmwareName" :placeholder="$t('firmwareDialog.firmwareNamePlaceholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('firmwareDialog.firmwareType')" prop="type">
|
||||
<el-select v-model="form.type" :placeholder="$t('firmwareDialog.firmwareTypePlaceholder')" style="width: 100%;"
|
||||
filterable :disabled="isTypeDisabled">
|
||||
<el-select v-model="form.type" :placeholder="$t('firmwareDialog.firmwareTypePlaceholder')"
|
||||
class="custom-select" filterable :disabled="isTypeDisabled">
|
||||
<el-option v-for="item in firmwareTypes" :key="item.key" :label="item.name" :value="item.key"></el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('firmwareDialog.version')" prop="version">
|
||||
<el-input v-model="form.version" :placeholder="$t('firmwareDialog.versionPlaceholder')"></el-input>
|
||||
<el-input v-model="form.version" :placeholder="$t('firmwareDialog.versionPlaceholder')" />
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('firmwareDialog.firmwareFile')" prop="firmwarePath">
|
||||
<el-upload ref="upload" class="upload-demo" action="#" :http-request="handleUpload"
|
||||
@@ -29,21 +36,21 @@
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('firmwareDialog.remark')" prop="remark">
|
||||
<el-input type="textarea" v-model="form.remark"
|
||||
:placeholder="$t('firmwareDialog.remarkPlaceholder')"></el-input>
|
||||
:placeholder="$t('firmwareDialog.remarkPlaceholder')" />
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<div slot="footer" class="dialog-footer">
|
||||
<el-button @click="handleCancel">{{ $t('button.cancel') }}</el-button>
|
||||
<el-button type="primary" @click="handleSubmit">{{ $t('button.save') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</CustomDialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import Api from '@/apis/api';
|
||||
import CustomDialog from './CustomDialog.vue';
|
||||
|
||||
export default {
|
||||
name: 'FirmwareDialog',
|
||||
components: {
|
||||
CustomDialog
|
||||
},
|
||||
props: {
|
||||
visible: {
|
||||
type: Boolean,
|
||||
@@ -68,7 +75,7 @@ export default {
|
||||
uploadProgress: 0,
|
||||
uploadStatus: '',
|
||||
isUploading: false,
|
||||
dialogVisible: this.visible,
|
||||
saving: false,
|
||||
rules: {
|
||||
firmwareName: [
|
||||
{ required: true, message: this.$t('firmwareDialog.requiredFirmwareName'), trigger: 'blur' }
|
||||
@@ -92,28 +99,8 @@ export default {
|
||||
return !!this.form.id
|
||||
}
|
||||
},
|
||||
created() {
|
||||
// 移除 getDictDataByType 调用
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
this.dialogVisible = val;
|
||||
},
|
||||
dialogVisible(val) {
|
||||
this.$emit('update:visible', val);
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
// 移除 getFirmwareTypes 方法
|
||||
handleClose() {
|
||||
this.dialogVisible = false;
|
||||
this.$emit('cancel');
|
||||
},
|
||||
handleCancel() {
|
||||
this.$refs.form.clearValidate();
|
||||
this.$emit('cancel');
|
||||
},
|
||||
handleSubmit() {
|
||||
submit() {
|
||||
this.$refs.form.validate(valid => {
|
||||
if (valid) {
|
||||
// 如果是新增模式且没有上传文件,则提示错误
|
||||
@@ -121,11 +108,20 @@ export default {
|
||||
this.$message.error(this.$t('firmwareDialog.requiredFirmwareFile'))
|
||||
return
|
||||
}
|
||||
this.saving = true
|
||||
// 提交成功后将关闭对话框的逻辑交给父组件处理
|
||||
this.$emit('submit', this.form)
|
||||
}
|
||||
})
|
||||
},
|
||||
cancel() {
|
||||
this.saving = false
|
||||
this.$emit('cancel')
|
||||
},
|
||||
// 提供给父组件调用以重置saving状态
|
||||
resetSaving() {
|
||||
this.saving = false
|
||||
},
|
||||
beforeUpload(file) {
|
||||
const isValidSize = file.size / 1024 / 1024 < 100
|
||||
const isValidType = ['.bin', '.apk'].some(ext => file.name.toLowerCase().endsWith(ext))
|
||||
@@ -197,6 +193,7 @@ export default {
|
||||
this.uploadProgress = 0
|
||||
this.uploadStatus = ''
|
||||
this.isUploading = false
|
||||
this.saving = false
|
||||
// 重置表单中的文件相关字段
|
||||
if (!this.form.id) { // 只在新增时重置
|
||||
this.form.firmwarePath = ''
|
||||
@@ -213,25 +210,24 @@ export default {
|
||||
}
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .el-dialog {
|
||||
border-radius: 20px;
|
||||
<style scoped lang="scss">
|
||||
.firmware-form {
|
||||
.custom-select {
|
||||
width: 100%;
|
||||
}
|
||||
.upload-demo {
|
||||
text-align: left;
|
||||
}
|
||||
.el-upload__tip {
|
||||
line-height: 1.2;
|
||||
padding-top: 2%;
|
||||
color: #909399;
|
||||
}
|
||||
.hint-text {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.upload-demo {
|
||||
text-align: left;
|
||||
}
|
||||
|
||||
.el-upload__tip {
|
||||
line-height: 1.2;
|
||||
padding-top: 2%;
|
||||
color: #909399;
|
||||
}
|
||||
|
||||
.hint-text {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
font-size: 14px;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
@@ -1,56 +1,54 @@
|
||||
<template>
|
||||
<el-dialog :visible="visible" :close-on-click-modal="false" @update:visible="handleVisibleChange" width="57%" center custom-class="custom-dialog"
|
||||
:show-close="false" class="center-dialog">
|
||||
|
||||
<div style="margin: 0 18px; text-align: left; padding: 10px; border-radius: 10px;">
|
||||
<div style="font-size: 30px; color: #3d4566; margin-top: -15px; margin-bottom: 20px; text-align: center;">
|
||||
{{ title }}
|
||||
</div>
|
||||
|
||||
<button class="custom-close-btn" @click="handleClose">×</button>
|
||||
|
||||
<el-form :model="form" label-width="auto" :rules="rules" ref="form" class="custom-form">
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 20px;">
|
||||
<el-form-item :label="$t('providerDialog.category')" prop="modelType" style="flex: 1;">
|
||||
<el-select v-model="form.modelType" :placeholder="$t('providerDialog.selectCategory')" class="custom-input-bg" style="width: 100%;">
|
||||
<CustomDialog
|
||||
:title="title"
|
||||
:visible.sync="visible"
|
||||
width="57%"
|
||||
class="provider-dialog-wrapper"
|
||||
@confirm="submit"
|
||||
@close="handleClose"
|
||||
:confirmLoading="saving"
|
||||
>
|
||||
<div class="dialog-container">
|
||||
<el-form :model="form" :rules="rules" ref="form" label-width="auto" label-position="left" class="provider-form">
|
||||
<div class="form-row">
|
||||
<el-form-item :label="$t('providerDialog.category')" prop="modelType" class="form-item">
|
||||
<el-select v-model="form.modelType" :placeholder="$t('providerDialog.selectCategory')" class="custom-select">
|
||||
<el-option v-for="item in modelTypes" :key="item.value" :label="item.label" :value="item.value">
|
||||
</el-option>
|
||||
</el-select>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item :label="$t('providerDialog.code')" prop="providerCode" style="flex: 1;">
|
||||
<el-input v-model="form.providerCode" :placeholder="$t('providerDialog.inputCode')" class="custom-input-bg"></el-input>
|
||||
<el-form-item :label="$t('providerDialog.code')" prop="providerCode" class="form-item">
|
||||
<el-input v-model="form.providerCode" :placeholder="$t('providerDialog.inputCode')" class="custom-input"></el-input>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; gap: 20px; margin-bottom: 20px;">
|
||||
<el-form-item :label="$t('providerDialog.name')" prop="name" style="flex: 1;">
|
||||
<el-input v-model="form.name" :placeholder="$t('providerDialog.inputName')" class="custom-input-bg"></el-input>
|
||||
<div class="form-row">
|
||||
<el-form-item :label="$t('providerDialog.name')" prop="name" class="form-item">
|
||||
<el-input v-model="form.name" :placeholder="$t('providerDialog.inputName')" class="custom-input"></el-input>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('providerDialog.sort')" prop="sort" style="flex: 1;">
|
||||
<el-input-number v-model="form.sort" :min="0" controls-position="right" class="custom-input-bg"
|
||||
<el-form-item :label="$t('providerDialog.sort')" prop="sort" class="form-item">
|
||||
<el-input-number v-model="form.sort" :min="0" controls-position="right" class="custom-input-number"
|
||||
style="width: 100%;"></el-input-number>
|
||||
</el-form-item>
|
||||
</div>
|
||||
|
||||
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px;">
|
||||
{{ $t('providerDialog.fieldConfig') }}
|
||||
<div style="display: inline-block; float: right;">
|
||||
<el-button type="primary" @click="addField" size="small" style="background: #5bc98c; border: none;"
|
||||
<div class="field-config-header">
|
||||
<span class="field-config-title">{{ $t('providerDialog.fieldConfig') }}</span>
|
||||
<div class="field-config-actions">
|
||||
<el-button type="primary" @click="addField" size="small" class="btn-add"
|
||||
:disabled="hasIncompleteFields">
|
||||
{{ $t('providerDialog.add') }}
|
||||
</el-button>
|
||||
<el-button type="primary" @click="toggleSelectAllFields" size="small"
|
||||
style="background: #5f70f3; border: none; margin-left: 10px;">
|
||||
<el-button type="primary" @click="toggleSelectAllFields" size="small" class="btn-select-all">
|
||||
{{ isAllFieldsSelected ? $t('providerDialog.deselectAll') : $t('providerDialog.selectAll') }}
|
||||
</el-button>
|
||||
<el-button type="danger" @click="batchRemoveFields" size="small"
|
||||
style="background: red; border: none; margin-left: 10px;">
|
||||
<el-button type="danger" @click="batchRemoveFields" size="small" class="btn-batch-delete">
|
||||
{{ $t('providerDialog.batchDelete') }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px;"></div>
|
||||
<div class="divider"></div>
|
||||
|
||||
<div class="fields-container">
|
||||
<el-table :data="form.fields" style="width: 100%;" border size="medium" :key="tableKey">
|
||||
@@ -122,26 +120,27 @@
|
||||
</div>
|
||||
</el-form>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: center;">
|
||||
<el-button type="primary" @click="submit" class="save-btn" :loading="saving">{{ $t('providerDialog.save') }}</el-button>
|
||||
</div>
|
||||
</el-dialog>
|
||||
</CustomDialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import CustomDialog from './CustomDialog.vue';
|
||||
export default {
|
||||
name: 'ProviderDialog',
|
||||
props: {
|
||||
title: String,
|
||||
visible: Boolean,
|
||||
form: Object,
|
||||
modelTypes: Array
|
||||
},
|
||||
components: {
|
||||
CustomDialog
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
saving: false,
|
||||
isAllFieldsSelected: false,
|
||||
tableKey: 0 // 用于强制表格重新渲染
|
||||
tableKey: 0
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
@@ -199,16 +198,8 @@ export default {
|
||||
}));
|
||||
},
|
||||
|
||||
handleVisibleChange(val) {
|
||||
this.$emit('update:visible', val);
|
||||
if (!val) {
|
||||
this.resetForm();
|
||||
}
|
||||
},
|
||||
|
||||
handleClose() {
|
||||
this.resetForm();
|
||||
this.$emit('update:visible', false);
|
||||
this.$emit('cancel');
|
||||
},
|
||||
|
||||
@@ -288,7 +279,7 @@ export default {
|
||||
},
|
||||
|
||||
forceTableRerender() {
|
||||
this.tableKey += 1; // 改变key值强制表格重新渲染
|
||||
this.tableKey += 1;
|
||||
},
|
||||
|
||||
submit() {
|
||||
@@ -331,8 +322,7 @@ export default {
|
||||
}
|
||||
this.isAllFieldsSelected = false;
|
||||
this.forceTableRerender();
|
||||
},
|
||||
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
visible(val) {
|
||||
@@ -344,97 +334,40 @@ export default {
|
||||
};
|
||||
</script>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
::v-deep .custom-dialog.el-dialog {
|
||||
margin-top: 0 !important;
|
||||
border-radius: 20px !important;
|
||||
}
|
||||
|
||||
::v-deep .custom-dialog .el-dialog__header {
|
||||
padding: 0;
|
||||
border-bottom: none;
|
||||
}
|
||||
|
||||
.custom-close-btn {
|
||||
position: absolute;
|
||||
top: 20px;
|
||||
right: 20px;
|
||||
width: 35px;
|
||||
height: 35px;
|
||||
border-radius: 50%;
|
||||
border: 2px solid #cfcfcf;
|
||||
background: none;
|
||||
font-size: 30px;
|
||||
font-weight: lighter;
|
||||
color: #cfcfcf;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
z-index: 1;
|
||||
padding: 0;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.custom-close-btn:hover {
|
||||
color: #409EFF;
|
||||
border-color: #409EFF;
|
||||
}
|
||||
|
||||
.custom-form .el-form-item {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.custom-form .el-form-item__label {
|
||||
color: #3d4566;
|
||||
font-weight: normal;
|
||||
text-align: right;
|
||||
padding-right: 20px;
|
||||
}
|
||||
|
||||
.custom-input-bg .el-input__inner {
|
||||
background-color: #f6f8fc;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
.custom-input-bg .el-input__inner::-webkit-input-placeholder {
|
||||
color: #9c9f9e;
|
||||
}
|
||||
|
||||
.fields-container {
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.save-btn {
|
||||
background: #e6f0fd;
|
||||
color: #237ff4;
|
||||
border: 1px solid #b3d1ff;
|
||||
width: 150px;
|
||||
height: 40px;
|
||||
font-size: 16px;
|
||||
transition: all 0.3s ease;
|
||||
}
|
||||
|
||||
.save-btn:hover {
|
||||
background: linear-gradient(to right, #237ff4, #9c40d5);
|
||||
color: white;
|
||||
border: none;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.el-table::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-table th,
|
||||
.el-table td {
|
||||
padding: 8px 0;
|
||||
}
|
||||
|
||||
.el-button.is-circle {
|
||||
border-radius: 2px;
|
||||
<style scoped lang="scss">
|
||||
.provider-dialog-wrapper {
|
||||
.provider-form {
|
||||
.form-row {
|
||||
display: flex;
|
||||
gap: 20px;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
.form-item {
|
||||
flex: 1;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
.custom-select {
|
||||
width: 100%;
|
||||
}
|
||||
.custom-input-number {
|
||||
width: 100%;
|
||||
}
|
||||
}
|
||||
.field-config-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
margin-bottom: 15px;
|
||||
.field-config-title {
|
||||
font-size: 16px;
|
||||
font-weight: 600;
|
||||
color: #3d4566;
|
||||
}
|
||||
}
|
||||
.divider {
|
||||
height: 2px;
|
||||
background: #e9e9e9;
|
||||
margin-bottom: 22px;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
@@ -1118,6 +1118,8 @@ export default {
|
||||
'agentTemplateManagement.action': 'Aktion',
|
||||
'agentTemplateManagement.createTemplate': 'Vorlage erstellen',
|
||||
'templateQuickConfig.newTemplate': 'Neue Vorlage',
|
||||
'templateQuickConfig.editTemplate': 'Vorlage bearbeiten',
|
||||
'templateQuickConfig.addTemplate': 'Vorlage hinzufügen',
|
||||
'agentTemplateManagement.editTemplate': 'Vorlage bearbeiten',
|
||||
'agentTemplateManagement.deleteTemplate': 'Vorlage löschen',
|
||||
'agentTemplateManagement.deleteSuccess': 'Vorlage erfolgreich gelöscht',
|
||||
|
||||
@@ -1152,6 +1152,8 @@ export default {
|
||||
'templateQuickConfig.cancel': 'Cancel',
|
||||
'templateQuickConfig.templateNotFound': 'Template not found',
|
||||
'templateQuickConfig.newTemplate': 'New Template',
|
||||
'templateQuickConfig.editTemplate': 'Edit Template',
|
||||
'templateQuickConfig.addTemplate': 'Add Template',
|
||||
'warning': 'Warning',
|
||||
'info': 'Info',
|
||||
'common.networkError': 'Network request failed',
|
||||
|
||||
@@ -1152,6 +1152,8 @@ export default {
|
||||
'templateQuickConfig.cancel': 'Cancelar',
|
||||
'templateQuickConfig.templateNotFound': 'Modelo não encontrado',
|
||||
'templateQuickConfig.newTemplate': 'Novo Modelo',
|
||||
'templateQuickConfig.editTemplate': 'Editar Modelo',
|
||||
'templateQuickConfig.addTemplate': 'Adicionar Modelo',
|
||||
'warning': 'Aviso',
|
||||
'info': 'Informação',
|
||||
'common.networkError': 'Falha na requisição de rede',
|
||||
|
||||
@@ -1118,6 +1118,8 @@ export default {
|
||||
'agentTemplateManagement.action': 'Hành động',
|
||||
'agentTemplateManagement.createTemplate': 'Tạo mẫu',
|
||||
'templateQuickConfig.newTemplate': 'Mẫu mới',
|
||||
'templateQuickConfig.editTemplate': 'Chỉnh sửa mẫu',
|
||||
'templateQuickConfig.addTemplate': 'Thêm mẫu',
|
||||
'agentTemplateManagement.editTemplate': 'Chỉnh sửa mẫu',
|
||||
'agentTemplateManagement.deleteTemplate': 'Xóa mẫu',
|
||||
'agentTemplateManagement.deleteSuccess': 'Đã xóa mẫu thành công',
|
||||
|
||||
@@ -1152,6 +1152,8 @@ export default {
|
||||
'templateQuickConfig.cancel': '取消',
|
||||
'templateQuickConfig.templateNotFound': '未找到指定模板',
|
||||
'templateQuickConfig.newTemplate': '新模板',
|
||||
'templateQuickConfig.editTemplate': '编辑模板',
|
||||
'templateQuickConfig.addTemplate': '新增模板',
|
||||
'warning': '警告',
|
||||
'info': '提示',
|
||||
'common.networkError': '网络请求失败',
|
||||
|
||||
@@ -1152,6 +1152,8 @@ export default {
|
||||
'templateQuickConfig.cancel': '取消',
|
||||
'templateQuickConfig.templateNotFound': '未找到指定模板',
|
||||
'templateQuickConfig.newTemplate': '新模板',
|
||||
'templateQuickConfig.editTemplate': '編輯模板',
|
||||
'templateQuickConfig.addTemplate': '新增模板',
|
||||
'warning': '警告',
|
||||
'info': '提示',
|
||||
'common.networkError': '網路請求失敗',
|
||||
|
||||
@@ -1,141 +1,103 @@
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">{{ $t("agentTemplateManagement.title") }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-input
|
||||
:placeholder="$t('agentTemplateManagement.searchPlaceholder')"
|
||||
v-model="search"
|
||||
class="search-input"
|
||||
clearable
|
||||
@keyup.enter.native="handleSearch"
|
||||
style="width: 240px"
|
||||
/>
|
||||
<el-button class="btn-search" @click="handleSearch">
|
||||
{{ $t("agentTemplateManagement.search") }}
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 主体内容 -->
|
||||
<div class="main-wrapper">
|
||||
<div class="content-panel">
|
||||
<div class="content-area">
|
||||
<el-card class="template-card" shadow="never">
|
||||
<el-table
|
||||
ref="templateTable"
|
||||
:data="templateList"
|
||||
style="width: 100%"
|
||||
v-loading="templateLoading"
|
||||
:element-loading-text="$t('agentTemplateManagement.loading')"
|
||||
element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(255, 255, 255, 0.7)"
|
||||
class="transparent-table"
|
||||
:header-cell-style="{ padding: '10px 20px' }"
|
||||
:cell-style="{ padding: '10px 20px' }"
|
||||
>
|
||||
<!-- 移除@row-click="handleRowClick" -->
|
||||
<!-- 自定义选择列,实现表头是"选择"文字,数据行是小方框 -->
|
||||
<el-table-column
|
||||
:label="$t('agentTemplateManagement.select')"
|
||||
align="center"
|
||||
min-width="100"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox
|
||||
v-model="scope.row.selected"
|
||||
@change="handleRowSelectionChange(scope.row)"
|
||||
@click.stop
|
||||
></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 模板名称 -->
|
||||
<el-table-column
|
||||
:label="$t('agentTemplateManagement.templateName')"
|
||||
prop="agentName"
|
||||
min-width="250"
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ scope.row.agentName }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 修改为序号列,并移动到此处 -->
|
||||
<el-table-column
|
||||
:label="$t('agentTemplateManagement.serialNumber')"
|
||||
min-width="120"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<span>{{ (currentPage - 1) * pageSize + scope.$index + 1 }}</span>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<!-- 操作列 -->
|
||||
<el-table-column
|
||||
:label="$t('agentTemplateManagement.action')"
|
||||
min-width="250"
|
||||
align="center"
|
||||
>
|
||||
<template slot-scope="scope">
|
||||
<div style="display: flex; justify-content: center; gap: 15px">
|
||||
<el-button type="text" @click="editTemplate(scope.row)">{{
|
||||
$t("agentTemplateManagement.editTemplate")
|
||||
}}</el-button>
|
||||
<el-button type="text" @click="deleteTemplate(scope.row)">{{
|
||||
$t("agentTemplateManagement.deleteTemplate")
|
||||
}}</el-button>
|
||||
</div>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<!-- 表格底部操作栏 -->
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button
|
||||
type="primary"
|
||||
@click="handleSelectAll"
|
||||
size="mini"
|
||||
class="select-all-btn"
|
||||
>
|
||||
{{
|
||||
isAllSelected
|
||||
? $t("agentTemplateManagement.deselectAll")
|
||||
: $t("agentTemplateManagement.selectAll")
|
||||
}}
|
||||
</el-button>
|
||||
<el-button type="success" @click="showAddTemplateDialog" size="mini">
|
||||
{{ $t("agentTemplateManagement.createTemplate") }}
|
||||
</el-button>
|
||||
<el-button
|
||||
type="danger"
|
||||
@click="batchDeleteTemplate"
|
||||
:disabled="!hasSelected"
|
||||
size="mini"
|
||||
>
|
||||
{{ $t("agentTemplateManagement.batchDelete") }}
|
||||
</el-button>
|
||||
</div>
|
||||
|
||||
<!-- 分页 -->
|
||||
<div class="custom-pagination">
|
||||
<el-pagination
|
||||
v-model:current-page="currentPage"
|
||||
v-model:page-size="pageSize"
|
||||
:page-sizes="pageSizeOptions"
|
||||
layout="total, sizes, prev, pager, next, jumper"
|
||||
:total="total"
|
||||
@size-change="handlePageSizeChange"
|
||||
@current-change="handlePageChange"
|
||||
<div class="operation-header">
|
||||
<h2 class="page-title">{{ $t("agentTemplateManagement.title") }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-input
|
||||
:placeholder="$t('agentTemplateManagement.searchPlaceholder')"
|
||||
v-model="search"
|
||||
class="search-input"
|
||||
clearable
|
||||
@keyup.enter.native="handleSearch"
|
||||
/>
|
||||
<CustomButton icon="el-icon-search" type="confirm" @click="handleSearch">
|
||||
{{ $t("agentTemplateManagement.search") }}
|
||||
</CustomButton>
|
||||
</div>
|
||||
</div>
|
||||
<CustomTable
|
||||
ref="templateTable"
|
||||
:data="templateList"
|
||||
:columns="tableColumns"
|
||||
:loading="templateLoading"
|
||||
:show-selection="true"
|
||||
:show-operations="true"
|
||||
:operations-label="$t('agentTemplateManagement.action')"
|
||||
:total="total"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
@size-change="handlePageSizeChange"
|
||||
@page-change="handlePageChange"
|
||||
>
|
||||
<template slot="selection" slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.selected" @change="handleRowSelectionChange(scope.row)"></el-checkbox>
|
||||
</template>
|
||||
<template slot="serialNumber" slot-scope="scope">
|
||||
<span>{{ (currentPage - 1) * pageSize + scope.$index + 1 }}</span>
|
||||
</template>
|
||||
<template slot="operations" slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="editTemplate(scope.row)">
|
||||
{{ $t("agentTemplateManagement.editTemplate") }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteTemplate(scope.row)">
|
||||
{{ $t("agentTemplateManagement.deleteTemplate") }}
|
||||
</el-button>
|
||||
</template>
|
||||
<template slot="footer-btns">
|
||||
<div class="ctrl_btn">
|
||||
<CustomButton :icon="isAllSelected ? 'el-icon-circle-close' : 'el-icon-circle-check'" size="small" @click="handleSelectAll">
|
||||
{{ isAllSelected ? $t("agentTemplateManagement.deselectAll") : $t("agentTemplateManagement.selectAll") }}
|
||||
</CustomButton>
|
||||
<CustomButton icon="el-icon-plus" size="small" @click="showAddTemplateDialog">
|
||||
{{ $t("agentTemplateManagement.createTemplate") }}
|
||||
</CustomButton>
|
||||
<CustomButton size="small" type="delete" icon="el-icon-delete" @click="batchDeleteTemplate">
|
||||
{{ $t("agentTemplateManagement.batchDelete") }}
|
||||
</CustomButton>
|
||||
</div>
|
||||
</template>
|
||||
</CustomTable>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 新增/编辑模板弹窗 -->
|
||||
<CustomDialog
|
||||
:title="dialogTitle"
|
||||
:visible.sync="dialogVisible"
|
||||
:confirm-loading="confirmLoading"
|
||||
:footer="true"
|
||||
:width="'1200px'"
|
||||
@confirm="handleDialogConfirm"
|
||||
@cancel="dialogVisible = false"
|
||||
>
|
||||
<el-form ref="dialogForm" :model="form" label-width="100px">
|
||||
<el-form-item :label="$t('templateQuickConfig.agentSettings.agentName')" prop="agentName">
|
||||
<el-input
|
||||
v-model="form.agentName"
|
||||
:placeholder="$t('templateQuickConfig.agentSettings.agentNamePlaceholder')"
|
||||
/>
|
||||
</el-form-item>
|
||||
<el-form-item :label="$t('templateQuickConfig.agentSettings.systemPrompt')" prop="systemPrompt">
|
||||
<el-input
|
||||
v-model="form.systemPrompt"
|
||||
type="textarea"
|
||||
:placeholder="$t('templateQuickConfig.agentSettings.systemPromptPlaceholder')"
|
||||
show-word-limit
|
||||
maxlength="2000"
|
||||
:rows="16"
|
||||
/>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</CustomDialog>
|
||||
|
||||
<el-footer>
|
||||
<version-footer />
|
||||
</el-footer>
|
||||
@@ -146,136 +108,196 @@
|
||||
import HeaderBar from "@/components/HeaderBar";
|
||||
import agentApi from "@/apis/module/agent";
|
||||
import VersionFooter from "@/components/VersionFooter.vue";
|
||||
import CustomButton from "@/components/CustomButton.vue";
|
||||
import CustomTable from "@/components/CustomTable.vue";
|
||||
import CustomDialog from "@/components/CustomDialog.vue";
|
||||
|
||||
const DEFAULT_MODEL_CONFIG = {
|
||||
ttsModelId: "TTS_EdgeTTS",
|
||||
vadModelId: "VAD_SileroVAD",
|
||||
asrModelId: "ASR_FunASR",
|
||||
llmModelId: "LLM_ChatGLMLLM",
|
||||
vllmModelId: "VLLM_ChatGLMVLLM",
|
||||
memModelId: "Memory_nomem",
|
||||
intentModelId: "Intent_function_call"
|
||||
};
|
||||
|
||||
export default {
|
||||
name: "AgentTemplateManagement",
|
||||
components: {
|
||||
HeaderBar,
|
||||
VersionFooter
|
||||
VersionFooter,
|
||||
CustomButton,
|
||||
CustomTable,
|
||||
CustomDialog
|
||||
},
|
||||
|
||||
data() {
|
||||
return {
|
||||
// 模板相关
|
||||
templateList: [],
|
||||
templateLoading: false,
|
||||
selectedTemplates: [],
|
||||
isAllSelected: false, // 添加全选状态
|
||||
|
||||
isAllSelected: false,
|
||||
search: "",
|
||||
// 分页相关数据
|
||||
pageSizeOptions: [10, 20, 50, 100],
|
||||
currentPage: 1,
|
||||
pageSize: 10,
|
||||
total: 0,
|
||||
tableColumns: [],
|
||||
dialogVisible: false,
|
||||
dialogTitle: "",
|
||||
confirmLoading: false,
|
||||
form: {
|
||||
id: null,
|
||||
agentCode: "小智",
|
||||
agentName: "",
|
||||
systemPrompt: "",
|
||||
sort: 0,
|
||||
model: { ...DEFAULT_MODEL_CONFIG }
|
||||
},
|
||||
originalForm: null
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.initTableColumns();
|
||||
this.loadTemplateList();
|
||||
},
|
||||
// 在computed部分添加hasSelected属性
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.pageSize);
|
||||
},
|
||||
visiblePages() {
|
||||
return this.getVisiblePages();
|
||||
},
|
||||
hasSelected() {
|
||||
return this.selectedTemplates.length > 0;
|
||||
},
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
// 加载模板列表
|
||||
// 改进loadTemplateList方法的错误处理逻辑
|
||||
initTableColumns() {
|
||||
this.tableColumns = [
|
||||
{
|
||||
prop: "agentName",
|
||||
label: this.$t("agentTemplateManagement.templateName"),
|
||||
},
|
||||
{
|
||||
prop: "serialNumber",
|
||||
label: this.$t("agentTemplateManagement.serialNumber"),
|
||||
}
|
||||
];
|
||||
},
|
||||
loadTemplateList() {
|
||||
this.templateLoading = true;
|
||||
const params = {
|
||||
page: this.currentPage,
|
||||
limit: this.pageSize,
|
||||
limit: this.pageSize
|
||||
};
|
||||
if (this.search) {
|
||||
params.agentName = this.search;
|
||||
}
|
||||
|
||||
try {
|
||||
agentApi.getAgentTemplatesPage(
|
||||
params,
|
||||
(res) => {
|
||||
// 更健壮的响应处理逻辑
|
||||
if (res && typeof res === "object") {
|
||||
if (res.data && res.data.code === 0) {
|
||||
const responseData = res.data.data || {};
|
||||
// 为每个模板添加selected属性
|
||||
this.templateList = Array.isArray(responseData.list)
|
||||
? responseData.list.map((item) => ({ ...item, selected: false }))
|
||||
: [];
|
||||
this.total =
|
||||
typeof responseData.total === "number" ? responseData.total : 0;
|
||||
} else {
|
||||
this.templateList = [];
|
||||
this.total = 0;
|
||||
this.$message.error(
|
||||
res?.data?.msg || this.$t("agentTemplateManagement.fetchTemplateFailed")
|
||||
);
|
||||
}
|
||||
} else {
|
||||
this.templateList = [];
|
||||
this.total = 0;
|
||||
this.$message.error(
|
||||
this.$t("agentTemplateManagement.fetchTemplateBackendError")
|
||||
);
|
||||
}
|
||||
this.templateLoading = false;
|
||||
},
|
||||
(error) => {
|
||||
agentApi.getAgentTemplatesPage(
|
||||
params,
|
||||
(res) => {
|
||||
if (res && res.data && res.data.code === 0) {
|
||||
const responseData = res.data.data || {};
|
||||
this.templateList = Array.isArray(responseData.list)
|
||||
? responseData.list.map((item) => ({ ...item, selected: false }))
|
||||
: [];
|
||||
this.total = typeof responseData.total === "number" ? responseData.total : 0;
|
||||
} else {
|
||||
this.templateList = [];
|
||||
this.total = 0;
|
||||
this.templateLoading = false;
|
||||
this.$message.error(this.$t("common.networkError"));
|
||||
this.$message.error(res?.data?.msg || this.$t("agentTemplateManagement.fetchTemplateFailed"));
|
||||
}
|
||||
);
|
||||
} catch (error) {
|
||||
this.templateList = [];
|
||||
this.total = 0;
|
||||
this.templateLoading = false;
|
||||
this.$message.error(this.$t("agentTemplateManagement.fetchTemplateBackendError"));
|
||||
}
|
||||
this.templateLoading = false;
|
||||
},
|
||||
(error) => {
|
||||
this.templateList = [];
|
||||
this.total = 0;
|
||||
this.templateLoading = false;
|
||||
this.$message.error(this.$t("common.networkError"));
|
||||
}
|
||||
);
|
||||
},
|
||||
|
||||
// 搜索模板
|
||||
handleSearch() {
|
||||
if (this.search) {
|
||||
const searchValue = this.search.toLowerCase();
|
||||
const filteredList = this.templateList.filter((template) =>
|
||||
template.agentName.toLowerCase().includes(searchValue)
|
||||
);
|
||||
this.templateList = filteredList;
|
||||
this.total = filteredList.length;
|
||||
} else {
|
||||
this.loadTemplateList();
|
||||
}
|
||||
this.currentPage = 1;
|
||||
this.loadTemplateList();
|
||||
},
|
||||
|
||||
// 修改showAddTemplateDialog方法,使其跳转到与编辑页面相同的页面
|
||||
// 显示新增模板弹窗
|
||||
showAddTemplateDialog() {
|
||||
// 跳转到模板快速配置页面,不传递templateId参数表示新增
|
||||
this.$router.push({
|
||||
path: "/template-quick-config",
|
||||
});
|
||||
this.dialogTitle = this.$t("templateQuickConfig.addTemplate");
|
||||
this.form = {
|
||||
id: null,
|
||||
agentCode: "小智",
|
||||
agentName: this.$t("templateQuickConfig.newTemplate"),
|
||||
systemPrompt: "",
|
||||
sort: 1,
|
||||
model: { ...DEFAULT_MODEL_CONFIG }
|
||||
};
|
||||
this.originalForm = JSON.parse(JSON.stringify(this.form));
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
|
||||
// 编辑模板
|
||||
editTemplate(row) {
|
||||
// 跳转到模板快速配置页面,并传递模板ID参数
|
||||
this.$router.push({
|
||||
path: "/template-quick-config",
|
||||
query: { templateId: row.id },
|
||||
this.dialogTitle = this.$t("templateQuickConfig.editTemplate");
|
||||
this.fetchTemplateById(row.id);
|
||||
},
|
||||
fetchTemplateById(templateId) {
|
||||
agentApi.getAgentTemplateById(templateId, (res) => {
|
||||
if (res && res.data && res.data.code === 0 && res.data.data) {
|
||||
const template = res.data.data;
|
||||
this.form = {
|
||||
id: template.id,
|
||||
agentCode: template.agentCode || "小智",
|
||||
agentName: template.agentName || "",
|
||||
systemPrompt: template.systemPrompt || "",
|
||||
sort: template.sort || 0,
|
||||
model: {
|
||||
ttsModelId: template.ttsModelId || DEFAULT_MODEL_CONFIG.ttsModelId,
|
||||
vadModelId: template.vadModelId || DEFAULT_MODEL_CONFIG.vadModelId,
|
||||
asrModelId: template.asrModelId || DEFAULT_MODEL_CONFIG.asrModelId,
|
||||
llmModelId: template.llmModelId || DEFAULT_MODEL_CONFIG.llmModelId,
|
||||
vllmModelId: template.vllmModelId || DEFAULT_MODEL_CONFIG.vllmModelId,
|
||||
memModelId: template.memModelId || DEFAULT_MODEL_CONFIG.memModelId,
|
||||
intentModelId: template.intentModelId || DEFAULT_MODEL_CONFIG.intentModelId
|
||||
}
|
||||
};
|
||||
this.originalForm = JSON.parse(JSON.stringify(this.form));
|
||||
this.dialogVisible = true;
|
||||
} else {
|
||||
this.$message.error(res?.data?.msg || this.$t("templateQuickConfig.templateNotFound"));
|
||||
}
|
||||
});
|
||||
},
|
||||
handleDialogConfirm() {
|
||||
const configData = {
|
||||
id: this.form.id || "",
|
||||
agentCode: this.form.agentCode,
|
||||
agentName: this.form.agentName,
|
||||
systemPrompt: this.form.systemPrompt,
|
||||
sort: this.form.sort,
|
||||
functions: [],
|
||||
...this.form.model
|
||||
};
|
||||
|
||||
// 删除模板
|
||||
this.confirmLoading = true;
|
||||
const apiCall = this.form.id
|
||||
? agentApi.updateAgentTemplate
|
||||
: agentApi.addAgentTemplate;
|
||||
|
||||
apiCall(configData, (res) => {
|
||||
this.confirmLoading = false;
|
||||
if (res && res.data && res.data.code === 0) {
|
||||
this.$message.success({
|
||||
message: this.$t("templateQuickConfig.saveSuccess"),
|
||||
showClose: true
|
||||
});
|
||||
this.dialogVisible = false;
|
||||
this.loadTemplateList();
|
||||
} else {
|
||||
this.$message.error({
|
||||
message: res?.data?.msg || this.$t("templateQuickConfig.saveFailed"),
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
}, (error) => {
|
||||
this.confirmLoading = false;
|
||||
this.$message.error(this.$t("common.networkError"));
|
||||
});
|
||||
},
|
||||
deleteTemplate(row) {
|
||||
this.$confirm(
|
||||
this.$t("agentTemplateManagement.confirmSingleDelete"),
|
||||
@@ -283,23 +305,18 @@ export default {
|
||||
{
|
||||
confirmButtonText: this.$t("common.confirm"),
|
||||
cancelButtonText: this.$t("common.cancel"),
|
||||
type: "warning",
|
||||
type: "warning"
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
agentApi.deleteAgentTemplate(row.id, (res) => {
|
||||
if (res && typeof res === "object") {
|
||||
// 检查res.data是否存在且包含code=0
|
||||
if (res.data && res.data.code === 0) {
|
||||
this.$message.success(this.$t("agentTemplateManagement.deleteSuccess"));
|
||||
this.loadTemplateList();
|
||||
} else {
|
||||
this.$message.error(
|
||||
res?.data?.msg || this.$t("agentTemplateManagement.deleteFailed")
|
||||
);
|
||||
}
|
||||
if (res && res.data && res.data.code === 0) {
|
||||
this.$message.success(this.$t("agentTemplateManagement.deleteSuccess"));
|
||||
this.selectedTemplates = [];
|
||||
this.isAllSelected = false;
|
||||
this.loadTemplateList();
|
||||
} else {
|
||||
this.$message.error(this.$t("agentTemplateManagement.deleteBackendError"));
|
||||
this.$message.error(res?.data?.msg || this.$t("agentTemplateManagement.deleteFailed"));
|
||||
}
|
||||
});
|
||||
})
|
||||
@@ -307,47 +324,30 @@ export default {
|
||||
this.$message.info(this.$t("common.deleteCancelled"));
|
||||
});
|
||||
},
|
||||
|
||||
// 批量删除模板
|
||||
batchDeleteTemplate() {
|
||||
if (this.selectedTemplates.length === 0) {
|
||||
this.$message.warning(this.$t("agentTemplateManagement.selectTemplate"));
|
||||
return;
|
||||
}
|
||||
|
||||
this.$confirm(
|
||||
this.$t("agentTemplateManagement.confirmBatchDelete", {
|
||||
count: this.selectedTemplates.length,
|
||||
}),
|
||||
this.$t("agentTemplateManagement.confirmBatchDelete", { count: this.selectedTemplates.length }),
|
||||
this.$t("common.warning"),
|
||||
{
|
||||
confirmButtonText: this.$t("common.confirm"),
|
||||
cancelButtonText: this.$t("common.cancel"),
|
||||
type: "warning",
|
||||
type: "warning"
|
||||
}
|
||||
)
|
||||
.then(() => {
|
||||
// 确保参数格式正确 - 将id数组作为请求体
|
||||
const ids = this.selectedTemplates.map((template) => template.id);
|
||||
|
||||
agentApi.batchDeleteAgentTemplate(ids, (res) => {
|
||||
if (res && typeof res === "object") {
|
||||
if (res.data && res.data.code === 0) {
|
||||
this.$message.success(
|
||||
this.$t("agentTemplateManagement.batchDeleteSuccess")
|
||||
);
|
||||
// 重新加载模板列表
|
||||
this.loadTemplateList();
|
||||
// 清空选中状态
|
||||
this.selectedTemplates = [];
|
||||
this.isAllSelected = false;
|
||||
} else {
|
||||
this.$message.error(
|
||||
res?.data?.msg || this.$t("agentTemplateManagement.batchDeleteFailed")
|
||||
);
|
||||
}
|
||||
if (res && res.data && res.data.code === 0) {
|
||||
this.$message.success(this.$t("agentTemplateManagement.batchDeleteSuccess"));
|
||||
this.loadTemplateList();
|
||||
this.selectedTemplates = [];
|
||||
this.isAllSelected = false;
|
||||
} else {
|
||||
this.$message.error(this.$t("agentTemplateManagement.deleteBackendError"));
|
||||
this.$message.error(res?.data?.msg || this.$t("agentTemplateManagement.batchDeleteFailed"));
|
||||
}
|
||||
});
|
||||
})
|
||||
@@ -355,150 +355,81 @@ export default {
|
||||
this.$message.info(this.$t("common.deleteCancelled"));
|
||||
});
|
||||
},
|
||||
|
||||
// 完善分页相关方法
|
||||
handlePageChange(page) {
|
||||
this.currentPage = page;
|
||||
this.loadTemplateList();
|
||||
},
|
||||
|
||||
handlePageSizeChange(size) {
|
||||
this.pageSize = size;
|
||||
this.currentPage = 1;
|
||||
this.loadTemplateList();
|
||||
},
|
||||
|
||||
goFirst() {
|
||||
this.currentPage = 1;
|
||||
},
|
||||
goPrev() {
|
||||
this.currentPage--;
|
||||
},
|
||||
goNext() {
|
||||
this.currentPage++;
|
||||
},
|
||||
goToPage(page) {
|
||||
this.currentPage = page;
|
||||
},
|
||||
getVisiblePages() {
|
||||
const pages = [];
|
||||
const totalPages = this.pageCount;
|
||||
const currentPage = this.currentPage;
|
||||
|
||||
if (totalPages <= 7) {
|
||||
for (let i = 1; i <= totalPages; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
} else {
|
||||
if (currentPage <= 4) {
|
||||
for (let i = 1; i <= 5; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
pages.push("...");
|
||||
pages.push(totalPages);
|
||||
} else if (currentPage >= totalPages - 3) {
|
||||
pages.push(1);
|
||||
pages.push("...");
|
||||
for (let i = totalPages - 4; i <= totalPages; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
} else {
|
||||
pages.push(1);
|
||||
pages.push("...");
|
||||
for (let i = currentPage - 1; i <= currentPage + 1; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
pages.push("...");
|
||||
pages.push(totalPages);
|
||||
}
|
||||
}
|
||||
|
||||
return pages;
|
||||
},
|
||||
|
||||
// 修改handleSelectAll方法
|
||||
handleSelectAll() {
|
||||
this.isAllSelected = !this.isAllSelected;
|
||||
this.templateList.forEach((row) => {
|
||||
row.selected = this.isAllSelected;
|
||||
});
|
||||
// 更新选中的模板列表
|
||||
this.selectedTemplates = this.isAllSelected ? [...this.templateList] : [];
|
||||
},
|
||||
|
||||
// 处理行选择变化
|
||||
handleRowSelectionChange(row) {
|
||||
// 查找选中的模板
|
||||
this.selectedTemplates = this.templateList.filter((template) => template.selected);
|
||||
// 更新全选状态
|
||||
this.isAllSelected =
|
||||
this.templateList.length > 0 &&
|
||||
this.selectedTemplates.length === this.templateList.length;
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
/* 基础背景和布局设置 */
|
||||
<style lang="scss" scoped>
|
||||
.welcome {
|
||||
min-height: 100vh;
|
||||
min-width: 900px;
|
||||
min-height: 506px;
|
||||
height: 100vh;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
flex-direction: column;
|
||||
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd) center;
|
||||
background-size: cover;
|
||||
overflow: hidden;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
/* 操作栏样式 */
|
||||
.operation-bar {
|
||||
.main-wrapper {
|
||||
height: calc(100vh - 63px - 35px);
|
||||
padding: 20px 22px 0;
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.operation-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
justify-content: space-between;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.right-operations {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
margin-left: auto;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 200px;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
/* 主容器样式 */
|
||||
.main-wrapper {
|
||||
// 顶部 63px 底部 35px 查询72px
|
||||
height: calc(100vh - 63px - 35px - 72px);
|
||||
margin: 0 22px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
position: relative;
|
||||
background: rgba(237, 242, 255, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.content-panel {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
border-radius: 15px;
|
||||
background: transparent;
|
||||
border: 1px solid #fff;
|
||||
@@ -506,25 +437,25 @@ export default {
|
||||
|
||||
.content-area {
|
||||
flex: 1;
|
||||
height: 100%;
|
||||
min-width: 600px;
|
||||
overflow-x: auto;
|
||||
overflow: auto;
|
||||
background-color: white;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* 模板卡片样式 */
|
||||
.template-card {
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
background: white;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
|
||||
:deep(.el-card__body) {
|
||||
padding: 15px;
|
||||
::v-deep .el-card__body {
|
||||
padding: 14px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
@@ -532,106 +463,15 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
/* 表格样式 - 优化整合版 */
|
||||
.transparent-table {
|
||||
width: 100%;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
height: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
--table-max-height: calc(100vh - 42vh);
|
||||
max-height: var(--table-max-height);
|
||||
|
||||
/* 表格头部样式 */
|
||||
.el-table__header th {
|
||||
padding: 8px 0 !important;
|
||||
height: 40px !important;
|
||||
}
|
||||
|
||||
.el-table__header th .cell {
|
||||
color: #303133 !important;
|
||||
font-weight: 600;
|
||||
}
|
||||
|
||||
/* 表格主体样式 */
|
||||
.el-table__body {
|
||||
.el-table__row td {
|
||||
padding: 12px 0 !important;
|
||||
border-bottom: 1px solid #ebeef5;
|
||||
}
|
||||
.el-table__row:hover {
|
||||
background-color: #f5f7fa;
|
||||
}
|
||||
}
|
||||
|
||||
/* 表格按钮样式 */
|
||||
.el-button--text {
|
||||
color: #7079aa;
|
||||
}
|
||||
|
||||
.el-button--text:hover {
|
||||
color: #5a64b5;
|
||||
}
|
||||
|
||||
/* 单元格文本样式 */
|
||||
.cell {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
}
|
||||
|
||||
/* 表格底部操作栏 */
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between !important;
|
||||
align-items: center;
|
||||
margin-top: auto;
|
||||
padding: 0 20px !important;
|
||||
width: 100% !important;
|
||||
box-sizing: border-box !important;
|
||||
}
|
||||
|
||||
/* 控制按钮样式 */
|
||||
.ctrl_btn {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-left: 0 !important;
|
||||
margin-left: 0 !important;
|
||||
|
||||
.el-button {
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
padding: 7px 12px 7px 10px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
line-height: 1;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background: #5f70f3;
|
||||
color: white;
|
||||
}
|
||||
.el-button--success {
|
||||
background: #5bc98c;
|
||||
color: white;
|
||||
}
|
||||
.el-button--danger {
|
||||
background: #fd5b63;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa;
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text:hover) {
|
||||
color: #5a64b5;
|
||||
}
|
||||
</style>
|
||||
@@ -1,95 +1,67 @@
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">{{ $t('otaManagement.firmwareManagement') }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-input :placeholder="$t('otaManagement.searchPlaceholder')" v-model="searchName" class="search-input"
|
||||
@keyup.enter.native="handleSearch" clearable />
|
||||
<el-button class="btn-search" @click="handleSearch">{{ $t('otaManagement.search') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="content-panel">
|
||||
<div class="content-area">
|
||||
<el-card class="params-card" shadow="never">
|
||||
<el-table ref="paramsTable" :data="paramsList" class="transparent-table" v-loading="loading"
|
||||
element-loading-text="Loading" element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(255, 255, 255, 0.7)"
|
||||
:header-cell-class-name="headerCellClassName">
|
||||
<el-table-column :label="$t('modelConfig.select')" align="center" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.firmwareName')" prop="firmwareName" align="center"></el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.firmwareType')" prop="type" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ getFirmwareTypeName(scope.row.type) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.version')" prop="version" align="center"></el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.fileSize')" prop="size" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ formatFileSize(scope.row.size) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.remark')" prop="remark" align="center"
|
||||
show-overflow-tooltip></el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.createTime')" prop="createDate" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ formatDate(scope.row.createDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.updateTime')" prop="updateDate" align="center">
|
||||
<template slot-scope="scope">
|
||||
{{ formatDate(scope.row.updateDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('otaManagement.action')" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text"
|
||||
@click="downloadFirmware(scope.row)">{{ $t('otaManagement.download') }}</el-button>
|
||||
<el-button size="mini" type="text" @click="editParam(scope.row)">{{ $t('otaManagement.edit') }}</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteParam(scope.row)">{{ $t('otaManagement.delete') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">
|
||||
{{ isAllSelected ? $t('otaManagement.deselectAll') : $t('otaManagement.selectAll') }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="success" @click="showAddDialog"
|
||||
style="background: #5bc98c;border: None;">{{ $t('otaManagement.addNew') }}</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete"
|
||||
@click="deleteSelectedParams">{{ $t('otaManagement.delete') }}</el-button>
|
||||
</div>
|
||||
<div class="custom-pagination">
|
||||
<el-select v-model="pageSize" @change="handlePageSizeChange" class="page-size-select">
|
||||
<el-option v-for="item in pageSizeOptions" :key="item" :label="$t('otaManagement.itemsPerPage', { items: item })"
|
||||
:value="item">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
||||
{{ $t('otaManagement.firstPage') }}
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">
|
||||
{{ $t('otaManagement.prevPage') }}
|
||||
</button>
|
||||
<button v-for="page in visiblePages" :key="page" class="pagination-btn"
|
||||
:class="{ active: page === currentPage }" @click="goToPage(page)">
|
||||
{{ page }}
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">
|
||||
{{ $t('otaManagement.nextPage') }}
|
||||
</button>
|
||||
<span class="total-text">{{ $t('otaManagement.totalRecords', { total }) }}</span>
|
||||
<div class="operation-header">
|
||||
<h2 class="page-title">{{ $t('otaManagement.firmwareManagement') }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-input :placeholder="$t('otaManagement.searchPlaceholder')" v-model="searchName"
|
||||
class="search-input" @keyup.enter.native="handleSearch" clearable />
|
||||
<CustomButton icon="el-icon-search" type="confirm" @click="handleSearch">
|
||||
{{ $t('otaManagement.search') }}
|
||||
</CustomButton>
|
||||
</div>
|
||||
</div>
|
||||
<CustomTable ref="paramsTable" :data="paramsList" :columns="tableColumns" :loading="loading"
|
||||
:show-selection="true" :show-operations="true" :operations-label="$t('otaManagement.action')"
|
||||
:total="total" :current-page="currentPage" :page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions" @size-change="handlePageSizeChange"
|
||||
@page-change="goToPage">
|
||||
<template slot="selection" slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||||
</template>
|
||||
<template slot="type" slot-scope="scope">
|
||||
{{ getFirmwareTypeName(scope.row.type) }}
|
||||
</template>
|
||||
<template slot="size" slot-scope="scope">
|
||||
{{ formatFileSize(scope.row.size) }}
|
||||
</template>
|
||||
<template slot="createDate" slot-scope="scope">
|
||||
{{ formatDate(scope.row.createDate) }}
|
||||
</template>
|
||||
<template slot="updateDate" slot-scope="scope">
|
||||
{{ formatDate(scope.row.updateDate) }}
|
||||
</template>
|
||||
<template slot="operations" slot-scope="scope">
|
||||
<el-button size="mini" type="text"
|
||||
@click="downloadFirmware(scope.row)">{{ $t('otaManagement.download') }}</el-button>
|
||||
<el-button size="mini" type="text" @click="editParam(scope.row)">
|
||||
{{ $t('otaManagement.edit') }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteParam(scope.row)">
|
||||
{{ $t('otaManagement.delete') }}
|
||||
</el-button>
|
||||
</template>
|
||||
<template slot="footer-btns">
|
||||
<div class="ctrl_btn">
|
||||
<CustomButton
|
||||
:icon="isAllSelected ? 'el-icon-circle-close' : 'el-icon-circle-check'"
|
||||
size="small" @click="handleSelectAll">
|
||||
{{ isAllSelected ? $t('otaManagement.deselectAll') : $t('otaManagement.selectAll') }}
|
||||
</CustomButton>
|
||||
<CustomButton icon="el-icon-plus" size="small" @click="showAddDialog">
|
||||
{{ $t('otaManagement.addNew') }}
|
||||
</CustomButton>
|
||||
<CustomButton size="small" type="delete" icon="el-icon-delete"
|
||||
@click="deleteSelectedParams">
|
||||
{{ $t('otaManagement.delete') }}
|
||||
</CustomButton>
|
||||
</div>
|
||||
</template>
|
||||
</CustomTable>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -97,7 +69,7 @@
|
||||
|
||||
<!-- 新增/编辑固件对话框 -->
|
||||
<firmware-dialog :title="dialogTitle" :visible.sync="dialogVisible" :form="firmwareForm"
|
||||
:firmware-types="firmwareTypes" @submit="handleSubmit" @cancel="dialogVisible = false" />
|
||||
:firmware-types="firmwareTypes" @submit="handleSubmit" @cancel="dialogVisible = false" />
|
||||
<el-footer>
|
||||
<version-footer />
|
||||
</el-footer>
|
||||
@@ -109,11 +81,12 @@ import Api from "@/apis/api";
|
||||
import FirmwareDialog from "@/components/FirmwareDialog.vue";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import VersionFooter from "@/components/VersionFooter.vue";
|
||||
import CustomButton from "@/components/CustomButton.vue";
|
||||
import CustomTable from "@/components/CustomTable.vue";
|
||||
import { formatDate, formatFileSize } from "@/utils/format";
|
||||
import i18n from '@/i18n';
|
||||
|
||||
export default {
|
||||
components: { HeaderBar, FirmwareDialog, VersionFooter },
|
||||
components: { HeaderBar, FirmwareDialog, VersionFooter, CustomButton, CustomTable },
|
||||
data() {
|
||||
return {
|
||||
searchName: "",
|
||||
@@ -137,34 +110,26 @@ export default {
|
||||
firmwarePath: ""
|
||||
},
|
||||
firmwareTypes: [],
|
||||
tableColumns: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.initTableColumns();
|
||||
this.fetchFirmwareList();
|
||||
this.getFirmwareTypes();
|
||||
},
|
||||
|
||||
computed: {
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.pageSize);
|
||||
},
|
||||
visiblePages() {
|
||||
const pages = [];
|
||||
const maxVisible = 3;
|
||||
let start = Math.max(1, this.currentPage - 1);
|
||||
let end = Math.min(this.pageCount, start + maxVisible - 1);
|
||||
|
||||
if (end - start + 1 < maxVisible) {
|
||||
start = Math.max(1, end - maxVisible + 1);
|
||||
}
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
return pages;
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
initTableColumns() {
|
||||
this.tableColumns = [
|
||||
{ prop: 'firmwareName', label: this.$t('otaManagement.firmwareName'), align: 'center' },
|
||||
{ prop: 'type', label: this.$t('otaManagement.firmwareType'), align: 'center' },
|
||||
{ prop: 'version', label: this.$t('otaManagement.version'), align: 'center' },
|
||||
{ prop: 'size', label: this.$t('otaManagement.fileSize'), align: 'center' },
|
||||
{ prop: 'remark', label: this.$t('otaManagement.remark'), align: 'center' },
|
||||
{ prop: 'createDate', label: this.$t('otaManagement.createTime'), align: 'center' },
|
||||
{ prop: 'updateDate', label: this.$t('otaManagement.updateTime'), align: 'center' }
|
||||
];
|
||||
},
|
||||
handlePageSizeChange(val) {
|
||||
this.pageSize = val;
|
||||
this.currentPage = 1;
|
||||
@@ -194,7 +159,7 @@ export default {
|
||||
this.paramsList = [];
|
||||
this.total = 0;
|
||||
this.$message.error({
|
||||
message: res?.data?.msg || this.$t('otaManagement.getFirmwareListFailed'),
|
||||
message: res?.data?.msg || this.$t('otaManagement.fetchFirmwareListFailed'),
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
@@ -212,7 +177,6 @@ export default {
|
||||
},
|
||||
showAddDialog() {
|
||||
this.dialogTitle = this.$t('otaManagement.addFirmware');
|
||||
// 完全重置表单数据
|
||||
this.firmwareForm = {
|
||||
id: null,
|
||||
firmwareName: "",
|
||||
@@ -222,12 +186,6 @@ export default {
|
||||
remark: "",
|
||||
firmwarePath: ""
|
||||
};
|
||||
this.$nextTick(() => {
|
||||
// 重置表单的校验状态
|
||||
if (this.$refs.firmwareDialog && this.$refs.firmwareDialog.$refs.form) {
|
||||
this.$refs.firmwareDialog.$refs.form.clearValidate();
|
||||
}
|
||||
});
|
||||
this.dialogVisible = true;
|
||||
},
|
||||
editParam(row) {
|
||||
@@ -237,7 +195,6 @@ export default {
|
||||
},
|
||||
handleSubmit(form) {
|
||||
if (form.id) {
|
||||
// 编辑
|
||||
Api.ota.updateOta(form.id, form, (res) => {
|
||||
res = res.data;
|
||||
if (res.code === 0) {
|
||||
@@ -255,7 +212,6 @@ export default {
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
Api.ota.saveOta(form, (res) => {
|
||||
res = res.data;
|
||||
if (res.code === 0) {
|
||||
@@ -274,7 +230,6 @@ export default {
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
deleteSelectedParams() {
|
||||
const selectedRows = this.firmwareList.filter(row => row.selected);
|
||||
if (selectedRows.length === 0) {
|
||||
@@ -287,7 +242,6 @@ export default {
|
||||
this.deleteParam(selectedRows);
|
||||
},
|
||||
deleteParam(row) {
|
||||
// 处理单个参数或参数数组
|
||||
const params = Array.isArray(row) ? row : [row];
|
||||
|
||||
if (Array.isArray(row) && row.length === 0) {
|
||||
@@ -345,38 +299,17 @@ export default {
|
||||
}
|
||||
});
|
||||
},
|
||||
headerCellClassName({ columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
return "custom-selection-header";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
goFirst() {
|
||||
this.currentPage = 1;
|
||||
this.fetchFirmwareList();
|
||||
},
|
||||
goPrev() {
|
||||
if (this.currentPage > 1) {
|
||||
this.currentPage--;
|
||||
this.fetchFirmwareList();
|
||||
}
|
||||
},
|
||||
goNext() {
|
||||
if (this.currentPage < this.pageCount) {
|
||||
this.currentPage++;
|
||||
this.fetchFirmwareList();
|
||||
}
|
||||
},
|
||||
goToPage(page) {
|
||||
this.currentPage = page;
|
||||
this.fetchFirmwareList();
|
||||
if (page !== this.currentPage) {
|
||||
this.currentPage = page;
|
||||
this.fetchFirmwareList();
|
||||
}
|
||||
},
|
||||
downloadFirmware(firmware) {
|
||||
if (!firmware || !firmware.id) {
|
||||
this.$message.error(this.$t('otaManagement.incompleteFirmwareInfo'));
|
||||
return;
|
||||
}
|
||||
// 先获取下载链接
|
||||
Api.ota.getDownloadUrl(firmware.id, (res) => {
|
||||
if (res.data.code === 0) {
|
||||
const uuid = res.data.data;
|
||||
@@ -422,25 +355,23 @@ export default {
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
// 顶部 63px 底部 35px 查询72px
|
||||
height: calc(100vh - 63px - 35px - 72px);
|
||||
margin: 0 22px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
height: calc(100vh - 63px - 35px);
|
||||
padding: 20px 22px 0;
|
||||
position: relative;
|
||||
background: rgba(237, 242, 255, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.operation-bar {
|
||||
.operation-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
justify-content: space-between;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -455,14 +386,7 @@ export default {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
@@ -491,7 +415,7 @@ export default {
|
||||
overflow: hidden;
|
||||
|
||||
::v-deep .el-card__body {
|
||||
padding: 15px;
|
||||
padding: 14px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
@@ -499,267 +423,15 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.ctrl_btn {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-left: 26px;
|
||||
|
||||
.el-button {
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
padding: 7px 12px 7px 10px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
line-height: 1;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background: #5f70f3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.el-button--danger {
|
||||
background: #fd5b63;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
|
||||
.el-select {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.pagination-btn:first-child,
|
||||
.pagination-btn:nth-child(2),
|
||||
.pagination-btn:nth-last-child(2),
|
||||
.pagination-btn:nth-child(3) {
|
||||
min-width: 60px;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: #d7dce6;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn:not(:first-child):not(:nth-child(3)):not(:nth-child(2)):not(:nth-last-child(2)) {
|
||||
min-width: 28px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(245, 247, 250, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn.active {
|
||||
background: #5f70f3 !important;
|
||||
color: #ffffff !important;
|
||||
border-color: #5f70f3 !important;
|
||||
|
||||
&:hover {
|
||||
background: #6d7cf5 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.total-text {
|
||||
margin-left: 10px;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
width: 100px;
|
||||
margin-right: 10px;
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
:deep(.el-input__suffix) {
|
||||
right: 6px;
|
||||
width: 15px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
top: 6px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
:deep(.el-input__suffix-inner) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-icon-arrow-up:before) {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-top: 9px solid #606266;
|
||||
position: relative;
|
||||
transform: rotate(0deg);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
background: white;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.el-table__body-wrapper {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.el-table__header-wrapper {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.el-table__header th {
|
||||
background: white !important;
|
||||
color: black;
|
||||
font-weight: 600;
|
||||
height: 40px;
|
||||
padding: 8px 0;
|
||||
font-size: 14px;
|
||||
border-bottom: 1px solid #e4e7ed;
|
||||
}
|
||||
|
||||
.el-table__body tr {
|
||||
background-color: white;
|
||||
|
||||
td {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||
padding: 8px 0;
|
||||
height: 40px;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
}
|
||||
|
||||
.el-table__row:hover>td {
|
||||
background-color: #f5f7fa !important;
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa !important;
|
||||
color: #7079aa;
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text:hover) {
|
||||
color: #5a64b5 !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner) {
|
||||
background-color: #ffffff !important;
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner:hover) {
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
|
||||
background-color: #5f70f3 !important;
|
||||
border-color: #5f70f3 !important;
|
||||
}
|
||||
|
||||
:deep(.el-loading-mask) {
|
||||
background-color: rgba(255, 255, 255, 0.6) !important;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
:deep(.el-loading-spinner .path) {
|
||||
stroke: #6b8cff;
|
||||
}
|
||||
|
||||
.el-table {
|
||||
// --table-max-height: calc(100vh - 40vh);
|
||||
max-height: var(--table-max-height);
|
||||
|
||||
.el-table__body-wrapper {
|
||||
max-height: calc(var(--table-max-height) - 40px);
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1144px) {
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
.el-table__body tr {
|
||||
td {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
&+tr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
color: #5a64b5;
|
||||
}
|
||||
</style>
|
||||
|
||||
@@ -1,49 +1,20 @@
|
||||
<template>
|
||||
<div class="welcome">
|
||||
<HeaderBar />
|
||||
|
||||
<div class="operation-bar">
|
||||
<h2 class="page-title">{{ $t('header.providerManagement') }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-dropdown trigger="click" @command="handleSelectModelType" @visible-change="handleDropdownVisibleChange">
|
||||
<el-button class="category-btn">
|
||||
{{ $t('providerManagement.categoryFilter') }} {{ selectedModelTypeLabel }}<i class="el-icon-arrow-down el-icon--right"
|
||||
:class="{ 'rotate-down': DropdownVisible }"></i>
|
||||
</el-button>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="">{{ $t('common.all') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-for="item in translatedModelTypes" :key="item.value" :command="item.value">
|
||||
{{ item.label }}
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
<el-input :placeholder="$t('providerManagement.searchPlaceholder')" v-model="searchName" class="search-input" @keyup.enter.native="handleSearch"
|
||||
clearable />
|
||||
<el-button class="btn-search" @click="handleSearch">{{ $t('common.search') }}</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="main-wrapper">
|
||||
<div class="content-panel">
|
||||
<div class="content-area">
|
||||
<el-card class="provider-card" shadow="never">
|
||||
<el-table ref="providersTable" :data="filteredProvidersList" class="transparent-table" v-loading="loading"
|
||||
element-loading-text="拼命加载中" element-loading-spinner="el-icon-loading"
|
||||
element-loading-background="rgba(255, 255, 255, 0.7)" :header-cell-class-name="headerCellClassName">
|
||||
<el-table-column :label="$t('modelConfig.select')" align="center" width="120">
|
||||
<template slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||||
</template>
|
||||
</el-table-column>
|
||||
|
||||
<el-table-column :label="$t('providerManagement.category')" prop="modelType" align="center" width="200">
|
||||
<template slot="header" slot-scope="scope">
|
||||
<el-dropdown trigger="click" @command="handleSelectModelType"
|
||||
@visible-change="isDropdownOpen = $event">
|
||||
<span class="dropdown-trigger" :class="{ 'active': isDropdownOpen }">
|
||||
{{ $t('providerManagement.category') }}{{ selectedModelTypeLabel }} <i class="dropdown-arrow"
|
||||
:class="{ 'is-active': isDropdownOpen }"></i>
|
||||
</span>
|
||||
<div class="operation-header">
|
||||
<h2 class="page-title">{{ $t('header.providerManagement') }}</h2>
|
||||
<div class="right-operations">
|
||||
<el-input :placeholder="$t('providerManagement.searchPlaceholder')" v-model="searchName" class="search-input"
|
||||
@keyup.enter.native="handleSearch" clearable />
|
||||
<el-dropdown trigger="click" @command="handleSelectModelType" @visible-change="handleDropdownVisibleChange">
|
||||
<CustomButton>
|
||||
{{ $t('providerManagement.categoryFilter') }}{{ selectedModelTypeLabel }}<i class="el-icon-arrow-down el-icon--right"
|
||||
:class="{ 'rotate-down': DropdownVisible }"></i>
|
||||
</CustomButton>
|
||||
<el-dropdown-menu slot="dropdown">
|
||||
<el-dropdown-item command="">{{ $t('common.all') }}</el-dropdown-item>
|
||||
<el-dropdown-item v-for="item in translatedModelTypes" :key="item.value" :command="item.value">
|
||||
@@ -51,66 +22,60 @@
|
||||
</el-dropdown-item>
|
||||
</el-dropdown-menu>
|
||||
</el-dropdown>
|
||||
</template>
|
||||
<template slot-scope="scope">
|
||||
<el-tag :type="getModelTypeTag(scope.row.modelType)">
|
||||
{{ getModelTypeLabel(scope.row.modelType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('providerManagement.providerCode')" prop="providerCode" align="center" width="150"></el-table-column>
|
||||
<el-table-column :label="$t('common.name')" prop="name" align="center"></el-table-column>
|
||||
<el-table-column :label="$t('providerManagement.fieldConfig')" align="center">
|
||||
<template slot-scope="scope">
|
||||
<el-popover placement="top-start" width="400" trigger="hover">
|
||||
<div v-for="field in scope.row.fields" :key="field.key" class="field-item">
|
||||
<span class="field-label">{{ field.label }}:</span>
|
||||
<span class="field-type">{{ field.type }}</span>
|
||||
<span v-if="isSensitiveField(field.key)" class="sensitive-tag">{{ $t('common.sensitive') }}</span>
|
||||
</div>
|
||||
<el-button slot="reference" size="mini" type="text">{{ $t('providerManagement.viewFields') }}</el-button>
|
||||
</el-popover>
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column :label="$t('common.sort')" prop="sort" align="center" width="80"></el-table-column>
|
||||
<el-table-column :label="$t('common.action')" align="center" width="180">
|
||||
<template slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="editProvider(scope.row)">{{ $t('common.edit') }}</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteProvider(scope.row)">{{ $t('common.delete') }}</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
|
||||
<div class="table_bottom">
|
||||
<div class="ctrl_btn">
|
||||
<el-button size="mini" type="primary" class="select-all-btn" @click="handleSelectAll">
|
||||
{{ isAllSelected ? $t('common.deselectAll') : $t('common.selectAll') }}
|
||||
</el-button>
|
||||
<el-button size="mini" type="success" @click="showAddDialog">{{ $t('common.add') }}</el-button>
|
||||
<el-button size="mini" type="danger" icon="el-icon-delete" @click="deleteSelectedProviders">{{ $t('common.delete') }}
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="custom-pagination">
|
||||
<el-select v-model="pageSize" @change="handlePageSizeChange" class="page-size-select">
|
||||
<el-option v-for="item in pageSizeOptions" :key="item" :label="$t('common.perPage', { number: item })" :value="item">
|
||||
</el-option>
|
||||
</el-select>
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
||||
{{ $t('common.firstPage') }}
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">
|
||||
{{ $t('common.prevPage') }}
|
||||
</button>
|
||||
<button v-for="page in visiblePages" :key="page" class="pagination-btn"
|
||||
:class="{ active: page === currentPage }" @click="goToPage(page)">
|
||||
{{ page }}
|
||||
</button>
|
||||
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">
|
||||
{{ $t('common.nextPage') }}
|
||||
</button>
|
||||
<span class="total-text">{{ $t('common.totalRecords', { number: total }) }}</span>
|
||||
<CustomButton icon="el-icon-search" type="confirm" @click="handleSearch">{{ $t('common.search') }}</CustomButton>
|
||||
</div>
|
||||
</div>
|
||||
<CustomTable
|
||||
ref="providersTable"
|
||||
:data="filteredProvidersList"
|
||||
:columns="tableColumns"
|
||||
:loading="loading"
|
||||
:show-selection="true"
|
||||
:show-operations="true"
|
||||
:operations-label="$t('common.action')"
|
||||
:total="total"
|
||||
:current-page="currentPage"
|
||||
:page-size="pageSize"
|
||||
:page-size-options="pageSizeOptions"
|
||||
@size-change="handlePageSizeChange"
|
||||
@page-change="goToPage"
|
||||
>
|
||||
<template slot="selection" slot-scope="scope">
|
||||
<el-checkbox v-model="scope.row.selected"></el-checkbox>
|
||||
</template>
|
||||
<template slot="modelType" slot-scope="scope">
|
||||
<el-tag :type="getModelTypeTag(scope.row.modelType)">
|
||||
{{ getModelTypeLabel(scope.row.modelType) }}
|
||||
</el-tag>
|
||||
</template>
|
||||
<template slot="fields" slot-scope="scope">
|
||||
<el-popover placement="top-start" width="400" trigger="hover">
|
||||
<div v-for="field in scope.row.fields" :key="field.key" class="field-item">
|
||||
<span class="field-label">{{ field.label }}:</span>
|
||||
<span class="field-type">{{ field.type }}</span>
|
||||
<span v-if="isSensitiveField(field.key)" class="sensitive-tag">{{ $t('common.sensitive') }}</span>
|
||||
</div>
|
||||
<el-button slot="reference" size="mini" type="text">{{ $t('providerManagement.viewFields') }}</el-button>
|
||||
</el-popover>
|
||||
</template>
|
||||
<template slot="operations" slot-scope="scope">
|
||||
<el-button size="mini" type="text" @click="editProvider(scope.row)">{{ $t('common.edit') }}</el-button>
|
||||
<el-button size="mini" type="text" @click="deleteProvider(scope.row)">{{ $t('common.delete') }}</el-button>
|
||||
</template>
|
||||
<template slot="footer-btns">
|
||||
<div class="ctrl_btn">
|
||||
<CustomButton :icon="isAllSelected ? 'el-icon-circle-close' : 'el-icon-circle-check'" size="small" @click="handleSelectAll">
|
||||
{{ isAllSelected ? $t('common.deselectAll') : $t('common.selectAll') }}
|
||||
</CustomButton>
|
||||
<CustomButton icon="el-icon-plus" size="small" @click="showAddDialog">
|
||||
{{ $t('common.add') }}
|
||||
</CustomButton>
|
||||
<CustomButton size="small" type="delete" icon="el-icon-delete" @click="deleteSelectedProviders">
|
||||
{{ $t('common.delete') }}
|
||||
</CustomButton>
|
||||
</div>
|
||||
</template>
|
||||
</CustomTable>
|
||||
</el-card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -131,9 +96,11 @@ import Api from "@/apis/api";
|
||||
import HeaderBar from "@/components/HeaderBar.vue";
|
||||
import ProviderDialog from "@/components/ProviderDialog.vue";
|
||||
import VersionFooter from "@/components/VersionFooter.vue";
|
||||
import CustomButton from "@/components/CustomButton.vue";
|
||||
import CustomTable from "@/components/CustomTable.vue";
|
||||
|
||||
export default {
|
||||
components: { HeaderBar, ProviderDialog, VersionFooter },
|
||||
components: { HeaderBar, ProviderDialog, VersionFooter, CustomButton, CustomTable },
|
||||
data() {
|
||||
return {
|
||||
searchName: "",
|
||||
@@ -158,7 +125,7 @@ export default {
|
||||
dialogVisible: false,
|
||||
dialogTitle: "新增供应器",
|
||||
isAllSelected: false,
|
||||
isDropdownOpen: false,
|
||||
DropdownVisible: false,
|
||||
sensitive_keys: ["api_key", "personal_access_token", "access_token", "token", "secret", "access_key_secret", "secret_key"],
|
||||
providerForm: {
|
||||
id: null,
|
||||
@@ -168,10 +135,11 @@ export default {
|
||||
fields: [],
|
||||
sort: 0
|
||||
},
|
||||
DropdownVisible: false,
|
||||
tableColumns: []
|
||||
};
|
||||
},
|
||||
created() {
|
||||
this.initTableColumns();
|
||||
this.fetchProviders();
|
||||
},
|
||||
computed: {
|
||||
@@ -186,41 +154,43 @@ export default {
|
||||
const selectedType = this.modelTypes.find(item => item.value === this.searchModelType);
|
||||
return selectedType ? `(${this.$t(selectedType.labelKey)})` : "";
|
||||
},
|
||||
pageCount() {
|
||||
return Math.ceil(this.total / this.pageSize);
|
||||
},
|
||||
visiblePages() {
|
||||
const pages = [];
|
||||
const maxVisible = 3;
|
||||
let start = Math.max(1, this.currentPage - 1);
|
||||
let end = Math.min(this.pageCount, start + maxVisible - 1);
|
||||
|
||||
if (end - start + 1 < maxVisible) {
|
||||
start = Math.max(1, end - maxVisible + 1);
|
||||
}
|
||||
|
||||
for (let i = start; i <= end; i++) {
|
||||
pages.push(i);
|
||||
}
|
||||
return pages;
|
||||
},
|
||||
filteredProvidersList() {
|
||||
return this.providersList;
|
||||
|
||||
// let list = this.providersList.filter(item => {
|
||||
// const nameMatch = item.name.toLowerCase().includes(this.searchName.toLowerCase());
|
||||
// const typeMatch = !this.searchModelType || item.model_type === this.searchModelType;
|
||||
// return nameMatch && typeMatch;
|
||||
// });
|
||||
|
||||
// list.sort((a, b) => a.sort - b.sort);
|
||||
|
||||
// // 分页处理
|
||||
// const start = (this.currentPage - 1) * this.pageSize;
|
||||
// return list.slice(start, start + this.pageSize);
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
initTableColumns() {
|
||||
this.tableColumns = [
|
||||
{
|
||||
prop: 'modelType',
|
||||
label: this.$t('providerManagement.category'),
|
||||
align: 'center',
|
||||
width: 200
|
||||
},
|
||||
{
|
||||
prop: 'providerCode',
|
||||
label: this.$t('providerManagement.providerCode'),
|
||||
align: 'center',
|
||||
width: 150
|
||||
},
|
||||
{
|
||||
prop: 'name',
|
||||
label: this.$t('common.name'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'fields',
|
||||
label: this.$t('providerManagement.fieldConfig'),
|
||||
align: 'center'
|
||||
},
|
||||
{
|
||||
prop: 'sort',
|
||||
label: this.$t('common.sort'),
|
||||
align: 'center',
|
||||
width: 80
|
||||
}
|
||||
];
|
||||
},
|
||||
fetchProviders() {
|
||||
this.loading = true;
|
||||
|
||||
@@ -255,7 +225,6 @@ export default {
|
||||
this.fetchProviders();
|
||||
},
|
||||
handleSelectModelType(value) {
|
||||
this.isDropdownOpen = false;
|
||||
this.searchModelType = value;
|
||||
this.handleSearch();
|
||||
},
|
||||
@@ -288,26 +257,23 @@ export default {
|
||||
handleSubmit({ form, done }) {
|
||||
this.loading = true;
|
||||
if (form.id) {
|
||||
// 编辑
|
||||
Api.model.updateModelProvider(form, ({ data }) => {
|
||||
|
||||
if (data.code === 0) {
|
||||
this.fetchProviders(); // 刷新表格
|
||||
this.fetchProviders();
|
||||
this.$message.success({
|
||||
message: this.$t('common.updateSuccess'),
|
||||
showClose: true
|
||||
});
|
||||
message: this.$t('common.updateSuccess'),
|
||||
showClose: true
|
||||
});
|
||||
}
|
||||
});
|
||||
} else {
|
||||
// 新增
|
||||
Api.model.addModelProvider(form, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
this.fetchProviders(); // 刷新表格
|
||||
this.fetchProviders();
|
||||
this.$message.success({
|
||||
message: this.$t('common.addSuccess'),
|
||||
showClose: true
|
||||
});
|
||||
message: this.$t('common.addSuccess'),
|
||||
showClose: true
|
||||
});
|
||||
this.total += 1;
|
||||
}
|
||||
});
|
||||
@@ -339,10 +305,8 @@ export default {
|
||||
const ids = providers.map(provider => provider.id);
|
||||
Api.model.deleteModelProviderByIds(ids, ({ data }) => {
|
||||
if (data.code === 0) {
|
||||
|
||||
this.isAllSelected = false;
|
||||
this.fetchProviders(); // 刷新表格
|
||||
|
||||
this.fetchProviders();
|
||||
this.$message.success({
|
||||
message: this.$t('common.deleteSuccess'),
|
||||
showClose: true
|
||||
@@ -390,57 +354,16 @@ export default {
|
||||
this.currentPage = 1;
|
||||
this.fetchProviders();
|
||||
},
|
||||
headerCellClassName({ columnIndex }) {
|
||||
if (columnIndex === 0) {
|
||||
return "custom-selection-header";
|
||||
}
|
||||
return "";
|
||||
},
|
||||
selectionCellClassName() {
|
||||
return "custom-selection-cell";
|
||||
},
|
||||
updateSelectionHeaderText() {
|
||||
// 确保表格已渲染
|
||||
this.$nextTick(() => {
|
||||
if (this.$refs.providersTable && this.$refs.providersTable.$el) {
|
||||
const headerCheckbox = this.$refs.providersTable.$el.querySelector('.custom-selection-header .el-checkbox .el-checkbox__label');
|
||||
if (headerCheckbox) {
|
||||
headerCheckbox.textContent = this.$t('modelConfig.select');
|
||||
}
|
||||
}
|
||||
});
|
||||
},
|
||||
mounted() {
|
||||
this.updateSelectionHeaderText();
|
||||
},
|
||||
updated() {
|
||||
this.updateSelectionHeaderText();
|
||||
},
|
||||
goFirst() {
|
||||
this.currentPage = 1;
|
||||
this.fetchProviders();
|
||||
},
|
||||
goPrev() {
|
||||
if (this.currentPage > 1) {
|
||||
this.currentPage--;
|
||||
this.fetchProviders();
|
||||
}
|
||||
},
|
||||
goNext() {
|
||||
if (this.currentPage < this.pageCount) {
|
||||
console.log("this.currentPage", this.currentPage);
|
||||
this.currentPage++;
|
||||
this.fetchProviders();
|
||||
}
|
||||
},
|
||||
goToPage(page) {
|
||||
this.currentPage = page;
|
||||
this.fetchProviders();
|
||||
if (page !== this.currentPage) {
|
||||
this.currentPage = page;
|
||||
this.fetchProviders();
|
||||
}
|
||||
},
|
||||
handleDropdownVisibleChange(visible) {
|
||||
this.DropdownVisible = visible;
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
||||
@@ -460,25 +383,24 @@ export default {
|
||||
}
|
||||
|
||||
.main-wrapper {
|
||||
// 顶部 63px 底部 35px 查询72px
|
||||
height: calc(100vh - 63px - 35px - 72px);
|
||||
margin: 0 22px;
|
||||
border-radius: 15px;
|
||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||
// 顶部 63px 底部 35px
|
||||
height: calc(100vh - 63px - 35px);
|
||||
padding: 20px 22px 0;
|
||||
position: relative;
|
||||
background: rgba(237, 242, 255, 0.5);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
.operation-bar {
|
||||
.operation-header {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
padding: 16px 24px;
|
||||
justify-content: space-between;
|
||||
padding: 0 0 16px 0;
|
||||
}
|
||||
|
||||
.page-title {
|
||||
font-weight: 500;
|
||||
font-size: 24px;
|
||||
margin: 0;
|
||||
}
|
||||
@@ -487,20 +409,14 @@ export default {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-left: auto;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
width: 240px;
|
||||
}
|
||||
|
||||
.btn-search {
|
||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||
border: none;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.content-panel {
|
||||
flex: 1;
|
||||
display: flex;
|
||||
overflow: hidden;
|
||||
height: 100%;
|
||||
@@ -519,20 +435,17 @@ export default {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.el-card {
|
||||
border: none;
|
||||
}
|
||||
|
||||
.provider-card {
|
||||
background: white;
|
||||
flex: 1;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
border: none;
|
||||
box-shadow: none;
|
||||
overflow: hidden;
|
||||
|
||||
::v-deep .el-card__body {
|
||||
padding: 15px;
|
||||
padding: 14px 20px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: 1;
|
||||
@@ -540,284 +453,8 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.ctrl_btn {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
padding-left: 26px;
|
||||
|
||||
.el-button {
|
||||
min-width: 72px;
|
||||
height: 32px;
|
||||
padding: 7px 12px 7px 10px;
|
||||
font-size: 12px;
|
||||
border-radius: 4px;
|
||||
line-height: 1;
|
||||
font-weight: 500;
|
||||
border: none;
|
||||
transition: all 0.3s ease;
|
||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
||||
|
||||
&:hover {
|
||||
transform: translateY(-1px);
|
||||
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||
}
|
||||
}
|
||||
|
||||
.el-button--primary {
|
||||
background: #5f70f3;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.el-button--danger {
|
||||
background: #fd5b63;
|
||||
color: white;
|
||||
}
|
||||
}
|
||||
|
||||
.custom-pagination {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
|
||||
.el-select {
|
||||
margin-right: 8px;
|
||||
}
|
||||
|
||||
.pagination-btn:first-child,
|
||||
.pagination-btn:nth-child(2),
|
||||
.pagination-btn:nth-last-child(2),
|
||||
.pagination-btn:nth-child(3) {
|
||||
min-width: 60px;
|
||||
height: 32px;
|
||||
padding: 0 12px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: #d7dce6;
|
||||
}
|
||||
|
||||
&:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: not-allowed;
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn:not(:first-child):not(:nth-child(3)):not(:nth-child(2)):not(:nth-last-child(2)) {
|
||||
min-width: 28px;
|
||||
height: 32px;
|
||||
padding: 0;
|
||||
border-radius: 4px;
|
||||
border: 1px solid transparent;
|
||||
background: transparent;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: all 0.3s ease;
|
||||
|
||||
&:hover {
|
||||
background: rgba(245, 247, 250, 0.3);
|
||||
}
|
||||
}
|
||||
|
||||
.pagination-btn.active {
|
||||
background: #5f70f3 !important;
|
||||
color: #ffffff !important;
|
||||
border-color: #5f70f3 !important;
|
||||
|
||||
&:hover {
|
||||
background: #6d7cf5 !important;
|
||||
}
|
||||
}
|
||||
|
||||
.total-text {
|
||||
color: #909399;
|
||||
font-size: 14px;
|
||||
margin-left: 10px;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
background: white;
|
||||
flex: 1;
|
||||
width: 100%;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
|
||||
.el-table__body-wrapper {
|
||||
flex: 1;
|
||||
overflow-y: auto;
|
||||
max-height: none !important;
|
||||
}
|
||||
|
||||
.el-table__header-wrapper {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.el-table__header th {
|
||||
background: white !important;
|
||||
color: black;
|
||||
}
|
||||
|
||||
&::before {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.el-table__body tr {
|
||||
background-color: white;
|
||||
|
||||
td {
|
||||
border-top: 1px solid rgba(0, 0, 0, 0.04);
|
||||
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
:deep(.el-checkbox__inner) {
|
||||
background-color: #ffffff !important;
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__inner:hover) {
|
||||
border-color: #cccccc !important;
|
||||
}
|
||||
|
||||
:deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
|
||||
background-color: #5f70f3 !important;
|
||||
border-color: #5f70f3 !important;
|
||||
}
|
||||
|
||||
@media (min-width: 1144px) {
|
||||
.table_bottom {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
margin-top: 40px;
|
||||
}
|
||||
|
||||
:deep(.transparent-table) {
|
||||
.el-table__body tr {
|
||||
td {
|
||||
padding-top: 16px;
|
||||
padding-bottom: 16px;
|
||||
}
|
||||
|
||||
&+tr {
|
||||
margin-top: 10px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa;
|
||||
}
|
||||
|
||||
:deep(.el-table .el-button--text:hover) {
|
||||
color: #5a64b5;
|
||||
}
|
||||
|
||||
.el-button--success {
|
||||
background: #5bc98c;
|
||||
color: white;
|
||||
}
|
||||
|
||||
:deep(.el-table .cell) {
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.page-size-select {
|
||||
width: 100px;
|
||||
margin-right: 10px;
|
||||
|
||||
:deep(.el-input__inner) {
|
||||
height: 32px;
|
||||
line-height: 32px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid #e4e7ed;
|
||||
background: #dee7ff;
|
||||
color: #606266;
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
:deep(.el-input__suffix) {
|
||||
right: 6px;
|
||||
width: 15px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
top: 6px;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
:deep(.el-input__suffix-inner) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
:deep(.el-icon-arrow-up:before) {
|
||||
content: "";
|
||||
display: inline-block;
|
||||
border-left: 6px solid transparent;
|
||||
border-right: 6px solid transparent;
|
||||
border-top: 9px solid #606266;
|
||||
position: relative;
|
||||
transform: rotate(0deg);
|
||||
transition: transform 0.3s;
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-table) {
|
||||
.el-table__body-wrapper {
|
||||
transition: height 0.3s ease;
|
||||
}
|
||||
}
|
||||
|
||||
.el-table {
|
||||
// --table-max-height: calc(100vh - 40vh);
|
||||
max-height: var(--table-max-height);
|
||||
|
||||
.el-table__body-wrapper {
|
||||
max-height: calc(var(--table-max-height) - 40px);
|
||||
}
|
||||
}
|
||||
|
||||
:deep(.el-loading-mask) {
|
||||
background-color: rgba(255, 255, 255, 0.6) !important;
|
||||
backdrop-filter: blur(2px);
|
||||
}
|
||||
|
||||
:deep(.el-loading-spinner .circular) {
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
}
|
||||
|
||||
:deep(.el-loading-spinner .path) {
|
||||
stroke: #6b8cff;
|
||||
}
|
||||
|
||||
:deep(.el-loading-text) {
|
||||
color: #6b8cff !important;
|
||||
font-size: 14px;
|
||||
margin-top: 8px;
|
||||
}
|
||||
|
||||
.field-item {
|
||||
@@ -843,40 +480,6 @@ export default {
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-trigger {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
color: #409EFF;
|
||||
}
|
||||
}
|
||||
|
||||
.dropdown-trigger.active {
|
||||
color: #409EFF;
|
||||
}
|
||||
|
||||
.dropdown-arrow {
|
||||
display: inline-block;
|
||||
margin-left: 5px;
|
||||
width: 0;
|
||||
height: 0;
|
||||
border-left: 5px solid transparent;
|
||||
border-right: 5px solid transparent;
|
||||
border-top: 7px solid black;
|
||||
position: relative;
|
||||
transition: transform 0.3s ease;
|
||||
transform: rotate(0deg);
|
||||
|
||||
&.is-active {
|
||||
transform: rotate(180deg);
|
||||
border-top-color: #409EFF;
|
||||
}
|
||||
}
|
||||
|
||||
.rotate-down {
|
||||
transform: rotate(180deg);
|
||||
transition: transform 0.3s ease;
|
||||
@@ -886,41 +489,11 @@ export default {
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.dropdown-trigger {
|
||||
font-size: 14px;
|
||||
color: #303133;
|
||||
cursor: pointer;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
|
||||
&:hover {
|
||||
color: #409EFF;
|
||||
}
|
||||
:deep(.el-table .el-button--text) {
|
||||
color: #7079aa;
|
||||
}
|
||||
|
||||
.dropdown-trigger.active {
|
||||
color: #409EFF;
|
||||
:deep(.el-table .el-button--text:hover) {
|
||||
color: #5a64b5;
|
||||
}
|
||||
|
||||
/* 确保选择列标题样式正确 */
|
||||
.custom-selection-header {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
:deep(.custom-selection-header .el-checkbox) {
|
||||
display: flex !important;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
:deep(.custom-selection-header .el-checkbox__label) {
|
||||
position: relative;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
:deep(.custom-selection-cell) {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
</style>
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user