easyui3

上传:

传图:

<link href="~/Scripts/uploadify/uploadify.css" rel="stylesheet" />

<div class="fitem" style="">
                    <div class="fl lh28" style="width:110px;">行驶证:</div>
                    <div style="width: 300px; float: left;">
                        <div style="margin-top: 5px; background: #fff;z-index:1;height:100px;" id="VehicleModify_commoditylist"></div>
                    </div>
                </div>

   <div class="ui-Receiving" id="VehicleModify_AddDivImageShow" style="display: none;">
        <div class="ui-Receiving-content">
            <div class="Receiving">
                <div class="Receiving-con" style="text-align:center">
                    <img id="VehicleModify_ShowImages" />
                </div>
            </div>
        </div>
    </div>

   <input type="hidden" id="tupian" />
    <input type="hidden" id="VehicleModify_evaluation_num" />
    <input type="hidden" id="VehicleModify_evaluation_tid" />
    <input type="hidden" id="VehicleModify_evaluation_servicenum" />
    <input type="hidden" id="VehicleModify_evaluation_phototnum" />
    <input type="hidden" id="OldPic" />

    <input type="hidden" id="VehicleLicense">

<script type="text/javascript" src="~/Scripts/uploadify/jquery.uploadify.min.js"></script>

 

var VehicleLicenseJson = '';//图片识别
var VehicleLicenseObj = {};
VehicleModify_evaluation_getlist();

//获取绑值:
if(msg.row_data.record.VehicleLicense != ''){
                    var temp = $(".submit_evaluation_pothos2");
                    gaiVehicleModify_evaluation_potho(temp, 0, res.VehicleLicense);
                    $("#OldPic").val(res.VehicleLicense)
                }

function VehicleModify_evaluation_getlist() {
    $("#VehicleModify_evaluation_num").val(1);
    var i = 0;
    var list = $("#VehicleModify_commoditylist");
    var str = "";
    list.html("");
    str += '<div class="submit_evaluation_columns">'
        + '<div class="sign_register_columns" style=" height: 110px; margin-bottom: 0; font-size: 12px; color: #333; position: relative; ">'
        + '<div style="position:absolute;top:0;left:0;width:100%;height:75px;">'
        + '<input type="hidden" id="imgFileStream' + i + '" />'
        + '<div style="  margin-bottom: 0; font-size: 12px; color: #333;" class="content' + i + '">'
        + '<div class="sign_register_column" style="width:100%;margin:0 0;border:none;text-align:center;min-height:100px;max-height:200px;overflow:hidden" >'
        + '<div class="submit_evaluation_pothos" >'
        + '</div>'
        + '<div class="submit_evaluation_pothos2" style="width:77px;height:77px;margin-top:10px;border:1px dashed #ccc;position:relative;" id="submit_potho' + i + '" onclick="VehicleModify_evaluation_potho(this,' + i + ')">'
        + '<img src="' + web_dir + '/Content/images/camera.png" style="width:35px;height:35px;margin-top:15px;"/>'
        + '<dd style="width:100%;height:100%;position:absolute;top:0;left:0;margin-left:0;overflow: hidden;">'
        + '<img style="position:absolute;left:0;height:100%;" onclick="VehicleModify_showImages(event,this)" id="VehicleModify_BusinessLicense" onload="VehicleModify_AutoSize(this,80,80)"/>'
        + '</dd >'
        + '<input type="file" style="width: 100%; height: 77px;position:absolute;top:0;left:0; opacity: 0;border:1px dashed #ccc; ">'
        + '</div>'
        + '</div>'
        + '</div>'
        + '</div>'
    list.html(str)
}


//上传图片
var imgFileStream = "";
function VehicleModify_evaluation_potho(t, i) {
    //console.log(t,i)
    var input = $(t).find("input");
    $("#VehicleModify_evaluation_phototnum").val(input.length);
    //console.log(input);
    input.localResizeIMG({
        width: 1800,
        quality: 0.6,
        success: function (result) {
            //嵌套页添加loading
            $(".mask1").html("<center class='loding'><img src='/Content/images/loding.gif'></center>")
            $(".mask1").fadeIn(150);
            //console.log(result)
            var num = parseFloat($(t).parent().find("div").length) - 1;
            if (num == 4) {
                $(".content" + i).css("height", "290px")
            }
            var img = new Image();
            img.src = result.base64;
            $(t).find("img").eq(1).attr("src", img.src);
            var wid = parseFloat(img.width)
            var hei = parseFloat(img.height);
            if (wid > hei) {
                $(t).find("img").eq(1).css("height", "100%");
                var aa = wid - hei;
                var bi = aa / 2 / hei;
            } else if (wid < hei) {
                $(t).find("img").eq(1).css("width", "100%");
                var aa = hei - wid;
                var bi = (aa / 2 / wid).toFixed(2);
            }
            $(t).find("input").hide();
            $(t).append('<img src="' + web_dir + '/Content/images/closer.png" style="width: 20px; height: 20px;position:absolute;top:-9px;right:-9px;z-index:10;overflow: visible"  onclick="VehicleModify_quxiao(this,' + i + ')"/>')
            var geshu = parseFloat($(t).parent().find("div").length) - 1;
            imgFileStream = $("#imgFileStream" + i).val()
            imgFileStream += $(t).parent().find("div").eq(geshu).find("img").eq(1).attr('src').split(',')[1];
            $("#imgFileStream" + i).val(imgFileStream)
            GetVehicleLicenseMess(imgFileStream);//上传成功后去接口发请求得到行驶证信息自动赋值到文本框
            if (num >= 5) {
                return
            }

            //为了单个这里直接return
            return
            $(t).parent().append('<div class="submit_evaluation_pothos2" style="width:77px;height:77px;margin-top:10px;border:1px dashed #ccc;position:relative" id="submit_potho" onclick="VehicleModify_evaluation_potho(this,' + i + ')">'
                + '<img src="' + web_dir + '/Content/images/camera.png" style="width:35px;height:35px;margin-top:15px;"/>'
                + '<dd style="width:100%;height:100%;position:absolute;top:0;left:0;margin-left:0;overflow:hidden">'
                + '<img style="position:absolute;left:0;height:100%;" onclick="VehicleModify_showImages(event,this)" id="VehicleModify_BusinessLicense" onload="VehicleModify_AutoSize(this,80,80)"/>'
                + '</dd >'
                + '<input type="file" style="width: 100%; height: 100%;position:absolute;top:0;left:0; opacity: 0;border:0.01rem dashed #ccc;">'
                + '</div>')

        }
    })
}

function gaiVehicleModify_evaluation_potho(t, i, src) {
    //console.log(t,i)
    var num = parseFloat($(t).parent().find("div").length) - 1;
    if (num == 4) {
        $(".content" + i).css("height", "290px")
    }
    var img = new Image();
    img.src = src;
    $(t).find("img").eq(1).attr("src", img.src);
    var wid = parseFloat(img.width)
    var hei = parseFloat(img.height);
    if (wid > hei) {
        $(t).find("img").eq(1).css("height", "100%");
        var aa = wid - hei;
        var bi = aa / 2 / hei;
    } else if (wid < hei) {
        $(t).find("img").eq(1).css("width", "100%");
        var aa = hei - wid;
        var bi = (aa / 2 / wid).toFixed(2);
    }
    $(t).find("input").hide();
    $(t).append('<img src="' + web_dir + '/Content/images/closer.png" style="width: 20px; height: 20px;position:absolute;top:-9px;right:-9px;z-index:10;overflow: visible"  onclick="VehicleModify_quxiao(this,' + i + ')"/>')
    var geshu = parseFloat($(t).parent().find("div").length) - 1;
    imgFileStream = $("#imgFileStream" + i).val()
    imgFileStream += $(t).parent().find("div").eq(geshu).find("img").eq(1).attr('src').split(',')[1];

    $("#imgFileStream" + i).val(imgFileStream)

    if (num >= 5) {
        return
    }
}

function VehicleModify_quxiao(t, i) {
    var num = parseFloat($(t).parent().parent().find("div").length) - 2;
    var div = $(t).parent().parent();
    $(t).parent().remove();
    $("#OldPic").val('');
    VehicleModify_evaluation_getlist();
    //为了单个这里直接return
    return
    if (num == 3) {
        $(".content" + i).css("height", "200px")
    };
    num = num - 1
    div.find("p").text(num + "/5")
    if (num == 3) {
        var img = div.find("div").eq(4).find("img").eq(1).attr('src');
        if (img == undefined) {
            num = num - 1

        } else {
            div.append('<div class="submit_evaluation_pothos2" style="width:77px;height:77px;margin-top:10px;border:1px dashed #ccc;position:relative" id="submit_potho" onclick="VehicleModify_evaluation_potho(this,' + i + ')">'
                + '<img src="' + web_dir + '/Content/images/camera.png" style="width:35px;height:35px;margin-top:15px;"/>'
                + '<dd style="width:100%;height:100%;position:absolute;top:0;left:0;margin-left:0;overflow:hidden">'
                + '<img style="position:absolute;left:0;height:100%;" onload="VehicleModify_AutoSize(this,80,80)" />'
                + '</dd >'
                //+ '<p style="font-size:12px;margin-top:-10px;"> 4/5</p>'
                + '<input type="file" style="width: 100%; height: 100%;position:absolute;top:0;left:0; opacity: 0;border:1px dashed #ccc; ">'
                + '</div>')
        }

    }

    imgFileStream = ''
    var geshu = $("#submit_potho" + i).parent().find("div").length;
    for (j = 1; j < geshu - 1; j++) {
        imgFileStream += ";" + $("#submit_potho" + i).parent().find("div").eq(j).find("img").eq(1).attr('src').split(',')[1];

    }
    $("#imgFileStream" + i).val(imgFileStream)
}

function VehicleModify_AutoSize(Img, maxWidth, maxHeight) {
    //console.log(Img)
    var image = new Image();
    //原图片原始地址(用于获取原图片的真实宽高,当<img>标签指定了宽、高时不受影响)
    image.src = Img.src;
    //当图片比图片框小时不做任何改变
    if (image.width < maxWidth && image.height < maxHeight) {
        Img.width = maxWidth;
        Img.height = maxHeight;
    }
    else //原图片宽高比例 大于 图片框宽高比例,则以框的宽为标准缩放,反之以框的高为标准缩放
    {
        if (maxWidth / maxHeight <= image.width / image.height) //原图片宽高比例 大于 图片框宽高比例
        {
            Img.width = maxWidth;   //以框的宽度为标准
            Img.height = maxWidth * (image.height / image.width);
            if (Img.height < 80) {
                Img.height = 75;
                Img.width = 75;
                //Img.style.left = "-8px";
                //Img.style.top = "0px";
            }
        }
        else {   //原图片宽高比例 小于 图片框宽高比例
            Img.width = maxHeight * (image.width / image.height);
            Img.height = maxHeight;   //以框的高度为标准
            if (Img.width < 80) {
                Img.width = 75;
                Img.height = 75;
                //Img.style.left = "0px";
                //Img.style.top = "-8px";
            }
        }
    }
}
function GetVehicleLicenseMess(imgBase64){
    $.ajax({
        type: "POST",
        url: "/Vehicle/GetVehicleLicenseMess",
        data: {
            UserToken: UserToken,
            imgBase64: imgBase64,
        },
        async: true,
        dataType: "json",
        success: function (msg) {
            //console.log(msg);
            $(".mask1").html("")
            $(".mask1").fadeOut(150);
            if (msg.status.code == 1) {
                VehicleLicenseJson = msg.row_data.record.VehicleLicenseJson;
                $("#VehicleLicense").val(msg.row_data.record.VehicleLicenseJson);
                if(msg.row_data.record.VehicleLicenseJson != undefined){
                    VehicleLicenseObj = JSON.parse(msg.row_data.record.VehicleLicenseJson);
                    //console.log(VehicleLicenseObj);
                    if(VehicleLicenseObj.words_result[0].card_type == 'vehicle_front'){
                        var list1 = VehicleLicenseObj.words_result[0].license_info;
                        //console.log(list1);
                        if(list1.length>0){
                            $(list1).each(function(inde,item){
                                if(item.word_name == '号牌号码'){
                                    $("#VehicleModify_PlateNumber").textbox({ value: item.word })
                                }
                                if(item.word_name == '品牌型号'){
                                    $("#VehicleModify_Brand").textbox({ value: item.word })
                                }
                                if(item.word_name == '车辆识别代号'){
                                    $("#VehicleModify_VIN").textbox({ value: item.word })
                                }
                                if(item.word_name == '车辆类型'){
                                    for(var i=0;i<VehicleModify_Mycategory.length;i++){
                                        var cur = VehicleModify_Mycategory[i];
                                        if(cur.CategoryName == item.word){
                                            console.log(cur.CategoryID);
                                            $('#VehicleModify_VTypeID').combobox('setValue', cur.CategoryID);
                                            break;
                                        }
                                    }
                                }
                            })
                        }
                    }
                    if(VehicleLicenseObj.words_result[1].card_type == 'vehicle_back'){
                        var list2 = VehicleLicenseObj.words_result[1].license_info;
                        //console.log(list2);
                        if(list2.length>0){
                            $(list2).each(function(inde,item){
                                if(item.word_name == '检验记录'){
                                    var result = item.word.substring(0,4) + '-' + item.word.substring(5,7) + '-01';
                                    $('#VehicleModify_CheckEndDate').datebox('setValue', result);
                                }
                            })
                        }
                    }
                }


            } else if(msg.status.code == -1000){
                $.messager.alert("提示", msg.status.msg, "", function () {
                    top.location.href = '/Home/SystemLogin';
                });
            } else {
                $.messager.alert("提示", msg.status.msg, "", function () {});
            }

        },
        error: function (a, b, c) {
        }
    });
}

function VehicleModify_showImages(event,t) {
    if(t.src.slice(t.src.length-6)=='wu.png'){
        return
    };
    var mysrc = $(event.target).attr("src");

    var mywidth = $(event.target).prop("naturalWidth");
    var myheight = $(event.target).prop("naturalHeight");

    var imgwidth = 1070;
    var imgheight = 580;
    $("#VehicleModify_ShowImages").attr("src", mysrc);
    var img = new Image();
    img.src = mysrc;

    if (mywidth >= imgwidth && myheight < imgheight) {
        //宽度超出并且高度不超出的情况
        $("#VehicleModify_ShowImages").attr("style", "width:" + imgwidth + "px;");
    } else if (mywidth >= imgwidth && myheight >= imgheight) {
        //宽度超出并且高度超出的情况
        $("#VehicleModify_ShowImages").attr("style", "height:" + imgheight + "px;");
    } else if (mywidth < imgwidth && myheight >= imgheight) {
        //宽度不超出但是高度超出
        $("#VehicleModify_ShowImages").attr("style", "height:" + imgheight + "px;");
    } else{
        //宽度不超出高度也不超出 if (mywidth < imgwidth && myheight < imgheight)
        $("#VehicleModify_ShowImages").attr("style", "width:" + mywidth + "px;height:" + myheight + "px;");
    }

    var box = document.getElementById('VehicleModify_ShowImages');
    box.onclick = function(){
        var newWin = window.open();
        var center = document.createElement('center');
        var img = document.createElement('img');
        img.src = t.src;
        newWin.document.body.appendChild(center)
        newWin.document.getElementsByTagName('center')[0].appendChild(img)
        return newWin;
    }

    $("#VehicleModify_AddDivImageShow").css("display", "block");
    $('#VehicleModify_AddDivImageShow').window({
        title: "查看图片",
        width: 1100,
        height: 620,
        draggable: true,
        modal: true,
        maximizable: false,
        minimizable: false,
        collapsible: false,
        resizable: true,
        onClose: function () {
            $("#VehicleModify_AddDivImageShow").css("display", "none");
        }
    });
}

 

只看图不传图:

<div class="fitem" style="">
                    <div class="fl lh28" style="width:110px;">行驶证:</div>
                    <div style="width: 300px; float: left;">
                        <img src="~/Content/images/wu.png" style="width:200px;height:127px;" onclick="VehicleInfo_showImages(event,this)" id="VehicleInfo_DrivingLicense" />
                    </div>
                </div>

<div class="ui-Receiving" id="VehicleInfo_AddDivImageShow" style="display: none;">
        <div class="ui-Receiving-content">
            <div class="Receiving">
                <div class="Receiving-con" style="text-align:center">
                    <img id="VehicleInfo_ShowImages" />
                </div>
            </div>
        </div>
    </div>
//绑值:
$('#VehicleInfo_DrivingLicense')[0].src = (res.VehicleLicense == '' || res.VehicleLicense == null) ? '/Content/images/wu.png' : res.VehicleLicense;

function VehicleInfo_showImages(event,t) {
    if(t.src.slice(t.src.length-6)=='wu.png'){
        return
    };
    var mysrc = $(event.target).attr("src");

    var mywidth = $(event.target).prop("naturalWidth");
    var myheight = $(event.target).prop("naturalHeight");

    var imgwidth = 1070;
    var imgheight = 580;
    $("#VehicleInfo_ShowImages").attr("src", mysrc);
    var img = new Image();
    img.src = mysrc;

    if (mywidth >= imgwidth && myheight < imgheight) {
        //宽度超出并且高度不超出的情况
        $("#VehicleInfo_ShowImages").attr("style", "width:" + imgwidth + "px;");
    } else if (mywidth >= imgwidth && myheight >= imgheight) {
        //宽度超出并且高度超出的情况
        $("#VehicleInfo_ShowImages").attr("style", "height:" + imgheight + "px;");
    } else if (mywidth < imgwidth && myheight >= imgheight) {
        //宽度不超出但是高度超出
        $("#VehicleInfo_ShowImages").attr("style", "height:" + imgheight + "px;");
    } else{
        //宽度不超出高度也不超出 if (mywidth < imgwidth && myheight < imgheight)
        $("#VehicleInfo_ShowImages").attr("style", "width:" + mywidth + "px;height:" + myheight + "px;");
    }

    var box = document.getElementById('VehicleInfo_ShowImages');
    box.onclick = function(){
        var newWin = window.open();
        var center = document.createElement('center');
        var img = document.createElement('img');
        img.src = t.src;
        newWin.document.body.appendChild(center)
        newWin.document.getElementsByTagName('center')[0].appendChild(img)
        return newWin;
    }
    $("#VehicleInfo_AddDivImageShow").css("display", "block");
    $('#VehicleInfo_AddDivImageShow').window({
        title: "查看图片",
        width: 1100,
        height: 520,
        draggable: true,
        modal: true,
        maximizable: false,
        minimizable: false,
        collapsible: false,
        resizable: true,
        onClose: function () {
            $("#VehicleInfo_AddDivImageShow").css("display", "none");
        }
    });
}

 

 

 

传文件:

<div class="fitem clear" id="gw1">
                <div class="fl lh28" style="width:80px;">附件一:</div>
                <input id="fb1" class="easyui-textbox" editable="false" labelposition="left" style="width:260px;" type="text" name="fb1" autocomplete="off" />
                <input type="file" id="file1" class="ffii" style="width:333px;height:30px;line-height:30px; display: none">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="fb1Fn()" style="width: 70px;">选择文件</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" id="addbtn1" onclick="addRow1()" style="width: 30px;"></a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" id="redbtn1" onclick="reduceRow1()" style="width: 30px"></a>
                <input type="hidden" id="baseT1" name="baseTT" value="">
            </div>
            <div class="fitem clear" id="gw2" style="display: none">
                <div class="fl lh28" style="width:80px;">附件二:</div>
                <input id="fb2" class="easyui-textbox" editable="false" labelposition="left" style="width:260px;" type="text" name="fb2" autocomplete="off" />
                <input type="file" id="file2" class="ffii" style="width:333px;height:30px;line-height:30px; display: none">
                <a href="javascript:void(0)" class="easyui-linkbutton" onclick="fb2Fn()" style="width: 70px;">选择文件</a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-add" id="addbtn2" onclick="addRow2()" style="width: 30px"></a>
                <a href="javascript:void(0)" class="easyui-linkbutton" iconcls="icon-cancel" id="redbtn2" onclick="reduceRow2()" style="width: 30px"></a>
                <input type="hidden" id="baseT2" name="baseTT" value="">
            </div>
myUpload()

function myUpload(){
    $("#file1").change(function(){
        var file = this.files[0];
        if(typeof file=='undefined'){
            return
        }
        var file_typename = file.name.substring(file.name.lastIndexOf('.'), file.name.length);
        if(!flagHZ(file_typename)){
            $("#baseT1").val("");//文件base64
            $("#baseT1").prop('title',"");//文件名
            $("#baseT1").attr('houzhui',"");//后缀名
            $("#baseT1").attr('addr',"");//url
            $("#file1").val("");
            $("#fb1").textbox('setValue','');//文件名
            $.messager.alert("提示", "请上传后缀名为:.doc或.docx或.xls或.xlsx或.pdf或.rar或.jpeg或.jpg或.png的文件", "", function () {});
            return
        }
        $("#fb1").textbox('setValue',file.name);//文件名
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function () {
            $("#baseT1").val(reader.result.split(',')[1])//文件base64
            $("#baseT1").prop('title',file.name)//文件名
            $("#baseT1").attr('houzhui',file_typename)//后缀名
            $("#baseT1").attr('addr',"")//url
        };
    })
    $("#file2").on('change',function(){
        var file = this.files[0];
        if(typeof file=='undefined'){
            return
        }
        var file_typename = file.name.substring(file.name.lastIndexOf('.'), file.name.length);
        if(!flagHZ(file_typename)){
            $("#baseT2").val("");
            $("#baseT2").prop('title',"");
            $("#baseT2").attr('houzhui',"");
            $("#baseT2").attr('addr',"");
            $("#file2").val("");
            $("#fb2").textbox('setValue','');
            $.messager.alert("提示", "请上传后缀名为:.doc或.docx或.xls或.xlsx或.pdf或.rar或.jpeg或.jpg或.png的文件", "", function () {});
            return
        }
        $("#fb2").textbox('setValue',file.name);
        var reader = new FileReader();
        reader.readAsDataURL(file);
        reader.onload = function () {
            $("#baseT2").val(reader.result.split(',')[1])//文件base64
            $("#baseT2").prop('title',file.name)//后缀名
            $("#baseT2").attr('houzhui',file_typename)//后缀名
            $("#baseT2").attr('addr',"")//url
        };
    })
}

function fb1Fn(){$("#file1").click()}
function addRow1(){ $("#gw2").show();$("#addbtn1").hide(); }
function reduceRow1(){
    $("#baseT1").val("");//文件base64
    $("#baseT1").prop('title',"");//文件名
    $("#baseT1").attr('houzhui',"")//后缀名
    $("#baseT1").attr('addr',"")//url
    $("#file1").val("");
    $("#fb1").textbox('setValue','');//文件名
    $("#fb1").textbox({icons: []});
    $("#file1").replaceWith('<input type="file" id="file1" class="ffii" style="width:333px;height:30px;line-height:30px; display: none">')
    myUpload();
}
function fb2Fn(){$("#file2").click()}
function addRow2(){ $("#gw3").show();$("#addbtn2").hide(); }
function reduceRow2(){
    $("#baseT2").val("");
    $("#baseT2").prop('title',"");
    $("#baseT2").attr('houzhui',"");//后缀名
    $("#baseT2").attr('addr',"");//url
    $("#file2").val("");
    $("#fb2").textbox('setValue','');
    $("#fb2").textbox({icons: []});
    $("#file2").replaceWith('<input type="file" id="file2" class="ffii" style="width:333px;height:30px;line-height:30px; display: none">')
    myUpload();
}

function flagHZ(str){
    var flag = false;
    var ary = ['.doc','.docx','.xls','.xlsx','.pdf','.rar','.jpeg','.jpg','.png'];
    for(var i=0;i<ary.length;i++){
        if(str == ary[i]){
            flag = true
            break;
        }
    }
    return flag;
}

获取绑值:
          if(res.File1 != ''){
                    var obj1 = JSON.parse(res.File1);
                    $("#fb1").textbox('setValue',obj1.FileName)//文件名
                    $("#baseT1").prop('title',obj1.FileName);//文件名
                    $("#baseT1").attr('addr',obj1.FileUrl);//url
                    $("#baseT1").attr('houzhui',obj1.FileExtention);//后缀名
                    $("#fb1").textbox({
                        icons: [{
                            iconCls:'icon-search',
                            handler: function(e){
                                window.open(obj1.FileUrl, 'top')
                            }
                        }]
                    })
                }
                if(res.File2 != ''){
                    $("#addbtn1").hide();
                    $("#gw2").show();
                    var obj2 = JSON.parse(res.File2);
                    $("#fb2").textbox('setValue',obj2.FileName)//文件名
                    $("#baseT2").prop('title',obj2.FileName);//文件名
                    $("#baseT2").attr('addr',obj2.FileUrl);//url
                    $("#baseT2").attr('houzhui',obj2.FileExtention);//后缀名
                    $("#fb2").textbox({
                        icons: [{
                            iconCls:'icon-search',
                            handler: function(e){
                                window.open(obj2.FileUrl, 'top')
                            }
                        }]
                    })
                }

提交:
   var strJsonFile = '';
    var ary = [];
    var Extentions = '';
    var OldFileNames = '';
    $("input[name='baseTT']").each(function(index,item){
        var obj = {};
        var cur = $(item);
        //console.log(cur.val());
        if(cur.val() != '' && cur.attr('addr') == ''){
            obj.FileName = cur.prop('title');//文件名
            obj.FileUrl = '';//url
            obj.FileExtention = cur.attr('houzhui');//后缀名
            obj.FileBase64s = cur.val();//64
            ary.push(obj)
        }else if(cur.val() == '' && cur.attr('addr') != '' && cur.attr('addr') != undefined){
            obj.FileName = cur.prop('title');//文件名
            obj.FileUrl = cur.attr('addr');//url
            obj.FileExtention = cur.attr('houzhui');//后缀名
            obj.FileBase64s = '';//64
            ary.push(obj)
        }
    })
    if(ary.length > 0){
        strJsonFile = JSON.stringify(ary)
    }

 

编辑器:

<link href="~/Scripts/Kindeditor/themes/default/default.css" rel="stylesheet" />
<!--编辑器!!!-->
            <div class="fitem">
                <span class="fl lh28" style="width:80px;">内容:</span>
                <div class="details_text" style="width: 700px; height: 500px; float: left;">
                    <textarea id="editor_id" style="height: 500px; width: 670px" name="content"></textarea>
                </div>
            </div>
<script type="text/javascript" src="~/Scripts/Kindeditor/kindeditor-all.js"></script>
<script type="text/javascript" src="~/Scripts/Kindeditor/zh-CN.js"></script>
var kindeditor;

//初始化图片上传控件
    KindEditor.ready(function (K) {
        kindeditor = K.create('#editor_id', {
            //uploadJson: '/Management/UploadPic?type=1&result=' + result + "&imgUrl=" + imgUrl + "&returnType=" + returnType,
            uploadJson: web_dir + '/Management/UploadPic?type=1',//指定上传文件的服务器端程序。
            allowFileManager: false,//true时显示浏览远程服务器按钮。
            pasteType: 1,//设置粘贴类型,0:禁止粘贴, 1:纯文本粘贴, 2:HTML粘贴

            //urlType,//指定编辑器的根目录路径。数据类型: String;默认值: 根据kindeditor.js文件名自动获取
            afterCreate: function () {//设置编辑器创建后执行的回调函数。
                var self = this;
                K.ctrl(document, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
                K.ctrl(self.edit.doc, 13, function () {
                    self.sync();
                    K('form[name=example]')[0].submit();
                });
            },
            items: [
                'source', '|', 'undo', 'redo', '|', 'preview', 'print', 'template', 'cut', 'copy', 'paste',
                'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
                'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'indent', 'outdent', 'subscript',
                'superscript', 'clearhtml', 'quickformat', 'selectall', '|', 'fullscreen', '/',
                'formatblock', 'fontname', 'fontsize', '|', 'forecolor', 'hilitecolor', 'bold',
                'italic', 'underline', 'strikethrough', 'lineheight', 'removeformat', '|', 'image',
                'flash', 'media', 'insertfile', 'table', 'hr', 'emoticons', 'code', 'pagebreak',
                'link', 'unlink', '|', 'about'
            ]//配置编辑器的工具栏,其中”/”表示换行,”|”表示分隔符。
        });
    });

//获取绑值(要转码):
kindeditor.html(unescape(res.NewsContent));

//提交(要转码):
var detailHtmlStr = escape(kindeditor.html());

 

posted @ 2021-11-02 11:15  石头记1  阅读(5)  评论(0)    收藏  举报