勾股OA在线文档

勾股OA5.0前端常用组件调用集(待发布)

1、layui的form组件,radio组件切换时的回调方法:

    <input type="radio" name="share" lay-filter="type" value="1" title="私有">
    <input type="radio" name="share" lay-filter="type" value="2" title="部门">
    form.on('radio(type)', function (data) {
        if(data.value==1){
            $('#person').hide();
            $('#depament').show();
        }
        else if(data.value==2){
            $('#person').show();
            $('#depament').hide();
        }
    });

2、layui的form组件,select组件切换时的回调方法:

<select name="chance_id" lay-filter="chance">
    <option value="" title="0">请选择</option>
    <option value="1" title="1">人员</option>
    <option value="2" title="2">部门</option>
</select>
form.on('select(chance)', function(data){
    var check_type = data.elem[data.elem.selectedIndex].title;
    if(check_type == 0){
        form.val('demo-val-filter', {
            "stage": ""
        });
        $("#stage").attr("disabled",true);
    }
    else{
        $("#stage").removeAttr("disabled");
    }
    form.render();
});

3、上传组件,uploadPlus.js,支持单文件上传、多文件上传,单图上传,多图上传(相册),大文件分片上传,支持上传回调,动态删除等。

const moduleInit = ['tool','uploadPlus'];
    function gouguInit() {
        var form = layui.form,tool=layui.tool,uploadPlus=layui.uploadPlus;

        //单图上传
        var photoUpload = new uploadPlus({
            'use':'single',
            'target':'uploadImg',
            'callback':function(res){
                layer.msg(res.msg);
                if (res.code == 0) {
                    //上传成功
                    $('#uploadThumb input').attr('value', res.data.filepath);
                    $('#uploadThumb img').attr('src', res.data.filepath);
                }
            }
        });

        //相关附件上传
        var attachment = new uploadPlus();