123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'gg/index' + location.search,
- add_url: 'gg/add',
- edit_url: 'gg/edit',
- del_url: 'gg/del',
- multi_url: 'gg/multi',
- import_url: 'gg/import',
- table: 'gg',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- showExport:false,
- commonSearch:false,
- search:false,
- columns: [
- [
- {checkbox: true},
- {field:'id', title: __('序号'),formatter: function(value, row, index){return ++index;}, operate: false},
- // {field: 'content', title: __('Content'), operate: 'LIKE'},
- // {field: 'images', title: __('Images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
- {field: 'title', title: __('标题')},
- {field: 'image', title: __('配图'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image, operate: false},
- {field: 'type', title: __('Type'), searchList: {"1":__('纯图'),"2":__('图文')}, formatter: Table.api.formatter.status},
- {field: 'switch', title: __('Switch'), table: table, formatter: Table.api.formatter.toggle},
- {field: 'sort', title: __('Sort')},
- {field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
- {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate}
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- $(document).on('change', "#c-type_text", function () {
- var that = this;
- if ($(that).val() == '纯图') {
- $("#c-imagess").attr("style","display:block;");
- $("#c-contents").attr("style","display:none;");
- } else {
- $("#c-contents").attr("style","display:block;");
- $("#c-imagess").attr("style","display:none;");
- // alert(222)
- }
- });
- Form.api.bindevent($("form[role=form]"));
- },
- edit: function () {
- var type = Config.type;
- if (type == 2) {
- $("#c-contents").attr("style","display:block;");
- } else {
- $("#c-imagess").attr("style","display:block;");
- }
- $(document).on('change', "#c-type_text", function () {
- var that = this;
- if ($(that).val() == '纯图') {
- $("#c-imagess").attr("style","display:block;");
- $("#c-contents").attr("style","display:none;");
- } else {
- $("#c-contents").attr("style","display:block;");
- $("#c-imagess").attr("style","display:none;");
- // alert(222)
- }
- });
- Form.api.bindevent($("form[role=form]"));
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|