topicEdit.html 7.45 KB
<!DOCTYPE html>
<head>
    <style>
    span .tag {
    display: block;
    float: left;
    padding: 2px 5px;
    background: #1caf9a;
    margin-right: 5px;
    margin-bottom: 5px;
    -moz-border-radius: 2px;
    -webkit-border-radius: 2px;
    border-radius: 2px;
    font-size: 13px;
    }
    </style>
</head>



<div id="tt" class="easyui-layout" fit="true" style="overflow-y: scroll">
    <form name="activityAddForm" id="activityAddForm" method="post" enctype="multipart/form-data">
        <div style="margin-top: 20px;margin-left: 30px">
            <table border="0" style="width:95%;margin-top:5px;line-height:30px;" id="tab">
                <tr style="height: 60px">

                    <td >
                        <span style="color:red">*</span><label>话题名称</label>  <br>
                        <input id="topicName" name="topicName" class="easyui-textbox" style="width: 380px;"/>
                    </td>
                </tr>
                <tr style="height: 60px">

                    <td >
                        <span style="color:red">*</span><label>话题描述</label>  <br>
                        <textarea id="topicDesc"  name="topicDesc" style="width: 380px;" rows="6" ></textarea>
                    </td>
                </tr>

                <tr style="height: 60px">
                    <td>
                        <span style="color:red">*</span><label>图片</label>  <br>

                        <div id="imageUpload">
                        </div>
                       <!-- <span style=" margin-left: 10px; color: red"> 图片宽高(186x170)</span>-->
                    </td>
                </tr>

                <tr style="height: 60px">

                    <td >
                        <span style="color:red">*</span><label>关联内容标签</label>  <br>
                        <a id="searchLabelBtn" class="btn-info">查询</a>
                        <div id="relatedLabelsDiv">
                            <div id="taglist" class="tagwrap">


                                <!--<span class="tag"><span>32132</span><a href="#" title="Removing tag" data-index="0" class="removetag">x</a></span>
                                <span class="tag"><span>淋淋惹</span><a href="#" title="Removing tag" data-index="1" class="removetag" >x</a></span>-->
                            </div>

                        </div>

                    </td>
                </tr>

            </table>
        </div>
    </form>
</div>
<script>
    $(function () {

        $("#topicName").textbox({
            required: true,
            missingMessage: "话题名称不能为空",
            prompt: "请输入话题名称"
        });


        $("#imageUpload").imageUpload({
            width: 171,
            height: 120,
            realInputName: "topicImageUrl",
            url: serverContextPath + '/fileupload/uploadFile',
            queryParams: {
                bucket: "activity"
            },
            onBeforeSubmit: function () {
                $.messager.progress({
                    title: "正在执行",
                    msg: "正在执行,请稍后...",
                    interval: 500,
                    text: ""
                });
            },
            filterFileName: function (data) {
                debugger;
                if (!data || data.code != 200) {
                    $.messager.progress("close");
                    $.messager.alert("错误",data.message);
                    return "";
                }
                return data.data.url;
            },
            onLoadSuccess: function (data) {
                $.messager.progress("close");
                //$("#imageUpload").hide();
                //$("#fileName").val(data.data.fileName);
                //$("#videoSize").val(data.data.fileSize); //如果有大小校验
                /*$("#callBackDiv").html("<div id='videoUploadDiv' class='image-upload' style='position: relative;top:19px;width: 120px; height: 150px;'><img id='imageShow' src='"+data.data.url+"?vframe/jpg/offset/0' width='120' height='150'/></div>"
                 +"<span style='position: relative;top: -40px;left: 30px;'>"+data.data.fileName+"</span><span style='position: relative;left: 50px;top: -40px;'>"+data.data.fileSize+"M</span>").show();
                 */
                return false;
            }
        });



        var data = paramObject.mkData;

        if (data){
            $("#topicName").textbox("setValue", data.topicName);
            debugger
            $("#topicDesc").val(data.topicDesc);
            $("#imageUpload").imageUpload("setValue", data.topicImageUrl);
            //展示已经关联的标签
            var labelInfoList = data.labelInfoList;
            for(var i=0; i< labelInfoList.length; i++){
                var choosedTagSpan = '<span style="margin-left: 10px" class="tag" name="choosedTag" data-labelId="'+labelInfoList[i].labelId+'"><span style="background-color: #1caf9a;color: white">'+labelInfoList[i].labelName+'</span><a href="#"  style="background-color: #1caf9a" title="Removing tag" data-index="0" class="removetag">x</a></span>' ;
                $("#taglist").append(choosedTagSpan);
            }

        }


        $(document).on('click', '.removetag', function() {
//            $(this).remove();
            $(this).closest(".tag").remove();
        });

       //查询标签列表
        $("#searchLabelBtn").linkbutton({
            iconCls : "icon-search",
            onClick : function() {
                chooseLabels();
            }
        });

    });

//选择标签列表
function chooseLabels(){
    var chooseLabelList = $("<div id='chooseLabelList'>").appendTo($(document.body));
    var title = "选择标签";
    $("#chooseLabelList").myDialog({
        title: title,
        width: "60%",
        height: "70%",
        resizable:false,
        buttons:[{
            id : "saveChooseLabelBtn",
            text: "保存",
            iconCls : "icon-save",
            handler:function(){
              //确定保存之前,要把之前已经选择的标签清空
                $("#taglist").html("");
             //做相应的处理 回填信息--所有被选择的复选框
                debugger
                $("input[type='checkbox'][class='tagCheckbox']:checked").each(function () {
                    var labelId = $(this).attr("data-labelId");
                    var labelName = $(this).attr("data-labelName");
                    var choosedTagSpan = '<span class="tag" style="margin-left: 10px" name="choosedTag"  data-labelId="'+labelId+'"><span style="background-color: #1caf9a;color: white">'+labelName+'</span><a href="#" style="background-color: #1caf9a" title="Removing tag" data-index="0" class="removetag">x</a></span>' ;
                    $("#taglist").append(choosedTagSpan);
                });

                $(chooseLabelList).dialog("close");
                $.messager.show({
                    title: "提示",
                    msg: title + "成功!",
                    height: 120
                });
            }
        }, {
            id:"closeChooseBtn",
            text: "关闭",
            iconCls: "icon-cancel",
            handler: function () {
                $.messager.confirm("确认", "确认关闭吗?", function (flag) {
                    if(flag){
                        $(chooseLabelList).dialog("close");
                    }
                });
            }
        }],
        modal: true,
        href: contextPath + "/html/grass/labelManage/chooseLabels.html",
    });

}


</script>