/**
|
* 初始化代检车订单管理详情对话框
|
*/
|
var TOrderCheckInfoDlg = {
|
tOrderCheckInfoData : {}
|
};
|
|
/**
|
* 清除数据
|
*/
|
TOrderCheckInfoDlg.clearData = function() {
|
this.tOrderCheckInfoData = {};
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TOrderCheckInfoDlg.set = function(key, val) {
|
this.tOrderCheckInfoData[key] = (typeof val == "undefined") ? $("#" + key).val() : val;
|
return this;
|
}
|
|
/**
|
* 设置对话框中的数据
|
*
|
* @param key 数据的名称
|
* @param val 数据的具体值
|
*/
|
TOrderCheckInfoDlg.get = function(key) {
|
return $("#" + key).val();
|
}
|
|
/**
|
* 关闭此对话框
|
*/
|
TOrderCheckInfoDlg.close = function() {
|
parent.layer.close(window.parent.TOrderCheck.layerIndex);
|
}
|
|
/**
|
* 收集数据
|
*/
|
TOrderCheckInfoDlg.collectData = function() {
|
this
|
.set('id')
|
.set('code')
|
.set('checkCode')
|
.set('userId')
|
.set('driverId')
|
.set('branchOfficeId')
|
.set('orderTakingTime')
|
.set('arrivalTimeAtTheAppointmentPoint')
|
.set('startTime')
|
.set('endTime')
|
.set('goTime')
|
.set('successTime')
|
.set('startAddress')
|
.set('startLat')
|
.set('startLng')
|
.set('endAddress')
|
.set('endLat')
|
.set('endLng')
|
.set('orderMoney')
|
.set('payMoney')
|
.set('checkMoney')
|
.set('discountedPriceCheck')
|
.set('discountedPrice')
|
.set('couponIdCheck')
|
.set('couponId')
|
.set('payType')
|
.set('payTime')
|
.set('checkPayTime')
|
.set('orderNo')
|
.set('checkOrderNo')
|
.set('state')
|
.set('status')
|
.set('createTime')
|
.set('checkStatus')
|
.set('checkIntro')
|
.set('checkImg')
|
.set('commentRate')
|
.set('commentStr')
|
.set('commentTime')
|
.set('reservationTime')
|
.set('provinceCode')
|
.set('cityCode')
|
.set('arerCode')
|
.set('reInspection')
|
.set('source');
|
}
|
/**
|
* 验证数据是否为空
|
*/
|
TOrderCheckInfoDlg.validate = function () {
|
var startAddress = this.tOrderCheckInfoData.startAddress;
|
if (startAddress == null || startAddress.trim() === "") {
|
Feng.error("请输入取车位置!");
|
return false;
|
}
|
|
var endAddress = this.tOrderCheckInfoData.endAddress;
|
if (endAddress == null || endAddress.trim() === "") {
|
Feng.error("请输入还车地址!");
|
return false;
|
}
|
|
var reservationTime = this.tOrderCheckInfoData.reservationTime;
|
if (reservationTime == null || reservationTime.trim() === "") {
|
Feng.error("请选择预约时间!");
|
return false;
|
}
|
|
return true;
|
};
|
/**
|
* 提交添加
|
*/
|
TOrderCheckInfoDlg.addSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
// 验证表单数据
|
if (!this.validate()) {
|
return;
|
}
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tOrderCheck/add", function(data){
|
if (data.code == 200) {
|
Feng.success("新建订单成功!");
|
window.parent.TOrderCheck.table.refresh();
|
TOrderCheckInfoDlg.close();
|
} else {
|
Feng.error("新建订单失败!" + data.message + "!");
|
}
|
|
},function(data){
|
Feng.error("添加失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tOrderCheckInfoData);
|
ajax.start();
|
}
|
|
/**
|
* 提交修改
|
*/
|
TOrderCheckInfoDlg.editSubmit = function() {
|
|
this.clearData();
|
this.collectData();
|
|
//提交信息
|
var ajax = new $ax(Feng.ctxPath + "/tOrderCheck/update", function(data){
|
Feng.success("修改成功!");
|
window.parent.TOrderCheck.table.refresh();
|
TOrderCheckInfoDlg.close();
|
},function(data){
|
Feng.error("修改失败!" + data.responseJSON.message + "!");
|
});
|
ajax.set(this.tOrderCheckInfoData);
|
ajax.start();
|
}
|
|
$(function() {
|
|
});
|
|
/**
|
* 订单详情页面管理
|
*/
|
var OrderDetail = {
|
id: "OrderDetail",
|
layerIndex: -1,
|
dispatchLayerIndex: null // 新增:用于存储派单弹窗的索引
|
};
|
|
/**
|
* 初始化时间线(如果在详情页面)
|
*/
|
OrderDetail.initTimeline = function() {
|
if (!window.orderData || window.orderData === '' || $('#orderTimeline').length === 0) {
|
console.error('订单数据未找到或时间线容器不存在');
|
return;
|
}
|
|
try {
|
var orderDataObj = JSON.parse(window.orderData);
|
var timelineHtml = OrderDetail.generateTimeline(orderDataObj.state, orderDataObj);
|
$('#orderTimeline').html(timelineHtml);
|
} catch (e) {
|
console.error('解析订单JSON数据失败:', e);
|
}
|
};
|
|
/**
|
* 生成时间线HTML
|
*/
|
OrderDetail.generateTimeline = function(currentState, orderData) {
|
// 订单状态为已取消时,不展示时间线
|
if (currentState === 111) {
|
return '<div style="text-align: center; color: #f56c6c; font-size: 16px; padding: 20px;">订单已取消</div>';
|
}
|
|
var timelineSteps = [
|
{code: 100, title: '等待平台派单', desc: '订单已创建,等待系统派单'},
|
{code: 101, title: '等待司机接单', desc: '已派单给司机,等待司机确认'},
|
{code: 102, title: '司机已接单', desc: '司机已接单,正在前往取车地点'},
|
{code: 104, title: '司机到达取车地', desc: '司机已到达,等待开始车检服务'},
|
{code: 105, title: '司机开始车检服务', desc: '车检服务进行中,预计等待3-5小时'},
|
{code: 106, title: '车检完成', desc: '车辆检测已完成'},
|
{code: 107, title: '司机前往还车地', desc: '司机正在前往还车地点'},
|
{code: 108, title: '用户支付服务费', desc: '服务完成,等待用户支付服务费'},
|
{code: 109, title: '服务完成', desc: '用户已支付,服务完成'},
|
{code: 110, title: '用户评价', desc: '用户对本次服务进行评价'}
|
];
|
|
var html = '';
|
|
for (var i = 0; i < timelineSteps.length; i++) {
|
var step = timelineSteps[i];
|
var stepClass = OrderDetail.getStepClass(step.code, currentState);
|
var stepDetail = OrderDetail.getStepDetail(step.code, orderData);
|
|
var title = step.title;
|
// 当订单已非待派单状态,将第一个节点标题改为“平台已派单”
|
if (step.code === 100 && currentState !== 100) {
|
title = '平台已派单';
|
}
|
if (step.code === 101 && currentState !== 101) {
|
continue;
|
}
|
html += '<div class="timeline-step ' + stepClass + '">';
|
html += ' <div class="timeline-node"></div>';
|
html += ' <div class="timeline-content">';
|
html += ' <div class="timeline-title">' + title + '</div>';
|
// html += ' <div class="timeline-detail">' + step.desc + '</div>';
|
|
// 添加详细信息
|
if (stepDetail) {
|
html += stepDetail;
|
}
|
|
html += ' </div>';
|
html += '</div>';
|
}
|
|
return html;
|
};
|
|
/**
|
* 获取步骤样式类
|
*/
|
OrderDetail.getStepClass = function(stepCode, currentState) {
|
// 特殊处理待派单状态,确保第一个节点激活
|
if (currentState === 100 && stepCode === 100) {
|
return 'active';
|
}
|
|
if (currentState > stepCode) {
|
return 'completed';
|
} else if (currentState === stepCode) {
|
return 'active';
|
} else {
|
return 'disabled';
|
}
|
};
|
|
/**
|
* 获取步骤详细信息
|
*/
|
OrderDetail.getStepDetail = function (stepCode, orderData) {
|
var html = '';
|
|
switch (stepCode) {
|
case 100: // 等待平台派单
|
if (orderData.state >= 101) {
|
if (orderData.dispatchTimeFormat) {
|
html += '<div class="timeline-detail"><strong>派单时间:</strong>' + orderData.dispatchTimeFormat + '</div>';
|
}
|
if (orderData.driverName) {
|
html += '<div class="timeline-detail"><strong>司机:</strong>' + orderData.driverName + ' ' + orderData.driverPhone + '</div>';
|
}
|
if (orderData.operatorName) {
|
html += '<div class="timeline-detail"><strong>操作人:</strong>' + orderData.operatorName + '</div>';
|
}
|
}
|
break;
|
|
case 101: // 等待司机接单
|
// 详情已移至 case 100
|
break;
|
|
case 102: // 司机已接单
|
if (orderData.state >= 102) {
|
if (orderData.orderTakingTimeFormat) {
|
html += '<div class="timeline-detail"><strong>接单时间:</strong>' + orderData.orderTakingTimeFormat + '</div>';
|
}
|
if (orderData.driverName) {
|
html += '<div class="timeline-detail"><strong>司机:</strong>' + orderData.driverName + ' ' + orderData.driverPhone + '</div>';
|
}
|
}
|
break;
|
|
case 104: // 司机到达取车地
|
if (orderData.state >= 104) {
|
if (orderData.arrivalTimeAtTheAppointmentPointFormat) {
|
html += '<div class="timeline-detail"><strong>到达时间:</strong>' + orderData.arrivalTimeAtTheAppointmentPointFormat + '</div>';
|
}
|
// 如果是当前状态,则提示等待支付
|
if (orderData.state === 104) {
|
html += '<div class="timeline-detail" style="color: #f8ac59;"><strong>等待用户支付车检费</strong></div>';
|
}
|
if (orderData.state >= 105 && orderData.checkMoney) {
|
html += '<div class="timeline-detail"><strong>用户已支付车检费:</strong>¥' + orderData.checkMoney + '</div>';
|
if (orderData.checkPayTimeFormat) {
|
html += '<div class="timeline-detail"><strong>支付时间:</strong>' + orderData.checkPayTimeFormat + '</div>';
|
}
|
}
|
}
|
break;
|
|
case 105: // 司机开始车检服务
|
if (orderData.state >= 105) {
|
html += '<div class="timeline-detail"><strong>预计等待3-5小时</strong></div>';
|
}
|
break;
|
|
case 106: // 车检完成
|
if (orderData.state >= 106) {
|
if (orderData.endTimeFormat) {
|
html += '<div class="timeline-detail"><strong>完成时间:</strong>' + orderData.endTimeFormat + '</div>';
|
}
|
if (orderData.checkResult) {
|
html += '<div class="timeline-detail"><strong>车检结果:</strong>' + orderData.checkResult + '</div>';
|
}
|
if (orderData.checkIntro) {
|
html += '<div class="timeline-detail"><strong>详细说明:</strong>' + orderData.checkIntro + '</div>';
|
}
|
if (orderData.checkImgList && orderData.checkImgList.length > 0) {
|
html += '<div class="timeline-detail"><strong>凭证图片:</strong></div>';
|
orderData.checkImgList.forEach(function (img) {
|
html += '<img src="' + img + '" style="max-width: 100px; max-height: 100px; margin: 5px; border: 1px solid #ddd; cursor: pointer;" onclick="OrderDetail.viewImage(this.src)">';
|
});
|
}
|
}
|
break;
|
|
case 107: // 司机前往还车地
|
if (orderData.state >= 107) {
|
if (orderData.goTimeFormat) {
|
html += '<div class="timeline-detail"><strong>出发时间:</strong>' + orderData.goTimeFormat + '</div>';
|
}
|
if (orderData.endAddress) {
|
html += '<div class="timeline-detail"><strong>还车地址:</strong>' + orderData.endAddress + '</div>';
|
}
|
}
|
break;
|
|
case 108: // 用户支付服务费
|
|
if (orderData.successTimeFormat) {
|
html += '<div class="timeline-detail"><strong>还车时间:</strong>' + orderData.successTimeFormat + '</div>';
|
}
|
if (orderData.state == 108) {
|
html += '<div class="timeline-detail"><strong>等待用户支付服务费</strong></div>';
|
}
|
break;
|
|
case 109: // 服务完成
|
if (orderData.state >= 109) {
|
if (orderData.state >= 108) {
|
if (orderData.payTimeFormat) {
|
html += '<div class="timeline-detail"><strong>服务费支付时间:</strong>' + orderData.payTimeFormat + '</div>';
|
}
|
if (orderData.payMoney) {
|
html += '<div class="timeline-detail"><strong>服务费:¥:</strong>' + orderData.payMoney + '</div>';
|
}
|
if (orderData.discountedPrice) {
|
html += '<div class="timeline-detail"><strong>优惠券:¥</strong>' + orderData.discountedPrice + '</div>';
|
}
|
if (orderData.payMoney && orderData.discountedPrice) {
|
html += '<div class="timeline-detail"><strong>实付:¥</strong>' + (orderData.payMoney - orderData.discountedPrice) + '</div>';
|
}
|
if (orderData.payType) {
|
html += '<div class="timeline-detail"><strong>支付方式:</strong>' + (orderData.payType == 1 ? '微信' : '支付宝') + '</div>';
|
}
|
}
|
}
|
break;
|
|
case 110: // 用户评价
|
if (orderData.state >= 110) {
|
if (orderData.commentTimeFormat) {
|
html += '<div><strong>评价时间:</strong>' + orderData.commentTimeFormat + '</div>';
|
}
|
if (orderData.commentContent) {
|
html += '<div><strong>评价内容:</strong>' + orderData.commentContent + '</div>';
|
}
|
if (orderData.commentRate) {
|
var stars = '';
|
for (var i = 1; i <= 5; i++) {
|
stars += i <= orderData.commentRate ? '⭐' : '☆';
|
}
|
html += '<div class="timeline-detail"><strong>评价:</strong>' + stars + '</div>';
|
}
|
if (orderData.commentImgList && orderData.commentImgList.length > 0) {
|
html += '<div><strong>评价图片:</strong></div>';
|
orderData.commentImgList.forEach(function (img) {
|
html += '<img src="' + img + '" style="max-width: 100px; max-height: 100px; margin: 5px; border: 1px solid #ddd; cursor: pointer;" onclick="OrderDetail.viewImage(this.src)">';
|
});
|
}
|
}
|
break;
|
}
|
|
return html;
|
};
|
|
/**
|
* 打开派单页面
|
*/
|
OrderDetail.openDispatch = function(orderId, type) {
|
var title = type === 1 ? '派单' : '改派';
|
var url = Feng.ctxPath + '/tOrderCheck/tOrderCheck_dispatch/' + orderId + '/' + type;
|
|
var me = this;
|
this.dispatchLayerIndex = layer.open({
|
type: 2,
|
title: title,
|
area: ['90%', '90%'],
|
fix: false,
|
maxmin: true,
|
content: url,
|
success: function(layero, index) {
|
var iframeWin = window[layero.find('iframe')[0]['name']];
|
// 定义回调函数,供子页面调用
|
iframeWin.onDispatchSuccess = function() {
|
layer.close(me.dispatchLayerIndex); // 关闭派单弹窗
|
window.location.reload(); // 刷新详情页
|
};
|
}
|
});
|
};
|
|
/**
|
* 查看大图
|
*/
|
OrderDetail.viewImage = function(src) {
|
layer.open({
|
type: 1,
|
title: false,
|
closeBtn: 1,
|
skin: 'layui-layer-nobg', //无背景
|
shadeClose: true,
|
content: '<img src="' + src + '" style="max-width: 100%; max-height: 100%; display: block; margin: auto;">',
|
area: ['90%', '90%']
|
});
|
};
|
|
/**
|
* 关闭详情页面
|
*/
|
OrderDetail.closeDetail = function() {
|
var index = parent.layer.getFrameIndex(window.name);
|
parent.layer.close(index);
|
};
|
|
// 页面加载完成后初始化时间线
|
$(document).ready(function() {
|
if (typeof OrderDetail !== 'undefined' && window.orderData) {
|
OrderDetail.initTimeline();
|
}
|
});
|
|
// 兼容某些场景下ready事件过早触发的问题
|
$(window).on('load', function() {
|
// 如果时间线仍然是空的,再尝试初始化一次
|
if (typeof OrderDetail !== 'undefined' && window.orderData && $('#orderTimeline').html().trim() === '') {
|
OrderDetail.initTimeline();
|
}
|
});
|