allocatr/public/assets/js/backend/orders/auditorder.js
2025-08-15 15:00:23 +08:00

239 lines
12 KiB
JavaScript
Executable File
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
var Controller = {
index: function () {
// 初始化表格参数配置
Table.api.init({
extend: {
index_url: 'orders/auditorder/index' + location.search,
add_url: 'orders/auditorder/add',
edit_url: 'orders/auditorder/edit',
// del_url: 'orders/auditorder/del',
//multi_url: 'orders/auditorder/multi',
import_url: 'orders/auditorder/import',
table: 'order',
}
});
var table = $("#table");
// 初始化表格
table.bootstrapTable({
queryParams: function (params) {
var filter = params.filter ? JSON.parse(params.filter) : {};
var op = params.op ? JSON.parse(params.op) : {};
// 如果没有 status 参数,则默认使用 50
if (!('status' in filter)) {
filter.status = '50';
op.status = '=';
}
params.filter = JSON.stringify(filter);
params.op = JSON.stringify(op);
return params;
},
onLoadSuccess: function (data) {
var sum = data || {};
// 1) 把汇总放到表格上方(可改为 append 到其它元素)
$('#table-sum-area').remove(); // 先移除已有的,防止重复
var html = '<div id="table-sum-area" style="margin:8px 0;text-align:right;">' +
'筛选条件总计 — 总预计利润:<strong>' + (parseFloat(data.sum || 0).toFixed(2)) + '</strong>' +
',总数量:<strong>' + (parseInt(data.total || 0)) + '</strong>' +
'</div>';
// 把汇总放在表格容器前面(你也可以放到 table.closest('.bootstrap-table') 里)
table.closest('.bootstrap-table').before(html);
// 2) (可选)如果你想把汇总放到表格 footer 的某一列,用 footerFormatter 示例:
// 注意footerFormatter 会在表格渲染 footer 时调用,这里只是演示
// 例如你有一列 field: 'real_amount',它的 footerFormatter 可以是:
// footerFormatter: function () { var s = table.data('sum') || {}; return (parseFloat(s.real_amount||0)).toFixed(2); }
},
url: $.fn.bootstrapTable.defaults.extend.index_url,
pk: 'id',
sortName: 'update_time',
sortOrder: 'desc',
fixedColumns: true,
fixedRightNumber: 1,
showExport: false,
columns: [
[
// {checkbox: true},
{field: 'id', title: __('Id'),operate: false},
{
field: 'status',
title: __('Status'),
searchList: {"50":__('Status 50'),"60":__('Status 60')},
formatter: Table.api.formatter.label,
custom: {
'50': 'warning', // 待跟进:灰蓝色(默认 Bootstrap info
'60': 'success', // 已跟进:绿色
}
},
{field: 'order_no', title: __('Order_no'), operate: '='},
{field: 'customer', title: __('Customer'), operate: false},
{field: 'tel', title: __('Tel'), operate: '='},
//{field: 'area_id', title: __('Area_id')},
//{field: 'address', title: __('Address'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'lng', title: __('Lng'), operate:'BETWEEN'},
// {field: 'lat', title: __('Lat'), operate:'BETWEEN'},
//{field: 'work_tel_id', title: __('Work_tel_id')},
{field: 'source_total_name', title: __('Source_shop'), operate: false},
{
field: 'source', title: '订单渠道', searchList: function (column) {
return Template('source', {});
}, formatter: function (value, row, index) {
return '无';
}, visible: false
},
// {field: 'source', title: __('Source'), operate: 'like'},
// {field: 'source_uid', title: __('Source_uid'), operate: '='},
// {field: 'item_id', title: __('Item_id')},
{field: 'item_title', title: __('Item_title'), operate: false},
{field: 'detail', title: __('Detail'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'remark', title: __('Remark'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'plan_time', title: __('Plan_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'user.nickname', title: '录单员', operate: false},
{field: 'dispatch_admin_user', title: '派单员', operate: false},
{field: 'online_amount', title: __('Online_amount'), operate:false},
{field: 'online_amount_last', title: __('Online_amount_last'), operate:false},
{field: 'offline_amount', title: __('Offline_amount'), operate:false},
{field: 'offline_amount_type_text', title: __('Offline_amount_type'), operate:false},
{field: 'amount_images', title: __('收款凭据'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'total', title: __('Total'), operate:'BETWEEN'},
{field: 'discount_amount', title: __('Discount_amount'), operate:false},
{field: 'real_amount', title: __('Real_amount'), operate:false},
{field: 'refund_amount', title: __('Refund_amount'), operate:false},
{field: 'cost', title: __('Cost'), operate:false},
{field: 'material_cost', title: __('材料成本'), operate:false},
{field: 'performance', title: __('Performance'), operate:false},
{field: 'workerman.images', title: __('师傅收款码'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
{field: 'trans_images', title: __('转账凭证'), operate: false, events: Table.api.events.image, formatter: Table.api.formatter.images},
// {field: 'cancel_reason_id', title: __('Cancel_reason_id')},
//{field: 'cancel_detail', title: __('Cancel_detail'), operate: 'LIKE', table: table, class: 'autocontent', formatter: Table.api.formatter.content},
// {field: 'audit_admin_id', title: __('Audit_admin_id')},
{field: 'create_time', title: __('Create_time'), operate:'RANGE', addclass:'datetimerange', autocomplete:false},
{field: 'update_time', title: __('Update_time'), operate:false, addclass:'datetimerange', autocomplete:false,sortable: true},
{field: 'audit_time', title: '完成时间', operate:'RANGE', addclass:'datetimerange', autocomplete:false},
//{field: 'auditadmin.username', title: __('Admin.username'), operate: 'LIKE'},
{field: 'auditadmin.nickname', title: __('Admin.nickname'), operate: '='},
{field: 'audit_remark', title: __('Audit_remark'), operate: false, table: table, class: 'autocontent', formatter: Table.api.formatter.content},
{field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate,
formatter: Table.api.formatter.operate,
buttons: [
{
name: 'edit',
text:"审核",
title:"审核",
icon: 'fa fa-pencil',
//title: __('Edit'),
extend: 'data-toggle="tooltip" data-container="body"',
classname: 'btn btn-xs btn-success btn-editone',
visible:function(row){
if(row.status == 50){
return true;
}
return false;
}
}
],
}
]
]
});
table.closest('.bootstrap-table').addClass('table-with-fixed-pagination');
$('#btn-export').on('click', function () {
var options = $("#table").bootstrapTable('getOptions');
// 提取列信息(不含 checkbox
var columns = [];
$.each(options.columns[0], function (i, item) {
if (item.field && !item.checkbox && !item.visible === false) {
columns.push({
field: item.field,
title: item.title
});
}
});
var params = {
columns: JSON.stringify(columns),
filter: options.queryParams({}).filter || {},
op: options.queryParams({}).op || {},
sort: options.sortName,
order: options.sortOrder
};
// console.log($.param(params))
var url = '/admin/orders/auditorder/export?' + $.param(params);
window.open(url); // 发起文件下载
});
// 为表格绑定事件
Table.api.bindevent(table);
},
add: function () {
Controller.api.bindevent();
},
edit: function () {
Controller.api.bindevent();
// 图片点击放大预览
var $overlay = $('#image-preview-overlay');
var $previewImg = $('#image-preview-img');
/*$('body').on('click', 'img[data-preview="true"]', function () {
var src = $(this).attr('src');
if (src) {
$previewImg.attr('src', src);
$overlay.fadeIn(100).css('display', 'flex');
}
});
$overlay.on('click', function () {
$previewImg.attr('src', '');
$overlay.fadeOut(100);
});*/
// edit页面全局图片点击放大预览
$(function () {
var $overlay = $('#image-preview-overlay');
var $previewImg = $('#image-preview-img');
// ✅ 所有 img 点击放大(包括上传区图片)
$('body').on('click', 'img', function (e) {
const src = $(this).attr('src');
if (src && src.trim() !== '') {
// ✅ 如果被 a 包裹,阻止跳转
if ($(this).parent('a').length) {
e.preventDefault();
}
$previewImg.attr('src', src);
$overlay.fadeIn(100).css('display', 'flex');
}
});
// ✅ 点击遮罩关闭
$overlay.on('click', function () {
$previewImg.attr('src', '');
$overlay.fadeOut(100);
});
});
},
api: {
bindevent: function () {
Form.api.bindevent($("form[role=form]"));
}
}
};
return Controller;
});