add.html 8.65 KB
<!DOCTYPE html>
<html lang="zh-CN"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<title>添加|后台管理系统</title>
<link rel="stylesheet" type="text/css" href="__PUB__style/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="__PUB__style/pp.css">
<link rel="stylesheet" type="text/css" href="__PUB__style/bootstrap-responsive.min.css">
<script type="text/javascript" src="__PUB__js/bootstrap.min.js"></script>
<script type="text/javascript" src="__PUB__js/jquery.min.js"></script>
<script type="text/javascript" src="__PUB__js/common.js"></script>

<link rel="stylesheet" href="__ROOTPUB__kindeditor/themes/default/default.css" />
<script charset="utf-8" src="__ROOTPUB__kindeditor/kindeditor-min.js"></script>
<script charset="utf-8" src="__ROOTPUB__kindeditor/lang/zh_CN.js"></script>
<script>
KindEditor.ready(function(K) {
	var editor = K.create('textarea[name="content"]', {
		uploadJson : "<{:U('Kind/upload_json')}>",
		fileManagerJson : "<{:U('Kind/file_manager_json')}>",
		allowFileManager : true
	});
	
	var editor1 = K.editor({
		uploadJson : "<{:U('Kind/upload_json')}>",
		fileManagerJson : "<{:U('Kind/file_manager_json')}>",
		allowFileManager : true
	});
	K('#uploadid').click(function() {
		editor1.loadPlugin('image', function() {
			editor1.plugin.imageDialog({
				imageUrl : K('#picid').val(),
				clickFn : function(url, title, width, height, border, align) {
					K('#picid').val(url);
					document.getElementById('picida').src=url;
					editor1.hideDialog();
				}
			});
		});
	});
	K('#uploadfid').click(function(){
		editor1.loadPlugin('insertfile', function(){
			editor1.plugin.fileDialog({
				fileUrl : K('#fileid').val(),
				clickFn : function(url, title) {
					K('#fileid').val(url);
					editor1.hideDialog();
				}
			});
		});
	});
	
	K('#J_selectImage').click(function() {
		editor1.loadPlugin('multiimage', function() {
			editor1.plugin.multiImageDialog({
				clickFn : function(urlList) {
					var div = K('#img');
					// div.html('');
					K.each(urlList, function(i, data) {
						div.append('<p><img src="' + data.url + '" /><input type="hidden" name="img[]" value="' + data.url + '" /></p>');
					});
					editor1.hideDialog();
				}
			});
		});
	});

});

$(document).ready(function(){
	$("#tid").click(function(){
		var vvv=$(this).children('option:selected').attr('upid');
		var shangid=$(this).children('option:selected').val();
		$(this).attr('gupid',vvv);
		$(this).attr('shangid',shangid);
	}).change(function(){
		var val=$(this).children('option:selected').val();
		var is=$(this).children('option:selected').attr('is');
		var upid=$(this).children('option:selected').attr('upid');
		
		var upupid=$(this).attr('gupid');
		
		if(is!=1){
			alert('该栏目不允许添加文章!');
			$(this).val($(this).attr('shangid'));
			//location.reload();
		}else{
			if(upupid!=upid){
				window.location.href="<{:U('add',array(),'')}><{:C('URL_PATHINFO_DEPR')}>tid<{:C('URL_PATHINFO_DEPR')}>"+val;
			}
			
			//picnum附件类型判断
			$.get("<{:U('getPicnum')}>", {tid:val}, function(data){
				for(var k=1; k<=3; k++)
				{
					checkPicnum(data,k);
				}
			});
		}
	});
	//删除图片
	$("#img").delegate("p","click",function(){
		if(window.confirm('你确定要删除此图片吗?')){
			var p=$(this);
			var f=p.children('img').attr('src');
			var validate={
				file:f
			};
			$.get("<{:U('delFile')}>", validate, function(data){
				if(data == 'yes')
				{
					p.remove();
				}
				else
				{
					alert('删除失败');
				}	
			});
		}
	});
 });
	function checkPicnum(data,num)
	{
		if(data.indexOf(num)!= -1)
		{
			$(".picnum_"+num).removeClass('display_none');
		}
		else
		{
			$(".picnum_"+num).addClass('display_none');
		}	
	}
	//获取单图、多图尺寸
	$(function(){
		var val=$('#tid').children('option:selected').val();
		$.get('<{:U('getchicun','','')}>',{'tid':val},function(data){
			$('#uploadid + span').text('(尺寸:'+data.img_size+')');	//单图
			$('#J_selectImage + span').text('(尺寸:'+data.imgs_size+')');	//多图
		},'json');
	});
</script>
<style>
#tid {
font-family: "宋体";
}
</style>
</head>

<body style="margin: 10px 0px;">
<div style="margin: 0px auto; width: 98%;">
<form name="form1" action="" method="post" style="">
<table class="table table-condensed table-bordered table-hover" style="">
<tbody style="">
	<tr>
		<td colspan="4">
			<div style="float:left">
				<b>添加</b>
			</div>
			<div style="float:right">
				[<a href="<{:U('index',array('tid'=>I('tid'),'p'=>I('p')))}>"><u>返回列表</u></a>]
			</div>
		</td>
	</tr>
	<tr>
		<td class="text_right_wid_90"><font color="red">所属栏目:</font></td>
		<td colspan="3">
			<span id="typeidct">
			<select name="tid" id="tid">
				<volist name="cat_list" id="vo">
				<option value="<{$vo.id}>" upid="<{$vo.upid}>" is="<{$vo.type}>" <neq name="vo.type" value="1">style="background:#CCC; color:#888;"</neq> <if condition="$vo.id eq $_GET['tid']">selected</if> >
					<{$vo.tname}>
				</option>
				</volist>

			</select>
			</span>
			(<font color="red">注:红色字为必填项</font>)
		</td>
	</tr>
	
	<tr>
		<td class="text_right_wid_90"><font color="red">标题:</font></td>
		<td colspan="3">
			<input name="title" type="text" id="title" class="txt_title" value=""> (<font color="red">注:红色字为必填项</font>)
		</td>
	</tr>
	<tr>
		<td class="text_right_wid_90">作者:</td>
		<td class="width_430">
			<input name="editor" type="text" id="writer" value="">
		</td>
		<td class="text_right_wid_90">来源:</td>
		<td>
			<input type="text" name="source" id="sourceid" value="">
		</td>
	</tr>
	
	<tr>
		<td class="text_right_wid_90">状态:</td>
		<td>
			<input name="isshow" type="radio" value="0" > 待审核 &nbsp; <input name="isshow" type="radio" value="1" checked>审核
		</td>
		<td class="text_right_wid_90">
			关联属性:
		</td>
		<td>
			<!-- <input id="flag" class="np" type="checkbox" value="h" name="flag[]">热门(h) &nbsp;  --><input id="flag" class="np" type="checkbox" value="r" name="flag[]">推荐(r)
		</td>
	</tr>
	
	
	<tr class="picnum_1 <if condition="!strstr($picnum,'1')">display_none</if>">
		<td class="text_right_wid_90">缩 略 图:</td>
		<td>
			<input name="thumb" type="text" id="picid" value=""><input type="button" value="上传图片" style="cursor:pointer;" id="uploadid"> <span style="color:#ccc;"></span>
		</td>
		<td colspan="2">
			<img src="<{$data.thumb|Thumb}>" id="picida" style=" max-height:60px; max-width:100px;">
		</td>
	</tr>
	
	
	<tr class="picnum_2 <if condition="!strstr($picnum,'2')">display_none</if>">
		<td class="text_right_wid_90">内容页多图:</td>
		<td colspan="3">
			<input type="button" id="J_selectImage" value="批量上传" /> <span style="color:#ccc;"></span>
		</td>
	</tr>
	<tr class="picnum_2 <if condition="!strstr($picnum,'2')">display_none</if>">
		<td colspan="4" id="img"></td>
	</tr>

	

	<tr class="picnum_3 <if condition="!strstr($picnum,'3')">display_none</if>">
		<td class="text_right_wid_90">附 件:</td>
		<td colspan="3">
			<input name="file" type="text" id="fileid" value=""><input type="button" value="上传附件" style="cursor:pointer;" id="uploadfid">
		</td>
	</tr>

	
	<tr>
		<td class="text_right_wid_90">排序:</td>
		<td colspan="3">
			<input class="width_120" name="sort" id="orderid" value="<{$maxsort}>" type="text">
		</td>
	</tr>
	
	<tr>
		<td class="text_right_wid_90">价格:</td>
		<td colspan="3"><input class="width_120" type="text" name="price" id="price" value=""></td>
	</tr>
    
	<tr>
		<td style="text-align:right; vertical-align:middle">关 键 字:</td>
		<td colspan="3"><input type="text" name="keywords" id="keywordid" value="" style="width:50%"> &nbsp;(注:多个用","分开)</td>
	</tr>
  
	<tr>
		<td style="text-align:right; vertical-align:middle">内容摘要:</td>
		<td colspan="3"><textarea name="description" rows="2" id="descriptionid" style="width:98%;"></textarea></td>
	</tr>
	<tr style="">
		<td style="text-align:right; vertical-align:middle"><font color="red">内容:</font></td>
		<td colspan="3" style=""><textarea name="content" id="content" style="width: 99%; height:500px; display: none;"></textarea></td>
	</tr>
	<tr>
		<td></td>
		<td colspan="3">
			<button class="btn btn-large btn-info" type="submit" style="cursor:pointer;">保存</button>
			<button class="btn btn-large btn-info" type="reset" onclick="location.reload();" style="cursor:pointer;">重置</button>
		</td>
	</tr>
</tbody>
</table>
</form>
</div>
</body>
</html>