码迷,mamicode.com
首页 > Web开发 > 详细

ajaxFileUpload与KindEditor

时间:2016-02-15 10:34:58      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html>
<head>
<TITLE>项目管理</TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<LINK href="../images/favicon.ico" rel="shortcut icon" type="image/png">
<LINK href="../css/xfback.css" rel="stylesheet" type="text/css">
<LINK href="../css/temp.css" rel="stylesheet" type="text/css">   
<SCRIPT src="../js/jquery-1.4.2.min.js" type="text/javascript"></SCRIPT>
<SCRIPT src="../js/index.js" type="text/javascript"></SCRIPT>
<script type="text/javascript" src="/p2p/back/js/ticket/common.js" ></script>
<script type="text/javascript" src="/p2p/back/js/ticket/ticket.js" ></script>
<script type="text/javascript" src="/p2p/back/js/ticket/ticketctl.js" ></script>
<SCRIPT src="../js/ajaxfileupload.js" charset="utf-8"></SCRIPT>
<script src="../js/base-js.js" type="text/javascript"></script><!--日历-->
<script src="../js/js-date.js" type="text/javascript"></script><!--日历-->
<script src="../js/city.js" type="text/javascript"></script><!--城市二级联动脚本-->
<script type="text/javascript" src="/p2p/front/js/Validform_v5.2.1.js"></script>
<link href="../kindeditor/themes/default/default.css" type="text/css" charset="utf-8" rel="stylesheet"/>
<script src="../kindeditor/kindeditor-min.js" type="text/javascript" charset="utf-8"></script>
<script src="../kindeditor/lang/zh_CN.js" type="text/javascript" charset="utf-8"></script>
<SCRIPT src="admin-item-add.js" type="text/javascript"></SCRIPT>

<BODY>
<!-- 头部 --> 
<!-- 头部开始 -->
  <div>
    <!-- iframe框架引入head.html文件 -->
    <iframe align="center" src="/p2p/back/common/head.html" style="width:100%; height:106px;" frameborder="no" border="0" marginwidth="0" marginheight="0" scrolling="no"></iframe>
  </div>
  <!-- 头部End -->
<DIV class="xn_c_top_02">
<DIV class="top_span" id="mg_sys"><A href="#">系统设置</A></DIV></DIV><!-- 头部end --> <!-- 内容区域 --> 
<DIV class="xn_c_contentwarp">
<DIV class="xn_c_contentlist">
<DIV class="xn_c_content_left">
<DIV class="xn_c_content_leftul">
<UL>
  <LI>
  <DIV class="xn_c_li_head_one"><!-- 展开样式:xn_c_li_bg_jian -->           
  <DIV class="xn_c_li_bg" id="lab_1"></DIV>
  众筹项目发布</DIV>
  <DIV class="xn_c_li_head_two" id="hi_1"><!-- 当前样式:xn_c_li_head_ishow -->       
      <A class="xn_c_li_head_ishow" id="mg_2" href="/p2p/back/item/admin-item.html">项目列表</A>
  </DIV></LI>
  <LI>
  <DIV class="xn_c_li_head_one">
  <DIV class="xn_c_li_bg" id="lab_2"></DIV>
  客户提交管理</DIV>
  <DIV class="xn_c_li_head_two" id="hi_2">
    <A class="xn_c_li_head_twoli" id="mg_3"  href="/p2p/back/finance/admin-releaselList.html">众筹申请管理</A>
    <A class="xn_c_li_head_twoli" id="mg_5" href="/p2p/back/channel/admin-channelList.html">渠道招商管理</A></DIV></LI>
  <LI>
  <DIV class="xn_c_li_head_one">         
  <DIV class="xn_c_li_bg" id="lab_2"></DIV>
  公告管理</DIV>
  <DIV class="xn_c_li_head_two" id="hi_2">
    <A class="xn_c_li_head_twoli" id="mg_3" href="/p2p/back/news/admin-content.html">公告列表</A></DIV></LI>
</UL></DIV>
<DIV class="xn_c_con_leftbutton">
<DIV class="xn_c_con_enimg">导航点击</DIV></DIV></DIV>
   
<FORM id="myform" name="myform" enctype="multipart/form-data" method="post" >

<DIV class="xn_c_content">
<DIV class="xf_content_add">
<DIV class="xfht_t_j_y_2"><!--右上-->     
<DIV class="xf_ht_obu_fklm" id="myTitle">添加项目</DIV><!-- 借款标基本信息 -->     
<DIV class="xf_ht_news_content">
<DIV class="xf_ht_news_content_t">
<TABLE class="xf_ht_news_content_t_t" border="0" cellspacing="0" cellpadding="0">
  <INPUT name="id" id="id" type="hidden">
  <TBODY>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">合同编号:</TD>
    <TD width="739">
        <INPUT id="contractNo" name="contractNo" class="xfht_zr_input" style="width: 600px;" type="text" datatype="contractNo" nullmsg="请填写合同编号">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目标题:</TD>
    <TD>
        <INPUT id="title" name="title" class="xfht_zr_input" id="edittitle" style="width: 600px;" type="text" datatype="title" nullmsg="请填写项目标题">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">发起人:</TD>
    <TD>
        <INPUT id="name" name="name" class="xfht_zr_input" style="width: 600px;" type="text" datatype="name" nullmsg="请填写发起人">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">联系电话:</TD>
    <TD>
        <INPUT id="mobile" name="mobile" class="xfht_zr_input" style="width: 600px;" type="text" datatype="mobile" nullmsg="请填写联系电话">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目周期:</TD>
    <TD>
      <INPUT name="startTime" id="startTime" class="xfht_zr_input" style="width: 130px;" type="text" datatype="startTime" errormsg="项目起期不能小于当天" nullmsg="请填写项目起期" onClick="return Calendar(‘startTime‘);">
      &nbsp;-&nbsp;
      <INPUT name="endTime" id="endTime" class="xfht_zr_input" style="width: 130px;" type="text" datatype="endTime" errormsg="项目止期至少大于项目起期7天" nullmsg="请填写项目止期" onClick="return Calendar(‘endTime‘);">
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">所属地区:</TD>
    <TD>
      <select  name="city" id="city" onChange="selectcityarea(‘city‘,‘area‘,‘myform‘);" class="xfht_zr_input" style="width:143px; padding:0;" >
        <option selected="selected" value="0">--请选择城市--</option>
      </select>
      &nbsp;-&nbsp;
      <select name="area" id="area" class="xfht_zr_input" style="width:143px; padding:0;" datatype="area" nullmsg="请选择所属地区">
        <option selected="selected" value="0">--请选择地区--</option>
      </select>
      <span class="Validform_checktip"></span>
      <script language="javascript">
        first("city","area","myform",0,0);
      </script>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">所属行业:</TD>
    <TD>
        <select id="industry" name="industry" class="xfht_zr_input" style="width: 310px; padding:0;" datatype="industry" nullmsg="请选择所属行业">
              <option value="0">--请选择--</option>
            <option value="1">金融</option>
            <option value="2">美食</option>
            <option value="3">娱乐</option>
            <option value="4">体育</option>
            <option value="5">影视</option>
            <option value="6">科技</option>
            <option value="7">文化</option>
          </select>
          <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <!-- <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目状态:</TD>
    <TD>
        <select id="state" name="state" class="xfht_zr_input" style="width: 310px; padding:0;" datatype="state" nullmsg="请选择项目状态">
              <option value="0">--请选择--</option>
            <option value="1">预热项目</option>
            <option value="2">融资项目</option>
            <option value="3">完成项目</option>
        </select>
        <span class="Validform_checktip"></span>
    </TD>
  </TR> -->
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目估值:</TD>
    <TD>
        <INPUT id="valuation" name="valuation" class="xfht_zr_input" style="width: 297px;" type="text" datatype="valuation" errormsg="请填写数字" nullmsg="请填写项目估值">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">募集金额:</TD>
    <TD>
        <INPUT id="money" name="money" class="xfht_zr_input" style="width: 297px;" type="text" datatype="money" errormsg="请填写数字" nullmsg="请填写募集金额">
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">回报方式:</TD>
    <TD width="739">
        <select id="returnWay" name="returnWay" class="xfht_zr_input" style="width: 310px; padding:0;" datatype="returnWay" nullmsg="请选择回报方式">
          <option value="0">--请选择--</option>
          <option value="1">现金</option>
          <option value="2">非现金</option>
        </select>
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR id="repay_date" style="display: none">
    <TD width="200" align="right" valign="middle" style=" padding-right: 5px;">回报周期:</TD>
    <TD width="739">
        <select id="returnPeriod" name="returnPeriod" class="xfht_zr_input" style="width: 310px; padding:0;" datatype="returnPeriod" nullmsg="请选择回报周期">
          <option value="0">--请选择--</option>
          <option value="1">1月</option>
          <option value="2">2月</option>
          <option value="3">3月</option>
          <option value="4">4月</option>
          <option value="5">5月</option>
          <option value="6">6月</option>
          <option value="7">7月</option>
          <option value="8">8月</option>
          <option value="9">9月</option>
          <option value="10">10月</option>
          <option value="11">11月</option>
          <option value="12">12月</option>
        </select>
        <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR id="bonus" style="display: none">
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">分红比例:</TD>
    <TD width="739">
        <INPUT id="dividendRatio" name="dividendRatio" class="xfht_zr_input" style="width: 297px;" type="text" datatype="dividendRatio" nullmsg="请填写分红比例" errormsg="请填写数字">&nbsp;&nbsp;%
        <span class="Validform_checktip"></span>
        </TD>
  </TR>
  <!-- <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目视频:</TD>
    <TD>
      <input type="file" id="videoFile" name="videoFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="document.getElementById(‘video‘).value=this.value"/>
      <input type="input" id="video" name="video" class="xfht_zr_input" style="width:525px;"  />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;" />
    </TD>
  </TR> -->
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目Logo:</TD>
    <TD>
      <input type="file" id="logoFile" name="logoFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFile(this,‘logo‘)"/>
      <input type="input" id="logo" name="logo" class="xfht_zr_input" style="width:525px;" datatype="logo" nullmsg="请上传项目Logo" />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">首页同城项目图:</TD>
    <TD>
      <input type="file" id="sameCityImgFile" name="sameCityImgFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFile(this,‘sameCityImg‘)"/>
      <input type="input" id="sameCityImg" name="sameCityImg" class="xfht_zr_input" style="width:525px;" datatype="sameCityImg" nullmsg="请上传同城项目图" />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">首页全国项目图:</TD>
    <TD>
      <input type="file" id="nationwideImgFile" name="nationwideImgFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFile(this,‘nationwideImg‘)"/>
      <input type="input" id="nationwideImg" name="nationwideImg" class="xfht_zr_input" style="width:525px;" datatype="nationwideImg" nullmsg="请上传全国项目图" />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">微信群二维码:</TD>
    <TD>
      <input type="file" id="wechatQrCodeFile" name="wechatQrCodeFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFile(this,‘wechatQrCode‘)"/>
      <input type="input" id="wechatQrCode" name="wechatQrCode" class="xfht_zr_input" style="width:525px;"  />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目介绍二维码:</TD>
    <TD>
      <input type="file" id="itemQrCodeFile" name="itemQrCodeFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFile(this,‘itemQrCode‘)"/>
      <input type="input" id="itemQrCode" name="itemQrCode" class="xfht_zr_input" style="width:525px;"  />
      <input type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
    </TD>
  </TR>
    <TR>
    <TD width="200" align="right" valign="middle" style="padding-right: 5px;">项目协议(word):</TD>
    <TD>
      <input type="file" id="protocolFile" name="protocolFile" style="width:600px;height:28px;position:absolute;opacity:0;filter:alpha(opacity=0);" onchange="checkFileWord(this,‘protocol‘)"/>
      <input type="input" id="protocol" name="protocol" class="xfht_zr_input" style="width:525px;" datatype="protocol" nullmsg="请上传项目协议" />
      <input name="" type="button" value="浏览..." style="width:70px; height:28px; border:1px solid #cdcdcd; color:#000; text-align:center;"/>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
    <TD width="200" align="right" valign="top" style="padding-right: 5px;">项目简介:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="itemIntro" name="itemIntro" datatype="itemIntro" nullmsg="请填写项目简介" ></TEXTAREA>
     </DIV>
     <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" style="padding-right: 5px;">项目介绍:</TD>
    <td>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="itemInfo_focus" style="background:none;border:0;" />
          <textarea class="xf_ht_jr_obttd_textarea" id="itemInfo" name="itemInfo" datatype="itemInfo" nullmsg="请填写项目介绍" ></textarea>
     </DIV>
     <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" style="padding-right: 5px;">融资情况:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="financeSituation_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="financeSituation" name="financeSituation" datatype="financeSituation" nullmsg="请填写融资情况" ></TEXTAREA>
      </DIV>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" style="padding-right: 5px;">股东回报:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="shareholderReturn_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="shareholderReturn" name="shareholderReturn" datatype="shareholderReturn" nullmsg="请填写股东回报" ></TEXTAREA>
      </DIV>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <!-- <TR>
    <TD width="200" align="right" valign="top" style="padding-right: 5px;">投资记录:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="itemInfo_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="investmentRecord" name="investmentRecord" ></TEXTAREA> 
      </DIV>
    </TD>
  </TR> -->
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" 
      style="padding-right: 5px;">融资情况简介:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="financeSituationIntro_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="financeSituationIntro" name="financeSituationIntro" datatype="financeSituationIntro" nullmsg="请填写融资情况简介" ></TEXTAREA>
        </DIV>
        <span class="Validform_checktip"></span>
      </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" 
      style="padding-right: 5px;">股东要求简介:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="shareholderRequestsIntro_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="shareholderRequestsIntro" name="shareholderRequestsIntro" datatype="shareholderRequestsIntro" nullmsg="请填写股东要求简介" ></TEXTAREA>
      </DIV>
      <span class="Validform_checktip"></span>
    </TD>
  </TR>
  <TR>
  <TR>
    <TD width="200" align="right" valign="top" 
      style="padding-right: 5px;">股东回报简介:</TD>
    <TD>
      <DIV class="xf_ht_news_conr">
          <input type="button" id="shareholderReturnIntro_focus" style="background:none;border:0;" />
          <TEXTAREA class="xf_ht_jr_obttd_textarea" id="shareholderReturnIntro" name="shareholderReturnIntro" datatype="shareholderReturnIntro" nullmsg="请填写股东回报简介" ></TEXTAREA>
      </DIV>
      <span class="Validform_checktip"></span>
    </TD>
   </TR>
</TBODY></TABLE></DIV>
<DIV class="xf_ht_news_content_b">
<TABLE class="xf_ht_news_content_t_b" border="0" cellspacing="0" cellpadding="0">
    <TBODY>
        <TR>
            <TD width="34" align="center" valign="top"><INPUT id="isSameCity" name="isSameCity" type="checkbox"/></TD>
            <TD><SPAN style="padding-right: 20px;">首页同城项目</SPAN></TD>
          </TR>
          <TR>
            <TD align="center" valign="middle">&nbsp;</TD>
            <TD>浏览次数设置:<INPUT class="xfht_zr_input" id="visits" name="visits" style="width: 80px;" type="text" value="1"></TD>
        </TR>
    </TBODY>
</TABLE>
</DIV>
<DIV class="xf_ht_news_content_button" >
    <INPUT class="xf_ht_tcc_button_ok" id="submitBtn" type="button" value="确定" />
</DIV>
</DIV>
</DIV>
</DIV>
</DIV>
</FORM>
</DIV>
</DIV>
 
<!-- 底部 --> 
<DIV class="xn_c_bottom">
    <DIV class="xn_c_bottom_left">
        <SPAN class="xn_c_bottom_t">授权单位:深圳喜沃互动网络科技有限公司</SPAN> <BR>
        <SPAN class="xn_c_bottom_t2">售后服务包到期时间:2015-07-01(已过期)</SPAN> 
    </DIV>
    <DIV class="xn_c_bottom_btn">
        <A href="#" target="_Blank">在线提交工单</A>
    </DIV>
    <DIV class="xn_c_bottom_right">
        <DIV class="xn_c_more">
            <A href="#" target="_blank">了解更多</A>       
        </DIV>
        <SPAN class="xn_c_bottom_rightT">当前版本:6.0.13</SPAN>     
    </DIV>
</DIV>
<!-- 底部end -->

</BODY>
</HTML>
var obj = {};

String.prototype.replaceAll = function(s1,s2){ 
    return this.replace(new RegExp(s1,"gm"),s2); 
};

function isNotNull(value){
    if(null != value && "" != value)
        return true;
    return false;
}

function replace(value){
    if(isNotNull(value)){
        return value.replaceAll("\"","‘").replaceAll(";","`");
    }
    return value;
}

function restore(value){
    if(isNotNull(value)){
        return value.replaceAll("`",";");
    }
    return value;
}

//时间戳转换为日期
function formatDate(time)   {
    if(isNotNull(time)){
        var date= new Date(time);
        var year=date.getYear()+1900;     
        var month=date.getMonth()+1;     
        var day=date.getDate();     
        return year + "-" + month + "-" + day;
    }
    return "";
}

//比较日期
function compareDate(startTime, endTime){
    if(isNotNull(startTime) && isNotNull(endTime)){
        var sDate = new Date(startTime.replace(/\-/g, "\/"));
        var eDate = new Date(endTime.replace(/\-/g, "\/"));
        var date = eDate.getTime() - sDate.getTime();
        var day = Math.floor(date/(24*3600*1000));
        if(day < 7){
            return false;
        }
    }
    return true;    
}

//初始化表格
obj.initTable = function(id){
    if(isNotNull(id)){
        $("#myTitle").text("编辑项目");
        $.ajax({
             type: "GET",
             url: "/item/query",
             async: false,
             data: {id : id},
             dataType: "json",
             success: function(data){
                 $("#id").val(data.id);
                $("#contractNo").val(data.contractNo);
                $("#title").val(data.title);
                $("#name").val(data.name);
                $("#mobile").val(data.mobile);
                $("#startTime").val(formatDate(data.startTime));
                $("#startTime").attr(‘disabled‘, true);
                $("#endTime").val(formatDate(data.endTime));
                $("#endTime").attr(‘disabled‘, true);
                if(isNotNull(data.cityCode) && isNotNull(data.areaCode)){
                    first("city","area","myform",data.cityCode,data.areaCode);
                }
                $("#industry").val(data.industry);
                //$("#state").val(data.state);
                $("#valuation").val(data.valuation);
                $("#money").val(data.money);
                $("#returnWay").val(data.returnWay);
                $("#returnWay").attr("disabled","true");
                if(data.returnWay == 1){
                    $("#repay_date").css("display","");
                    $("#bonus").css("display","");
                    $("#returnPeriod").attr("disabled","true");
                    $("#dividendRatio").attr("disabled","true");
                    $("#returnPeriod").val(data.returnPeriod);
                    $("#dividendRatio").val(data.dividendRatio);
                }
                $("#logo").val(data.logo);
                $("#sameCityImg").val(data.sameCityImg);
                $("#nationwideImg").val(data.nationwideImg);
                $("#wechatQrCode").val(data.wechatQrCode);
                $("#itemQrCode").val(data.itemQrCode);
                $("#protocol").val(data.protocol);
                $("#itemIntro").text(data.itemIntro);
                $("#itemInfo").html(data.itemInfo);
                $("#financeSituation").html(data.financeSituation);
                $("#shareholderReturn").html(data.shareholderReturn);
                //$("#investmentRecord").html(data.investmentRecord);
                $("#financeSituationIntro").html(data.financeSituationIntro);
                $("#shareholderRequestsIntro").html(data.shareholderRequestsIntro);
                $("#shareholderReturnIntro").html(data.shareholderReturnIntro);
                if(data.isSameCity == 1){
                    $("#isSameCity").attr("checked", true);
                }
                $("#visits").val(data.visits);
             }
        });
    }
};

//确定按钮事件
obj.okBtn = function(event){
    var id = event.data.id;
    $("#myform").Validform({
        btnSubmit:"#submitBtn", 
        tiptype:function(msg,o,cssctl){
             if(!o.obj.is("form")){
                var objtip=o.obj.parents().children(".Validform_checktip");
                cssctl(objtip,o.type);
                objtip.text(msg);
            }
        },
        ajaxPost:true,
        datatype:{
            //参数gets是获取到的表单元素值,obj为当前表单元素,curform为当前验证的表单,regxp为内置的一些正则表达式的引用;
            "contractNo" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写合同编号!";
                }
                return true;
            },
            "title" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写项目标题!";
                }
                return true;
            },
            "name" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写发起人!";
                }
                return true;
            },
            "mobile" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写联系电话!";
                }
                return true;
            },
            "startTime" : function(gets,obj,curform,regxp){
                if(id == ‘‘){
                    if(gets == ‘‘){
                        return "请填写项目起期!";
                    }
                    if (new Date(gets.replace(/-/g,"/")).toLocaleDateString() < new Date().toLocaleDateString()) {
                           return false;
                    }
                }
                return true;
            },
            "endTime" : function(gets,obj,curform,regxp){
                if(id == ‘‘){
                    if(gets == ‘‘){
                        return "请填写项目止期!";
                    }
                    if(!compareDate(curform.context.startTime.value, gets)){
                        return false;
                    }
                }
                return true;
            },
            "area" : function(gets,obj,curform,regxp){
                if(gets == 0){
                    return "请选择所属地区!";
                }
                return true;
            },
            "industry" : function(gets,obj,curform,regxp){
                if(gets == 0){
                    return "请选择所属行业!";
                }
                return true;
            },
            /*"state" : function(gets,obj,curform,regxp){
                if(gets == 0){
                    return "请选择项目状态!";
                }
                return true;
            },*/
            "valuation" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写项目估值!";
                }
                if(isNaN(gets)){
                    return false;
                }
                return true;
            },
            "money" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写募集金额!";
                }
                if(isNaN(gets)){
                    return false;
                }
                return true;
            },
            "returnWay" : function(gets,obj,curform,regxp){
                if(gets == 0){
                    return "请选择回报方式!";
                }
                return true;
            },
            "returnPeriod" : function(gets,obj,curform,regxp){
                if(curform.context.returnWay.value == 1 && gets == 0){
                    return "请选择回报周期!";
                }
                return true;
            },
            "dividendRatio" : function(gets,obj,curform,regxp){
                if(curform.context.returnWay.value == 1 && gets == ‘‘){
                    return "请填写分红比例!";
                }
                if(isNaN(gets)){
                    return false;
                }
                return true;
            },
            "logo" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请上传项目Logo!";
                }
                return true;
            },
            "sameCityImg" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请上传同城项目图!";
                }
                return true;
            },
            "nationwideImg" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请上传全国项目图!";
                }
                return true;
            },
            "protocol" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请上传项目协议!";
                }
                return true;
            },
            "itemIntro" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    return "请填写项目简介!";
                }
                return true;
            },
            "itemInfo" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#itemInfo_focus").focus();
                    return "请填写项目介绍!";
                }
                return true;
            },
            "financeSituation" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#financeSituation_focus").focus();
                    return "请填写融资情况!";
                }
                return true;
            },
            "shareholderReturn" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#shareholderReturn_focus").focus();
                    return "请填写股东回报!";
                }
                return true;
            },
            "financeSituationIntro" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#financeSituationIntro_focus").focus();
                    return "请填写融资情况简介!";
                }
                return true;
            },
            "shareholderRequestsIntro" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#shareholderRequestsIntro_focus").focus();
                    return "请填写股东要求简介!";
                }
                return true;
            },
            "shareholderReturnIntro" : function(gets,obj,curform,regxp){
                if(gets == ‘‘){
                    $("#shareholderReturnIntro_focus").focus();
                    return "请填写股东回报简介!";
                }
                return true;
            }
        },
        beforeCheck:function(curform){
            //在表单提交执行验证之前执行
        },
        beforeSubmit:function(curform){
            //在验证成功后,表单提交前执行
            obj.editRow(id);
        },
        callback:function(data){
            //这里执行回调操作;
        }
    });
};

//校验图片文件
function checkFile(obj, id){
    var array = [ ".bmp", ".pcx", ".tiff", ".gif", ".jpeg", ".jpg",
                  ".tga", ".exif", ".fpx", ".svg", ".psd", ".cdr", ".pcd",
                  ".dxf", ".ufo", ".eps", ".ai", ".png", ".hdri", ".raw" ];
    var suffix = obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
    var flag = false;
    for (var i = 0; i < array.length; i++) {
        if(suffix == array[i]){
            flag = true;
            break;
        }
    }
    if(!flag){
        alert("图片格式不正确 ");
        return;
    }
    $("#" + id).val(obj.value);
}

//校验word文件
function checkFileWord(obj, id){
    var array = [ ".doc", ".docx" ];
    var suffix = obj.value.substr(obj.value.lastIndexOf(".")).toLowerCase();//获得文件后缀名
    var flag = false;
    for (var i = 0; i < array.length; i++) {
        if(suffix == array[i]){
            flag = true;
            break;
        }
    }
    if(!flag){
        alert("文件格式不正确");
        return;
    }
    $("#" + id).val(obj.value);
}

obj.editRow= function(id){
    if(!isNotNull(id)){
        id = undefined;
    }
    $.ajaxFileUpload({
        url: ‘/item/editRow/id/‘ + id,
        type: ‘post‘,
        secureuri: false,
        fileElementId: [    //文件的id
            ‘logoFile‘, 
            ‘sameCityImgFile‘, 
            ‘nationwideImgFile‘, 
            ‘wechatQrCodeFile‘, 
            ‘itemQrCodeFile‘,
            ‘protocolFile‘
        ],
        dataType: ‘text‘,//返回数据的类型
        data: {            //表单参数
            id: $("#id").val(),
            isSameCity: Number($(‘#isSameCity‘).is(‘:checked‘)),
            contractNo: $("#contractNo").val(),
            title: $("#title").val(),
            name: $("#name").val(),
            mobile: $("#mobile").val(),
            startTime: $("#startTime").val(),
            endTime: $("#endTime").val(),
            city: $("#city").find("option:selected").text(),
            cityCode: $("#city").find("option:selected").val(),
            area: $("#area").find("option:selected").text(),
            areaCode: $("#area").find("option:selected").val(),
            industry: $("#industry").val(),
            //state: $("#state").val(),
            valuation: $("#valuation").val(),
            money: $("#money").val(),
            returnWay: $("#returnWay").val(),
            returnPeriod: $("#returnPeriod").val(),
            dividendRatio: $("#dividendRatio").val(),
            itemIntro: $("#itemIntro").val(),
            itemInfo: replace(window.itemInfo.html()),
            financeSituation: replace(window.financeSituation.html()),
            shareholderReturn: replace(window.shareholderReturn.html()),
            //investmentRecord: replace(window.investmentRecord.html()),
            financeSituationIntro: replace(window.financeSituationIntro.html()),
            shareholderRequestsIntro: replace(window.shareholderRequestsIntro.html()),
            shareholderReturnIntro: replace(window.shareholderReturnIntro.html()),
            visits: $("#visits").val()
        },  
        success: function (data, status){
            alert(data);
            if(data == "保存成功"){
                location.href="/p2p/back/item/admin-item.html";
            }else if(data == "修改成功"){
                location.reload();
            }
        },  
        error: function(data, status, e){  
            alert(e);  
        }  
    });
};

//初始化页面
obj.initHtml = function(id){
    var Repay_type=document.getElementById(‘returnWay‘);
    var Repay_date=document.getElementById(‘repay_date‘);
    var Bonus=document.getElementById(‘bonus‘);
    Repay_type.onchange=function(){
      Repay_date.style.display=this.value==1? "":"none";
      Bonus.style.display=this.value==1? "":"none";
    }
    KindEditor.ready(function(K) {
        var options = {
            filterMode : false,//关闭过滤模式,保留所有标签
            uploadJson : ‘../kindeditor/jsp/upload_json.jsp‘,//指定上传文件的服务器端程序
            fileManagerJson : ‘../kindeditor/jsp/file_manager_json.jsp‘,//指定浏览远程图片的服务器端程序
            allowFileManager : true,//显示文件上传按钮
            afterCreate: function () {
                $(this.edit.iframe.get(0).contentWindow.document).keydown(function (e) {
                    if ((e.ctrlKey || e.metaKey) && e.which == 13 && !e.shiftKey && !e.altKey) {
                        $("#myform").submit();
                    }
                });
            },
            afterChange: function () {
                this.sync();
            },
            items: [‘bold‘, ‘italic‘, ‘underline‘, ‘strikethrough‘, ‘removeformat‘, ‘|‘, ‘insertorderedlist‘, ‘insertunorderedlist‘,
                ‘forecolor‘, ‘hilitecolor‘, ‘fontname‘, ‘fontsize‘, ‘|‘, ‘link‘, ‘unlink‘, ‘emoticons‘,
                ‘shcode‘, ‘image‘, ‘quote‘, ‘|‘, ‘source‘, ‘about‘]
        };
        window.itemInfo = K.create(‘#itemInfo‘, options);
        window.financeSituation = K.create(‘#financeSituation‘, options);
        window.shareholderReturn = K.create(‘#shareholderReturn‘, options);
        //window.investmentRecord = K.create(‘#investmentRecord‘, options);
        var options2 = {
                filterMode : false,//关闭过滤模式,保留所有标签
                uploadJson : ‘../kindeditor/jsp/upload_json.jsp‘,//指定上传文件的服务器端程序
                fileManagerJson : ‘../kindeditor/jsp/file_manager_json.jsp‘,//指定浏览远程图片的服务器端程序
                allowFileManager : true,//显示文件上传按钮
                afterCreate: function () {
                    $(this.edit.iframe.get(0).contentWindow.document).keydown(function (e) {
                        if ((e.ctrlKey || e.metaKey) && e.which == 13 && !e.shiftKey && !e.altKey) {
                            $("#myform").submit();
                        }
                    });
                },
                afterChange: function () {
                    this.sync();
                },
                items: [‘bold‘, ‘italic‘, ‘underline‘, ‘strikethrough‘, ‘removeformat‘, ‘|‘, ‘insertorderedlist‘, ‘insertunorderedlist‘,
                    ‘forecolor‘, ‘hilitecolor‘, ‘fontname‘, ‘fontsize‘, ‘|‘, ‘link‘, ‘unlink‘, ‘emoticons‘,
                    ‘shcode‘, ‘quote‘, ‘|‘, ‘source‘, ‘about‘]
            };
        window.financeSituationIntro = K.create(‘#financeSituationIntro‘, options2);
        window.shareholderRequestsIntro = K.create(‘#shareholderRequestsIntro‘, options2);
        window.shareholderReturnIntro = K.create(‘#shareholderReturnIntro‘, options2);
    });
    obj.initTable(id);
    $("#submitBtn").bind("click", {id: id}, obj.okBtn);
};


//加载页面
$(document).ready(function(){
    var id = "";
    var url = location.href;
    if(url.indexOf("=") != -1){
        id = url.substring(url.indexOf("=") + 1, url.length);
    }
    obj.initHtml(id);
});

技术分享

 

引用资源见文件栏目

 技术分享

ajaxFileUpload与KindEditor

标签:

原文地址:http://www.cnblogs.com/linying/p/5190019.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!