<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="edit.aspx.cs" Inherits="wjdhcms_SAAS.module.content.edit" %>



<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=8">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>内容</title>
    <!-- start: CSS file-->
    <!-- Vendor CSS-->
    <link href="../static/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet" />
    <link href="../static/vendor/skycons/css/skycons.css" rel="stylesheet" />
    <link href="../static/vendor/font-awesome/css/font-awesome.min.css" rel="stylesheet" />
    <!-- Plugins CSS-->
    <link href="../static/plugins/bootkit/css/bootkit.css" rel="stylesheet" />
    <!-- <link href="../static/plugins/jquery-ui/css/jquery-ui-1.10.4.min.css" rel="stylesheet" />  -->

    <link href="../static/plugins/bootstrap-datepicker/css/datepicker3.css" rel="stylesheet" />    
    <link href="../static/plugins/bootstrap-tagsinput/css/bootstrap-tagsinput.css" rel="stylesheet" />      
    

    <!-- Page CSS -->   
    <link href="../static/css/style.css" rel="stylesheet" />
    <link href="../static/css/add-ons.min.css" rel="stylesheet" />

    <!-- end: CSS file--> 
    <!-- Head Libs -->
    <script src="../static/plugins/modernizr/js/modernizr.js"></script>
    
    <!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
      <script src="../static/js/html5shiv.min.js"></script>
      <script src="../static/js/respond.min.js"></script>
    <![endif]-->
    




</head>
<body class="mainbody">
  <div class="container-fluid">
    <div class="row">
      <div class="col-lg-12">
        <div class="panel wizard-type1" id="wizard2">
          <form id="form" data-toggle="formcache">
                <div class="panel-heading bk-bg-primary">
                  <ul class="steps">
                      <li><a href="#tab11" data-toggle="tab"><span class="badge badge-info"><i class="fa fa-file-text"></i></span>基本信息</a></li>
                      <li><a href="#tab12" data-toggle="tab"><span class="badge badge-info"><i class="fa fa-paperclip"></i></span>附加信息</a></li>
                      <li><a href="#tab13" data-toggle="tab"><span class="badge badge-info"><i class="fa fa-sitemap"></i></span>SEO选项</a></li>
                      <li><a href="#tab14" data-toggle="tab"><span class="badge badge-info"><i class="fa fa-plus-square-o"></i></span>拓展选项</a></li>
                    </ul>
                    <div class="progress thin progress-striped active">
                      <div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100" style="width: 0%;">
                      </div>
                    </div>
                </div>
                <div class="panel-body">
                  <div>
                    <div class="tip">
                    </div>
                    <div class="tab-content">
                      <div class="tab-pane" id="tab11">
                        <div class="row">
                          <div class="col-sm-12">
                            <div class="form-horizontal">

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="title">标题</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*标题最多100个字符</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <input type="text" id="title" name="title" class="form-control" value="">
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="thumb">缩略图</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">产品缩略图</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2 img-upload">
                                  <input type="text" id="thumb" name="thumb" class="form-control" value="">
                                  <div class="upload-box upload-img"></div>
                                </div>
                              </div>
                              <div id="productmodels">
                              </div>
                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="coreword">核心词</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*信息的一个核心词，用于关联信息</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <input type="text" id="coreword" name="coreword" class="form-control" value="">
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="tags">相关标签</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*建议填写3-5个词，每个词写完后点击英文“,”或回车</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <input type="text" id="tags" name="tags" class="form-control" data-role="tagsinput" data-tag-class="label label-primary" value="">
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="zhaiyao">内容摘要</label>
                                <div class="col-md-6">
                                  <textarea id="zhaiyao" name="zhaiyao" rows="3" class="form-control"></textarea>
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="content">内容描述</label>
                                <div class="col-md-11">
                                <textarea type="text" class="form-control" id="content" name="content"></textarea>
                                </div>
                              </div>

                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="tab-pane" id="tab12">
                        <div class="row">
                          <div class="col-sm-12">
                            <div class="form-horizontal">
                              <div class="form-group">
                                <label class="col-xs-6 col-md-1 control-label">图片显示模式</label>
                                <div class="col-xs-6 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">这里是文字说明</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2 dfjb text-left">
                                  <div class="radio-custom radio-inline">
                                    <input type="radio" id="shape_0" name="shape" value="0" checked> 
                                    <label for="shape_0">全局</label>
                                  </div>
                                  <div class="radio-custom radio-inline">
                                    <input type="radio" id="shape_3" name="shape" value="3"> 
                                    <label for="shape_3">拉伸</label>
                                  </div>
                                  <div class="radio-custom radio-inline">
                                    <input type="radio" id="shape_2" name="shape" value="2"> 
                                    <label for="shape_2">居中</label>
                                  </div>
                                  <div class="radio-custom radio-inline">
                                    <input type="radio" id="shape_1" name="shape" value="1"> 
                                    <label for="shape_1">裁切</label>
                                  </div>
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label">信息属性</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">这里是文字说明</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2 dfjb text-left">
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="hot" name="hot" value="1"> 
                                    <label for="hot">热门</label>
                                  </div>
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="top" name="top" value="1"> 
                                    <label for="top">置顶</label>
                                  </div>
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="tuijian" name="tuijian" value="1"> 
                                    <label for="tuijian">推荐</label>
                                  </div>
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="neilian" name="neilian" value="1"> 
                                    <label for="neilian">内链</label>
                                  </div>  
                                </div>
                              </div>
							   <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label">同步</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">B2B需要开店，微博需要授权</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2 dfjb text-left">
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="b2b" name="b2b" value="1"> 
                                    <label for="hot">B2B</label>
                                  </div>
                                  <div class="checkbox-custom checkbox-inline">
                                    <input type="checkbox" id="weibo" name="weibo" value="1"> 
                                    <label for="top">微博</label>
                                  </div>
                              
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="listorder">排序</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*填写数字</span>
                                </div>
                                <div class="col-xs-12 col-md-1 col-md-pull-2">
                                  <input type="text" id="listorder" name="listorder" class="form-control" placeholder="Text" value="99">
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="hits">游览次数</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*填写数字</span>
                                </div>
                                <div class="col-xs-12 col-md-1 col-md-pull-2">
                                  <input type="text" id="hits" name="hits" class="form-control" placeholder="Text" value="99">
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="update_time">定时发布时间</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right"></span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <div class="input-group">                                    
                                    <input type="text" id="update_time" name="update_time" data-plugin-datepicker class="form-control" />
                                    <span class="input-group-addon">
                                      <i class="fa fa-calendar"></i>
                                    </span>
                                  </div>
                                </div>
                              </div>
                              <div class="form-group" id="djlm">

                              </div>
                            </div>
                          </div>
                        </div>
                      </div>
                      <div class="tab-pane" id="tab13">
                        <div class="row">
                          <div class="col-sm-12">
                            <div class="form-horizontal">
                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="seotitle">SEO标题</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*标题最多100个字符</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <input type="text" id="seotitle" name="seotitle" class="form-control" placeholder="请填写SEO标题,如果不填写则直接用标题" value="">
                                </div>
                              </div>

                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="keywords">SEO关键词</label>
                                <div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*标题最多100个字符</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <input type="text" id="keywords" name="keywords" class="form-control" data-role="tagsinput" data-tag-class="label label-primary" value="">
                                </div>
                              </div>
                              <div class="form-group">
                                <label class="col-xs-4 col-md-1 control-label" for="description">SEO描述</label><div class="col-xs-8 col-md-2 col-md-push-4">
                                  <span class="help-block text-right">*标题最多200个字符</span>
                                </div>
                                <div class="col-xs-12 col-md-4 col-md-pull-2">
                                  <textarea name="description" id="description" rows="3" class="form-control" placeholder="请填写描述"></textarea>
                                </div>
                              </div>
                              </div>
                          </div>
                        </div>
                      </div>
                      <div class="tab-pane" id="tab14">
                        <div class="row">
                          <div class="col-sm-12">
                            <div class="form-horizontal" id="custom_fields">
                            </div>
                          </div>
                        </div>
                      </div>
                      
                    </div>
                    <div class="navbar-fixed-bottom" style="padding: 0 25px;">
                    <div class="actions">
                         <input type="hidden" class="btn btn-info" id="id" name="id" value="123123" />     
                      <input type="button" class="btn btn-info" id="submit" value="提交保存" />
                      <input type="button" class="btn btn-primary button-next" name="next" value="下一项" />
                    </div>
                    </div>
                  </div>
                </div>
                </form>
              </div>
      </div>
    </div>
  </div>

    <!-- start: JavaScript-->

    
    <!-- Vendor JS-->       
    <script src="../static/vendor/js/jquery-2.1.1.min.js"></script>
    <script src="../static/vendor/js/jquery-migrate-1.2.1.min.js"></script>
    <script src="../static/vendor/bootstrap/js/bootstrap.min.js"></script>
    <script src="../static/vendor/skycons/js/skycons.js"></script>   
    
    <!-- Plugins JS-->
    <script src="../static/plugins/bootstrap-datepicker/js/bootstrap-datepicker.js"></script>
    <script src="../static/plugins/wizard/js/jquery.bootstrap.wizard.min.js"></script>
    <script src="../static/plugins/bootstrap-tagsinput/js/bootstrap-tagsinput.js"></script>
    <script src="../static/plugins/sisyphus/js/sisyphus.min.js"></script>
    <script src="../static/plugins/editor/kindeditor.js"></script>

    <script src="../static/plugins/webuploader/webuploader.min.js"></script>
    <script src="../static/plugins/webuploader/imgupload.js"></script>    
    
    <!-- Pages JS -->
    <script src="../static/js/pages/form-wizard.js"></script>
    <script src="../static/js/pages/form-elements.js"></script>
    
    <script src="../static/js/ajax.js"></script>
    <!-- end: JavaScript-->

<script type="text/javascript">


    $(function () {
        $('#submit').on("click", function () {
            // alert($('#id').val())
            var json = $('#form').serializeArray();
            //var a = JSON.stringify(json);
            //console.log(a)
            send_json('../../api/content.ashx?action=' + $.getUrlParam('action') + '&catid=<%=catid%>', json, function () {
                window.location.href = document.referrer
            });
            $(this).submit();
        });
    });
    $(function () {
        if ($.getUrlParam('action') == 'edit') {
            get_json('../../api/content.ashx?action=getfield&catid=<%=catid%>', function (data) {
                var list = '';
                for (var i = 0; i < data.data.length; i++) {
                    if (data.data[i].field_type == "text") {
                        var input_text = '<input type="text" id="' + data.data[i].field_eng + '" name="' + data.data[i].field_eng + '" class="form-control" value="">';
                    } else {
                        var input_text = '<textarea id="' + data.data[i].field_eng + '" name="' + data.data[i].field_eng + '" rows="3" class="form-control"></textarea>'

                    }
                    list += ''
                    + '<div class="form-group">'
                        + '<label class="col-xs-4 col-md-1 control-label" for="' + data.data[i].field_eng + '">' + data.data[i].field_name + '</label>'
                        + '<div class="col-xs-8 col-md-2 col-md-push-4">'
                          + '<span class="help-block text-right">' + data.data[i].field_tips + '</span>'
                        + '</div>'
                        + '<div class="col-xs-12 col-md-4 col-md-pull-2">'
                          + input_text
                        + '</div>'
                      + '</div>';
                }
                $('#custom_fields').append(list);
                get_json('../../api/content.ashx?action=getedit&catid=<%=catid%>&id=<%=id%>', function (data) {
                    for (var attr in data.data) {
                        if (attr == "photos") {
                            var content = '';
                            content += ''
                              + '<div class="form-group">'
                               + ' <label class="col-xs-4 col-md-1 control-label" for="' + attr + '">图片相册</label>'
                                + '<div class="col-xs-8 col-md-2 col-md-push-4">'
                                  + '<span class="help-block text-right">产品图集</span>'
                                + '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2 img-upload">'
                                  + '<input type="hidden" id="' + attr + '" name="' + attr + '" class="form-control" value="">'
                                  + '<div class="upload-box upload-imgs"></div>'
                                + '</div>'
                              + '</div>'
                              + '<div class="col-md-12">'
                               + ' <label class="col-xs-4 col-md-1 control-label"></label>'
									+ '<div class="col-xs-8 col-md-2 col-md-push-4">'
									+ '<span class="help-block text-right"></span>'
									+ '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2 photo-list">'
                                + '</div>'
                              + '</div>';
                            $('#productmodels').append(content);
                            if (data.data[attr] != null) {
                                if (data.data[attr].length != 0) {
                                    var photo = data.data[attr].split(',');
                                    for (var i = 0; i < photo.length; i++) {
                                        addImage(photo[i])
                                    };
                                }

                            };
                            $(".upload-imgs").InitUploader({ btntext: "批量上传", multiple: true, water: true, filesize: "20480", sendurl: "../../api/upload_ajax.ashx", swf: "../static/plugins/webuploader/uploader.swf" });
                        } else if (attr == "marketprice") {
                            input_field('市场价格', attr, data.data[attr], '市场的参与价格，不参与计算')
                        } else if (attr == "price") {
                            input_field('销售', attr, data.data[attr], '*出售的实际交易价格')
                        } else if (attr == "longword") {
                            input_field('长尾词', attr, data.data[attr], '*厂家|价格。相关服务会自动附加长');
                        } else if (attr == "preendword") {
                            content = '';
                            content += ''
                              + '<div class="form-group">'
                                + '<label class="col-xs-4 col-md-1 control-label" for="' + attr + '">前/后缀词</label>'
								  + '<div class="col-xs-8 col-md-2 col-md-push-4 dfjb text-left">'
                                  + '<div class="radio-custom radio-inline">'
                                    + '<input type="radio" id="kpreendwordType_1" name="preendWordtype" value="0"> '
                                    + '<label for="kpreendwordType_1">前缀</label>'
                                  + '</div>'
                                  + '<div class="radio-custom radio-inline">'
                                    + '<input type="radio" id="kpreendwordType_2" name="preendWordtype" value="1"> '
                                    + '<label for="kpreendwordType_2">后缀</label>'
                                  + '</div>'
                                + '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2">'
                                  + '<input type="text" id="' + attr + '" name="' + attr + '" class="form-control"  value="' + data.data[attr] + '">'
                                + '</div>'
                              + '</div>';
                            $('#productmodels').append(content);
                        } else if (attr == "preendWordtype") {
                            $('[name="' + attr + '"][value="' + data.data[attr] + '"]').prop('checked', true)
                        } else if (attr == "fields" && data.data[attr] != "") {
                            var fieldsJson = JSON.parse(data.data[attr]);
                            for (model in fieldsJson) {
                                $('#tab14').find('#' + model).val(fieldsJson[model])
                            }
                        } else if (attr == "morecatids") {
                            var djlm = '<label class="col-xs-4 col-md-1 control-label\">多级栏目</label>' +
                                '<div class="col-xs-12 col-md-6">';
                            for (var i = 0; i < data.data.morecatids.length; i++) {
                                for (var j = 0; j < data.data.morecatids[i].list.length; j++) {
                                    var djlm2 = "";
                                    for (var k = 0; k < data.data.morecatids[i].list[j].list.length; k++) {
                                        djlm2 += ''
										+ '<ol class="dd-list">'
											+ '<li class="dd-item">'
												+ '<div class="dd-handle">'
												  + '<div class="checkbox-custom checkbox-inline">'
													+ '<input type="checkbox" id="' + data.data.morecatids[i].list[j].list[k].id + '" name="moreid" value="' + data.data.morecatids[i].list[j].list[k].id + '"> '
													+ '<label for="' + data.data.morecatids[i].list[j].list[k].id + '">' + data.data.morecatids[i].list[j].list[k].catname + '</label>'
												  + '</div>'
												+ '</div>'
											+ '</li>'
										+ '</ol>'
                                    };
                                    djlm += ''
                                      + '<div class="col-sm-6 col-md-6">'
                                          + '<ol class="dd-list">'
                                              + '<li class="dd-item">'
                                                  + '<div class="dd-handle">'
                                                    + '<div class="checkbox-custom checkbox-inline">'
                                                      + '<input type="checkbox" id="' + data.data.morecatids[i].list[j].id + '" name="moreid" value="' + data.data.morecatids[i].list[j].id + '"> '
                                                      + '<label for="' + data.data.morecatids[i].list[j].id + '">' + data.data.morecatids[i].list[j].catname + '</label>'
                                                    + '</div>'
                                                  + '</div>'
                                                  + djlm2
                                              + '</li>'
                                            + '</ol>'
                                          + '</div>'
                                }
                            };
                            djlm = djlm + '</div>';
                            $('#djlm').html(djlm);
                            var moreArry = [];
                            moreArry = data.data.moreid.split(',')
                            for (var i = 0; i < moreArry.length; i++) {
                                $('[name="moreid"][value="' + moreArry[i] + '"]').prop('checked', true);
                            }

                        } else {
                            if ($('[name="' + attr + '"]').is(':checkbox')) {
                                if (data.data[attr] == "1") {
                                    $('#' + attr).prop('checked', true)
                                }
                            } else if ($('[name="' + attr + '"]').is(':radio')) {
                                $('[name="' + attr + '"][value="' + data.data[attr] + '"]').prop('checked', true)
                            } else {
                                if ($('[name="' + attr + '"]').is('#content')) {

                                    $('[name="' + attr + '"]').val(data.data[attr]);
                                    var editor = KindEditor.create('#content', {
                                        width: '100%',
                                        height: '350px',
                                        filterMode: false, //默认不过滤HTML
                                        resizeType: 1,
                                        // filePostName: 'name',
                                        uploadJson: 'http://' + document.domain + '/api/upload_ajax.ashx',
                                        fileManagerJson: '../tools/editor/server/file_manager_json.ashx',
                                        allowFileManager: false,
                                        syncType: form,
                                        afterChange: function () {
                                            this.sync();
                                        }
                                    });

                                } else if ($('[name="' + attr + '"]').is('#update_time')) {
                                    var add_time = formatTime(data.data[attr], "yyyy-MM-dd hh:mm:ss");
                                    $('[name="' + attr + '"]').val(add_time);
                                } else {
                                    $('[name="' + attr + '"]').val(data.data[attr]);
                                }
                            }
                        }
                    }

                    $('[data-role="tagsinput"]').tagsinput();
                });
                $('#form').sisyphus();

            });
        } else {
            get_json('../../api/content.ashx?action=getfield&catid=<%=catid%>', function (data) {
                var list = '';
                for (var i = 0; i < data.data.length; i++) {
                    if (data.data[i].field_type == "text") {
                        var input_text = '<input type="text" id="' + data.data[i].field_eng + '" name="' + data.data[i].field_eng + '" class="form-control" value="">';
                    } else {
                        var input_text = '<textarea id="' + data.data[i].field_eng + '" name="' + data.data[i].field_eng + '" rows="3" class="form-control"></textarea>'

                    }
                    list += ''
                    + '<div class="form-group">'
                        + '<label class="col-xs-4 col-md-1 control-label" for="' + data.data[i].field_eng + '">' + data.data[i].field_name + '</label>'
                        + '<div class="col-xs-8 col-md-2 col-md-push-4">'
                          + '<span class="help-block text-right">' + data.data[i].field_tips + '</span>'
                        + '</div>'
                        + '<div class="col-xs-12 col-md-4 col-md-pull-2">'
                          + input_text
                        + '</div>'
                      + '</div>';
                }
                $('#custom_fields').append(list);
                get_json('../../api/content.ashx?action=getedit&catid=<%=catid%>&id=<%=id%>', function (data) {
                    for (var attr in data.data) {
                        if (attr == "photos") {
                            var content = '';
                            content += ''
                              + '<div class="form-group">'
                               + ' <label class="col-xs-4 col-md-1 control-label" for="' + attr + '">图片相册</label>'
                                + '<div class="col-xs-8 col-md-2 col-md-push-4">'
                                  + '<span class="help-block text-right">产品图集</span>'
                                + '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2 img-upload">'
                                  + '<input type="hidden" id="' + attr + '" name="' + attr + '" class="form-control" value="">'
                                  + '<div class="upload-box upload-imgs"></div>'
                                + '</div>'
                              + '</div>'
                              + '<div class="col-md-12">'
                               + ' <label class="col-xs-4 col-md-1 control-label"></label>'
									+ '<div class="col-xs-8 col-md-2 col-md-push-4">'
									+ '<span class="help-block text-right"></span>'
									+ '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2 photo-list">'
                                + '</div>'
                              + '</div>';
                            $('#productmodels').append(content);
                            $(".upload-imgs").InitUploader({ btntext: "批量上传", multiple: true, water: true, filesize: "20480", sendurl: "../../api/upload_ajax.ashx", swf: "../static/plugins/webuploader/uploader.swf" });
                        } else if (attr == "marketprice") {
                            input_field('市场价格', attr, data.data[attr], '市场的参与价格，不参与计算')
                        } else if (attr == "price") {
                            input_field('销售', attr, data.data[attr], '*出售的实际交易价格')
                        } else if (attr == "longword") {
                            input_field('长尾词', attr, data.data[attr], '*厂家|价格。相关服务会自动附加长');
                        } else if (attr == "preendword") {
                            content = '';
                            content += ''
                              + '<div class="form-group">'
                                + '<label class="col-xs-4 col-md-1 control-label" for="' + attr + '">前/后缀词</label>'
                                + '<div class="col-xs-8 col-md-2 col-md-push-4 dfjb text-left">'
                                  + '<div class="radio-custom radio-inline">'
                                    + '<input type="radio" id="kpreendwordType_1" name="preendwordType" value="0" > '
                                    + '<label for="kpreendwordType_1">前缀</label>'
                                  + '</div>'
                                  + '<div class="radio-custom radio-inline">'
                                    + '<input type="radio" id="kpreendwordType_2" name="preendwordType" value="1"> '
                                    + '<label for="kpreendwordType_2">后缀</label>'
                                  + '</div>'
                                + '</div>'
                                + '<div class="col-xs-12 col-md-4 col-md-pull-2">'
                                  + '<input type="text" id="' + attr + '" name="' + attr + '" class="form-control" data-role="tagsinput" data-tag-class="label label-primary"  value="">'
                                + '</div>'
                              + '</div>';
                            $('#productmodels').append(content);
                        } else if (attr == "morecatids") {
                            var djlm = '<label class="col-xs-4 col-md-1 control-label\">多级栏目</label>' +
                                '<div class="col-xs-12 col-md-6">';
                            for (var i = 0; i < data.data.morecatids.length; i++) {
                                for (var j = 0; j < data.data.morecatids[i].list.length; j++) {
                                    var djlm2 = "";
                                    for (var k = 0; k < data.data.morecatids[i].list[j].list.length; k++) {
                                        djlm2 += ''
										+ '<ol class="dd-list">'
											+ '<li class="dd-item">'
												+ '<div class="dd-handle">'
												  + '<div class="checkbox-custom checkbox-inline">'
													+ '<input type="checkbox" id="' + data.data.morecatids[i].list[j].list[k].id + '" name="moreid" value="' + data.data.morecatids[i].list[j].list[k].id + '"> '
													+ '<label for="' + data.data.morecatids[i].list[j].list[k].id + '">' + data.data.morecatids[i].list[j].list[k].catname + '</label>'
												  + '</div>'
												+ '</div>'
											+ '</li>'
										+ '</ol>'
                                    };
                                    djlm += ''
                                      + '<div class="col-sm-6 col-md-6">'
                                          + '<ol class="dd-list">'
                                              + '<li class="dd-item">'
                                                  + '<div class="dd-handle">'
                                                    + '<div class="checkbox-custom checkbox-inline">'
                                                      + '<input type="checkbox" id="' + data.data.morecatids[i].list[j].id + '" name="moreid" value="' + data.data.morecatids[i].list[j].id + '"> '
                                                      + '<label for="' + data.data.morecatids[i].list[j].id + '">' + data.data.morecatids[i].list[j].catname + '</label>'
                                                    + '</div>'
                                                  + '</div>'
                                                  + djlm2
                                              + '</li>'
                                            + '</ol>'
                                          + '</div>'
                                }
                            };
                            djlm = djlm + '</div>';
                            $('#djlm').html(djlm);
                        }
                    }
                    $('[data-role="tagsinput"]').tagsinput();
                });
                $('#form').sisyphus();
                $('[data-role="tagsinput"]').tagsinput();
            });
            var editor = KindEditor.create('#content', {
                width: '100%',
                height: '350px',
                filterMode: false, //默认不过滤HTML
                resizeType: 1,
                uploadJson: 'http://' + document.domain + '/api/upload_ajax.ashx',
                fileManagerJson: '../tools/editor/server/file_manager_json.ashx',
                allowFileManager: false,
                syncType: form,
                afterChange: function () {
                    this.sync();
                }
            });
        }
    });
    function input_field(title, name, value, tip) {
        var content = ''
         + '<div class="form-group">'
           + '<label class="col-xs-4 col-md-1 control-label" for="' + name + '">' + title + '</label>'
           + '<div class="col-xs-8 col-md-2 col-md-push-4">'
             + '<span class="help-block text-right">' + tip + '</span>'
           + '</div>'
           + '<div class="col-xs-12 col-md-4 col-md-pull-2">'
             + '<input type="text" id="' + name + '" name="' + name + '" data-role="tagsinput"  class="form-control" data-tag-class="label label-primary" value="' + value + '">'
           + '</div>'
         + '</div>';
        $('#productmodels').append(content);
        $('[data-role="tagsinput"]').tagsinput();
    }



    $(function () {
        $(".upload-img").InitUploader({ filesize: "20480", sendurl: "../../api/upload_ajax.ashx", swf: "../static/plugins/webuploader/uploader.swf", filetypes: "gif,jpg,png" });
        $('#djlm').on('change', 'input[type="checkbox"]', function () {
            if ($(this).is(':checked')) {
                $(this).parent().parent().parent().parent().parent().find('.dd-handle:eq(0) input[type="checkbox"]').attr('checked', true);
                $(this).parent().parent().parent().find('input[type="checkbox"]').attr('checked', true);
            } else {
                $(this).parent().parent().parent().find('input[type="checkbox"]').attr('checked', false);
            }
        })
    });




</script>
</body>
</html>