123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274 |
- <!DOCTYPE html>
- <html class="x-admin-sm">
-
- <head>
- <meta charset="UTF-8">
- <meta name="renderer" content="webkit">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
- <link rel="shortcut icon" href="https://osscold.baozhida.cn/favicon.ico">
- <link rel="bookmark" href="https://osscold.baozhida.cn/favicon.ico">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
- <link rel="stylesheet" href="https://osscold.baozhida.cn/layui/css/layui.css">
- <script type="text/javascript" src="https://osscold.baozhida.cn/layui/layui.js" charset="utf-8"></script>
- <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
- <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
- <!--[if lt IE 9]>
- <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
- <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
- <![endif]--></head>
-
- <body>
- <div class="layui-fluid">
- <div class="layui-row">
- <form class="layui-form">
- <div class="layui-form-item" style="margin-top: 20px">
- <label for="Admin_name" class="layui-form-label">
- <span class="x-red">*</span>名称</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.Date.Admin_name}}"
- {{end}} type="text" id="Admin_name" name="Admin_name" required="" lay-verify="required" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label class="layui-form-label">
- <span class="x-red">*</span>权限</label>
- <div class="layui-input-inline">
- <select lay-filter="Admin_power" id="Admin_power" name="Admin_power" class="valid" >
- {{range $index, $elem := .Power_List}}
- <option value="{{$elem.Id}}" {{if gt $.id 0 }}
- {{if eq $.Date.Admin_power $elem.Id }}
- selected
- {{end}}
- {{end}}
- >{{$elem.Power_name}}</option>
- {{end}}
- </select>
- </div>
- </div>
- {{if eq .id 0 }}
- <div class="layui-form-item">
- <label for="Admin_user" class="layui-form-label">
- <span class="x-red">*</span>账号</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.Date.Admin_user}}"
- {{end}} type="text" id="Admin_user" name="Admin_user" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
- </div>
- <div class="layui-form-item">
- <label for="Admin_telephone" class="layui-form-label">
- <span class="x-red">*</span>密码</label>
- <div class="layui-input-inline">
- <input disabled readonly class="layui-input layui-disabled"
- value="密码会自动生成"
- type="text" required="" autocomplete="off" class="layui-input">
- </div>
- </div>
- {{end}}
- <div class="layui-form-item">
- <label class="layui-form-label">性别</label>
- <div class="layui-input-inline">
- <select id="Admin_gender" name="Admin_gender" class="valid" >
- <option value="0" {{if gt $.id 0 }}
- {{if eq 0 .Date.Admin_gender }}
- selected
- {{end}}
- {{end}}
- >未知</option>
- <option value="1" {{if gt $.id 0 }}
- {{if eq 1 .Date.Admin_gender }}
- selected
- {{end}}
- {{end}}
- >男</option>
- <option value="2" {{if gt $.id 0 }}
- {{if eq 2 .Date.Admin_gender }}
- selected
- {{end}}
- {{end}}
- >女</option>
- </select>
- </div>
- </div>
- <div class="layui-form-item">
- <label for="Admin_telephone" class="layui-form-label">电话</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.Date.Admin_telephone}}"
- {{end}} type="text" id="Admin_telephone" name="Admin_telephone" required="" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label for="Admin_mail" class="layui-form-label">邮箱</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.Date.Admin_mail}}"
- {{end}} type="text" id="Admin_mail" name="Admin_mail" required="" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item">
- <label for="Admin_text" class="layui-form-label">
- 备注</label>
- <div class="layui-input-inline">
- <input {{if gt .id 0 }}
- value="{{.Date.Admin_text}}"
- {{end}} type="text" id="Admin_text" name="Admin_text" required="" autocomplete="off" class="layui-input">
- </div>
- </div>
- <div class="layui-form-item" style="text-align: center;margin-top: 20px">
- <!-- <label for="L_repass" class="layui-form-label"></label>-->
- <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button></div>
- </form>
- </div>
- </div>
- <script>
- layui.use(['form', 'layer',"layedit"],
- function() {
- $ = layui.jquery;
- var form = layui.form,
- layer = layui.layer;
- var layedit = layui.layedit
- layedit.set({
- uploadImage: {
- url: '/UpFile' //接口url
- }
- });
- //构建一个默认的编辑器
- var index = layedit.build('T_text', {
- height: 580 //设置编辑器高度,
- });
- //监听提交
- form.on('submit(add)',
- function(data) {
- console.log("=== submit(add) ==");
- console.log(data);
- $.ajax({
- type: 'POST',
- url: 'Admin_Post',//发送请求
- data: {
- Admin_uuid:"{{.Admin_uuid}}",
- Admin_name:data.field.Admin_name,
- Admin_power:data.field.Admin_power,
- Admin_user:data.field.Admin_user,
- Admin_telephone:data.field.Admin_telephone,
- Admin_mail:data.field.Admin_mail,
- Admin_gender:data.field.Admin_gender,
- Admin_text:data.field.Admin_text,
- },
- success: function(result) {
- console.log(result)
- if(result.Code == 200){
- layer.msg("操作成功", {
- icon: 1,
- time: 2000
- });
- //关闭当前frame
- parent.layer.close(parent.layer.getFrameIndex(window.name));
- parent.location.reload();
- form.render('select');
- }if(result.Code == 210){
- layer.alert(
- "生成密码:"+result.Data,
- {icon: 6,closeBtn: 0 ,title: "请保管好密码,后期无法呈现"},
- function () {
- //关闭当前frame
- parent.layer.close(parent.layer.getFrameIndex(window.name));
- parent.location.reload();
- form.render('select');
- });
- }else {
- layer.msg("错误:"+result.Msg, {
- icon: 2,
- time: 2000
- });
- }
- //
- // return false;
- }
- });
- return false;
- });
- });
- </script>
- <script>
- layui.use('upload', function(){
- var $ = layui.jquery
- ,upload = layui.upload;
- //普通图片上传
- var uploadInst = upload.render({
- elem: '#test1'
- ,url: '/UpFile' //改成您自己的上传接口
- ,before: function(obj){
- //预读本地文件示例,不支持ie8
- obj.preview(function(index, file, result){
- $('#demo1').attr('src', result); //图片链接(base64)
- });
- }
- ,done: function(res){
- console.log(res)
- //如果上传失败
- if(res.code != 0){
- return layer.msg('上传失败');
- }
- T_img = res.data.src
- console.log(T_img)
- //上传成功
- }
- ,error: function(){
- console.log("error")
- //演示失败状态,并实现重传
- var demoText = $('#demoText');
- demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
- demoText.find('.demo-reload').on('click', function(){
- uploadInst.upload();
- });
- }
- });
- //绑定原始文件域
- upload.render({
- elem: '#test20'
- ,url: 'https://httpbin.org/post' //改成您自己的上传接口
- ,done: function(res){
- layer.msg('上传成功');
- console.log(res)
- }
- });
- });
- </script>
- </body>
- </html>
|