This commit is contained in:
kenneth 2025-06-17 11:53:31 +08:00
parent 5c8182cdf9
commit 417d0671de
10 changed files with 87 additions and 114 deletions

View File

@ -39,14 +39,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}

View File

@ -44,14 +44,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
}

View File

@ -44,14 +44,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}

View File

@ -38,14 +38,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}

View File

@ -54,14 +54,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: 0,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(0, res))
default:
a.render.JSONErr(w, "method not allowed")
}

View File

@ -48,14 +48,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}

View File

@ -56,8 +56,8 @@ func (a *app) edit(w http.ResponseWriter, r *http.Request) {
vm := &systemmodel.User{}
if id > 0 {
if u, err := a.userService.Get(ctx, id); err == nil {
vm.HashedPassword = []byte("********")
vm = u
vm.HashedPassword = []byte("********")
}
}
a.render.Render(ctx, w, user.Edit(ctx, vm))
@ -122,14 +122,7 @@ func (a *app) list(w http.ResponseWriter, r *http.Request) {
a.render.JSONErr(w, err.Error())
return
}
data := render.ResponseList{
Code: 0,
Message: "ok",
Count: count,
Data: res,
}
a.render.JSON(w, data)
a.render.JSON(w, render.NewResponseList(count, res))
default:
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
}

View File

@ -72,7 +72,7 @@ templ Edit(ctx context.Context, item *system.User) {
<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="请输入密码"
value={string(item.HashedPassword)} autocomplete="off" placeholder="请输入密码"
class="layui-input" />
</div>
</div>

View File

@ -151,7 +151,20 @@ func Edit(ctx context.Context, item *system.User) templ.Component {
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\">")
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=\"")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var8 string
templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(string(item.HashedPassword))
if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `internal/erpserver/templ/system/user/edit.templ`, Line: 75, 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, 13, "\" 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
}
@ -159,78 +172,78 @@ func Edit(ctx context.Context, item *system.User) templ.Component {
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\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 14, "</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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 15, "<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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 16, "<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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 17, "<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\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 18, "</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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 19, "<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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 20, "<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\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 21, "</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;\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 22, "<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))
templ_7745c5c3_Var9, 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: 139, Col: 78}
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_Var9))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</div></div>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 23, "</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_Var10 string
templ_7745c5c3_Var10, 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_Var10))
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, 24, "</div></div></div><div class=\"layui-form-item layui-fixbar btn-fixbar-box\"><div class=\"layui-input-block\">")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 25, "</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
}
@ -238,7 +251,7 @@ func Edit(ctx context.Context, item *system.User) templ.Component {
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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 26, "<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
}
@ -268,12 +281,12 @@ func editCss() templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var10 := templ.GetChildren(ctx)
if templ_7745c5c3_Var10 == nil {
templ_7745c5c3_Var10 = templ.NopComponent
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, 26, "<style>\n .layui-body {\n padding: 15px;\n left: 0;\n }\n</style>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 27, "<style>\n .layui-body {\n padding: 15px;\n left: 0;\n }\n</style>")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
@ -297,61 +310,61 @@ func editJs(ctx context.Context, item *system.User) templ.Component {
}()
}
ctx = templ.InitializeContext(ctx)
templ_7745c5c3_Var11 := templ.GetChildren(ctx)
if templ_7745c5c3_Var11 == nil {
templ_7745c5c3_Var11 = templ.NopComponent
templ_7745c5c3_Var12 := templ.GetChildren(ctx)
if templ_7745c5c3_Var12 == nil {
templ_7745c5c3_Var12 = 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': '")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 28, "<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)
templ_7745c5c3_Var13, 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': '")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 29, "' },\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_Var14, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(token)
templ_7745c5c3_Var14, 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: 256, Col: 56}
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_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: ['")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 30, "'],\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_Var15, templ_7745c5c3_Err := templruntime.ScriptContentInsideStringLiteral(item.RoleID)
templ_7745c5c3_Var15, 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: 270, Col: 55}
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_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>")
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 31, "' },\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_Var16, 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_Var16)
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 32, "'],\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
}

View File

@ -78,6 +78,15 @@ type ResponseList struct {
Data any `json:"data"`
}
func NewResponseList(count int64, data any) ResponseList {
return ResponseList{
Code: 0,
Message: "OK",
Count: count,
Data: data,
}
}
func respond(w http.ResponseWriter, data any) {
v, err := json.Marshal(data)
if err != nil {