274 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			274 lines
		
	
	
		
			14 KiB
		
	
	
	
		
			Go
		
	
	
	
	
	
| // 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'], function () {\n            let form = layui.form;\n            let $ = layui.jquery;\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
 |