<div class="layui-fluid layui-anim febs-anim" id="febs-clothes-order" lay-title="订单列表">
|
<div class="layui-row febs-container">
|
<div class="layui-col-md12">
|
<div class="layui-card">
|
<div class="layui-card-body febs-table-full">
|
<form class="layui-form layui-table-form" lay-filter="clothes-order-table-form">
|
<div class="layui-form-item">
|
<div class="layui-col-md10">
|
<div class="layui-inline">
|
<label class="layui-form-label">购买人:</label>
|
<div class="layui-input-inline">
|
<input type="text" placeholder="购买人" name="name" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">订单编号:</label>
|
<div class="layui-input-inline">
|
<input type="text" placeholder="订单编号" name="orderNo" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">订单状态:</label>
|
<div class="layui-input-inline">
|
<select name="status">
|
<option value="">请选择</option>
|
<option value="1">待支付</option>
|
<option value="2">待发货</option>
|
<option value="3">待收货</option>
|
<option value="4">已完成</option>
|
<option value="5">已取消</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">支付状态:</label>
|
<div class="layui-input-inline">
|
<select name="payResult">
|
<option value="">请选择</option>
|
<option value="1">成功</option>
|
<option value="2">未成功</option>
|
</select>
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">开始时间:</label>
|
<div class="layui-input-inline">
|
<input type="text" name="startTime" id="febs-clothes-order-date-start" lay-verify="date"
|
placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
<div class="layui-inline">
|
<label class="layui-form-label">结束时间:</label>
|
<div class="layui-input-inline">
|
<input type="text" name="endTime" id="febs-clothes-order-date-end" lay-verify="date"
|
placeholder="yyyy-MM-dd HH:mm:ss" autocomplete="off" class="layui-input">
|
</div>
|
</div>
|
</div>
|
|
<div class="layui-col-md2 layui-col-sm12 layui-col-xs12 table-action-area">
|
<div class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain table-action" id="query">
|
<i class="layui-icon"></i>
|
</div>
|
<div class="layui-btn layui-btn-sm layui-btn-primary febs-button-green-plain table-action" id="reset">
|
<i class="layui-icon"></i>
|
</div>
|
</div>
|
</div>
|
</form>
|
<table lay-filter="orderClothesTable" lay-data="{id: 'orderClothesTable'}"></table>
|
<style type="text/css">
|
.layui-table cell{
|
text-align:center;
|
height: auto;
|
white-space: nowrap; /*文本不会换行,在同一行显示*/
|
overflow: hidden; /*超出隐藏*/
|
text-overflow: ellipsis; /*省略号显示*/
|
}
|
.layui-table img{
|
max-width:100px
|
}
|
|
::-webkit-scrollbar {
|
height: 20px !important;
|
background-color: #f4f4f4;
|
}
|
</style>
|
</div>
|
</div>
|
</div>
|
</div>
|
</div>
|
<!-- 表格操作栏 start -->
|
<script type="text/html" id="user-option">
|
<span shiro:lacksPermission="user:view,user:update,user:delete">
|
<span class="layui-badge-dot febs-bg-orange"></span> 无权限
|
</span>
|
<a lay-event="edit" shiro:hasPermission="user:update"><i
|
class="layui-icon febs-edit-area febs-blue"></i></a>
|
</script>
|
<script type="text/html" id="tableToolBarClothesOrder">
|
<div class="layui-btn-container">
|
<!-- <button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="printSelect">打印预览</button>-->
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="deliverGoods">发货</button>
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="updateDeliver">修改物流信息</button>
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="refundOrder">仅退款</button>
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="confirmOrder">确认收货</button>
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" lay-event="exportDeliverTwo">导出待发货订单</button>
|
<button class="layui-btn layui-btn-sm layui-btn-primary febs-button-blue-plain" id="importDeliver" lay-event="importDeliver">导入发货</button>
|
</div>
|
</script>
|
|
<script type="text/html" id="clothesOrderOption">
|
<button class="layui-btn layui-btn-normal layui-btn-sm" type="button" shiro:hasPermission="orderPrint:view" lay-event="orderPrint">打印预览</button>
|
</script>
|
<!-- 表格操作栏 end -->
|
<script data-th-inline="none" type="text/javascript">
|
// 引入组件并初始化
|
layui.use([ 'jquery', 'form', 'table', 'febs', 'formSelects', 'upload','laydate'], function () {
|
var $ = layui.jquery,
|
febs = layui.febs,
|
form = layui.form,
|
table = layui.table,
|
upload = layui.upload,
|
$view = $('#febs-clothes-order'),
|
$query = $view.find('#query'),
|
$reset = $view.find('#reset'),
|
$searchForm = $view.find('form'),
|
sortObject = {field: 'orderTime', type: 'desc'},
|
formSelects = layui.formSelects,
|
laydate = layui.laydate,
|
tableIns;
|
|
let currPageOrder = 1;//首先默认值为1,防止出错
|
//获取当前页
|
currPageOrder = $view.find(".layui-laypage-em").next().html();
|
//日期范围
|
laydate.render({
|
elem: '#febs-clothes-order-date-start',type: 'datetime'
|
});
|
|
laydate.render({
|
elem: '#febs-clothes-order-date-end',type: 'datetime'
|
});
|
|
|
form.render();
|
|
formSelects.render();
|
|
// 表格初始化
|
initClothesOrderTable();
|
|
table.on('toolbar(orderClothesTable)', function(obj){
|
var layEvent = obj.event;
|
var id = obj.config.id;
|
var checkStatus = table.checkStatus(id);
|
if(layEvent === 'printSelect'){
|
let data = checkStatus.data;
|
if (data.length > 1) {
|
febs.alert.warn('每次只能操作一个订单');
|
return;
|
}
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
console.log(data[i].status);
|
if(data[i].status != 2){
|
febs.alert.warn('请选择待发货的订单');
|
return;
|
}else{
|
ids = data[i].id;
|
}
|
}
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择订单');
|
return;
|
}
|
printSelectData(ids)
|
}
|
|
if (layEvent === 'deliverGoods') {
|
let data = checkStatus.data;
|
if (data.length > 1) {
|
febs.alert.warn('每次只能操作一个订单');
|
return;
|
}
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
if(data[i].status != 2){
|
febs.alert.warn('请选择待发货的订单');
|
return;
|
}else{
|
ids = data[i].id;
|
}
|
}
|
console.log(ids);
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择订单');
|
return;
|
}
|
febs.modal.open('发货', 'modules/clothesType/deliverGoods/' + ids, {
|
btn: ['确认','取消'],
|
yes: function (index, layero) {
|
$('#deliver-update-clothes').find('#submit').trigger('click');
|
},
|
btn2: function () {
|
layer.closeAll();
|
}
|
});
|
}
|
|
if (layEvent === 'updateDeliver') {
|
let data = checkStatus.data;
|
if (data.length > 1) {
|
febs.alert.warn('每次只能操作一个订单');
|
return;
|
}
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
if(data[i].status != 2){
|
febs.alert.warn('请选择待收货的订单');
|
return;
|
}else{
|
ids = data[i].id;
|
}
|
}
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择订单');
|
return;
|
}
|
febs.modal.open('修改物流信息', 'modules/clothesType/deliverGoods/' + ids, {
|
btn: ['确认','取消'],
|
yes: function (index, layero) {
|
$('#deliver-update-clothes').find('#deliverInfoSubmit').trigger('click');
|
},
|
btn2: function () {
|
layer.closeAll();
|
}
|
});
|
}
|
|
if(layEvent === 'refundOrder'){
|
let data = checkStatus.data;
|
if (data.length > 1) {
|
febs.alert.warn('每次只能操作一个订单');
|
return;
|
}
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
if(data[i].status != 2 ){
|
febs.alert.warn('请选择待发货的订单');
|
return;
|
}else{
|
ids = data[i].id;
|
}
|
}
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择订单');
|
return;
|
}
|
febs.modal.confirm('仅退款', '确认退款订单?', function () {
|
refundOrder(ids);
|
});
|
}
|
|
if(layEvent === 'confirmOrder'){
|
let data = checkStatus.data;
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
if(data[i].status != 3){
|
febs.alert.warn('请选择待收货的订单');
|
return;
|
}else{
|
ids = ids + data[i].id+",";
|
}
|
}
|
console.log(ids);
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择订单');
|
return;
|
}
|
febs.get(ctx + 'admin/clothesType/confirmOrder/'+ids, null, function () {
|
febs.alert.success('操作成功');
|
$query.click();
|
});
|
}
|
|
if (layEvent == 'exportDeliverTwo') {
|
let data = checkStatus.data;
|
let ids = "";
|
for(let i = 0;i < data.length;i++){
|
if(data[i].status != 2){
|
febs.alert.warn('请选择待发货的订单');
|
return;
|
}else if(data[i].deliveryState != 1){
|
febs.alert.warn('请选择待配送的订单');
|
return;
|
}else{
|
ids = ids + data[i].id+",";
|
}
|
}
|
console.log(ids);
|
if(ids == null || ids == ""){
|
febs.alert.warn('请选择待发货的订单');
|
return;
|
}
|
window.location.href = ctx + "admin/clothesType/exportOrderList?ids="+ids;
|
}
|
|
});
|
|
|
/*
|
* [自定义打印选中行数据]
|
* @param {[type]} allData [传入选中行]
|
*/
|
function printSelectData(allData) {
|
let orderId = allData;
|
console.log(orderId);
|
$.ajax({
|
url: '/admin/clothesType/printOrder/'+orderId,
|
type: "get",
|
contentType: 'application/json',
|
success(res) {
|
console.log(res);
|
printSelect(res.data);
|
},
|
error(xhr, status, error) {
|
console.error("AJAX 请求失败:", error);
|
alert("请求失败,请重试");
|
}
|
});
|
}
|
|
function printSelect(data) {
|
//用于包含内容
|
var v = document.createElement("div");
|
//页面头部,导入css ,media="print"表示打印时使用该样式
|
var f = ["<head>", "<style>", "div{font-size:8px;}", ".main{width:100%;}",
|
".main div{width:100%;display:inline-block;}", "</style>", "</head>"
|
].join("");
|
console.log(data);
|
var template =
|
"<div class='main'>" +
|
"<div style='text-align: center;font-size: 30px;font-weight: bold;margin-bottom: 10px'>订单编号:" + data.orderNo + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>类型:" + data.typeName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>布料:" + data.clothName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>编码:" + data.clothCode + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>尺码:" + data.sizeName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>编码:" + data.sizeCode + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>工艺:" + data.artName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>编码:" + data.artCode + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>正面图案:" + data.patternName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>编码:" + data.patternCode + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>文案:" + data.patternText + "</div>" +
|
"<div class='print-images' style='font-size: 30px;font-weight: bold;'>图片:" +
|
"<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.patternImage+">" +
|
"</div>" +
|
|
"<div style='font-size: 30px;font-weight: bold;'>反面图案:" + data.locationName + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>编码:" + data.locationCode + "</div>" +
|
"<div style='font-size: 30px;font-weight: bold;'>文案:" + data.locationText + "</div>" +
|
"<div class='print-images' style='font-size: 30px;font-weight: bold;'>图片:" +
|
"<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.locationImage+">" +
|
"</div>" +
|
"<div class='print-images' style='font-size: 30px;font-weight: bold;'>正面:" +
|
"<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.typeFront+">" +
|
"</div>" +
|
"<div class='print-images' style='font-size: 30px;font-weight: bold;'>反面:" +
|
"<img style='width: 200px; height: 200px; max-width: 80%; margin-top: 5px;' src="+ data.typeBack+">" +
|
"</div>" +
|
"</div>"
|
|
v.innerHTML = template;
|
//新建窗口
|
var h = window.open("打印窗口", "_blank");
|
//写入拼凑内容
|
h.document.write(f + $(v).prop("outerHTML"));
|
h.document.close();
|
//在新窗口的 document 中查找图片
|
ensureImagesLoaded(h.document, '.print-images img')
|
.then(() => h.print())
|
.catch(() => layer.msg('部分图片加载失败'));
|
//调用打印
|
h.print();
|
//关闭页面
|
h.close();
|
}
|
|
function ensureImagesLoaded(doc, selector) {
|
var imgs = $(selector, doc); // 👈 在指定文档中查找
|
var promises = [];
|
|
imgs.each(function() {
|
var img = this;
|
var promise = new Promise(function(resolve, reject) {
|
if (img.complete && img.naturalWidth !== 0) {
|
resolve();
|
} else {
|
$(img).on('load', resolve).on('error', reject);
|
}
|
});
|
promises.push(promise);
|
});
|
|
return Promise.all(promises);
|
}
|
|
|
|
function refundOrder(id) {
|
febs.get(ctx + 'admin/clothesType/refundOrder/' + id, null, function () {
|
febs.alert.success('操作成功');
|
$query.click();
|
});
|
}
|
|
upload.render({
|
elem: '#importDeliver'
|
,url: 'admin/clothesType/importDeliver' //此处配置你自己的上传接口即可
|
,accept: 'file' //普通文件
|
,done: function(res){
|
console.log("123");
|
febs.alert.success('操作成功');
|
$query.click();
|
}
|
});
|
|
|
// 初始化表格操作栏各个按钮功能
|
table.on('tool(orderClothesTable)', function (obj) {
|
var data = obj.data,
|
layEvent = obj.event;
|
if (layEvent === 'orderPrint') {
|
febs.modal.open('订单编号:'+data.orderNo,'modules/clothesType/orderPrint/' + data.id, {
|
area: ['100%', '100%'],
|
});
|
};
|
});
|
|
|
|
// 查询按钮
|
$query.on('click', function () {
|
var params = $.extend(getQueryParams(), {field: sortObject.field, order: sortObject.type});
|
tableIns.reload({where: params, page: {curr: currPageOrder}});
|
});
|
|
// 刷新按钮
|
$reset.on('click', function () {
|
$searchForm[0].reset();
|
sortObject.type = 'null';
|
tableIns.reload({where: getQueryParams(), page: {curr: currPageOrder}, initSort: sortObject});
|
});
|
|
function initClothesOrderTable() {
|
tableIns = febs.table.init({
|
elem: $view.find('table'),
|
id: 'orderClothesTable',
|
url: ctx + 'admin/clothesType/orderList',
|
// defaultToolbar: [],
|
//系统自带打印导出
|
totalRow : true,
|
toolbar: '#tableToolBarClothesOrder',
|
cols: [[
|
{type: 'checkbox', fixed: 'left'},
|
{type: 'numbers', title: '', width: 80},
|
{title: '操作', toolbar: '#clothesOrderOption', minWidth: 200, align: 'center'},
|
// {title: '操作',
|
// templet: function (d) {
|
// return '<button class="layui-btn layui-btn-normal layui-btn-xs" lay-event="seeOrder">详情</button>'
|
// },minWidth: 200,align:'center'},
|
{field: 'orderNo', title: '订单编号', minWidth: 200,align:'left' ,totalRowText:"合计"},
|
{field: 'memberName', title: '购买人', minWidth: 100,align:'left'},
|
{field: 'typeName', title: '类型', minWidth: 100,align:'left'},
|
// {field: 'goodsName', title: '商品', minWidth: 160,align:'left'},
|
// {field: 'typeImage', title: '图片', minWidth: 100,align:'left'},
|
{field: 'goodsCnt', title: '数量', minWidth: 120,align:'left'},
|
{field: 'status', title: '状态',
|
templet: function (d) {
|
if (d.status === 1) {
|
return '<span style="color:red;">待支付</span>'
|
} else if (d.status === 2) {
|
return '<span style="color:green;">待发货</span>'
|
}else if (d.status === 3) {
|
return '<span style="color:green;">待收货</span>'
|
}else if (d.status === 4) {
|
return '<span style="color:green;">已完成</span>'
|
}else if (d.status === 5) {
|
return '<span style="color:green;">已取消</span>'
|
}else{
|
return ''
|
}
|
}, minWidth: 80,align:'center'},
|
{field: 'amount', title: '总价', minWidth: 80,align:'left', totalRow:true},
|
{field: 'discountAmount', title: '优惠', minWidth: 80,align:'left', totalRow:true},
|
{field: 'carriage', title: '邮费', minWidth: 80,align:'left', totalRow:true},
|
{field: 'realAmount', title: '总金额', minWidth: 100,align:'left', totalRow:true},
|
{field: 'orderTime', title: '下单时间', minWidth: 200,align:'left'},
|
|
{field: 'payMethod', title: '支付方式', minWidth: 100,align:'left'},
|
{field: 'payTime', title: '支付时间', minWidth: 120,align:'left'},
|
{field: 'remark', title: '备注', minWidth: 160,align:'left'},
|
]]
|
});
|
}
|
|
// 获取查询参数
|
function getQueryParams() {
|
let startTimestr = $searchForm.find('input[name="startTime"]').val().trim();
|
let endTimeStr = $searchForm.find('input[name="endTime"]').val().trim();
|
if(startTimestr != '' && endTimeStr != '' && startTimestr >= endTimeStr){
|
febs.alert.warn('开始时间需要小于结束时间');
|
return{};
|
}
|
return {
|
startTime: $searchForm.find('input[name="startTime"]').val().trim(),
|
endTime: $searchForm.find('input[name="endTime"]').val().trim(),
|
name: $searchForm.find('input[name="name"]').val().trim(),
|
orderNo: $searchForm.find('input[name="orderNo"]').val().trim(),
|
payResult: $searchForm.find("select[name='payResult']").val(),
|
status: $searchForm.find("select[name='status']").val(),
|
};
|
}
|
|
})
|
</script>
|