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