'wip(semantic):调整模板api接口'
This commit is contained in:
@@ -54,7 +54,7 @@
|
||||
</script>
|
||||
|
||||
<script type="module">
|
||||
import { RIGHTS_API } from '/static/api/http.js'
|
||||
import { RIGHTS_API, parserTableData as parseData } from '/static/api/http.js'
|
||||
|
||||
layui.use(['table', 'form', 'jquery', 'treetable', 'popup', 'dtree', 'iconPicker'], function () {
|
||||
let table = layui.table
|
||||
@@ -65,50 +65,48 @@
|
||||
let iconPicker = layui.iconPicker
|
||||
let dtree = layui.dtree
|
||||
|
||||
window.render = function () {
|
||||
treetable.render({
|
||||
treeColIndex: 1,
|
||||
treeSpid: 0,
|
||||
treeIdName: 'powerId',
|
||||
treePidName: 'parentId',
|
||||
skin: 'line',
|
||||
method: 'post',
|
||||
treeDefaultClose: true,
|
||||
toolbar: '#toolbar',
|
||||
elem: '#tables',
|
||||
url: RIGHTS_API.RIGHTS(),
|
||||
page: false,
|
||||
cols: [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ field: 'powerName', minWidth: 200, title: '权限名称' },
|
||||
{ field: 'icon', title: '图标', templet: (d) => `<i class="layui-icon ${d.icon}"></i>` },
|
||||
{
|
||||
field: 'powerType', title: '权限类型', templet: (d) => {
|
||||
if (d.powerType === '0') {
|
||||
return `<span>目录</span>`
|
||||
} else if (d.powerType === '1') {
|
||||
return `<span>菜单</span>`
|
||||
} else if (d.powerType === '2') {
|
||||
return `<span>按钮</span>`
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'enable', title: '是否可用', templet: (d) => {
|
||||
// TODO 修改禁用启动逻辑
|
||||
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: '#tool', width: 150, align: 'center' },
|
||||
],
|
||||
],
|
||||
})
|
||||
}
|
||||
const get_columns = () => [
|
||||
[
|
||||
{ type: 'checkbox' },
|
||||
{ field: 'powerName', minWidth: 200, title: '权限名称' },
|
||||
{ field: 'icon', title: '图标', templet: (d) => `<i class="layui-icon ${d.icon}"></i>` },
|
||||
{
|
||||
field: 'powerType', title: '权限类型', templet: (d) => {
|
||||
if (d.powerType === '0') {
|
||||
return `<span>目录</span>`
|
||||
} else if (d.powerType === '1') {
|
||||
return `<span>菜单</span>`
|
||||
} else if (d.powerType === '2') {
|
||||
return `<span>按钮</span>`
|
||||
}
|
||||
},
|
||||
},
|
||||
{
|
||||
field: 'enable', title: '是否可用', templet: (d) => {
|
||||
// TODO 修改禁用启动逻辑
|
||||
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: '#tool', width: 150, align: 'center' },
|
||||
],
|
||||
]
|
||||
|
||||
render()
|
||||
treetable.render({
|
||||
treeColIndex: 1,
|
||||
treeSpid: 0,
|
||||
treeIdName: 'powerId',
|
||||
treePidName: 'parentId',
|
||||
skin: 'line',
|
||||
method: 'post',
|
||||
treeDefaultClose: true,
|
||||
toolbar: '#toolbar',
|
||||
elem: '#tables',
|
||||
url: RIGHTS_API.RIGHTS(),
|
||||
page: false,
|
||||
cols: get_columns(),
|
||||
})
|
||||
|
||||
form.on('submit(power_query)', function (data) {
|
||||
var keyword = data.field.powerName
|
||||
@@ -173,9 +171,9 @@
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg)
|
||||
popup.success(result.message)
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
popup.failure(result.message)
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -211,12 +209,12 @@
|
||||
success: function (result) {
|
||||
layer.close(loading)
|
||||
if (result.success) {
|
||||
popup.success(result.msg, function () {
|
||||
popup.success(result.message, function () {
|
||||
console.log(obj)
|
||||
obj.del()
|
||||
})
|
||||
} else {
|
||||
popup.failure(result.msg)
|
||||
popup.failure(result.message)
|
||||
}
|
||||
},
|
||||
})
|
||||
|
||||
@@ -138,12 +138,12 @@
|
||||
type: 'post',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
layer.msg(result.message, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.render()
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
layer.msg(result.message, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
@@ -153,12 +153,12 @@
|
||||
type: 'put',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
layer.msg(result.message, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name))//关闭当前页
|
||||
parent.render()
|
||||
})
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2, time: 1000 })
|
||||
layer.msg(result.message, { icon: 2, time: 1000 })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user