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/order.js

161 lines
8.2 KiB

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'order/index' + location.search,
add_url: 'order/add',
edit_url: 'order/edit',
del_url: 'order/del',
multi_url: 'order/multi',
import_url: 'order/import',
table: 'order',
}
});
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: 'warehouse.title', title: __('所属场次'),operate: 'LIKE'},
{field: 'order_type', title: __('订单类型'), formatter: Table.api.formatter.status, searchList: {1: __('卖单'), 0: __('买单')}},
{field: 'order_sn', title: __('Order_sn'), operate:"LIKE"},
{field: 'status', title: __('Status'), formatter: Table.api.formatter.status, searchList: Config.statusList},
{field: 'pay_amount', title: __('实付金额'), operate:'BETWEEN'},
{field: 'pay_time', title: __('Pay_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'createtime', title: __('下单时间'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
{field: 'user.nickname', title: __('昵称'),operate: 'LIKE'},
{field: 'user.mobile', title: __('手机号'),operate: 'LIKE'},
{field: 'detail.goods_id', title: __('商品id'),operate: 'LIKE'},
{field: 'detail.goods_name', title: __('标题'),operate: 'LIKE'},
{field: 'operate', title: __('Operate'), table: table,events: Table.api.events.operate,
buttons:[
{
name:'cancel',
text:'取消订单',
title:'取消订单',
confirm: '确定取消订单吗?',
classname: 'btn btn-xs btn-danger btn-magic btn-ajax',
icon: 'fa fa-check',
url: 'order/cancel',
visible:function(row){
if (row.status == 0) {
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:'cancel',
text:'拆分订单',
title:'拆分订单',
classname: 'btn btn-xs btn-info btn-view btn-dialog',
icon: 'fa fa-check',
url: 'order/split',
visible:function(row){
if (row.status == 3) {
return true;
}
return false;
},
refresh:true
},
{
name:'split',
text:'发货',
title:'发货',
classname: 'btn btn-xs btn-info btn-view btn-dialog',
icon: 'fa fa-check',
url: 'order/send/type/1',
visible:function(row){
if (row.status == 4) {
return true;
}
return false;
},
//refresh:true
},
{
name:'split',
text:'查看物流',
title:'查看物流',
classname: 'btn btn-xs btn-info btn-view btn-dialog',
icon: 'fa fa-check',
url: 'order/send/type/2',
visible:function(row){
if (row.order_type == 0 && (row.status == 5 || row.status == 6)) {
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 == 6) {
$(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();
},
send: function () {
Controller.api.bindevent();
},
split: function () {
$(document).on("fa.event.appendfieldlist", ".btn-append", function(){
Form.events.selectpage($("#setmeal_json"));
});
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});