123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'hearbook/index',
- add_url: 'hearbook/add',
- edit_url: 'hearbook/edit',
- del_url: 'hearbook/del',
- multi_url: 'hearbook/multi',
- table: 'hearbook',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [
- {checkbox: true},
- {field: 'id', title: __('Id')},
- {field: 'title', title: __('Title')},
- {field: 'entitle', title: __('Entitle')},
- {field: 'version', title: __('Version')},
- {field: 'basic_title', title: __('Basic_title')},
- {field: 'boy_voice_title', title: __('Boy_voice_title')},
- {field: 'girl_voice_title', title: __('Girl_voice_title')},
- {field: 'package_title', title: __('Package_title')},
- {field: 'isallowed', title: __('Isallowed'), visible:false, searchList: {"isallowed 0":__('Isallowed 0'),"isallowed 1":__('Isallowed 1')}},
- {field: 'isallowed_text', title: __('Isallowed'), operate:false},
- {field: 'appid', title: __('Appid')},
- {field: 'apikey', title: __('Apikey')},
- {field: 'servretkey', title: __('Servretkey')},
- {field: 'status', title: __('Status'), visible:false, searchList: {"status 0":__('Status 0'),"status 1":__('Status 1')}},
- {field: 'status_text', title: __('Status'), operate:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- checkForm();
- Controller.api.bindevent();
- },
- edit: function () {
- checkForm();
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
- // 状态为有效时,某些字段不能为空
- function checkForm()
- {
- $("button[type='submit']").click(function(){
- var status_val = $("[name='row[status]']:checked").val();
- if(status_val == 1){
- var basic_title_len = $("#c-basic_title").val().length;
- var boy_voice_title_len = $("#c-boy_voice_title").val().length;
- var girl_voice_title_len = $("#c-girl_voice_title").val().length;
- var male_anchor_title_len = $("#c-male_anchor_title").val().length;
- var child_anchor_title_len = $("#c-child_anchor_title").val().length;
- var appid_len = $("#c-appid").val().length;
- var apikey_len = $("#c-apikey").val().length;
- var servretkey_len = $("#c-servretkey").val().length;
- if(basic_title_len == 0){
- Toastr.error('基础语音包文件名不能为空');
- return false;
- }
- if(boy_voice_title_len == 0){
- Toastr.error('青年男声不能为空');
- return false;
- }
- if(girl_voice_title_len == 0){
- Toastr.error('青年女声不能为空');
- return false;
- }
- if(male_anchor_title_len == 0){
- Toastr.error('男主播不能为空');
- return false;
- }
- if(child_anchor_title_len == 0){
- Toastr.error('娃娃音不能为空');
- return false;
- }
- if(appid_len == 0){
- Toastr.error('Appid不能为空');
- return false;
- }
- if(apikey_len == 0){
- Toastr.error('Apikey不能为空');
- return false;
- }
- if(servretkey_len == 0){
- Toastr.error('Servretkey不能为空');
- return false;
- }
- }
- });
- }
|