lave_month.js 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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: 'wechat/lave_month/index' + location.search,
  8. // add_url: 'wechat/lave_month/add',
  9. // edit_url: 'wechat/lave_month/edit',
  10. del_url: 'wechat/lave_month/del',
  11. multi_url: 'wechat/lave_month/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: 'cid', title: __('Cid')},
  24. {field: 'user_id', title: __('User_id')},
  25. {field: 'order_id', title: __('Order_id'), operate: 'LIKE'},
  26. {field: 'order_name', title: __('Order_name'), operate: 'LIKE'},
  27. {field: 'amount', title: __('Amount'), operate:'BETWEEN'},
  28. {field: 'name', title: __('Name'), operate: 'LIKE'},
  29. {field: 'contact', title: __('Contact'), operate: 'LIKE'},
  30. {field: 'tel', title: __('Tel'), operate: 'LIKE'},
  31. {field: 'address', title: __('Address'), operate: 'LIKE'},
  32. {field: 'is_open', title: __('Is_open'), searchList: {"0":__('Is_open 0'),"1":__('Is_open 1')}, formatter: Table.api.formatter.normal},
  33. {field: 'is_ticket', title: __('Is_ticket'), searchList: {"0":__('Is_ticket 0'),"1":__('Is_ticket 1')}, formatter: Table.api.formatter.normal},
  34. {field: 'paid', title: __('Paid'), searchList: {"0":__('Paid 0'),"1":__('Paid 1')}, formatter: Table.api.formatter.normal},
  35. {field: 'pay_type', title: __('Pay_type'), searchList: {"0":__('Pay_type 0'),"1":__('Pay_type 1'),"2":__('Pay_type 2'),"3":__('Pay_type 3'),"4":__('Pay_type 4')}, formatter: Table.api.formatter.normal},
  36. {field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  37. {field: 'paytime', title: __('Paytime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
  38. {field: 'SN', title: __('Sn'), operate: 'LIKE'},
  39. {field: 'type', title: __('Type'), searchList: {"0":__('Type 0'),"1":__('Type 1')}, formatter: Table.api.formatter.normal},
  40. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  41. ]
  42. ]
  43. });
  44. // 为表格绑定事件
  45. Table.api.bindevent(table);
  46. },
  47. add: function () {
  48. Controller.api.bindevent();
  49. },
  50. edit: function () {
  51. Controller.api.bindevent();
  52. },
  53. api: {
  54. bindevent: function () {
  55. Form.api.bindevent($("form[role=form]"));
  56. var refreshkey = function (data) {
  57. // $("input[name='row[price]']").val(data.eventkey).trigger("change");
  58. Layer.closeAll();
  59. var keytitle = data.text;
  60. var cont = $(".clickbox .create-click:first");
  61. $(".keytitle", cont).remove();
  62. if (keytitle) {
  63. cont.append('<div class="keytitle">' + __('Event key') + ':' + keytitle + '</div>');
  64. }
  65. };
  66. $(document).on('click', "#select-resources", function () {
  67. var key = $("input[name='row[eventkey]']").val();
  68. parent.Backend.api.open($(this).attr("href") + "?key=" + key, __('Select'), {callback: refreshkey});
  69. return false;
  70. });
  71. $(document).on('click', "#add-resources", function () {
  72. parent.Backend.api.open($(this).attr("href") + "?key=", __('Add'), {callback: refreshkey});
  73. return false;
  74. });
  75. }
  76. }
  77. };
  78. return Controller;
  79. });