<div class="layui-form-item">
<label for="L_name" class="layui-form-label">
<span class="x-red">*</span>审批类型
</label>
<div class="layui-input-inline">
<select lay-search="" lay-filter="cate_demo" name="cate" id="cate">
<option value="0">请选择</option>
<option value="1">入户审批</option>
<option value="2">发票审批</option>
<option value="3">完税审批</option>
</select>
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
<div class="layui-form-item">
<label for="L_name" class="layui-form-label">
<span class="x-red">*</span>审批人
</label>
<div class="layui-input-inline">
<select lay-search="" lay-filter="admin_user" name="admin_user[]" id="admin_user">
</select>
</div>
<div class="layui-form-mid layui-word-aux">
</div>
</div>
<script id="choice_lists" type="text/html">
{{each list as value i}}
<option value="{{value.id}}">{{value.nick_name}}</option>
{{/each}}
</script>
// 定义锁,true表示锁死,false表示可操作
let lock_flag = false;
layui.use(['jquery','form', 'layer'],
function () {
$ = layui.jquery;
var form = layui.form, layer = layui.layer;
form.on('select(cate_demo)', function(data){
$.ajax({
data : {cate:data.value},
url : 'get_checker',
dataType : 'json',
type : 'POST',
success : function(data){
var art_data = {
list : data.data
};
var html = template('choice_lists', art_data);
//var html = '<option value="2">ru_checker</option><option value="2">ru_checkersss</option>';
$('#admin_user').html(html);
form.render(); //在layui中重新渲染表单这一步比较重要,部分表单元素需要重新渲染后才能生效,例如select
},error:function(){
layer.alert('接口错误');
}
});
})
//监听提交
form.on('submit(add)',
function (data) {
if (!lock_flag) {
// 上锁
lock_flag = true;
$("#edit_form").submit();
}
return false;
}
);
}
);