financial.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
  2. var Controller = {
  3. index : function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend : {
  7. index_url : 'qingdongams/workorder/financial/index',
  8. detail_url : 'qingdongams/workorder/workorder/detail',
  9. multi_url : 'qingdongams/workorder/financial/multi',
  10. table : 'workorder',
  11. }
  12. });
  13. var table = $("#table");
  14. // 初始化表格
  15. table.bootstrapTable({
  16. url : $.fn.bootstrapTable.defaults.extend.index_url,
  17. pk : 'id',
  18. sortName : 'id',
  19. fixedColumns : true,
  20. fixedNumber : 2,
  21. columns : [
  22. [
  23. {field: 'workorder_number', title: '工单编号', operate: 'like'},
  24. {
  25. field: 'title', title: '工单标题', fixedColumns: true, formatter: function (value, row, index) {
  26. return "<a href='javascript:void(0);' data-id='" + row.id + "' class='show-detail'>" + value + "</a>";
  27. }, operate: 'like'
  28. },
  29. {field: 'workorder_type', title: '工单类型', operate: 'like'},
  30. {
  31. field: 'status', title: '工单状态', formatter: Table.api.formatter.status,
  32. searchList: { 1: '待处理', 2: '处理中', 3: '已完成',9:"已撤销"}
  33. },
  34. {
  35. field: 'process', title: '工单进程', formatter: Table.api.formatter.status,
  36. searchList: {0: '已提交', 1: '备货中', 2: '备货完成', 3: '到访/录入物流信息',4:"待支付", 9: '已送达'}
  37. },
  38. {field : 'customer', title : '客户名称', formatter : function (value, row, index) {
  39. if(!value){
  40. return '';
  41. }
  42. return "<a href='javascript:void(0);' data-id='" + row.customer_id + "' class='show-customer'>" + value.name + "</a>";
  43. },operate:false},
  44. {field: 'contacts', title: '联系人', formatter : function (value, row, index) {
  45. if(!value){
  46. return '';
  47. }
  48. return value.name ;
  49. },operate:false},
  50. {field: 'createtime', title: '创建时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.date},
  51. {field: 'end_time', title: '结束时间', operate:'RANGE', addclass:'datetimerange', formatter: Table.api.formatter.datetime},
  52. {field: 'results', title: '结果说明', operate: false},
  53. ]
  54. ],
  55. pagination : true,
  56. search : false,
  57. commonSearch : true,
  58. searchFormVisible : true,
  59. //显示导出按钮
  60. showExport: false,
  61. onLoadSuccess:function(){
  62. }
  63. });
  64. $(document).on('click', '.show-detail', function (data) {
  65. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  66. var options = {
  67. shadeClose : false,
  68. shade : [0.3, '#393D49'],
  69. area : area,
  70. callback : function (value) {
  71. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  72. console.log(value);
  73. }
  74. };
  75. Fast.api.open($.fn.bootstrapTable.defaults.extend.detail_url + "?ids=" + $(this).data('id'), '工单详情', options);
  76. });
  77. $(document).on('click', '.show-customer', function (data) {
  78. var area = [$(window).width() > 1200 ? '1200px' : '95%', $(window).height() > 800 ? '800px' : '95%'];
  79. var options = {
  80. shadeClose : false,
  81. shade : [0.3, '#393D49'],
  82. area : area,
  83. callback : function (value) {
  84. //在回调函数里可以调用你的业务代码实现前端的各种逻辑和效果
  85. console.log(value);
  86. }
  87. };
  88. Fast.api.open("qingdongams/customer/customer/detail?ids=" + $(this).data('id'), '客户详情', options);
  89. });
  90. // 为表格绑定事件
  91. Table.api.bindevent(table);
  92. },
  93. add : function () {
  94. Controller.api.bindevent();
  95. },
  96. change : function () {
  97. Controller.api.bindevent();
  98. },
  99. batch_change : function () {
  100. Controller.api.bindevent();
  101. },
  102. detail : function () {
  103. // 初始化表格参数配置
  104. Table.api.init({});
  105. Controller.api.bindevent();
  106. },
  107. api : {
  108. bindevent : function () {
  109. Form.api.bindevent($("form[role=form]"), function(data, ret){
  110. //这里是表单提交处理成功后的回调函数,接收来自php的返回数据
  111. Fast.api.close(data);//这里是重点
  112. });
  113. }
  114. }
  115. };
  116. return Controller;
  117. });