zoukankan      html  css  js  c++  java
  • layui框架前端

    如何获取,layui函数  批量删除中的id

    /批量删除
            var arr=[];//存储id的数组
            data.forEach(function(data){
            arr.push(data.menu_id);
            })
            content : '${ctxtPath}/menu/txst',// iframe的url  ssm框架  传后台
            console.log(arr); 

    批量删除 ssm框架

      <button class="layui-btn layui-btn-danger" lay-event="getCheckData" >批量删除</button> 
    case 'getCheckData': //定义的按钮名称 var data = checkStatus.data; //layer.alert(JSON.stringify(data)); //alert(data.test_id); var str=""; if(data.length>0){ for(var i=0;i<data.length;i++){ str+=data[i].test_id+","; } layer.confirm('是否删除这'+data.length+'条数据?',{icon:1,title:'提示'},function(index){

    ajax传值 $.ajax({ url:'${ctxtPath}/test/delAll?str='+ str, type:'get', data: $(data.form).serialize(), dataType:'json', success:function(data,textStatus,jqXHR){ window.location.reload(); 刷新页面 } }); layer.closr(index); }); } else{ layer.alert("请选择要删除的数据 "); } break; case 'getCheckLength': var data = checkStatus.data; layer.msg('选中了:'+ data.length + ' 个'); break; case 'isAll': //全选 // window.location.href='${ctxtPath}/menu/toAddMenu'; layer.msg(checkStatus.isAll ? '全选': '未全选'); break; case 'add': //添加 layer.open({ type : 2, title : '标题', maxmin : true, offset: '100px', area : [ '500px', '600px' ], content : '${ctxtPath}/test/testadd',// iframe的url end: function(){ //此处用于演示 window.location.reload(); } }); break;

    conllect层

    //删除数据
    	@ResponseBody
    	@RequestMapping(value="/delTest/{testId}", method = RequestMethod.POST)
    	@SystemLog(module="菜单管理", methods="/menu/delMenu", logDesc="删除菜单")
    	public Map<String, Object> delTest(@PathVariable String testId, HttpServletRequest request){
    		Map<String, Object> map = new HashMap<String, Object>();
    		Test test = testService.getMenu(testId);
    		System.out.println(test);
    		testService.delTest(test);;
    		map.put("status", "0");
    		return map;
    	}
    	//批量删除
    
    		@ResponseBody
    		@RequestMapping(value="/delAll", method = RequestMethod.GET)
    		@SystemLog(module="菜单管理", methods="/menu/delMenu", logDesc="删除菜单")
    		public Map<String, Object> delAll( HttpServletRequest request){
    			Map<String, Object> map = new HashMap<String, Object>();
    			String str=request.getParameter("str");
    			// testService.getMenu(str);	
    			testService.delAll(str);
    			System.out.println(str);
    			map.put("status", "0");
    			return map;
    		}
    

     service层

    	
    	//批量删除
    	public void delAll(String str){
    		//String menuSql = "delete from test_lcy where test_id in ('"+ menuIds +"') ";
    		str=str.replaceAll(",", "','");
    		String sql = "delete from test_lcy where test_id in ('"+ str +"') ";
    		jdbcDao.updateSql(sql);
    		//jdbcDao.updateSql(menuSql);
    	}
    

    Layui 搜索框

    搜索框

    部门 :
          <div class="layui-inline">
            <select name="testClass" id="testClass" class="layui-input" lay-verify="required" style=" 154px">
              <option value="">请选择部门</option>
              <option  value="1">java</option>
              <option  value="2">C#</option>
            </select>
          </div> 
          名字:
           <div class="layui-inline" style="margin-left: 5px">
            <input class="layui-input" name="testName" id="testName" autocomplete="off">
          </div>
          
          
          <button class="layui-btn" data-type="reload">搜索</button>
          
          
          
        </div>
    

    搜索框函数

    // 搜索
      var $ = layui.$, active = {
        reload: function(){
          var roleName  = $('#testName');
          var roleClass=$('#testClass');
          //执行重载
          table.reload('test', {
            page: {
              curr: 1 //重新从第 1 页开始
            }
            ,where: {
    // 实体类中的字段名称:获取对象的value值 testName:roleName.val(), testClass:roleClass.val() } }, 'data'); } }; $('.demoTable .layui-btn').on('click', function(){ var type = $(this).data('type'); active[type] ? active[type].call(this) : ''; });

     conllert 层

    //查看所有数据
    	@ResponseBody
    	@RequestMapping(value="/getseeall")
    	public Map<String, Object> getseeall(Test test, HttpServletRequest request){
    	
    		Map<String, Object> map = new HashMap<String, Object>();
    		Page page = testService.queryMenu(test);
    		map.put("code", "0");
    		map.put("msg", "");
    		map.put("count", page.getRecordCount());
    		map.put("data", page.getResultList());
    		return map;
    	}
    	
    

     service

    public Page queryMenu(Test test){
    		List<Object> args = new ArrayList<Object>();
    		String Name =  test.getTestName();
    		String calss=  test.getTestClass();
    		StringBuffer sql = new StringBuffer(
    	
    		"SELECT  test_id, test_name,test_age,test_home,test_phone,test_class FROM test_lcy where 1 = 1 ");
    		if(StringUtils.hasText(Name)){
    			sql.append("and test_name like ?");
    			args.add("%" + Name + "%");	
    		}
    		if(StringUtils.hasText( calss)){
    			sql.append("and test_class like ?");
    			args.add("%" + calss + "%");	
    		}
    	    // sql.append(" order by  desc");
    		return jdbcDao.querySqlPage(sql.toString(), args.toArray());
    	}
    
  • 相关阅读:
    ZOJ Problem Set–2417 Lowest Bit
    ZOJ Problem Set–1402 Magnificent Meatballs
    ZOJ Problem Set–1292 Integer Inquiry
    ZOJ Problem Set–1109 Language of FatMouse
    ZOJ Problem Set–1295 Reverse Text
    ZOJ Problem Set–1712 Skew Binary
    ZOJ Problem Set–1151 Word Reversal
    ZOJ Problem Set–1494 Climbing Worm
    ZOJ Problem Set–1251 Box of Bricks
    ZOJ Problem Set–1205 Martian Addition
  • 原文地址:https://www.cnblogs.com/layuechuquwan/p/11731586.html
Copyright © 2011-2022 走看看