小键子

小键子

0飞吻 2018-7-25 加入 来自重庆

(这个人懒得留下签名)

小键子 最近的提问

小键子 最近的回答

  • 2018-10-12 18:8:46表格出现表头与内容错位的情况中回答:

    TableFilter.init("filterKey1",cols1,tableReport); //引用模板(对象,表格,表格初始化实例)
    {
    console.log("筛选");
    console.log($("#filterKey1_filter_wrapper"));
    $("#filterKey1_filter_wrapper").find("input[title='订单类型']").next().click();
    $("#filterKey1_filter_wrapper").find("input[title='企业名称']").next().click();

    }


    import Checkbox from "../templates/checkbox.html"
    let {laytpl,form} = layui;
    const filterCols = (cols,deleteCols) =>{
    let cls = JSON.parse(JSON.stringify(cols));
    for(let i = cls.length-1;i>=0;i--){
    let item = cls[i];
    for(let key of deleteCols){
    if(key == item.field){
    cls.splice(i,1);
    }
    }
    }
    return cls;
    };
    export default {
    init(id,cols,tabInst,cb,fn){
    $("#"+id).click((e)=>{
    $("#"+id+"_filter_wrapper").show().css("right","0");
    console.log("弹出窗口");

    // if(id == "filterKey"){
    // console.log("筛选");
    // /**
    // * user.html;其他页面不影响不要删除了
    // * */
    // console.log("筛选");
    // console.log($("#filterKey_filter_wrapper"));
    // $("#filterKey_filter_wrapper").find("input[title='所属机构']").next().click();
    // $("#filterKey_filter_wrapper").find("input[title='部门']").next().click();
    // $("#filterKey_filter_btn").click();
    // }
    });
    let wrapper = $(`<div id="${id}_filter_wrapper" class="filter_wrapper lline flex-v" style="display: none;">
    <div class="bg"></div>
    <div class="flex pd20"><span class="flex-1">字段筛选</span><i class="layui-icon hand">ဆ</i></div>
    <div class="layui-form pdl20 flex-1 scroll" id="${id}_filters" lay-filter="${id}_filters_form"></div>
    <div class="flex flex-pack-between tline pdt10 pdl20 pdr20 pdb10 layui-form flex-align-center" lay-filter="${id}_filters_form_op">
    <input type="checkbox" name="check_all" lay-skin="primary" title="全选" lay-filter="${id}_check_all" checked="">
    <button class="layui-btn layui-bg-cyan" id="${id}_filter_btn">保存</button>
    </div>
    </div>`);
    wrapper.find(".hand").click(()=>{
    $("#"+id+"_filter_wrapper").css("right","-260px");
    setTimeout(()=>{
    $("#"+id+"_filter_wrapper").hide()
    },300)
    });

    wrapper.find(".bg").click(()=>{
    $("#"+id+"_filter_wrapper").css("right","-260px")
    setTimeout(()=>{
    $("#"+id+"_filter_wrapper").hide()
    },300)
    })
    $("body").append(wrapper);
    laytpl(Checkbox).render({filterKey:`${id}_filters`,list:cols}, function(html){
    $(`#${id}_filters`).html(html);
    form.render("checkbox");
    form.on(`checkbox(${id}_filters)`, (data)=>{
    let checked = data.elem.checked;
    if(checked){
    let flag = false;
    $(`#${id}_filters`).find("input[type=checkbox]").each((index,item)=>{
    if(!item.checked){
    flag = true;
    }
    });
    if(flag){
    form.val(`${id}_filters_form_op`,{check_all:""});
    }else{
    form.val(`${id}_filters_form_op`,{check_all:"on"});
    }

    }else{
    form.val(`${id}_filters_form_op`,{check_all:""});
    }

    });
    form.on(`checkbox(${id}_check_all)`, (data)=>{
    let checked = data.elem.checked;
    if(checked){
    let obj = {};
    for(let item of cols){
    obj[item.field] = "on";
    }
    form.val(`${id}_filters_form`,obj);
    }else{
    let obj = {};
    $(`#${id}_filters`).find("input[type=checkbox]").each((index,item)=>{
    let name = item.name;
    let checked = item.checked;
    obj[name] = !checked ? "on":"";
    });
    form.val(`${id}_filters_form`,obj);
    }
    });
    });
    $(`#${id}_filter_btn`).click(()=> {
    let deleteCols = [];
    $(`#${id}_filters`).find("input[type=checkbox]").each((index,item)=>{
    let name = item.name;
    let checked = item.checked;
    if(!checked){
    deleteCols.push(item.name);
    }
    });
    tabInst.reload({
    cols:[filterCols(cols,deleteCols)]
    });
    $("#"+id+"_filter_wrapper").css("right","-260px");
    setTimeout(()=>{
    $("#"+id+"_filter_wrapper").hide();
    if(typeof cb === 'function'){
    cb();
    }
    },300)
    })

    }
    }
  • 2018-10-12 17:49:19表格出现表头与内容错位的情况中回答:

    @425607807_m 隐藏一些字段后就错乱,不知道怎么搞
  • 2018-8-24 17:16:0上传组件只能上传png格式我没做限制中回答:

    已经解决acceptMime注释就可以
  • 2018-8-9 13:35:31竟然是这样的,坑人啊中回答:

    我发觉layui有个东西当复制的时候表单账号文字居中,希望@贤心 改下
  • 2018-8-9 13:35:0竟然是这样的,坑人啊中回答:

    我发觉layui有个东西当复制的时候表单账号文字居中,希望@贤心改下
  • 2018-8-9 13:26:53我在给单选框赋值的时候没生效中回答:

    @岁月小偷 我是这么解决的,他穿过来1我就判断 data.gender="男"
    传过来2就是data.gender="女",这么搞的感谢你给我解答虽然是我自己解决的但是还是要采纳
  • 2018-7-30 10:50:26layui清空表单操作中回答:

    后来同事给我说了我就是这么做的