update: 模型配置编辑弹窗样式调整

This commit is contained in:
zhuoqinglian
2026-06-22 17:31:09 +08:00
parent cd58b2c3cb
commit 3c5ca9f143
2 changed files with 163 additions and 272 deletions
@@ -127,7 +127,6 @@ export default {
border-radius: 10px;
overflow: hidden;
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
margin-top: 15vh !important;
}
::v-deep .el-dialog__header {
@@ -1,135 +1,107 @@
<template>
<el-dialog :visible.sync="dialogVisible" :close-on-click-modal="false" 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: -10px;
margin-bottom: 10px;
text-align: center;
">
{{
modelData.duplicateMode
? $t("modelConfigDialog.duplicateModel")
: $t("modelConfigDialog.editModel")
}}
</div>
<button class="custom-close-btn" @click="dialogVisible = false">×</button>
<div style="
display: flex;
justify-content: space-between;
align-items: center;
margin-bottom: 10px;
">
<div style="font-size: 20px; font-weight: bold; color: #3d4566">
{{ $t("modelConfigDialog.modelInfo") }}
<CustomDialog
:title="title"
:visible.sync="dialogVisible"
width="57%"
class="model-edit-dialog"
:confirmLoading="saving"
@confirm="handleSave"
@close="handleClose"
@open="handleOpen"
>
<div class="dialog-scroll-body">
<div class="header-row">
<div class="section-title">{{ $t("modelConfigDialog.modelInfo") }}</div>
<div class="switch-group">
<div class="switch-item">
<span class="switch-label">{{ $t("modelConfigDialog.enable") }}</span>
<el-switch v-model="form.isEnabled" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
</div>
<div style="display: flex; align-items: center; gap: 20px">
<div style="display: flex; align-items: center">
<span style="margin-right: 8px">{{ $t("modelConfigDialog.enable") }}</span>
<el-switch v-model="form.isEnabled" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
</div>
<div style="display: none; align-items: center">
<span style="margin-right: 8px">{{
$t("modelConfigDialog.setDefault")
}}</span>
<el-switch v-model="form.isDefault" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
</div>
<div class="switch-item hidden">
<span class="switch-label">{{ $t("modelConfigDialog.setDefault") }}</span>
<el-switch v-model="form.isDefault" :active-value="1" :inactive-value="0" class="custom-switch"></el-switch>
</div>
</div>
</div>
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px"></div>
<div class="section-divider"></div>
<el-form :model="form" ref="form" label-width="auto" label-position="left" class="custom-form">
<div style="display: flex; gap: 20px; margin-bottom: 0">
<el-form-item :label="$t('modelConfigDialog.modelName')" prop="name" style="flex: 1">
<el-input v-model="form.modelName" :placeholder="$t('modelConfigDialog.enterModelName')"
class="custom-input-bg"></el-input>
</el-form-item>
<el-form-item :label="$t('modelConfigDialog.modelCode')" prop="code" style="flex: 1">
<el-input v-model="form.modelCode" :placeholder="$t('modelConfigDialog.enterModelCode')"
class="custom-input-bg"></el-input>
</el-form-item>
</div>
<div style="display: flex; gap: 20px; margin-bottom: 0">
<el-form-item :label="$t('modelConfigDialog.supplier')" prop="supplier" style="flex: 1">
<el-select v-model="form.configJson.type" :placeholder="$t('modelConfigDialog.selectSupplier')"
class="custom-select custom-input-bg" style="width: 100%" @focus="loadProviders" filterable>
<el-option v-for="item in providers" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('modelConfigDialog.sortOrder')" prop="sort" style="flex: 1">
<el-input v-model.number="form.sort" type="number" :placeholder="$t('modelConfigDialog.enterSortOrder')"
class="custom-input-bg"></el-input>
</el-form-item>
</div>
<el-form-item :label="$t('modelConfigDialog.docLink')" prop="docUrl" style="margin-bottom: 27px">
<el-input v-model="form.docLink" :placeholder="$t('modelConfigDialog.enterDocLink')"
class="custom-input-bg"></el-input>
<el-form :model="form" ref="form" label-width="auto" label-position="left">
<div class="form-row">
<el-form-item :label="$t('modelConfigDialog.modelName')" prop="name" style="flex: 1">
<el-input v-model="form.modelName" :placeholder="$t('modelConfigDialog.enterModelName')"></el-input>
</el-form-item>
<el-form-item :label="$t('modelConfigDialog.remark')" prop="remark" class="prop-remark">
<el-input v-model="form.remark" type="textarea" :rows="3" :placeholder="$t('modelConfigDialog.enterRemark')"
:autosize="{ minRows: 3, maxRows: 5 }" class="custom-input-bg"></el-input>
<el-form-item :label="$t('modelConfigDialog.modelCode')" prop="code" style="flex: 1">
<el-input v-model="form.modelCode" :placeholder="$t('modelConfigDialog.enterModelCode')"></el-input>
</el-form-item>
</el-form>
<div style="font-size: 20px; font-weight: bold; color: #3d4566; margin-bottom: 15px">
{{ $t("modelConfigDialog.callInfo") }}
</div>
<div style="height: 2px; background: #e9e9e9; margin-bottom: 22px"></div>
<el-form :model="form.configJson" ref="callInfoForm" label-width="auto" class="custom-form">
<template v-for="(row, rowIndex) in chunkedCallInfoFields">
<div :key="rowIndex" style="display: flex; gap: 20px; margin-bottom: 0">
<el-form-item v-for="field in row" :key="field.prop" :label="field.label" :prop="field.prop"
style="flex: 1">
<template v-if="field.type === 'json-textarea'">
<el-input v-model="fieldJsonMap[field.prop]" type="textarea" :rows="3"
:placeholder="$t('modelConfigDialog.enterJsonExample')" class="custom-input-bg"
@change="(val) => handleJsonChange(field.prop, val)" @focus="
isSensitiveField(field.prop)
? handleJsonInputFocus(field.prop, fieldJsonMap[field.prop])
: undefined
" @blur="
isSensitiveField(field.prop)
? handleJsonInputBlur(field.prop)
: undefined
"></el-input>
</template>
<div class="form-row">
<el-form-item :label="$t('modelConfigDialog.supplier')" prop="supplier" style="flex: 1">
<el-select v-model="form.configJson.type" :placeholder="$t('modelConfigDialog.selectSupplier')"
style="width: 100%" @focus="loadProviders" filterable>
<el-option v-for="item in providers" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item :label="$t('modelConfigDialog.sortOrder')" prop="sort" style="flex: 1">
<el-input v-model.number="form.sort" type="number" :placeholder="$t('modelConfigDialog.enterSortOrder')"></el-input>
</el-form-item>
</div>
<el-input v-else v-model="form.configJson[field.prop]" :placeholder="field.placeholder" :type="field.type"
class="custom-input-bg" :show-password="field.type === 'password'" @focus="
<el-form-item :label="$t('modelConfigDialog.docLink')" prop="docUrl" style="margin-bottom: 27px">
<el-input v-model="form.docLink" :placeholder="$t('modelConfigDialog.enterDocLink')"></el-input>
</el-form-item>
<el-form-item :label="$t('modelConfigDialog.remark')" prop="remark" class="prop-remark">
<el-input v-model="form.remark" type="textarea" :rows="4" :placeholder="$t('modelConfigDialog.enterRemark')"></el-input>
</el-form-item>
</el-form>
<div class="section-title">{{ $t("modelConfigDialog.callInfo") }}</div>
<div class="section-divider"></div>
<el-form :model="form.configJson" ref="callInfoForm" label-width="auto">
<template>
<div v-for="(row, rowIndex) in chunkedCallInfoFields" :key="rowIndex" class="form-row">
<el-form-item v-for="field in row" :key="field.prop" :label="field.label" :prop="field.prop"
style="flex: 1">
<template v-if="field.type === 'json-textarea'">
<el-input v-model="fieldJsonMap[field.prop]" type="textarea" :rows="3"
:placeholder="$t('modelConfigDialog.enterJsonExample')"
@change="(val) => handleJsonChange(field.prop, val)" @focus="
isSensitiveField(field.prop)
? handleInputFocus(field.prop, form.configJson[field.prop])
? handleJsonInputFocus(field.prop, fieldJsonMap[field.prop])
: undefined
" @blur="
isSensitiveField(field.prop) ? handleInputBlur(field.prop) : undefined
isSensitiveField(field.prop)
? handleJsonInputBlur(field.prop)
: undefined
"></el-input>
</el-form-item>
</div>
</template>
</el-form>
</div>
</template>
<div style="display: flex; justify-content: center">
<el-button type="primary" @click="handleSave" class="save-btn" :loading="saving" :disabled="saving">
{{ $t("modelConfigDialog.save") }}
</el-button>
<el-input v-else v-model="form.configJson[field.prop]" :placeholder="field.placeholder" :type="field.type"
:show-password="field.type === 'password'" @focus="
isSensitiveField(field.prop)
? handleInputFocus(field.prop, form.configJson[field.prop])
: undefined
" @blur="
isSensitiveField(field.prop) ? handleInputBlur(field.prop) : undefined
"></el-input>
</el-form-item>
</div>
</template>
</el-form>
</div>
</el-dialog>
</CustomDialog>
</template>
<script>
import CustomDialog from './CustomDialog.vue';
import Api from "@/apis/api";
export default {
name: "ModelEditDialog",
components: { CustomDialog },
props: {
visible: { type: Boolean, default: false },
modelData: {
@@ -175,6 +147,11 @@ export default {
};
},
computed: {
title() {
return this.modelData.duplicateMode
? this.$t("modelConfigDialog.duplicateModel")
: this.$t("modelConfigDialog.editModel");
},
chunkedCallInfoFields() {
const chunkSize = 2;
const result = [];
@@ -189,19 +166,11 @@ export default {
this.resetProviders();
this.loadProviders();
},
dialogVisible(val) {
this.$emit("update:visible", val);
if (!val) {
this.resetForm();
} else if (val && this.modelData.id) {
this.loadModelData();
}
},
visible(val) {
this.dialogVisible = val;
if (val) {
this.loadProviders();
}
},
dialogVisible(val) {
this.$emit("update:visible", val);
},
"form.configJson.type"(newVal) {
if (newVal && this.providersLoaded) {
@@ -210,6 +179,19 @@ export default {
},
},
methods: {
handleOpen() {
this.loadProviders();
if (this.modelData.id) {
this.loadModelData();
}
},
handleClose() {
this.saving = false;
// 处理关闭弹窗闪动问题
setTimeout(() => {
this.resetForm();
}, 200)
},
resetForm() {
this.form = {
id: "",
@@ -480,168 +462,78 @@ export default {
</script>
<style lang="scss" scoped>
.custom-dialog {
position: relative;
border-radius: 20px;
overflow: hidden;
background: white;
padding-bottom: 17px;
::v-deep .el-dialog {
margin-top: 6vh !important;
}
.model-edit-dialog {
.dialog-scroll-body {
max-height: 72vh;
overflow-y: auto;
overflow-x: hidden;
.custom-dialog .el-dialog__header {
padding: 0;
border-bottom: none;
}
&::-webkit-scrollbar {
width: 6px;
}
&::-webkit-scrollbar-thumb {
background: #a1c9fd;
border-radius: 3px;
}
&::-webkit-scrollbar-track {
background: #f0f3fe;
border-radius: 3px;
}
}
.center-dialog {
display: flex;
align-items: center;
justify-content: center;
}
.header-row {
display: flex;
justify-content: space-between;
align-items: center;
}
.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;
}
.section-title {
margin-bottom: 10px;
font-size: 20px;
font-weight: bold;
color: #3d4566;
text-align: left;
}
.custom-close-btn:hover {
color: #409eff;
border-color: #409eff;
}
.switch-group {
display: flex;
align-items: center;
gap: 20px;
}
.custom-select .el-input__suffix {
background: #e6e8ea;
right: 6px;
width: 20px;
height: 20px;
display: flex;
justify-content: center;
align-items: center;
top: 9px;
}
.switch-item {
display: flex;
align-items: center;
.custom-select .el-input__suffix-inner {
display: flex;
align-items: center;
justify-content: center;
width: 100%;
}
&.hidden {
display: none;
}
.custom-select .el-icon-arrow-up:before {
content: "";
display: inline-block;
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 7px solid #c0c4cc;
position: relative;
top: -2px;
transform: rotate(180deg);
}
.switch-label {
margin-right: 8px;
}
}
.custom-form .el-form-item {
margin-bottom: 20px;
}
.section-divider {
height: 1px;
background: #e9e9e9;
margin-bottom: 16px;
}
.custom-form .el-form-item__label {
color: #3d4566;
font-weight: normal;
text-align: right;
padding-right: 20px;
}
.form-row {
display: flex;
gap: 20px;
margin-bottom: 0;
}
.custom-form .el-form-item.prop-remark .el-form-item__label {
margin-top: -4px;
}
.custom-input-bg .el-input__inner::-webkit-input-placeholder,
.custom-input-bg .el-textarea__inner::-webkit-input-placeholder {
color: #9c9f9e;
}
.custom-input-bg .el-input__inner,
.custom-input-bg .el-textarea__inner {
background-color: #f6f8fc;
}
.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;
}
.custom-switch .el-switch__core {
border-radius: 20px;
height: 23px;
background-color: #c0ccda;
width: 35px;
padding: 0 20px;
}
.custom-switch .el-switch__core:after {
width: 15px;
height: 15px;
background-color: white;
top: 3px;
left: 4px;
transition: all 0.3s;
}
.custom-switch.is-checked .el-switch__core {
border-color: #b5bcf0;
background-color: #cfd7fa;
padding: 0 20px;
}
.custom-switch.is-checked .el-switch__core:after {
left: 100%;
margin-left: -18px;
background-color: #1b47ee;
}
[style*="display: flex"] {
gap: 20px;
}
.custom-input-bg .el-input__inner {
height: 32px;
}
.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;
::v-deep .el-input__inner {
height: 32px;
}
::v-deep .el-form-item {
margin-bottom: 10px;
}
}
</style>