order.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. define(['jquery', 'bootstrap', 'backend', 'form', 'table'], function ($, undefined, Backend, Form, Table) {
  2. var Controller = {
  3. index: function () {
  4. // 初始化表格参数配置
  5. Table.api.init({
  6. extend: {
  7. index_url: 'order/index',
  8. add_url: 'order/add',
  9. edit_url: 'order/edit',
  10. del_url: 'order/del',
  11. multi_url: 'order/multi',
  12. }
  13. });
  14. var table = $("#table");
  15. // 初始化表格
  16. table.bootstrapTable({
  17. url: $.fn.bootstrapTable.defaults.extend.index_url,
  18. sortName: 'id',
  19. columns: [
  20. [
  21. {field: 'state', checkbox: true, },
  22. {field: 'id', title: __('Id')},
  23. {field: 'user_id', title: __('User_id')},
  24. {field: 'book_id', title: __('Book_id')},
  25. {field: 'title', title: __('Title')},
  26. {field: 'author', title: __('Author')},
  27. {field: 'amount', title: __('Amount')},
  28. {field: 'saleamount', title: __('Saleamount')},
  29. {field: 'nums', title: __('Nums')},
  30. {field: 'payamount', title: __('Payamount')},
  31. {field: 'paytime', title: __('Paytime'), formatter: Table.api.formatter.datetime},
  32. {field: 'paytype', title: __('Paytype')},
  33. {field: 'createtime', title: __('Createtime'), formatter: Table.api.formatter.datetime},
  34. {field: 'status', title: __('Status'), formatter: Controller.api.formatter.status},
  35. {field: 'operate', title: __('Operate'), events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  36. ]
  37. ]
  38. });
  39. // 为表格绑定事件
  40. Table.api.bindevent(table);
  41. $(document).on('click', '.btn-filter-paid', function () {
  42. table.bootstrapTable('refresh', {query: {filter: JSON.stringify({status: 'paid'}), op: JSON.stringify({status: '='})}});
  43. });
  44. },
  45. add: function () {
  46. Controller.api.bindevent();
  47. },
  48. edit: function () {
  49. Controller.api.bindevent();
  50. },
  51. volume: function () {
  52. Controller.api.bindevent();
  53. require(['angular', 'angular-app', 'angular-ui-select', 'ngcontrol/volume'], function (angular, app, printapp) {
  54. angular.bootstrap(document, ["ui.select", "App"]);
  55. });
  56. },
  57. print: function () {
  58. require(['frontend-ebook'], function (Ebook) {
  59. window.imageLoaded = Ebook.imageLoaded;
  60. $(".ebook_container").on("load", "img", function () {
  61. $(this).parent().removeClass('img_loading');
  62. });
  63. require(['angular', 'angular-app', 'ngcontrol/preface', 'ngcontrol/preview'], function (angular, app) {
  64. angular.bootstrap(document, ["App"]);
  65. });
  66. });
  67. },
  68. api: {
  69. bindevent: function () {
  70. Form.api.bindevent($("form[role=form]"));
  71. $(document).bind("change", "input[name='row[status]']", function(){
  72. $("#expressdom").toggleClass("hidden", ['created', 'paid', 'printing', 'deleted'].indexOf($("input[name='row[status]']:checked").val())>-1);
  73. });
  74. },
  75. formatter: {
  76. icon: function (value, row, index) {
  77. //渲染fontawesome图标
  78. return '<i class="fa fa-' + value + '"></i> ' + value;
  79. },
  80. status: function (value, row, index) {
  81. //渲染状态
  82. var html = '';
  83. if (value == 'created') {
  84. html = '<span class="text-purple"><i class="fa fa-circle"></i> ' + __('Created') + '</span>';
  85. } else if (value == 'paid') {
  86. html = '<a href="/order/volume/ids/' + row['id'] + '" class="btn btn-danger btn-xs btn-dialog" title="' + __('Print') + '"><i class="fa fa-print"></i> ' + __('Paid,Print Now') + '</a>';
  87. } else if (value == 'printing') {
  88. html = '<span class="text-warning"><i class="fa fa-print"></i> ' + __('Printing') + '</span>';
  89. } else if (value == 'delivered') {
  90. html = '<span class="text-success"><i class="fa fa-circle"></i> ' + __('Delivered') + '</span>';
  91. } else if (value == 'finished') {
  92. html = '<span class="text-info"><i class="fa fa-ok"></i> ' + __('Finished') + '</span>';
  93. } else if (value == 'deleted') {
  94. html = '<span class="text-maroon"><i class="fa fa-remove"></i> ' + __('Deleted') + '</span>';
  95. }
  96. return html;
  97. },
  98. }
  99. }
  100. };
  101. return Controller;
  102. });