鼠笼管理系统
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

682 lines
36 KiB

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>用户设置</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet" href="/public/layui/css/layuinew.css" media="all">
<link rel="stylesheet" href="/public/style/edit.css" media="all">
<!-- 注意:如果你直接复制所有代码到本地,上述css路径需要改成你本地的 -->
</head>
<body>
<style>
#editorwrapper {
border: 1px solid #ccc;
z-index: 100; /* 按需定义 */
}
#toolbar-container { border-bottom: 1px solid #ccc; }
#editor-container { height: 400px; }
.layui-input-group {
position: relative;
display: table;
box-sizing: border-box;
width: 100%;
}
.layui-form-item .layui-form-checkbox[lay-skin="primary"] {
margin-top: unset !important;
}
</style>
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this">用户设置信息</li>
</ul>
<div class="layui-tab-content" style="height: 100px;">
<div class="layui-tab-item layui-show"><table class="layui-hide" id="classClass" style="padding:25px;" lay-filter="classClass"></table></div>
</div>
</div>
<script src="/public/layui/layui.js" charset="utf-8"></script>
<script src="/public/style/edit.js" charset="utf-8"></script>
<!-- 注意:如果你直接复制所有代码到本地,上述 JS 路径需要改成你本地的 -->
<script type="text/html" id="cage">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="cage">编辑查看</a>
</script>
<script type="text/html" id="squirrel">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="squirrel">编辑查看</a>
</script>
<script type="text/html" id="excel">
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="excel">编辑查看</a>
</script>
<script type="text/html" id="isde">
{{# if(d.is_delete==0){}}
<span class="layui-badge layui-bg-gray">正常</span>
{{# }else{}}
<span class="layui-badge">已删除</span>
{{# }}}
</script>
<script type="text/html" id="sta">
{{# if(d.status==0){}}
<span class="layui-badge layui-bg-blue">待通过</span>
{{# }else{}}
<span class="layui-badge layui-bg-gray">正常</span>
{{# }}}
</script>
<script type="text/html" id="tool">
<!-- 这里的 checked 的状态只是演示 -->
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="default">重置设置</a>
</script>
<script>
const { createEditor, createToolbar } = window.wangEditor
const toolbarConfig = {}
layui.use(['layedit','table','upload','element','form','layer'], function(){
var layedit = layui.layedit
,table = layui.table
,form = layui.form
,layer = layui.layer
,upload = layui.upload
,element = layui.element
,$ = layui.jquery;
form.render('checkbox');
table.render({
elem: '#classClass'
,url: '/admin_user/usersetlist'
,toolbar: '#toolbarDemo'
,cellMinWidth: 80 //全局定义常规单元格的最小宽度,layui 2.2.1 新增
,defaultToolbar: ['filter', 'exports', 'print', { //自定义头部工具栏右侧图标。如无需自定义,去除该参数即可
title: '提示'
,layEvent: 'LAYTABLE_TIPS'
,icon: 'layui-icon-tips'
}]
,page: true
,cols: [[
{field:'id', width:80, title: '序号'}
,{field:'username',width:180, title: '用户名'}
,{field:'realname', title: '真实姓名'}
,{toolbar: '#cage' ,title: '笼位设置'}
,{toolbar: '#squirrel',title: '鼠设置'}
,{toolbar: '#excel', title: 'EXCEL'}
,{field:'phone', title: '手机号'}
,{field:'created',width:180, title: '添加时间'}
// ,{toolbar: '#tool',width:200, title: '操作'}
]]
});
table.on('tool(classClass)', function(obj){
console.log(obj)
var data = obj.data;
if(obj.event === 'del'){
layer.confirm('确定要删除数据嘛', function(index){
$.post('/admin_index/delete',{tablename:'company',id:data.id},function(obj){
if(obj.status != 1){
return layer.msg(obj.msg);
}else{
//示范一个公告层
layer.open({
type: 1
,title: false //不显示标题栏
,closeBtn: false
,area: '300px;'
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: '返回列表'
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">删除成功</div>'
,yes: function(){
history.go(0)
}
});
}
});
});
}
if(obj.event === 'cage'){
// iframe 层
layer.open({
type: 1,
area: '450px',
resize: false,
shadeClose: true,
title: '笼位设置',
content: `
<div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px;">
<div class="demo-login-container">
<div class="layui-form-item">
<div class="layui-input-group">
<input type="hidden" name="id" value="`+data.cageSet.id+`" >
<input type="hidden" name="table" value="CageSetModel" >
<div class="layui-input-split layui-input-prefix">
每列笼位数显示数量
</div>
<input type="text" name="line_num" value="`+data.cageSet.line_num+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
每笼最多放成年鼠数量
</div>
<input type="text" name="big_num_max" value="`+data.cageSet.big_num_max+`" lay-verify="required" lay-reqtext="请填写毛色" autocomplete="off" class="layui-input" lay-affix="eye">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
每笼最多放幼崽数量
</div>
<input type="text" name="small_num_max" value="`+data.cageSet.small_num_max+`" lay-verify="required" lay-reqtext="请填写父亲" autocomplete="off" class="layui-input" lay-affix="eye">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
有幼崽的鼠笼最多放成年鼠数量
</div>
<input type="text" name="big_small_num" value="`+data.cageSet.big_small_num+`" lay-verify="required" lay-reqtext="请填写母亲" autocomplete="off" class="layui-input" lay-affix="eye">
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
分笼提醒
</div>
<select name="split_remind">
<option value="">请选择</option>
<option value="true" `+(data.cageSet.split_remind==true?"selected":"")+`>开</option>
<option value="false" `+(data.cageSet.split_remind==false?"selected":"")+`>关</option>
</select>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
超期分笼提醒
</div>
<select name="timeout_split_remind">
<option value="">请选择</option>
<option value="true" `+(data.cageSet.timeout_split_remind==true?"selected":"")+`>开</option>
<option value="false" `+(data.cageSet.timeout_split_remind==false?"selected":"")+`>关</option>
</select>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">确认</button>
</div>
</div>
</div>
`,
success: function(){
var laydate = layui.laydate;
// 渲染
laydate.render({
elem: '#ID-laydate-demo'
});
// 对弹层中的表单进行初始化渲染
form.render();
// 表单提交事件
form.on('submit(demo-login)', function(data){
var field = data.field; // 获取表单字段值
$.post('/admin_user/usersetedit',field,function(obj){
if(obj.status != 1){
return layer.msg(obj.msg);
}else{
//示范一个公告层
layer.open({
type: 1
,title: false //不显示标题栏
,closeBtn: false
,area: '300px;'
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: '返回列表'
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">修改成功</div>'
,yes: function(){
history.go(0)
}
});
}
});
return false; // 阻止默认 form 跳转
});
}
});
}
if(obj.event === 'squirrel'){
// iframe 层
layer.open({
type: 1,
area: '450px',
resize: false,
shadeClose: true,
title: '鼠设置',
content: `
<div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px;">
<div class="demo-login-container">
<div class="layui-form-item">
<div class="layui-input-group">
<input type="hidden" name="id" value="`+data.squirrelSet.id+`" >
<input type="hidden" name="table" value="SquirrelSetModel" >
<div class="layui-input-split layui-input-prefix">
断奶时间(天)
</div>
<input type="text" name="weaning_time" value="`+data.squirrelSet.weaning_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
断奶后护理时间(天)
</div>
<input type="text" name="nursing_time" value="`+data.squirrelSet.nursing_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
雄鼠性成熟时间(天)
</div>
<input type="text" name="male_grow_time" value="`+data.squirrelSet.male_grow_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
雌鼠性成熟时间(天)
</div>
<input type="text" name="female_grow_time" value="`+data.squirrelSet.female_grow_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
不育鼠时间(月)
</div>
<input type="text" name="infertility_time" value="`+data.squirrelSet.infertility_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
给药后持续几天显示给药标识
</div>
<input type="text" name="dose_time" value="`+data.squirrelSet.dose_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
记住几个近期给药的颜色
</div>
<input type="text" name="color_time" value="`+data.squirrelSet.color_time+`" lay-verify="required" placeholder="编 号" lay-reqtext="请填写编号" autocomplete="off" class="layui-input" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
配繁标识
</div>
<select name="breeding_tag">
<option value="">请选择</option>
<option value="true" `+(data.squirrelSet.breeding_tag==true?"selected":"")+`>开</option>
<option value="false" `+(data.squirrelSet.breeding_tag==false?"selected":"")+`>关</option>
</select>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<div class="layui-input-split layui-input-prefix">
见栓标识
</div>
<select name="see_bole_tag">
<option value="">请选择</option>
<option value="true" `+(data.squirrelSet.see_bole_tag==true?"selected":"")+`>开</option>
<option value="false" `+(data.squirrelSet.see_bole_tag==false?"selected":"")+`>关</option>
</select>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">确认</button>
</div>
</div>
</div>
`,
success: function(){
var laydate = layui.laydate;
// 渲染
laydate.render({
elem: '#ID-laydate-demo'
});
// 对弹层中的表单进行初始化渲染
form.render();
// 表单提交事件
form.on('submit(demo-login)', function(data){
var field = data.field; // 获取表单字段值
$.post('/admin_user/usersetedit',field,function(obj){
if(obj.status != 1){
return layer.msg(obj.msg);
}else{
//示范一个公告层
layer.open({
type: 1
,title: false //不显示标题栏
,closeBtn: false
,area: '300px;'
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: '返回列表'
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">修改成功</div>'
,yes: function(){
history.go(0)
}
});
}
});
return false; // 阻止默认 form 跳转
});
}
});
}
if(obj.event === 'excel'){
form.render("checkbox");
var now = '';
// iframe 层
layer.open({
type: 1,
area: '450px',
resize: false,
shadeClose: true,
title: 'EXCEL设置',
content: `
<div class="layui-form" lay-filter="filter-test-layer" style="margin: 16px;">
<div class="demo-login-container">
<input type="hidden" name="id" value="`+data.excelSet.id+`" >
<input type="hidden" name="table" value="ExcelSetModel" >
<div class="layui-form-item">
<div class="layui-input-group">
<input type="txt" value="现存鼠" lay-verify="required" disabled autocomplete="off" class="layui-input" style="text-align: center;" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[number]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.number+`">编号
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[sex]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.sex+`">性别
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[birthday]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.birthday+`">出生
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[strains_id]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.strains_id+`">品系
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[gene]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.gene+`">基因
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[cage_num]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.cage_num+`">笼号
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[content]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.content+`">描述
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[hair_color]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.hair_color+`">毛色
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[fenlong]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.fenlong+`">分笼
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[fanzhi]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.fanzhi+`">配繁
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[breeding_tag]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.breeding_tag+`">体重
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[see_bole_tag]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.see_bole_tag+`">见栓
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[give_medicine]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.give_medicine+`">给药
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[father]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.father+`">父亲
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[mother]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.mother+`">母亲
</div>
<div class="layui-col-md3">
<input type="checkbox" name="now_squirrel[remark]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.now_squirrel.remark+`">备注
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group">
<input type="txt" value="处理鼠" lay-verify="required" disabled autocomplete="off" class="layui-input" style="text-align: center;" >
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[number]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.number+`">编号
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[sex]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.sex+`">性别
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[birthday]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.birthday+`">出生
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[strains_id]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.strains_id+`">品系
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[gene]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.gene+`">基因
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[cage_num]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.cage_num+`">笼号
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[content]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.content+`">描述
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[hair_color]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.hair_color+`">毛色
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[fenlong]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.fenlong+`">分笼
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[fanzhi]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.fanzhi+`">配繁
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[breeding_tag]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.breeding_tag+`">体重
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[see_bole_tag]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.see_bole_tag+`">见栓
</div>
</div>
<div class="layui-input-group layui-row layui-col-space1">
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[give_medicine]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.give_medicine+`">给药
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[father]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.father+`">父亲
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[mother]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.mother+`">母亲
</div>
<div class="layui-col-md3">
<input type="checkbox" name="handle_squirrel[remark]" lay-skin="primary" style="margin-top:unset;" checked="`+data.excelSet.handle_squirrel.remark+`">备注
</div>
</div>
</div>
<div class="layui-form-item">
<button class="layui-btn layui-btn-fluid" lay-submit lay-filter="demo-login">确认</button>
</div>
</div>
</div>
`,
success: function(){
// 对弹层中的表单进行初始化渲染
// 表单提交事件
form.render("checkbox");
form.on('submit(demo-login)', function(data){
var field = data.field; // 获取表单字段值
$.post('/admin_user/usersetedit',field,function(obj){
if(obj.status != 1){
return layer.msg(obj.msg);
}else{
//示范一个公告层
layer.open({
type: 1
,title: false //不显示标题栏
,closeBtn: false
,area: '300px;'
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: '返回列表'
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">修改成功</div>'
,yes: function(){
history.go(0)
}
});
}
});
return false; // 阻止默认 form 跳转
});
}
});
}
});
$('.site-demo-layedit').on('click', function(){
var type = $(this).data('type');
active[type] ? active[type].call(this) : '';
});
//监听提交
form.on('submit(subdata)', function(data){
var datas = data.field
datas.content = editor.getHtml()
$.post('/admin_index/companysave',datas,function(obj){
if(obj.status != 1){
return layer.msg(obj.msg);
}else{
//示范一个公告层
layer.open({
type: 1
,title: false //不显示标题栏
,closeBtn: false
,area: '300px;'
,shade: 0.8
,id: 'LAY_layuipro' //设定一个id,防止重复弹出
,btn: '返回列表'
,btnAlign: 'c'
,moveType: 1 //拖拽模式,0或者1
,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">添加成功</div>'
,yes: function(){
history.go(0)
}
});
}
});
return false;
});
//常规使用 - 普通图片上传
var uploadInst = upload.render({
elem: '#test1'
,url: '/admin_index/upload' //此处用的是第三方的 http 请求演示,实际使用时改成您自己的上传接口即可。
,before: function(obj){
//预读本地文件示例,不支持ie8
obj.preview(function(index, file, result){
$('#demo1').attr('src', result); //图片链接(base64)
});
element.progress('demo', '0%'); //进度条复位
layer.msg('上传中', {icon: 16, time: 0});
}
,done: function(res){
//如果上传失败
if(res.status != 1){
return layer.msg('上传失败');
}
$('#img').val(res.data); //置空上传失败的状态
//上传成功的一些操作
//……
$('#demoText').html(''); //置空上传失败的状态
}
,error: function(){
//演示失败状态,并实现重传
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();
});
}
//进度条
,progress: function(n, elem, e){
element.progress('demo', n + '%'); //可配合 layui 进度条元素使用
if(n == 100){
layer.msg('上传完毕', {icon: 1});
}
}
});
form.render('checkbox');
// function deletet(tablename,id){
// $.post('/admin_index/delete',{tablename:tablename,id:id},function(obj){
// if(obj.status != 1){
// return layer.msg(obj.msg);
// }else{
// //示范一个公告层
// layer.open({
// type: 1
// ,title: false //不显示标题栏
// ,closeBtn: false
// ,area: '300px;'
// ,shade: 0.8
// ,id: 'LAY_layuipro' //设定一个id,防止重复弹出
// ,btn: '返回列表'
// ,btnAlign: 'c'
// ,moveType: 1 //拖拽模式,0或者1
// ,content: '<div style="padding: 50px; line-height: 22px; background-color: #393D49; color: #fff; font-weight: bold;font-size: 20px;text-align: center;">添加成功</div>'
// ,yes: function(){
// history.go(0)
// }
// });
// }
// });
// }
});
</script>
</body>
</html>