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.
 
 
 
 
 
 
ymww_backend/public/assets/js/backend/warehouse.js

161 lines
8.6 KiB

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'warehouse/index' + location.search,
add_url: 'warehouse/add',
edit_url: 'warehouse/edit',
del_url: 'warehouse/del',
multi_url: 'warehouse/multi',
import_url: 'warehouse/import',
table: 'warehouse',
}
});
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: 'title', title: __('Title'), operate: 'LIKE'},
{field: 'image', title: __('Image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image},
{field: 'period', title: __('时间段'), operate: false},
{field: 'limit_buy_num', title: __('Limit_buy_num')},
// {field: 'end_time', title: __('End_time'), operate: 'LIKE'},
// {field: 'before_activity_hour', title: __('Before_activity_hour')},
// {field: 'after_activity_hour', title: __('After_activity_hour')},
// {field: 'entrusted_ratio', title: __('Entrusted_ratio'), operate:'BETWEEN'},
// {field: 'entrustment_ratio', title: __('Entrustment_ratio'), operate:'BETWEEN'},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'status', title: __('Status'), searchList: {normal: __('Normal'), hidden: __('Hidden')}, formatter: Table.api.formatter.status},
// {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,
buttons:[
{
name:'split',
text:'订单汇算',
title:'订单汇算',
confirm: '确定订单汇算吗?',
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa fa-check',
url: 'warehouse/settle',
visible:function(row){
if (row.show_status == 1) {
return true;
}
return false;
},
success: function (data, ret) {
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
},
refresh:true
},
{
name:'split',
text:'汇算确认',
title:'汇算确认',
confirm: '确定汇算确认吗?',
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa fa-check',
url: 'warehouse/confirm',
visible:function(row){
if (row.show_status == 2) {
return true;
}
return false;
},
success: function (data, ret) {
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
return false;
},
refresh:true
},
{
name:'split',
text:'开启售卖',
title:'开启售卖',
confirm: '确定开启售卖吗?',
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa fa-check',
url: 'warehouse/sell',
visible:function(row){
if (row.show_status == 3) {
return true;
}
return false;
},
success: function (data, ret) {
$(".btn-refresh").trigger("click");
//如果需要阻止成功提示,则必须使用return false;
//return false;
},
error: function (data, ret) {
console.log(data, ret);
Layer.alert(ret.msg);
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();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});