hearbook.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  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: 'hearbook/index',
  8. add_url: 'hearbook/add',
  9. edit_url: 'hearbook/edit',
  10. del_url: 'hearbook/del',
  11. multi_url: 'hearbook/multi',
  12. table: 'hearbook',
  13. }
  14. });
  15. var table = $("#table");
  16. // 初始化表格
  17. table.bootstrapTable({
  18. url: $.fn.bootstrapTable.defaults.extend.index_url,
  19. pk: 'id',
  20. sortName: 'id',
  21. columns: [
  22. [
  23. {checkbox: true},
  24. {field: 'id', title: __('Id')},
  25. {field: 'title', title: __('Title')},
  26. {field: 'entitle', title: __('Entitle')},
  27. {field: 'version', title: __('Version')},
  28. {field: 'basic_title', title: __('Basic_title')},
  29. {field: 'boy_voice_title', title: __('Boy_voice_title')},
  30. {field: 'girl_voice_title', title: __('Girl_voice_title')},
  31. {field: 'package_title', title: __('Package_title')},
  32. {field: 'isallowed', title: __('Isallowed'), visible:false, searchList: {"isallowed 0":__('Isallowed 0'),"isallowed 1":__('Isallowed 1')}},
  33. {field: 'isallowed_text', title: __('Isallowed'), operate:false},
  34. {field: 'appid', title: __('Appid')},
  35. {field: 'apikey', title: __('Apikey')},
  36. {field: 'servretkey', title: __('Servretkey')},
  37. {field: 'status', title: __('Status'), visible:false, searchList: {"status 0":__('Status 0'),"status 1":__('Status 1')}},
  38. {field: 'status_text', title: __('Status'), operate:false},
  39. {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
  40. ]
  41. ]
  42. });
  43. // 为表格绑定事件
  44. Table.api.bindevent(table);
  45. },
  46. add: function () {
  47. checkForm();
  48. Controller.api.bindevent();
  49. },
  50. edit: function () {
  51. checkForm();
  52. Controller.api.bindevent();
  53. },
  54. api: {
  55. bindevent: function () {
  56. Form.api.bindevent($("form[role=form]"));
  57. }
  58. }
  59. };
  60. return Controller;
  61. });
  62. // 状态为有效时,某些字段不能为空
  63. function checkForm()
  64. {
  65. $("button[type='submit']").click(function(){
  66. var status_val = $("[name='row[status]']:checked").val();
  67. if(status_val == 1){
  68. var basic_title_len = $("#c-basic_title").val().length;
  69. var boy_voice_title_len = $("#c-boy_voice_title").val().length;
  70. var girl_voice_title_len = $("#c-girl_voice_title").val().length;
  71. var male_anchor_title_len = $("#c-male_anchor_title").val().length;
  72. var child_anchor_title_len = $("#c-child_anchor_title").val().length;
  73. var appid_len = $("#c-appid").val().length;
  74. var apikey_len = $("#c-apikey").val().length;
  75. var servretkey_len = $("#c-servretkey").val().length;
  76. if(basic_title_len == 0){
  77. Toastr.error('基础语音包文件名不能为空');
  78. return false;
  79. }
  80. if(boy_voice_title_len == 0){
  81. Toastr.error('青年男声不能为空');
  82. return false;
  83. }
  84. if(girl_voice_title_len == 0){
  85. Toastr.error('青年女声不能为空');
  86. return false;
  87. }
  88. if(male_anchor_title_len == 0){
  89. Toastr.error('男主播不能为空');
  90. return false;
  91. }
  92. if(child_anchor_title_len == 0){
  93. Toastr.error('娃娃音不能为空');
  94. return false;
  95. }
  96. if(appid_len == 0){
  97. Toastr.error('Appid不能为空');
  98. return false;
  99. }
  100. if(apikey_len == 0){
  101. Toastr.error('Apikey不能为空');
  102. return false;
  103. }
  104. if(servretkey_len == 0){
  105. Toastr.error('Servretkey不能为空');
  106. return false;
  107. }
  108. }
  109. });
  110. }