v2
This commit is contained in:
13
internal/erpserver/templ/component/content.templ
Normal file
13
internal/erpserver/templ/component/content.templ
Normal file
@@ -0,0 +1,13 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"strings"
|
||||
)
|
||||
|
||||
templ Content(str string) {
|
||||
trimSpace(str)
|
||||
}
|
||||
|
||||
func trimSpace(str string) string {
|
||||
return strings.TrimSpace(str)
|
||||
}
|
||||
48
internal/erpserver/templ/component/content_templ.go
Normal file
48
internal/erpserver/templ/component/content_templ.go
Normal file
@@ -0,0 +1,48 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package component
|
||||
|
||||
//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 (
|
||||
"strings"
|
||||
)
|
||||
|
||||
func Content(str string) 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_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "trimSpace(str)")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func trimSpace(str string) string {
|
||||
return strings.TrimSpace(str)
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
25
internal/erpserver/templ/component/time.go
Normal file
25
internal/erpserver/templ/component/time.go
Normal file
@@ -0,0 +1,25 @@
|
||||
package component
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"github.com/a-h/templ"
|
||||
)
|
||||
|
||||
func YearBegin() templ.Component {
|
||||
dt := time.Now()
|
||||
t := dt.AddDate(0, -int(dt.Month())+1, -dt.Day()+1)
|
||||
return templ.Raw(t.Format("2006-01-02") + " 00:00:00")
|
||||
}
|
||||
|
||||
func MonthBegin() string {
|
||||
dt := time.Now()
|
||||
t := dt.AddDate(0, 0, -dt.Day()+1)
|
||||
return t.Format("2006-01-02") + " 00:00:00"
|
||||
}
|
||||
|
||||
func MonthEnd() string {
|
||||
dt := time.Now()
|
||||
t := dt.AddDate(0, 0, -dt.Day()+1).AddDate(0, 1, -1)
|
||||
return t.Format("2006-01-02") + " 23:59:59"
|
||||
}
|
||||
47
internal/erpserver/templ/component/upload.templ
Normal file
47
internal/erpserver/templ/component/upload.templ
Normal file
@@ -0,0 +1,47 @@
|
||||
package component
|
||||
|
||||
templ Upload(avatar string) {
|
||||
<button type="button" class="layui-btn pear-btn-primary" id="upload_img_btn_logo">
|
||||
<i class="layui-icon layui-icon-upload"></i> 上传
|
||||
</button>
|
||||
<div style="width: 132px;">
|
||||
<div class="layui-upload-list">
|
||||
<i class="btn-remove layui-icon layui-icon-clear" id="upload_img_remove_logo" title="删除"></i>
|
||||
<img class="layui-upload-img" id="upload_img_preview_logo">
|
||||
<input type="hidden" id="upload_img_input_logo" name="File" value={ avatar } />
|
||||
<div id="upload_img_tips_logo"></div>
|
||||
</div>
|
||||
|
||||
<div class="layui-progress layui-progress-big" lay-showPercent="yes" lay-filter="upload_img_progress_logo">
|
||||
<div class="layui-progress-bar" lay-percent=""></div>
|
||||
</div>
|
||||
</div>
|
||||
<style>
|
||||
.layui-upload-list {
|
||||
position: relative;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.layui-upload-img {
|
||||
display: none;
|
||||
width: 100%;
|
||||
height: 92px;
|
||||
}
|
||||
|
||||
.layui-upload-list:hover .btn-remove {
|
||||
display: inline-block;
|
||||
}
|
||||
|
||||
.layui-upload-list .btn-remove {
|
||||
display: none;
|
||||
position: absolute;
|
||||
top: -12px;
|
||||
right: -11px;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
font-size: 24px;
|
||||
color: red;
|
||||
cursor: pointer;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
53
internal/erpserver/templ/component/upload_templ.go
Normal file
53
internal/erpserver/templ/component/upload_templ.go
Normal file
@@ -0,0 +1,53 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package component
|
||||
|
||||
//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"
|
||||
|
||||
func Upload(avatar string) 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_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<button type=\"button\" class=\"layui-btn pear-btn-primary\" id=\"upload_img_btn_logo\"><i class=\"layui-icon layui-icon-upload\"></i> 上传</button><div style=\"width: 132px;\"><div class=\"layui-upload-list\"><i class=\"btn-remove layui-icon layui-icon-clear\" id=\"upload_img_remove_logo\" title=\"删除\"></i> <img class=\"layui-upload-img\" id=\"upload_img_preview_logo\"> <input type=\"hidden\" id=\"upload_img_input_logo\" name=\"File\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var2 string
|
||||
templ_7745c5c3_Var2, templ_7745c5c3_Err = templ.JoinStringErrs(avatar)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/component/upload.templ`, Line: 11, Col: 86}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var2))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, "\"><div id=\"upload_img_tips_logo\"></div></div><div class=\"layui-progress layui-progress-big\" lay-showPercent=\"yes\" lay-filter=\"upload_img_progress_logo\"><div class=\"layui-progress-bar\" lay-percent=\"\"></div></div></div><style>\n .layui-upload-list {\n position: relative;\n cursor: pointer;\n }\n\n .layui-upload-img {\n display: none;\n width: 100%;\n height: 92px;\n }\n\n .layui-upload-list:hover .btn-remove {\n display: inline-block;\n }\n\n .layui-upload-list .btn-remove {\n display: none;\n position: absolute;\n top: -12px;\n right: -11px;\n width: 20px;\n height: 20px;\n font-size: 24px;\n color: red;\n cursor: pointer;\n }\n </style>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
195
internal/erpserver/templ/system/auditlog/list.templ
Normal file
195
internal/erpserver/templ/system/auditlog/list.templ
Normal file
@@ -0,0 +1,195 @@
|
||||
package auditlog
|
||||
|
||||
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, component.MonthBegin(), component.MonthEnd())) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
@component.TemplBtn(meuns, true)
|
||||
|
||||
<div class="search-layer" id="search-layer" style="display: none;">
|
||||
<div class="layui-form layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="timeBegin" class="tips">开始时间</label>
|
||||
<input type="text" name="timeBegin" id="timeBegin" placeholder="yyyy-MM-dd" readonly
|
||||
value={ component.MonthBegin() } class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="timeEnd" class="tips">结束时间</label>
|
||||
<input type="text" name="timeEnd" id="timeEnd" placeholder="yyyy-MM-dd" readonly value={ component.MonthEnd() }
|
||||
class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="email" class="tips">邮箱</label>
|
||||
<input type="text" name="email" id="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="username" class="tips">用户名</label>
|
||||
<input type="text" name="username" id="username" placeholder="请输入用户名" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-panel">
|
||||
<table id="tablelist" lay-filter="tablelist"></table>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ listCss() {
|
||||
}
|
||||
|
||||
templ listJs(ctx context.Context, monthBegin, monthEnd string) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'table', 'form', 'laydate', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let laydate = layui.laydate;
|
||||
let util = layui.util;
|
||||
|
||||
/**开始时间 */
|
||||
laydate.render({
|
||||
elem: '#timeBegin',
|
||||
type: 'datetime',
|
||||
value: '{{ monthBegin }}',
|
||||
ready: function (date) {
|
||||
this.dateTime.hours = 0;
|
||||
this.dateTime.minutes = 0;
|
||||
this.dateTime.seconds = 0;
|
||||
}
|
||||
});
|
||||
|
||||
/**截止时间 */
|
||||
laydate.render({
|
||||
elem: '#timeEnd',
|
||||
type: 'datetime',
|
||||
value: '{{ monthEnd }}',
|
||||
ready: function (date) {
|
||||
this.dateTime.hours = 23;
|
||||
this.dateTime.minutes = 59;
|
||||
this.dateTime.seconds = 59;
|
||||
}
|
||||
});
|
||||
|
||||
// 加载列表
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: "/system/audit_log/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: 'email', title: '邮箱', align: 'left', width: 180, fixed: 'left' },
|
||||
// { field: 'username', title: '用户名', align: 'left', width: 100 },
|
||||
{ field: 'created_at', title: '创建时间', align: 'left', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },
|
||||
{ field: 'method', title: '请求方法', align: 'left', width: 90 },
|
||||
{ field: 'parameters', title: '请求参数', align: 'left', width: 120 },
|
||||
{ field: 'url', title: 'URL', align: 'left', width: 300 },
|
||||
{ field: 'start_at', title: '开始时间', align: 'left', width: 160, templet: function (d) { return !d.start_at ? '' : util.toDateString(d.start_at) } },
|
||||
{ field: 'end_at', title: '结束时间', align: 'left', width: 160, templet: function (d) { return !d.end_at ? '' : util.toDateString(d.end_at) } },
|
||||
{ field: 'duration', title: '时间(毫秒)', align: 'left', width: 90 },
|
||||
{ field: 'ip', title: 'ip', align: 'left', width: 150 },
|
||||
{ field: 'browser', title: '浏览器', align: 'left', width: 150 },
|
||||
{ field: 'os', title: '系统', align: 'left', width: 150 },
|
||||
{ field: 'referer_url', title: 'Referer', align: 'left', width: 300 },
|
||||
{ field: 'remark', title: '备注', align: 'left', width: 200 },
|
||||
]],
|
||||
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 'search': search(); break;
|
||||
case 'refresh': refresh(); break;
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
$('#timeBegin').val(formatDate(getCurrentYearStart(), 'YYYY-MM-DD HH:mm:ss'));
|
||||
$('#timeEnd').val(formatDate(getCurrentMonthEnd(), 'YYYY-MM-DD HH:mm:ss'));
|
||||
$('#email').val('');
|
||||
$('#username').val('');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
table.reload('tablelist');
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
function getQueryParams() {
|
||||
return {
|
||||
timeBegin: $('#timeBegin').val(),
|
||||
timeEnd: $('#timeEnd').val(),
|
||||
name: $('#username').val(),
|
||||
email: $('#email').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search_btn() {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
188
internal/erpserver/templ/system/auditlog/list_templ.go
Normal file
188
internal/erpserver/templ/system/auditlog/list_templ.go
Normal file
@@ -0,0 +1,188 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package auditlog
|
||||
|
||||
//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).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, " <div class=\"search-layer\" id=\"search-layer\" style=\"display: none;\"><div class=\"layui-form layui-row\"><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"timeBegin\" class=\"tips\">开始时间</label> <input type=\"text\" name=\"timeBegin\" id=\"timeBegin\" placeholder=\"yyyy-MM-dd\" readonly value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(component.MonthBegin())
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/auditlog/list.templ`, Line: 22, Col: 58}
|
||||
}
|
||||
_, 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, 2, "\" class=\"layui-input\"></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"timeEnd\" class=\"tips\">结束时间</label> <input type=\"text\" name=\"timeEnd\" id=\"timeEnd\" placeholder=\"yyyy-MM-dd\" readonly value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(component.MonthEnd())
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/auditlog/list.templ`, Line: 28, Col: 133}
|
||||
}
|
||||
_, 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, 3, "\" class=\"layui-input\"></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"email\" class=\"tips\">邮箱</label> <input type=\"text\" name=\"email\" id=\"email\" placeholder=\"请输入邮箱\" autocomplete=\"off\" class=\"layui-input\"></div></div></div><div class=\"layui-form layui-row\"><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"username\" class=\"tips\">用户名</label> <input type=\"text\" name=\"username\" id=\"username\" placeholder=\"请输入用户名\" autocomplete=\"off\" class=\"layui-input\"></div></div></div></div><div class=\"layui-panel\"><table 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, component.MonthBegin(), component.MonthEnd())).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_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func listJs(ctx context.Context, monthBegin, monthEnd string) 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_Var6 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var6 == nil {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<script>\n layui.use(['jquery', 'table', 'form', 'laydate', 'util'], function () {\n let $ = layui.jquery;\n let table = layui.table;\n let form = layui.form;\n let laydate = layui.laydate;\n let util = layui.util;\n\n /**开始时间 */\n laydate.render({\n elem: '#timeBegin',\n type: 'datetime',\n value: '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(monthBegin)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/auditlog/list.templ`, Line: 73, Col: 37}
|
||||
}
|
||||
_, 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, 5, "',\n ready: function (date) {\n this.dateTime.hours = 0;\n this.dateTime.minutes = 0;\n this.dateTime.seconds = 0;\n }\n });\n\n /**截止时间 */\n laydate.render({\n elem: '#timeEnd',\n type: 'datetime',\n value: '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(monthEnd)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/auditlog/list.templ`, Line: 85, Col: 35}
|
||||
}
|
||||
_, 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, 6, "',\n ready: function (date) {\n this.dateTime.hours = 23;\n this.dateTime.minutes = 59;\n this.dateTime.seconds = 59;\n }\n });\n\n // 加载列表\n table.render({\n elem: '#tablelist',\n url: \"/system/audit_log/list\",\n method: \"POST\",\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/auditlog/list.templ`, Line: 98, Col: 52}
|
||||
}
|
||||
_, 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, 7, "' },\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: 'email', title: '邮箱', align: 'left', width: 180, fixed: 'left' },\n // { field: 'username', title: '用户名', align: 'left', width: 100 },\n { field: 'created_at', title: '创建时间', align: 'left', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },\n { field: 'method', title: '请求方法', align: 'left', width: 90 },\n { field: 'parameters', title: '请求参数', align: 'left', width: 120 },\n { field: 'url', title: 'URL', align: 'left', width: 300 },\n { field: 'start_at', title: '开始时间', align: 'left', width: 160, templet: function (d) { return !d.start_at ? '' : util.toDateString(d.start_at) } },\n { field: 'end_at', title: '结束时间', align: 'left', width: 160, templet: function (d) { return !d.end_at ? '' : util.toDateString(d.end_at) } },\n { field: 'duration', title: '时间(毫秒)', align: 'left', width: 90 },\n { field: 'ip', title: 'ip', align: 'left', width: 150 },\n { field: 'browser', title: '浏览器', align: 'left', width: 150 },\n { field: 'os', title: '系统', align: 'left', width: 150 },\n { field: 'referer_url', title: 'Referer', align: 'left', width: 300 },\n { field: 'remark', title: '备注', align: 'left', width: 200 },\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 table.on('toolbar(tablelist)', function (obj) {\n switch (obj.event) {\n case 'search': search(); break;\n case 'refresh': refresh(); break;\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 $('#timeBegin').val(formatDate(getCurrentYearStart(), 'YYYY-MM-DD HH:mm:ss'));\n $('#timeEnd').val(formatDate(getCurrentMonthEnd(), 'YYYY-MM-DD HH:mm:ss'));\n $('#email').val('');\n $('#username').val('');\n return false;\n }\n });\n }\n\n function refresh() {\n table.reload('tablelist');\n }\n\n // 搜索条件\n function getQueryParams() {\n return {\n timeBegin: $('#timeBegin').val(),\n timeEnd: $('#timeEnd').val(),\n name: $('#username').val(),\n email: $('#email').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 </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
310
internal/erpserver/templ/system/category/list.templ
Normal file
310
internal/erpserver/templ/system/category/list.templ
Normal file
@@ -0,0 +1,310 @@
|
||||
package category
|
||||
|
||||
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", "rebuild_parent_path")
|
||||
@component.TemplLink(meuns, "add_children", "edit")
|
||||
|
||||
<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="departTree" 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;
|
||||
|
||||
getCategory();
|
||||
|
||||
// 加载列表
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: '/system/category/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: 'id', title: 'ID', align: 'left', width: 80, fixed: 'left' },
|
||||
{ field: 'name', title: '名称', width: 240, fixed: 'left' },
|
||||
{
|
||||
field: 'icon', title: '图标', align: 'center', width: 90, templet: function (d) {
|
||||
if (d.icon === 0 || d.icon === undefined || d.icon === '') { return ''; }
|
||||
return '<img src="' + d.icon + '" width=30 height=30 />';
|
||||
}
|
||||
},
|
||||
{ field: 'letter', title: '标识', width: 180 },
|
||||
{ field: 'description', title: '描述', width: 240 },
|
||||
{
|
||||
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: 'sort', title: '排序', align: 'center', width: 80 },
|
||||
{ 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) } },
|
||||
{ title: '操作', toolbar: '#actionBox', align: 'center', width: 200, 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': refresh(); break;
|
||||
case 'rebuild_parent_path': rebuildParentPath(); break;
|
||||
case 'search': search(); break;
|
||||
}
|
||||
});
|
||||
|
||||
function add() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/category/add"
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
layer.confirm('确定要刷新类别数据吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/category/refresh',
|
||||
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/category/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 'add_children': addChildren(obj); break;
|
||||
case 'edit': edit(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function addChildren(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '为 ' + obj.data['name'] + ' 新增子级',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/category/add_children?parentID=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/category/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
form.on('submit(btn-query)', function (data) {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
function getCategory() {
|
||||
$.ajax({
|
||||
url: "/system/category/data?type=tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
tree.render({
|
||||
elem: '#departTree',
|
||||
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>
|
||||
}
|
||||
182
internal/erpserver/templ/system/category/list_templ.go
Normal file
182
internal/erpserver/templ/system/category/list_templ.go
Normal file
@@ -0,0 +1,182 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package category
|
||||
|
||||
//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", "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, "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=\"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=\"departTree\" 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 getCategory();\n\n // 加载列表\n table.render({\n elem: '#tablelist',\n url: '/system/category/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/category/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: 'id', title: 'ID', align: 'left', width: 80, fixed: 'left' },\n { field: 'name', title: '名称', width: 240, fixed: 'left' },\n {\n field: 'icon', title: '图标', align: 'center', width: 90, templet: function (d) {\n if (d.icon === 0 || d.icon === undefined || d.icon === '') { return ''; }\n return '<img src=\"' + d.icon + '\" width=30 height=30 />';\n }\n },\n { field: 'letter', title: '标识', width: 180 },\n { field: 'description', title: '描述', width: 240 },\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 { field: 'sort', title: '排序', align: 'center', width: 80 },\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 { title: '操作', toolbar: '#actionBox', align: 'center', width: 200, 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': refresh(); break;\n case 'rebuild_parent_path': rebuildParentPath(); break;\n case 'search': search(); break;\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/category/add\"\n });\n }\n\n function refresh() {\n layer.confirm('确定要刷新类别数据吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/category/refresh',\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/category/list.templ`, Line: 154, 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/category/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/category/list.templ`, Line: 176, 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 '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['name'] + ' 新增子级',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/category/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/category/edit?id=\" + obj.data['id']\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 form.on('submit(btn-query)', function (data) {\n table.reload('tablelist', {\n where: getQueryParams(),\n page: {\n curr: 1\n }\n })\n return false;\n });\n\n function getCategory() {\n $.ajax({\n url: \"/system/category/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_Var8, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/category/list.templ`, Line: 285, Col: 56}
|
||||
}
|
||||
_, 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 success: function (res) {\n tree.render({\n elem: '#departTree',\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
|
||||
138
internal/erpserver/templ/system/config/edit.templ
Normal file
138
internal/erpserver/templ/system/config/edit.templ
Normal file
@@ -0,0 +1,138 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
"time"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/pkg/mid"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/erpserver/model/view"
|
||||
)
|
||||
|
||||
templ Edit(ctx context.Context, item *view.EditSysConfig) {
|
||||
@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">
|
||||
<label for="Key" class="layui-form-label">键</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="Key" name="Key" value={ item.Key } lay-verify="required"
|
||||
autocomplete="off" placeholder="请输入存储键" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Value" class="layui-form-label">值</label>
|
||||
<div class="layui-input-inline">
|
||||
<textarea id="Value" name="Value" style="width: 500px;height: 400px;" placeholder="请输入存储值"
|
||||
class="layui-textarea" lay-verify="required">{ item.Result }</textarea>
|
||||
</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 *view.EditSysConfig) {
|
||||
<script>
|
||||
layui.use(['jquery', 'form', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let form = layui.form;
|
||||
let util = layui.util;
|
||||
|
||||
// 事件绑定
|
||||
util.on("lay-on", {
|
||||
"close": function () {
|
||||
window.parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
}
|
||||
});
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/config/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;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
242
internal/erpserver/templ/system/config/edit_templ.go
Normal file
242
internal/erpserver/templ/system/config/edit_templ.go
Normal file
@@ -0,0 +1,242 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package config
|
||||
|
||||
//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/view"
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func Edit(ctx context.Context, item *view.EditSysConfig) 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/config/edit.templ`, Line: 22, 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/config/edit.templ`, Line: 36, Col: 49}
|
||||
}
|
||||
_, 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\"><label for=\"Key\" class=\"layui-form-label\">键</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"Key\" name=\"Key\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(item.Key)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/config/edit.templ`, Line: 43, Col: 95}
|
||||
}
|
||||
_, 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\"><label for=\"Value\" class=\"layui-form-label\">值</label><div class=\"layui-input-inline\"><textarea id=\"Value\" name=\"Value\" style=\"width: 500px;height: 400px;\" placeholder=\"请输入存储值\" class=\"layui-textarea\" lay-verify=\"required\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.Result)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/config/edit.templ`, Line: 51, Col: 102}
|
||||
}
|
||||
_, 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, "</textarea></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, 9, "<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_Var7 string
|
||||
templ_7745c5c3_Var7, 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/config/edit.templ`, Line: 61, Col: 78}
|
||||
}
|
||||
_, 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, 10, "</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_Var8 string
|
||||
templ_7745c5c3_Var8, 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/config/edit.templ`, Line: 67, 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, 11, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "</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, 13, "<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_Var9 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var9 == nil {
|
||||
templ_7745c5c3_Var9 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<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 *view.EditSysConfig) 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, 15, "<script>\n layui.use(['jquery', 'form', 'util'], function () {\n let $ = layui.jquery;\n let form = layui.form;\n let util = layui.util;\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 form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/config/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 </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
200
internal/erpserver/templ/system/config/list.templ
Normal file
200
internal/erpserver/templ/system/config/list.templ
Normal file
@@ -0,0 +1,200 @@
|
||||
package config
|
||||
|
||||
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", "reset_pear")
|
||||
@component.TemplLink(meuns, "edit", "refresh_cache")
|
||||
|
||||
<div class="search-layer" id="search-layer" style="display: none;">
|
||||
<div class="layui-form layui-row">
|
||||
<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" name="name" id="name" placeholder="请输入名称" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-panel">
|
||||
<table 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'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let util = layui.util;
|
||||
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: "/system/config/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: 'key', title: '键', align: 'left', width: 180 },
|
||||
{ field: 'value', title: '值', align: 'left', width: 600 },
|
||||
{ title: '操作', toolbar: '#actionBox', align: 'center', width: 180 },
|
||||
{ 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) } },
|
||||
]],
|
||||
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 'search': search(); break;
|
||||
case 'reset_pear': resetPear(); break;
|
||||
}
|
||||
});
|
||||
|
||||
function add(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/config/add"
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
$('#name').val('');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function resetPear(obj) {
|
||||
layer.confirm('确定要重置pear吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/config/reset_pear',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
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); // 关闭弹窗
|
||||
});
|
||||
}
|
||||
|
||||
table.on('tool(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'edit': edit(obj); break;
|
||||
case 'refresh_cache': refresh_cache(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/config/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_cache(obj) {
|
||||
layer.confirm('确定要刷新数据吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/config/refresh_cache',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
data: { "key": obj.data['key'] },
|
||||
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 {
|
||||
SearchKey: $('#name').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search_btn() {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
170
internal/erpserver/templ/system/config/list_templ.go
Normal file
170
internal/erpserver/templ/system/config/list_templ.go
Normal file
@@ -0,0 +1,170 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package config
|
||||
|
||||
//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", "reset_pear").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", "refresh_cache").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;\"><div class=\"layui-form layui-row\"><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\" name=\"name\" id=\"name\" placeholder=\"请输入名称\" autocomplete=\"off\" class=\"layui-input\"></div></div></div></div><div class=\"layui-panel\"><table 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'], function () {\n let $ = layui.jquery;\n let table = layui.table;\n let form = layui.form;\n let util = layui.util;\n\n table.render({\n elem: '#tablelist',\n url: \"/system/config/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/config/list.templ`, Line: 50, 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: 'key', title: '键', align: 'left', width: 180 },\n { field: 'value', title: '值', align: 'left', width: 600 },\n { title: '操作', toolbar: '#actionBox', align: 'center', width: 180 },\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 ]],\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 table.on('toolbar(tablelist)', function (obj) {\n switch (obj.event) {\n case 'add': add(); break;\n case 'search': search(); break;\n case 'reset_pear': resetPear(); 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/config/add\"\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 $('#name').val('');\n return false;\n }\n });\n }\n\n function resetPear(obj) {\n layer.confirm('确定要重置pear吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/config/reset_pear',\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/config/list.templ`, Line: 126, 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 } 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 table.on('tool(tablelist)', function (obj) {\n switch (obj.event) {\n case 'edit': edit(obj); break;\n case 'refresh_cache': refresh_cache(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/config/edit?id=\" + obj.data['id']\n });\n }\n\n function refresh_cache(obj) {\n layer.confirm('确定要刷新数据吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/config/refresh_cache',\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/config/list.templ`, Line: 164, 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 data: { \"key\": obj.data['key'] },\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 SearchKey: $('#name').val()\n };\n }\n\n // 搜索\n function search_btn() {\n table.reload('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
|
||||
203
internal/erpserver/templ/system/department/edit.templ
Normal file
203
internal/erpserver/templ/system/department/edit.templ
Normal file
@@ -0,0 +1,203 @@
|
||||
package department
|
||||
|
||||
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.Department) {
|
||||
@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">
|
||||
<label class="layui-form-label">上级</label>
|
||||
<div class="layui-input-inline" style="width:300px;">
|
||||
<ul id="departTree" class="dtree organizationTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label for="name" class="layui-form-label">名称</label>
|
||||
<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">
|
||||
<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 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>
|
||||
|
||||
<!-- 其它 -->
|
||||
<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.Department) {
|
||||
{{ 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;
|
||||
|
||||
getDepartmentTree();
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/department/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 getDepartmentTree() {
|
||||
$.ajax({
|
||||
url: "/system/department/data?type=xm_select_tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
xmSelect.render({
|
||||
el: '#departTree',
|
||||
// 工具栏
|
||||
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>
|
||||
}
|
||||
282
internal/erpserver/templ/system/department/edit_templ.go
Normal file
282
internal/erpserver/templ/system/department/edit_templ.go
Normal file
@@ -0,0 +1,282 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package department
|
||||
|
||||
//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.Department) 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/department/edit.templ`, Line: 21, Col: 75}
|
||||
}
|
||||
_, 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/department/edit.templ`, Line: 36, Col: 49}
|
||||
}
|
||||
_, 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\"><label class=\"layui-form-label\">上级</label><div class=\"layui-input-inline\" style=\"width:300px;\"><ul id=\"departTree\" class=\"dtree organizationTree\"></ul></div></div><div class=\"layui-form-item\"><label for=\"name\" class=\"layui-form-label\">名称</label><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/department/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\"><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, 8, "<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, 9, "<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, 10, "</select></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_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.Sort)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/department/edit.templ`, Line: 74, Col: 100}
|
||||
}
|
||||
_, 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, 11, "\" 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, 12, "<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_Var7 string
|
||||
templ_7745c5c3_Var7, 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/department/edit.templ`, Line: 86, Col: 78}
|
||||
}
|
||||
_, 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, 13, "</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_Var8 string
|
||||
templ_7745c5c3_Var8, 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/department/edit.templ`, Line: 92, 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>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "</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, 16, "<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_Var9 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var9 == nil {
|
||||
templ_7745c5c3_Var9 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<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.Department) 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)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "<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 getDepartmentTree();\n\n // 表单提交\n form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/department/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 getDepartmentTree() {\n $.ajax({\n url: \"/system/department/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_Var11, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/department/edit.templ`, Line: 170, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var11)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "' },\n success: function (res) {\n xmSelect.render({\n el: '#departTree',\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_Var12, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.ParentID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/department/edit.templ`, Line: 184, Col: 57}
|
||||
}
|
||||
_, 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 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
|
||||
301
internal/erpserver/templ/system/department/list.templ
Normal file
301
internal/erpserver/templ/system/department/list.templ
Normal file
@@ -0,0 +1,301 @@
|
||||
package department
|
||||
|
||||
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, "add_children", "edit")
|
||||
|
||||
<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="departmentTree" 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;
|
||||
|
||||
getDepartmentTree();
|
||||
|
||||
// 加载列表
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: '/system/department/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: 'id', title: '编号', width: 60, fixed: 'left' },
|
||||
{ field: 'name', title: '名称', width: 240, fixed: 'left' },
|
||||
{
|
||||
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 '其它';
|
||||
}
|
||||
}
|
||||
},
|
||||
{ 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) } },
|
||||
{ title: '操作', toolbar: '#actionBox', align: 'center', width: 200, 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': refresh_cache(); break;
|
||||
case 'rebuild_parent_path': rebuildParentPath(); break;
|
||||
case 'search': search(); break;
|
||||
}
|
||||
});
|
||||
|
||||
function add() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增部门',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/department/add"
|
||||
});
|
||||
}
|
||||
|
||||
function refresh_cache() {
|
||||
layer.confirm('确定要刷新部门缓存数据吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/department/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/department/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 'add_children': addChildren(obj); break;
|
||||
case 'edit': edit(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function addChildren(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '为 ' + obj.data['Name'] + ' 新增子级',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/department/add_children?parentID=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/department/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
form.on('submit(btn-query)', function (data) {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
function getDepartmentTree() {
|
||||
$.ajax({
|
||||
url: "/system/department/data?type=tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
tree.render({
|
||||
elem: '#departmentTree',
|
||||
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>
|
||||
}
|
||||
182
internal/erpserver/templ/system/department/list_templ.go
Normal file
182
internal/erpserver/templ/system/department/list_templ.go
Normal file
@@ -0,0 +1,182 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package department
|
||||
|
||||
//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, "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=\"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=\"departmentTree\" 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 getDepartmentTree();\n\n // 加载列表\n table.render({\n elem: '#tablelist',\n url: '/system/department/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/department/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: 'id', title: '编号', width: 60, fixed: 'left' },\n { field: 'name', title: '名称', width: 240, fixed: 'left' },\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 }\n },\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 { title: '操作', toolbar: '#actionBox', align: 'center', width: 200, 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': refresh_cache(); break;\n case 'rebuild_parent_path': rebuildParentPath(); break;\n case 'search': search(); break;\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/department/add\"\n });\n }\n\n function refresh_cache() {\n layer.confirm('确定要刷新部门缓存数据吗?', { title: '提示' }, function (index, layero) {\n $.ajax({\n url: '/system/department/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/department/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/department/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/department/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 '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['Name'] + ' 新增子级',\n shade: 0.1,\n area: ['99%', '98%'],\n content: \"/system/department/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/department/edit?id=\" + obj.data['id']\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 form.on('submit(btn-query)', function (data) {\n table.reload('tablelist', {\n where: getQueryParams(),\n page: {\n curr: 1\n }\n })\n return false;\n });\n\n function getDepartmentTree() {\n $.ajax({\n url: \"/system/department/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_Var8, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/department/list.templ`, Line: 276, Col: 56}
|
||||
}
|
||||
_, 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 success: function (res) {\n tree.render({\n elem: '#departmentTree',\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
|
||||
187
internal/erpserver/templ/system/loginlog/list.templ
Normal file
187
internal/erpserver/templ/system/loginlog/list.templ
Normal file
@@ -0,0 +1,187 @@
|
||||
package loginlog
|
||||
|
||||
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, component.MonthBegin(), component.MonthEnd())) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
@component.TemplBtn(meuns, true)
|
||||
|
||||
<div class="search-layer" id="search-layer" style="display: none;">
|
||||
<div class="layui-form layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="timeBegin" class="tips">开始时间</label>
|
||||
<input type="text" name="timeBegin" id="timeBegin" placeholder="yyyy-MM-dd" readonly
|
||||
value={ component.MonthBegin() } class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="timeEnd" class="tips">结束时间</label>
|
||||
<input type="text" name="timeEnd" id="timeEnd" placeholder="yyyy-MM-dd" readonly value={ component.MonthEnd() }
|
||||
class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="email" class="tips">邮箱</label>
|
||||
<input type="text" name="email" id="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-panel">
|
||||
<table id="tablelist" lay-filter="tablelist"></table>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ listCss() {
|
||||
}
|
||||
|
||||
templ listJs(ctx context.Context, monthBegin, monthEnd string) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['jquery', 'table', 'form', 'laydate', 'util'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let laydate = layui.laydate;
|
||||
let util = layui.util;
|
||||
|
||||
/**开始时间 */
|
||||
laydate.render({
|
||||
elem: '#timeBegin',
|
||||
type: 'datetime',
|
||||
value: '{{ monthBegin }}',
|
||||
ready: function (date) {
|
||||
this.dateTime.hours = 0;
|
||||
this.dateTime.minutes = 0;
|
||||
this.dateTime.seconds = 0;
|
||||
}
|
||||
});
|
||||
|
||||
/**截止时间 */
|
||||
laydate.render({
|
||||
elem: '#timeEnd',
|
||||
type: 'datetime',
|
||||
value: '{{ monthEnd }}',
|
||||
ready: function (date) {
|
||||
this.dateTime.hours = 23;
|
||||
this.dateTime.minutes = 59;
|
||||
this.dateTime.seconds = 59;
|
||||
}
|
||||
});
|
||||
|
||||
// 加载列表
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: "/system/login_log/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: 'email', title: '邮箱', align: 'left', width: 180, fixed: 'left' },
|
||||
// { field: 'username', title: '用户名', align: 'left', width: 100 },
|
||||
{ field: 'created_at', title: '创建时间', align: 'left', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },
|
||||
{
|
||||
field: 'is_success', title: '成功?', align: 'center', width: 80, templet: function (d) {
|
||||
if (d.is_success) {
|
||||
return "是";
|
||||
}
|
||||
return "否";
|
||||
}
|
||||
},
|
||||
{ field: 'message', title: '消息', align: 'left', width: 200 },
|
||||
{ field: 'ip', title: 'ip', align: 'left', width: 150 },
|
||||
{ field: 'browser', title: '浏览器', align: 'left', width: 150 },
|
||||
{ field: 'os', title: '系统', align: 'left', width: 150 },
|
||||
{ field: 'url', title: 'URL', align: 'left', width: 200 },
|
||||
{ field: 'referer_url', title: 'Referer', align: 'left', width: 300 },
|
||||
]],
|
||||
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 'search': search(); break;
|
||||
case 'refresh': refresh(); break;
|
||||
}
|
||||
});
|
||||
|
||||
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) {
|
||||
$('#timeBegin').val(formatDate(getCurrentYearStart(), 'YYYY-MM-DD HH:mm:ss'));
|
||||
$('#timeEnd').val(formatDate(getCurrentMonthEnd(), 'YYYY-MM-DD HH:mm:ss'));
|
||||
$('#email').val('');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
table.reload('tablelist');
|
||||
}
|
||||
|
||||
// 搜索条件
|
||||
function getQueryParams() {
|
||||
return {
|
||||
timeBegin: $('#timeBegin').val(),
|
||||
timeEnd: $('#timeEnd').val(),
|
||||
email: $('#email').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search_btn() {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
188
internal/erpserver/templ/system/loginlog/list_templ.go
Normal file
188
internal/erpserver/templ/system/loginlog/list_templ.go
Normal file
@@ -0,0 +1,188 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package loginlog
|
||||
|
||||
//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).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, " <div class=\"search-layer\" id=\"search-layer\" style=\"display: none;\"><div class=\"layui-form layui-row\"><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"timeBegin\" class=\"tips\">开始时间</label> <input type=\"text\" name=\"timeBegin\" id=\"timeBegin\" placeholder=\"yyyy-MM-dd\" readonly value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var3 string
|
||||
templ_7745c5c3_Var3, templ_7745c5c3_Err = templ.JoinStringErrs(component.MonthBegin())
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/loginlog/list.templ`, Line: 22, Col: 58}
|
||||
}
|
||||
_, 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, 2, "\" class=\"layui-input\"></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"timeEnd\" class=\"tips\">结束时间</label> <input type=\"text\" name=\"timeEnd\" id=\"timeEnd\" placeholder=\"yyyy-MM-dd\" readonly value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(component.MonthEnd())
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/loginlog/list.templ`, Line: 28, Col: 133}
|
||||
}
|
||||
_, 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, 3, "\" class=\"layui-input\"></div></div><div class=\"layui-col-xs12 layui-col-sm12 layui-col-md4\"><div class=\"layui-form-column\"><label for=\"email\" class=\"tips\">邮箱</label> <input type=\"text\" name=\"email\" id=\"email\" placeholder=\"请输入邮箱\" autocomplete=\"off\" class=\"layui-input\"></div></div></div></div><div class=\"layui-panel\"><table 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, component.MonthBegin(), component.MonthEnd())).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_Var5 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var5 == nil {
|
||||
templ_7745c5c3_Var5 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func listJs(ctx context.Context, monthBegin, monthEnd string) 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_Var6 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var6 == nil {
|
||||
templ_7745c5c3_Var6 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<script>\n layui.use(['jquery', 'table', 'form', 'laydate', 'util'], function () {\n let $ = layui.jquery;\n let table = layui.table;\n let form = layui.form;\n let laydate = layui.laydate;\n let util = layui.util;\n\n /**开始时间 */\n laydate.render({\n elem: '#timeBegin',\n type: 'datetime',\n value: '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(monthBegin)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/loginlog/list.templ`, Line: 64, Col: 37}
|
||||
}
|
||||
_, 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, 5, "',\n ready: function (date) {\n this.dateTime.hours = 0;\n this.dateTime.minutes = 0;\n this.dateTime.seconds = 0;\n }\n });\n\n /**截止时间 */\n laydate.render({\n elem: '#timeEnd',\n type: 'datetime',\n value: '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(monthEnd)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/loginlog/list.templ`, Line: 76, Col: 35}
|
||||
}
|
||||
_, 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, 6, "',\n ready: function (date) {\n this.dateTime.hours = 23;\n this.dateTime.minutes = 59;\n this.dateTime.seconds = 59;\n }\n });\n\n // 加载列表\n table.render({\n elem: '#tablelist',\n url: \"/system/login_log/list\",\n method: \"POST\",\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/loginlog/list.templ`, Line: 89, Col: 52}
|
||||
}
|
||||
_, 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, 7, "' },\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: 'email', title: '邮箱', align: 'left', width: 180, fixed: 'left' },\n // { field: 'username', title: '用户名', align: 'left', width: 100 },\n { field: 'created_at', title: '创建时间', align: 'left', width: 160, templet: function (d) { return !d.created_at ? '' : util.toDateString(d.created_at) } },\n {\n field: 'is_success', title: '成功?', align: 'center', width: 80, templet: function (d) {\n if (d.is_success) {\n return \"是\";\n }\n return \"否\";\n }\n },\n { field: 'message', title: '消息', align: 'left', width: 200 },\n { field: 'ip', title: 'ip', align: 'left', width: 150 },\n { field: 'browser', title: '浏览器', align: 'left', width: 150 },\n { field: 'os', title: '系统', align: 'left', width: 150 },\n { field: 'url', title: 'URL', align: 'left', width: 200 },\n { field: 'referer_url', title: 'Referer', align: 'left', width: 300 },\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 table.on('toolbar(tablelist)', function (obj) {\n switch (obj.event) {\n case 'search': search(); break;\n case 'refresh': refresh(); break;\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 $('#timeBegin').val(formatDate(getCurrentYearStart(), 'YYYY-MM-DD HH:mm:ss'));\n $('#timeEnd').val(formatDate(getCurrentMonthEnd(), 'YYYY-MM-DD HH:mm:ss'));\n $('#email').val('');\n return false;\n }\n });\n }\n\n function refresh() {\n table.reload('tablelist');\n }\n\n // 搜索条件\n function getQueryParams() {\n return {\n timeBegin: $('#timeBegin').val(),\n timeEnd: $('#timeEnd').val(),\n email: $('#email').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 </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
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
|
||||
@@ -39,14 +39,14 @@ templ Edit(ctx context.Context, item *system.Role) {
|
||||
}
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">上级</div>
|
||||
<label class="layui-form-label">上级</label>
|
||||
<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>
|
||||
<label for="name" class="layui-form-label">名称</label>
|
||||
<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" />
|
||||
@@ -54,7 +54,7 @@ templ Edit(ctx context.Context, item *system.Role) {
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">显示名称</div>
|
||||
<label for="display_name" class="layui-form-label">显示名称</label>
|
||||
<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="请输入显示名称"
|
||||
@@ -63,7 +63,7 @@ templ Edit(ctx context.Context, item *system.Role) {
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">状态标识</label>
|
||||
<label for="status" class="layui-form-label">状态标识</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="status" name="status">
|
||||
if item.Status == 0 {
|
||||
@@ -78,7 +78,7 @@ templ Edit(ctx context.Context, item *system.Role) {
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">排序</label>
|
||||
<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" />
|
||||
@@ -90,13 +90,13 @@ templ Edit(ctx context.Context, item *system.Role) {
|
||||
<div class="layui-tab-item">
|
||||
if item.ID > 0 {
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-form-label">创建时间</div>
|
||||
<label class="layui-form-label">创建时间</label>
|
||||
<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>
|
||||
<label class="layui-form-label">更新时间</label>
|
||||
<div class="layui-form-label" style="width:400px;text-align:left;">
|
||||
{ item.UpdatedAt.Format(time.DateTime) }
|
||||
</div>
|
||||
|
||||
@@ -97,7 +97,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 6, "<div class=\"layui-form-item\"><label class=\"layui-form-label\">上级</label><div class=\"layui-input-inline\" style=\"width:300px;\"><ul id=\"roleTree\" class=\"dtree organizationTree\"></ul></div></div><div class=\"layui-form-item\"><label for=\"name\" class=\"layui-form-label\">名称</label><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
|
||||
}
|
||||
@@ -110,7 +110,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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=\"")
|
||||
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\"><label for=\"display_name\" class=\"layui-form-label\">显示名称</label><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
|
||||
}
|
||||
@@ -123,7 +123,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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\">")
|
||||
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 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
|
||||
}
|
||||
@@ -138,7 +138,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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=\"")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</select></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
|
||||
}
|
||||
@@ -156,7 +156,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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;\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<div class=\"layui-form-item\"><label class=\"layui-form-label\">创建时间</label><div class=\"layui-form-label\" style=\"width:400px;text-align:left;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
@@ -169,7 +169,7 @@ func Edit(ctx context.Context, item *system.Role) templ.Component {
|
||||
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;\">")
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">更新时间</label><div class=\"layui-form-label\" style=\"width:400px;text-align:left;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
|
||||
147
internal/erpserver/templ/system/role/setmenu.templ
Normal file
147
internal/erpserver/templ/system/role/setmenu.templ
Normal file
@@ -0,0 +1,147 @@
|
||||
package role
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/pkg/mid"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/erpserver/model/view"
|
||||
)
|
||||
|
||||
templ SetMenu(ctx context.Context, item *view.SetMenuView) {
|
||||
@base.Base(ctx, setMenuCss(), setMenuJs(ctx)) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
|
||||
if item.Role.ID == 0 {
|
||||
<h3>角色数据错误, 请刷新重试</h3>
|
||||
return
|
||||
}
|
||||
|
||||
<div class="layui-body layui-bg-white">
|
||||
<form class="layui-form">
|
||||
<input type="hidden" name="ID" value={ item.Role.ID } />
|
||||
if len(item.Menus) > 0 {
|
||||
<div class="layui-collapse" lay-accordion>
|
||||
for _, menu := range item.Menus {
|
||||
<div class="layui-colla-item">
|
||||
<div class="layui-colla-title">{ menu.Name }({ menu.Link })</div>
|
||||
<div class="layui-colla-content">
|
||||
if len(menu.Items) > 0 {
|
||||
<div class="layui-collapse" lay-accordion>
|
||||
for _, menu1 := range menu.Items {
|
||||
<div class="layui-colla-item">
|
||||
<div class="layui-colla-title">{ menu1.Name }({ menu1.Link })</div>
|
||||
<div class="layui-colla-content">
|
||||
if len(menu1.Items) > 0 {
|
||||
<div class="layui-collapse" lay-accordion>
|
||||
for _, menu2 := range menu1.Items {
|
||||
<div class="layui-colla-item">
|
||||
<div class="layui-colla-title">{ menu2.Name }({ menu2.Link })</div>
|
||||
<div class="layui-colla-content">
|
||||
if len(menu2.Items) > 0 {
|
||||
<div class="layui-form">
|
||||
for _, menu3 := range menu2.Items {
|
||||
if menu3.IsSelect {
|
||||
<input type="checkbox" name="menus" value={ menu3.ID } lay-text={ menu3.Name }
|
||||
checked>
|
||||
} else {
|
||||
<input type="checkbox" name="menus" value={ menu3.ID }
|
||||
lay-text={ menu3.Name }>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
<div class="layui-form-item" style="margin-top:10px;">
|
||||
@component.SubmitBtn(meuns, "set_menu")
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ setMenuCss() {
|
||||
<style>
|
||||
.layui-body {
|
||||
padding: 15px;
|
||||
left: 0;
|
||||
}
|
||||
|
||||
.layui-bg-white {
|
||||
background-color: #ffffff;
|
||||
}
|
||||
|
||||
.layui-colla-content {
|
||||
padding: 10px 15px;
|
||||
}
|
||||
|
||||
.layui-collapse {
|
||||
margin-bottom: 0;
|
||||
}
|
||||
</style>
|
||||
}
|
||||
|
||||
templ setMenuJs(ctx context.Context) {
|
||||
{{ token := mid.GetCsrfToken(ctx) }}
|
||||
<script>
|
||||
layui.use(['form', 'jquery', 'iconPicker'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let iconPicker = layui.iconPicker;
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(set_menu)', function (data) {
|
||||
|
||||
// 获取checkbox数据,拼接成字符串!!!!!!
|
||||
var menus = "";
|
||||
var r = document.getElementsByName("menus");
|
||||
for (var i = 0; i < r.length; i++) {
|
||||
if (r[i].checked) {
|
||||
menus += "," + r[i].value;
|
||||
}
|
||||
}
|
||||
if (menus.length > 0) {
|
||||
menus = menus.substring(1);
|
||||
}
|
||||
data.field.roleMenu = menus;
|
||||
|
||||
$.ajax({
|
||||
url: '/system/role/set_menu',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
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;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
383
internal/erpserver/templ/system/role/setmenu_templ.go
Normal file
383
internal/erpserver/templ/system/role/setmenu_templ.go
Normal file
@@ -0,0 +1,383 @@
|
||||
// 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/model/view"
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func SetMenu(ctx context.Context, item *view.SetMenuView) 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)
|
||||
if item.Role.ID == 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "<h3>角色数据错误, 请刷新重试</h3>return")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 2, " <div class=\"layui-body layui-bg-white\"><form class=\"layui-form\"><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.Role.ID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 23, Col: 67}
|
||||
}
|
||||
_, 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, "\"> ")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(item.Menus) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 4, "<div class=\"layui-collapse\" lay-accordion>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, menu := range item.Menus {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 5, "<div class=\"layui-colla-item\"><div class=\"layui-colla-title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(menu.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 28, Col: 70}
|
||||
}
|
||||
_, 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, 6, "(")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(menu.Link)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 28, Col: 84}
|
||||
}
|
||||
_, 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, ")</div><div class=\"layui-colla-content\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(menu.Items) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 8, "<div class=\"layui-collapse\" lay-accordion>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, menu1 := range menu.Items {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<div class=\"layui-colla-item\"><div class=\"layui-colla-title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(menu1.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 34, Col: 83}
|
||||
}
|
||||
_, 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, "(")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(menu1.Link)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 34, Col: 98}
|
||||
}
|
||||
_, 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, ")</div><div class=\"layui-colla-content\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(menu1.Items) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 12, "<div class=\"layui-collapse\" lay-accordion>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, menu2 := range menu1.Items {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "<div class=\"layui-colla-item\"><div class=\"layui-colla-title\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(menu2.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 40, Col: 95}
|
||||
}
|
||||
_, 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, "(")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(menu2.Link)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 40, Col: 110}
|
||||
}
|
||||
_, 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 class=\"layui-colla-content\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if len(menu2.Items) > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<div class=\"layui-form\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
for _, menu3 := range menu2.Items {
|
||||
if menu3.IsSelect {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<input type=\"checkbox\" name=\"menus\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var10 string
|
||||
templ_7745c5c3_Var10, templ_7745c5c3_Err = templ.JoinStringErrs(menu3.ID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 46, Col: 116}
|
||||
}
|
||||
_, 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, 18, "\" lay-text=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var11 string
|
||||
templ_7745c5c3_Var11, templ_7745c5c3_Err = templ.JoinStringErrs(menu3.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 46, Col: 140}
|
||||
}
|
||||
_, 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, 19, "\" checked>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<input type=\"checkbox\" name=\"menus\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var12 string
|
||||
templ_7745c5c3_Var12, templ_7745c5c3_Err = templ.JoinStringErrs(menu3.ID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 49, Col: 116}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var12))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "\" lay-text=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var13 string
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err = templ.JoinStringErrs(menu3.Name)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 50, Col: 89}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var13))
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "</div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "<div class=\"layui-form-item\" style=\"margin-top:10px;\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = component.SubmitBtn(meuns, "set_menu").Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "</div></form></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = base.Base(ctx, setMenuCss(), setMenuJs(ctx)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func setMenuCss() 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_Var14 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var14 == nil {
|
||||
templ_7745c5c3_Var14 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "<style>\n .layui-body {\n padding: 15px;\n left: 0;\n }\n\n .layui-bg-white {\n background-color: #ffffff;\n }\n\n .layui-colla-content {\n padding: 10px 15px;\n }\n\n .layui-collapse {\n margin-bottom: 0;\n }\n </style>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func setMenuJs(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_Var15 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var15 == nil {
|
||||
templ_7745c5c3_Var15 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
token := mid.GetCsrfToken(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 33, "<script>\n layui.use(['form', 'jquery', 'iconPicker'], function () {\n let form = layui.form;\n let $ = layui.jquery;\n let iconPicker = layui.iconPicker;\n\n // 表单提交\n form.on('submit(set_menu)', function (data) {\n\n // 获取checkbox数据,拼接成字符串!!!!!!\n var menus = \"\";\n var r = document.getElementsByName(\"menus\");\n for (var i = 0; i < r.length; i++) {\n if (r[i].checked) {\n menus += \",\" + r[i].value;\n }\n }\n if (menus.length > 0) {\n menus = menus.substring(1);\n }\n data.field.roleMenu = menus;\n\n $.ajax({\n url: '/system/role/set_menu',\n type: 'post',\n headers: { 'X-CSRF-Token': '")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var16, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/role/setmenu.templ`, Line: 126, Col: 56}
|
||||
}
|
||||
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ_7745c5c3_Var16)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 34, "' },\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 </script>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
var _ = templruntime.GeneratedTemplate
|
||||
289
internal/erpserver/templ/system/user/edit.templ
Normal file
289
internal/erpserver/templ/system/user/edit.templ
Normal file
@@ -0,0 +1,289 @@
|
||||
package user
|
||||
|
||||
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.User) {
|
||||
@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">
|
||||
<label for="email" class="layui-form-label">邮箱</label>
|
||||
<div class="layui-input-inline">
|
||||
if item.ID > 0 {
|
||||
<input type="text" id="email" name="email" value={ item.Email } lay-verify="required"
|
||||
autocomplete="off" readonly placeholder="请输入邮箱" class="layui-input" />
|
||||
} else {
|
||||
<input type="text" id="email" name="email" value={ item.Email } 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;">
|
||||
<ul id="departTree" 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;">
|
||||
<ul id="roleTree" class="dtree organizationTree"></ul>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="username" class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="username" name="username" value={ item.Username }
|
||||
lay-verify="required" autocomplete="off" placeholder="请输入用户名" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="password" class="layui-form-label">密码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="text" id="password" name="password" lay-verify="required"
|
||||
value="" autocomplete="off" placeholder="请输入密码"
|
||||
class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">修改密码</label>
|
||||
<div class="layui-input-inline">
|
||||
<input type="checkbox" name="change_password" lay-skin="switch" lay-text="是|否"
|
||||
title="是|否">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-inline">
|
||||
@component.Upload(item.Avatar)
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="gender" class="layui-form-label">性别</label>
|
||||
<div class="layui-input-inline">
|
||||
<select id="gender" name="gender">
|
||||
if item.Gender == 0 {
|
||||
<option value="0" selected>未知</option>
|
||||
<option value="1">男</option>
|
||||
<option value="2">女</option>
|
||||
} else if item.Gender == 1 {
|
||||
<option value="0">未知</option>
|
||||
<option value="1" selected>男</option>
|
||||
<option value="2">女</option>
|
||||
} else if item.Gender == 2 {
|
||||
<option value="0">未知</option>
|
||||
<option value="1">男</option>
|
||||
<option value="2" selected>女</option>
|
||||
}
|
||||
</select>
|
||||
</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.User) {
|
||||
{{ 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;
|
||||
|
||||
getDepartmentTree();
|
||||
getRoleTree();
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/user/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 getDepartmentTree() {
|
||||
$.ajax({
|
||||
url: "/system/department/data?type=xm_select_tree",
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
success: function (res) {
|
||||
xmSelect.render({
|
||||
el: '#departTree',
|
||||
// 工具栏
|
||||
toolbar: {
|
||||
show: true
|
||||
},
|
||||
radio: true,
|
||||
clickClose: true,
|
||||
tips: '请选择部门',
|
||||
filterable: true,
|
||||
data: res,
|
||||
name: 'department_id',
|
||||
initValue: ['{{ item.DepartmentID }}'],
|
||||
tree: {
|
||||
show: true,
|
||||
//非严格模式
|
||||
strict: false,
|
||||
//默认展开节点的数组, 为 true 时, 展开所有节点
|
||||
expandedKeys: [1],
|
||||
},
|
||||
on: function (data) { },
|
||||
});
|
||||
},
|
||||
error: function (err) {
|
||||
// 处理请求错误
|
||||
console.log('请求出错:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
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: 'role_id',
|
||||
initValue: ['{{ item.RoleID }}'],
|
||||
tree: {
|
||||
show: true,
|
||||
//非严格模式
|
||||
strict: false,
|
||||
//默认展开节点的数组, 为 true 时, 展开所有节点
|
||||
expandedKeys: [1],
|
||||
},
|
||||
on: function (data) { },
|
||||
});
|
||||
},
|
||||
error: function (err) {
|
||||
// 处理请求错误
|
||||
console.log('请求出错:', err);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
362
internal/erpserver/templ/system/user/edit_templ.go
Normal file
362
internal/erpserver/templ/system/user/edit_templ.go
Normal file
@@ -0,0 +1,362 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package user
|
||||
|
||||
//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.User) 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/user/edit.templ`, Line: 22, 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/user/edit.templ`, Line: 36, Col: 49}
|
||||
}
|
||||
_, 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\"><label for=\"email\" class=\"layui-form-label\">邮箱</label><div class=\"layui-input-inline\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.ID > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<input type=\"text\" id=\"email\" name=\"email\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(item.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 44, Col: 101}
|
||||
}
|
||||
_, 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, 8, "\" lay-verify=\"required\" autocomplete=\"off\" readonly placeholder=\"请输入邮箱\" class=\"layui-input\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<input type=\"text\" id=\"email\" name=\"email\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 47, Col: 101}
|
||||
}
|
||||
_, 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, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入邮箱\" class=\"layui-input\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div></div><div class=\"layui-form-item\"><div class=\"layui-form-label\">部门</div><div class=\"layui-input-inline\" style=\"width:300px;\"><ul id=\"departTree\" 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;\"><ul id=\"roleTree\" class=\"dtree organizationTree\"></ul></div></div><div class=\"layui-form-item\"><label for=\"username\" class=\"layui-form-label\">用户名</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"username\" name=\"username\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(item.Username)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 67, Col: 110}
|
||||
}
|
||||
_, 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-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入用户名\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"password\" class=\"layui-form-label\">密码</label><div class=\"layui-input-inline\"><input type=\"text\" id=\"password\" name=\"password\" lay-verify=\"required\" value=\"\" autocomplete=\"off\" placeholder=\"请输入密码\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">修改密码</label><div class=\"layui-input-inline\"><input type=\"checkbox\" name=\"change_password\" lay-skin=\"switch\" lay-text=\"是|否\" title=\"是|否\"></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
|
||||
}
|
||||
templ_7745c5c3_Err = component.Upload(item.Avatar).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div></div><div class=\"layui-form-item\"><label for=\"gender\" class=\"layui-form-label\">性别</label><div class=\"layui-input-inline\"><select id=\"gender\" name=\"gender\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.Gender == 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<option value=\"0\" selected>未知</option> <option value=\"1\">男</option> <option value=\"2\">女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Gender == 1 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<option value=\"0\">未知</option> <option value=\"1\" selected>男</option> <option value=\"2\">女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Gender == 2 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<option value=\"0\">未知</option> <option value=\"1\">男</option> <option value=\"2\" selected>女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</select></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, 18, "<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, 19, "<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, 20, "</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, 21, "<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/user/edit.templ`, Line: 133, 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, 22, "</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/user/edit.templ`, Line: 139, 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, 23, "</div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 24, "</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, 25, "<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, 26, "<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.User) 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, 27, "<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 getDepartmentTree();\n getRoleTree();\n\n // 表单提交\n form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/user/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 getDepartmentTree() {\n $.ajax({\n url: \"/system/department/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/user/edit.templ`, Line: 219, 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, 28, "' },\n success: function (res) {\n xmSelect.render({\n el: '#departTree',\n // 工具栏\n toolbar: {\n show: true\n },\n radio: true,\n clickClose: true,\n tips: '请选择部门',\n filterable: true,\n data: res,\n name: 'department_id',\n initValue: ['")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var13, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.DepartmentID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 233, Col: 61}
|
||||
}
|
||||
_, 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, 29, "'],\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 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_Var14, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 256, 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: '#roleTree',\n // 工具栏\n toolbar: {\n show: true\n },\n radio: true,\n clickClose: true,\n tips: '请选择角色',\n filterable: true,\n data: res,\n name: 'role_id',\n initValue: ['")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Var15, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.RoleID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 270, Col: 55}
|
||||
}
|
||||
_, 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
|
||||
256
internal/erpserver/templ/system/user/list.templ
Normal file
256
internal/erpserver/templ/system/user/list.templ
Normal file
@@ -0,0 +1,256 @@
|
||||
package user
|
||||
|
||||
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")
|
||||
@component.TemplLink(meuns, "edit")
|
||||
|
||||
<div class="search-layer" id="search-layer" style="display: none;">
|
||||
<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 name="status" 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" name="id" id="id" placeholder="请输入编号" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="email" class="tips">邮箱</label>
|
||||
<input type="text" name="email" id="email" placeholder="请输入邮箱" autocomplete="off" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form layui-row">
|
||||
<div class="layui-col-xs12 layui-col-sm12 layui-col-md4">
|
||||
<div class="layui-form-column">
|
||||
<label for="username" class="tips">用户名</label>
|
||||
<input type="text" name="username" id="username" placeholder="请输入用户名" autocomplete="off"
|
||||
class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-panel">
|
||||
<table 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'], function () {
|
||||
let $ = layui.jquery;
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let util = layui.util;
|
||||
|
||||
table.render({
|
||||
elem: '#tablelist',
|
||||
url: "/system/user/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: 'email', title: '邮箱', align: 'left', width: 180, fixed: 'left' },
|
||||
{ field: 'username', title: '用户名', align: 'left', width: 100 },
|
||||
{
|
||||
field: 'avatar', title: '头像', align: 'center', width: 90, templet: function (d) {
|
||||
if (d.avatar === 0 || d.avatar === undefined || d.avatar === '') { return ''; }
|
||||
if (d.avatar === '/statics/admin/images/avatar.jpg') {
|
||||
return '<img src="/statics/admin/images/avatar.jpg" width=30 height=30 />';
|
||||
}
|
||||
return '<img src="' + d.avatar + '" width=30 height=30 />';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'department_name', title: '部门', align: 'left', width: 100, templet: function (d) {
|
||||
return d.department ? d.department.name : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'role_name', title: '角色', align: 'left', width: 100, templet: function (d) {
|
||||
return d.role ? d.role.display_name : '';
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'gender', title: '性别', align: 'center', width: 50, templet: function (d) {
|
||||
if (d.gender == 0) {
|
||||
return '未知';
|
||||
} else if (d.gender == 1) {
|
||||
return '男';
|
||||
} else if (d.gender == 2) {
|
||||
return '女';
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
field: 'status', title: '状态', align: 'center', width: 90, templet: function (row) {
|
||||
switch (row.status) {
|
||||
case 0: return '正常';
|
||||
case -1: return '删除';
|
||||
default: return '其它';
|
||||
}
|
||||
return '';
|
||||
}
|
||||
},
|
||||
{ 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: 100, 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 'search': search(); break;
|
||||
case 'refresh': refresh(); break;
|
||||
}
|
||||
});
|
||||
|
||||
function add(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '新增',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/user/add"
|
||||
});
|
||||
}
|
||||
|
||||
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) {
|
||||
console.log('搜索');
|
||||
search_btn();
|
||||
layer.close(index);
|
||||
},
|
||||
btn2: function (index, layero) {
|
||||
$('#id').val('');
|
||||
$('#email').val('');
|
||||
$('#username').val('');
|
||||
$('#status').val(9999);
|
||||
form.render('select');
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function refresh() {
|
||||
table.reload('tablelist');
|
||||
}
|
||||
|
||||
table.on('tool(tablelist)', function (obj) {
|
||||
switch (obj.event) {
|
||||
case 'edit': edit(obj); break;
|
||||
}
|
||||
});
|
||||
|
||||
function edit(obj) {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: '修改',
|
||||
shade: 0.1,
|
||||
area: ['99%', '98%'],
|
||||
content: "/system/user/edit?id=" + obj.data['id']
|
||||
});
|
||||
}
|
||||
|
||||
function roleMenuRefresh(obj) {
|
||||
layer.confirm('确定要刷新角色权限吗?', { title: '提示' }, function (index, layero) {
|
||||
$.ajax({
|
||||
url: '/system/menu/roleMenuRefresh',
|
||||
type: 'post',
|
||||
headers: { 'X-CSRF-Token': '{{ token }}' },
|
||||
dataType: 'json',
|
||||
data: { "roleName": obj.data['name'] },
|
||||
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: $('#username').val(),
|
||||
email: $('#email').val(),
|
||||
id: $('#id').val()
|
||||
};
|
||||
}
|
||||
|
||||
// 搜索
|
||||
function search_btn() {
|
||||
table.reload('tablelist', {
|
||||
where: getQueryParams(),
|
||||
page: {
|
||||
curr: 1
|
||||
}
|
||||
})
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
||||
158
internal/erpserver/templ/system/user/list_templ.go
Normal file
158
internal/erpserver/templ/system/user/list_templ.go
Normal file
File diff suppressed because one or more lines are too long
127
internal/erpserver/templ/system/user/profile.templ
Normal file
127
internal/erpserver/templ/system/user/profile.templ
Normal file
@@ -0,0 +1,127 @@
|
||||
package user
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/pkg/mid"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/erpserver/model/system"
|
||||
)
|
||||
|
||||
templ Profile(ctx context.Context, item *system.User) {
|
||||
@base.Base(ctx, profileCss(), profileJs(ctx)) {
|
||||
{{ meuns := mid.GetCurMenus(ctx) }}
|
||||
{{ ht := mid.GetHtmlCsrfToken(ctx) }}
|
||||
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form">
|
||||
@ht
|
||||
<input type="hidden" name="ID" value={ item.ID } />
|
||||
<input type="hidden" name="Status" value={ item.Status } />
|
||||
<input type="hidden" id="DepartmentID" name="DepartmentID" value={ item.DepartmentID } />
|
||||
<input type="hidden" id="RoleID" name="RoleID" value={ item.RoleID } />
|
||||
<div class="layui-form-item">
|
||||
<label for="Email" class="layui-form-label">邮箱</label>
|
||||
<div class="layui-input-block">
|
||||
if item.ID > 0 {
|
||||
<input type="text" id="Email" name="Email" value={ item.Email } lay-verify="required"
|
||||
autocomplete="off" readonly placeholder="请输入邮箱" class="layui-input" />
|
||||
} else {
|
||||
<input type="text" id="Email" name="Email" value={ item.Email } lay-verify="required"
|
||||
autocomplete="off" placeholder="请输入邮箱" class="layui-input" />
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Username" class="layui-form-label">用户名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="Username" name="Username" value={ item.Username } lay-verify="required"
|
||||
autocomplete="off" placeholder="请输入用户名" class="layui-input" />
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Password" class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" id="Password" name="Password" value=""
|
||||
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-block">
|
||||
<input type="checkbox" name="ChangePassword" lay-skin="switch" lay-text="是|否" title="是|否">
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-block">
|
||||
@component.Upload(item.Avatar)
|
||||
</div>
|
||||
</div>
|
||||
<div class="layui-form-item">
|
||||
<label for="Gender" class="layui-form-label">性别</label>
|
||||
<div class="layui-input-block">
|
||||
<select id="Gender" name="Gender">
|
||||
if item.Gender == 0 {
|
||||
<option value="0" selected>未知</option>
|
||||
<option value="1">男</option>
|
||||
<option value="2">女</option>
|
||||
} else if item.Gender == 1 {
|
||||
<option value="0">未知</option>
|
||||
<option value="1" selected>男</option>
|
||||
<option value="2">女</option>
|
||||
} else if item.Gender == 2 {
|
||||
<option value="0">未知</option>
|
||||
<option value="1">男</option>
|
||||
<option value="2" selected>女</option>
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<div class="layui-input-block">
|
||||
@component.SubmitBtn(meuns, "save")
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
|
||||
templ profileCss() {
|
||||
}
|
||||
|
||||
templ profileJs(ctx context.Context) {
|
||||
<script>
|
||||
layui.use(['form', 'jquery', 'iconPicker', 'xmSelect'], function () {
|
||||
let form = layui.form;
|
||||
let $ = layui.jquery;
|
||||
let iconPicker = layui.iconPicker;
|
||||
|
||||
|
||||
// 表单提交
|
||||
form.on('submit(save)', function (data) {
|
||||
$.ajax({
|
||||
url: '/system/user/save',
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: data.field,
|
||||
success: function (result) {
|
||||
if (result.success) {
|
||||
layer.msg(result.msg, { icon: 1, time: 1000 });
|
||||
window.location.reload();
|
||||
} else {
|
||||
layer.msg(result.msg, { icon: 2 })
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return false;
|
||||
});
|
||||
});
|
||||
</script>
|
||||
}
|
||||
273
internal/erpserver/templ/system/user/profile_templ.go
Normal file
273
internal/erpserver/templ/system/user/profile_templ.go
Normal file
@@ -0,0 +1,273 @@
|
||||
// Code generated by templ - DO NOT EDIT.
|
||||
|
||||
// templ: version: v0.3.898
|
||||
package user
|
||||
|
||||
//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/model/system"
|
||||
"management/internal/erpserver/templ/base"
|
||||
"management/internal/erpserver/templ/component"
|
||||
"management/internal/pkg/mid"
|
||||
)
|
||||
|
||||
func Profile(ctx context.Context, item *system.User) 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-card\"><div class=\"layui-card-body\"><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/user/profile.templ`, Line: 21, 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, "\"> <input type=\"hidden\" name=\"Status\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var4 string
|
||||
templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(item.Status)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 22, Col: 74}
|
||||
}
|
||||
_, 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, "\"> <input type=\"hidden\" id=\"DepartmentID\" name=\"DepartmentID\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var5 string
|
||||
templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(item.DepartmentID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 23, Col: 104}
|
||||
}
|
||||
_, 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, "\"> <input type=\"hidden\" id=\"RoleID\" name=\"RoleID\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var6 string
|
||||
templ_7745c5c3_Var6, templ_7745c5c3_Err = templ.JoinStringErrs(item.RoleID)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 24, Col: 86}
|
||||
}
|
||||
_, 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, 6, "\"><div class=\"layui-form-item\"><label for=\"Email\" class=\"layui-form-label\">邮箱</label><div class=\"layui-input-block\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.ID > 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 7, "<input type=\"text\" id=\"Email\" name=\"Email\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var7 string
|
||||
templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(item.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 29, Col: 89}
|
||||
}
|
||||
_, 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, 8, "\" lay-verify=\"required\" autocomplete=\"off\" readonly placeholder=\"请输入邮箱\" class=\"layui-input\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 9, "<input type=\"text\" id=\"Email\" name=\"Email\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var8 string
|
||||
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(item.Email)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 32, Col: 89}
|
||||
}
|
||||
_, 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, 10, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入邮箱\" class=\"layui-input\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 11, "</div></div><div class=\"layui-form-item\"><label for=\"Username\" class=\"layui-form-label\">用户名</label><div class=\"layui-input-block\"><input type=\"text\" id=\"Username\" name=\"Username\" value=\"")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
var templ_7745c5c3_Var9 string
|
||||
templ_7745c5c3_Var9, templ_7745c5c3_Err = templ.JoinStringErrs(item.Username)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/profile.templ`, Line: 40, Col: 98}
|
||||
}
|
||||
_, 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, 12, "\" lay-verify=\"required\" autocomplete=\"off\" placeholder=\"请输入用户名\" class=\"layui-input\"></div></div><div class=\"layui-form-item\"><label for=\"Password\" class=\"layui-form-label\">密码</label><div class=\"layui-input-block\"><input type=\"text\" id=\"Password\" name=\"Password\" value=\"\" 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-block\"><input type=\"checkbox\" name=\"ChangePassword\" lay-skin=\"switch\" lay-text=\"是|否\" title=\"是|否\"></div></div><div class=\"layui-form-item\"><label class=\"layui-form-label\">头像</label><div class=\"layui-input-block\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = component.Upload(item.Avatar).Render(ctx, templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 13, "</div></div><div class=\"layui-form-item\"><label for=\"Gender\" class=\"layui-form-label\">性别</label><div class=\"layui-input-block\"><select id=\"Gender\" name=\"Gender\">")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
if item.Gender == 0 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "<option value=\"0\" selected>未知</option> <option value=\"1\">男</option> <option value=\"2\">女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Gender == 1 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<option value=\"0\">未知</option> <option value=\"1\" selected>男</option> <option value=\"2\">女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
} else if item.Gender == 2 {
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<option value=\"0\">未知</option> <option value=\"1\">男</option> <option value=\"2\" selected>女</option>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
}
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "</select></div></div><div class=\"layui-form-item\"><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, 18, "</div></div></form></div></div>")
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
templ_7745c5c3_Err = base.Base(ctx, profileCss(), profileJs(ctx)).Render(templ.WithChildren(ctx, templ_7745c5c3_Var2), templ_7745c5c3_Buffer)
|
||||
if templ_7745c5c3_Err != nil {
|
||||
return templ_7745c5c3_Err
|
||||
}
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func profileCss() 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)
|
||||
return nil
|
||||
})
|
||||
}
|
||||
|
||||
func profileJs(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_Var11 := templ.GetChildren(ctx)
|
||||
if templ_7745c5c3_Var11 == nil {
|
||||
templ_7745c5c3_Var11 = templ.NopComponent
|
||||
}
|
||||
ctx = templ.ClearChildren(ctx)
|
||||
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<script>\n layui.use(['form', 'jquery', 'iconPicker', 'xmSelect'], function () {\n let form = layui.form;\n let $ = layui.jquery;\n let iconPicker = layui.iconPicker;\n\n\n // 表单提交\n form.on('submit(save)', function (data) {\n $.ajax({\n url: '/system/user/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 });\n window.location.reload();\n } else {\n layer.msg(result.msg, { icon: 2 })\n }\n }\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