v2
This commit is contained in:
271
internal/erpserver/templ/system/menu/edit.templ
Normal file
271
internal/erpserver/templ/system/menu/edit.templ
Normal file
@@ -0,0 +1,271 @@
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/pkg/mid"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/erpserver/model/system"
|
||||
)
|
||||
|
||||
templ Edit(ctx context.Context, item *system.Menu) {
|
||||
@base.Base(ctx, editCss(), editJs(ctx, item)) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
{{ ht := mid.GetHtmlCsrfToken(ctx) }}
|
||||
|
||||
<div class="layui-body layui-bg-gray">
|
||||
<div class="layui-card">
|
||||
<form class="layui-form">
|
||||
@ht
|
||||
<input type="hidden" name="ID" value={ item.ID } />
|
||||
|
||||
<div class="layui-tab layui-tab-card rhino-form">
|
||||
<ul class="layui-tab-title">
|
||||
<li class="layui-this">基础信息</li>
|
||||
<li>其它</li>
|
||||
</ul>
|
||||
|
||||
<div class="layui-tab-content">
|
||||
<div class="layui-tab-item layui-show">
|
||||
<div class="layui-form-item">
|
||||
<label for="Name" class="layui-form-label">名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="Name" name="Name" value={ item.Name } lay-verify="required"
|
||||
autocomplete="off" placeholder="请输入名称" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="DisplayName" class="layui-form-label">显示名称</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="DisplayName" name="DisplayName" value={ item.DisplayName }
|
||||
lay-verify="required" autocomplete="off" placeholder="请输入显示名称"
|
||||
class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Type" class="layui-form-label">类型</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="Type" name="Type">
|
||||
if item.Type == "node" {
|
||||
<option value="node" selected>菜单节点</option>
|
||||
<option value="menu">菜单</option>
|
||||
<option value="btn">按钮</option>
|
||||
} else if item.Type == "menu" {
|
||||
<option value="node">菜单节点</option>
|
||||
<option value="menu" selected>菜单</option>
|
||||
<option value="btn">按钮</option>
|
||||
} else if item.Type == "btn" {
|
||||
<option value="node">菜单节点</option>
|
||||
<option value="menu">菜单</option>
|
||||
<option value="btn" selected>按钮</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Url" class="layui-form-label">菜单URL</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="Url" name="Url" value={ item.Url } autocomplete="off"
|
||||
placeholder="请输入菜单URL" class="layui-input" style="width: 400px;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Avatar" class="layui-form-label">图标</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="Avatar" name="Avatar" value={ item.Avatar }
|
||||
autocomplete="off" placeholder="请输入菜单图标" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Style" class="layui-form-label">样式</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="Style" name="Style" value={ item.Style } autocomplete="off"
|
||||
placeholder="请输入样式" class="layui-input" style="width: 400px;" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">上级菜单</label>
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<ul id="menuTree" class="dtree organizationTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否可见</label>
|
||||
<div class="layui-input-inline">
|
||||
if item.Visible {
|
||||
<input type="radio" id="Visible" name="Visible" value="true" title="可见" checked />
|
||||
<input type="radio" id="Visible" name="Visible" value="false" title="不可见" />
|
||||
} else {
|
||||
<input type="radio" id="Visible" name="Visible" value="true" title="可见" />
|
||||
<input type="radio" id="Visible" name="Visible" value="false" title="不可见" checked />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">是否列表</label>
|
||||
<div class="layui-input-inline">
|
||||
if item.IsList {
|
||||
<input type="radio" id="IsList" name="IsList" value="true" title="是" checked />
|
||||
<input type="radio" id="IsList" name="IsList" value="false" title="否" />
|
||||
} else {
|
||||
<input type="radio" id="IsList" name="IsList" value="true" title="是" />
|
||||
<input type="radio" id="IsList" name="IsList" value="false" title="否" checked />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Sort" class="layui-form-label">排序</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="number" id="Sort" name="Sort" value={ item.Sort } lay-affix="number"
|
||||
min="1" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Status" class="layui-form-label">状态</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="Status" name="Status">
|
||||
if item.Status == 0 {
|
||||
<option value="0" selected>正常</option>
|
||||
<option value="-1">删除</option>
|
||||
} else if item.Status == -1 {
|
||||
<option value="0">正常</option>
|
||||
<option value="-1" selected>删除</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-tab-item">
|
||||
if item.ID > 0 {
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">创建时间</div>
|
||||
<div class="layui-form-label" style="width:400px;text-align:left;">
|
||||
{ item.CreatedAt.Format(time.DateTime) }
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">更新时间</div>
|
||||
<div class="layui-form-label" style="width:400px;text-align:left;">
|
||||
{ item.UpdatedAt.Format(time.DateTime) }
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-fixbar btn-fixbar-box">
|
||||
<div class="layui-input-block">
|
||||
@component.SubmitBtn(meuns, "save")
|
||||
<button type="button" class="layui-btn layui-btn-primary layui-btn-sm" lay-on="close">
|
||||
<i class="layui-icon layui-icon-close"></i>关闭
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ editCss() {
|
||||
<style>
|
||||
.layui-body {
|
||||
padding: 15px;
|
||||
left: 0;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
templ editJs(ctx context.Context, item *system.Menu) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'form', 'iconPicker', 'xmSelect', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let form = layui.form;
|
||||
let iconPicker = layui.iconPicker;
|
||||
let util = layui.util;
|
||||
|
||||
getMenuTree();
|
||||
|
||||
// 图标选择器
|
||||
iconPicker.render({
|
||||
elem: '#Avatar',
|
||||
url: '/layui/font/iconfont.svg',
|
||||
type: 'fontClass'
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/menu/save',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: data.field,
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name)); // 关闭当前页
|
||||
parent.layui.table.reload("tablelist", {
|
||||
page: { curr: 1 },
|
||||
});
|
||||
});
|
||||
} else {
|
||||
parent.layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// 事件绑定
|
||||
util.on("lay-on", {
|
||||
"close": function () {
|
||||
window.parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
function getMenuTree() {
|
||||
$.ajax({
|
||||
url: "/system/menu/data?type=xm_select_tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
xmSelect.render({
|
||||
el: '#menuTree',
|
||||
// 工具栏
|
||||
toolbar: {
|
||||
show: true
|
||||
},
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
tips: '请选择父级',
|
||||
filterable: true,
|
||||
data: res,
|
||||
name: 'ParentID',
|
||||
initValue: ['{{ item.ParentID }}'],
|
||||
tree: {
|
||||
show: true,
|
||||
//非严格模式
|
||||
strict: false,
|
||||
//默认展开节点的数组, 为 true 时, 展开所有节点
|
||||
expandedKeys: [1],
|
||||
},
|
||||
on: function (data) { },
|
||||
});
|
||||
},
|
||||
error: function (err) {
|
||||
// 处理请求错误
|
||||
console.log('请求出错:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
361
internal/erpserver/templ/system/menu/edit_templ.go
Normal file
361
internal/erpserver/templ/system/menu/edit_templ.go
Normal file
@@ -0,0 +1,361 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package menu
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/erpserver/model/system"
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func Edit(ctx context.Context, item *system.Menu) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
meuns := mid.GetCurMenus(ctx)
|
||||
ht := mid.GetHtmlCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<div class=\"layui-body layui-bg-gray\"><div class=\"layui-card\"><form class=\"layui-form\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = ht.Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "<input type=\"hidden\" name=\"ID\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(item.ID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 22, Col: 66}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var3))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "\"><div class=\"layui-tab layui-tab-card rhino-form\"><ul class=\"layui-tab-title\"><li class=\"layui-this\">基础信息</li><li>其它</li></ul><div class=\"layui-tab-content\"><div class=\"layui-tab-item layui-show\"><div class=\"layui-form-item\"><label for=\"Name\" class=\"layui-form-label\">名称</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"Name\" name=\"Name\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 35, Col: 98}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入名称\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"DisplayName\" class=\"layui-form-label\">显示名称</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"DisplayName\" name=\"DisplayName\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(item.DisplayName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 42, Col: 119}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入显示名称\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"Type\" class=\"layui-form-label\">类型</label><div class=\"layui-input-inline\"><select id=\"Type\" name=\"Type\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.Type == "node" {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<option value=\"node\" selected>菜单节点</option> <option value=\"menu\">菜单</option> <option value=\"btn\">按钮</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Type == "menu" {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<option value=\"node\">菜单节点</option> <option value=\"menu\" selected>菜单</option> <option value=\"btn\">按钮</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Type == "btn" {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<option value=\"node\">菜单节点</option> <option value=\"menu\">菜单</option> <option value=\"btn\" selected>按钮</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "</select></div></div><div class=\"layui-form-item\"><label for=\"Url\" class=\"layui-form-label\">菜单URL</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"Url\" name=\"Url\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.Url)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 70, Col: 95}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var6))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 10, "\" autocomplete=\"off\" placeholder=\"请输入菜单URL\" class=\"layui-input\" style=\"width: 400px;\"></div></div><div class=\"layui-form-item\"><label for=\"Avatar\" class=\"layui-form-label\">图标</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"Avatar\" name=\"Avatar\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(item.Avatar)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 77, Col: 104}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "\" autocomplete=\"off\" placeholder=\"请输入菜单图标\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"Style\" class=\"layui-form-label\">样式</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"Style\" name=\"Style\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(item.Style)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 84, Col: 101}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var8))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "\" autocomplete=\"off\" placeholder=\"请输入样式\" class=\"layui-input\" style=\"width: 400px;\"></div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">上级菜单</label><div class=\"layui-input-inline\" style=\"width:300px;\"><ul id=\"menuTree\" class=\"dtree organizationTree\"></ul></div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">是否可见</label><div class=\"layui-input-inline\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.Visible {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<input type=\"radio\" id=\"Visible\" name=\"Visible\" value=\"true\" title=\"可见\" checked> <input type=\"radio\" id=\"Visible\" name=\"Visible\" value=\"false\" title=\"不可见\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<input type=\"radio\" id=\"Visible\" name=\"Visible\" value=\"true\" title=\"可见\"> <input type=\"radio\" id=\"Visible\" name=\"Visible\" value=\"false\" title=\"不可见\" checked>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">是否列表</label><div class=\"layui-input-inline\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.IsList {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<input type=\"radio\" id=\"IsList\" name=\"IsList\" value=\"true\" title=\"是\" checked> <input type=\"radio\" id=\"IsList\" name=\"IsList\" value=\"false\" title=\"否\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<input type=\"radio\" id=\"IsList\" name=\"IsList\" value=\"true\" title=\"是\"> <input type=\"radio\" id=\"IsList\" name=\"IsList\" value=\"false\" title=\"否\" checked>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</div></div><div class=\"layui-form-item\"><label for=\"Sort\" class=\"layui-form-label\">排序</label><div class=\"layui-input-inline\"><input type=\"number\" id=\"Sort\" name=\"Sort\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(item.Sort)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 121, Col: 100}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var9))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "\" lay-affix=\"number\" min=\"1\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"Status\" class=\"layui-form-label\">状态</label><div class=\"layui-input-inline\"><select id=\"Status\" name=\"Status\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.Status == 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<option value=\"0\" selected>正常</option> <option value=\"-1\">删除</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Status == -1 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "<option value=\"0\">正常</option> <option value=\"-1\" selected>删除</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "</select></div></div></div><div class=\"layui-tab-item\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.ID > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "<div class=\"layui-form-item\"><div class=\"layui-form-label\">创建时间</div><div class=\"layui-form-label\" style=\"width:400px;text-align:left;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(item.CreatedAt.Format(time.DateTime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 145, Col: 78}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var10))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</div></div><div class=\"layui-form-item\"><div class=\"layui-form-label\">更新时间</div><div class=\"layui-form-label\" style=\"width:400px;text-align:left;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(item.UpdatedAt.Format(time.DateTime))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 151, Col: 78}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var11))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</div></div></div><div class=\"layui-form-item layui-fixbar btn-fixbar-box\"><div class=\"layui-input-block\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = component.SubmitBtn(meuns, "save").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<button type=\"button\" class=\"layui-btn layui-btn-primary layui-btn-sm\" lay-on=\"close\"><i class=\"layui-icon layui-icon-close\"></i>关闭</button></div></div></form></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = base.Base(ctx, editCss(), editJs(ctx, item)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func editCss() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var12 == nil {
|
||||
templ_7745c5c3_Var12 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<style>\n .layui-body {\n padding: 15px;\n left: 0;\n }\n </style>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func editJs(ctx context.Context, item *system.Menu) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var13 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var13 == nil {
|
||||
templ_7745c5c3_Var13 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "<script>\n layui.use(['jquery', 'form', 'iconPicker', 'xmSelect', 'util'], function () {\n let $ = layui.jquery;\n let form = layui.form;\n let iconPicker = layui.iconPicker;\n let util = layui.util;\n\n getMenuTree();\n\n // 图标选择器\n iconPicker.render({\n elem: '#Avatar',\n url: '/layui/font/iconfont.svg',\n type: 'fontClass'\n });\n\n // 表单提交\n form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/menu/save',\n type: 'post',\n dataType: 'json',\n data: data.field,\n success: function (result) {\n if (result.success) {\n layer.msg(result.msg, { icon: 1, time: 1000 }, function () {\n parent.layer.close(parent.layer.getFrameIndex(window.name)); // 关闭当前页\n parent.layui.table.reload(\"tablelist\", {\n page: { curr: 1 },\n });\n });\n } else {\n parent.layer.msg(result.msg, { icon: 2 })\n }\n }\n });\n\n return false;\n });\n\n // 事件绑定\n util.on(\"lay-on\", {\n \"close\": function () {\n window.parent.layer.close(parent.layer.getFrameIndex(window.name));\n }\n });\n\n\n function getMenuTree() {\n $.ajax({\n url: \"/system/menu/data?type=xm_select_tree\",\n type: 'post',\n dataType: 'json',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var14, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 238, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var14)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "' },\n success: function (res) {\n xmSelect.render({\n el: '#menuTree',\n // 工具栏\n toolbar: {\n show: true\n },\n radio: true,\n clickClose: true,\n tips: '请选择父级',\n filterable: true,\n data: res,\n name: 'ParentID',\n initValue: ['")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.ParentID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/edit.templ`, Line: 252, Col: 57}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var15)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "'],\n tree: {\n show: true,\n //非严格模式\n strict: false,\n //默认展开节点的数组, 为 true 时, 展开所有节点\n expandedKeys: [1],\n },\n on: function (data) { },\n });\n },\n error: function (err) {\n // 处理请求错误\n console.log('请求出错:', err);\n }\n });\n }\n });\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
190
internal/erpserver/templ/system/menu/list.templ
Normal file
190
internal/erpserver/templ/system/menu/list.templ
Normal file
@@ -0,0 +1,190 @@
|
||||
package menu
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/pkg/mid"
|
||||
"management/internal/erpserver/templ/component"
|
||||
)
|
||||
|
||||
templ List(ctx context.Context) {
|
||||
@base.Base(ctx, listCss(), listJs(ctx)) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
@component.TemplBtn(meuns, true, "add", "refresh_cache")
|
||||
@component.TemplLink(meuns, "add_children", "edit")
|
||||
|
||||
<div class="layui-panel">
|
||||
<table class="layui-hide" id="tablelist" lay-filter="tablelist"></table>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ listCss() {
|
||||
}
|
||||
|
||||
templ listJs(ctx context.Context) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'table', 'form', 'util', 'treeTable'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let treetable = layui.treeTable;
|
||||
let form = layui.form;
|
||||
let util = layui.util;
|
||||
|
||||
treetable.render({
|
||||
elem: '#tablelist',
|
||||
url: '/system/menu/list',
|
||||
method: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
where: getQueryParams(),
|
||||
height: function () {
|
||||
return $(window).height() - 22;
|
||||
},
|
||||
cols: [[
|
||||
{ field: 'name', title: '名称', width: 360 },
|
||||
{ field: 'display_name', title: '显示名称', width: 120, align: 'center' },
|
||||
{
|
||||
field: 'type', title: '类型', width: 100, align: 'center', templet: function (d) {
|
||||
switch (d.type) {
|
||||
case 'node': return '菜单节点';
|
||||
case 'menu': return '菜单';
|
||||
case 'btn': return '按钮';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'avatar', title: '图标', width: 50, align: 'center', templet: function (d) {
|
||||
if (!d.avatar) { return ''; }
|
||||
return '<i class="' + d.avatar + '"></i>'
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'status', title: '状态', width: 60, align: 'center', templet: function (d) {
|
||||
if (d.id === 0) { return ''; }
|
||||
|
||||
switch (d.status) {
|
||||
case 0: return '<span style="color: green">正常</span>';
|
||||
case -1: return '<span style="color: red">删除</span>';
|
||||
default: return '其它';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'is_list', title: '列表', width: 60, align: 'center', templet: function (d) {
|
||||
if (d.is_list) { return '<span style="color: green">是</span>'; }
|
||||
return '<span style="color: red">否</span>';
|
||||
}
|
||||
},
|
||||
{ title: '操作', toolbar: '#actionBox', align: 'center', width: 200 },
|
||||
{ field: 'url', title: 'url', width: 200 },
|
||||
{ field: 'created_at', title: '创建时间', width: 160, align: 'center', templet: function (d) { return (!d.created_at || d.id === 0) ? '' : util.toDateString(d.created_at) } },
|
||||
{ field: 'updated_at', title: '更新时间', width: 160, align: 'center', templet: function (d) { return !d.updated_at ? '' : util.toDateString(d.updated_at) } },
|
||||
]],
|
||||
even: true,
|
||||
page: true,
|
||||
toolbar: '#toolbar',
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'exports'],
|
||||
view: {}
|
||||
});
|
||||
|
||||
table.on('toolbar(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'add': add(); break;
|
||||
case 'refresh_cache': refreshCache(); break;
|
||||
case 'refresh': refresh(); break;
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
function add() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增菜单',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/menu/add"
|
||||
});
|
||||
}
|
||||
|
||||
function refreshCache() {
|
||||
layer.confirm('确定要刷新菜单缓存数据吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/menu/refresh_cache',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
|
||||
table.reload('tablelist');
|
||||
});
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index); // 关闭弹窗
|
||||
}, function (index, layero) {
|
||||
layer.close(index); // 关闭弹窗
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
table.reload('tablelist');
|
||||
}
|
||||
|
||||
table.on('tool(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'add_children': addChildren(obj); break;
|
||||
case 'edit': edit(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function addChildren(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '为 ' + obj.data.display_name + ' 新增子级',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/menu/add_children?parentID=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/menu/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
function getQueryParams() {
|
||||
return {
|
||||
searchName: $('#searchName').val(),
|
||||
searchKey: $('#searchKey').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search() {
|
||||
table.reloadData('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
158
internal/erpserver/templ/system/menu/list_templ.go
Normal file
158
internal/erpserver/templ/system/menu/list_templ.go
Normal file
@@ -0,0 +1,158 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package menu
|
||||
|
||||
//lint:file-ignore SA4006 This context is only used if a nested component is present.
|
||||
|
||||
import "github.com/a-h/templ"
|
||||
import templruntime "github.com/a-h/templ/runtime"
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func List(ctx context.Context) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var1 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var1 == nil {
|
||||
templ_7745c5c3_Var1 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Var2 := templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
meuns := mid.GetCurMenus(ctx)
|
||||
templ_7745c5c3_Err = component.TemplBtn(meuns, true, "add", "refresh_cache").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, " ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = component.TemplLink(meuns, "add_children", "edit").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " <div class=\"layui-panel\"><table class=\"layui-hide\" id=\"tablelist\" lay-filter=\"tablelist\"></table></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = base.Base(ctx, listCss(), listJs(ctx)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func listCss() templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var3 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var3 == nil {
|
||||
templ_7745c5c3_Var3 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func listJs(ctx context.Context) templ.Component {
|
||||
return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) {
|
||||
templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context
|
||||
if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil {
|
||||
return templ_7745c5c3_CtxErr
|
||||
}
|
||||
templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W)
|
||||
if !templ_7745c5c3_IsBuffer {
|
||||
defer func() {
|
||||
templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err == nil {
|
||||
templ_7745c5c3_Err = templ_7745c5c3_BufErr
|
||||
}
|
||||
}()
|
||||
}
|
||||
ctx = templ.InitializeContext(ctx)
|
||||
templ_7745c5c3_Var4 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var4 == nil {
|
||||
templ_7745c5c3_Var4 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 3, "<script>\n layui.use(['jquery', 'table', 'form', 'util', 'treeTable'], function () {\n let $ = layui.jquery;\n let table = layui.table;\n let treetable = layui.treeTable;\n let form = layui.form;\n let util = layui.util;\n\n treetable.render({\n elem: '#tablelist',\n url: '/system/menu/list',\n method: 'post',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/list.templ`, Line: 40, Col: 52}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var5)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "' },\n where: getQueryParams(),\n height: function () {\n return $(window).height() - 22;\n },\n cols: [[\n { field: 'name', title: '名称', width: 360 },\n { field: 'display_name', title: '显示名称', width: 120, align: 'center' },\n {\n field: 'type', title: '类型', width: 100, align: 'center', templet: function (d) {\n switch (d.type) {\n case 'node': return '菜单节点';\n case 'menu': return '菜单';\n case 'btn': return '按钮';\n }\n return '';\n }\n },\n {\n field: 'avatar', title: '图标', width: 50, align: 'center', templet: function (d) {\n if (!d.avatar) { return ''; }\n return '<i class=\"' + d.avatar + '\"></i>'\n }\n },\n {\n field: 'status', title: '状态', width: 60, align: 'center', templet: function (d) {\n if (d.id === 0) { return ''; }\n\n switch (d.status) {\n case 0: return '<span style=\"color: green\">正常</span>';\n case -1: return '<span style=\"color: red\">删除</span>';\n default: return '其它';\n }\n return '';\n }\n },\n {\n field: 'is_list', title: '列表', width: 60, align: 'center', templet: function (d) {\n if (d.is_list) { return '<span style=\"color: green\">是</span>'; }\n return '<span style=\"color: red\">否</span>';\n }\n },\n { title: '操作', toolbar: '#actionBox', align: 'center', width: 200 },\n { field: 'url', title: 'url', width: 200 },\n { field: 'created_at', title: '创建时间', width: 160, align: 'center', templet: function (d) { return (!d.created_at || d.id === 0) ? '' : util.toDateString(d.created_at) } },\n { field: 'updated_at', title: '更新时间', width: 160, align: 'center', templet: function (d) { return !d.updated_at ? '' : util.toDateString(d.updated_at) } },\n ]],\n even: true,\n page: true,\n toolbar: '#toolbar',\n defaultToolbar: [{\n title: '刷新',\n layEvent: 'refresh',\n icon: 'layui-icon-refresh',\n }, 'filter', 'exports'],\n view: {}\n });\n\n table.on('toolbar(tablelist)', function (obj) {\n switch (obj.event) {\n case 'add': add(); break;\n case 'refresh_cache': refreshCache(); break;\n case 'refresh': refresh(); break;\n\n }\n });\n\n function add() {\n layer.open({\n type: 2,\n title: '新增菜单',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/menu/add\"\n });\n }\n\n function refreshCache() {\n layer.confirm('确定要刷新菜单缓存数据吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/menu/refresh_cache',\n type: 'post',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/menu/list.templ`, Line: 122, Col: 60}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var6)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "' },\n success: function (result) {\n if (result.success) {\n layer.msg(result.msg, { icon: 1, time: 1000 }, function () {\n table.reload('tablelist');\n });\n } else {\n layer.msg(result.msg, { icon: 2 })\n }\n }\n });\n layer.close(index); // 关闭弹窗\n }, function (index, layero) {\n layer.close(index); // 关闭弹窗\n });\n }\n\n function refresh() {\n table.reload('tablelist');\n }\n\n table.on('tool(tablelist)', function (obj) {\n switch (obj.event) {\n case 'add_children': addChildren(obj); break;\n case 'edit': edit(obj); break;\n }\n });\n\n function addChildren(obj) {\n layer.open({\n type: 2,\n title: '为 ' + obj.data.display_name + ' 新增子级',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/menu/add_children?parentID=\" + obj.data['id']\n });\n }\n\n function edit(obj) {\n layer.open({\n type: 2,\n title: '修改',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/menu/edit?id=\" + obj.data['id']\n });\n }\n\n // 搜索条件\n function getQueryParams() {\n return {\n searchName: $('#searchName').val(),\n searchKey: $('#searchKey').val()\n };\n }\n\n // 搜索\n function search() {\n table.reloadData('tablelist', {\n where: getQueryParams(),\n page: {\n curr: 1\n }\n });\n return false;\n }\n });\n </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
Reference in New Issue
Block a user