mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-22 23:23:55 +08:00
365 lines
8.8 KiB
Vue
365 lines
8.8 KiB
Vue
<template>
|
|
<el-dialog :title="title"
|
|
:visible.sync="visible"
|
|
width="520px"
|
|
class="param-dialog-wrapper"
|
|
:append-to-body="true"
|
|
:close-on-click-modal="false"
|
|
:key="dialogKey"
|
|
custom-class="custom-param-dialog"
|
|
:show-close="false"
|
|
>
|
|
<div class="dialog-container">
|
|
<div class="dialog-header">
|
|
<h2 class="dialog-title">{{ title }}</h2>
|
|
<button class="custom-close-btn" @click="cancel">
|
|
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
<path d="M13 1L1 13M1 1L13 13" stroke="currentColor" stroke-width="2" stroke-linecap="round"/>
|
|
</svg>
|
|
</button>
|
|
</div>
|
|
|
|
<el-form :model="form" :rules="rules" ref="form" label-width="110px" label-position="left" class="param-form">
|
|
<el-form-item label="参数编码" prop="paramCode" class="form-item">
|
|
<el-input v-model="form.paramCode" placeholder="请输入参数编码" class="custom-input"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="参数值" prop="paramValue" class="form-item">
|
|
<el-input v-model="form.paramValue" placeholder="请输入参数值" class="custom-input"></el-input>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="值类型" prop="valueType" class="form-item">
|
|
<el-select v-model="form.valueType" placeholder="请选择值类型" class="custom-select">
|
|
<el-option v-for="item in valueTypeOptions" :key="item.value" :label="item.label" :value="item.value"/>
|
|
</el-select>
|
|
</el-form-item>
|
|
|
|
<el-form-item label="备注" prop="remark" class="form-item remark-item">
|
|
<el-input type="textarea" v-model="form.remark" placeholder="请输入备注" :rows="3" class="custom-textarea"></el-input>
|
|
</el-form-item>
|
|
</el-form>
|
|
|
|
<div class="dialog-footer">
|
|
<el-button
|
|
type="primary"
|
|
@click="submit"
|
|
class="save-btn"
|
|
:loading="saving"
|
|
:disabled="saving">
|
|
保存
|
|
</el-button>
|
|
<el-button @click="cancel" class="cancel-btn">
|
|
取消
|
|
</el-button>
|
|
</div>
|
|
</div>
|
|
</el-dialog>
|
|
</template>
|
|
|
|
<script>
|
|
export default {
|
|
props: {
|
|
title: {
|
|
type: String,
|
|
default: '新增参数'
|
|
},
|
|
visible: {
|
|
type: Boolean,
|
|
default: false
|
|
},
|
|
form: {
|
|
type: Object,
|
|
default: () => ({
|
|
id: null,
|
|
paramCode: '',
|
|
paramValue: '',
|
|
valueType: 'string',
|
|
remark: ''
|
|
})
|
|
}
|
|
},
|
|
data() {
|
|
return {
|
|
dialogKey: Date.now(),
|
|
saving: false,
|
|
valueTypeOptions: [
|
|
{ value: 'string', label: '字符串(string)' },
|
|
{ value: 'number', label: '数字(number)' },
|
|
{ value: 'boolean', label: '布尔值(boolean)' },
|
|
{ value: 'array', label: '数组(array)' },
|
|
{ value: 'json', label: 'JSON对象(json)' }
|
|
],
|
|
rules: {
|
|
paramCode: [
|
|
{ required: true, message: "请输入参数编码", trigger: "blur" }
|
|
],
|
|
paramValue: [
|
|
{ required: true, message: "请输入参数值", trigger: "blur" }
|
|
],
|
|
valueType: [
|
|
{ required: true, message: "请选择值类型", trigger: "change" }
|
|
]
|
|
}
|
|
};
|
|
},
|
|
methods: {
|
|
submit() {
|
|
this.$refs.form.validate((valid) => {
|
|
if (valid) {
|
|
this.saving = true; // 开始加载
|
|
this.$emit('submit', {
|
|
form: this.form,
|
|
done: () => {
|
|
this.saving = false; // 加载完成
|
|
}
|
|
});
|
|
|
|
setTimeout(() => {
|
|
this.saving = false;
|
|
}, 3000);
|
|
}
|
|
});
|
|
},
|
|
cancel() {
|
|
this.saving = false; // 取消时重置状态
|
|
this.$emit('cancel');
|
|
}
|
|
},
|
|
watch: {
|
|
visible(newVal) {
|
|
if (newVal) {
|
|
this.dialogKey = Date.now();
|
|
}
|
|
}
|
|
}
|
|
};
|
|
</script>
|
|
|
|
<style>
|
|
.custom-param-dialog {
|
|
border-radius: 16px !important;
|
|
overflow: hidden;
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
|
|
border: none !important;
|
|
|
|
.el-dialog__header {
|
|
display: none;
|
|
}
|
|
|
|
.el-dialog__body {
|
|
padding: 0 !important;
|
|
border-radius: 16px;
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<style scoped lang="scss">
|
|
.param-dialog-wrapper {
|
|
.dialog-container {
|
|
padding: 24px 32px;
|
|
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
|
}
|
|
|
|
.dialog-header {
|
|
position: relative;
|
|
margin-bottom: 24px;
|
|
text-align: center;
|
|
}
|
|
|
|
.dialog-title {
|
|
font-size: 20px;
|
|
color: #1e293b;
|
|
margin: 0;
|
|
padding: 0;
|
|
font-weight: 600;
|
|
letter-spacing: 0.5px;
|
|
}
|
|
|
|
.custom-close-btn {
|
|
position: absolute;
|
|
top: -8px;
|
|
right: -8px;
|
|
width: 32px;
|
|
height: 32px;
|
|
border-radius: 50%;
|
|
border: none;
|
|
background: #f1f5f9;
|
|
color: #64748b;
|
|
cursor: pointer;
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
padding: 0;
|
|
outline: none;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
|
|
&:hover {
|
|
color: #ffffff;
|
|
background: #ef4444;
|
|
transform: rotate(90deg);
|
|
box-shadow: 0 4px 6px rgba(239, 68, 68, 0.2);
|
|
}
|
|
|
|
svg {
|
|
transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
}
|
|
}
|
|
|
|
.param-form {
|
|
.form-item {
|
|
margin-bottom: 20px;
|
|
|
|
:deep(.el-form-item__label) {
|
|
color: #475569;
|
|
font-weight: 500;
|
|
padding-right: 12px;
|
|
text-align: right;
|
|
font-size: 14px;
|
|
letter-spacing: 0.2px;
|
|
}
|
|
}
|
|
|
|
.custom-input {
|
|
:deep(.el-input__inner) {
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
border: 1px solid #e2e8f0;
|
|
height: 42px;
|
|
padding: 0 14px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
font-size: 14px;
|
|
color: #334155;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
|
|
&:focus {
|
|
border-color: #3b82f6;
|
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
&::placeholder {
|
|
color: #94a3b8;
|
|
font-weight: 400;
|
|
}
|
|
}
|
|
}
|
|
|
|
.custom-select {
|
|
width: 100%;
|
|
|
|
:deep(.el-input__inner) {
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
border: 1px solid #e2e8f0;
|
|
height: 42px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
font-size: 14px;
|
|
color: #334155;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
|
|
&:focus {
|
|
border-color: #3b82f6;
|
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
&::placeholder {
|
|
color: #94a3b8;
|
|
font-weight: 400;
|
|
}
|
|
}
|
|
}
|
|
|
|
.custom-textarea {
|
|
:deep(.el-textarea__inner) {
|
|
background-color: #ffffff;
|
|
border-radius: 8px;
|
|
border: 1px solid #e2e8f0;
|
|
padding: 12px 14px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
font-size: 14px;
|
|
color: #334155;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
line-height: 1.5;
|
|
|
|
&:focus {
|
|
border-color: #3b82f6;
|
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
|
background-color: #ffffff;
|
|
}
|
|
|
|
&::placeholder {
|
|
color: #94a3b8;
|
|
font-weight: 400;
|
|
}
|
|
}
|
|
}
|
|
|
|
.remark-item :deep(.el-form-item__label) {
|
|
margin-top: -4px;
|
|
}
|
|
}
|
|
|
|
.dialog-footer {
|
|
display: flex;
|
|
justify-content: center;
|
|
padding: 16px 0 0;
|
|
margin-top: 16px;
|
|
|
|
.save-btn {
|
|
width: 120px;
|
|
height: 42px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
border-radius: 8px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
background: #3b82f6;
|
|
color: white;
|
|
border: none;
|
|
letter-spacing: 0.5px;
|
|
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
|
|
|
&:hover {
|
|
background: #2563eb;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
|
|
}
|
|
|
|
&:active {
|
|
transform: translateY(0);
|
|
box-shadow: 0 2px 3px rgba(59, 130, 246, 0.2);
|
|
}
|
|
}
|
|
|
|
.cancel-btn {
|
|
width: 120px;
|
|
height: 42px;
|
|
font-size: 14px;
|
|
font-weight: 500;
|
|
border-radius: 8px;
|
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
|
background: #ffffff;
|
|
color: #64748b;
|
|
border: 1px solid #e2e8f0;
|
|
margin-left: 16px;
|
|
letter-spacing: 0.5px;
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
|
|
&:hover {
|
|
background: #f8fafc;
|
|
color: #475569;
|
|
border-color: #cbd5e1;
|
|
transform: translateY(-1px);
|
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
}
|
|
|
|
&:active {
|
|
transform: translateY(0);
|
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
</style>
|