<script language="javascript">
var act = '{$act}';
$(function(){
	$("#addFormBug{$uniqid}").form('load',{
		'title':'<?php echo $info["title"] ?>',
		'type':'<?php echo $info["type"] ?>',
		'os':'<?php echo $info["os"] ?>',
		'projects':'<?php echo $info["project"] ?>',
		'project':'<?php echo $info["project"] ?>'
	});
	
	$("#projects{$uniqid}").combobox({
		url:'__APP__?g=<?php echo GROUP_NAME; ?>&m=Business&a=getProject&act=json&val=name',
		editable:true,
		method:'get',
		valueField:'id',
		textField:'text',
		required:false,
		filter: function(q,r){
			$("#project{$uniqid}").val(q);
			var opts = $(this).combobox('options');
			var v = r[opts.textField];
			var vp = ','+String(getPinYin(v));
			var qp = ','+q.toUpperCase();
			if(vp.indexOf(qp)>=0 || v.indexOf(q) == 0){
				return r[opts.textField];
			}
		},
		onSelect:function(c){
			$("#project{$uniqid}").val(c['id']);
		}
	});
});

function onSubmitBug(idd){
	$.messager.progress();
	$("#toUser"+idd+" option").attr("selected",true);
	$("#addFormBug"+idd).form('submit',{
		url:'__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=add&act=add&go=1',
		onSubmit: function(){
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');
			}
			return isValid;
		},
		success:function(data){
			$.messager.progress('close');
			$("#toUser"+idd+" option").attr("selected",false);
			if(data==1){
				$.messager.alert('提示','新增数据成功！','info',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					$("#Bug").datagrid('reload');
					if(sa==1){
						cancel['Bug'].dialog('close');
						cancel['Bug'] = null;
					}
				});
			}else if(data==0){
				$.messager.alert('提示','新增数据失败！','warning');
			}else if(data<0){
				$.messager.alert('提示','您没有新增权限！','warning',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					if(sa==1){
						cancel['Bug'].dialog('close');
						cancel['Bug'] = null;
					}
				});
			}else{
				$.messager.alert('提示',data,'warning');
			}
		}
	});
}

function onUploadBug(idd){
	$.messager.progress();
	$("#toUser"+idd+" option").attr("selected",true);
	var ids = $("#ids"+idd).val();
	$("#addFormBug"+idd).form('submit',{
		url:'__APP__?g=<?php echo GROUP_NAME; ?>&m=<?php echo MODULE_NAME; ?>&a=add&act=edit&go=1&id='+ids,
		onSubmit: function(){
			var isValid = $(this).form('validate');
			if (!isValid){
				$.messager.progress('close');
			}
			return isValid;
		},
		success:function(data){
			$.messager.progress('close');
			$("#toUser"+idd+" option").attr("selected",false);
			if(data==1){
				$.messager.alert('提示','更新数据成功！','info',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					$("#Bug").datagrid('reload');
					if(sa==1){
						cancel['Bug'].dialog('close');
						cancel['Bug'] = null;
					}
				});
				$("#add").dialog('refresh');
			}else if(data==0){
				$.messager.alert('提示','更新数据失败！','warning');
			}else if(data==2){
				$.messager.alert('提示','只能更新自己所新增的数据！','warning');
			}else if(data<0){
				$.messager.alert('提示','您没有更新权限','warning',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					if(sa==1){
						cancel['Bug'].dialog('close');
						cancel['Bug'] = null;
					}
				});
			}else{
				$.messager.alert('提示',data,'warning');
			}
		}
	});
}

function onResetBug(idd){
	cancel['Bug'].dialog('close');
	cancel['Bug'] = null;
}
</script>

<div class="con-tb">
<form method="post" enctype="multipart/form-data" id="addFormBug{$uniqid}"> 
<table class="infobox" width="100%" border="0" cellspacing="0" cellpadding="0" style="border-collapse: collapse;">
  <tr>
    <td><label for="title">问题描述</label></td>
    <td colspan="3"><input name="title" id="title{$uniqid}" class="easyui-validatebox" data-options="required:true,validType:'ptext'" type="text" style="width:99%" /></td>
    </tr>
  <tr>
    <td width="12%"><label for="type">问题类型</label><input id="ids{$uniqid}" type="hidden" value="{$id}" /></td>
    <td width="32%"><input name="type" id="type{$uniqid}" class="easyui-combobox" data-options="url:'__ITEM__/__RUNTIME__/Data/Json/Linkage/wentileixing_data.json',editable:true,method:'get',valueField:'id',textField:'text',required:true,editable:false" type="text" size="34"/></td>
    <td width="12%"><label for="os">系统平台</label></td>
    <td><input name="os" id="os{$uniqid}" size="34" class="easyui-validatebox" type="text" data-options="required:false,validType:'ptext'" /></td>
    </tr>
  <tr>
    <td><label for="project">对应项目</label></td>
    <td colspan="3"><input name="projects" id="projects{$uniqid}" size="60" class="relo" /><input name="project" id="project{$uniqid}"  type="hidden" value="" /><span class="up-font">（自定义时，请直接输入） </span></td>
    </tr>
  <tr>
    <td><label for="content">详细现象</label></td>
    <td height="225" colspan="3"  ><textarea name="content" id="content{$uniqid}"  rows="18" data-options="uploadJson:'__APP__?g=Public&m=Upload&a=save&act=Bug'" class="easyui-kindeditor" style="width:99%; height:220px;">{$info.baseinfo.content}</textarea></td>
    </tr>
  <tr>
    <td><label for="solution">解决方案</label></td>
    <td height="225" colspan="3"><textarea name="solution" id="solution{$uniqid}"  rows="18" class="easyui-kindeditor" style="width:99%; height:220px" data-options="uploadJson:'__APP__?g=Public&m=Upload&a=save&act=Bug'">{$info.baseinfo.solution}</textarea></td>
    </tr>
   <tr>
    <td><label for="files">附件</label></td>
    <td colspan="3">
     <input name="files" type="file" />&nbsp;<span class="up-font-over">(文件类型：rar、zip)</span>
     <if condition="$act=='edit'">
     <input name="oldfile" type="hidden" value="{$info.files}" />
     <br />&nbsp;<font>附件地址：</font>
     <if condition="$info['files']">
      <font class="up-font">__ITEM__/__UPLOAD__/{$info.files}</font>
     <else />
      <font class="up-font">暂无上传文件</font>
     </if>
     </if>
    </td>
    </tr> 
  
  <tr>
    <td height="38" colspan="4" align="center"><if condition="$act=='add'">
    <a href="javascript:void(0);" onclick="javascript:onSubmitBug('{$uniqid}')" id="su" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a><else /><a href="javascript:void(0);" onclick="javascript:return onUploadBug('{$uniqid}')" id="sue" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a></if> &nbsp; <a href="javascript:void(0);" onclick="javascript:onResetBug('{$uniqid}')" id="re" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">关闭</a></td>
    </tr>
 </table>
</form>
</div>
<div id="addOpts"></div>