123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
- var Controller = {
- index: function () {
- // 初始化表格参数配置
- Table.api.init({
- extend: {
- index_url: 'shop/attribute/index' + location.search,
- add_url: 'shop/attribute/add/category_id/' + Config.category_id,
- edit_url: 'shop/attribute/edit',
- del_url: 'shop/attribute/del',
- multi_url: 'shop/attribute/multi',
- import_url: 'shop/attribute/import',
- table: 'shop_attribute',
- }
- });
- var table = $("#table");
- // 初始化表格
- table.bootstrapTable({
- url: $.fn.bootstrapTable.defaults.extend.index_url,
- pk: 'id',
- sortName: 'id',
- columns: [
- [{
- checkbox: true
- },
- {
- field: 'id',
- title: __('Id')
- },
- {
- field: 'category_id',
- title: __('Category_id'),
- visible: false
- },
- {
- field: 'name',
- title: __('Name'),
- operate: 'LIKE'
- },
- {
- field: 'type',
- title: __('Type'),
- searchList: {
- "radio": __('Type radio'),
- "checkbox": __('Type checkbox')
- },
- formatter: Table.api.formatter.normal
- },
- {
- field: 'is_must',
- title: __('Is_must'),
- searchList: {
- "1": __('Yes'),
- "0": __('No')
- },
- table: table,
- formatter: Table.api.formatter.toggle
- },
- {
- field: 'is_search',
- title: __('Is_search'),
- searchList: {
- "1": __('Yes'),
- "0": __('No')
- },
- table: table,
- formatter: Table.api.formatter.toggle
- },
- {
- field: 'createtime',
- title: __('Createtime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'updatetime',
- title: __('Updatetime'),
- operate: 'RANGE',
- addclass: 'datetimerange',
- autocomplete: false,
- formatter: Table.api.formatter.datetime
- },
- {
- field: 'operate',
- title: __('Operate'),
- table: table,
- events: Table.api.events.operate,
- formatter: Table.api.formatter.operate,
- buttons: [{
- name: 'goods_attribute',
- title: __('属性值'),
- classname: 'btn btn-xs btn-primary btn-dialog',
- text: '属性值',
- extend: 'data-area=\'["90%","90%"]\'',
- url: 'shop/attribute_value/index/attribute_id/{id}',
- icon: 'fa fa-plus'
- }]
- }
- ]
- ]
- });
- // 为表格绑定事件
- Table.api.bindevent(table);
- },
- add: function () {
- Controller.api.bindevent();
- },
- edit: function () {
- Controller.api.bindevent();
- },
- api: {
- bindevent: function () {
- Form.api.bindevent($("form[role=form]"));
- }
- }
- };
- return Controller;
- });
|