gz_car_ui/js/car_basic/child/driver_re_detail.js

257 lines
7.5 KiB
JavaScript
Raw Normal View History

let objParam;
let form, table, tableIns, layer, element;
let pageNum = 1;
function setParams(params) {
objParam = JSON.parse(params);
layui.use(["form", "table", 'layer', 'element'], function () {
form = layui.form;
table = layui.table;
element = layui.element;
layer = layui.layer;
initTable();
});
}
// 查询/重置
function queryTable(type) {
if (type === 1) {
let code = $('#code').val();
let flag = checkValue(code);
if (flag) {
$('#code').val('');
return layer.msg('需求计划编号查询包含特殊字符,请重新输入', { icon: 2 });
}
reloadTable(1);
} else if (type === 2) {
$('#code').val('');
$('#status').val('');
layui.form.render();
reloadTable(1);
}
}
// 刷新页面数据
function reloadData() {
reloadTable(pageNum);
}
// 重载表格
function reloadTable(pageNum) {
table.reload("currentTableId", {
page: {
curr: pageNum ? pageNum : 1,
},
where: {
encryptedData: JSON.stringify({
'code': $('#code').val(),
'status': $('#status').val(),
'proId': objParam.proId
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
2025-07-14 18:45:42 +08:00
height: "full-30",
url: dataUrl + "backstage/carDriver/getRePlan",
where: {
encryptedData: JSON.stringify({
'id': objParam.id
}),
},
request: {
pageName: 'pageNum',
limitName: 'pageSize'
},
parseData: function (res) { // res 即为原始返回的数据
if (res.code === 401) {
closeWindowOpen();
}
return {
"code": 0, // 解析接口状态
"msg": '获取成功', // 解析提示文本
"count": res.total, // 解析数据长度
"data": res.list // 解析数据列表
};
},
cols: [
[
{
width: '5%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "typeName",
2025-07-14 18:45:42 +08:00
width: '10%',
title: "计划类型",
unresize: true,
align: "center",
},
{
field: "code",
2025-07-14 18:45:42 +08:00
width: '10%',
title: "需求计划编号",
unresize: true,
align: "center",
templet: function (d) {
return "<a style='color:#409eff;' onclick='viewPlanDetail(" + JSON.stringify(d) + ")'>" + d.code + "</a>";
},
},
2025-07-14 18:45:42 +08:00
{
field: "proName",
width: '20%',
title: "工程名称",
unresize: true,
align: "center",
},
{
field: "userName",
2025-07-14 18:45:42 +08:00
width: '10%',
title: "申请人",
unresize: true,
align: "center",
},
{
field: "appLyTime",
title: "申请时间",
2025-07-14 18:45:42 +08:00
width: '10%',
unresize: true,
align: "center",
sort:true,
},
{
2025-07-14 18:45:42 +08:00
field: "outTime",
title: "派车日期",
width: '10%',
unresize: true,
align: "center",
sort:true,
},
2025-07-14 18:45:42 +08:00
{
field: "model",
title: "车辆类型",
width: '14%',
unresize: true,
align: "center",
},
{
field: "licensePlate",
title: "车牌号",
width: '10%',
unresize: true,
align: "center",
},
],
],
limits: [10, 15, 20, 25, 50, 100],
limit: 10,
page: true,
done: function (res, curr, count) {
pageNum = tableIns.config.page.curr;
table.resize("currentTableId");
},
});
}
// 导出
function exportExcel() {
let params = {
'planCode': $('#planCode').val(),
'status': $('#status').val(),
'proId': objParam.proId
}
let url = dataUrl + "backstage/purchase/exportDetails";
exportExcelUtil(url, '需求计划详情', JSON.stringify(params));
}
// 详情
function dispatchCarDetail(obj, type) {
let flag = isExistData(type, obj);
if (!flag && type === 1) {
return layer.msg('暂无派车批次数据', { icon: 7 });
} else if (!flag && type === 2) {
return layer.msg('暂无待审核批次数据', { icon: 7 });
}
let title = '详情';
if (type === 2) {
title = '审核';
}
obj.type = type;
2025-07-08 16:29:36 +08:00
openIframeByParamObj2("dispatchCarDetail", title, "../car_demand_plan/child/dispatch_car_detail.html", "92%", "95%", obj);
}
// 修改记录
function editRecord(obj) {
let flag = isExistData(3, obj);
if (!flag) {
return layer.msg('暂无派车批次数据', { icon: 7 });
}
openIframeByParamObj2("editRecord", "修改记录", "../car_demand_plan/child/dispatch_car_edit_record_list.html", "92%", "95%", obj);
}
// 派车分配
function dispatchCarAllocation(obj) {
openIframeByParamObj("dispatchCarAllocation", "派车分配", "./dispatch_car_allocation_form.html", "92%", "95%", obj);
}
// 刷新页面数据
function refreshAllData() {
getProStatisticsDetails();
reloadData();
}
// 需求计划详情
function viewPlanDetail(obj) {
openIframeByParamObj2("viewPlanDetail", "需求计划详情", "../car_demand_plan/child/apply_plan_detail.html", "92%", "95%", obj);
}
// 分配错误修改
function allocationError() {
openIframeByParamObj("allocationError", "分配错误修改", "./allocation_error_form.html", "50%", "65%", objParam);
}
// 校验是否存在派车批次数据、待审核批次数据
function isExistData(type, obj) {
let flag = true;
let params = {
encryptedData: JSON.stringify({
'planId': obj.id,
})
};
let url = ''
if (type === 1 || type === 3) {
url = dataUrl + 'backstage/supDispatchCar/getAllOutList'; // 详情-派车批次
} else if (type === 2) { // 审核-待审核批次
url = dataUrl + 'backstage/dispatchCar/getAuditListNew';
}
ajaxRequest(url, "POST", params, false, function () {
}, function (result) {
if (result.code === 200) {
if (result.data.length === 0 && (type === 1 || type === 3)) {
flag = false;
} else if (result.data.length === 0 && type === 2) {
flag = false;
}
} else {
}
}, function (xhr, status, error) {
errorFn(xhr, status, error)
}, null);
return flag;
2025-07-08 16:29:36 +08:00
}