mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-26 00:53:54 +08:00
优化了界面样式
This commit is contained in:
@@ -11,73 +11,86 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<el-main style="padding: 20px; display: flex; flex-direction: column;">
|
<div class="main-wrapper">
|
||||||
<div class="table-container">
|
<div class="content-panel">
|
||||||
<el-table ref="deviceTable" :data="paginatedDeviceList" @selection-change="handleSelectionChange" style="width: 100%; margin-top: 20px" border stripe>
|
<div class="content-area">
|
||||||
<el-table-column type="selection" align="center" width="60"></el-table-column>
|
<el-card class="params-card" shadow="never">
|
||||||
<el-table-column label="设备型号" prop="model" flex></el-table-column>
|
<el-table
|
||||||
<el-table-column label="固件版本" prop="firmwareVersion" width="120"></el-table-column>
|
ref="deviceTable"
|
||||||
<el-table-column label="Mac地址" prop="macAddress"></el-table-column>
|
:data="paginatedDeviceList"
|
||||||
<el-table-column label="绑定时间" prop="bindTime" width="200"></el-table-column>
|
@selection-change="handleSelectionChange"
|
||||||
<el-table-column label="最近对话" prop="lastConversation" width="140"></el-table-column>
|
class="transparent-table"
|
||||||
<el-table-column label="备注" width="180">
|
:header-cell-class-name="headerCellClassName"
|
||||||
<template slot-scope="scope">
|
border
|
||||||
<el-input v-if="scope.row.isEdit" v-model="scope.row.remark" size="mini"
|
stripe>
|
||||||
@blur="stopEditRemark(scope.$index)"></el-input>
|
<el-table-column type="selection" align="center" width="120"></el-table-column>
|
||||||
<span v-else>
|
<el-table-column label="设备型号" prop="model" align="center"></el-table-column>
|
||||||
<i v-if="!scope.row.remark" class="el-icon-edit" @click="startEditRemark(scope.$index, scope.row)"></i>
|
<el-table-column label="固件版本" prop="firmwareVersion" align="center" width="120"></el-table-column>
|
||||||
<span v-else @click="startEditRemark(scope.$index, scope.row)">
|
<el-table-column label="Mac地址" prop="macAddress" align="center"></el-table-column>
|
||||||
{{ scope.row.remark }}
|
<el-table-column label="绑定时间" prop="bindTime" align="center" width="200"></el-table-column>
|
||||||
</span>
|
<el-table-column label="最近对话" prop="lastConversation" align="center" width="140"></el-table-column>
|
||||||
</span>
|
<el-table-column label="备注" align="center" width="180">
|
||||||
</template>
|
<template slot-scope="scope">
|
||||||
</el-table-column>
|
<el-input v-if="scope.row.isEdit" v-model="scope.row.remark" size="mini"
|
||||||
<el-table-column label="OTA升级" width="120">
|
@blur="stopEditRemark(scope.$index)"></el-input>
|
||||||
<template slot-scope="scope">
|
<span v-else>
|
||||||
<el-switch v-model="scope.row.otaSwitch" size="mini" active-color="#13ce66"
|
<i v-if="!scope.row.remark" class="el-icon-edit" @click="startEditRemark(scope.$index, scope.row)"></i>
|
||||||
inactive-color="#ff4949"></el-switch>
|
<span v-else @click="startEditRemark(scope.$index, scope.row)">
|
||||||
</template>
|
{{ scope.row.remark }}
|
||||||
</el-table-column>
|
</span>
|
||||||
<el-table-column label="操作" width="80">
|
</span>
|
||||||
<template slot-scope="scope">
|
</template>
|
||||||
<el-button size="mini" type="text" @click="handleUnbind(scope.row.device_id)" style="color: #ff4949">
|
</el-table-column>
|
||||||
解绑
|
<el-table-column label="OTA升级" align="center" width="120">
|
||||||
</el-button>
|
<template slot-scope="scope">
|
||||||
</template>
|
<el-switch v-model="scope.row.otaSwitch" size="mini" active-color="#13ce66"
|
||||||
</el-table-column>
|
inactive-color="#ff4949"></el-switch>
|
||||||
</el-table>
|
</template>
|
||||||
<div class="table_bottom">
|
</el-table-column>
|
||||||
<div class="ctrl_btn">
|
<el-table-column label="操作" align="center" width="80">
|
||||||
<el-button size="mini" type="primary" class="select-all-btn" @click="toggleAllSelection">
|
<template slot-scope="scope">
|
||||||
{{ isAllSelected ? '取消全选' : '全选' }}
|
<el-button size="mini" type="text" @click="handleUnbind(scope.row.device_id)" style="color: #ff4949">
|
||||||
</el-button>
|
解绑
|
||||||
<el-button type="primary" size="mini" class="add-device-btn" @click="handleAddDevice">
|
</el-button>
|
||||||
新增
|
</template>
|
||||||
</el-button>
|
</el-table-column>
|
||||||
</div>
|
</el-table>
|
||||||
<div class="custom-pagination">
|
|
||||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">首页</button>
|
<div class="table_bottom">
|
||||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">上一页</button>
|
<div class="ctrl_btn">
|
||||||
<button
|
<el-button size="mini" type="primary" class="select-all-btn" @click="toggleAllSelection">
|
||||||
v-for="page in visiblePages"
|
{{ isAllSelected ? '取消全选' : '全选' }}
|
||||||
:key="page"
|
</el-button>
|
||||||
class="pagination-btn"
|
<el-button type="success" size="mini" class="add-device-btn" @click="handleAddDevice">
|
||||||
:class="{ active: page === currentPage }"
|
新增
|
||||||
@click="goToPage(page)"
|
</el-button>
|
||||||
>
|
<el-button size="mini" type="danger" icon="el-icon-delete"
|
||||||
{{ page }}
|
@click="deleteSelected">删除</el-button>
|
||||||
</button>
|
</div>
|
||||||
<button class="pagination-btn" :disabled="currentPage === pageCount" @click="goNext">下一页</button>
|
<div class="custom-pagination">
|
||||||
<span class="total-text">共{{ deviceList.length }}条记录</span>
|
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">首页</button>
|
||||||
</div>
|
<button class="pagination-btn" :disabled="currentPage === 1" @click="goPrev">上一页</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">下一页</button>
|
||||||
|
<span class="total-text">共{{ deviceList.length }}条记录</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="copyright">
|
</div>
|
||||||
©2025 xiaozhi-esp32-server
|
|
||||||
</div>
|
<div class="copyright">©2025 xiaozhi-esp32-server</div>
|
||||||
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" :agent-id="currentAgentId"
|
<AddDeviceDialog :visible.sync="addDeviceDialogVisible" :agent-id="currentAgentId"
|
||||||
@refresh="fetchBindDevices(currentAgentId)" />
|
@refresh="fetchBindDevices(currentAgentId)" />
|
||||||
</el-main>
|
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
@@ -156,6 +169,28 @@ export default {
|
|||||||
this.$refs.deviceTable.toggleAllSelection();
|
this.$refs.deviceTable.toggleAllSelection();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteSelected() {
|
||||||
|
if (this.selectedDevices.length === 0) {
|
||||||
|
this.$message.warning("请先选择需要删除的设备");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.$confirm(`确定要删除选中的${this.selectedDevices.length}个设备吗?`, '警告', {
|
||||||
|
confirmButtonText: '确定',
|
||||||
|
cancelButtonText: '取消',
|
||||||
|
type: 'warning'
|
||||||
|
}).then(() => {
|
||||||
|
const ids = this.selectedDevices.map(device => device.device_id);
|
||||||
|
Api.device.batchDeleteDevices(ids, ({ data }) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.$message.success(`成功删除${this.selectedDevices.length}个设备`);
|
||||||
|
this.fetchBindDevices(this.currentAgentId);
|
||||||
|
} else {
|
||||||
|
this.$message.error(data.msg || '删除失败');
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
handleAddDevice() {
|
handleAddDevice() {
|
||||||
this.addDeviceDialogVisible = true;
|
this.addDeviceDialogVisible = true;
|
||||||
@@ -214,25 +249,28 @@ export default {
|
|||||||
model: device.board,
|
model: device.board,
|
||||||
firmwareVersion: device.appVersion,
|
firmwareVersion: device.appVersion,
|
||||||
macAddress: device.macAddress,
|
macAddress: device.macAddress,
|
||||||
bindTime: formattedBindTime, // 使用格式化后的时间
|
bindTime: formattedBindTime,
|
||||||
lastConversation: device.lastConnectedAt,
|
lastConversation: device.lastConnectedAt,
|
||||||
remark: device.alias,
|
remark: device.alias,
|
||||||
isEdit: false,
|
isEdit: false,
|
||||||
otaSwitch: device.autoUpdate === 1,
|
otaSwitch: device.autoUpdate === 1,
|
||||||
// 添加原始时间用于排序
|
|
||||||
rawBindTime: new Date(device.createDate).getTime()
|
rawBindTime: new Date(device.createDate).getTime()
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
// 按照绑定时间降序排序
|
|
||||||
.sort((a, b) => a.rawBindTime - b.rawBindTime);
|
.sort((a, b) => a.rawBindTime - b.rawBindTime);
|
||||||
} else {
|
} else {
|
||||||
this.$message.error(data.msg || '获取设备列表失败');
|
this.$message.error(data.msg || '获取设备列表失败');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
headerCellClassName({ columnIndex }) {
|
||||||
|
if (columnIndex === 0) {
|
||||||
|
return "custom-selection-header";
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style scoped>
|
<style scoped>
|
||||||
@@ -241,6 +279,7 @@ export default {
|
|||||||
min-height: 506px;
|
min-height: 506px;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
position: relative;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd);
|
background: linear-gradient(to bottom right, #dce8ff, #e4eeff, #e6cbfd);
|
||||||
background-size: cover;
|
background-size: cover;
|
||||||
@@ -248,35 +287,111 @@ export default {
|
|||||||
-o-background-size: cover;
|
-o-background-size: cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table-container {
|
.main-wrapper {
|
||||||
background: #f9fafc;
|
margin: 5px 22px;
|
||||||
padding: 20px;
|
border-radius: 15px;
|
||||||
border-radius: 20px;
|
min-height: 600px;
|
||||||
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
box-shadow: 0 2px 12px rgba(0, 0, 0, 0.1);
|
||||||
margin-top: 15px;
|
position: relative;
|
||||||
|
background: rgba(237, 242, 255, 0.5);
|
||||||
}
|
}
|
||||||
|
|
||||||
.add-device-btn {
|
.operation-bar {
|
||||||
background: linear-gradient(135deg, #6b8cff, #a966ff) !important;
|
display: flex;
|
||||||
border: none !important;
|
justify-content: space-between;
|
||||||
color: white !important;
|
align-items: center;
|
||||||
margin-left: 10px;
|
padding: 16px 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.page-title {
|
||||||
|
font-size: 24px;
|
||||||
|
margin: 0;
|
||||||
|
color: #2c3e50;
|
||||||
|
}
|
||||||
|
|
||||||
|
.right-operations {
|
||||||
|
display: flex;
|
||||||
|
gap: 10px;
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.search-input {
|
||||||
|
width: 280px;
|
||||||
|
border-radius: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-search {
|
||||||
|
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
||||||
|
border: none;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-panel {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
height: 100%;
|
||||||
|
border-radius: 15px;
|
||||||
|
background: transparent;
|
||||||
|
border: 1px solid #fff;
|
||||||
|
}
|
||||||
|
|
||||||
|
.content-area {
|
||||||
|
flex: 1;
|
||||||
|
height: 100%;
|
||||||
|
min-width: 600px;
|
||||||
|
overflow-x: auto;
|
||||||
|
background-color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.params-card {
|
||||||
|
background: white;
|
||||||
|
border: none;
|
||||||
|
box-shadow: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table_bottom {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
margin-top: 20px;
|
||||||
|
padding: 0 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctrl_btn {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
padding-left: 26px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctrl_btn .el-button {
|
||||||
|
min-width: 72px;
|
||||||
height: 32px;
|
height: 32px;
|
||||||
padding: 7px 12px;
|
padding: 7px 12px;
|
||||||
border-radius: 4px !important;
|
border-radius: 4px;
|
||||||
|
border: none;
|
||||||
|
transition: all 0.3s;
|
||||||
box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
|
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-icon-edit {
|
.ctrl_btn .el-button:hover {
|
||||||
color: #409eff;
|
transform: translateY(-1px);
|
||||||
cursor: pointer;
|
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
|
||||||
font-size: 14px;
|
}
|
||||||
vertical-align: middle;
|
|
||||||
|
.ctrl_btn .el-button--primary {
|
||||||
|
background: #5f70f3;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctrl_btn .el-button--success {
|
||||||
|
background: #5bc98c;
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
|
||||||
|
.ctrl_btn .el-button--danger {
|
||||||
|
background: #fd5b63;
|
||||||
|
color: white;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-pagination {
|
.custom-pagination {
|
||||||
@@ -326,78 +441,53 @@ export default {
|
|||||||
margin-left: 10px;
|
margin-left: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.table_bottom {
|
.copyright {
|
||||||
display: flex;
|
text-align: center;
|
||||||
justify-content: space-between;
|
color: #979db1;
|
||||||
align-items: center;
|
font-size: 12px;
|
||||||
margin-top: 20px;
|
font-weight: 400;
|
||||||
|
margin-top: auto;
|
||||||
|
padding: 30px 0 20px;
|
||||||
|
position: absolute;
|
||||||
|
bottom: 0;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%);
|
||||||
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.ctrl_btn {
|
/* 表格样式覆盖 */
|
||||||
display: flex;
|
:deep(.transparent-table) {
|
||||||
gap: 8px;
|
background: white;
|
||||||
padding-left: 26px;
|
|
||||||
|
|
||||||
.el-button {
|
|
||||||
min-width: 72px;
|
|
||||||
height: 32px;
|
|
||||||
padding: 7px 12px;
|
|
||||||
border-radius: 4px;
|
|
||||||
border: none;
|
|
||||||
transition: all 0.3s;
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.transparent-table .el-table__header th) {
|
||||||
.operation-bar {
|
background: white !important;
|
||||||
display: flex;
|
color: black;
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
padding: 16px 24px;
|
|
||||||
margin-top: 15px;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.page-title {
|
:deep(.transparent-table .el-table__body tr td) {
|
||||||
font-size: 24px;
|
border-top: 1px solid rgba(0, 0, 0, 0.04);
|
||||||
margin: 0;
|
border-bottom: 1px solid rgba(0, 0, 0, 0.04);
|
||||||
color: #2c3e50;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.right-operations {
|
:deep(.el-icon-edit) {
|
||||||
display: flex;
|
color: #7079aa;
|
||||||
gap: 10px;
|
cursor: pointer;
|
||||||
margin-left: auto;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.search-input {
|
:deep(.el-icon-edit:hover) {
|
||||||
width: 280px;
|
color: #5a64b5;
|
||||||
border-radius: 4px;
|
|
||||||
transition: all 0.3s;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.btn-search {
|
:deep(.custom-selection-header .el-checkbox) {
|
||||||
background: linear-gradient(135deg, #6b8cff, #a966ff);
|
display: none !important;
|
||||||
border: none;
|
|
||||||
color: white;
|
|
||||||
transition: all 0.3s;
|
|
||||||
|
|
||||||
&:hover {
|
|
||||||
opacity: 0.9;
|
|
||||||
transform: translateY(-1px);
|
|
||||||
box-shadow: 0 2px 6px rgba(107, 140, 255, 0.4);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:deep(.custom-selection-header::after) {
|
||||||
|
content: "选择";
|
||||||
|
display: inline-block;
|
||||||
|
color: black;
|
||||||
|
font-weight: bold;
|
||||||
|
padding-bottom: 18px;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|||||||
Reference in New Issue
Block a user