156 lines
6.3 KiB
JavaScript
156 lines
6.3 KiB
JavaScript
let objParam, dataObj;
|
|
let form, table, upload, tableIns, layer;
|
|
let pageNum = 1;
|
|
let checkNowValue = '';
|
|
let checkType = '';
|
|
function setParams(params) {
|
|
objParam = JSON.parse(params);
|
|
console.error(objParam);
|
|
$('#titleName').html(objParam.proName);
|
|
$('#code').html(objParam.code);
|
|
layui.use(["form", "table", 'upload', 'layer'], function () {
|
|
form = layui.form;
|
|
table = layui.table;
|
|
upload = layui.upload;
|
|
layer = layui.layer;
|
|
layui.use(["layer", 'element'], function () {
|
|
layer = layui.layer;
|
|
element = layui.element;
|
|
// tab 切换事件
|
|
element.on('tab(demo-filter-tab)', function (data) {
|
|
let value = $(this).attr('value');
|
|
if (value === '1') {
|
|
let src = '../car_demand_plan/child/apply_plan_detail.html';
|
|
if (objParam.code.indexOf('spec-') > -1) {
|
|
src = '../car_demand_plan/child/emerg_internal_car_detail.html';
|
|
}
|
|
$('#indexIframe').attr('src', src + '?isPage=1' + '&obj=' + encodeURIComponent(JSON.stringify(objParam)));
|
|
} else if (value === '2') {
|
|
let src = '../car_demand_plan/child/dispatch_input_detail.html';
|
|
$('#indexIframe').attr('src', src + '?isPage=1' + '&obj=' + encodeURIComponent(JSON.stringify(objParam)));
|
|
}
|
|
});
|
|
});
|
|
if (objParam.pageType === 1) { // 需求计划详情跳转
|
|
$('#layui-tab-title li').eq(0).addClass('layui-this');
|
|
let src = '../car_demand_plan/child/apply_plan_detail.html';
|
|
if (objParam.code.indexOf('spec-') > -1) {
|
|
src = '../car_demand_plan/child/emerg_internal_car_detail.html';
|
|
}
|
|
$('#indexIframe').attr('src', src + '?isPage=1' + '&obj=' + encodeURIComponent(JSON.stringify(objParam)));
|
|
} else if (objParam.pageType === 2) { // 派车详情跳转
|
|
$('#layui-tab-title li').eq(1).addClass('layui-this');
|
|
let src = '../car_demand_plan/child/dispatch_input_detail.html';
|
|
$('#indexIframe').attr('src', src + '?isPage=1' + '&obj=' + encodeURIComponent(JSON.stringify(objParam)));
|
|
}
|
|
});
|
|
}
|
|
|
|
// 查询派车批次
|
|
function getAllOutList() {
|
|
let params = {
|
|
encryptedData: JSON.stringify({
|
|
'planId': objParam.id,
|
|
})
|
|
};
|
|
let url = dataUrl + 'backstage/supDispatchCar/getAllOutList';
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
}, function (result) {
|
|
console.error(result);
|
|
if (result.code === 200) {
|
|
if (result.data.length === 0) {
|
|
parent.layer.msg('暂无派车批次数据', { icon: 7 });
|
|
closePage();
|
|
} else {
|
|
setBatchData(result.data);
|
|
}
|
|
} else {
|
|
}
|
|
}, function (xhr, status, error) {
|
|
errorFn(xhr, status, error)
|
|
}, null);
|
|
// 派车批次
|
|
function setBatchData(dataList) {
|
|
let html = '', id = '', status = '', type = '';
|
|
$.each(dataList, function (index, item) {
|
|
if (index === dataList.length - 1) {
|
|
id = item.id;
|
|
status = item.status;
|
|
type = item.type;
|
|
}
|
|
let batchName = '第' + numToChinese(index + 1) + '批次';
|
|
html += '<li value="' + item.id + '" status="' + item.status + '" type="' + item.type + '">' + batchName + '</li>';
|
|
})
|
|
$('#layui-tab-title').empty().append(html);
|
|
$('#layui-tab-title li').eq(dataList.length - 1).addClass('layui-this');
|
|
var scrollableElement = document.getElementById('layui-tab-brief');
|
|
// 添加事件监听器来处理滚轮事件
|
|
scrollableElement.addEventListener('wheel', function (event) {
|
|
// 阻止默认的滚动行为
|
|
event.preventDefault();
|
|
// 检查滚动的方向
|
|
var delta = event.deltaY > 0 ? -20 : 20; // 根据需要调整滚动的步长
|
|
// 设置新的滚动位置
|
|
scrollableElement.scrollLeft += delta;
|
|
});
|
|
checkNowValue = id;
|
|
checkType = type;
|
|
getUpdateList(id);
|
|
}
|
|
}
|
|
|
|
// 查询每个批次的修改记录
|
|
function getUpdateList(outId) {
|
|
let params = {
|
|
encryptedData: JSON.stringify({
|
|
planId: objParam.id,
|
|
outId: outId
|
|
})
|
|
};
|
|
let url = dataUrl + 'backstage/dispatchCar/getUpdateList';
|
|
ajaxRequest(url, "POST", params, true, function () {
|
|
}, function (result) {
|
|
console.error(result);
|
|
if (result.code === 200) {
|
|
getShipmentBatch(result.data);
|
|
}
|
|
}, function (xhr, status, error) {
|
|
errorFn(xhr, status, error)
|
|
}, null);
|
|
}
|
|
|
|
// 修改记录次数
|
|
function getShipmentBatch(list) {
|
|
let dataList = [], html = '';
|
|
if (list && list.length > 0) {
|
|
$.each(list, function (index, item) {
|
|
if (index === 0) {
|
|
dataList.push({ name: '初始派车数据', id: item.id, color: '', isInit: true })
|
|
} else {
|
|
dataList.push({ name: '第' + numToChinese(index) + '次修改', id: item.id, color: '#f56c6c', isInit: false })
|
|
}
|
|
});
|
|
}
|
|
$.each(dataList, function (index, item) {
|
|
html += '<li value="' + item.id + '" type="' + checkType + '" style="color:' + item.color + '" isInit=' + item.isInit + '>' + this.name + '</li>';
|
|
})
|
|
$('#layui-tab-title2').empty().append(html);
|
|
$('#layui-tab-title2 li').eq(0).addClass('layui-this');
|
|
var scrollableElement = document.getElementById('layui-tab-brief');
|
|
// 添加事件监听器来处理滚轮事件
|
|
scrollableElement.addEventListener('wheel', function (event) {
|
|
// 阻止默认的滚动行为
|
|
event.preventDefault();
|
|
// 检查滚动的方向
|
|
var delta = event.deltaY > 0 ? -20 : 20; // 根据需要调整滚动的步长
|
|
// 设置新的滚动位置
|
|
scrollableElement.scrollLeft += delta;
|
|
});
|
|
$('#indexIframe').attr('src', './dispatch_car_edit_record_detail.html?id=' + dataList[0].id + '&type=' + checkType + '&code=' + objParam.code + '&isInit=' + dataList[0].isInit);
|
|
}
|
|
|
|
// 关闭页面
|
|
function closePage(type) {
|
|
let index = parent.layer.getFrameIndex(window.name); // 先得到当前 iframe层的索引
|
|
parent.layer.close(index); // 再执行关闭
|
|
} |