修复菜单编辑

This commit is contained in:
李志强 2025-07-14 14:43:14 +08:00
parent 7cd7149091
commit 95b70b20b4
2 changed files with 41 additions and 4 deletions

View File

@ -317,7 +317,7 @@ function getUserCounts() {
fetch('{:url("users/counts")}') fetch('{:url("users/counts")}')
.then(response => response.json()) .then(response => response.json())
.then(res => { .then(res => {
console.log('用户统计接口返回数据:', res); // console.log('用户统计接口返回数据:', res);
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
// 更新用户总数 // 更新用户总数
document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = res.data.total.toLocaleString(); document.querySelector('.stat-card:nth-child(1) .stat-value').textContent = res.data.total.toLocaleString();
@ -353,7 +353,7 @@ function getArticleCounts() {
fetch('{:url("articles/counts")}') fetch('{:url("articles/counts")}')
.then(response => response.json()) .then(response => response.json())
.then(res => { .then(res => {
console.log('文章统计接口返回数据:', res); // console.log('文章统计接口返回数据:', res);
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
// 更新文章总数 // 更新文章总数
document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = res.data.total.toLocaleString(); document.querySelector('.stat-card:nth-child(3) .stat-value').textContent = res.data.total.toLocaleString();
@ -389,7 +389,7 @@ function getResourcesCounts() {
fetch('{:url("resources/counts")}') fetch('{:url("resources/counts")}')
.then(response => response.json()) .then(response => response.json())
.then(res => { .then(res => {
console.log('资源统计接口返回数据:', res); // console.log('资源统计接口返回数据:', res);
if (res.code === 0 && res.data) { if (res.code === 0 && res.data) {
// 更新资源总数 // 更新资源总数
document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = res.data.total.toLocaleString(); document.querySelector('.stat-card:nth-child(4) .stat-value').textContent = res.data.total.toLocaleString();

View File

@ -50,8 +50,10 @@
</div> </div>
</div> </div>
<script> <script>
layui.use(['jquery'], function () { layui.use(['form', 'jquery', 'layer'], function () {
var $ = layui.jquery; var $ = layui.jquery;
var form = layui.form;
var layer = layui.layer;
var $input = $('#icon_class_input'); var $input = $('#icon_class_input');
var $dropdown = $('#iconDropdown'); var $dropdown = $('#iconDropdown');
var $search = $('#iconSearchInput'); var $search = $('#iconSearchInput');
@ -101,6 +103,41 @@
} }
}); });
} }
//保存
window.save = function () {
var data = {};
// 获取表单数据
data.smid = $('input[name="smid"]').val();
data.label = $('input[name="label"]').val();
data.icon_class = $('input[name="icon_class"]').val();
data.sort = $('input[name="sort"]').val();
data.status = $('input[name="status"]:checked').val();
// 简单校验
if (!data.label) {
layer.msg('菜单名不能为空', { icon: 2 });
return;
}
$.post(
'{$config["admin_route"]}yunzer/menuedit',
data,
function (res) {
if (res.code == 0) {
layer.msg(res.msg, { icon: 1 });
// 1秒后关闭弹窗并刷新父页面
setTimeout(function () {
var index = parent.layer.getFrameIndex(window.name);
parent.layer.close(index);
parent.location.reload();
}, 1000);
} else {
layer.alert(res.msg, { icon: 2 });
}
},
'json'
);
}
}); });
</script> </script>
<style> <style>