plan_record.js 3.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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/plan_record/index' + location.search,
  8. // add_url: 'wechat/plan/add',
  9. // edit_url: 'wechat/plan/edit',
  10. del_url: 'wechat/plan/del',
  11. multi_url: 'wechat/plan/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: 'plan_id', title: __('Plan_id')},
  25. {field: 'contract_display_account', title: __('contract_display_account')},
  26. // {field: 'text', title: __('Text')},
  27. {field: 'price', title: __('price')},
  28. {field: 'is_signing', title: __('is_signing'), searchList: {"0":__('is_signing 0'),"1":__('is_signing 1'),"2":__('is_signing 2')}, formatter: Table.api.formatter.normal},
  29. {field: 'createtime', title: __('Create time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  30. // {field: 'updatetime', title: __('Update time'), formatter: Table.api.formatter.datetime, operate: 'RANGE', addclass: 'datetimerange', sortable: true},
  31. // {field: 'status', title: __('Status'), formatter: Table.api.formatter.status},
  32. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  33. ]
  34. ]
  35. });
  36. // 为表格绑定事件
  37. Table.api.bindevent(table);
  38. },
  39. add: function () {
  40. Controller.api.bindevent();
  41. },
  42. edit: function () {
  43. Controller.api.bindevent();
  44. },
  45. api: {
  46. bindevent: function () {
  47. Form.api.bindevent($("form[role=form]"));
  48. var refreshkey = function (data) {
  49. // $("input[name='row[price]']").val(data.eventkey).trigger("change");
  50. Layer.closeAll();
  51. var keytitle = data.text;
  52. var cont = $(".clickbox .create-click:first");
  53. $(".keytitle", cont).remove();
  54. if (keytitle) {
  55. cont.append('<div class="keytitle">' + __('Event key') + ':' + keytitle + '</div>');
  56. }
  57. };
  58. $(document).on('click', "#select-resources", function () {
  59. var key = $("input[name='row[eventkey]']").val();
  60. parent.Backend.api.open($(this).attr("href") + "?key=" + key, __('Select'), {callback: refreshkey});
  61. return false;
  62. });
  63. $(document).on('click', "#add-resources", function () {
  64. parent.Backend.api.open($(this).attr("href") + "?key=", __('Add'), {callback: refreshkey});
  65. return false;
  66. });
  67. }
  68. }
  69. };
  70. return Controller;
  71. });