wip(semantic):调整模板文件内容
This commit is contained in:
@@ -27,34 +27,32 @@
|
||||
</div>
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="power_table" lay-filter="power_table"></table>
|
||||
<table id="tables" lay-filter="tables"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
|
||||
{% include 'admin/common/footer.html' %}
|
||||
|
||||
<script type="text/html" id="power-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add">
|
||||
<script type="text/html" id="toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="toolbar-add">
|
||||
<i class="layui-icon layui-icon-add-1"></i>
|
||||
新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-md" lay-event="batchRemove">
|
||||
<button class="pear-btn pear-btn-md" lay-event="toolbar-remove">
|
||||
<i class="layui-icon layui-icon-delete"></i>
|
||||
删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<script type="text/html" id="power-bar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="edit"><i
|
||||
<script type="text/html" id="tool">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-sm" lay-event="tool-edit"><i
|
||||
class="layui-icon layui-icon-edit"></i>
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="remove"><i
|
||||
<button class="pear-btn pear-btn-danger pear-btn-sm" lay-event="tool-remove"><i
|
||||
class="layui-icon layui-icon-delete"></i>
|
||||
</button>
|
||||
</script>
|
||||
|
||||
{% include 'admin/common/footer.html' %}
|
||||
<script type="module">
|
||||
import { RIGHTS_API } from '/static/api/http.js'
|
||||
|
||||
@@ -76,8 +74,8 @@
|
||||
skin: 'line',
|
||||
method: 'post',
|
||||
treeDefaultClose: true,
|
||||
toolbar: '#power-toolbar',
|
||||
elem: '#power_table',
|
||||
toolbar: '#toolbar',
|
||||
elem: '#tables',
|
||||
url: RIGHTS_API.RIGHTS(),
|
||||
page: false,
|
||||
cols: [
|
||||
@@ -87,11 +85,11 @@
|
||||
{ field: 'icon', title: '图标', templet: (d) => `<i class="layui-icon ${d.icon}"></i>` },
|
||||
{
|
||||
field: 'powerType', title: '权限类型', templet: (d) => {
|
||||
if (d.powerType == '0') {
|
||||
if (d.powerType === '0') {
|
||||
return `<span>目录</span>`
|
||||
} else if (d.powerType == '1') {
|
||||
} else if (d.powerType === '1') {
|
||||
return `<span>菜单</span>`
|
||||
} else if (d.powerType == '2') {
|
||||
} else if (d.powerType === '2') {
|
||||
return `<span>按钮</span>`
|
||||
}
|
||||
},
|
||||
@@ -99,12 +97,12 @@
|
||||
{
|
||||
field: 'enable', title: '是否可用', templet: (d) => {
|
||||
// TODO 修改禁用启动逻辑
|
||||
return `<input type="checkbox" name="enable" value="${d.powerId}" lay-skin="switch" lay-text="启用|禁用" lay-filter="power_enable" ${d.enable ===
|
||||
return `<input type="checkbox" name="enable" value="${d.powerId}" lay-skin="switch" lay-text="启用|禁用" lay-filter="tool-switch" ${d.enable ===
|
||||
1 ? 'checked=checked' : ''}>`
|
||||
},
|
||||
},
|
||||
{ field: 'sort', title: '排序' },
|
||||
{ title: '操作', templet: '#power-bar', width: 150, align: 'center' },
|
||||
{ title: '操作', templet: '#tool', width: 150, align: 'center' },
|
||||
],
|
||||
],
|
||||
})
|
||||
@@ -114,7 +112,7 @@
|
||||
|
||||
form.on('submit(power_query)', function (data) {
|
||||
var keyword = data.field.powerName
|
||||
var $tds = $('#power_table').next('.treeTable').find('.layui-table-body tbody tr td')
|
||||
var $tds = $('#tables').next('.treeTable').find('.layui-table-body tbody tr td')
|
||||
if (!keyword) {
|
||||
$tds.css('background-color', 'transparent')
|
||||
layer.msg('请输入关键字', { icon: 5 })
|
||||
@@ -135,30 +133,30 @@
|
||||
if (searchCount === 0) {
|
||||
layer.msg('没有匹配结果', { icon: 5 })
|
||||
} else {
|
||||
treetable.expandAll('#power_table')
|
||||
treetable.expandAll('#tables')
|
||||
}
|
||||
return false
|
||||
})
|
||||
|
||||
table.on('tool(power_table)', function (obj) {
|
||||
if (obj.event === 'remove') {
|
||||
window.remove(obj)
|
||||
} else if (obj.event === 'edit') {
|
||||
window.edit(obj)
|
||||
table.on('tool(tables)', function (obj) {
|
||||
if (obj.event === 'tool-remove') {
|
||||
window.tool_remove(obj)
|
||||
} else if (obj.event === 'tool-edit') {
|
||||
window.tool_edit(obj)
|
||||
}
|
||||
})
|
||||
|
||||
table.on('toolbar(power_table)', function (obj) {
|
||||
if (obj.event === 'add') {
|
||||
window.add()
|
||||
table.on('toolbar(tables)', function (obj) {
|
||||
if (obj.event === 'toolbar-add') {
|
||||
window.toolbar_add()
|
||||
} else if (obj.event === 'refresh') {
|
||||
window.refresh()
|
||||
} else if (obj.event === 'batchRemove') {
|
||||
window.batchRemove(obj)
|
||||
} else if (obj.event === 'toolbar-remove') {
|
||||
window.toolbar_remove(obj)
|
||||
}
|
||||
})
|
||||
|
||||
form.on('switch(power_enable)', function (obj) {
|
||||
form.on('switch(tool-switch)', function (obj) {
|
||||
let operate
|
||||
if (obj.elem.checked) {
|
||||
operate = 1 /*启用*/
|
||||
@@ -183,24 +181,17 @@
|
||||
})
|
||||
})
|
||||
|
||||
window.add = function () {
|
||||
window.toolbar_add = function () {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['450px', '500px'],
|
||||
content: 'rights/add',
|
||||
})
|
||||
layer.open({
|
||||
type: 1,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['450px', '500px'],
|
||||
content: $('#add_view'),
|
||||
content: '/rights/add',
|
||||
})
|
||||
}
|
||||
|
||||
window.edit = function (obj) {
|
||||
window.tool_edit = function (obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
@@ -209,7 +200,7 @@
|
||||
content: '/rights/power/' + obj.data['powerId'],
|
||||
})
|
||||
}
|
||||
window.remove = function (obj) {
|
||||
window.tool_remove = function (obj) {
|
||||
layer.confirm('确定要删除该权限', { icon: 3, title: '提示' }, function (index) {
|
||||
layer.close(index)
|
||||
let loading = layer.load()
|
||||
@@ -232,7 +223,7 @@
|
||||
})
|
||||
}
|
||||
|
||||
window.batchRemove = function (obj) {
|
||||
window.toolbar_remove = function (obj) {
|
||||
let data = table.checkStatus(obj.config.id).data
|
||||
if (data.length === 0) {
|
||||
layer.msg('未选中数据', {
|
||||
@@ -242,7 +233,7 @@
|
||||
return false
|
||||
}
|
||||
var ids = []
|
||||
var hasCheck = table.checkStatus('power_table')
|
||||
var hasCheck = table.checkStatus('tables')
|
||||
var hasCheckData = hasCheck.data
|
||||
if (hasCheckData.length > 0) {
|
||||
$.each(hasCheckData, function (index, element) {
|
||||
@@ -293,4 +284,5 @@
|
||||
})
|
||||
})
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -83,9 +83,12 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% include 'admin/common/footer.html' %}
|
||||
|
||||
<script type="module">
|
||||
import { RIGHTS_API } from 'static/api/http.js'
|
||||
import { RIGHTS_API } from '/static/api/http.js'
|
||||
|
||||
layui.use(['form', 'jquery', 'iconPicker', 'dtree'], function () {
|
||||
let form = layui.form
|
||||
@@ -93,16 +96,15 @@
|
||||
let iconPicker = layui.iconPicker
|
||||
let dtree = layui.dtree
|
||||
|
||||
{#添加权限数据页面#}
|
||||
dtree.renderSelect({
|
||||
elem: '#select_parent_dept',
|
||||
elem: '#selectParent',
|
||||
url: RIGHTS_API.RIGHTS(),
|
||||
method: 'get',
|
||||
selectInputName: { nodeId: 'parentId', context: 'powerName' },
|
||||
skin: 'layui',
|
||||
dataFormat: 'list',
|
||||
response: { treeId: 'powerId', parentId: 'parentId', title: 'powerName' }, //修改response中返回数据的定义
|
||||
selectInitVal: '0',
|
||||
selectInitVal: '0'
|
||||
})
|
||||
|
||||
form.on('radio(powerType)', function () {
|
||||
@@ -129,7 +131,7 @@
|
||||
form.on('submit(power-save)', function (data) {
|
||||
data.field.icon = 'layui-icon ' + data.field.icon
|
||||
$.ajax({
|
||||
url: '/admin/power/save',
|
||||
url: RIGHTS_API.POWER(0),
|
||||
data: JSON.stringify(data.field),
|
||||
dataType: 'json',
|
||||
contentType: 'application/json',
|
||||
@@ -143,7 +145,7 @@
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
}
|
||||
},
|
||||
}
|
||||
})
|
||||
return false
|
||||
})
|
||||
@@ -162,10 +164,9 @@
|
||||
// 点击回调
|
||||
click: function (data) {
|
||||
console.log(data)
|
||||
},
|
||||
}
|
||||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
@@ -8,76 +8,74 @@
|
||||
<form class="layui-form" action="">
|
||||
<div class="mainBox">
|
||||
<div class="main-container">
|
||||
<div class="main-container">
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.id }}" name="powerId" lay-verify="title"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item layui-hide">
|
||||
<label class="layui-form-label">编号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.id }}" name="powerId"
|
||||
autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级</label>
|
||||
<div class="layui-input-block">
|
||||
<ul id="selectParent" name="parentId" class="dtree" data-id="-1"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">父级</label>
|
||||
<div class="layui-input-block">
|
||||
<ul id="selectParent" name="parentId" class="dtree" data-id="-1"></ul>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.name }}" name="powerName" lay-verify="title"
|
||||
autocomplete="off" placeholder="权限名称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.name }}" name="powerName"
|
||||
autocomplete="off" placeholder="权限名称" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item" id="powerCodeItem">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="powerCode" value="{{ power.code }}" name="powerCode"
|
||||
autocomplete="off" placeholder="权限标识" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" id="powerCodeItem">
|
||||
<label class="layui-form-label">标识</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="powerCode" value="{{ power.code }}" name="powerCode"
|
||||
autocomplete="off" placeholder="权限标识" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 0 %} checked{% endif %}
|
||||
name="powerType" value="0" title="目录">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 1 %} checked{% endif %}
|
||||
name="powerType" value="1" title="菜单">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 2 %} checked{% endif %}
|
||||
name="powerType" value="2" title="按钮">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 0 %} checked{% endif %}
|
||||
name="powerType" value="0" title="目录">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 1 %} checked{% endif %}
|
||||
name="powerType" value="1" title="菜单">
|
||||
<input type="radio" lay-filter="powerType" {% if power.type == 2 %} checked{% endif %}
|
||||
name="powerType" value="2" title="按钮">
|
||||
</div>
|
||||
<div class="layui-form-item" id="powerUrlItem">
|
||||
<label class="layui-form-label">路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="powerUrl" value="{{ power.url }}" name="powerUrl"
|
||||
autocomplete="off" placeholder="菜单路径" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" id="powerUrlItem">
|
||||
<label class="layui-form-label">路径</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="powerUrl" value="{{ power.url }}" name="powerUrl"
|
||||
autocomplete="off" placeholder="菜单路径" class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item" id="openTypeItem">
|
||||
<label class="layui-form-label">打开</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="openType" id="openType">
|
||||
<option value=""></option>
|
||||
<option value="_iframe" {% if power.open_type == "_iframe" %} selected{% endif %}>框架
|
||||
</option>
|
||||
<option value="_blank" {% if power.open_type == "_blank" %} selected{% endif %}>签页</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item" id="openTypeItem">
|
||||
<label class="layui-form-label">打开</label>
|
||||
<div class="layui-input-block">
|
||||
<select name="openType" id="openType">
|
||||
<option value=""></option>
|
||||
<option value="_iframe" {% if power.open_type == "_iframe" %} selected{% endif %}>框架
|
||||
</option>
|
||||
<option value="_blank" {% if power.open_type == "_blank" %} selected{% endif %}>签页</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">图标</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="edit_icon" value="{{ power.icon }}" name="icon" lay-filter="icon"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">图标</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="edit_icon" value="{{ power.icon }}" name="icon" lay-filter="icon"
|
||||
class="layui-input">
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.sort }}" name="sort" lay-verify="title" autocomplete="off"
|
||||
placeholder="排序" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" value="{{ power.sort }}" name="sort" lay-verify="title" autocomplete="off"
|
||||
placeholder="排序" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -95,7 +93,10 @@
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
|
||||
{% include 'admin/common/footer.html' %}
|
||||
|
||||
<script type="module">
|
||||
|
||||
import { RIGHTS_API } from '/static/api/http.js'
|
||||
@@ -201,7 +202,5 @@
|
||||
window.init("{{ power.type }}")
|
||||
})
|
||||
</script>
|
||||
<script>
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user