280 lines
12 KiB
JavaScript
280 lines
12 KiB
JavaScript
define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'template', 'addtabs', 'moment','citypicker','cascader'], function
|
|
($, undefined, Backend, Table, Form,Template,undefined, Moment) {
|
|
|
|
var Controller = {
|
|
|
|
index: function () {
|
|
|
|
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
|
|
var $targetPanel = $($(this).attr("href"));
|
|
var tabVal = $(this).data('val');
|
|
if (tabVal === 'first') {
|
|
Controller.api.first();
|
|
}else if (tabVal === 'second') {
|
|
console.log(3333);
|
|
Controller.api.second();
|
|
}else if (tabVal === 'third'){
|
|
Controller.api.third();
|
|
}else if (tabVal === 'fourth'){
|
|
Controller.api.fourth();
|
|
}
|
|
});
|
|
Controller.api.first();
|
|
Controller.api.datepicker();
|
|
},
|
|
|
|
api: {
|
|
bindevent: function () {
|
|
Form.api.bindevent($("form[role=form]"));
|
|
},
|
|
first: function (){
|
|
Table.api.init();
|
|
// 表格2
|
|
var table = $("#table1");
|
|
table.bootstrapTable({
|
|
url: 'statistics/aftersale/dispatch',
|
|
sortName: 'id',
|
|
search: false,
|
|
commonSearch: false,
|
|
visible: false,
|
|
showToggle: false,
|
|
showColumns: false,
|
|
showExport: true,
|
|
searchFormVisible: true,
|
|
columns: [
|
|
[
|
|
{field: 'nickname', title: '名称', operate: false},
|
|
{field: 'mobile', title: '电话', operate: false},
|
|
{field: 'order_total', title: '订单总数', operate: false},
|
|
{field: 'after_total', title: '退款订单数', operate: false},
|
|
{field: 'rate', title: '退款率', operate: false},
|
|
]
|
|
]
|
|
});
|
|
// 为表格2绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
$('#first-search').on('click', function () {
|
|
|
|
const range = $('#daterange-table').val();
|
|
const keyword = $('#keyword').val();
|
|
let data = '';
|
|
if (range !== ''){
|
|
data += 'range=' + range;
|
|
}
|
|
if (keyword !== ''){
|
|
data += '&keyword=' + keyword;
|
|
}
|
|
// data = encodeURIComponent(data);
|
|
$("#table1").bootstrapTable('refresh',{
|
|
url:'statistics/aftersale/dispatch?' + data,
|
|
});
|
|
});
|
|
|
|
},
|
|
|
|
second: function (){
|
|
Table.api.init();
|
|
// 表格2
|
|
var table = $("#table2");
|
|
table.bootstrapTable({
|
|
url: 'statistics/aftersale/city',
|
|
sortName: 'id',
|
|
search: false,
|
|
commonSearch: false,
|
|
visible: false,
|
|
showToggle: false,
|
|
showColumns: false,
|
|
showExport: true,
|
|
searchFormVisible: true,
|
|
columns: [
|
|
[
|
|
{field: 'area.merge_name', title: '城市', operate: false},
|
|
{field: 'order_total', title: '订单总数', operate: false},
|
|
{field: 'after_total', title: '退款订单数', operate: false},
|
|
{field: 'rate', title: '退款率', operate: false},
|
|
|
|
]
|
|
]
|
|
});
|
|
// 为表格2绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
$('#first-search2').on('click', function () {
|
|
|
|
const range = $('#daterange-table2').val();
|
|
const area_id = $('#area_id').val();
|
|
let data = '';
|
|
if (range !== ''){
|
|
data += 'range=' + range;
|
|
}
|
|
if (area_id !== ''){
|
|
data += 'area_id=' + area_id;
|
|
}
|
|
// data = encodeURIComponent(data);
|
|
$("#table2").bootstrapTable('refresh',{
|
|
url:'statistics/aftersale/city?' + data,
|
|
});
|
|
});
|
|
|
|
Controller.api.areapicker();
|
|
|
|
},
|
|
|
|
third: function (){
|
|
Table.api.init();
|
|
// 表格2
|
|
var table = $("#table3");
|
|
table.bootstrapTable({
|
|
url: 'statistics/aftersale/item',
|
|
sortName: 'id',
|
|
search: false,
|
|
commonSearch: false,
|
|
visible: false,
|
|
showToggle: false,
|
|
showColumns: false,
|
|
showExport: true,
|
|
searchFormVisible: true,
|
|
columns: [
|
|
[
|
|
{field: 'item_title', title: '服务项目', operate: false},
|
|
{field: 'order_total', title: '订单总数', operate: false},
|
|
{field: 'after_total', title: '退款订单数', operate: false},
|
|
{field: 'rate', title: '退款率', operate: false},
|
|
]
|
|
]
|
|
});
|
|
// 为表格2绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
$('#first-search3').on('click', function () {
|
|
|
|
const range = $('#daterange-table3').val();
|
|
const item_id = $('#item_id_value').val();
|
|
let data = '';
|
|
if (range !== ''){
|
|
data += 'range=' + range;
|
|
}
|
|
if (item_id !== ''){
|
|
data += 'item_id=' + item_id;
|
|
}
|
|
// data = encodeURIComponent(data);
|
|
$("#table3").bootstrapTable('refresh',{
|
|
url:'statistics/aftersale/item?' + data,
|
|
});
|
|
});
|
|
Controller.api.itemspicker();
|
|
},
|
|
|
|
fourth: function (){
|
|
Table.api.init();
|
|
// 表格2
|
|
var table = $("#table4");
|
|
table.bootstrapTable({
|
|
url: 'statistics/aftersale/worker',
|
|
sortName: 'id',
|
|
search: false,
|
|
commonSearch: false,
|
|
visible: false,
|
|
showToggle: false,
|
|
showColumns: false,
|
|
showExport: true,
|
|
searchFormVisible: true,
|
|
columns: [
|
|
[
|
|
{field: 'name', title: '名称', operate: false},
|
|
{field: 'tel', title: '电话', operate: false},
|
|
{field: 'order_total', title: '订单总数', operate: false},
|
|
{field: 'after_total', title: '退款订单数', operate: false},
|
|
{field: 'rate', title: '退款率', operate: false},
|
|
]
|
|
]
|
|
});
|
|
// 为表格2绑定事件
|
|
Table.api.bindevent(table);
|
|
|
|
$('#first-search4').on('click', function () {
|
|
|
|
const range = $('#daterange-table4').val();
|
|
const keyword = $('#keyword4').val();
|
|
let data = '';
|
|
if (range !== ''){
|
|
data += 'range=' + range;
|
|
}
|
|
if (keyword !== ''){
|
|
data += '&keyword=' + keyword;
|
|
}
|
|
// data = encodeURIComponent(data);
|
|
$("#table4").bootstrapTable('refresh',{
|
|
url:'statistics/aftersale/worker?' + data,
|
|
});
|
|
});
|
|
|
|
},
|
|
|
|
datepicker: function () {
|
|
var ranges = {};
|
|
ranges[__('Today')] = [Moment().startOf('day'), Moment().endOf('day')];
|
|
ranges[__('Yesterday')] = [Moment().subtract(1, 'days').startOf('day'), Moment().subtract(1, 'days').endOf('day')];
|
|
ranges[__('Last 7 Days')] = [Moment().subtract(6, 'days').startOf('day'), Moment().endOf('day')];
|
|
ranges[__('Last 30 Days')] = [Moment().subtract(29, 'days').startOf('day'), Moment().endOf('day')];
|
|
ranges[__('This Month')] = [Moment().startOf('month'), Moment().endOf('month')];
|
|
ranges[__('Last Month')] = [Moment().subtract(1, 'month').startOf('month'), Moment().subtract(1, 'month').endOf('month')];
|
|
ranges[__('今年')] = [Moment().startOf('year'), Moment().endOf('year')];
|
|
var options = {
|
|
timePicker: false,
|
|
autoUpdateInput: false,
|
|
timePickerSeconds: true,
|
|
timePicker24Hour: true,
|
|
autoApply: true,
|
|
locale: {
|
|
format: 'YYYY-MM-DD',
|
|
customRangeLabel: __("Custom Range"),
|
|
applyLabel: __("Apply"),
|
|
cancelLabel: __("Clear"),
|
|
},
|
|
ranges: ranges,
|
|
};
|
|
var callback = function (start, end) {
|
|
$(this.element).val(start.format(options.locale.format) + " - " + end.format(options.locale.format));
|
|
};
|
|
require(['bootstrap-daterangepicker'], function () {
|
|
$(".datetimerange").each(function () {
|
|
$(this).on('apply.daterangepicker', function (ev, picker) {
|
|
callback.call(picker, picker.startDate, picker.endDate);
|
|
var label = picker.chosenLabel;
|
|
$(picker.element).data('label', label).trigger("change");
|
|
});
|
|
$(this).on('cancel.daterangepicker', function (ev, picker) {
|
|
$(this).val('');
|
|
});
|
|
$(this).daterangepicker($.extend({}, options), callback);
|
|
});
|
|
});
|
|
},
|
|
|
|
areapicker: function () {
|
|
$("#city-search").citypicker();
|
|
|
|
$("#city-search").on("cp:updated", function() {
|
|
var citypicker = $(this).data("citypicker");
|
|
var code = citypicker.getCode("district") || citypicker.getCode("city") || citypicker.getCode("province");
|
|
// table.bootstrapTable('refresh',{query: {area_code: code}});
|
|
$('#area_id').val(code);
|
|
});
|
|
},
|
|
itemspicker: function () {
|
|
var _data = items;
|
|
$('#item_id').zdCascader({
|
|
data: _data,
|
|
onChange: function ($this, data, allPathData) {
|
|
// console.log(data,allPathData);
|
|
$('#item_id_value').val(data.value);
|
|
}
|
|
});
|
|
},
|
|
}
|
|
};
|
|
return Controller;
|
|
});
|