mirror of
https://github.com/xinnan-tech/xiaozhi-esp32-server.git
synced 2026-07-27 09:33:55 +08:00
修复“删除”和“批量删除”功能,优化“新增/编辑”页面
This commit is contained in:
@@ -113,37 +113,22 @@ export default {
|
|||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
// 删除
|
// 删除
|
||||||
deleteParam(id, callback) {
|
deleteParam(ids, callback) {
|
||||||
|
console.log(4444,ids )
|
||||||
RequestService.sendRequest()
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/admin/params`)
|
.url(`${getServiceUrl()}/admin/params/delete`)
|
||||||
.method('DELETE')
|
.method('POST')
|
||||||
.data({ ids: [id] })
|
.data(ids)
|
||||||
.success((res) => {
|
.success((res) => {
|
||||||
RequestService.clearRequestTime()
|
RequestService.clearRequestTime()
|
||||||
callback(res)
|
callback(res);
|
||||||
})
|
})
|
||||||
.fail((err) => {
|
.fail((err) => {
|
||||||
console.error('删除参数失败:', err)
|
console.error('删除参数失败:', err)
|
||||||
RequestService.reAjaxFun(() => {
|
RequestService.reAjaxFun(() => {
|
||||||
this.deleteParam(id, callback)
|
this.deleteParam(ids, callback)
|
||||||
})
|
})
|
||||||
}).send()
|
}).send()
|
||||||
},
|
},
|
||||||
// 批量删除
|
|
||||||
batchDeleteParams(ids, callback) {
|
|
||||||
RequestService.sendRequest()
|
|
||||||
.url(`${getServiceUrl()}/admin/params`)
|
|
||||||
.method('DELETE')
|
|
||||||
.data({ ids })
|
|
||||||
.success((res) => {
|
|
||||||
RequestService.clearRequestTime()
|
|
||||||
callback(res)
|
|
||||||
})
|
|
||||||
.fail((err) => {
|
|
||||||
console.error('批量删除参数失败:', err)
|
|
||||||
RequestService.reAjaxFun(() => {
|
|
||||||
this.batchDeleteParams(ids, callback)
|
|
||||||
})
|
|
||||||
}).send()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,8 @@ export default {
|
|||||||
},
|
},
|
||||||
// 修改用户状态
|
// 修改用户状态
|
||||||
changeUserStatus(status, userIds, successCallback) {
|
changeUserStatus(status, userIds, successCallback) {
|
||||||
return RequestService.sendRequest()
|
console.log(555,userIds)
|
||||||
|
RequestService.sendRequest()
|
||||||
.url(`${getServiceUrl()}/admin/users/changeStatus/${status}`)
|
.url(`${getServiceUrl()}/admin/users/changeStatus/${status}`)
|
||||||
.method('put')
|
.method('put')
|
||||||
.data(userIds)
|
.data(userIds)
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<el-dialog :title="title"
|
<el-dialog :title="title"
|
||||||
:visible.sync="visible"
|
:visible.sync="visible"
|
||||||
width="500px"
|
width="520px"
|
||||||
class="param-dialog-wrapper"
|
class="param-dialog-wrapper"
|
||||||
:append-to-body="true"
|
:append-to-body="true"
|
||||||
:close-on-click-modal="false"
|
:close-on-click-modal="false"
|
||||||
@@ -12,10 +12,14 @@
|
|||||||
<div class="dialog-container">
|
<div class="dialog-container">
|
||||||
<div class="dialog-header">
|
<div class="dialog-header">
|
||||||
<h2 class="dialog-title">{{ title }}</h2>
|
<h2 class="dialog-title">{{ title }}</h2>
|
||||||
<button class="custom-close-btn" @click="cancel">×</button>
|
<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>
|
</div>
|
||||||
|
|
||||||
<el-form :model="form" :rules="rules" ref="form" label-width="100px" label-position="left" class="param-form">
|
<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-form-item label="参数编码" prop="paramCode" class="form-item">
|
||||||
<el-input v-model="form.paramCode" placeholder="请输入参数编码" class="custom-input"></el-input>
|
<el-input v-model="form.paramCode" placeholder="请输入参数编码" class="custom-input"></el-input>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
@@ -115,8 +119,10 @@ export default {
|
|||||||
|
|
||||||
<style>
|
<style>
|
||||||
.custom-param-dialog {
|
.custom-param-dialog {
|
||||||
border-radius: 20px !important;
|
border-radius: 16px !important;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
|
||||||
|
border: none !important;
|
||||||
|
|
||||||
.el-dialog__header {
|
.el-dialog__header {
|
||||||
display: none;
|
display: none;
|
||||||
@@ -124,7 +130,7 @@ export default {
|
|||||||
|
|
||||||
.el-dialog__body {
|
.el-dialog__body {
|
||||||
padding: 0 !important;
|
padding: 0 !important;
|
||||||
border-radius: 20px;
|
border-radius: 16px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
@@ -132,45 +138,53 @@ export default {
|
|||||||
<style scoped lang="scss">
|
<style scoped lang="scss">
|
||||||
.param-dialog-wrapper {
|
.param-dialog-wrapper {
|
||||||
.dialog-container {
|
.dialog-container {
|
||||||
padding: 20px 30px;
|
padding: 24px 32px;
|
||||||
|
background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-header {
|
.dialog-header {
|
||||||
position: relative;
|
position: relative;
|
||||||
margin-bottom: 20px;
|
margin-bottom: 24px;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
.dialog-title {
|
.dialog-title {
|
||||||
font-size: 24px;
|
font-size: 20px;
|
||||||
color: #3d4566;
|
color: #1e293b;
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
font-weight: normal;
|
font-weight: 600;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-close-btn {
|
.custom-close-btn {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 0;
|
top: -8px;
|
||||||
right: 0;
|
right: -8px;
|
||||||
width: 35px;
|
width: 32px;
|
||||||
height: 35px;
|
height: 32px;
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
border: 2px solid #cfcfcf;
|
border: none;
|
||||||
background: none;
|
background: #f1f5f9;
|
||||||
font-size: 24px;
|
color: #64748b;
|
||||||
color: #cfcfcf;
|
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
outline: none;
|
outline: none;
|
||||||
transition: all 0.2s ease;
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
|
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
color: #409EFF;
|
color: #ffffff;
|
||||||
border-color: #409EFF;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -179,30 +193,36 @@ export default {
|
|||||||
margin-bottom: 20px;
|
margin-bottom: 20px;
|
||||||
|
|
||||||
:deep(.el-form-item__label) {
|
:deep(.el-form-item__label) {
|
||||||
color: #3d4566;
|
color: #475569;
|
||||||
font-weight: normal;
|
font-weight: 500;
|
||||||
padding-right: 20px;
|
padding-right: 12px;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
|
font-size: 14px;
|
||||||
|
letter-spacing: 0.2px;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-input {
|
.custom-input {
|
||||||
:deep(.el-input__inner) {
|
:deep(.el-input__inner) {
|
||||||
background-color: #f6f8fc;
|
background-color: #ffffff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid #e0e3e9;
|
border: 1px solid #e2e8f0;
|
||||||
height: 40px;
|
height: 42px;
|
||||||
padding: 0 12px;
|
padding: 0 14px;
|
||||||
transition: all 0.3s;
|
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 {
|
&:focus {
|
||||||
border-color: #5b8cff;
|
border-color: #3b82f6;
|
||||||
box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.2);
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||||
background-color: #fff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: #9c9f9e;
|
color: #94a3b8;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -211,40 +231,49 @@ export default {
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
:deep(.el-input__inner) {
|
:deep(.el-input__inner) {
|
||||||
background-color: #f6f8fc;
|
background-color: #ffffff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid #e0e3e9;
|
border: 1px solid #e2e8f0;
|
||||||
height: 40px;
|
height: 42px;
|
||||||
transition: all 0.3s;
|
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 {
|
&:focus {
|
||||||
border-color: #5b8cff;
|
border-color: #3b82f6;
|
||||||
box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.2);
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||||
background-color: #fff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: #9c9f9e;
|
color: #94a3b8;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.custom-textarea {
|
.custom-textarea {
|
||||||
:deep(.el-textarea__inner) {
|
:deep(.el-textarea__inner) {
|
||||||
background-color: #f6f8fc;
|
background-color: #ffffff;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
border: 1px solid #e0e3e9;
|
border: 1px solid #e2e8f0;
|
||||||
padding: 12px;
|
padding: 12px 14px;
|
||||||
transition: all 0.3s;
|
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 {
|
&:focus {
|
||||||
border-color: #5b8cff;
|
border-color: #3b82f6;
|
||||||
box-shadow: 0 0 0 2px rgba(91, 140, 255, 0.2);
|
box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
|
||||||
background-color: #fff;
|
background-color: #ffffff;
|
||||||
}
|
}
|
||||||
|
|
||||||
&::placeholder {
|
&::placeholder {
|
||||||
color: #9c9f9e;
|
color: #94a3b8;
|
||||||
|
font-weight: 400;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -257,40 +286,59 @@ export default {
|
|||||||
.dialog-footer {
|
.dialog-footer {
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: center;
|
justify-content: center;
|
||||||
padding: 15px 0 0;
|
padding: 16px 0 0;
|
||||||
margin-top: 10px;
|
margin-top: 16px;
|
||||||
|
|
||||||
.save-btn {
|
.save-btn {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
height: 40px;
|
height: 42px;
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
background: #e6f0fd;
|
background: #3b82f6;
|
||||||
color: #237ff4;
|
color: white;
|
||||||
border: 1px solid #b3d1ff;
|
border: none;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
box-shadow: 0 2px 4px rgba(59, 130, 246, 0.2);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #237ff4;
|
background: #2563eb;
|
||||||
color: white;
|
transform: translateY(-1px);
|
||||||
border: none;
|
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 {
|
.cancel-btn {
|
||||||
width: 120px;
|
width: 120px;
|
||||||
height: 40px;
|
height: 42px;
|
||||||
font-size: 16px;
|
font-size: 14px;
|
||||||
|
font-weight: 500;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
transition: all 0.3s ease;
|
transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
|
||||||
background: #f6f8fc;
|
background: #ffffff;
|
||||||
color: #3d4566;
|
color: #64748b;
|
||||||
border: 1px solid #e0e3e9;
|
border: 1px solid #e2e8f0;
|
||||||
margin-left: 20px;
|
margin-left: 16px;
|
||||||
|
letter-spacing: 0.5px;
|
||||||
|
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
|
||||||
|
|
||||||
&:hover {
|
&:hover {
|
||||||
background: #e9e9e9;
|
background: #f8fafc;
|
||||||
border-color: #d9d9d9;
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,7 +35,7 @@
|
|||||||
@click="handleSelectAll">全选</el-button>
|
@click="handleSelectAll">全选</el-button>
|
||||||
<el-button size="mini" type="success" @click="showAddDialog">新增</el-button>
|
<el-button size="mini" type="success" @click="showAddDialog">新增</el-button>
|
||||||
<el-button size="mini" type="danger" icon="el-icon-delete"
|
<el-button size="mini" type="danger" icon="el-icon-delete"
|
||||||
@click="batchDelete">删除</el-button>
|
@click="deleteParam($refs.paramsTable.selection)">删除</el-button>
|
||||||
</div>
|
</div>
|
||||||
<div class="custom-pagination">
|
<div class="custom-pagination">
|
||||||
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
<button class="pagination-btn" :disabled="currentPage === 1" @click="goFirst">
|
||||||
@@ -173,43 +173,57 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
deleteParam(row) {
|
deleteParam(row) {
|
||||||
this.$confirm("确定要删除该参数吗?", "警告", {
|
// 处理单个参数或参数数组
|
||||||
confirmButtonText: "确定",
|
const params = Array.isArray(row) ? row : [row];
|
||||||
cancelButtonText: "取消",
|
|
||||||
type: "warning",
|
if (Array.isArray(row) && row.length === 0) {
|
||||||
})
|
|
||||||
.then(() => {
|
|
||||||
Api.admin.deleteParam(row.id, ({ data }) => {
|
|
||||||
if (data.code === 0) {
|
|
||||||
this.$message.success("删除成功");
|
|
||||||
this.fetchParams();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
})
|
|
||||||
.catch(() => { });
|
|
||||||
},
|
|
||||||
batchDelete() {
|
|
||||||
const selectedParams = this.$refs.paramsTable.selection;
|
|
||||||
if (selectedParams.length === 0) {
|
|
||||||
this.$message.warning("请先选择需要删除的参数");
|
this.$message.warning("请先选择需要删除的参数");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.$confirm(`确定要删除选中的${selectedParams.length}个参数吗?`, "警告", {
|
|
||||||
confirmButtonText: "确定",
|
const paramCount = params.length;
|
||||||
cancelButtonText: "取消",
|
this.$confirm(`确定要删除选中的${paramCount}个参数吗?`, '警告', {
|
||||||
type: "warning",
|
confirmButtonText: '确定',
|
||||||
})
|
cancelButtonText: '取消',
|
||||||
.then(() => {
|
type: 'warning',
|
||||||
const ids = selectedParams.map(item => item.id);
|
distinguishCancelAndClose: true
|
||||||
Api.admin.batchDeleteParams(ids, ({ data }) => {
|
}).then(() => {
|
||||||
if (data.code === 0) {
|
const ids = params.map(param => param.id);
|
||||||
this.$message.success("删除成功");
|
if (ids.some(id => isNaN(id))) {
|
||||||
this.fetchParams();
|
this.$message.error('存在无效的参数ID');
|
||||||
}
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Api.admin.deleteParam(ids, ({ data }) => {
|
||||||
|
if (data.code === 0) {
|
||||||
|
this.$message.success({
|
||||||
|
message: `成功删除${paramCount}个参数`,
|
||||||
|
showClose: true
|
||||||
|
});
|
||||||
|
this.fetchParams(); // 刷新参数列表
|
||||||
|
} else {
|
||||||
|
this.$message.error({
|
||||||
|
message: data.msg || '删除失败,请重试',
|
||||||
|
showClose: true
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch(action => {
|
||||||
|
if (action === 'cancel') {
|
||||||
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '已取消删除操作',
|
||||||
|
duration: 1000
|
||||||
});
|
});
|
||||||
})
|
} else {
|
||||||
.catch(() => { });
|
this.$message({
|
||||||
|
type: 'info',
|
||||||
|
message: '操作已关闭',
|
||||||
|
duration: 1000
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
},
|
},
|
||||||
headerCellClassName({ columnIndex }) {
|
headerCellClassName({ columnIndex }) {
|
||||||
if (columnIndex === 0) {
|
if (columnIndex === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user