gz_car_ui/js/car_settlement/child/branch_settlement_detail.js

226 lines
6.8 KiB
JavaScript

let objParam;
let form, table, tableIns, layer, element;
let pageNum = 1;
function setParams(params) {
objParam = JSON.parse(params);
console.error(objParam);
$('#bmname').html(objParam.bmname);
layui.use(["form", "table", 'layer', 'element'], function () {
form = layui.form;
table = layui.table;
element = layui.element;
layer = layui.layer;
setDataView();
initTable();
});
}
// 数据概览
function setDataView() {
$('#proNum').html(objParam.porNum);
$('#planNum').html(objParam.planNum);
$('#needNum').html(objParam.needNum);
$('#carNum').html(objParam.carNum);
$('#dpcNum').html(objParam.dpcNum);
$('#money').html(objParam.money);
$('#payMoney').html(objParam.payMoney);
$('#noPayMoney').html(objParam.noPayMoney);
}
// 查询/重置
function queryTable(type) {
if (type === 1) {
let proName = $('#proName').val();
let flag = checkValue(proName);
if (flag) {
$('#proName').val('');
return layer.msg('工程名称查询包含特殊字符,请重新输入', { icon: 2 });
}
reloadTable(1);
} else if (type === 2) {
$('#proName').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({
'proName': $('#proName').val(),
'status': $('#status').val(),
'bmname': objParam.bmname
}),
},
},
);
}
// 初始化表格
function initTable() {
tableIns = table.render({
elem: "#currentTableId",
id: 'currentTableId',
headers: {
authorization: sessionStorage.getItem("gz-token"),
},
height: "full-250",
url: dataUrl + "backstage/carStatistics/getSltPageListByBmName",
where: {
encryptedData: JSON.stringify({
'proName': $('#proName').val(),
'status': $('#status').val(),
'bmname': objParam.bmname
}),
},
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: '6%',
title: "序号",
align: "center",
templet: function (d) {
return d.LAY_NUM;
},
},
{
field: "proName",
width: '14%',
title: "工程名称",
unresize: true,
align: "center",
sort: true,
},
{
field: "planNum",
width: '10%',
title: "需求计划数量",
unresize: true,
align: "center",
sort: true,
},
{
field: "needNum",
title: "申请用车数量",
width: '10%',
unresize: true,
align: "center",
sort: true,
},
{
field: "carNum",
title: "已派车数量",
width: '10%',
unresize: true,
align: "center",
sort: true,
},
{
field: "dpcNum",
title: "待派车数量",
width: '9%',
unresize: true,
align: "center",
sort: true,
},
{
field: "money",
width: '9%',
title: "应付金额",
unresize: true,
sort: true,
align: "center",
templet: function (d) {
return '<span> ¥ ' + (d.money ? d.money : 0) + '</span>';
},
},
{
field: "payMoney",
title: "已付金额",
width: '9.5%',
align: "center",
unresize: true,
sort: true,
templet: function (d) {
return '<span> ¥ ' + (d.payMoney ? d.payMoney : 0) + '</span>';
},
},
{
field: "noPayMoney",
title: "待付金额",
width: '9.5%',
align: "center",
unresize: true,
sort: true,
templet: function (d) {
return '<span> ¥ ' + (d.noPayMoney ? d.noPayMoney : 0) + '</span>';
},
},
{
title: "操作",
width: '13%',
align: "center",
unresize: true,
templet: function (d) {
let html = "";
html += "<a onclick='branchSettlementProDetail(" + JSON.stringify(d) + ")'>详情</a>";
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 exportExcel() {
let params = {
'proName': $('#proName').val(),
'status': $('#status').val(),
'bmname': objParam.bmname
}
let url = dataUrl + "backstage/carStatistics/export2";
exportExcelUtil(url, '分公司详情', JSON.stringify(params));
}
// 详情
function branchSettlementProDetail(obj, type) {
obj.type = type;
obj.bmname = objParam.bmname
openIframeByParamObj2("branchSettlementProDetail", "工程详情", "../car_settlement/child/branch_settlement_pro_detail.html", "92%", "95%", obj);
}