let objParam; let form, table, tableIns, layer, element; let pageNum = 1; function setParams(params) { objParam = JSON.parse(params); $('#proName').html(objParam.proName); $('#bmname').html(objParam.companyName); layui.use(["form", "table", 'layer', 'element'], function () { form = layui.form; table = layui.table; element = layui.element; layer = layui.layer; getProPlanDataView(); initTable(); }); } // 数据概览 function getProPlanDataView() { let params = { encryptedData: JSON.stringify({ proId: objParam.proId }) }; let url = dataUrl + 'backstage/homeIndex/getProPlanDataView'; ajaxRequest(url, "POST", params, true, function () { }, function (result) { if (result.code === 200) { setNum(result.data); } }, function (xhr, status, error) { errorFn(xhr, status, error) }, null); // 数据概览赋值 function setNum(obj) { $('.layui-progress').remove(); $('#planNum').html(obj.planNum); $('#carNum').html(obj.carNum); $('#craneNum').html(obj.craneNum); $('#money').html('¥ ' + objParam.money); $('.layui-progress').remove(); $("#progress").after(`
`); element.render(); } } // 查询/重置 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(''); $('#dispatchStatus').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(), 'dispatchStatus': $('#dispatchStatus').val(), 'proId': objParam.proId }), }, }, ); } // 初始化表格 function initTable() { tableIns = table.render({ elem: "#currentTableId", id: 'currentTableId', headers: { authorization: sessionStorage.getItem("gz-token"), }, height: "full-250", url: dataUrl + "backstage/homeIndex/getProPlanDetails", where: { encryptedData: JSON.stringify({ 'code': $('#code').val(), 'dispatchStatus': $('#dispatchStatus').val(), 'proId': objParam.proId }), }, 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.9%', title: "序号", align: "center", templet: function (d) { return d.LAY_NUM; }, }, { field: "typeName", width: '10%', title: "类型", unresize: true, align: "center", sort: true, templet: function (d) { return d.typeName === 1 ? '车辆' : '吊车' }, }, { field: "code", width: '12%', title: "需求计划编号", unresize: true, align: "center", sort: true, templet: function (d) { return "" + d.code + ""; }, }, { field: "userName", width: '10%', title: "申请人", unresize: true, align: "center", sort: true, }, { field: "applyTime", title: "申请时间", width: '10%', unresize: true, align: "center", sort: true, }, { field: "remark", title: "备注", width: '12%', unresize: true, align: "center", sort: true, templet: function (d) { if (d.remark) { if (d.remark.length > 60) { return '' + d.remark.substring(0, 60) + '...' } else { return '' + d.remark + '' } } else { return ''; } }, }, { field: "statusName", title: "派车状态", width: '10%', unresize: true, align: "center", sort: true, templet: function (d) { return setStatusColor(d.dispatchStatus); }, }, { field: "dispatchNum", width: '10%', title: "派车数量", unresize: true, align: "center", sort: true, }, { field: "money", title: "采购金额", width: '10%', align: "center", unresize: true, sort: true, templet: function (d) { return '¥ ' + d.money + '' }, }, { title: "操作", width: '10%', align: "center", unresize: true, templet: function (d) { let html = ""; html += "详情"; return html; }, }, ], ], 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 setStatusColor(value) { let color = "#409Eff"; let name = '' if (value === '1') { color = "#f56c6c"; name = '待派车'; } else if (value === '2') { color = "#19be6b"; name = '已派车' } return '' + name + ''; } // 需求计划详情 function viewPlanDetail(obj) { obj.id = obj.planId; let content = '../car_demand_plan/child/apply_plan_detail.html'; if (obj.code.indexOf('spec-') > -1) { content = '../car_demand_plan/child/emerg_internal_car_detail.html'; } openIframeByParamObj2("viewPlanDetail2", "需求计划详情", content, "92%", "95%", obj); } // 导出 function exportExcel() { let params = { 'code': $('#code').val(), 'dispatchStatus': $('#dispatchStatus').val(), 'proId': objParam.proId } let url = dataUrl + "backstage/homeIndex/exportProPlanDetails"; exportExcelUtil(url, '需求计划详情', JSON.stringify(params)); } // 详情 function dispatchCarDetail(obj, type) { obj.id = obj.planId; obj.pageType = 1; obj.typeName = obj.typeName === 1 ? '车辆' : '吊车'; obj.proName = objParam.proName; openIframeByParamObj2("homePlanDetail", "详情", '../welcome/plan_dispatch_detail.html', "92%", "95%", obj); }