<script language="javascript">
$(function(){
	$("#addFormPart{$uniqid}").form('load',{
		'_parentId':'<?php echo $info["_parentId"] ?>',
		'name':'<?php echo $info["name"] ?>',
		'access':'<?php echo $info["access"] ?>',
		'status':'<?php echo $info["status"] ?>',
		'comment':'<?php echo $info["comment"] ?>'
	});
});

var idd = '';
function onSubmitPart(idd){
	$.messager.progress();
	$("#addFormPart"+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');
			if(data==1){
				$.messager.alert('提示','新增数据成功！','info',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					$("#Part").treegrid('reload');
					if(sa==1){
						cancel['Part'].dialog('close');
						cancel['Part'] = null;
					}
				});
			}else if(data==0){
				$.messager.alert('提示','新增数据失败！','warning');
			}else{
				$.messager.alert('提示','您没有新增权限！','warning',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					if(sa==1){
						cancel['Part'].dialog('close');
						cancel['Part'] = null;
					}
				});
			}
		}
	});
}

function onUploadPart(idd){
	$.messager.progress();
	var ids = $("#ids"+idd).val();
	alert(ids);
	$("#addFormPart"+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');
			if(data==1){
				$.messager.alert('提示','更新数据成功！','info',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					$("#Part").treegrid('reload');
					if(sa==1){
						cancel['Part'].dialog('close');
						cancel['Part'] = null;
					}
				});
			}else if(data==0){
				$.messager.alert('提示','更新数据失败！','warning');
			}else{
				//alert(data);
				$.messager.alert('提示','您没有修改权限！','warning',function(){
					var sa = '{$TC.config.SUBMIT_ACTION}';
					if(sa==1){
						cancel['Part'].dialog('close');
						cancel['Part'] = null;
					}
				});
			}
		}
	});
}

function onResetPart(idd){
	cancel['Part'].dialog('close');
	cancel['Part'] = null;
}
</script>
<div class="con-tb">
<form id="addFormPart{$uniqid}" method="post">
 <table class="infobox" width="100%" border="0" cellspacing="0" cellpadding="0">
 <if condition="C('MORE_COMY')">
  <tr>
    <td width="23%"><label for="_parentId">所属公司</label></td>
    <td width="77%">
    <input name="_parentId" class="easyui-combobox relo" size="22" data-options="url:'__ITEM__/__RUNTIME__/Data/Json/Comy_2_data.json',editable:false,method:'get',required:true,valueField:'id',textField:'text'" />
    </td>
  </tr>
 </if>
  <tr>
    <td width="23%"><label for="name">部门名称</label></td>
    <td width="77%"><input name="name" type="text" class="easyui-validatebox" size="22" data-options="required:true" /><input id="ids{$uniqid}" type="hidden" value="{$id}" /></td>
  </tr>
  <tr>
    <td width="23%"><label for="access">权限值</label></td>
    <td width="77%"><input name="access" type="text" class="easyui-numberbox" size="16" data-options="value:10" /></td>
  </tr>
  <tr>
    <td width="23%"><label for="status">状态</label></td>
    <td width="77%">
    <select class="easyui-combobox" name="status">  
        <option value="1">开启</option>  
        <option  value="0">关闭</option>  
    </select>
   </td>
  </tr>
  <tr>
    <td width="23%"><label for="comment">备注</label></td>
    <td width="77%"><input name="comment" type="text" class="easyui-validatebox" value="" size="38" /></td>
  </tr>
  <tr>
    <td height="38" colspan="2" align="center"><if condition="$act=='add'"><a href="javascript:void(0);" onclick="javascript:onSubmitPart('{$uniqid}')" id="su" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a><else /><a href="javascript:void(0);" onclick="javascript:return onUploadPart('{$uniqid}')" id="sue" class="easyui-linkbutton" data-options="iconCls:'icon-save'">保存</a></if> &nbsp; <a href="javascript:void(0);" onclick="javascript:onResetPart('{$uniqid}')" id="re" class="easyui-linkbutton" data-options="iconCls:'icon-cancel'">关闭</a></td>
  </tr>
 </table>
</form>
</div>