Files
xiaozhi-esp32-server/main/manager-web/src/components/AddWisdomBodyDialog.vue
T

113 lines
2.8 KiB
Vue
Raw Normal View History

2025-03-18 21:49:57 +08:00
<template>
2025-05-08 17:57:11 +08:00
<el-dialog :visible="visible" @close="handleClose" width="25%" center @open="handleOpen">
2025-04-05 21:03:46 +08:00
<div
style="margin: 0 10px 10px;display: flex;align-items: center;gap: 10px;font-weight: 700;font-size: 20px;text-align: left;color: #3d4566;">
<div
style="width: 40px;height: 40px;border-radius: 50%;background: #5778ff;display: flex;align-items: center;justify-content: center;">
<img loading="lazy" src="@/assets/home/equipment.png" alt="" style="width: 18px;height: 15px;" />
2025-03-18 21:49:57 +08:00
</div>
2025-04-02 10:16:12 +08:00
添加智能体
2025-03-18 21:49:57 +08:00
</div>
<div style="height: 1px;background: #e8f0ff;" />
<div style="margin: 22px 15px;">
2025-05-08 17:57:11 +08:00
<div style="font-weight: 400;text-align: left;color: #3d4566;">
<div style="color: red;display: inline-block;">*</div> 智能体名称
2025-03-18 21:49:57 +08:00
</div>
<div class="input-46" style="margin-top: 12px;">
2025-04-05 21:03:46 +08:00
<el-input ref="inputRef" placeholder="请输入智能体名称.." v-model="wisdomBodyName" @keyup.enter.native="confirm" />
2025-03-18 21:49:57 +08:00
</div>
</div>
<div style="display: flex;margin: 15px 15px;gap: 7px;">
<div class="dialog-btn" @click="confirm">
确定
</div>
2025-04-05 21:03:46 +08:00
<div class="dialog-btn" style="background: #e6ebff;border: 1px solid #adbdff;color: #5778ff;" @click="cancel">
2025-03-18 21:49:57 +08:00
取消
</div>
</div>
</el-dialog>
</template>
<script>
2025-04-05 21:03:46 +08:00
import Api from '@/apis/api';
2025-03-19 18:13:03 +08:00
2025-03-18 21:49:57 +08:00
export default {
name: 'AddWisdomBodyDialog',
props: {
visible: { type: Boolean, required: true }
},
data() {
return {
wisdomBodyName: "",
inputRef: null
}
2025-03-18 21:49:57 +08:00
},
methods: {
handleOpen() {
this.$nextTick(() => {
this.$refs.inputRef.focus();
});
},
2025-03-18 21:49:57 +08:00
confirm() {
2025-03-19 18:13:03 +08:00
if (!this.wisdomBodyName.trim()) {
2025-04-02 10:16:12 +08:00
this.$message.error('请输入智能体名称');
2025-03-19 18:13:03 +08:00
return;
}
2025-04-05 21:03:46 +08:00
Api.agent.addAgent(this.wisdomBodyName, (res) => {
this.$message.success({
2025-04-05 21:03:46 +08:00
message: '添加成功',
showClose: true
});
2025-03-19 18:13:03 +08:00
this.$emit('confirm', res);
this.$emit('update:visible', false);
this.wisdomBodyName = "";
});
2025-03-18 21:49:57 +08:00
},
cancel() {
this.$emit('update:visible', false)
this.wisdomBodyName = ""
2025-04-16 11:34:30 +08:00
},
handleClose() {
this.$emit('update:visible', false);
},
2025-03-18 21:49:57 +08:00
}
}
</script>
<style scoped>
.input-46 {
border: 1px solid #e4e6ef;
background: #f6f8fb;
border-radius: 15px;
}
.dialog-btn {
cursor: pointer;
flex: 1;
border-radius: 23px;
background: #5778ff;
height: 40px;
font-weight: 500;
font-size: 12px;
color: #fff;
line-height: 40px;
text-align: center;
}
2025-04-05 21:03:46 +08:00
2025-03-18 21:49:57 +08:00
::v-deep .el-dialog {
border-radius: 15px;
box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}
2025-04-05 21:03:46 +08:00
2025-03-18 21:49:57 +08:00
::v-deep .el-dialog__headerbtn {
display: none;
}
2025-04-05 21:03:46 +08:00
2025-03-18 21:49:57 +08:00
::v-deep .el-dialog__body {
padding: 4px 6px;
}
2025-04-05 21:03:46 +08:00
::v-deep .el-dialog__header {
2025-03-18 21:49:57 +08:00
padding: 10px;
}
</style>