1. <style type="text/css">
  2. .fieldset_s{border: 1px #dedede solid;padding: 19px; color: #0E2D5F;}
  3. .fieldset_s legend {color: #000;}
  4. </style>
  5. <div id="acc_toolbar">
  6. <div style="padding:13px 6px 16px 6px;">
  7. <!--<fieldset class="fieldset_s">
  8. <legend>信息查询</legend>
  9. <label for="acc_date_begin">发生日期:</label>
  10. <input id="acc_date_begin" type="text" class="easyui-datebox" style="width:100px;"> 至 
  11. <input id="acc_date_end" type="text" class="easyui-datebox" style="width:100px;">
  12. <label for="acc_client"> 客户/学员名称:</label>
  13. <input id="acc_client" type="text" style="width:100px;">
  14. <label for="acc_staff"> 业务员:</label>
  15. <input id="acc_staff" type="text" style="width:100px;">
  16. <label for="acc_project"> 项目课程:</label>
  17. <input id="acc_project" class="easyui-textbox" style="width:100px;">
  18.  <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>
  19. <div id="dialogs" style="display:none;">
  20. 暂未启用
  21. </div>
  22. </fieldset>-->
  23.  
  24. <div style="text-align:center;padding:9px 6px;">录入凭证</div>
  25. <div>
  26.     凭证:<input class="easyui-textbox" type="text" name="voucher_no" value='记' data-options="width:40,required:true"> 字 
  27. <input class="easyui-textbox" type="text" name="voucher_no" value='001' data-options="width:50,required:true">
  28.     日 期: <input class="easyui-datebox" type="text" name="voucher_date" data-options="required:true">
  29. </div>
  30. <br>
  31.  
  32. </div>
  33. <a href="javascript:void(0);" onclick="javascript:accounts_add();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'" >添加分录</a>
  34. <a href="javascript:void(0);" onclick="javascript:accounts_save();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-save'">保存凭证</a>
  35. <a href="javascript:void(0);" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-remove'">删除</a>
  36. <a href="javascript:void(0);" onclick="javascript:accounts_redo();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-redo'">撤销</a>
  37. <a href="javascript:void(0);" onclick="javascript:accounts_edit();" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-edit'">修改</a>
  38. <a href="javascript:void(0);" onclick="javascript:MoveUp();" class="easyui-linkbutton" data-options="plain:true">上移</a>
  39. <a href="javascript:void(0);" onclick="javascript:MoveDown();" class="easyui-linkbutton" data-options="plain:true">下移</a>
  40. </div>
  41. <div class="easyui-panel" title="" style="width:99%;height:99%;padding:3px;border:0px;">
  42. <table id="dgacount" class="easyui-datagrid"></table>
  43. </div>
  44. <div id="combogrid_bar">
  45. <a href="#" class="easyui-linkbutton" data-options="plain:true,iconCls:'icon-add'"></a>
  46. </div>
  47. <script type="text/javascript">
  48. $(function(){
  49. /*datagrid应收款管理*/
  50.  
  51. editRow=undefined; //定义全局变量
  52. get_account_Datas();
  53. textbox_staff();
  54.  
  55. //监听浏览器宽度变化,调整datagrid尺寸和布局
  56. /* $(window).resize(function(){
  57. $('#dgacount').datagrid('resize');
  58. });
  59. */
  60. //$("#search_toolbar").appendTo(".datagrid-toolbar");添加标签
  61. //
  62.  
  63. textbox_acc_client();
  64. });
  65.  
  66. //键盘事件 暂未启用
  67. function enterSubmit(src,e)
  68. {
  69. if (window.event) {keyPress = window.event.keyCode;}else{keyPress = e.which;};
  70. if (keyPress==13) {alert('sdf');};
  71. }
  72. // datagrid重新加载数据acc_client:$("#acc_client").val
  73. function getquerydata()
  74. {
  75. //获取 要查询的参数
  76. var acc_date_begin = $("#acc_date_end").datebox("getValue");//注意日期的取值方式
  77. var acc_date_end = $("#acc_date_end").datebox("getValue");
  78. var acc_client = $("#acc_client").val();
  79. var acc_staff = $("#acc_staff").val();
  80. var acc_project = $("#acc_project").val();
  81.  
  82. alert(acc_date_begin);
  83. $('#dgacount').datagrid('load',{
  84. acc_date_begin:acc_date_begin //向后台传递的参数
  85.  
  86. });
  87. }
  88.  
  89. //
  90. function textbox_acc_client()
  91. {
  92. $("#acc_client").textbox({
  93. /*buttonText:'click',
  94. iconCls:'icon-search',
  95. onClickButton:function(e){
  96.  
  97. alertdialog();
  98. },*/
  99.  
  100. icons:[{
  101. iconCls:'icon-search',
  102. handler:function(e){
  103. var v=$(e.data.target).textbox('getValue');
  104. var v=$(e.data.target).textbox('setText','小兵');
  105. //alert(v?v:'空');
  106. alertdialog();
  107. }
  108. }]
  109.  
  110. })
  111. }
  112.  
  113. //
  114. function textbox_staff()
  115. {
  116. $("#acc_staff").textbox({
  117.  
  118. icons:[{
  119. iconCls:'icon-search',
  120. handler:function(e){
  121. var v=$(e.data.target).textbox('getValue');
  122. alert(v?v:'空');
  123. alertdialog();
  124. }
  125. }]
  126. }
  127. )
  128. }
  129.  
  130. function alertdialog()
  131. {
  132. $('#dialogs').dialog({
  133. title: 'My Dialog',
  134. width: 400,
  135. height: 200,
  136. closed: false,
  137. cache: false,
  138. modal: true
  139. });
  140. }
  141.  
  142. //初始化datagrid的数据
  143.  
  144. function get_account_Datas(){
  145. /*<?php //base_url()?>/static/data/test.json
  146. <?php echo site_url();?>/bankinfo/selectAll
  147. */
  148.  
  149. $('#dgacount').datagrid({
  150. title: '凭证信息管理',
  151. collapsible: true,
  152. url:'<?php //base_url()?>/static/data/vouher.json',//php文件中使用echo返回json数据 翻页的同时传递了page 和rows;
  153. loadMsg:'数据加载中,请稍后......',
  154. //pagination:true,
  155. pageNumber:1,
  156. pageSize:10,
  157. pageList:[6,10,16,26],
  158. rownumbers:true,
  159. singleSelect:true,
  160. //pagePosition:top,
  161. fit:true,//datagrid的适应父窗口
  162. fitColumns:false,//自动扩大或缩小列的尺寸以适应表格的宽度并且防止水平滚动
  163. striped:true,
  164. //method:'post',
  165. toolbar:'#acc_toolbar',
  166. //onClickCell: onClickCell,
  167.  
  168. onAfterEdit: function (rowIndex, rowData, changes) {
  169. editRow = undefined;
  170. },
  171. onDblClickRow:function (rowIndex, rowData) {
  172.  
  173. if (editRow != undefined) {
  174. $("#dgacount").datagrid('endEdit', editRow);
  175. }
  176.  
  177. if (editRow == undefined) {
  178. $("#dgacount").datagrid('beginEdit', rowIndex);
  179. editRow = rowIndex;
  180. }
  181. },
  182. onClickRow:function(rowIndex,rowData){
  183.  
  184. if (editRow != undefined) {
  185. $("#dgacount").datagrid('endEdit', editRow);
  186.  
  187. }
  188.  
  189. },
  190.  
  191. columns:[[
  192. {field:'summary',title:'<br><span style="font-weight:bold;font-size:15px;">摘 要</span><br>',width:200,align:'center',
  193. editor:{
  194. type:'combobox',options:{
  195. valueField:'month',
  196. textField:'month',
  197. method:'get',
  198. url:'<?php base_url()?>/static/data/month.json',
  199. height:60,
  200.  
  201. }
  202. },
  203. styler: function(value,rowData,rowIndex){
  204. return {style:'height:50px'}
  205. },
  206. },
  207.  
  208. {field:'inout_date',title:'<br>发生日期<br>',width:100,align:'center',hidden:true,
  209. editor:{
  210. type:'datebox',options:{
  211. //required:true,
  212.  
  213. },
  214. },
  215. },
  216. {field:'subjects',title:'<span style="font-weight:bold;font-size:15px;">会计科目   </span>',width:200,align:'right',
  217. editor:{
  218. type:'combobox',options:{
  219. valueField:'month',
  220. textField:'month',
  221. method:'get',
  222. url:'<?php base_url()?>/static/data/month.json',
  223. height:60,
  224. }
  225. },
  226. styler: function(value,rowData,rowIndex){
  227. return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
  228. },
  229.  
  230. },{field:'ought_money',title:'<span style="font-weight:bold;font-size:15px;">借方金额   </span>',width:200,align:'right',
  231. editor:{type:'numberbox',options:{
  232. precision:2,
  233. height:60,
  234. }},
  235. styler: function(value,rowData,rowIndex){
  236. return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
  237. },
  238.  
  239. },
  240. {field:'inout_money',title:'<span style="font-weight:bold;font-size:15px;">贷方金额   </span>',width:200,align:'right',
  241. editor:{type:'numberbox',options:{
  242. precision:2,
  243. height:60,
  244. }},
  245. styler: function(value,rowData,rowIndex){
  246. return {style:'height:50px;font-weight:bold;font-size:36pt;letter-spacing:2px;'}
  247. },
  248.  
  249. },
  250.  
  251. {field:'client_name',title:'客户/学员名称',width:100,align:'center',
  252. editor:{
  253. type:'combogrid',options:{
  254. panelWidth:200,
  255. idField:'related_id',
  256. textField:'related_name',
  257. mode:'remote',//远程获取数据
  258. method:'get',
  259. fitColumns:true,
  260. //toolbar:'#combogrid_bar',
  261. url:'<?php echo site_url();?>/relatedcompay/getcombogirdjson',
  262. columns:[[
  263. {field:'related_name',title:'客户/学员姓名',width:80},
  264. {field:'related_programe',title:'项目课程',width:120}
  265. ]],
  266. }
  267. }
  268. },
  269. {field:'staff_id',title:'所属业务员/职员',width:100,align:'center',
  270. editor:{
  271. type:'combogrid',options:{
  272. panelWidth:200,
  273. idField:'staff_id',
  274. textField:'name',
  275. mode:'remote',//远程获取数据
  276. method:'get',
  277. fitColumns:true,
  278. toolbar:'#combogrid_bar',
  279. url:'<?php echo site_url();?>/departstaff/getStaffCombogridJson',
  280. columns:[[
  281. {field:'name',title:'姓名',width:80},
  282. {field:'job_role',title:'项目课程',width:190}
  283. ]],
  284. }
  285. }
  286. },
  287. {field:'dept_id',title:'所属业务核算部门',width:160,align:'center',
  288. editor:{
  289. type:'text',options:{//required:true,
  290.  
  291. }
  292. }
  293. },
  294. {field:'sys_id',title:'预设核算项目课程',width:160,align:'center',
  295. editor:{
  296. type:'combotree',options:{
  297. url:'<?php echo site_url();?>/systemcode/getcomTreeJson',
  298. }
  299. }
  300. },
  301.  
  302. {field:'account_id',title:'凭证ID',width:100,},
  303. ]]
  304. });
  305.  
  306. }
  307.  
  308. //添加应收款
  309. function accounts_add(){
  310. var dataB=$("#dgacount").datagrid('getData');
  311. //alert('当前页数据量:'+data.rows.length);
  312. var rowIndexs = dataB.rows.length;
  313. if (editRow != undefined) {
  314. $("#dgacount").datagrid('endEdit', editRow);
  315. editRow=undefined;
  316. }
  317. if (editRow == undefined) {
  318. $("#dgacount").datagrid('insertRow', {
  319. index:rowIndexs,
  320. row: {}
  321. });
  322.  
  323. $("#dgacount").datagrid('beginEdit', rowIndexs);
  324. editRow = rowIndexs;
  325. }
  326. }
  327.  
  328. //撤销编辑操作
  329. function accounts_redo() {
  330. editRow = undefined;
  331. $("#dgacount").datagrid('rejectChanges');
  332. $("#dgacount").datagrid('unselectAll');
  333. }
  334.  
  335. //修改数据
  336. function accounts_edit(){
  337. var row = $("#dgacount").datagrid('getSelected');
  338. //console.info(row);
  339. if (row !=null) {
  340. if (editRow != undefined) {
  341. $("#dgacount").datagrid('endEdit', editRow);
  342. }
  343. if (editRow == undefined) {
  344. var index = $("#dgacount").datagrid('getRowIndex', row);
  345. $("#dgacount").datagrid('beginEdit', index);
  346. editRow = index;
  347. $("#dgacount").datagrid('unselectAll');
  348. }
  349. } else {
  350.  
  351. }
  352. }
  353.  
  354. //保存数据
  355. function accounts_save() {
  356.  
  357. var $dg = $("#dgacount");
  358. var rows = $dg.datagrid('getRows');
  359. for ( var i = 0; i < rows.length; i++) {
  360. $dg.datagrid('endEdit', i);
  361. }
  362. // $("#dgacount").datagrid('endEdit', 0);//结束编辑状态
  363. //如果调用acceptChanges(),使用getChanges()则获取不到编辑和新增的数据。
  364. //使用JSON序列化datarow对象,发送到后台。
  365. //判断列值 是否为空
  366. var mesg = '';
  367. var rows = $("#dgacount").datagrid('getChanges');
  368. console.info(rows);
  369. if(rows.length<=0)
  370. {
  371. $.messager.alert('友情提示',' 无添加或修改的内容!<br><br>','warning');
  372. return false;
  373. }
  374. if(rows)
  375. {
  376. $.each(rows,function(key,val){
  377. if($.trim(rows[key]["client_name"])=='' || $.trim(rows[key]["client_name"])==undefined || $.trim(rows[key]["client_name"]) ==null)
  378. {
  379. mesg += '客户名称不能为空!<br><br>';
  380. }
  381. if($.trim(rows[key]["dept_id"])=='' || $.trim(rows[key]["dept_id"])==undefined || $.trim(rows[key]["dept_id"]) ==null)
  382. {
  383. mesg += '预设核算项目课程不能为空!<br><br>';
  384. }
  385. });
  386.  
  387. }
  388. //alert(rows[0]["bank_name"]);
  389. if(mesg!='')
  390. {
  391. $.messager.alert('友情提示',mesg,'warning');
  392. return false;
  393. }
  394.  
  395. var rowstr = JSON.stringify(rows);
  396. console.info(rowstr);
  397. //alert(rowstr[bank_name]);//可获取到json数据
  398. $.post('<?php echo site_url();?>/accounts/addaccounts', {adata:rowstr}, function (data) {
  399. //alert(typeof(data)); //返回的是string类型
  400.  
  401. if(data)
  402. {
  403. $.messager.alert('友情提示',data,'info');
  404. }else{
  405. $.messager.alert('友情提示','数据格式填写错误!','error');
  406. }
  407. //$('#zijin').html(data); // 数据测试
  408. $("#dgacount").datagrid('reload'); //执行成功后刷新当前页数据
  409.  
  410. });
  411. }
  412.  
  413. function onClickRow(index){
  414. if (editIndex != index){
  415. if (endEditing()){
  416. $('#dgacount').datagrid('selectRow', index)
  417. .datagrid('beginEdit', index);
  418. editIndex = index;
  419. } else {
  420. $('#dgacount').datagrid('selectRow', editIndex);
  421. }
  422. }
  423. }
  424.  
  425. //上移
  426. function MoveUp() {
  427. var row = $("#dgacount").datagrid('getSelected');
  428. var index = $("#dgacount").datagrid('getRowIndex', row);
  429. mysort(index, 'up', 'dgacount');
  430.  
  431. }
  432. //下移
  433. function MoveDown() {
  434.  
  435. var row = $("#dgacount").datagrid('getSelected');
  436. var index = $("#dgacount").datagrid('getRowIndex', row);
  437. mysort(index, 'down', 'dgacount');
  438.  
  439. }
  440. function mysort(index, type, gridname) {
  441. if ("up" == type) {
  442. if (index != 0) {
  443. var toup = $('#' + gridname).datagrid('getData').rows[index];
  444. var todown = $('#' + gridname).datagrid('getData').rows[index - 1];
  445. $('#' + gridname).datagrid('getData').rows[index] = todown;
  446. $('#' + gridname).datagrid('getData').rows[index - 1] = toup;
  447. $('#' + gridname).datagrid('refreshRow', index);
  448. $('#' + gridname).datagrid('refreshRow', index - 1);
  449. $('#' + gridname).datagrid('selectRow', index - 1);
  450. }
  451. } else if ("down" == type) {
  452. var rows = $('#' + gridname).datagrid('getRows').length;
  453. if (index != rows - 1) {
  454.  
  455. var todown = $('#' + gridname).datagrid('getData').rows[index];
  456. var toup = $('#' + gridname).datagrid('getData').rows[index + 1];
  457. $('#' + gridname).datagrid('getData').rows[index + 1] = todown;
  458. $('#' + gridname).datagrid('getData').rows[index] = toup;
  459. $('#' + gridname).datagrid('refreshRow', index);
  460. $('#' + gridname).datagrid('refreshRow', index + 1);
  461. $('#' + gridname).datagrid('selectRow', index + 1);
  462. }
  463. }
  464.  
  465. }
  466. //分页
  467. function getpages()
  468. {
  469.  
  470. $("#dgacount").datagrid().datagrid("getPager").pagination({
  471. displayMsg:'当前显示从sdf第{from}条到{total}条记录',
  472. buttons:[{
  473. iconCls:'icon-search',
  474. handler:function(){
  475. alert('search');
  476. }
  477. },{
  478. iconCls:'icon-add',
  479. handler:function(){
  480. alert('add');
  481. }
  482. },{
  483. iconCls:'icon-edit',
  484. handler:function(){
  485. alert('edit');
  486. }
  487. }
  488. ]
  489. })
  490.  
  491. }
  492. function reload_combogrid(targetgrid)
  493. {
  494. targetgrid.combogrid('reload');
  495. }
  496.  
  497. $.extend($.fn.datagrid.methods, {
  498. editCell: function(jq,param){
  499. return jq.each(function(){
  500. var opts = $(this).datagrid('options');
  501. var fields = $(this).datagrid('getColumnFields',true).concat($(this).datagrid('getColumnFields'));
  502. for(var i=0; i<fields.length; i++){
  503. var col = $(this).datagrid('getColumnOption', fields[i]);
  504. col.editor1 = col.editor;
  505. if (fields[i] != param.field){
  506. col.editor = null;
  507. }
  508. }
  509. $(this).datagrid('beginEdit', param.index);
  510. for(var i=0; i<fields.length; i++){
  511. var col = $(this).datagrid('getColumnOption', fields[i]);
  512. col.editor = col.editor1;
  513. }
  514. });
  515. }
  516. });
  517.  
  518. var editIndex = undefined;
  519. function endEditing(){
  520. if (editIndex == undefined){return true}
  521. if ($('#dgacount').datagrid('validateRow', editIndex)){
  522. $('#dgacount').datagrid('endEdit', editIndex);
  523. editIndex = undefined;
  524. return true;
  525. } else {
  526. return false;
  527. }
  528. }
  529. function onClickCell(index, field){
  530. if (endEditing()){
  531. $('#dgacount').datagrid('selectRow', index)
  532. .datagrid('editCell', {index:index,field:field});
  533. editIndex = index;
  534. }
  535. }
  536. </script>

voucer的更多相关文章

随机推荐

  1. OpenJudge 2980 大整数乘法

    链接地址:http://bailian.openjudge.cn/practice/2980/ 题目: 总时间限制: 1000ms 内存限制: 65536kB 描述 求两个不超过200位的非负整数的积 ...

  2. Oracle if else if for case

    ------------------游标+for+if else if DECLARE cursor s_cursor is SELECT * from emp;--定义游标 begin for r ...

  3. preg_match_all, preg_match

    int preg_match(string $pattern, string $subject[, $arr][, int $flags]);$pattern 正则表达式$subject: 要搜索的字 ...

  4. 创建安全的ashx文件,ashx编译

    <%@ WebHandler Language="C#" Class="Handler2" %> using System; using Syste ...

  5. Asp.Net细节性问题精萃

    1.<%=…%>与<%#… %>的区别: 答:<%=…%>是在程序执行时调用,<%#… %>是在DataBind()方法之后被调用 2.控件接收哪些类型 ...

  6. 多站点FTP同步

    需求描述: 由于工作的原因,发布程序时,经常需要将一站点的脚本.程序同步到其它的终端站点中,以保证所有站点的程序是同步的,用过FlashFtp,CuteFtp,LeapFtp等客户端工具,均于自己的需 ...

  7. Redhat 6.5 x64 下载地址

    http://ftp.okhysing.is/ftp/redhat/6.5/isos/x86_64/

  8. 添加数据时候获取自增的ID

    create database dbDemo go use dbDemo go create table tdstudent { id int primary key identity(1,1), n ...

  9. 特殊的Python

    在学习python之前,我也学习过C ,C++ ,Java ,PHP ,javascript,前端也学习过.但是在学习Python的这段时间里,多多少少也感觉到Python在语法方面的不同和特殊性. ...

  10. java创建多线程(转载)

    转载自:Java创建线程的两个方法 Java提供了线程类Thread来创建多线程的程序.其实,创建线程与创建普通的类的对象的操作是一样的,而线程就是Thread类或其子类的实例对象.每个Thread对 ...