allocatr/public/assets/js/backend/order.js
2025-03-10 15:49:47 +08:00

221 lines
9.6 KiB
JavaScript

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
function clearInfo() {
$('[name^="row["]').val('');
$("#c-city").citypicker('reset');
$(".selectpicker").val('').selectpicker('refresh');
}
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',
push_url: 'order/status',
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: 'user.nickname', title: '录单员'},
{field: 'order_no', title: __('Order_no'), operate: 'LIKE'},
{field: 'customer', title: __('Customer'), operate: 'LIKE'},
{field: 'tel', title: __('Tel'), operate: 'LIKE'},
{
field: 'status',
title: __('Status'),
searchList: {
"10": __('Status 10'),
"20": __('Status 20'),
"30": __('Status 30'),
"40": __('Status 40'),
"50": __('Status 50'),
"-10": __('Status -10'),
"-20": __('Status -20'),
"-30": __('Status -30')
},
formatter: Table.api.formatter.status
},
{field: 'area.merge_name', title: __('Area_id')},
{
field: 'address',
title: __('Address'),
operate: 'LIKE',
table: table,
class: 'autocontent',
formatter: Table.api.formatter.content
},
{field: 'phone.model', title: __('Work_tel_id')},
// {field: 'worker_id', title: __('Worker_id')},
{field: 'source_shop', title: __('Source')},
// {field: 'source_uid', title: __('Source_uid'), operate: 'LIKE'},
{field: 'item_title', title: __('Item_title'), operate: 'LIKE'},
{
field: 'detail',
title: __('Detail'),
operate: 'LIKE',
table: table,
class: 'autocontent',
formatter: Table.api.formatter.content
},
{
field: 'remark',
title: __('Remark'),
operate: 'LIKE',
table: table,
class: 'autocontent',
formatter: Table.api.formatter.content
},
{
field: 'images',
title: __('Images'),
operate: false,
events: Table.api.events.image,
formatter: Table.api.formatter.images
},
{
field: 'create_time',
title: __('Create_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false
},
{
field: 'update_time',
title: __('Update_time'),
operate: 'RANGE',
addclass: 'datetimerange',
autocomplete: false
},
{
field: 'operate',
title: __('Operate'),
table: table,
events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'edit',
icon: 'fa fa-pencil',
title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-editone'
},
{
name: 'push',
icon: 'fa fa-copy',
title: '复制',
url: 'order/copy',
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-info btn-dialog',
callback: function ($data){
console.log($data);
}
},
{
name:"dispatch",
text:"派单",
title:"派单",
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-warning btn-dialog',
//classname:"btn-view btn-dialog",
icon:'fa fa-add',
url: function(row){
return 'orders/dispatch/add?order_id='+row.id;
},
visible:function(row){
if(row.status == 10){
return true;
}
return false;
},
refresh:true,
},
{
name:"income",
text:"新增收款",
title:"新增收款",
classname:"btn-view btn-dialog",
icon:'fa fa-money',
url: function(row){
return 'orders/income/add?order_id='+row.id;
},
dropdown:"更多",
visible:function(row){
return true;
},
refresh:true,
},
{
name: 'del',
text:"取消订单",
title:"取消订单",
icon: 'fa fa-trash',
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-danger btn-delone',
dropdown:"更多",
},
],
}
]
],
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
$("#c-city").on("cp:updated", function() {
var citypicker = $(this).data("citypicker");
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
$("#area_id").val(code);
});
$("#c-city").on("click", function() {
Form.api.submit($("form[role=form]"),);
return false;
});
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
},
copy: function () {
Controller.api.bindevent();
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"),function (success,ret) {
clearInfo();
Toastr.success('录入成功');
return false;
},);
}
}
};
function parseAndFill() {
// 获取左侧输入框的内容
}
return Controller;
});