define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'service/order/order/index' + location.search,
// edit_url: 'service/order/order/edit',
multi_url: 'service/order/order/multi',
import_url: 'service/order/order/import',
table: 'service_order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'id',
fixedColumns: true,
fixedRightNumber: 1,
columns: [
[
{field: 'goods_id', title: __('项目信息'),operate: false, cellStyle: function () {return {css: {"min-width": "266px"}}},formatter:function (value,row) {
return `
订单编号:${row.orderId}
ID:${row.id}
${row.detail.name}
${row.to_shop_text}
规格
${row.detail.sku_name}
数量
X${row.detail.num}
价格
${row.detail.price}
`
}},
{field: 'status', title: __('状态'),operate: false, cellStyle: function () {return {css: {"width": "200px"}}},formatter:function (value,row){
let result = '';
if(row.to_shop == 'shop' && row.status == 2){
result += `
订单状态
待核销
`
} else {
result += `
订单状态
${row.status_text}
`
}
result += `
售后状态
${row.is_service_text}
投诉状态
${row.is_complaint_text}
`
return result
}},
{field: 'user_id', title: __('用户信息'),operate: false, cellStyle: function () {return {css: {"min-width": "248px"}}},formatter:function (value,row){
let result = `
${row.user.nickname}
${row.user.mobile}
`
if(row.to_shop == 'door'){
result += `
预约信息:${row.address.name+''+row.address.mobile}
地址:${row.address.province+row.address.city+row.address.district+row.address.area+row.address.address}
预约时间:${row.starttime_text}
`
}else {
result += `
核销码:${row.check_name}
核销二维码:

`
}
result += `
`
return result
}},
{field: 'shop_id', title: __('服务者/门店信息'),operate: false, cellStyle: function () {return {css: {"min-width": "248px"}}},formatter:function (value,row){
if(row.shop && row.skill){
return `
门店信息
${row.shop.name}
${row.shop.leader_name+''+row.shop.leader_mobile}
服务者
${row.skill.name}
${row.skill.mobile}
`
}else if(row.skill){
return `
服务者
${row.skill.name}
${row.skill.mobile}
`
}else if(row.shop){
return `
门店信息
${row.shop.name}
${row.shop.leader_name+''+row.shop.leader_mobile}
`
}else {
return ''
}
}},
{field: 'price', title: __('付款信息'),operate: false, cellStyle: function () {return {css: {"min-width": "108px"}}},formatter:function (value,row){
return ``
}},
{field: 'id', title: __('财务'),operate: false, cellStyle: function () {return {css: {"min-width": "250px"}}},formatter:function (value,row){
if(row.is_settle == 2){
let result = `
付款方式
${row.paytype_text}
服务者佣金
${row.skillRebate || 0}
`
if(row.shop_id > 0){
result +=`
商户佣金
${row.shopRebate}
`
}
return result
}else {
let result = `
付款方式
${row.paytype_text}
服务者佣金
${row.is_settle_text}
`
if(row.shop_id > 0){
result +=`
商户佣金
${row.is_settle_text}
`
}
if(row.leader_id>0){
result +=`
一级佣金
${row.is_settle_text}
`
}
if(row.rec_leader_id>0){
result +=`
二级佣金
${row.is_settle_text}
`
}
return result
}
}},
{field: 'id', title: __('时间'),operate: false, cellStyle: function () {return {css: {"min-width": "180px"}}},formatter:function (value,row){
return `
预约时间
${row.starttime_text}
`
}},
// {checkbox: true},
{field: 'id', title: __('Id'),visible: false},
{field: 'orderId', title: __('Orderid'), operate: 'LIKE', width:148,visible: false},
// {field: 'reach_images', title: __('Reach_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
// {field: 'finish_images', title: __('Finish_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'user_id', title: __('User_id'),visible: false},
{field: 'skill_id', title: __('Skill_id'),visible: false},
{field: 'leader_id', title: __('leader_id'),visible: false},
{field: 'rec_leader_id', title: __('rec_leader_id'),visible: false},
{field: 'shop_id', title: __('Shop_id'),visible: false},
{field: 'goods_id', title: __('Goods_id'),visible: false},
{field: 'traveltype', title: __('Traveltype'), searchList: {"0":__('Traveltype 0'),"1":__('Traveltype 1'),"2":__('Traveltype 2')}, formatter: Table.api.formatter.normal,visible: false},
{field: 'choose_skill_type', title: __('Choose_skill_type'), searchList: {"0":__('Choose_skill_type 0'),"1":__('Choose_skill_type 1')}, formatter: Table.api.formatter.normal,visible: false},
{field: 'paytype', title: __('Paytype'), searchList: {"0":__('Paytype 0'),"1":__('Paytype 1'),"2":__('Paytype 2'),"3":__('Paytype 3'),"4":__('Paytype 4')}, formatter: Table.api.formatter.normal,visible: false},
{field: 'to_shop', title: __('To_shop'), searchList: {"door":__('To_shop door'),"shop":__('To_shop shop')}, formatter: Table.api.formatter.normal,visible: false},
{field: 'price', title: __('Price'), operate:'BETWEEN',visible: false},
// {field: 'distance', title: __('Distance'), operate:'BETWEEN'},
// {field: 'travel_price', title: __('Travel_price'), operate:'BETWEEN'},
// {field: 'sumprice', title: __('Sumprice'), operate:'BETWEEN'},
// {field: 'goods_total_price', title: __('Goods_total_price'), operate:'BETWEEN'},
// {field: 'discount', title: __('Discount')},
// {field: 'coupon_id', title: __('Coupon_id')},
// {field: 'coupon_price', title: __('Coupon_price'), operate:'BETWEEN'},
// {field: 'premium_price', title: __('Premium_price'), operate:'BETWEEN'},
// {field: 'add_price', title: __('Add_price'), operate:'BETWEEN'},
{field: 'payprice', title: __('Payprice'), operate:'BETWEEN',visible: false},
{field: 'act_travel_price', title: __('Act_travel_price'), operate:'BETWEEN',visible: false},
{field: 'refund_price', title: __('Refund_price'), operate:'BETWEEN',visible: false},
{field: 'settle_price', title: __('Settle_price'), operate:'BETWEEN',visible: false},
{field: 'total_cost_seconds', title: __('Total_cost_seconds'),visible: false},
{field: 'starttime', title: __('Starttime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false},
{field: 'endtime', title: __('Endtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false},
//{field: 'actendtime', title: __('Actendtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime},
//{field: 'trade_no', title: __('Trade_no'), operate: 'LIKE'},
{field: 'memo', title: __('Memo'), operate: 'LIKE',visible: false},
{field: 'qrcode_image', title: __('Qrcode_image'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.image,visible: false},
{field: 'check_name', title: __('Check_name'),visible: false},
{field: 'is_service', title: __('Is_service'), searchList: {"0":__('Is_service 0'),"1":__('Is_service 1'),"2":__('Is_service 2'),"-1":__('Is_service -1')}, formatter: Table.api.formatter.normal,visible: false},
{field: 'is_complaint', title: __('Is_complaint'), searchList: {"0":__('Is_complaint 0'),"1":__('Is_complaint 1')}, formatter: Table.api.formatter.normal,visible: false},
//{field: 'is_pool', title: __('Is_pool'), searchList: {"0":__('Is_pool 0'),"1":__('Is_pool 1')}, formatter: Table.api.formatter.normal},
{field: 'is_settle', title: __('Is_settle'), searchList: {"0":__('Is_settle 0'),"1":__('Is_settle 1'),"2":__('Is_settle 2')}, formatter: Table.api.formatter.normal,visible: false},
// {field: 'reach_images', title: __('Reach_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
// {field: 'finish_images', title: __('Finish_images'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'status', title: __('Status'), searchList: {"0":__('Status 0'),"1":__('Status 1'),"2":__('Status 2'),"3":__('Status 3'),"4":__('Status 4'),"5":__('Status 5'),"6":__('Status 6'),"7":__('Status 7'),"-1":__('Status -1')}, formatter: Table.api.formatter.status,visible: false},
{field: 'createtime', title: __('Createtime'), operate:'RANGE', addclass:'datetimerange', autocomplete:false, formatter: Table.api.formatter.datetime,visible: false},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
buttons: [
{
name: 'detail',
text: __('订单详情'),
title: __('订单详情'),
classname: 'btn btn-xs btn-detail btn-dialog',
icon: 'fa fa-detail',
url: function(row){
return 'service/order/order/info?ids='+row.id;
},
},
{
name: 'users',
text: __('分配商户'),
title: __('分配商户'),
classname: 'btn btn-xs btn-change btn-dialog',
url: function(row){
return 'service/order/order/updateshop?ids='+row.id;
},
visible:function(row){
if(row.status == 1 && !row.shop_id && !row.skill_id && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'users',
text: __('分配服务者'),
title: __('分配服务者'),
classname: 'btn btn-xs btn-change btn-dialog',
url: function(row){
return 'service/order/order/updateskill?ids='+row.id;
},
visible:function(row){
if(row.status == 1 && !row.skill_id && row.to_shop == 'door' && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'users',
text: __('更换服务者'),
title: __('更换服务者'),
classname: 'btn btn-xs btn-change btn-dialog',
url: function(row){
return 'service/order/order/updateskill?ids='+row.id;
},
visible:function(row){
if(row.skill_id && (row.status == 1 || row.status == 2) && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'accept',
text: __('订单接取'),
title: __('订单接取'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=2',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if((row.skill_id) && row.status === 1 && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'go',
text: __('服务者出发'),
title: __('服务者出发'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=3',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if(row.status === 2 && row.to_shop == 'door' && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'check',
text: __('订单已核销'),
title: __('订单已核销'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=6',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if(row.status === 2 && row.to_shop == 'shop' && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: '',
text: __('服务者到达'),
title: __('服务者到达'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=4',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if(row.status === 3 && row.to_shop == 'door' && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: '',
text: __('开始服务'),
title: __('开始服务'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=5',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if(row.status === 4 && row.to_shop == 'door' && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: '',
text: __('服务完成'),
title: __('服务完成'),
classname: 'btn btn-xs btn-status btn-ajax',
url: 'service/order/order/handleOrder?state=6',
success: function (data, ret) {
$(".btn-refresh").trigger('click');
},
visible:function(row){
if(row.status === 5 && (row.is_service == 0 || row.is_service == -1)){
return true;
}
}
},
{
name: 'comment',
text: __('订单评价'),
title: __('订单评价'),
classname: 'btn btn-xs btn-success btn-comment btn-dialog',
url: function(row){
return 'service/order/comment/index?order_id='+row.id;
},
visible:function(row){
if(row.status === 7){
return true;
}
}
},
{
name: 'refund',
text: __('退款'),
title: __('退款'),
classname: 'btn btn-xs btn-cancel btn-dialog',
url: function(row){
return 'service/order/order/refund?ids='+row.id;
},
hidden:function(row){
if(row.is_settle === 2 || row.is_service === 2 || row.status == -1 || row.status == 0){
return true;
}
}
},
],
formatter: Table.api.formatter.operate}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
recyclebin: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
'dragsort_url': ''
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
url: 'service/order/order/recyclebin' + location.search,
pk: 'id',
sortName: 'id',
columns: [
[
{checkbox: true},
{field: 'id', title: __('Id')},
{
field: 'deletetime',
title: __('Deletetime'),
operate: 'RANGE',
addclass: 'datetimerange',
formatter: Table.api.formatter.datetime
},
{
field: 'operate',
width: '140px',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
buttons: [
{
name: 'Restore',
text: __('Restore'),
classname: 'btn btn-xs btn-info btn-ajax btn-restoreit',
icon: 'fa fa-rotate-left',
url: 'service/order/order/restore',
refresh: true
},
{
name: 'Destroy',
text: __('Destroy'),
classname: 'btn btn-xs btn-danger btn-ajax btn-destroyit',
icon: 'fa fa-times',
url: 'service/order/order/destroy',
refresh: true
}
],
formatter: Table.api.formatter.operate
}
]
]
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
updateshop: function () {
$(document).on('click', '.btn-embossed', function () {
parent.$(".btn-refresh").trigger('click');
});
Controller.api.bindevent();
},
updateskill: function () {
$(document).on('click', '.btn-embossed', function () {
parent.$(".btn-refresh").trigger('click');
});
Controller.api.bindevent();
},
refund: function () {
$(document).on('click', '.btn-embossed', function () {
parent.$(".btn-refresh").trigger('click');
});
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});