You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
104 lines
5.4 KiB
104 lines
5.4 KiB
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
|
|
|
var Controller = {
|
|
index: function () {
|
|
// 初始化表格参数配置
|
|
Table.api.init({
|
|
extend: {
|
|
index_url: 'goods/index' + location.search,
|
|
add_url: 'goods/add',
|
|
edit_url: 'goods/edit',
|
|
del_url: 'goods/del',
|
|
multi_url: 'goods/multi',
|
|
import_url: 'goods/import',
|
|
table: 'goods',
|
|
}
|
|
});
|
|
|
|
var table = $("#table");
|
|
|
|
// 初始化表格
|
|
table.bootstrapTable({
|
|
url: $.fn.bootstrapTable.defaults.extend.index_url,
|
|
pk: 'id',
|
|
sortName: 'id',
|
|
fixedColumns: true,
|
|
fixedRightNumber: 1,
|
|
columns: [
|
|
[
|
|
{checkbox: true},
|
|
{field: 'id', title: __('Id')},
|
|
{field: 'goods_type', title: __('商品类型'), formatter: Table.api.formatter.status, searchList: {1: __('商品'), 0: __('商品池')}},
|
|
|
|
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
|
|
{field: 'owner', title: __('归属人'),operate: false},
|
|
{field: 'user.nickname', title: __('归属人'),visible: false,operate: 'LIKE'},
|
|
{field: 'name', title: __('Name'), operate: 'LIKE'},
|
|
{field: 'warehouse.title', title: __('Warehouse_id')},
|
|
{field: 'price', title: __('Price'), operate:'BETWEEN'},
|
|
|
|
{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: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: {normal: __('Normal'), hidden: __('Hidden')}},
|
|
|
|
// {field: 'content', title: __('Content')},
|
|
// {field: 'goods_form', title: __('Goods_form'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
// {field: 'on_time', title: __('On_time'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
// {field: 'off_time', title: __('Off_time'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
|
|
{field: 'operate', title: __('Operate'), table: table,events: Table.api.events.operate,
|
|
buttons:[
|
|
// {
|
|
// name:'split',
|
|
// text:'可拆分',
|
|
// title:'可拆分',
|
|
// classname: 'btn btn-xs btn-info btn-view btn-dialog',
|
|
// icon: 'fa fa-check',
|
|
// url: 'goods/split',
|
|
// visible:function(row){
|
|
// if (row.goods_type == 1) {
|
|
// return true;
|
|
// }
|
|
// return false;
|
|
// },
|
|
// //refresh:true
|
|
// },
|
|
],
|
|
formatter: function(value, row, index) {
|
|
var that = $.extend({}, this);
|
|
var table = $(that.table).clone(true);
|
|
// operate-edit编辑 perate-del删除
|
|
//判断什么时候显示什么时候不显示
|
|
|
|
if (row.status == 1) {
|
|
//$(table).data("operate-edit", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
|
|
//$(table).data("operate-del", null); // 列表页面隐藏 .编辑operate-edit - 删除按钮operate-del
|
|
}
|
|
that.table = table;
|
|
return Table.api.formatter.operate.call(that, value, row, index);
|
|
},
|
|
// cellStyle: {css: {"max-width": "100px","white-space":"pre-line","word-wrap":"break-word","word-break":"break-all"}}
|
|
}
|
|
]
|
|
]
|
|
});
|
|
|
|
// 为表格绑定事件
|
|
Table.api.bindevent(table);
|
|
},
|
|
add: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
edit: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
split: function () {
|
|
Controller.api.bindevent();
|
|
},
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
}
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|
|
|