v1
This commit is contained in:
212
internal/erpserver/templ/system/role/edit.templ
Normal file
212
internal/erpserver/templ/system/role/edit.templ
Normal file
@@ -0,0 +1,212 @@
|
||||
package role
|
||||
|
||||
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.Role) {
|
||||
@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" id="id" name="id" value={ item.ID } />
|
||||
|
||||
<div class="layui-tab layui-tab-card">
|
||||
<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">
|
||||
if item.ID > 0 {
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">ID</div>
|
||||
<div class="layui-form-label" style="width:400px;text-align:left;">
|
||||
{ item.ID }
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">上级</div>
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<ul id="roleTree" class="dtree organizationTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">名称</div>
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<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">
|
||||
<div class="layui-form-label">显示名称</div>
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<input type="text" id="display_name" name="display_name" value={ item.DisplayName }
|
||||
lay-verify="required" autocomplete="off" placeholder="请输入显示名称"
|
||||
class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label 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 class="layui-form-item">
|
||||
<label 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>
|
||||
|
||||
<!-- 其它 -->
|
||||
<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.Role) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'form', 'xmSelect', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let form = layui.form;
|
||||
let xmSelect = layui.xmSelect;
|
||||
let util = layui.util;
|
||||
|
||||
getRoleTree();
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/role/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 getRoleTree() {
|
||||
$.ajax({
|
||||
url: "/system/role/data?type=xm_select_tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
xmSelect.render({
|
||||
el: '#roleTree',
|
||||
// 工具栏
|
||||
toolbar: {
|
||||
show: true
|
||||
},
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
tips: '请选择父级',
|
||||
filterable: true,
|
||||
data: res,
|
||||
name: 'parent_id',
|
||||
initValue: ['{{ item.ParentID }}'],
|
||||
tree: {
|
||||
show: true,
|
||||
//非严格模式
|
||||
strict: false,
|
||||
//默认展开节点的数组, 为 true 时, 展开所有节点
|
||||
expandedKeys: [1],
|
||||
},
|
||||
on: function (data) { },
|
||||
});
|
||||
},
|
||||
error: function (err) {
|
||||
// 处理请求错误
|
||||
console.log('请求出错:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
295
internal/erpserver/templ/system/role/edit_templ.go
Normal file
295
internal/erpserver/templ/system/role/edit_templ.go
Normal file
@@ -0,0 +1,295 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package role
|
||||
|
||||
//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.Role) 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\" id=\"id\" 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/role/edit.templ`, Line: 21, Col: 74}
|
||||
}
|
||||
_, 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\"><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\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.ID > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\"layui-form-item\"><div class=\"layui-form-label\">ID</div><div class=\"layui-form-label\" style=\"width:400px;text-align:left;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(item.ID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 36, Col: 53}
|
||||
}
|
||||
_, 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, 5, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"layui-form-item\"><div class=\"layui-form-label\">上级</div><div class=\"layui-input-inline\" style=\"width:300px;\"><ul id=\"roleTree\" class=\"dtree organizationTree\"></ul></div></div><div class=\"layui-form-item\"><div class=\"layui-form-label\">名称</div><div class=\"layui-input-inline\" style=\"width:300px;\"><input type=\"text\" id=\"name\" name=\"name\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(item.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 51, Col: 98}
|
||||
}
|
||||
_, 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, 7, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入名称\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><div class=\"layui-form-label\">显示名称</div><div class=\"layui-input-inline\" style=\"width:300px;\"><input type=\"text\" id=\"display_name\" name=\"display_name\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.DisplayName)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 59, Col: 121}
|
||||
}
|
||||
_, 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, 8, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入显示名称\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label 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, 9, "<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, 10, "<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, 11, "</select></div></div><div class=\"layui-form-item\"><label 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_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(item.Sort)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 83, Col: 100}
|
||||
}
|
||||
_, 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, 12, "\" lay-affix=\"number\" min=\"1\" class=\"layui-input\"></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, 13, "<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_Var8 string
|
||||
templ_7745c5c3_Var8, 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/role/edit.templ`, Line: 95, Col: 78}
|
||||
}
|
||||
_, 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, 14, "</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_Var9 string
|
||||
templ_7745c5c3_Var9, 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/role/edit.templ`, Line: 101, Col: 78}
|
||||
}
|
||||
_, 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, 15, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "</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, 17, "<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_Var10 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var10 == nil {
|
||||
templ_7745c5c3_Var10 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<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.Role) 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_Var11 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var11 == nil {
|
||||
templ_7745c5c3_Var11 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<script>\n layui.use(['jquery', 'form', 'xmSelect', 'util'], function () {\n let $ = layui.jquery;\n let form = layui.form;\n let xmSelect = layui.xmSelect;\n let util = layui.util;\n\n getRoleTree();\n\n // 表单提交\n form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/role/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 function getRoleTree() {\n $.ajax({\n url: \"/system/role/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_Var12, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 179, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var12)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "' },\n success: function (res) {\n xmSelect.render({\n el: '#roleTree',\n // 工具栏\n toolbar: {\n show: true\n },\n radio: true,\n clickClose: true,\n tips: '请选择父级',\n filterable: true,\n data: res,\n name: 'parent_id',\n initValue: ['")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.ParentID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/edit.templ`, Line: 193, Col: 57}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var13)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "'],\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
|
||||
314
internal/erpserver/templ/system/role/list.templ
Normal file
314
internal/erpserver/templ/system/role/list.templ
Normal file
@@ -0,0 +1,314 @@
|
||||
package role
|
||||
|
||||
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", "rebuild_parent_path")
|
||||
@component.TemplLink(meuns, "edit", "set_menu", "refresh_role_menus")
|
||||
|
||||
<div class="search-layer" id="search-layer" style="display: none;">
|
||||
<input type="hidden" id="parentId" name="parentId" value="0" />
|
||||
<div class="layui-form layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="status" class="tips">状态</label>
|
||||
<select id="status">
|
||||
<option value="0">正常</option>
|
||||
<option value="-1">删除</option>
|
||||
<option value="9999">全部</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="id" class="tips">编号</label>
|
||||
<input type="text" id="id" placeholder="请输入编号" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="name" class="tips">名称</label>
|
||||
<input type="text" id="name" placeholder="请输入名称" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-row h-all">
|
||||
<div class="layui-col-md2 h-all">
|
||||
<div class="own-left-pannel">
|
||||
<div id="roleTree" class="own-tree"></div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-md10">
|
||||
<div class="own-pannel">
|
||||
<table id="tablelist" lay-filter="tablelist"></table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ listCss() {
|
||||
}
|
||||
|
||||
templ listJs(ctx context.Context) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'table', 'form', 'tree', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let tree = layui.tree;
|
||||
let util = layui.util;
|
||||
|
||||
getRoleTree();
|
||||
|
||||
// 加载列表
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: "/system/role/list",
|
||||
method: "POST",
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
where: getQueryParams(),
|
||||
height: function () {
|
||||
return $(window).height() - 22;
|
||||
},
|
||||
page: true,
|
||||
limit: 15,
|
||||
limits: [15, 30, 45, 60, 75, 90],
|
||||
cols: [[
|
||||
{ field: 'display_name', title: '显示名称', align: 'left', width: 160, fixed: 'left' },
|
||||
{ field: 'name', title: '名称', align: 'left', width: 150, fixed: 'left' },
|
||||
{
|
||||
field: 'status', title: '状态', align: 'center', width: 90, templet: function (row) {
|
||||
switch (row.status) {
|
||||
case 0: return '正常';
|
||||
case -1: return '删除';
|
||||
default: return '其它';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
{ field: 'sort', title: '排序', align: 'center', width: 60 },
|
||||
{ field: 'created_at', title: '创建时间', align: 'center', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },
|
||||
{ field: 'updated_at', title: '更新时间', align: 'center', width: 160, templet: function (d) { return !d.updated_at ? '' : util.toDateString(d.updated_at) } },
|
||||
{ title: '操作', toolbar: '#actionBox', align: 'center', width: 300, fixed: 'right' },
|
||||
]],
|
||||
skin: 'grid',
|
||||
toolbar: '#toolbar',
|
||||
defaultToolbar: [{
|
||||
title: '刷新',
|
||||
layEvent: 'refresh',
|
||||
icon: 'layui-icon-refresh',
|
||||
}, 'filter', 'exports'],
|
||||
request: {
|
||||
pageName: 'page',
|
||||
limitName: 'rows'
|
||||
}
|
||||
});
|
||||
|
||||
// 工具栏
|
||||
table.on('toolbar(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'add': add(); break;
|
||||
case 'refresh': table.reload('tablelist'); break;
|
||||
case 'refresh_cache': refreshCache(); break;
|
||||
case 'rebuild_parent_path': rebuildParentPath(); break;
|
||||
case 'search': search(); break;
|
||||
}
|
||||
});
|
||||
|
||||
function add(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/role/add"
|
||||
});
|
||||
}
|
||||
|
||||
function refreshCache() {
|
||||
layer.confirm('确定要刷新角色数据吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/role/refresh_cache',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 2000 });
|
||||
search_btn();
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index); // 关闭弹窗
|
||||
}, function (index, layero) {
|
||||
layer.close(index); // 关闭弹窗
|
||||
});
|
||||
}
|
||||
|
||||
function rebuildParentPath() {
|
||||
layer.confirm('确定要重建父路径吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/role/rebuild_parent_path',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 2000 });
|
||||
search_btn();
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index); // 关闭弹窗
|
||||
}, function (index, layero) {
|
||||
layer.close(index); // 关闭弹窗
|
||||
});
|
||||
}
|
||||
|
||||
function search() {
|
||||
layer.open({
|
||||
type: 1,
|
||||
offset: '20px',
|
||||
title: '搜索',
|
||||
content: $('#search-layer'), // 捕获的元素
|
||||
shade: 0.1,
|
||||
shadeClose: false,
|
||||
scrollbar: false,
|
||||
resize: false,
|
||||
move: false,
|
||||
skin: 'search-layer-open',
|
||||
area: ['50%', '350px'],
|
||||
btn: ['搜索', '重置'],
|
||||
btn1: function (index, layero) {
|
||||
search_btn();
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
$('#status').val(0);
|
||||
$('#id').val('');
|
||||
$('#name').val('');
|
||||
$('#parentId').val(0);
|
||||
form.render('select');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// 表格项操作按钮
|
||||
table.on('tool(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'edit': edit(obj); break;
|
||||
case 'set_menu': setMenu(obj); break;
|
||||
case 'refresh_role_menus': refreshRoleMenus(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/role/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function setMenu(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '为 ' + obj.data['display_name'] + ' 分配权限',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/role/set_menu?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function refreshRoleMenus(obj) {
|
||||
layer.confirm('确定要刷新角色权限吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/role/refresh_role_menus',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
data: { "roleID": obj.data['id'] },
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 2000 });
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
layer.close(index); // 关闭弹窗
|
||||
}, function (index, layero) {
|
||||
layer.close(index); // 关闭弹窗
|
||||
});
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
function getQueryParams() {
|
||||
return {
|
||||
status: $('#status').val(),
|
||||
name: $('#name').val(),
|
||||
id: $('#id').val(),
|
||||
parentId: $('#parentId').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search_btn() {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function getRoleTree() {
|
||||
$.ajax({
|
||||
url: "/system/role/data?type=tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
tree.render({
|
||||
elem: '#roleTree',
|
||||
data: res,
|
||||
onlyIconControl: true, // 是否仅允许节点左侧图标控制展开收缩
|
||||
showLine: true,
|
||||
click: function (obj) {
|
||||
// console.log(obj.data); // 得到当前点击的节点数据
|
||||
// console.log(obj.state); // 得到当前节点的展开状态:open、close、normal
|
||||
// console.log(obj.elem); // 得到当前节点元素
|
||||
// console.log(obj.data.children); // 当前节点下是否有子节点
|
||||
$('#parentId').val(obj.data.id);
|
||||
search_btn();
|
||||
}
|
||||
});
|
||||
},
|
||||
error: function (err) {
|
||||
// 处理请求错误
|
||||
console.log('请求出错:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
194
internal/erpserver/templ/system/role/list_templ.go
Normal file
194
internal/erpserver/templ/system/role/list_templ.go
Normal file
@@ -0,0 +1,194 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package role
|
||||
|
||||
//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", "rebuild_parent_path").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, "edit", "set_menu", "refresh_role_menus").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=\"search-layer\" id=\"search-layer\" style=\"display: none;\"><input type=\"hidden\" id=\"parentId\" name=\"parentId\" value=\"0\"><div class=\"layui-form layui-row\"><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"status\" class=\"tips\">状态</label> <select id=\"status\"><option value=\"0\">正常</option> <option value=\"-1\">删除</option> <option value=\"9999\">全部</option></select></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"id\" class=\"tips\">编号</label> <input type=\"text\" id=\"id\" placeholder=\"请输入编号\" class=\"layui-input\"></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"name\" class=\"tips\">名称</label> <input type=\"text\" id=\"name\" placeholder=\"请输入名称\" class=\"layui-input\"></div></div></div></div><div class=\"layui-row h-all\"><div class=\"layui-col-md2 h-all\"><div class=\"own-left-pannel\"><div id=\"roleTree\" class=\"own-tree\"></div></div></div><div class=\"layui-col-md10\"><div class=\"own-pannel\"><table id=\"tablelist\" lay-filter=\"tablelist\"></table></div></div></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', 'tree', 'util'], function () {\n let $ = layui.jquery;\n let table = layui.table;\n let form = layui.form;\n let tree = layui.tree;\n let util = layui.util;\n\n getRoleTree();\n\n // 加载列表\n table.render({\n elem: '#tablelist',\n url: \"/system/role/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/role/list.templ`, Line: 80, 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 page: true,\n limit: 15,\n limits: [15, 30, 45, 60, 75, 90],\n cols: [[\n { field: 'display_name', title: '显示名称', align: 'left', width: 160, fixed: 'left' },\n { field: 'name', title: '名称', align: 'left', width: 150, fixed: 'left' },\n {\n field: 'status', title: '状态', align: 'center', width: 90, templet: function (row) {\n switch (row.status) {\n case 0: return '正常';\n case -1: return '删除';\n default: return '其它';\n }\n return '';\n }\n },\n { field: 'sort', title: '排序', align: 'center', width: 60 },\n { field: 'created_at', title: '创建时间', align: 'center', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },\n { field: 'updated_at', title: '更新时间', align: 'center', width: 160, templet: function (d) { return !d.updated_at ? '' : util.toDateString(d.updated_at) } },\n { title: '操作', toolbar: '#actionBox', align: 'center', width: 300, fixed: 'right' },\n ]],\n skin: 'grid',\n toolbar: '#toolbar',\n defaultToolbar: [{\n title: '刷新',\n layEvent: 'refresh',\n icon: 'layui-icon-refresh',\n }, 'filter', 'exports'],\n request: {\n pageName: 'page',\n limitName: 'rows'\n }\n });\n\n // 工具栏\n table.on('toolbar(tablelist)', function (obj) {\n switch (obj.event) {\n case 'add': add(); break;\n case 'refresh': table.reload('tablelist'); break;\n case 'refresh_cache': refreshCache(); break;\n case 'rebuild_parent_path': rebuildParentPath(); break;\n case 'search': search(); break;\n }\n });\n\n function add(obj) {\n layer.open({\n type: 2,\n title: '新增',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/role/add\"\n });\n }\n\n function refreshCache() {\n layer.confirm('确定要刷新角色数据吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/role/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/role/list.templ`, Line: 145, 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 dataType: 'json',\n success: function (result) {\n if (result.success) {\n layer.msg(result.msg, { icon: 1, time: 2000 });\n search_btn();\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 rebuildParentPath() {\n layer.confirm('确定要重建父路径吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/role/rebuild_parent_path',\n type: 'post',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/list.templ`, Line: 167, Col: 60}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var7)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "' },\n dataType: 'json',\n success: function (result) {\n if (result.success) {\n layer.msg(result.msg, { icon: 1, time: 2000 });\n search_btn();\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 search() {\n layer.open({\n type: 1,\n offset: '20px',\n title: '搜索',\n content: $('#search-layer'), // 捕获的元素\n shade: 0.1,\n shadeClose: false,\n scrollbar: false,\n resize: false,\n move: false,\n skin: 'search-layer-open',\n area: ['50%', '350px'],\n btn: ['搜索', '重置'],\n btn1: function (index, layero) {\n search_btn();\n layer.close(index);\n },\n btn2: function (index, layero) {\n $('#status').val(0);\n $('#id').val('');\n $('#name').val('');\n $('#parentId').val(0);\n form.render('select');\n return false;\n }\n });\n }\n\n // 表格项操作按钮\n table.on('tool(tablelist)', function (obj) {\n switch (obj.event) {\n case 'edit': edit(obj); break;\n case 'set_menu': setMenu(obj); break;\n case 'refresh_role_menus': refreshRoleMenus(obj); break;\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/role/edit?id=\" + obj.data['id']\n });\n }\n\n function setMenu(obj) {\n layer.open({\n type: 2,\n title: '为 ' + obj.data['display_name'] + ' 分配权限',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/role/set_menu?id=\" + obj.data['id']\n });\n }\n\n function refreshRoleMenus(obj) {\n layer.confirm('确定要刷新角色权限吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/role/refresh_role_menus',\n type: 'post',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/list.templ`, Line: 247, Col: 60}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var8)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "' },\n dataType: 'json',\n data: { \"roleID\": obj.data['id'] },\n success: function (result) {\n if (result.success) {\n layer.msg(result.msg, { icon: 1, time: 2000 });\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 // 搜索条件\n function getQueryParams() {\n return {\n status: $('#status').val(),\n name: $('#name').val(),\n id: $('#id').val(),\n parentId: $('#parentId').val()\n };\n }\n\n // 搜索\n function search_btn() {\n table.reload('tablelist', {\n where: getQueryParams(),\n page: {\n curr: 1\n }\n })\n }\n\n function getRoleTree() {\n $.ajax({\n url: \"/system/role/data?type=tree\",\n type: 'post',\n dataType: 'json',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/list.templ`, Line: 289, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var9)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "' },\n success: function (res) {\n tree.render({\n elem: '#roleTree',\n data: res,\n onlyIconControl: true, // 是否仅允许节点左侧图标控制展开收缩\n showLine: true,\n click: function (obj) {\n // console.log(obj.data); // 得到当前点击的节点数据\n // console.log(obj.state); // 得到当前节点的展开状态:open、close、normal\n // console.log(obj.elem); // 得到当前节点元素\n // console.log(obj.data.children); // 当前节点下是否有子节点\n $('#parentId').val(obj.data.id);\n search_btn();\n }\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
|
||||
Reference in New Issue
Block a user