|
|
@ -8,7 +8,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
<div class="container lw-main lw-banner"> |
|
|
|
<div class="container lw-main lw-banner"> |
|
|
|
<div class="btn-group" role="group" style="margin-bottom: 20px" aria-label="..."> |
|
|
|
<div class="btn-group" role="group" style="margin-bottom: 20px" aria-label="..."> |
|
|
|
<button type="button" class="btn btn-default"><i class="fa fa-plus"></i> 新增</button> |
|
|
|
<button type="button" id="create-category-btn" class="btn btn-default"><i class="fa fa-plus"></i> 新增</button> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
<table id="data-table"></table> |
|
|
|
<table id="data-table"></table> |
|
|
|
</div> |
|
|
|
</div> |
|
|
@ -17,6 +17,7 @@ |
|
|
|
<div class="modal-dialog" role="document"> |
|
|
|
<div class="modal-dialog" role="document"> |
|
|
|
<div class="modal-content"> |
|
|
|
<div class="modal-content"> |
|
|
|
<form id="data-form"> |
|
|
|
<form id="data-form"> |
|
|
|
|
|
|
|
<input type="hidden" name="id"> |
|
|
|
<div class="modal-header"> |
|
|
|
<div class="modal-header"> |
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span |
|
|
|
<button type="button" class="close" data-dismiss="modal" aria-label="Close"><span |
|
|
|
aria-hidden="true">×</span></button> |
|
|
|
aria-hidden="true">×</span></button> |
|
|
@ -26,7 +27,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<div class="form-group"> |
|
|
|
<label>标题</label> |
|
|
|
<label>标题</label> |
|
|
|
<input type="text" name="name" class="form-control" placeholder="请输入标题..."> |
|
|
|
<input type="text" name="name" class="form-control" required placeholder="请输入标题..."> |
|
|
|
</div> |
|
|
|
</div> |
|
|
|
|
|
|
|
|
|
|
|
<div class="form-group"> |
|
|
|
<div class="form-group"> |
|
|
@ -46,8 +47,7 @@ |
|
|
|
<th:block th:include="admin/common::footer"></th:block> |
|
|
|
<th:block th:include="admin/common::footer"></th:block> |
|
|
|
<script> |
|
|
|
<script> |
|
|
|
$(function () { |
|
|
|
$(function () { |
|
|
|
// $("#save-window").modal("show") |
|
|
|
// 显示表单所有分类数据 |
|
|
|
|
|
|
|
|
|
|
|
$('#data-table').bootstrapTable({ |
|
|
|
$('#data-table').bootstrapTable({ |
|
|
|
url: "/admin/category/", |
|
|
|
url: "/admin/category/", |
|
|
|
columns: [ |
|
|
|
columns: [ |
|
|
@ -84,7 +84,7 @@ |
|
|
|
return res.data |
|
|
|
return res.data |
|
|
|
} |
|
|
|
} |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
// 编辑对应分类 |
|
|
|
$("#data-table").on("click",".category-edit-btn",function () { |
|
|
|
$("#data-table").on("click",".category-edit-btn",function () { |
|
|
|
let id = $(this).data("id") |
|
|
|
let id = $(this).data("id") |
|
|
|
$.ajax({ |
|
|
|
$.ajax({ |
|
|
@ -103,12 +103,64 @@ |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
console.log(id); |
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增分类 |
|
|
|
|
|
|
|
$("#create-category-btn").on("click", function () { |
|
|
|
|
|
|
|
$("#window-title").text('新增分类') |
|
|
|
|
|
|
|
// 清空之前表单的数据 |
|
|
|
|
|
|
|
$("#data-form").initForm({id: "",name:"",summary: ""}) |
|
|
|
|
|
|
|
$('#save-window').modal('show') |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 删除分类 |
|
|
|
$("#data-table").on("click",".category-delete-btn",function () { |
|
|
|
$("#data-table").on("click",".category-delete-btn",function () { |
|
|
|
let id = $(this).data("id") |
|
|
|
let id = $(this).data('id') |
|
|
|
console.log(id); |
|
|
|
let idx = layer.confirm('是否要删除该数据?', { |
|
|
|
|
|
|
|
btn: ['确认', '取消'] //按钮 |
|
|
|
|
|
|
|
}, function () { // 点击确认后删除 |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
url: '/admin/category/' + id, |
|
|
|
|
|
|
|
method: 'delete', |
|
|
|
|
|
|
|
dataType: 'json', |
|
|
|
|
|
|
|
success: res => { |
|
|
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
|
|
layer.msg("删除成功", {icon: 1, time: 700}) |
|
|
|
|
|
|
|
$('#data-table').bootstrapTable('refresh', {silent: true}) |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
layer.msg(res.message, {icon: 2}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
layer.close(idx); // 关闭提示框 |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 更新分类数据 |
|
|
|
|
|
|
|
$("#data-form").on("submit",function () { |
|
|
|
|
|
|
|
let data = $(this).serialize(); |
|
|
|
|
|
|
|
$.ajax({ |
|
|
|
|
|
|
|
url:"/admin/category/", |
|
|
|
|
|
|
|
method: "POST", |
|
|
|
|
|
|
|
data: data, |
|
|
|
|
|
|
|
dataType: "json", |
|
|
|
|
|
|
|
success: res => { |
|
|
|
|
|
|
|
if (res.code === 200) { |
|
|
|
|
|
|
|
// 显示成功信息 |
|
|
|
|
|
|
|
layer.msg("保存成功", {icon: 1, time: 600}, function () { |
|
|
|
|
|
|
|
// 关闭模态框 |
|
|
|
|
|
|
|
$('#save-window').modal('hide') |
|
|
|
|
|
|
|
// 重载表格数据 |
|
|
|
|
|
|
|
$('#data-table').bootstrapTable('refresh',{silent: true}) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else { |
|
|
|
|
|
|
|
layer.msg(res.message, {icon: 2}) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
return false; // 阻止表单的提交行为 |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
}) |
|
|
|
}) |
|
|
|