pycharm下格式化模板文件,统一风格

This commit is contained in:
zhengxinonly
2021-06-13 12:45:11 +08:00
parent d9a5bcb0de
commit 5faf88283f
39 changed files with 2829 additions and 2712 deletions
+201 -197
View File
@@ -37,223 +37,227 @@
<script type="text/html" id="role-toolbar">
{% if authorize("admin:role:add") %}
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
<i class="layui-icon layui-icon-add-1"></i>
新增
</button>
{% endif %}
{% if authorize("admin:role:remove") %}
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
<i class="layui-icon layui-icon-delete"></i>
删除
</button>
{% endif %}
</script>
<script type="text/html" id="role-bar">
{% if authorize("admin:role:edit") %}
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>
</button>
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
class="layui-icon layui-icon-edit"></i>
</button>
{% endif %}
{% if authorize("admin:role:power") %}
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="power"><i class="layui-icon layui-icon-vercode"></i>
</button>
<button class="pear-btn pear-btn-warming pear-btn-sm" lay-event="power"><i
class="layui-icon layui-icon-vercode"></i>
</button>
{% endif %}
{% if authorize("admin:role:remove") %}
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i class="layui-icon layui-icon-delete"></i>
</button>
{% endif %}
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
class="layui-icon layui-icon-delete"></i>
</button>
{% endif %}
</script>
<script type="text/html" id="role-enable">
<input type="checkbox" name="enable" value="{{ "{{d.id}}" }}" lay-skin="switch" lay-text="启用|禁用" lay-filter="role-enable" {{"{{# if(d.enable==1){ }} checked {{# } }}"}}>
<input type="checkbox" name="enable" value="{{ "{{d.id}}" }}" lay-skin="switch" lay-text="启用|禁用"
lay-filter="role-enable" {{ "{{# if(d.enable==1){ }} checked {{# } }}" }}>
</script>
{% include 'admin/common/footer.html' %}
<script>
layui.use(['table', 'form', 'jquery','popup','common'], function () {
let table = layui.table;
let form = layui.form;
let $ = layui.jquery;
let popup = layui.popup;
layui.use(['table', 'form', 'jquery', 'popup', 'common'], function () {
let table = layui.table
let form = layui.form
let $ = layui.jquery
let popup = layui.popup
let MODULE_PATH = "/admin/role/";
let MODULE_PATH = '/admin/role/'
let cols = [
[
{% if authorize("admin:role:remove") %}
{type: 'checkbox'},
{% endif %}
{title: '角色名', field: 'roleName', align: 'center', width: 100},
{title: 'Key值', field: 'roleCode', align: 'center'},
{title: '描述', field: 'details', align: 'center'},
{title: '是否可用', field: 'enable', align: 'center', templet: '#role-enable'},
{title: '排序', field: 'sort', align: 'center'},
{title: '操作', toolbar: '#role-bar', align: 'center', width: 195}
]
]
let cols = [
[
{% if authorize("admin:role:remove") %}
{ type: 'checkbox' },
{% endif %}
{ title: '角色名', field: 'roleName', align: 'center', width: 100 },
{ title: 'Key值', field: 'roleCode', align: 'center' },
{ title: '描述', field: 'details', align: 'center' },
{ title: '是否可用', field: 'enable', align: 'center', templet: '#role-enable' },
{ title: '排序', field: 'sort', align: 'center' },
{ title: '操作', toolbar: '#role-bar', align: 'center', width: 195 }
]
]
table.render({
elem: '#role-table',
url: MODULE_PATH + 'data',
page: true,
cols: cols,
skin: 'line',
toolbar: '#role-toolbar',
defaultToolbar: [{
layEvent: 'refresh',
icon: 'layui-icon-refresh',
}, 'filter', 'print', 'exports']
});
table.on('tool(role-table)', function (obj) {
if (obj.event === 'remove') {
window.remove(obj);
} else if (obj.event === 'edit') {
window.edit(obj);
} else if (obj.event === 'power') {
window.power(obj);
}
});
table.on('toolbar(role-table)', function (obj) {
if (obj.event === 'add') {
window.add();
} else if (obj.event === 'refresh') {
window.refresh();
} else if (obj.event === 'batchRemove') {
window.batchRemove(obj);
}
});
form.on('submit(role-query)', function (data) {
table.reload('role-table', {where: data.field})
return false;
});
form.on('switch(role-enable)', function (obj) {
let operate;
if (obj.elem.checked) {
operate = "enable";
} else {
operate = "disable";
}
let loading = layer.load()
$.ajax({
url: '/admin/role/' + operate,
data: JSON.stringify({roleId: this.value}),
dataType: 'json',
contentType: 'application/json',
type: 'put',
success: function (result) {
layer.close(loading);
if (result.success) {
layer.msg(result.msg, {icon: 1, time: 1000});
} else {
layer.msg(result.msg, {icon: 2, time: 1000});
}
}
})
});
window.add = function () {
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: ['500px', '500px'],
content: MODULE_PATH + 'add'
});
}
window.power = function (obj) {
layer.open({
type: 2,
title: '授权',
shade: 0.1,
area: ['320px', '400px'],
content: MODULE_PATH + 'power/' + obj.data["id"]
});
}
window.edit = function (obj) {
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['500px', '500px'],
content: MODULE_PATH + 'edit/' + obj.data['id']
});
}
window.remove = function (obj) {
layer.confirm('确定要删除该角色', {icon: 3, title: '提示'}, function (index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: MODULE_PATH + "remove/" + obj.data['id'],
dataType: 'json',
type: 'delete',
success: function (result) {
layer.close(loading);
if (result.success) {
layer.msg(result.msg, {icon: 1, time: 1000}, function () {
obj.del();
});
} else {
layer.msg(result.msg, {icon: 2, time: 1000});
}
}
})
});
}
window.batchRemove = function(obj) {
let data = table.checkStatus(obj.config.id).data;
if (data.length === 0) {
layer.msg("未选中数据", {
icon: 3,
time: 1000
});
return false;
}
var ids = []
var hasCheck = table.checkStatus('role-table')
var hasCheckData = hasCheck.data
if (hasCheckData.length > 0) {
$.each(hasCheckData, function (index, element) {
ids.push(element.id)
})
}
console.log(ids)
layer.confirm('确定要删除选中角色', {
icon: 3,
title: '提示'
}, function(index) {
layer.close(index);
let loading = layer.load();
$.ajax({
url: MODULE_PATH + "batchRemove",
data: {ids:ids},
dataType: 'json',
type: 'delete',
success: function (result) {
layer.close(loading);
if (result.success) {
popup.success(result.msg, function () {
table.reload('role-table');
});
} else {
popup.failure(result.msg);
}
}
})
});
}
window.refresh = function () {
table.reload('role-table');
}
table.render({
elem: '#role-table',
url: MODULE_PATH + 'data',
page: true,
cols: cols,
skin: 'line',
toolbar: '#role-toolbar',
defaultToolbar: [{
layEvent: 'refresh',
icon: 'layui-icon-refresh',
}, 'filter', 'print', 'exports']
})
table.on('tool(role-table)', function (obj) {
if (obj.event === 'remove') {
window.remove(obj)
} else if (obj.event === 'edit') {
window.edit(obj)
} else if (obj.event === 'power') {
window.power(obj)
}
})
table.on('toolbar(role-table)', function (obj) {
if (obj.event === 'add') {
window.add()
} else if (obj.event === 'refresh') {
window.refresh()
} else if (obj.event === 'batchRemove') {
window.batchRemove(obj)
}
})
form.on('submit(role-query)', function (data) {
table.reload('role-table', { where: data.field })
return false
})
form.on('switch(role-enable)', function (obj) {
let operate
if (obj.elem.checked) {
operate = 'enable'
} else {
operate = 'disable'
}
let loading = layer.load()
$.ajax({
url: '/admin/role/' + operate,
data: JSON.stringify({ roleId: this.value }),
dataType: 'json',
contentType: 'application/json',
type: 'put',
success: function (result) {
layer.close(loading)
if (result.success) {
layer.msg(result.msg, { icon: 1, time: 1000 })
} else {
layer.msg(result.msg, { icon: 2, time: 1000 })
}
}
})
})
window.add = function () {
layer.open({
type: 2,
title: '新增',
shade: 0.1,
area: ['500px', '500px'],
content: MODULE_PATH + 'add'
})
}
window.power = function (obj) {
layer.open({
type: 2,
title: '授权',
shade: 0.1,
area: ['320px', '400px'],
content: MODULE_PATH + 'power/' + obj.data['id']
})
}
window.edit = function (obj) {
layer.open({
type: 2,
title: '修改',
shade: 0.1,
area: ['500px', '500px'],
content: MODULE_PATH + 'edit/' + obj.data['id']
})
}
window.remove = function (obj) {
layer.confirm('确定要删除该角色', { icon: 3, title: '提示' }, function (index) {
layer.close(index)
let loading = layer.load()
$.ajax({
url: MODULE_PATH + 'remove/' + obj.data['id'],
dataType: 'json',
type: 'delete',
success: function (result) {
layer.close(loading)
if (result.success) {
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
obj.del()
})
} else {
layer.msg(result.msg, { icon: 2, time: 1000 })
}
}
})
})
}
window.batchRemove = function (obj) {
let data = table.checkStatus(obj.config.id).data
if (data.length === 0) {
layer.msg('未选中数据', {
icon: 3,
time: 1000
})
return false
}
var ids = []
var hasCheck = table.checkStatus('role-table')
var hasCheckData = hasCheck.data
if (hasCheckData.length > 0) {
$.each(hasCheckData, function (index, element) {
ids.push(element.id)
})
}
console.log(ids)
layer.confirm('确定要删除选中角色', {
icon: 3,
title: '提示'
}, function (index) {
layer.close(index)
let loading = layer.load()
$.ajax({
url: MODULE_PATH + 'batchRemove',
data: { ids: ids },
dataType: 'json',
type: 'delete',
success: function (result) {
layer.close(loading)
if (result.success) {
popup.success(result.msg, function () {
table.reload('role-table')
})
} else {
popup.failure(result.msg)
}
}
})
})
}
window.refresh = function () {
table.reload('role-table')
}
})
</script>
</html>