123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- layui.use([ 'laypage', 'layer', 'table', 'element','form','laydate'], function(){
- var laypage = layui.laypage //分页
- ,layer = layui.layer //弹层
- ,table = layui.table //表格
- ,element = layui.element //元素操作
- ,form = layui.form
- ,laydate = layui.laydate;
- // laydate.render({
- // elem: '#date1'
- // });
- // laydate.render({
- // elem: '#date2'
- // });
- var tableIds = 'astrictList';
- //第一个实例
- table.render({
- elem: '#'+tableIds
- ,url: '/usersignup/astrictform' //数据接口
- ,where:{token:csrfToken}
- ,method:'post'
- ,page: true //开启分页
- ,text:'数据加载中'
- ,id:'tablereload'
- ,cols: [[ //表头
- {type:'numbers'},
- {field: 'mobile', title: '电话', align:'center',width:200}
- // ,{field: 'astrict_start', title: '限制开始', align:'center',width:100}
- // ,{field: 'astrict_end', title: '限制结束',align:'center',width:100}
- ,{field: 'astrict_msg', title: '限制提示',align:'center'}
- ,{field: 'state', title: '状态',align:'center',width:150,templet:function (d) {
- switch (d.state){
- case '2':
- return '<input type="checkbox" value="'+d.id+'" data-state="1" lay-skin="switch" lay-filter="switchTest" lay-text="|暂停">'
- break;
- case '1':
- return '<input type="checkbox" checked value="'+d.id+'" data-state="2" lay-skin="switch" lay-filter="switchTest" lay-text="使用|">'
- break;
- }
- }}
- ,{field: 'create_at', title: '添加时间', align:'center',width:250}
- ,{fixed: 'right',title:'操作', width: 165, align:'center', toolbar: '#astrictfunc'}
- ]]
- });
- //列表操作
- table.on('tool('+tableIds+')', function(obj){
- var layEvent = obj.event,
- data = obj.data;
- if(layEvent === 'del') {
- layer.confirm('您确定要删除吗?',{ btn: ['确定', '取消']},function () {
- $.post('/usersignup/astrictdel',{'id':data.id},function (data) {
- table.reload('tablereload');
- })
- })
- }
- });
- var $ = layui.$, active = {
- addData: function(){ //获取选中数据
- layer.open({
- type: 2,
- title: '添加限制号码',
- closeBtn: 1, //不显示关闭按钮
- shade: [0],
- area: ['600px', '500px'],
- anim: 2,
- content: '/usersignup/astrictadd', //iframe的url,no代表不显示滚动条
- end:function () {
- table.reload('tablereload');
- }
- });
- // var checkStatus = table.checkStatus('idTest')
- // ,data = checkStatus.data;
- // layer.alert(JSON.stringify(data));
- }, reload:function () {
- var form = pfgs_serialize($('form'));
- var name = '';
- var source_id = '';
- if(form.input_house == 'name'){
- name = form.input_house_text;
- } else if(form.input_house == 'source_id'){
- source_id = form.input_house_text;
- }
- table.reload('tablereload',{
- where:{
- source_id:source_id,
- name:name,
- type:form.type
- },
- page:{ //重载分页
- curr:1
- }
- })
- }
- };
- $('.demoTable .layui-btn').on('click', function(){
- var type = $(this).data('type');
- active[type] ? active[type].call(this) : '';
- });
- //添加
- form.on('submit(addnews)', function(data){
- layer.msg('数据提交中,请稍候',{icon: 16,time:false,shade:0.8});
- $.post('/usersignup/astrictaddto',{'data':data.field,'token':csrfToken},function (data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- TableClose();
- })
- return false;
- });
- //监听指定开关
- form.on('switch(switchTest)', function(data){
- var id = $(this).val();
- var state = $(this).data('state')
- layer.confirm('确定修改吗?',{btn: ['确定', '取消']},function () {
- $.post('/usersignup/astrictstate',{'id':id,'state':state,'token':csrfToken},function (data) {
- if(data.data != null){
- layer.msg(ReturnInfo(data.data),{icon:5});
- return ;
- }
- layer.msg(data.msg);
- table.reload('tablereload');
- })
- },function () {
- table.reload('tablereload');
- })
- });
- });
|