<style type="text/css">
.fieldset_s{border: 1px #dedede solid;padding: 19px; color: #0E2D5F;}
.fieldset_s legend {color: #000;}
</style>
<div id="acc_toolbar">
<div style="padding:13px 6px 16px 6px;">
<!--<fieldset class="fieldset_s">
<legend>信息查询</legend>
<label for="acc_date_begin">发生日期:</label>
<input id="acc_date_begin" type="text" class="easyui-datebox" style="width:100px;"> 至 
<input id="acc_date_end" type="text" class="easyui-datebox" style="width:100px;">
<label for="acc_client"> 客户/学员名称:</label>
<input id="acc_client" type="text" style="width:100px;">
<label for="acc_staff"> 业务员:</label>
<input id="acc_staff" type="text" style="width:100px;">
<label for="acc_project"> 项目课程:</label>
<input id="acc_project" class="easyui-textbox" style="width:100px;">
 <a href="javascript:void(0)" onclick="javascript:getquerydata();" onkeydown="return enterSubmit(this,event);" class="easyui-linkbutton c4" data-options="iconCls:'icon-search'" iconCls="icon-search" style="width:90px">搜 索</a>
<div id="dialogs" style="display:none;">
暂未启用
</div>
</fieldset>--> <div style="text-align:center;padding:9px 6px;">录入凭证</div>
<div>
    凭证:<input class="easyui-textbox" type="text" name="voucher_no" value='记' data-options="width:40,required:true"> 字 
<input class="easyui-textbox" type="text" name="voucher_no" value='001' data-options="width:50,required:true"> 号
    日 期: <input class="easyui-datebox" type="text" name="voucher_date" data-options="required:true">
</div>
<br> </div>
<a href="javascript:void(0);" onclick="javascript:accounts_add();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'" >添加分录</a>
<a href="javascript:void(0);" onclick="javascript:accounts_save();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'">保存凭证</a>
<a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'">删除</a>
<a href="javascript:void(0);" onclick="javascript:accounts_redo();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-redo'">撤销</a>
<a href="javascript:void(0);" onclick="javascript:accounts_edit();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">修改</a>
<a href="javascript:void(0);" onclick="javascript:MoveUp();" class="easyui-linkbutton" data-options="plain:true">上移</a>
<a href="javascript:void(0);" onclick="javascript:MoveDown();" class="easyui-linkbutton" data-options="plain:true">下移</a>
</div>
<div class="easyui-panel" title="" style="width:99%;height:99%;padding:3px;border:0px;">
<table id="dgacount" class="easyui-datagrid"></table>
</div>
<div id="combogrid_bar">
<a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'"></a>
</div>
<script type="text/javascript">
$(function(){
/*datagrid应收款管理*/ editRow=undefined; //定义全局变量
get_account_Datas();
textbox_staff(); //监听浏览器宽度变化,调整datagrid尺寸和布局
/* $(window).resize(function(){
$('#dgacount').datagrid('resize');
});
*/
//$("#search_toolbar").appendTo(".datagrid-toolbar");添加标签
// textbox_acc_client();
}); //键盘事件 暂未启用
function enterSubmit(src,e)
{
if (window.event) {keyPress = window.event.keyCode;}else{keyPress = e.which;};
if (keyPress==13) {alert('sdf');};
}
// datagrid重新加载数据acc_client:$("#acc_client").val
function getquerydata()
{
//获取 要查询的参数
var acc_date_begin = $("#acc_date_end").datebox("getValue");//注意日期的取值方式
var acc_date_end = $("#acc_date_end").datebox("getValue");
var acc_client = $("#acc_client").val();
var acc_staff = $("#acc_staff").val();
var acc_project = $("#acc_project").val(); alert(acc_date_begin);
$('#dgacount').datagrid('load',{
acc_date_begin:acc_date_begin //向后台传递的参数 });
} //
function textbox_acc_client()
{
$("#acc_client").textbox({
/*buttonText:'click',
iconCls:'icon-search',
onClickButton:function(e){ alertdialog();
},*/ icons:[{
iconCls:'icon-search',
handler:function(e){
var v=$(e.data.target).textbox('getValue');
var v=$(e.data.target).textbox('setText','小兵');
//alert(v?v:'空');
alertdialog();
}
}] })
} //
function textbox_staff()
{
$("#acc_staff").textbox({ icons:[{
iconCls:'icon-search',
handler:function(e){
var v=$(e.data.target).textbox('getValue');
alert(v?v:'空');
alertdialog();
}
}]
}
)
} function alertdialog()
{
$('#dialogs').dialog({
title: 'My Dialog',
width: 400,
height: 200,
closed: false,
cache: false,
modal: true
});
} //初始化datagrid的数据 function get_account_Datas(){
/*<?php //base_url()?>/static/data/test.json
<?php echo site_url();?>/bankinfo/selectAll
*/ $('#dgacount').datagrid({
title: '凭证信息管理',
collapsible: true,
url:'<?php //base_url()?>/static/data/vouher.json',//php文件中使用echo返回json数据 翻页的同时传递了page 和rows;
loadMsg:'数据加载中,请稍后......',
//pagination:true,
pageNumber:1,
pageSize:10,
pageList:[6,10,16,26],
rownumbers:true,
singleSelect:true,
//pagePosition:top,
fit:true,//datagrid的适应父窗口
fitColumns:false,//自动扩大或缩小列的尺寸以适应表格的宽度并且防止水平滚动
striped:true,
//method:'post',
toolbar:'#acc_toolbar',
//onClickCell: onClickCell, onAfterEdit: function (rowIndex, rowData, changes) {
editRow = undefined;
},
onDblClickRow:function (rowIndex, rowData) { if (editRow != undefined) {
$("#dgacount").datagrid('endEdit', editRow);
} if (editRow == undefined) {
$("#dgacount").datagrid('beginEdit', rowIndex);
editRow = rowIndex;
}
},
onClickRow:function(rowIndex,rowData){ if (editRow != undefined) {
$("#dgacount").datagrid('endEdit', editRow); } }, columns:[[
{field:'summary',title:'<br><span style="font-weight:bold;font-size:15px;">摘 要</span><br>',width:200,align:'center',
editor:{
type:'combobox',options:{
valueField:'month',
textField:'month',
method:'get',
url:'<?php base_url()?>/static/data/month.json',
height:60, }
},
styler: function(value,rowData,rowIndex){
return {style:'height:50px'}
},
}, {field:'inout_date',title:'<br>发生日期<br>',width:100,align:'center',hidden:true,
editor:{
type:'datebox',options:{
//required:true, },
},
},
{field:'subjects',title:'<span style="font-weight:bold;font-size:15px;">会计科目   </span>',width:200,align:'right',
editor:{
type:'combobox',options:{
valueField:'month',
textField:'month',
method:'get',
url:'<?php base_url()?>/static/data/month.json',
height:60,
}
},
styler: function(value,rowData,rowIndex){
return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
}, },{field:'ought_money',title:'<span style="font-weight:bold;font-size:15px;">借方金额   </span>',width:200,align:'right',
editor:{type:'numberbox',options:{
precision:2,
height:60,
}},
styler: function(value,rowData,rowIndex){
return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
}, },
{field:'inout_money',title:'<span style="font-weight:bold;font-size:15px;">贷方金额   </span>',width:200,align:'right',
editor:{type:'numberbox',options:{
precision:2,
height:60,
}},
styler: function(value,rowData,rowIndex){
return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
}, }, {field:'client_name',title:'客户/学员名称',width:100,align:'center',
editor:{
type:'combogrid',options:{
panelWidth:200,
idField:'related_id',
textField:'related_name',
mode:'remote',//远程获取数据
method:'get',
fitColumns:true,
//toolbar:'#combogrid_bar',
url:'<?php echo site_url();?>/relatedcompay/getcombogirdjson',
columns:[[
{field:'related_name',title:'客户/学员姓名',width:80},
{field:'related_programe',title:'项目课程',width:120}
]],
}
}
},
{field:'staff_id',title:'所属业务员/职员',width:100,align:'center',
editor:{
type:'combogrid',options:{
panelWidth:200,
idField:'staff_id',
textField:'name',
mode:'remote',//远程获取数据
method:'get',
fitColumns:true,
toolbar:'#combogrid_bar',
url:'<?php echo site_url();?>/departstaff/getStaffCombogridJson',
columns:[[
{field:'name',title:'姓名',width:80},
{field:'job_role',title:'项目课程',width:190}
]],
}
}
},
{field:'dept_id',title:'所属业务核算部门',width:160,align:'center',
editor:{
type:'text',options:{//required:true, }
}
},
{field:'sys_id',title:'预设核算项目课程',width:160,align:'center',
editor:{
type:'combotree',options:{
url:'<?php echo site_url();?>/systemcode/getcomTreeJson',
}
}
}, {field:'account_id',title:'凭证ID',width:100,},
]]
}); } //添加应收款
function accounts_add(){
var dataB=$("#dgacount").datagrid('getData');
//alert('当前页数据量:'+data.rows.length);
var rowIndexs = dataB.rows.length;
if (editRow != undefined) {
$("#dgacount").datagrid('endEdit', editRow);
editRow=undefined;
}
if (editRow == undefined) {
$("#dgacount").datagrid('insertRow', {
index:rowIndexs,
row: {}
}); $("#dgacount").datagrid('beginEdit', rowIndexs);
editRow = rowIndexs;
}
} //撤销编辑操作
function accounts_redo() {
editRow = undefined;
$("#dgacount").datagrid('rejectChanges');
$("#dgacount").datagrid('unselectAll');
} //修改数据
function accounts_edit(){
var row = $("#dgacount").datagrid('getSelected');
//console.info(row);
if (row !=null) {
if (editRow != undefined) {
$("#dgacount").datagrid('endEdit', editRow);
}
if (editRow == undefined) {
var index = $("#dgacount").datagrid('getRowIndex', row);
$("#dgacount").datagrid('beginEdit', index);
editRow = index;
$("#dgacount").datagrid('unselectAll');
}
} else { }
} //保存数据
function accounts_save() { var $dg = $("#dgacount");
var rows = $dg.datagrid('getRows');
for ( var i = 0; i < rows.length; i++) {
$dg.datagrid('endEdit', i);
}
// $("#dgacount").datagrid('endEdit', 0);//结束编辑状态
//如果调用acceptChanges(),使用getChanges()则获取不到编辑和新增的数据。
//使用JSON序列化datarow对象,发送到后台。
//判断列值 是否为空
var mesg = '';
var rows = $("#dgacount").datagrid('getChanges');
console.info(rows);
if(rows.length<=0)
{
$.messager.alert('友情提示',' 无添加或修改的内容!<br><br>','warning');
return false;
}
if(rows)
{
$.each(rows,function(key,val){
if($.trim(rows[key]["client_name"])=='' || $.trim(rows[key]["client_name"])==undefined || $.trim(rows[key]["client_name"]) ==null)
{
mesg += '客户名称不能为空!<br><br>';
}
if($.trim(rows[key]["dept_id"])=='' || $.trim(rows[key]["dept_id"])==undefined || $.trim(rows[key]["dept_id"]) ==null)
{
mesg += '预设核算项目课程不能为空!<br><br>';
}
}); }
//alert(rows[0]["bank_name"]);
if(mesg!='')
{
$.messager.alert('友情提示',mesg,'warning');
return false;
} var rowstr = JSON.stringify(rows);
console.info(rowstr);
//alert(rowstr[bank_name]);//可获取到json数据
$.post('<?php echo site_url();?>/accounts/addaccounts', {adata:rowstr}, function (data) {
//alert(typeof(data)); //返回的是string类型 if(data)
{
$.messager.alert('友情提示',data,'info');
}else{
$.messager.alert('友情提示','数据格式填写错误!','error');
}
//$('#zijin').html(data); // 数据测试
$("#dgacount").datagrid('reload'); //执行成功后刷新当前页数据 });
} function onClickRow(index){
if (editIndex != index){
if (endEditing()){
$('#dgacount').datagrid('selectRow', index)
.datagrid('beginEdit', index);
editIndex = index;
} else {
$('#dgacount').datagrid('selectRow', editIndex);
}
}
} //上移
function MoveUp() {
var row = $("#dgacount").datagrid('getSelected');
var index = $("#dgacount").datagrid('getRowIndex', row);
mysort(index, 'up', 'dgacount'); }
//下移
function MoveDown() { var row = $("#dgacount").datagrid('getSelected');
var index = $("#dgacount").datagrid('getRowIndex', row);
mysort(index, 'down', 'dgacount'); }
function mysort(index, type, gridname) {
if ("up" == type) {
if (index != 0) {
var toup = $('#' + gridname).datagrid('getData').rows[index];
var todown = $('#' + gridname).datagrid('getData').rows[index - 1];
$('#' + gridname).datagrid('getData').rows[index] = todown;
$('#' + gridname).datagrid('getData').rows[index - 1] = toup;
$('#' + gridname).datagrid('refreshRow', index);
$('#' + gridname).datagrid('refreshRow', index - 1);
$('#' + gridname).datagrid('selectRow', index - 1);
}
} else if ("down" == type) {
var rows = $('#' + gridname).datagrid('getRows').length;
if (index != rows - 1) { var todown = $('#' + gridname).datagrid('getData').rows[index];
var toup = $('#' + gridname).datagrid('getData').rows[index + 1];
$('#' + gridname).datagrid('getData').rows[index + 1] = todown;
$('#' + gridname).datagrid('getData').rows[index] = toup;
$('#' + gridname).datagrid('refreshRow', index);
$('#' + gridname).datagrid('refreshRow', index + 1);
$('#' + gridname).datagrid('selectRow', index + 1);
}
} }
//分页
function getpages()
{ $("#dgacount").datagrid().datagrid("getPager").pagination({
displayMsg:'当前显示从sdf第{from}条到{total}条记录',
buttons:[{
iconCls:'icon-search',
handler:function(){
alert('search');
}
},{
iconCls:'icon-add',
handler:function(){
alert('add');
}
},{
iconCls:'icon-edit',
handler:function(){
alert('edit');
}
}
]
}) }
function reload_combogrid(targetgrid)
{
targetgrid.combogrid('reload');
} $.extend($.fn.datagrid.methods, {
editCell: function(jq,param){
return jq.each(function(){
var opts = $(this).datagrid('options');
var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
for(var i=0; i<fields.length; i++){
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor1 = col.editor;
if (fields[i] != param.field){
col.editor = null;
}
}
$(this).datagrid('beginEdit', param.index);
for(var i=0; i<fields.length; i++){
var col = $(this).datagrid('getColumnOption', fields[i]);
col.editor = col.editor1;
}
});
}
}); var editIndex = undefined;
function endEditing(){
if (editIndex == undefined){return true}
if ($('#dgacount').datagrid('validateRow', editIndex)){
$('#dgacount').datagrid('endEdit', editIndex);
editIndex = undefined;
return true;
} else {
return false;
}
}
function onClickCell(index, field){
if (endEditing()){
$('#dgacount').datagrid('selectRow', index)
.datagrid('editCell', {index:index,field:field});
editIndex = index;
}
}
</script>

voucer的更多相关文章

随机推荐

  1. springmvc学习(四)

    1.使用 @CookieValue 绑定请求中的 Cookie 值 例子: java @RequestMapping(value="/testCookieValue") publi ...

  2. KMP的模版实现(以hdu1711为例)

    贴代码,觉得带template的有一些大材小用……不过还是按自己风格写吧! /************************************************************* ...

  3. 第43条:返回零长度的数组或者集合,而不是null

    private final List<Cheese> cheesesInStock = ...; public Cheese[] getCheese() { if(cheesesInSto ...

  4. http数据包解析碰到gzip压缩格式的解压

    其中在做http数据包临控时碰到gzip压缩格式,在网友发布的一些技术文章基础上,经过一段时间的研究.调试,终于解析成功.现将核心代码公布于此,希望能够和大家一起共同学习交流.注:以下代码需要依赖zl ...

  5. HTML5的离线储存

    在用户没有与因特网连接时,可以正常访问站点或应用,在用户与因特网连接时,更新用户机器上的缓存文件.        原理:HTML5的离线存储是基于一个新建的.appcache文件的缓存机制(不是存储技 ...

  6. Centos 6.4 /usr/src/kernels 目录为空解决方法

    /usr/src/kernels 目录下是Linux的内核源码,如果其为空,则需要安装安装 kernel-headers 和 kernel-devel包

  7. JavaScript 判断用户输入的邮箱及手机格式是否正确

    JavaScript判断用户输入的邮箱格式是否正确.判断用户输入的手机号格式是否正确,下面有个不错的示例,感兴趣的朋友可以参考下. 复制代码代码如下: /*  * 功能:判断用户输入的邮箱格式是否正确 ...

  8. MYSQL Error 2006HY000:MySQL server has gone away的解决方案

    MySQL server has gone away有几种情况. 1.应用程序(比如PHP)长时间的执行批量的MYSQL语句. 最常见的就是采集或者新旧数据转化. 解决方案: 在my.cnf文件中添加 ...

  9. Centos 7 通过YUM安装 PHP7 NGINX1.1.8 POSTGRESQL9.5

    转载 1.最小化安装CENTOS7 2.更新源: yum update reboot 3.安装扩展源: yum install epel-release 4.安装工具软件: yum install w ...

  10. 数列 COGS1048:[Citric S2] 一道防AK好题

    [题目描述] Czy手上有一个长度为n的数列,第i个数为xi. 他现在想知道,对于给定的a,b,c,他要找到一个i,使得a*(i+1)*xi2+(b+1)*i*xi+(c+i)=0成立. 如果有多个i ...